From 2d55657c0341238eb9d6fd8d545bcd7efade5ed8 Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Mon, 16 Jan 2012 14:50:09 -0800 Subject: Have ./configure use the compiler return code for error indication. Previously ./configure would use any output on stderr as an indication that the compilation failed. However if some compiler wrapper uses stderr for some other purpose, e.g. distcc for nodes going down, then ./configure would not properly configure the build. This problem was noted by Mike Frysinger. For backwards compatibility, ./configure will revert to the old way, i.e. checking for anything on stderr, if when it deliberately runs the compiler with an error, a zero exit status is returned. --- configure | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) (limited to 'configure') diff --git a/configure b/configure index 5a5a488..84fa5a3 100755 --- a/configure +++ b/configure @@ -97,6 +97,22 @@ case "$1" in done test=ztest$$ + +cat > $test.c </dev/null; then + try() + { + test "`( $* ) 2>&1`" = "" + } +else + try() + { + ( $* ) 2>/dev/null + } +fi + cat > $test.c <&1`" = "" && - test "`($LDSHARED $SFLAGS -o $test$shared_ext $test.o) 2>&1`" = ""; then + if try $CC -w -c $SFLAGS $test.c && + try $LDSHARED $SFLAGS -o $test$shared_ext $test.o; then echo Building shared library $SHAREDLIBV with $CC. elif test -z "$old_cc" -a -z "$old_cflags"; then echo No shared library support. @@ -281,7 +297,7 @@ cat > $test.c < off64_t dummy = 0; EOF -if test "`($CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c) 2>&1`" = ""; then +if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1" SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1" ALL="${ALL} all64" @@ -297,7 +313,7 @@ int main(void) { return 0; } EOF - if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then + if try $CC $CFLAGS -o $test $test.c; then echo "Checking for fseeko... Yes." else CFLAGS="${CFLAGS} -DNO_FSEEKO" @@ -312,7 +328,7 @@ cat > $test.c < int main() { return 0; } EOF -if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then +if try $CC -c $CFLAGS $test.c; then sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h mv zconf.temp.h zconf.h echo "Checking for unistd.h... Yes." @@ -324,7 +340,7 @@ cat > $test.c < int main() { return 0; } EOF -if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then +if try $CC -c $CFLAGS $test.c; then sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h mv zconf.temp.h zconf.h echo "Checking for stdarg.h... Yes." @@ -367,7 +383,7 @@ int main() } EOF -if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then +if try $CC -c $CFLAGS $test.c; then echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." cat > $test.c <&1`" = ""; then + if try $CC $CFLAGS -o $test $test.c; then echo "Checking for vsnprintf() in stdio.h... Yes." cat >$test.c <&1`" = ""; then + if try $CC -c $CFLAGS $test.c; then echo "Checking for return value of vsnprintf()... Yes." else CFLAGS="$CFLAGS -DHAS_vsnprintf_void" @@ -455,7 +471,7 @@ int main() } EOF - if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then + if try $CC -c $CFLAGS $test.c; then echo "Checking for return value of vsprintf()... Yes." else CFLAGS="$CFLAGS -DHAS_vsprintf_void" @@ -486,7 +502,7 @@ int main() } EOF - if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then + if try $CC $CFLAGS -o $test $test.c; then echo "Checking for snprintf() in stdio.h... Yes." cat >$test.c <&1`" = ""; then + if try $CC -c $CFLAGS $test.c; then echo "Checking for return value of snprintf()... Yes." else CFLAGS="$CFLAGS -DHAS_snprintf_void" @@ -539,7 +555,7 @@ int main() } EOF - if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then + if try $CC -c $CFLAGS $test.c; then echo "Checking for return value of sprintf()... Yes." else CFLAGS="$CFLAGS -DHAS_sprintf_void" @@ -565,7 +581,7 @@ int main() return 0; } EOF - if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then + if try $CC -c $CFLAGS $test.c; then echo "Checking for attribute(visibility) support... Yes." else CFLAGS="$CFLAGS -DNO_VIZ" -- cgit v1.2.3-55-g6feb