Skip to contentSkip to conversation

configure: Append extra cflags and ldflags

PATCH Superseded Jan Kiszka 3 participants 4 messages Jun 15, 2009 – Jun 16, 2009

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 configure: Append extra cflags and ldflags

In order to allow overriding flags that are set by configure, we have to append them instead of prepending as it is done so far.

---

 configure |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
configure +4 -4
index 85bc598..eb687bf 100755
@@ -380,9 +380,9 @@ for opt do
   ;;
   --install=*) install="$optarg"
   ;;
-  --extra-cflags=*) CFLAGS="$optarg"
+  --extra-cflags=*) EXTRA_CFLAGS="$optarg"
   ;;
-  --extra-ldflags=*) LDFLAGS="$optarg"
+  --extra-ldflags=*) EXTRA_LDFLAGS="$optarg"
   ;;
   --cpu=*) cpu="$optarg"
   ;;
@@ -1432,8 +1432,8 @@ echo "OS_CFLAGS=$OS_CFLAGS" >> $config_mak
 echo "OS_LDFLAGS=$OS_LDFLAGS" >> $config_mak
 echo "ARCH_CFLAGS=$ARCH_CFLAGS" >> $config_mak
 echo "ARCH_LDFLAGS=$ARCH_LDFLAGS" >> $config_mak
-echo "CFLAGS=$CFLAGS" >> $config_mak
-echo "LDFLAGS=$LDFLAGS" >> $config_mak
+echo "CFLAGS=$CFLAGS $EXTRA_CFLAGS" >> $config_mak
+echo "LDFLAGS=$LDFLAGS $EXTRA_LDFLAGS" >> $config_mak
 echo "EXESUF=$EXESUF" >> $config_mak
 echo "PTHREADLIBS=$PTHREADLIBS" >> $config_mak
 echo "CLOCKLIBS=$CLOCKLIBS" >> $config_mak
#1 lore raw
Quoted 2 lines · Jan Kiszka

In order to allow overriding flags that are set by configure, we have to
append them instead of prepending as it is done so far.

The help message from configure does not mention about overriding but adding flags. Which one is this?

author
#2 lore raw
Quoted 6 lines · Blue Swirl
Quoted 2 lines · Jan Kiszka

In order to allow overriding flags that are set by configure, we have to
append them instead of prepending as it is done so far.

The help message from configure does not mention about overriding but adding flags. Which one is this?

I didn't derive this from the help, but from common practice when using EXTRA_* flags and the fact the gcc switches that come last override what comes first. Without the patch, adding your personal -W* switches to the build is impossible when they collide with some set by configure.

Jan

#3 lore raw
In reply to Jan Kiszka
Quoted 3 lines · Jan Kiszka

In order to allow overriding flags that are set by configure, we have to append them instead of prepending as it is done so far.

Ah, this is useful for -O0 when debugging.

Signature · 1 line
error compiling committee.c: too many arguments to function