diff options
-rwxr-xr-x | configure | 34 |
1 files changed, 33 insertions, 1 deletions
@@ -13,20 +13,27 @@ | |||
13 | # If you have problems, try without defining CC and CFLAGS before reporting | 13 | # If you have problems, try without defining CC and CFLAGS before reporting |
14 | # an error. | 14 | # an error. |
15 | 15 | ||
16 | # start off configure.log | ||
16 | echo -------------------- >> configure.log | 17 | echo -------------------- >> configure.log |
17 | echo $0 $* >> configure.log | 18 | echo $0 $* >> configure.log |
18 | date >> configure.log | 19 | date >> configure.log |
19 | 20 | ||
21 | # set command prefix for cross-compilation | ||
20 | if [ -n "${CHOST}" ]; then | 22 | if [ -n "${CHOST}" ]; then |
21 | uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`" | 23 | uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`" |
22 | CROSS_PREFIX="${CHOST}-" | 24 | CROSS_PREFIX="${CHOST}-" |
23 | fi | 25 | fi |
24 | 26 | ||
27 | # destination name for static library | ||
25 | STATICLIB=libz.a | 28 | STATICLIB=libz.a |
29 | |||
30 | # extract zlib version numbers from zlib.h | ||
26 | VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h` | 31 | VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h` |
27 | VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < zlib.h` | 32 | VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < zlib.h` |
28 | VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h` | 33 | VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h` |
29 | VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h` | 34 | VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h` |
35 | |||
36 | # establish commands for library building | ||
30 | if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then | 37 | if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then |
31 | AR=${AR-"${CROSS_PREFIX}ar"} | 38 | AR=${AR-"${CROSS_PREFIX}ar"} |
32 | test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log | 39 | test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log |
@@ -47,6 +54,8 @@ if "${CROSS_PREFIX}nm" --version >/dev/null 2>/dev/null || test $? -lt 126; then | |||
47 | else | 54 | else |
48 | NM=${NM-"nm"} | 55 | NM=${NM-"nm"} |
49 | fi | 56 | fi |
57 | |||
58 | # set defaults before processing command line options | ||
50 | LDCONFIG=${LDCONFIG-"ldconfig"} | 59 | LDCONFIG=${LDCONFIG-"ldconfig"} |
51 | LDSHAREDLIBC="${LDSHAREDLIBC--lc}" | 60 | LDSHAREDLIBC="${LDSHAREDLIBC--lc}" |
52 | ARCHS= | 61 | ARCHS= |
@@ -68,6 +77,7 @@ old_cflags="$CFLAGS" | |||
68 | OBJC='$(OBJZ) $(OBJG)' | 77 | OBJC='$(OBJZ) $(OBJG)' |
69 | PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)' | 78 | PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)' |
70 | 79 | ||
80 | # process command line options | ||
71 | while test $# -ge 1 | 81 | while test $# -ge 1 |
72 | do | 82 | do |
73 | case "$1" in | 83 | case "$1" in |
@@ -100,6 +110,7 @@ case "$1" in | |||
100 | esac | 110 | esac |
101 | done | 111 | done |
102 | 112 | ||
113 | # define functions for testing compiler and library characteristics and logging the results | ||
103 | test=ztest$$ | 114 | test=ztest$$ |
104 | 115 | ||
105 | show() | 116 | show() |
@@ -150,6 +161,7 @@ tryboth() | |||
150 | 161 | ||
151 | echo >> configure.log | 162 | echo >> configure.log |
152 | 163 | ||
164 | # check for gcc vs. cc and set compile and link flags based on the system identified by uname | ||
153 | cat > $test.c <<EOF | 165 | cat > $test.c <<EOF |
154 | extern int getchar(); | 166 | extern int getchar(); |
155 | int hello() {return getchar();} | 167 | int hello() {return getchar();} |
@@ -302,12 +314,14 @@ else | |||
302 | esac | 314 | esac |
303 | fi | 315 | fi |
304 | 316 | ||
317 | # destination names for shared library if not defined above | ||
305 | SHAREDLIB=${SHAREDLIB-"libz$shared_ext"} | 318 | SHAREDLIB=${SHAREDLIB-"libz$shared_ext"} |
306 | SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"} | 319 | SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"} |
307 | SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"} | 320 | SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"} |
308 | 321 | ||
309 | echo >> configure.log | 322 | echo >> configure.log |
310 | 323 | ||
324 | # see if shared library build supported | ||
311 | if test $shared -eq 1; then | 325 | if test $shared -eq 1; then |
312 | echo Checking for shared library support... | tee -a configure.log | 326 | echo Checking for shared library support... | tee -a configure.log |
313 | # we must test in two steps (cc then ld), required at least on SunOS 4.x | 327 | # we must test in two steps (cc then ld), required at least on SunOS 4.x |
@@ -335,6 +349,9 @@ else | |||
335 | TEST="all teststatic testshared" | 349 | TEST="all teststatic testshared" |
336 | fi | 350 | fi |
337 | 351 | ||
352 | echo >> configure.log | ||
353 | |||
354 | # check for underscores in external names for use by assembler code | ||
338 | CPP=${CPP-"$CC -E"} | 355 | CPP=${CPP-"$CC -E"} |
339 | case $CFLAGS in | 356 | case $CFLAGS in |
340 | *ASMV*) | 357 | *ASMV*) |
@@ -350,6 +367,7 @@ esac | |||
350 | 367 | ||
351 | echo >> configure.log | 368 | echo >> configure.log |
352 | 369 | ||
370 | # check for large file support, and if none, check for fseeko() | ||
353 | cat > $test.c <<EOF | 371 | cat > $test.c <<EOF |
354 | #include <sys/types.h> | 372 | #include <sys/types.h> |
355 | off64_t dummy = 0; | 373 | off64_t dummy = 0; |
@@ -382,6 +400,7 @@ fi | |||
382 | 400 | ||
383 | echo >> configure.log | 401 | echo >> configure.log |
384 | 402 | ||
403 | # check for strerror() for use by gz* functions | ||
385 | cat > $test.c <<EOF | 404 | cat > $test.c <<EOF |
386 | #include <string.h> | 405 | #include <string.h> |
387 | #include <errno.h> | 406 | #include <errno.h> |
@@ -395,10 +414,12 @@ else | |||
395 | echo "Checking for strerror... No." | tee -a configure.log | 414 | echo "Checking for strerror... No." | tee -a configure.log |
396 | fi | 415 | fi |
397 | 416 | ||
417 | # copy clean zconf.h for subsequent edits | ||
398 | cp -p zconf.h.in zconf.h | 418 | cp -p zconf.h.in zconf.h |
399 | 419 | ||
400 | echo >> configure.log | 420 | echo >> configure.log |
401 | 421 | ||
422 | # check for unistd.h and save result in zconf.h | ||
402 | cat > $test.c <<EOF | 423 | cat > $test.c <<EOF |
403 | #include <unistd.h> | 424 | #include <unistd.h> |
404 | int main() { return 0; } | 425 | int main() { return 0; } |
@@ -413,6 +434,7 @@ fi | |||
413 | 434 | ||
414 | echo >> configure.log | 435 | echo >> configure.log |
415 | 436 | ||
437 | # check for stdarg.h and save result in zconf.h | ||
416 | cat > $test.c <<EOF | 438 | cat > $test.c <<EOF |
417 | #include <stdarg.h> | 439 | #include <stdarg.h> |
418 | int main() { return 0; } | 440 | int main() { return 0; } |
@@ -425,6 +447,7 @@ else | |||
425 | echo "Checking for stdarg.h... No." | tee -a configure.log | 447 | echo "Checking for stdarg.h... No." | tee -a configure.log |
426 | fi | 448 | fi |
427 | 449 | ||
450 | # if the z_ prefix was requested, save that in zconf.h | ||
428 | if test $zprefix -eq 1; then | 451 | if test $zprefix -eq 1; then |
429 | sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h | 452 | sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h |
430 | mv zconf.temp.h zconf.h | 453 | mv zconf.temp.h zconf.h |
@@ -432,6 +455,7 @@ if test $zprefix -eq 1; then | |||
432 | echo "Using z_ prefix on all symbols." | tee -a configure.log | 455 | echo "Using z_ prefix on all symbols." | tee -a configure.log |
433 | fi | 456 | fi |
434 | 457 | ||
458 | # if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists | ||
435 | if test $solo -eq 1; then | 459 | if test $solo -eq 1; then |
436 | sed '/#define ZCONF_H/a\ | 460 | sed '/#define ZCONF_H/a\ |
437 | #define Z_SOLO | 461 | #define Z_SOLO |
@@ -442,6 +466,7 @@ OBJC='$(OBJZ)' | |||
442 | PIC_OBJC='$(PIC_OBJZ)' | 466 | PIC_OBJC='$(PIC_OBJZ)' |
443 | fi | 467 | fi |
444 | 468 | ||
469 | # if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X | ||
445 | if test $cover -eq 1; then | 470 | if test $cover -eq 1; then |
446 | CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage" | 471 | CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage" |
447 | if test -n "$GCC_CLASSIC"; then | 472 | if test -n "$GCC_CLASSIC"; then |
@@ -451,6 +476,10 @@ fi | |||
451 | 476 | ||
452 | echo >> configure.log | 477 | echo >> configure.log |
453 | 478 | ||
479 | # conduct a series of tests to resolve eight possible cases of using "vs" or "s" printf functions | ||
480 | # (using stdarg or not), with or without "n" (proving size of buffer), and with or without a | ||
481 | # return value. The most secure result is vsnprintf() with a return value. snprintf() with a | ||
482 | # return value is secure as well, but then gzprintf() will be limited to 20 arguments. | ||
454 | cat > $test.c <<EOF | 483 | cat > $test.c <<EOF |
455 | #include <stdio.h> | 484 | #include <stdio.h> |
456 | #include <stdarg.h> | 485 | #include <stdarg.h> |
@@ -636,6 +665,7 @@ EOF | |||
636 | fi | 665 | fi |
637 | fi | 666 | fi |
638 | 667 | ||
668 | # see if we can hide zlib internal symbols that are linked between separate source files | ||
639 | if test "$gcc" -eq 1; then | 669 | if test "$gcc" -eq 1; then |
640 | echo >> configure.log | 670 | echo >> configure.log |
641 | cat > $test.c <<EOF | 671 | cat > $test.c <<EOF |
@@ -655,6 +685,7 @@ EOF | |||
655 | fi | 685 | fi |
656 | fi | 686 | fi |
657 | 687 | ||
688 | # clean up files produced by running the compiler and linker | ||
658 | rm -f $test.[co] $test $test$shared_ext $test.gcno | 689 | rm -f $test.[co] $test $test$shared_ext $test.gcno |
659 | 690 | ||
660 | # show the results in the log | 691 | # show the results in the log |
@@ -691,7 +722,7 @@ echo -------------------- >> configure.log | |||
691 | echo >> configure.log | 722 | echo >> configure.log |
692 | echo >> configure.log | 723 | echo >> configure.log |
693 | 724 | ||
694 | # udpate Makefile | 725 | # udpate Makefile with the configure results |
695 | sed < Makefile.in " | 726 | sed < Makefile.in " |
696 | /^CC *=/s#=.*#=$CC# | 727 | /^CC *=/s#=.*#=$CC# |
697 | /^CFLAGS *=/s#=.*#=$CFLAGS# | 728 | /^CFLAGS *=/s#=.*#=$CFLAGS# |
@@ -721,6 +752,7 @@ sed < Makefile.in " | |||
721 | /^test: */s#:.*#: $TEST# | 752 | /^test: */s#:.*#: $TEST# |
722 | " > Makefile | 753 | " > Makefile |
723 | 754 | ||
755 | # create zlib.pc with the configure results | ||
724 | sed < zlib.pc.in " | 756 | sed < zlib.pc.in " |
725 | /^CC *=/s#=.*#=$CC# | 757 | /^CC *=/s#=.*#=$CC# |
726 | /^CFLAGS *=/s#=.*#=$CFLAGS# | 758 | /^CFLAGS *=/s#=.*#=$CFLAGS# |