File indexing completed on 2024-12-15 03:36:21
0001 #!/bin/sh 0002 # configure script for zlib. 0003 # 0004 # Normally configure builds both a static and a shared library. 0005 # If you want to build just a static library, use: ./configure --static 0006 # 0007 # To impose specific compiler or flags or install directory, use for example: 0008 # prefix=$HOME CC=cc CFLAGS="-O4" ./configure 0009 # or for csh/tcsh users: 0010 # (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure) 0011 0012 # Incorrect settings of CC or CFLAGS may prevent creating a shared library. 0013 # If you have problems, try without defining CC and CFLAGS before reporting 0014 # an error. 0015 0016 # start off configure.log 0017 echo -------------------- >> configure.log 0018 echo $0 $* >> configure.log 0019 date >> configure.log 0020 0021 # set command prefix for cross-compilation 0022 if [ -n "${CHOST}" ]; then 0023 uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`" 0024 CROSS_PREFIX="${CHOST}-" 0025 fi 0026 0027 # destination name for static library 0028 STATICLIB=libz.a 0029 0030 # extract zlib version numbers from zlib.h 0031 VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h` 0032 VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < zlib.h` 0033 VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h` 0034 VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h` 0035 0036 # establish commands for library building 0037 if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then 0038 AR=${AR-"${CROSS_PREFIX}ar"} 0039 test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log 0040 else 0041 AR=${AR-"ar"} 0042 test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log 0043 fi 0044 ARFLAGS=${ARFLAGS-"rc"} 0045 if "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null || test $? -lt 126; then 0046 RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"} 0047 test -n "${CROSS_PREFIX}" && echo Using ${RANLIB} | tee -a configure.log 0048 else 0049 RANLIB=${RANLIB-"ranlib"} 0050 fi 0051 if "${CROSS_PREFIX}nm" --version >/dev/null 2>/dev/null || test $? -lt 126; then 0052 NM=${NM-"${CROSS_PREFIX}nm"} 0053 test -n "${CROSS_PREFIX}" && echo Using ${NM} | tee -a configure.log 0054 else 0055 NM=${NM-"nm"} 0056 fi 0057 0058 # set defaults before processing command line options 0059 LDCONFIG=${LDCONFIG-"ldconfig"} 0060 LDSHAREDLIBC="${LDSHAREDLIBC--lc}" 0061 ARCHS= 0062 prefix=${prefix-/usr/local} 0063 exec_prefix=${exec_prefix-'${prefix}'} 0064 libdir=${libdir-'${exec_prefix}/lib'} 0065 sharedlibdir=${sharedlibdir-'${libdir}'} 0066 includedir=${includedir-'${prefix}/include'} 0067 mandir=${mandir-'${prefix}/share/man'} 0068 shared_ext='.so' 0069 shared=1 0070 solo=0 0071 cover=0 0072 zprefix=0 0073 zconst=0 0074 build64=0 0075 gcc=0 0076 old_cc="$CC" 0077 old_cflags="$CFLAGS" 0078 OBJC='$(OBJZ) $(OBJG)' 0079 PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)' 0080 0081 # leave this script, optionally in a bad way 0082 leave() 0083 { 0084 if test "$*" != "0"; then 0085 echo "** $0 aborting." | tee -a configure.log 0086 fi 0087 rm -f $test.[co] $test $test$shared_ext $test.gcno ./--version 0088 echo -------------------- >> configure.log 0089 echo >> configure.log 0090 echo >> configure.log 0091 exit $1 0092 } 0093 0094 # process command line options 0095 while test $# -ge 1 0096 do 0097 case "$1" in 0098 -h* | --help) 0099 echo 'usage:' | tee -a configure.log 0100 echo ' configure [--const] [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log 0101 echo ' [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log 0102 echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log 0103 exit 0 ;; 0104 -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;; 0105 -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;; 0106 -l*=* | --libdir=*) libdir=`echo $1 | sed 's/.*=//'`; shift ;; 0107 --sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/.*=//'`; shift ;; 0108 -i*=* | --includedir=*) includedir=`echo $1 | sed 's/.*=//'`;shift ;; 0109 -u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;; 0110 -p* | --prefix) prefix="$2"; shift; shift ;; 0111 -e* | --eprefix) exec_prefix="$2"; shift; shift ;; 0112 -l* | --libdir) libdir="$2"; shift; shift ;; 0113 -i* | --includedir) includedir="$2"; shift; shift ;; 0114 -s* | --shared | --enable-shared) shared=1; shift ;; 0115 -t | --static) shared=0; shift ;; 0116 --solo) solo=1; shift ;; 0117 --cover) cover=1; shift ;; 0118 -z* | --zprefix) zprefix=1; shift ;; 0119 -6* | --64) build64=1; shift ;; 0120 -a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;; 0121 --sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;; 0122 --localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;; 0123 -c* | --const) zconst=1; shift ;; 0124 *) 0125 echo "unknown option: $1" | tee -a configure.log 0126 echo "$0 --help for help" | tee -a configure.log 0127 leave 1;; 0128 esac 0129 done 0130 0131 # temporary file name 0132 test=ztest$$ 0133 0134 # put arguments in log, also put test file in log if used in arguments 0135 show() 0136 { 0137 case "$*" in 0138 *$test.c*) 0139 echo === $test.c === >> configure.log 0140 cat $test.c >> configure.log 0141 echo === >> configure.log;; 0142 esac 0143 echo $* >> configure.log 0144 } 0145 0146 # check for gcc vs. cc and set compile and link flags based on the system identified by uname 0147 cat > $test.c <<EOF 0148 extern int getchar(); 0149 int hello() {return getchar();} 0150 EOF 0151 0152 test -z "$CC" && echo Checking for ${CROSS_PREFIX}gcc... | tee -a configure.log 0153 cc=${CC-${CROSS_PREFIX}gcc} 0154 cflags=${CFLAGS-"-O3"} 0155 # to force the asm version use: CFLAGS="-O3 -DASMV" ./configure 0156 case "$cc" in 0157 *gcc*) gcc=1 ;; 0158 *clang*) gcc=1 ;; 0159 esac 0160 case `$cc -v 2>&1` in 0161 *gcc*) gcc=1 ;; 0162 esac 0163 0164 show $cc -c $test.c 0165 if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then 0166 echo ... using gcc >> configure.log 0167 CC="$cc" 0168 CFLAGS="${CFLAGS--O3} ${ARCHS}" 0169 SFLAGS="${CFLAGS--O3} -fPIC" 0170 LDFLAGS="${LDFLAGS} ${ARCHS}" 0171 if test $build64 -eq 1; then 0172 CFLAGS="${CFLAGS} -m64" 0173 SFLAGS="${SFLAGS} -m64" 0174 fi 0175 if test "${ZLIBGCCWARN}" = "YES"; then 0176 if test "$zconst" -eq 1; then 0177 CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -pedantic -DZLIB_CONST" 0178 else 0179 CFLAGS="${CFLAGS} -Wall -Wextra -pedantic" 0180 fi 0181 fi 0182 if test -z "$uname"; then 0183 uname=`(uname -s || echo unknown) 2>/dev/null` 0184 fi 0185 case "$uname" in 0186 Linux* | linux* | GNU | GNU/* | solaris*) 0187 LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"} ;; 0188 *BSD | *bsd* | DragonFly) 0189 LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"} 0190 LDCONFIG="ldconfig -m" ;; 0191 CYGWIN* | Cygwin* | cygwin* | OS/2*) 0192 EXE='.exe' ;; 0193 MINGW* | mingw*) 0194 # temporary bypass 0195 rm -f $test.[co] $test $test$shared_ext 0196 echo "Please use win32/Makefile.gcc instead." | tee -a configure.log 0197 leave 1 0198 LDSHARED=${LDSHARED-"$cc -shared"} 0199 LDSHAREDLIBC="" 0200 EXE='.exe' ;; 0201 QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4 0202 # (alain.bonnefoy@icbt.com) 0203 LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;; 0204 HP-UX*) 0205 LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"} 0206 case `(uname -m || echo unknown) 2>/dev/null` in 0207 ia64) 0208 shared_ext='.so' 0209 SHAREDLIB='libz.so' ;; 0210 *) 0211 shared_ext='.sl' 0212 SHAREDLIB='libz.sl' ;; 0213 esac ;; 0214 Darwin* | darwin*) 0215 shared_ext='.dylib' 0216 SHAREDLIB=libz$shared_ext 0217 SHAREDLIBV=libz.$VER$shared_ext 0218 SHAREDLIBM=libz.$VER1$shared_ext 0219 LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"} 0220 if libtool -V 2>&1 | grep Apple > /dev/null; then 0221 AR="libtool" 0222 else 0223 AR="/usr/bin/libtool" 0224 fi 0225 ARFLAGS="-o" ;; 0226 *) LDSHARED=${LDSHARED-"$cc -shared"} ;; 0227 esac 0228 else 0229 # find system name and corresponding cc options 0230 CC=${CC-cc} 0231 gcc=0 0232 echo ... using $CC >> configure.log 0233 if test -z "$uname"; then 0234 uname=`(uname -sr || echo unknown) 2>/dev/null` 0235 fi 0236 case "$uname" in 0237 HP-UX*) SFLAGS=${CFLAGS-"-O +z"} 0238 CFLAGS=${CFLAGS-"-O"} 0239 # LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"} 0240 LDSHARED=${LDSHARED-"ld -b"} 0241 case `(uname -m || echo unknown) 2>/dev/null` in 0242 ia64) 0243 shared_ext='.so' 0244 SHAREDLIB='libz.so' ;; 0245 *) 0246 shared_ext='.sl' 0247 SHAREDLIB='libz.sl' ;; 0248 esac ;; 0249 IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."} 0250 CFLAGS=${CFLAGS-"-ansi -O2"} 0251 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;; 0252 OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"} 0253 CFLAGS=${CFLAGS-"-O -std1"} 0254 LDFLAGS="${LDFLAGS} -Wl,-rpath,." 0255 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;; 0256 OSF1*) SFLAGS=${CFLAGS-"-O -std1"} 0257 CFLAGS=${CFLAGS-"-O -std1"} 0258 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;; 0259 QNX*) SFLAGS=${CFLAGS-"-4 -O"} 0260 CFLAGS=${CFLAGS-"-4 -O"} 0261 LDSHARED=${LDSHARED-"cc"} 0262 RANLIB=${RANLIB-"true"} 0263 AR="cc" 0264 ARFLAGS="-A" ;; 0265 SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "} 0266 CFLAGS=${CFLAGS-"-O3"} 0267 LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;; 0268 SunOS\ 5* | solaris*) 0269 LDSHARED=${LDSHARED-"cc -G -h libz$shared_ext.$VER1"} 0270 SFLAGS=${CFLAGS-"-fast -KPIC"} 0271 CFLAGS=${CFLAGS-"-fast"} 0272 if test $build64 -eq 1; then 0273 # old versions of SunPRO/Workshop/Studio don't support -m64, 0274 # but newer ones do. Check for it. 0275 flag64=`$CC -flags | egrep -- '^-m64'` 0276 if test x"$flag64" != x"" ; then 0277 CFLAGS="${CFLAGS} -m64" 0278 SFLAGS="${SFLAGS} -m64" 0279 else 0280 case `(uname -m || echo unknown) 2>/dev/null` in 0281 i86*) 0282 SFLAGS="$SFLAGS -xarch=amd64" 0283 CFLAGS="$CFLAGS -xarch=amd64" ;; 0284 *) 0285 SFLAGS="$SFLAGS -xarch=v9" 0286 CFLAGS="$CFLAGS -xarch=v9" ;; 0287 esac 0288 fi 0289 fi 0290 ;; 0291 SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"} 0292 CFLAGS=${CFLAGS-"-O2"} 0293 LDSHARED=${LDSHARED-"ld"} ;; 0294 SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"} 0295 CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"} 0296 LDSHARED=${LDSHARED-"cc -xarch=v9b"} ;; 0297 UNIX_System_V\ 4.2.0) 0298 SFLAGS=${CFLAGS-"-KPIC -O"} 0299 CFLAGS=${CFLAGS-"-O"} 0300 LDSHARED=${LDSHARED-"cc -G"} ;; 0301 UNIX_SV\ 4.2MP) 0302 SFLAGS=${CFLAGS-"-Kconform_pic -O"} 0303 CFLAGS=${CFLAGS-"-O"} 0304 LDSHARED=${LDSHARED-"cc -G"} ;; 0305 OpenUNIX\ 5) 0306 SFLAGS=${CFLAGS-"-KPIC -O"} 0307 CFLAGS=${CFLAGS-"-O"} 0308 LDSHARED=${LDSHARED-"cc -G"} ;; 0309 AIX*) # Courtesy of dbakker@arrayasolutions.com 0310 SFLAGS=${CFLAGS-"-O -qmaxmem=8192"} 0311 CFLAGS=${CFLAGS-"-O -qmaxmem=8192"} 0312 LDSHARED=${LDSHARED-"xlc -G"} ;; 0313 # send working options for other systems to zlib@gzip.org 0314 *) SFLAGS=${CFLAGS-"-O"} 0315 CFLAGS=${CFLAGS-"-O"} 0316 LDSHARED=${LDSHARED-"cc -shared"} ;; 0317 esac 0318 fi 0319 0320 # destination names for shared library if not defined above 0321 SHAREDLIB=${SHAREDLIB-"libz$shared_ext"} 0322 SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"} 0323 SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"} 0324 0325 echo >> configure.log 0326 0327 # define functions for testing compiler and library characteristics and logging the results 0328 0329 cat > $test.c <<EOF 0330 #error error 0331 EOF 0332 if ($CC -c $CFLAGS $test.c) 2>/dev/null; then 0333 try() 0334 { 0335 show $* 0336 test "`( $* ) 2>&1 | tee -a configure.log`" = "" 0337 } 0338 echo - using any output from compiler to indicate an error >> configure.log 0339 else 0340 try() 0341 { 0342 show $* 0343 ( $* ) >> configure.log 2>&1 0344 ret=$? 0345 if test $ret -ne 0; then 0346 echo "(exit code "$ret")" >> configure.log 0347 fi 0348 return $ret 0349 } 0350 fi 0351 0352 tryboth() 0353 { 0354 show $* 0355 got=`( $* ) 2>&1` 0356 ret=$? 0357 printf %s "$got" >> configure.log 0358 if test $ret -ne 0; then 0359 return $ret 0360 fi 0361 test "$got" = "" 0362 } 0363 0364 cat > $test.c << EOF 0365 int foo() { return 0; } 0366 EOF 0367 echo "Checking for obsessive-compulsive compiler options..." >> configure.log 0368 if try $CC -c $CFLAGS $test.c; then 0369 : 0370 else 0371 echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log 0372 leave 1 0373 fi 0374 0375 echo >> configure.log 0376 0377 # see if shared library build supported 0378 cat > $test.c <<EOF 0379 extern int getchar(); 0380 int hello() {return getchar();} 0381 EOF 0382 if test $shared -eq 1; then 0383 echo Checking for shared library support... | tee -a configure.log 0384 # we must test in two steps (cc then ld), required at least on SunOS 4.x 0385 if try $CC -w -c $SFLAGS $test.c && 0386 try $LDSHARED $SFLAGS -o $test$shared_ext $test.o; then 0387 echo Building shared library $SHAREDLIBV with $CC. | tee -a configure.log 0388 elif test -z "$old_cc" -a -z "$old_cflags"; then 0389 echo No shared library support. | tee -a configure.log 0390 shared=0; 0391 else 0392 echo 'No shared library support; try without defining CC and CFLAGS' | tee -a configure.log 0393 shared=0; 0394 fi 0395 fi 0396 if test $shared -eq 0; then 0397 LDSHARED="$CC" 0398 ALL="static" 0399 TEST="all teststatic" 0400 SHAREDLIB="" 0401 SHAREDLIBV="" 0402 SHAREDLIBM="" 0403 echo Building static library $STATICLIB version $VER with $CC. | tee -a configure.log 0404 else 0405 ALL="static shared" 0406 TEST="all teststatic testshared" 0407 fi 0408 0409 # check for underscores in external names for use by assembler code 0410 CPP=${CPP-"$CC -E"} 0411 case $CFLAGS in 0412 *ASMV*) 0413 echo >> configure.log 0414 show "$NM $test.o | grep _hello" 0415 if test "`$NM $test.o | grep _hello | tee -a configure.log`" = ""; then 0416 CPP="$CPP -DNO_UNDERLINE" 0417 echo Checking for underline in external names... No. | tee -a configure.log 0418 else 0419 echo Checking for underline in external names... Yes. | tee -a configure.log 0420 fi ;; 0421 esac 0422 0423 echo >> configure.log 0424 0425 # check for large file support, and if none, check for fseeko() 0426 cat > $test.c <<EOF 0427 #include <sys/types.h> 0428 off64_t dummy = 0; 0429 EOF 0430 if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then 0431 CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1" 0432 SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1" 0433 ALL="${ALL} all64" 0434 TEST="${TEST} test64" 0435 echo "Checking for off64_t... Yes." | tee -a configure.log 0436 echo "Checking for fseeko... Yes." | tee -a configure.log 0437 else 0438 echo "Checking for off64_t... No." | tee -a configure.log 0439 echo >> configure.log 0440 cat > $test.c <<EOF 0441 #include <stdio.h> 0442 int main(void) { 0443 fseeko(NULL, 0, 0); 0444 return 0; 0445 } 0446 EOF 0447 if try $CC $CFLAGS -o $test $test.c; then 0448 echo "Checking for fseeko... Yes." | tee -a configure.log 0449 else 0450 CFLAGS="${CFLAGS} -DNO_FSEEKO" 0451 SFLAGS="${SFLAGS} -DNO_FSEEKO" 0452 echo "Checking for fseeko... No." | tee -a configure.log 0453 fi 0454 fi 0455 0456 echo >> configure.log 0457 0458 # check for strerror() for use by gz* functions 0459 cat > $test.c <<EOF 0460 #include <string.h> 0461 #include <errno.h> 0462 int main() { return strlen(strerror(errno)); } 0463 EOF 0464 if try $CC $CFLAGS -o $test $test.c; then 0465 echo "Checking for strerror... Yes." | tee -a configure.log 0466 else 0467 CFLAGS="${CFLAGS} -DNO_STRERROR" 0468 SFLAGS="${SFLAGS} -DNO_STRERROR" 0469 echo "Checking for strerror... No." | tee -a configure.log 0470 fi 0471 0472 # copy clean zconf.h for subsequent edits 0473 cp -p zconf.h.in zconf.h 0474 0475 echo >> configure.log 0476 0477 # check for unistd.h and save result in zconf.h 0478 cat > $test.c <<EOF 0479 #include <unistd.h> 0480 int main() { return 0; } 0481 EOF 0482 if try $CC -c $CFLAGS $test.c; then 0483 sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h 0484 mv zconf.temp.h zconf.h 0485 echo "Checking for unistd.h... Yes." | tee -a configure.log 0486 else 0487 echo "Checking for unistd.h... No." | tee -a configure.log 0488 fi 0489 0490 echo >> configure.log 0491 0492 # check for stdarg.h and save result in zconf.h 0493 cat > $test.c <<EOF 0494 #include <stdarg.h> 0495 int main() { return 0; } 0496 EOF 0497 if try $CC -c $CFLAGS $test.c; then 0498 sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h 0499 mv zconf.temp.h zconf.h 0500 echo "Checking for stdarg.h... Yes." | tee -a configure.log 0501 else 0502 echo "Checking for stdarg.h... No." | tee -a configure.log 0503 fi 0504 0505 # if the z_ prefix was requested, save that in zconf.h 0506 if test $zprefix -eq 1; then 0507 sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h 0508 mv zconf.temp.h zconf.h 0509 echo >> configure.log 0510 echo "Using z_ prefix on all symbols." | tee -a configure.log 0511 fi 0512 0513 # if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists 0514 if test $solo -eq 1; then 0515 sed '/#define ZCONF_H/a\ 0516 #define Z_SOLO 0517 0518 ' < zconf.h > zconf.temp.h 0519 mv zconf.temp.h zconf.h 0520 OBJC='$(OBJZ)' 0521 PIC_OBJC='$(PIC_OBJZ)' 0522 fi 0523 0524 # if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X 0525 if test $cover -eq 1; then 0526 CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage" 0527 if test -n "$GCC_CLASSIC"; then 0528 CC=$GCC_CLASSIC 0529 fi 0530 fi 0531 0532 echo >> configure.log 0533 0534 # conduct a series of tests to resolve eight possible cases of using "vs" or "s" printf functions 0535 # (using stdarg or not), with or without "n" (proving size of buffer), and with or without a 0536 # return value. The most secure result is vsnprintf() with a return value. snprintf() with a 0537 # return value is secure as well, but then gzprintf() will be limited to 20 arguments. 0538 cat > $test.c <<EOF 0539 #include <stdio.h> 0540 #include <stdarg.h> 0541 #include "zconf.h" 0542 int main() 0543 { 0544 #ifndef STDC 0545 choke me 0546 #endif 0547 return 0; 0548 } 0549 EOF 0550 if try $CC -c $CFLAGS $test.c; then 0551 echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." | tee -a configure.log 0552 0553 echo >> configure.log 0554 cat > $test.c <<EOF 0555 #include <stdio.h> 0556 #include <stdarg.h> 0557 int mytest(const char *fmt, ...) 0558 { 0559 char buf[20]; 0560 va_list ap; 0561 va_start(ap, fmt); 0562 vsnprintf(buf, sizeof(buf), fmt, ap); 0563 va_end(ap); 0564 return 0; 0565 } 0566 int main() 0567 { 0568 return (mytest("Hello%d\n", 1)); 0569 } 0570 EOF 0571 if try $CC $CFLAGS -o $test $test.c; then 0572 echo "Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log 0573 0574 echo >> configure.log 0575 cat >$test.c <<EOF 0576 #include <stdio.h> 0577 #include <stdarg.h> 0578 int mytest(const char *fmt, ...) 0579 { 0580 int n; 0581 char buf[20]; 0582 va_list ap; 0583 va_start(ap, fmt); 0584 n = vsnprintf(buf, sizeof(buf), fmt, ap); 0585 va_end(ap); 0586 return n; 0587 } 0588 int main() 0589 { 0590 return (mytest("Hello%d\n", 1)); 0591 } 0592 EOF 0593 0594 if try $CC -c $CFLAGS $test.c; then 0595 echo "Checking for return value of vsnprintf()... Yes." | tee -a configure.log 0596 else 0597 CFLAGS="$CFLAGS -DHAS_vsnprintf_void" 0598 SFLAGS="$SFLAGS -DHAS_vsnprintf_void" 0599 echo "Checking for return value of vsnprintf()... No." | tee -a configure.log 0600 echo " WARNING: apparently vsnprintf() does not return a value. zlib" | tee -a configure.log 0601 echo " can build but will be open to possible string-format security" | tee -a configure.log 0602 echo " vulnerabilities." | tee -a configure.log 0603 fi 0604 else 0605 CFLAGS="$CFLAGS -DNO_vsnprintf" 0606 SFLAGS="$SFLAGS -DNO_vsnprintf" 0607 echo "Checking for vsnprintf() in stdio.h... No." | tee -a configure.log 0608 echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log 0609 echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log 0610 echo " vulnerabilities." | tee -a configure.log 0611 0612 echo >> configure.log 0613 cat >$test.c <<EOF 0614 #include <stdio.h> 0615 #include <stdarg.h> 0616 int mytest(const char *fmt, ...) 0617 { 0618 int n; 0619 char buf[20]; 0620 va_list ap; 0621 va_start(ap, fmt); 0622 n = vsprintf(buf, fmt, ap); 0623 va_end(ap); 0624 return n; 0625 } 0626 int main() 0627 { 0628 return (mytest("Hello%d\n", 1)); 0629 } 0630 EOF 0631 0632 if try $CC -c $CFLAGS $test.c; then 0633 echo "Checking for return value of vsprintf()... Yes." | tee -a configure.log 0634 else 0635 CFLAGS="$CFLAGS -DHAS_vsprintf_void" 0636 SFLAGS="$SFLAGS -DHAS_vsprintf_void" 0637 echo "Checking for return value of vsprintf()... No." | tee -a configure.log 0638 echo " WARNING: apparently vsprintf() does not return a value. zlib" | tee -a configure.log 0639 echo " can build but will be open to possible string-format security" | tee -a configure.log 0640 echo " vulnerabilities." | tee -a configure.log 0641 fi 0642 fi 0643 else 0644 echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." | tee -a configure.log 0645 0646 echo >> configure.log 0647 cat >$test.c <<EOF 0648 #include <stdio.h> 0649 int mytest() 0650 { 0651 char buf[20]; 0652 snprintf(buf, sizeof(buf), "%s", "foo"); 0653 return 0; 0654 } 0655 int main() 0656 { 0657 return (mytest()); 0658 } 0659 EOF 0660 0661 if try $CC $CFLAGS -o $test $test.c; then 0662 echo "Checking for snprintf() in stdio.h... Yes." | tee -a configure.log 0663 0664 echo >> configure.log 0665 cat >$test.c <<EOF 0666 #include <stdio.h> 0667 int mytest() 0668 { 0669 char buf[20]; 0670 return snprintf(buf, sizeof(buf), "%s", "foo"); 0671 } 0672 int main() 0673 { 0674 return (mytest()); 0675 } 0676 EOF 0677 0678 if try $CC -c $CFLAGS $test.c; then 0679 echo "Checking for return value of snprintf()... Yes." | tee -a configure.log 0680 else 0681 CFLAGS="$CFLAGS -DHAS_snprintf_void" 0682 SFLAGS="$SFLAGS -DHAS_snprintf_void" 0683 echo "Checking for return value of snprintf()... No." | tee -a configure.log 0684 echo " WARNING: apparently snprintf() does not return a value. zlib" | tee -a configure.log 0685 echo " can build but will be open to possible string-format security" | tee -a configure.log 0686 echo " vulnerabilities." | tee -a configure.log 0687 fi 0688 else 0689 CFLAGS="$CFLAGS -DNO_snprintf" 0690 SFLAGS="$SFLAGS -DNO_snprintf" 0691 echo "Checking for snprintf() in stdio.h... No." | tee -a configure.log 0692 echo " WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log 0693 echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log 0694 echo " vulnerabilities." | tee -a configure.log 0695 0696 echo >> configure.log 0697 cat >$test.c <<EOF 0698 #include <stdio.h> 0699 int mytest() 0700 { 0701 char buf[20]; 0702 return sprintf(buf, "%s", "foo"); 0703 } 0704 int main() 0705 { 0706 return (mytest()); 0707 } 0708 EOF 0709 0710 if try $CC -c $CFLAGS $test.c; then 0711 echo "Checking for return value of sprintf()... Yes." | tee -a configure.log 0712 else 0713 CFLAGS="$CFLAGS -DHAS_sprintf_void" 0714 SFLAGS="$SFLAGS -DHAS_sprintf_void" 0715 echo "Checking for return value of sprintf()... No." | tee -a configure.log 0716 echo " WARNING: apparently sprintf() does not return a value. zlib" | tee -a configure.log 0717 echo " can build but will be open to possible string-format security" | tee -a configure.log 0718 echo " vulnerabilities." | tee -a configure.log 0719 fi 0720 fi 0721 fi 0722 0723 # see if we can hide zlib internal symbols that are linked between separate source files 0724 if test "$gcc" -eq 1; then 0725 echo >> configure.log 0726 cat > $test.c <<EOF 0727 #define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) 0728 int ZLIB_INTERNAL foo; 0729 int main() 0730 { 0731 return 0; 0732 } 0733 EOF 0734 if tryboth $CC -c $CFLAGS $test.c; then 0735 CFLAGS="$CFLAGS -DHAVE_HIDDEN" 0736 SFLAGS="$SFLAGS -DHAVE_HIDDEN" 0737 echo "Checking for attribute(visibility) support... Yes." | tee -a configure.log 0738 else 0739 echo "Checking for attribute(visibility) support... No." | tee -a configure.log 0740 fi 0741 fi 0742 0743 # show the results in the log 0744 echo >> configure.log 0745 echo ALL = $ALL >> configure.log 0746 echo AR = $AR >> configure.log 0747 echo ARFLAGS = $ARFLAGS >> configure.log 0748 echo CC = $CC >> configure.log 0749 echo CFLAGS = $CFLAGS >> configure.log 0750 echo CPP = $CPP >> configure.log 0751 echo EXE = $EXE >> configure.log 0752 echo LDCONFIG = $LDCONFIG >> configure.log 0753 echo LDFLAGS = $LDFLAGS >> configure.log 0754 echo LDSHARED = $LDSHARED >> configure.log 0755 echo LDSHAREDLIBC = $LDSHAREDLIBC >> configure.log 0756 echo OBJC = $OBJC >> configure.log 0757 echo PIC_OBJC = $PIC_OBJC >> configure.log 0758 echo RANLIB = $RANLIB >> configure.log 0759 echo SFLAGS = $SFLAGS >> configure.log 0760 echo SHAREDLIB = $SHAREDLIB >> configure.log 0761 echo SHAREDLIBM = $SHAREDLIBM >> configure.log 0762 echo SHAREDLIBV = $SHAREDLIBV >> configure.log 0763 echo STATICLIB = $STATICLIB >> configure.log 0764 echo TEST = $TEST >> configure.log 0765 echo VER = $VER >> configure.log 0766 echo Z_U4 = $Z_U4 >> configure.log 0767 echo exec_prefix = $exec_prefix >> configure.log 0768 echo includedir = $includedir >> configure.log 0769 echo libdir = $libdir >> configure.log 0770 echo mandir = $mandir >> configure.log 0771 echo prefix = $prefix >> configure.log 0772 echo sharedlibdir = $sharedlibdir >> configure.log 0773 echo uname = $uname >> configure.log 0774 0775 # udpate Makefile with the configure results 0776 sed < Makefile.in " 0777 /^CC *=/s#=.*#=$CC# 0778 /^CFLAGS *=/s#=.*#=$CFLAGS# 0779 /^SFLAGS *=/s#=.*#=$SFLAGS# 0780 /^LDFLAGS *=/s#=.*#=$LDFLAGS# 0781 /^LDSHARED *=/s#=.*#=$LDSHARED# 0782 /^CPP *=/s#=.*#=$CPP# 0783 /^STATICLIB *=/s#=.*#=$STATICLIB# 0784 /^SHAREDLIB *=/s#=.*#=$SHAREDLIB# 0785 /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV# 0786 /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM# 0787 /^AR *=/s#=.*#=$AR# 0788 /^ARFLAGS *=/s#=.*#=$ARFLAGS# 0789 /^RANLIB *=/s#=.*#=$RANLIB# 0790 /^LDCONFIG *=/s#=.*#=$LDCONFIG# 0791 /^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC# 0792 /^EXE *=/s#=.*#=$EXE# 0793 /^prefix *=/s#=.*#=$prefix# 0794 /^exec_prefix *=/s#=.*#=$exec_prefix# 0795 /^libdir *=/s#=.*#=$libdir# 0796 /^sharedlibdir *=/s#=.*#=$sharedlibdir# 0797 /^includedir *=/s#=.*#=$includedir# 0798 /^mandir *=/s#=.*#=$mandir# 0799 /^OBJC *=/s#=.*#= $OBJC# 0800 /^PIC_OBJC *=/s#=.*#= $PIC_OBJC# 0801 /^all: */s#:.*#: $ALL# 0802 /^test: */s#:.*#: $TEST# 0803 " > Makefile 0804 0805 # create zlib.pc with the configure results 0806 sed < zlib.pc.in " 0807 /^CC *=/s#=.*#=$CC# 0808 /^CFLAGS *=/s#=.*#=$CFLAGS# 0809 /^CPP *=/s#=.*#=$CPP# 0810 /^LDSHARED *=/s#=.*#=$LDSHARED# 0811 /^STATICLIB *=/s#=.*#=$STATICLIB# 0812 /^SHAREDLIB *=/s#=.*#=$SHAREDLIB# 0813 /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV# 0814 /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM# 0815 /^AR *=/s#=.*#=$AR# 0816 /^ARFLAGS *=/s#=.*#=$ARFLAGS# 0817 /^RANLIB *=/s#=.*#=$RANLIB# 0818 /^EXE *=/s#=.*#=$EXE# 0819 /^prefix *=/s#=.*#=$prefix# 0820 /^exec_prefix *=/s#=.*#=$exec_prefix# 0821 /^libdir *=/s#=.*#=$libdir# 0822 /^sharedlibdir *=/s#=.*#=$sharedlibdir# 0823 /^includedir *=/s#=.*#=$includedir# 0824 /^mandir *=/s#=.*#=$mandir# 0825 /^LDFLAGS *=/s#=.*#=$LDFLAGS# 0826 " | sed -e " 0827 s/\@VERSION\@/$VER/g; 0828 " > zlib.pc 0829 0830 # done 0831 leave 0