aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure34
1 files changed, 33 insertions, 1 deletions
diff --git a/configure b/configure
index 439a032..d6bc57a 100755
--- a/configure
+++ b/configure
@@ -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
16echo -------------------- >> configure.log 17echo -------------------- >> configure.log
17echo $0 $* >> configure.log 18echo $0 $* >> configure.log
18date >> configure.log 19date >> configure.log
19 20
21# set command prefix for cross-compilation
20if [ -n "${CHOST}" ]; then 22if [ -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}-"
23fi 25fi
24 26
27# destination name for static library
25STATICLIB=libz.a 28STATICLIB=libz.a
29
30# extract zlib version numbers from zlib.h
26VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h` 31VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
27VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < zlib.h` 32VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < zlib.h`
28VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h` 33VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h`
29VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h` 34VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h`
35
36# establish commands for library building
30if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then 37if "${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
47else 54else
48 NM=${NM-"nm"} 55 NM=${NM-"nm"}
49fi 56fi
57
58# set defaults before processing command line options
50LDCONFIG=${LDCONFIG-"ldconfig"} 59LDCONFIG=${LDCONFIG-"ldconfig"}
51LDSHAREDLIBC="${LDSHAREDLIBC--lc}" 60LDSHAREDLIBC="${LDSHAREDLIBC--lc}"
52ARCHS= 61ARCHS=
@@ -68,6 +77,7 @@ old_cflags="$CFLAGS"
68OBJC='$(OBJZ) $(OBJG)' 77OBJC='$(OBJZ) $(OBJG)'
69PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)' 78PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)'
70 79
80# process command line options
71while test $# -ge 1 81while test $# -ge 1
72do 82do
73case "$1" in 83case "$1" in
@@ -100,6 +110,7 @@ case "$1" in
100 esac 110 esac
101done 111done
102 112
113# define functions for testing compiler and library characteristics and logging the results
103test=ztest$$ 114test=ztest$$
104 115
105show() 116show()
@@ -150,6 +161,7 @@ tryboth()
150 161
151echo >> configure.log 162echo >> configure.log
152 163
164# check for gcc vs. cc and set compile and link flags based on the system identified by uname
153cat > $test.c <<EOF 165cat > $test.c <<EOF
154extern int getchar(); 166extern int getchar();
155int hello() {return getchar();} 167int hello() {return getchar();}
@@ -302,12 +314,14 @@ else
302 esac 314 esac
303fi 315fi
304 316
317# destination names for shared library if not defined above
305SHAREDLIB=${SHAREDLIB-"libz$shared_ext"} 318SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
306SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"} 319SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
307SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"} 320SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
308 321
309echo >> configure.log 322echo >> configure.log
310 323
324# see if shared library build supported
311if test $shared -eq 1; then 325if 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"
336fi 350fi
337 351
352echo >> configure.log
353
354# check for underscores in external names for use by assembler code
338CPP=${CPP-"$CC -E"} 355CPP=${CPP-"$CC -E"}
339case $CFLAGS in 356case $CFLAGS in
340 *ASMV*) 357 *ASMV*)
@@ -350,6 +367,7 @@ esac
350 367
351echo >> configure.log 368echo >> configure.log
352 369
370# check for large file support, and if none, check for fseeko()
353cat > $test.c <<EOF 371cat > $test.c <<EOF
354#include <sys/types.h> 372#include <sys/types.h>
355off64_t dummy = 0; 373off64_t dummy = 0;
@@ -382,6 +400,7 @@ fi
382 400
383echo >> configure.log 401echo >> configure.log
384 402
403# check for strerror() for use by gz* functions
385cat > $test.c <<EOF 404cat > $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
396fi 415fi
397 416
417# copy clean zconf.h for subsequent edits
398cp -p zconf.h.in zconf.h 418cp -p zconf.h.in zconf.h
399 419
400echo >> configure.log 420echo >> configure.log
401 421
422# check for unistd.h and save result in zconf.h
402cat > $test.c <<EOF 423cat > $test.c <<EOF
403#include <unistd.h> 424#include <unistd.h>
404int main() { return 0; } 425int main() { return 0; }
@@ -413,6 +434,7 @@ fi
413 434
414echo >> configure.log 435echo >> configure.log
415 436
437# check for stdarg.h and save result in zconf.h
416cat > $test.c <<EOF 438cat > $test.c <<EOF
417#include <stdarg.h> 439#include <stdarg.h>
418int main() { return 0; } 440int 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
426fi 448fi
427 449
450# if the z_ prefix was requested, save that in zconf.h
428if test $zprefix -eq 1; then 451if 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
433fi 456fi
434 457
458# if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists
435if test $solo -eq 1; then 459if 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)'
442PIC_OBJC='$(PIC_OBJZ)' 466PIC_OBJC='$(PIC_OBJZ)'
443fi 467fi
444 468
469# if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
445if test $cover -eq 1; then 470if 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
452echo >> configure.log 477echo >> 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.
454cat > $test.c <<EOF 483cat > $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
637fi 666fi
638 667
668# see if we can hide zlib internal symbols that are linked between separate source files
639if test "$gcc" -eq 1; then 669if 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
656fi 686fi
657 687
688# clean up files produced by running the compiler and linker
658rm -f $test.[co] $test $test$shared_ext $test.gcno 689rm -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
691echo >> configure.log 722echo >> configure.log
692echo >> configure.log 723echo >> configure.log
693 724
694# udpate Makefile 725# udpate Makefile with the configure results
695sed < Makefile.in " 726sed < 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
724sed < zlib.pc.in " 756sed < zlib.pc.in "
725/^CC *=/s#=.*#=$CC# 757/^CC *=/s#=.*#=$CC#
726/^CFLAGS *=/s#=.*#=$CFLAGS# 758/^CFLAGS *=/s#=.*#=$CFLAGS#