aboutsummaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2012-06-09 22:42:24 -0700
committerMark Adler <madler@alumni.caltech.edu>2012-06-09 23:17:07 -0700
commitbfac1564633d0f0184369fd152e5c8b46c1137ca (patch)
treee4054e0d07480d7c9de47cb745c78f01c809d043 /configure
parent977e1080472337420e576130d576099bc0cad4c9 (diff)
downloadzlib-bfac1564633d0f0184369fd152e5c8b46c1137ca.tar.gz
zlib-bfac1564633d0f0184369fd152e5c8b46c1137ca.tar.bz2
zlib-bfac1564633d0f0184369fd152e5c8b46c1137ca.zip
Fix configure check for veracity of compiler error return codes.
There were two problems before that this fixes. One was that the check for the compiler error return code preceded the determination of the compiler and its options. The other was that the checks for compiler and library characteristics could be fooled if the error options were set to reject K&R-style C. configure now aborts if the compiler produces a hard error on K&R-style C. In addition, aborts of configure are now consistent, and remove any temporary files.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure143
1 files changed, 85 insertions, 58 deletions
diff --git a/configure b/configure
index 8876707..a69d7bf 100755
--- a/configure
+++ b/configure
@@ -77,6 +77,19 @@ old_cflags="$CFLAGS"
77OBJC='$(OBJZ) $(OBJG)' 77OBJC='$(OBJZ) $(OBJG)'
78PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)' 78PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)'
79 79
80# leave this script, optionally in a bad way
81leave()
82{
83 if test "$*" != "0"; then
84 echo "** $0 aborting." | tee -a configure.log
85 fi
86 rm -f $test.[co] $test $test$shared_ext $test.gcno ./--version
87 echo -------------------- >> configure.log
88 echo >> configure.log
89 echo >> configure.log
90 exit $1
91}
92
80# process command line options 93# process command line options
81while test $# -ge 1 94while test $# -ge 1
82do 95do
@@ -106,13 +119,17 @@ case "$1" in
106 -a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;; 119 -a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
107 --sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;; 120 --sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;;
108 --localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;; 121 --localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;;
109 *) echo "unknown option: $1"; echo "$0 --help for help" | tee -a configure.log; exit 1 ;; 122 *)
123 echo "unknown option: $1" | tee -a configure.log
124 echo "$0 --help for help" | tee -a configure.log
125 leave 1;;
110 esac 126 esac
111done 127done
112 128
113# define functions for testing compiler and library characteristics and logging the results 129# temporary file name
114test=ztest$$ 130test=ztest$$
115 131
132# put arguments in log, also put test file in log if used in arguments
116show() 133show()
117{ 134{
118 case "$*" in 135 case "$*" in
@@ -124,43 +141,6 @@ show()
124 echo $* >> configure.log 141 echo $* >> configure.log
125} 142}
126 143
127cat > $test.c <<EOF
128#error error
129EOF
130if ($CC -c $CFLAGS $test.c) 2>/dev/null; then
131 try()
132 {
133 show $*
134 test "`( $* ) 2>&1 | tee -a configure.log`" = ""
135 }
136 echo - using any output from compiler to indicate an error >> configure.log
137else
138 try()
139 {
140 show $*
141 ( $* ) >> configure.log 2>&1
142 ret=$?
143 if test $ret -ne 0; then
144 echo "(exit code "$ret")" >> configure.log
145 fi
146 return $ret
147 }
148fi
149
150tryboth()
151{
152 show $*
153 got=`( $* ) 2>&1`
154 ret=$?
155 printf %s "$got" >> configure.log
156 if test $ret -ne 0; then
157 return $ret
158 fi
159 test "$got" = ""
160}
161
162echo >> configure.log
163
164# check for gcc vs. cc and set compile and link flags based on the system identified by uname 144# check for gcc vs. cc and set compile and link flags based on the system identified by uname
165cat > $test.c <<EOF 145cat > $test.c <<EOF
166extern int getchar(); 146extern int getchar();
@@ -179,8 +159,8 @@ case `$cc -v 2>&1` in
179 *gcc*) gcc=1 ;; 159 *gcc*) gcc=1 ;;
180esac 160esac
181 161
182show $cc -c $cflags $test.c 162show $cc -c $test.c
183if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) >> configure.log 2>&1; then 163if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
184 echo ... using gcc >> configure.log 164 echo ... using gcc >> configure.log
185 CC="$cc" 165 CC="$cc"
186 CFLAGS="${CFLAGS--O3} ${ARCHS}" 166 CFLAGS="${CFLAGS--O3} ${ARCHS}"
@@ -208,7 +188,7 @@ if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) >> configure.log 2>&1; then
208# temporary bypass 188# temporary bypass
209 rm -f $test.[co] $test $test$shared_ext 189 rm -f $test.[co] $test $test$shared_ext
210 echo "Please use win32/Makefile.gcc instead." | tee -a configure.log 190 echo "Please use win32/Makefile.gcc instead." | tee -a configure.log
211 exit 1 191 leave 1
212 LDSHARED=${LDSHARED-"$cc -shared"} 192 LDSHARED=${LDSHARED-"$cc -shared"}
213 LDSHAREDLIBC="" 193 LDSHAREDLIBC=""
214 EXE='.exe' ;; 194 EXE='.exe' ;;
@@ -338,7 +318,59 @@ SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
338 318
339echo >> configure.log 319echo >> configure.log
340 320
321# define functions for testing compiler and library characteristics and logging the results
322
323cat > $test.c <<EOF
324#error error
325EOF
326if ($CC -c $CFLAGS $test.c) 2>/dev/null; then
327 try()
328 {
329 show $*
330 test "`( $* ) 2>&1 | tee -a configure.log`" = ""
331 }
332 echo - using any output from compiler to indicate an error >> configure.log
333else
334try()
335{
336 show $*
337 ( $* ) >> configure.log 2>&1
338 ret=$?
339 if test $ret -ne 0; then
340 echo "(exit code "$ret")" >> configure.log
341 fi
342 return $ret
343}
344fi
345
346tryboth()
347{
348 show $*
349 got=`( $* ) 2>&1`
350 ret=$?
351 printf %s "$got" >> configure.log
352 if test $ret -ne 0; then
353 return $ret
354 fi
355 test "$got" = ""
356}
357
358cat > $test.c << EOF
359int foo() { return 0; }
360EOF
361echo "Checking for obsessive-compulsive compiler options..." >> configure.log
362if ! try $CC -c $CFLAGS $test.c; then
363 echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log
364 leave 1
365fi
366
367echo >> configure.log
368
341# see if shared library build supported 369# see if shared library build supported
370cat > $test.c <<EOF
371extern int getchar();
372int hello() {return getchar();}
373EOF
342if test $shared -eq 1; then 374if test $shared -eq 1; then
343 echo Checking for shared library support... | tee -a configure.log 375 echo Checking for shared library support... | tee -a configure.log
344 # we must test in two steps (cc then ld), required at least on SunOS 4.x 376 # we must test in two steps (cc then ld), required at least on SunOS 4.x
@@ -366,8 +398,6 @@ else
366 TEST="all teststatic testshared" 398 TEST="all teststatic testshared"
367fi 399fi
368 400
369echo >> configure.log
370
371# check for underscores in external names for use by assembler code 401# check for underscores in external names for use by assembler code
372CPP=${CPP-"$CC -E"} 402CPP=${CPP-"$CC -E"}
373case $CFLAGS in 403case $CFLAGS in
@@ -709,14 +739,14 @@ cat > $test.c <<EOF
709#include <stdio.h> 739#include <stdio.h>
710#define is32(n,t) for(n=1,k=0;n;n<<=1,k++);if(k==32){puts(t);return 0;} 740#define is32(n,t) for(n=1,k=0;n;n<<=1,k++);if(k==32){puts(t);return 0;}
711int main() { 741int main() {
712 int k; 742 int k;
713 unsigned i; 743 unsigned i;
714 unsigned long l; 744 unsigned long l;
715 unsigned short s; 745 unsigned short s;
716 is32(i, "unsigned") 746 is32(i, "unsigned")
717 is32(l, "unsigned long") 747 is32(l, "unsigned long")
718 is32(s, "unsigned short") 748 is32(s, "unsigned short")
719 return 1; 749 return 1;
720} 750}
721EOF 751EOF
722Z_U4="" 752Z_U4=""
@@ -728,9 +758,6 @@ else
728 echo "Looking for a four-byte integer type... Not found." | tee -a configure.log 758 echo "Looking for a four-byte integer type... Not found." | tee -a configure.log
729fi 759fi
730 760
731# clean up files produced by running the compiler and linker
732rm -f $test.[co] $test $test$shared_ext $test.gcno ./--version
733
734# show the results in the log 761# show the results in the log
735echo >> configure.log 762echo >> configure.log
736echo ALL = $ALL >> configure.log 763echo ALL = $ALL >> configure.log
@@ -762,9 +789,6 @@ echo mandir = $mandir >> configure.log
762echo prefix = $prefix >> configure.log 789echo prefix = $prefix >> configure.log
763echo sharedlibdir = $sharedlibdir >> configure.log 790echo sharedlibdir = $sharedlibdir >> configure.log
764echo uname = $uname >> configure.log 791echo uname = $uname >> configure.log
765echo -------------------- >> configure.log
766echo >> configure.log
767echo >> configure.log
768 792
769# udpate Makefile with the configure results 793# udpate Makefile with the configure results
770sed < Makefile.in " 794sed < Makefile.in "
@@ -820,3 +844,6 @@ sed < zlib.pc.in "
820" | sed -e " 844" | sed -e "
821s/\@VERSION\@/$VER/g; 845s/\@VERSION\@/$VER/g;
822" > zlib.pc 846" > zlib.pc
847
848# done
849leave 0