summaryrefslogtreecommitdiff
path: root/configure.in
diff options
context:
space:
mode:
authorTom Lane2015-01-14 16:08:17 +0000
committerTom Lane2015-01-14 16:08:17 +0000
commitadb355106891ff318ca284f0cae3a993eef96185 (patch)
tree5aa9106f7a68bfa63f36eb27ca917af5142802ad /configure.in
parent045c7d3ebd413c501904233664825df5c1d955d7 (diff)
Allow CFLAGS from configure's environment to override automatic CFLAGS.
Previously, configure would add any switches that it chose of its own accord to the end of the user-specified CFLAGS string. Since most compilers process these left-to-right, this meant that configure's choices would override the user-specified flags in case of conflicts. We'd rather that worked the other way around, so adjust the logic to put the user's string at the end not the beginning. There does not seem to be a need for a similar behavior change for CPPFLAGS or LDFLAGS: in those, the earlier switches tend to win (think -I or -L behavior) so putting the user's string at the front is fine. Backpatch to 9.4 but not earlier. I'm not planning to run buildfarm member guar on older branches, and it seems a bit risky to change this behavior in long-stable branches.
Diffstat (limited to 'configure.in')
-rw-r--r--configure.in13
1 files changed, 11 insertions, 2 deletions
diff --git a/configure.in b/configure.in
index 882d542b701..f518b556450 100644
--- a/configure.in
+++ b/configure.in
@@ -409,6 +409,10 @@ else
fi
fi
+# CFLAGS we determined above will be added back at the end
+user_CFLAGS=$CFLAGS
+CFLAGS=""
+
# set CFLAGS_VECTOR from the environment, if available
if test "$ac_env_CFLAGS_VECTOR_set" = set; then
CFLAGS_VECTOR=$ac_env_CFLAGS_VECTOR_value
@@ -420,7 +424,7 @@ fi
# but has its own. Also check other compiler-specific flags here.
if test "$GCC" = yes -a "$ICC" = no; then
- CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wpointer-arith"
+ CFLAGS="-Wall -Wmissing-prototypes -Wpointer-arith"
# These work in some but not all gcc versions
PGAC_PROG_CC_CFLAGS_OPT([-Wdeclaration-after-statement])
PGAC_PROG_CC_CFLAGS_OPT([-Wendif-labels])
@@ -483,7 +487,12 @@ if test "$PORTNAME" = "win32"; then
CPPFLAGS="$CPPFLAGS -I$srcdir/src/include/port/win32 -DEXEC_BACKEND"
fi
-# Check if the compiler still works with the template settings
+# Now that we're done automatically adding stuff to CFLAGS, put back the
+# user-specified flags (if any) at the end. This lets users override
+# the automatic additions.
+CFLAGS="$CFLAGS $user_CFLAGS"
+
+# Check if the compiler still works with the final flag settings
AC_MSG_CHECKING([whether the C compiler still works])
AC_TRY_LINK([], [return 0;],
[AC_MSG_RESULT(yes)],