Configure: always respect C compiler options.
Previously, auto/cc/* and auto/include didn't respect C compiler options
provided via --with-cc-opt and/or CFLAGS, which resulted in bogus errors
when path to system headers and libraries was defined via --sysroot.
While there, retain working GCC's -pipe for autotests.
Change-Id: Ie097ef25278d924b60204fb453b6a540738cb86f
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Reviewed-on: https://nginx-review.googlesource.com/1009
Reviewed-by: Martin Maly <mmaly@google.com>
diff --git a/auto/cc/acc b/auto/cc/acc
index 6baee67..65bc0c1 100644
--- a/auto/cc/acc
+++ b/auto/cc/acc
@@ -8,7 +8,7 @@
# C89 mode
CFLAGS="$CFLAGS -Ae"
-CC_TEST_FLAGS="-Ae"
+CC_TEST_FLAGS="$CC_TEST_FLAGS -Ae"
PCRE_OPT="$PCRE_OPT -Ae"
ZLIB_OPT="$ZLIB_OPT -Ae"
diff --git a/auto/cc/clang b/auto/cc/clang
index 25707b4..2b8d346 100644
--- a/auto/cc/clang
+++ b/auto/cc/clang
@@ -13,7 +13,7 @@
have=NGX_COMPILER value="\"clang $NGX_CLANG_VER\"" . auto/define
-CC_TEST_FLAGS="-pipe"
+CC_TEST_FLAGS="$CC_TEST_FLAGS -pipe"
# optimizations
diff --git a/auto/cc/conf b/auto/cc/conf
index edc6d74..58f54d4 100644
--- a/auto/cc/conf
+++ b/auto/cc/conf
@@ -29,12 +29,12 @@
ngx_long_regex_cont=$ngx_regex_cont
ngx_long_cont=$ngx_cont
+CC_TEST_FLAGS="$CFLAGS $NGX_CC_OPT"
+
. auto/cc/name
if test -n "$CFLAGS"; then
- CC_TEST_FLAGS="$CFLAGS $NGX_CC_OPT"
-
case $NGX_CC_NAME in
ccc)
@@ -129,8 +129,6 @@
esac
- CC_TEST_FLAGS="$CC_TEST_FLAGS $NGX_CC_OPT"
-
fi
CFLAGS="$CFLAGS $NGX_CC_OPT"
diff --git a/auto/cc/gcc b/auto/cc/gcc
index c9101fe..63df2f8 100644
--- a/auto/cc/gcc
+++ b/auto/cc/gcc
@@ -18,7 +18,7 @@
# Solaris 7's /usr/ccs/bin/as does not support "-pipe"
-CC_TEST_FLAGS="-pipe"
+CC_TEST_FLAGS="$CC_TEST_FLAGS -pipe"
ngx_feature="gcc -pipe switch"
ngx_feature_name=
@@ -29,10 +29,10 @@
ngx_feature_test=
. auto/feature
-CC_TEST_FLAGS=
-
if [ $ngx_found = yes ]; then
PIPE="-pipe"
+else
+ CC_TEST_FLAGS="$CFLAGS $NGX_CC_OPT"
fi
diff --git a/auto/include b/auto/include
index e34dabd..6a17191 100644
--- a/auto/include
+++ b/auto/include
@@ -27,7 +27,8 @@
END
-ngx_test="$CC -o $NGX_AUTOTEST $NGX_AUTOTEST.c"
+ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
+ -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT"
eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"