diff options
Diffstat (limited to 'configure')
-rwxr-xr-x | configure | 143 |
1 files changed, 85 insertions, 58 deletions
@@ -77,6 +77,19 @@ old_cflags="$CFLAGS" | |||
77 | OBJC='$(OBJZ) $(OBJG)' | 77 | OBJC='$(OBJZ) $(OBJG)' |
78 | PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)' | 78 | PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)' |
79 | 79 | ||
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 | |||
80 | # process command line options | 93 | # process command line options |
81 | while test $# -ge 1 | 94 | while test $# -ge 1 |
82 | do | 95 | do |
@@ -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 |
111 | done | 127 | done |
112 | 128 | ||
113 | # define functions for testing compiler and library characteristics and logging the results | 129 | # temporary file name |
114 | test=ztest$$ | 130 | test=ztest$$ |
115 | 131 | ||
132 | # put arguments in log, also put test file in log if used in arguments | ||
116 | show() | 133 | show() |
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 | ||
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 | |||
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 |
165 | cat > $test.c <<EOF | 145 | cat > $test.c <<EOF |
166 | extern int getchar(); | 146 | extern int getchar(); |
@@ -179,8 +159,8 @@ case `$cc -v 2>&1` in | |||
179 | *gcc*) gcc=1 ;; | 159 | *gcc*) gcc=1 ;; |
180 | esac | 160 | esac |
181 | 161 | ||
182 | show $cc -c $cflags $test.c | 162 | show $cc -c $test.c |
183 | if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) >> configure.log 2>&1; then | 163 | if 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 | ||
339 | echo >> configure.log | 319 | echo >> configure.log |
340 | 320 | ||
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 | |||
341 | # see if shared library build supported | 369 | # see if shared library build supported |
370 | cat > $test.c <<EOF | ||
371 | extern int getchar(); | ||
372 | int hello() {return getchar();} | ||
373 | EOF | ||
342 | if test $shared -eq 1; then | 374 | if 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" |
367 | fi | 399 | fi |
368 | 400 | ||
369 | echo >> 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 |
372 | CPP=${CPP-"$CC -E"} | 402 | CPP=${CPP-"$CC -E"} |
373 | case $CFLAGS in | 403 | case $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;} |
711 | int main() { | 741 | int 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 | } |
721 | EOF | 751 | EOF |
722 | Z_U4="" | 752 | Z_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 |
729 | fi | 759 | fi |
730 | 760 | ||
731 | # clean up files produced by running the compiler and linker | ||
732 | rm -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 |
735 | echo >> configure.log | 762 | echo >> configure.log |
736 | echo ALL = $ALL >> configure.log | 763 | echo ALL = $ALL >> configure.log |
@@ -762,9 +789,6 @@ echo mandir = $mandir >> configure.log | |||
762 | echo prefix = $prefix >> configure.log | 789 | echo prefix = $prefix >> configure.log |
763 | echo sharedlibdir = $sharedlibdir >> configure.log | 790 | echo sharedlibdir = $sharedlibdir >> configure.log |
764 | echo uname = $uname >> configure.log | 791 | echo uname = $uname >> configure.log |
765 | echo -------------------- >> configure.log | ||
766 | echo >> configure.log | ||
767 | echo >> configure.log | ||
768 | 792 | ||
769 | # udpate Makefile with the configure results | 793 | # udpate Makefile with the configure results |
770 | sed < Makefile.in " | 794 | sed < Makefile.in " |
@@ -820,3 +844,6 @@ sed < zlib.pc.in " | |||
820 | " | sed -e " | 844 | " | sed -e " |
821 | s/\@VERSION\@/$VER/g; | 845 | s/\@VERSION\@/$VER/g; |
822 | " > zlib.pc | 846 | " > zlib.pc |
847 | |||
848 | # done | ||
849 | leave 0 | ||