@@ -77,6 +77,19 @@ old_cflags="$CFLAGS"
7777OBJC=' $(OBJZ) $(OBJG)'
7878PIC_OBJC=' $(PIC_OBJZ) $(PIC_OBJG)'
7979
80+ # leave this script, optionally in a bad way
81+ leave ()
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+
8093# process command line options
8194while test $# -ge 1
8295do
@@ -106,13 +119,17 @@ case "$1" in
106119 -a* =* | --archs=* ) ARCHS=` echo $1 | sed ' s/.*=//' ` ; shift ;;
107120 --sysconfdir=* ) echo " ignored option: --sysconfdir" | tee -a configure.log; shift ;;
108121 --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;;
110126 esac
111127done
112128
113- # define functions for testing compiler and library characteristics and logging the results
129+ # temporary file name
114130test=ztest$$
115131
132+ # put arguments in log, also put test file in log if used in arguments
116133show ()
117134{
118135 case " $* " in
@@ -124,43 +141,6 @@ show()
124141 echo $* >> configure.log
125142}
126143
127- cat > $test .c << EOF
128- #error error
129- EOF
130- if ($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
137- else
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- }
148- fi
149-
150- tryboth ()
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-
162- echo >> configure.log
163-
164144# check for gcc vs. cc and set compile and link flags based on the system identified by uname
165145cat > $test .c << EOF
166146extern int getchar();
@@ -179,8 +159,8 @@ case `$cc -v 2>&1` in
179159 * gcc* ) gcc=1 ;;
180160esac
181161
182- show $cc -c $cflags $ test .c
183- if test " $gcc " -eq 1 && ($cc -c $cflags $ test .c) >> configure.log 2>&1 ; then
162+ show $cc -c $test .c
163+ if test " $gcc " -eq 1 && ($cc -c $test .c) >> configure.log 2>&1 ; then
184164 echo ... using gcc >> configure.log
185165 CC=" $cc "
186166 CFLAGS=" ${CFLAGS--O3} ${ARCHS} "
@@ -208,7 +188,7 @@ if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) >> configure.log 2>&1; then
208188# temporary bypass
209189 rm -f $test .[co] $test $test$shared_ext
210190 echo " Please use win32/Makefile.gcc instead." | tee -a configure.log
211- exit 1
191+ leave 1
212192 LDSHARED=${LDSHARED-" $cc -shared" }
213193 LDSHAREDLIBC=" "
214194 EXE=' .exe' ;;
@@ -338,7 +318,59 @@ SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
338318
339319echo >> configure.log
340320
321+ # define functions for testing compiler and library characteristics and logging the results
322+
323+ cat > $test .c << EOF
324+ #error error
325+ EOF
326+ if ($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
333+ else
334+ try ()
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+ }
344+ fi
345+
346+ tryboth ()
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+
358+ cat > $test .c << EOF
359+ int foo() { return 0; }
360+ EOF
361+ echo " Checking for obsessive-compulsive compiler options..." >> configure.log
362+ if ! 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
365+ fi
366+
367+ echo >> configure.log
368+
341369# see if shared library build supported
370+ cat > $test .c << EOF
371+ extern int getchar();
372+ int hello() {return getchar();}
373+ EOF
342374if test $shared -eq 1; then
343375 echo Checking for shared library support... | tee -a configure.log
344376 # we must test in two steps (cc then ld), required at least on SunOS 4.x
366398 TEST=" all teststatic testshared"
367399fi
368400
369- echo >> configure.log
370-
371401# check for underscores in external names for use by assembler code
372402CPP=${CPP-" $CC -E" }
373403case $CFLAGS in
@@ -709,14 +739,14 @@ cat > $test.c <<EOF
709739#include <stdio.h>
710740#define is32(n,t) for(n=1,k=0;n;n<<=1,k++);if(k==32){puts(t);return 0;}
711741int main() {
712- int k;
713- unsigned i;
714- unsigned long l;
715- unsigned short s;
716- is32(i, "unsigned")
717- is32(l, "unsigned long")
718- is32(s, "unsigned short")
719- return 1;
742+ int k;
743+ unsigned i;
744+ unsigned long l;
745+ unsigned short s;
746+ is32(i, "unsigned")
747+ is32(l, "unsigned long")
748+ is32(s, "unsigned short")
749+ return 1;
720750}
721751EOF
722752Z_U4=" "
728758 echo " Looking for a four-byte integer type... Not found." | tee -a configure.log
729759fi
730760
731- # clean up files produced by running the compiler and linker
732- rm -f $test .[co] $test $test$shared_ext $test .gcno ./--version
733-
734761# show the results in the log
735762echo >> configure.log
736763echo ALL = $ALL >> configure.log
@@ -762,9 +789,6 @@ echo mandir = $mandir >> configure.log
762789echo prefix = $prefix >> configure.log
763790echo sharedlibdir = $sharedlibdir >> configure.log
764791echo uname = $uname >> configure.log
765- echo -------------------- >> configure.log
766- echo >> configure.log
767- echo >> configure.log
768792
769793# udpate Makefile with the configure results
770794sed < Makefile.in "
@@ -820,3 +844,6 @@ sed < zlib.pc.in "
820844" | sed -e "
821845s/\@VERSION\@/$VER /g;
822846" > zlib.pc
847+
848+ # done
849+ leave 0
0 commit comments