annotate src/zlib-1.2.7/configure @ 83:ae30d91d2ffe

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam
date Fri, 07 Feb 2020 11:51:13 +0000
parents e13257ea84a4
children
rev   line source
Chris@4 1 #!/bin/sh
Chris@4 2 # configure script for zlib.
Chris@4 3 #
Chris@4 4 # Normally configure builds both a static and a shared library.
Chris@4 5 # If you want to build just a static library, use: ./configure --static
Chris@4 6 #
Chris@4 7 # To impose specific compiler or flags or install directory, use for example:
Chris@4 8 # prefix=$HOME CC=cc CFLAGS="-O4" ./configure
Chris@4 9 # or for csh/tcsh users:
Chris@4 10 # (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure)
Chris@4 11
Chris@4 12 # Incorrect settings of CC or CFLAGS may prevent creating a shared library.
Chris@4 13 # If you have problems, try without defining CC and CFLAGS before reporting
Chris@4 14 # an error.
Chris@4 15
Chris@4 16 # start off configure.log
Chris@4 17 echo -------------------- >> configure.log
Chris@4 18 echo $0 $* >> configure.log
Chris@4 19 date >> configure.log
Chris@4 20
Chris@4 21 # set command prefix for cross-compilation
Chris@4 22 if [ -n "${CHOST}" ]; then
Chris@4 23 uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`"
Chris@4 24 CROSS_PREFIX="${CHOST}-"
Chris@4 25 fi
Chris@4 26
Chris@4 27 # destination name for static library
Chris@4 28 STATICLIB=libz.a
Chris@4 29
Chris@4 30 # extract zlib version numbers from zlib.h
Chris@4 31 VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
Chris@4 32 VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < zlib.h`
Chris@4 33 VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h`
Chris@4 34 VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h`
Chris@4 35
Chris@4 36 # establish commands for library building
Chris@4 37 if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then
Chris@4 38 AR=${AR-"${CROSS_PREFIX}ar"}
Chris@4 39 test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
Chris@4 40 else
Chris@4 41 AR=${AR-"ar"}
Chris@4 42 test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
Chris@4 43 fi
Chris@4 44 ARFLAGS=${ARFLAGS-"rc"}
Chris@4 45 if "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null || test $? -lt 126; then
Chris@4 46 RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"}
Chris@4 47 test -n "${CROSS_PREFIX}" && echo Using ${RANLIB} | tee -a configure.log
Chris@4 48 else
Chris@4 49 RANLIB=${RANLIB-"ranlib"}
Chris@4 50 fi
Chris@4 51 if "${CROSS_PREFIX}nm" --version >/dev/null 2>/dev/null || test $? -lt 126; then
Chris@4 52 NM=${NM-"${CROSS_PREFIX}nm"}
Chris@4 53 test -n "${CROSS_PREFIX}" && echo Using ${NM} | tee -a configure.log
Chris@4 54 else
Chris@4 55 NM=${NM-"nm"}
Chris@4 56 fi
Chris@4 57
Chris@4 58 # set defaults before processing command line options
Chris@4 59 LDCONFIG=${LDCONFIG-"ldconfig"}
Chris@4 60 LDSHAREDLIBC="${LDSHAREDLIBC--lc}"
Chris@4 61 ARCHS=
Chris@4 62 prefix=${prefix-/usr/local}
Chris@4 63 exec_prefix=${exec_prefix-'${prefix}'}
Chris@4 64 libdir=${libdir-'${exec_prefix}/lib'}
Chris@4 65 sharedlibdir=${sharedlibdir-'${libdir}'}
Chris@4 66 includedir=${includedir-'${prefix}/include'}
Chris@4 67 mandir=${mandir-'${prefix}/share/man'}
Chris@4 68 shared_ext='.so'
Chris@4 69 shared=1
Chris@4 70 solo=0
Chris@4 71 cover=0
Chris@4 72 zprefix=0
Chris@4 73 build64=0
Chris@4 74 gcc=0
Chris@4 75 old_cc="$CC"
Chris@4 76 old_cflags="$CFLAGS"
Chris@4 77 OBJC='$(OBJZ) $(OBJG)'
Chris@4 78 PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)'
Chris@4 79
Chris@4 80 # process command line options
Chris@4 81 while test $# -ge 1
Chris@4 82 do
Chris@4 83 case "$1" in
Chris@4 84 -h* | --help)
Chris@4 85 echo 'usage:' | tee -a configure.log
Chris@4 86 echo ' configure [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log
Chris@4 87 echo ' [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log
Chris@4 88 echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log
Chris@4 89 exit 0 ;;
Chris@4 90 -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;;
Chris@4 91 -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;;
Chris@4 92 -l*=* | --libdir=*) libdir=`echo $1 | sed 's/.*=//'`; shift ;;
Chris@4 93 --sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/.*=//'`; shift ;;
Chris@4 94 -i*=* | --includedir=*) includedir=`echo $1 | sed 's/.*=//'`;shift ;;
Chris@4 95 -u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;;
Chris@4 96 -p* | --prefix) prefix="$2"; shift; shift ;;
Chris@4 97 -e* | --eprefix) exec_prefix="$2"; shift; shift ;;
Chris@4 98 -l* | --libdir) libdir="$2"; shift; shift ;;
Chris@4 99 -i* | --includedir) includedir="$2"; shift; shift ;;
Chris@4 100 -s* | --shared | --enable-shared) shared=1; shift ;;
Chris@4 101 -t | --static) shared=0; shift ;;
Chris@4 102 --solo) solo=1; shift ;;
Chris@4 103 --cover) cover=1; shift ;;
Chris@4 104 -z* | --zprefix) zprefix=1; shift ;;
Chris@4 105 -6* | --64) build64=1; shift ;;
Chris@4 106 -a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
Chris@4 107 --sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;;
Chris@4 108 --localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;;
Chris@4 109 *) echo "unknown option: $1"; echo "$0 --help for help" | tee -a configure.log; exit 1 ;;
Chris@4 110 esac
Chris@4 111 done
Chris@4 112
Chris@4 113 # define functions for testing compiler and library characteristics and logging the results
Chris@4 114 test=ztest$$
Chris@4 115
Chris@4 116 show()
Chris@4 117 {
Chris@4 118 case "$*" in
Chris@4 119 *$test.c*)
Chris@4 120 echo === $test.c === >> configure.log
Chris@4 121 cat $test.c >> configure.log
Chris@4 122 echo === >> configure.log;;
Chris@4 123 esac
Chris@4 124 echo $* >> configure.log
Chris@4 125 }
Chris@4 126
Chris@4 127 cat > $test.c <<EOF
Chris@4 128 #error error
Chris@4 129 EOF
Chris@4 130 if ($CC -c $CFLAGS $test.c) 2>/dev/null; then
Chris@4 131 try()
Chris@4 132 {
Chris@4 133 show $*
Chris@4 134 test "`( $* ) 2>&1 | tee -a configure.log`" = ""
Chris@4 135 }
Chris@4 136 echo - using any output from compiler to indicate an error >> configure.log
Chris@4 137 else
Chris@4 138 try()
Chris@4 139 {
Chris@4 140 show $*
Chris@4 141 ( $* ) >> configure.log 2>&1
Chris@4 142 ret=$?
Chris@4 143 if test $ret -ne 0; then
Chris@4 144 echo "(exit code "$ret")" >> configure.log
Chris@4 145 fi
Chris@4 146 return $ret
Chris@4 147 }
Chris@4 148 fi
Chris@4 149
Chris@4 150 tryboth()
Chris@4 151 {
Chris@4 152 show $*
Chris@4 153 got=`( $* ) 2>&1`
Chris@4 154 ret=$?
Chris@4 155 printf %s "$got" >> configure.log
Chris@4 156 if test $ret -ne 0; then
Chris@4 157 return $ret
Chris@4 158 fi
Chris@4 159 test "$got" = ""
Chris@4 160 }
Chris@4 161
Chris@4 162 echo >> configure.log
Chris@4 163
Chris@4 164 # check for gcc vs. cc and set compile and link flags based on the system identified by uname
Chris@4 165 cat > $test.c <<EOF
Chris@4 166 extern int getchar();
Chris@4 167 int hello() {return getchar();}
Chris@4 168 EOF
Chris@4 169
Chris@4 170 test -z "$CC" && echo Checking for ${CROSS_PREFIX}gcc... | tee -a configure.log
Chris@4 171 cc=${CC-${CROSS_PREFIX}gcc}
Chris@4 172 cflags=${CFLAGS-"-O3"}
Chris@4 173 # to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
Chris@4 174 case "$cc" in
Chris@4 175 *gcc*) gcc=1 ;;
Chris@4 176 *clang*) gcc=1 ;;
Chris@4 177 esac
Chris@4 178 case `$cc -v 2>&1` in
Chris@4 179 *gcc*) gcc=1 ;;
Chris@4 180 esac
Chris@4 181
Chris@4 182 show $cc -c $cflags $test.c
Chris@4 183 if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) >> configure.log 2>&1; then
Chris@4 184 echo ... using gcc >> configure.log
Chris@4 185 CC="$cc"
Chris@4 186 CFLAGS="${CFLAGS--O3} ${ARCHS}"
Chris@4 187 SFLAGS="${CFLAGS--O3} -fPIC"
Chris@4 188 LDFLAGS="${LDFLAGS} ${ARCHS}"
Chris@4 189 if test $build64 -eq 1; then
Chris@4 190 CFLAGS="${CFLAGS} -m64"
Chris@4 191 SFLAGS="${SFLAGS} -m64"
Chris@4 192 fi
Chris@4 193 if test "${ZLIBGCCWARN}" = "YES"; then
Chris@4 194 CFLAGS="${CFLAGS} -Wall -Wextra -pedantic"
Chris@4 195 fi
Chris@4 196 if test -z "$uname"; then
Chris@4 197 uname=`(uname -s || echo unknown) 2>/dev/null`
Chris@4 198 fi
Chris@4 199 case "$uname" in
Chris@4 200 Linux* | linux* | GNU | GNU/* | solaris*)
Chris@4 201 LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"} ;;
Chris@4 202 *BSD | *bsd* | DragonFly)
Chris@4 203 LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"}
Chris@4 204 LDCONFIG="ldconfig -m" ;;
Chris@4 205 CYGWIN* | Cygwin* | cygwin* | OS/2*)
Chris@4 206 EXE='.exe' ;;
Chris@4 207 MINGW* | mingw*)
Chris@4 208 # temporary bypass
Chris@4 209 rm -f $test.[co] $test $test$shared_ext
Chris@4 210 echo "Please use win32/Makefile.gcc instead." | tee -a configure.log
Chris@4 211 exit 1
Chris@4 212 LDSHARED=${LDSHARED-"$cc -shared"}
Chris@4 213 LDSHAREDLIBC=""
Chris@4 214 EXE='.exe' ;;
Chris@4 215 QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
Chris@4 216 # (alain.bonnefoy@icbt.com)
Chris@4 217 LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
Chris@4 218 HP-UX*)
Chris@4 219 LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
Chris@4 220 case `(uname -m || echo unknown) 2>/dev/null` in
Chris@4 221 ia64)
Chris@4 222 shared_ext='.so'
Chris@4 223 SHAREDLIB='libz.so' ;;
Chris@4 224 *)
Chris@4 225 shared_ext='.sl'
Chris@4 226 SHAREDLIB='libz.sl' ;;
Chris@4 227 esac ;;
Chris@4 228 Darwin* | darwin*)
Chris@4 229 shared_ext='.dylib'
Chris@4 230 SHAREDLIB=libz$shared_ext
Chris@4 231 SHAREDLIBV=libz.$VER$shared_ext
Chris@4 232 SHAREDLIBM=libz.$VER1$shared_ext
Chris@4 233 LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
Chris@4 234 AR="/usr/bin/libtool"
Chris@4 235 ARFLAGS="-o" ;;
Chris@4 236 *) LDSHARED=${LDSHARED-"$cc -shared"} ;;
Chris@4 237 esac
Chris@4 238 else
Chris@4 239 # find system name and corresponding cc options
Chris@4 240 CC=${CC-cc}
Chris@4 241 gcc=0
Chris@4 242 echo ... using $CC >> configure.log
Chris@4 243 if test -z "$uname"; then
Chris@4 244 uname=`(uname -sr || echo unknown) 2>/dev/null`
Chris@4 245 fi
Chris@4 246 case "$uname" in
Chris@4 247 HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
Chris@4 248 CFLAGS=${CFLAGS-"-O"}
Chris@4 249 # LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
Chris@4 250 LDSHARED=${LDSHARED-"ld -b"}
Chris@4 251 case `(uname -m || echo unknown) 2>/dev/null` in
Chris@4 252 ia64)
Chris@4 253 shared_ext='.so'
Chris@4 254 SHAREDLIB='libz.so' ;;
Chris@4 255 *)
Chris@4 256 shared_ext='.sl'
Chris@4 257 SHAREDLIB='libz.sl' ;;
Chris@4 258 esac ;;
Chris@4 259 IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
Chris@4 260 CFLAGS=${CFLAGS-"-ansi -O2"}
Chris@4 261 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
Chris@4 262 OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
Chris@4 263 CFLAGS=${CFLAGS-"-O -std1"}
Chris@4 264 LDFLAGS="${LDFLAGS} -Wl,-rpath,."
Chris@4 265 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;;
Chris@4 266 OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
Chris@4 267 CFLAGS=${CFLAGS-"-O -std1"}
Chris@4 268 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
Chris@4 269 QNX*) SFLAGS=${CFLAGS-"-4 -O"}
Chris@4 270 CFLAGS=${CFLAGS-"-4 -O"}
Chris@4 271 LDSHARED=${LDSHARED-"cc"}
Chris@4 272 RANLIB=${RANLIB-"true"}
Chris@4 273 AR="cc"
Chris@4 274 ARFLAGS="-A" ;;
Chris@4 275 SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
Chris@4 276 CFLAGS=${CFLAGS-"-O3"}
Chris@4 277 LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;;
Chris@4 278 SunOS\ 5* | solaris*)
Chris@4 279 LDSHARED=${LDSHARED-"cc -G -h libz$shared_ext.$VER1"}
Chris@4 280 SFLAGS=${CFLAGS-"-fast -KPIC"}
Chris@4 281 CFLAGS=${CFLAGS-"-fast"}
Chris@4 282 if test $build64 -eq 1; then
Chris@4 283 # old versions of SunPRO/Workshop/Studio don't support -m64,
Chris@4 284 # but newer ones do. Check for it.
Chris@4 285 flag64=`$CC -flags | egrep -- '^-m64'`
Chris@4 286 if test x"$flag64" != x"" ; then
Chris@4 287 CFLAGS="${CFLAGS} -m64"
Chris@4 288 SFLAGS="${SFLAGS} -m64"
Chris@4 289 else
Chris@4 290 case `(uname -m || echo unknown) 2>/dev/null` in
Chris@4 291 i86*)
Chris@4 292 SFLAGS="$SFLAGS -xarch=amd64"
Chris@4 293 CFLAGS="$CFLAGS -xarch=amd64" ;;
Chris@4 294 *)
Chris@4 295 SFLAGS="$SFLAGS -xarch=v9"
Chris@4 296 CFLAGS="$CFLAGS -xarch=v9" ;;
Chris@4 297 esac
Chris@4 298 fi
Chris@4 299 fi
Chris@4 300 ;;
Chris@4 301 SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
Chris@4 302 CFLAGS=${CFLAGS-"-O2"}
Chris@4 303 LDSHARED=${LDSHARED-"ld"} ;;
Chris@4 304 SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
Chris@4 305 CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"}
Chris@4 306 LDSHARED=${LDSHARED-"cc -xarch=v9b"} ;;
Chris@4 307 UNIX_System_V\ 4.2.0)
Chris@4 308 SFLAGS=${CFLAGS-"-KPIC -O"}
Chris@4 309 CFLAGS=${CFLAGS-"-O"}
Chris@4 310 LDSHARED=${LDSHARED-"cc -G"} ;;
Chris@4 311 UNIX_SV\ 4.2MP)
Chris@4 312 SFLAGS=${CFLAGS-"-Kconform_pic -O"}
Chris@4 313 CFLAGS=${CFLAGS-"-O"}
Chris@4 314 LDSHARED=${LDSHARED-"cc -G"} ;;
Chris@4 315 OpenUNIX\ 5)
Chris@4 316 SFLAGS=${CFLAGS-"-KPIC -O"}
Chris@4 317 CFLAGS=${CFLAGS-"-O"}
Chris@4 318 LDSHARED=${LDSHARED-"cc -G"} ;;
Chris@4 319 AIX*) # Courtesy of dbakker@arrayasolutions.com
Chris@4 320 SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
Chris@4 321 CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
Chris@4 322 LDSHARED=${LDSHARED-"xlc -G"} ;;
Chris@4 323 # send working options for other systems to zlib@gzip.org
Chris@4 324 *) SFLAGS=${CFLAGS-"-O"}
Chris@4 325 CFLAGS=${CFLAGS-"-O"}
Chris@4 326 LDSHARED=${LDSHARED-"cc -shared"} ;;
Chris@4 327 esac
Chris@4 328 fi
Chris@4 329
Chris@4 330 # destination names for shared library if not defined above
Chris@4 331 SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
Chris@4 332 SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
Chris@4 333 SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
Chris@4 334
Chris@4 335 echo >> configure.log
Chris@4 336
Chris@4 337 # see if shared library build supported
Chris@4 338 if test $shared -eq 1; then
Chris@4 339 echo Checking for shared library support... | tee -a configure.log
Chris@4 340 # we must test in two steps (cc then ld), required at least on SunOS 4.x
Chris@4 341 if try $CC -w -c $SFLAGS $test.c &&
Chris@4 342 try $LDSHARED $SFLAGS -o $test$shared_ext $test.o; then
Chris@4 343 echo Building shared library $SHAREDLIBV with $CC. | tee -a configure.log
Chris@4 344 elif test -z "$old_cc" -a -z "$old_cflags"; then
Chris@4 345 echo No shared library support. | tee -a configure.log
Chris@4 346 shared=0;
Chris@4 347 else
Chris@4 348 echo 'No shared library support; try without defining CC and CFLAGS' | tee -a configure.log
Chris@4 349 shared=0;
Chris@4 350 fi
Chris@4 351 fi
Chris@4 352 if test $shared -eq 0; then
Chris@4 353 LDSHARED="$CC"
Chris@4 354 ALL="static"
Chris@4 355 TEST="all teststatic"
Chris@4 356 SHAREDLIB=""
Chris@4 357 SHAREDLIBV=""
Chris@4 358 SHAREDLIBM=""
Chris@4 359 echo Building static library $STATICLIB version $VER with $CC. | tee -a configure.log
Chris@4 360 else
Chris@4 361 ALL="static shared"
Chris@4 362 TEST="all teststatic testshared"
Chris@4 363 fi
Chris@4 364
Chris@4 365 echo >> configure.log
Chris@4 366
Chris@4 367 # check for underscores in external names for use by assembler code
Chris@4 368 CPP=${CPP-"$CC -E"}
Chris@4 369 case $CFLAGS in
Chris@4 370 *ASMV*)
Chris@4 371 echo >> configure.log
Chris@4 372 show "$NM $test.o | grep _hello"
Chris@4 373 if test "`$NM $test.o | grep _hello | tee -a configure.log`" = ""; then
Chris@4 374 CPP="$CPP -DNO_UNDERLINE"
Chris@4 375 echo Checking for underline in external names... No. | tee -a configure.log
Chris@4 376 else
Chris@4 377 echo Checking for underline in external names... Yes. | tee -a configure.log
Chris@4 378 fi ;;
Chris@4 379 esac
Chris@4 380
Chris@4 381 echo >> configure.log
Chris@4 382
Chris@4 383 # check for large file support, and if none, check for fseeko()
Chris@4 384 cat > $test.c <<EOF
Chris@4 385 #include <sys/types.h>
Chris@4 386 off64_t dummy = 0;
Chris@4 387 EOF
Chris@4 388 if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then
Chris@4 389 CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1"
Chris@4 390 SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1"
Chris@4 391 ALL="${ALL} all64"
Chris@4 392 TEST="${TEST} test64"
Chris@4 393 echo "Checking for off64_t... Yes." | tee -a configure.log
Chris@4 394 echo "Checking for fseeko... Yes." | tee -a configure.log
Chris@4 395 else
Chris@4 396 echo "Checking for off64_t... No." | tee -a configure.log
Chris@4 397 echo >> configure.log
Chris@4 398 cat > $test.c <<EOF
Chris@4 399 #include <stdio.h>
Chris@4 400 int main(void) {
Chris@4 401 fseeko(NULL, 0, 0);
Chris@4 402 return 0;
Chris@4 403 }
Chris@4 404 EOF
Chris@4 405 if try $CC $CFLAGS -o $test $test.c; then
Chris@4 406 echo "Checking for fseeko... Yes." | tee -a configure.log
Chris@4 407 else
Chris@4 408 CFLAGS="${CFLAGS} -DNO_FSEEKO"
Chris@4 409 SFLAGS="${SFLAGS} -DNO_FSEEKO"
Chris@4 410 echo "Checking for fseeko... No." | tee -a configure.log
Chris@4 411 fi
Chris@4 412 fi
Chris@4 413
Chris@4 414 echo >> configure.log
Chris@4 415
Chris@4 416 # check for strerror() for use by gz* functions
Chris@4 417 cat > $test.c <<EOF
Chris@4 418 #include <string.h>
Chris@4 419 #include <errno.h>
Chris@4 420 int main() { return strlen(strerror(errno)); }
Chris@4 421 EOF
Chris@4 422 if try $CC $CFLAGS -o $test $test.c; then
Chris@4 423 echo "Checking for strerror... Yes." | tee -a configure.log
Chris@4 424 else
Chris@4 425 CFLAGS="${CFLAGS} -DNO_STRERROR"
Chris@4 426 SFLAGS="${SFLAGS} -DNO_STRERROR"
Chris@4 427 echo "Checking for strerror... No." | tee -a configure.log
Chris@4 428 fi
Chris@4 429
Chris@4 430 # copy clean zconf.h for subsequent edits
Chris@4 431 cp -p zconf.h.in zconf.h
Chris@4 432
Chris@4 433 echo >> configure.log
Chris@4 434
Chris@4 435 # check for unistd.h and save result in zconf.h
Chris@4 436 cat > $test.c <<EOF
Chris@4 437 #include <unistd.h>
Chris@4 438 int main() { return 0; }
Chris@4 439 EOF
Chris@4 440 if try $CC -c $CFLAGS $test.c; then
Chris@4 441 sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
Chris@4 442 mv zconf.temp.h zconf.h
Chris@4 443 echo "Checking for unistd.h... Yes." | tee -a configure.log
Chris@4 444 else
Chris@4 445 echo "Checking for unistd.h... No." | tee -a configure.log
Chris@4 446 fi
Chris@4 447
Chris@4 448 echo >> configure.log
Chris@4 449
Chris@4 450 # check for stdarg.h and save result in zconf.h
Chris@4 451 cat > $test.c <<EOF
Chris@4 452 #include <stdarg.h>
Chris@4 453 int main() { return 0; }
Chris@4 454 EOF
Chris@4 455 if try $CC -c $CFLAGS $test.c; then
Chris@4 456 sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
Chris@4 457 mv zconf.temp.h zconf.h
Chris@4 458 echo "Checking for stdarg.h... Yes." | tee -a configure.log
Chris@4 459 else
Chris@4 460 echo "Checking for stdarg.h... No." | tee -a configure.log
Chris@4 461 fi
Chris@4 462
Chris@4 463 # if the z_ prefix was requested, save that in zconf.h
Chris@4 464 if test $zprefix -eq 1; then
Chris@4 465 sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h
Chris@4 466 mv zconf.temp.h zconf.h
Chris@4 467 echo >> configure.log
Chris@4 468 echo "Using z_ prefix on all symbols." | tee -a configure.log
Chris@4 469 fi
Chris@4 470
Chris@4 471 # if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists
Chris@4 472 if test $solo -eq 1; then
Chris@4 473 sed '/#define ZCONF_H/a\
Chris@4 474 #define Z_SOLO
Chris@4 475
Chris@4 476 ' < zconf.h > zconf.temp.h
Chris@4 477 mv zconf.temp.h zconf.h
Chris@4 478 OBJC='$(OBJZ)'
Chris@4 479 PIC_OBJC='$(PIC_OBJZ)'
Chris@4 480 fi
Chris@4 481
Chris@4 482 # if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
Chris@4 483 if test $cover -eq 1; then
Chris@4 484 CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
Chris@4 485 if test -n "$GCC_CLASSIC"; then
Chris@4 486 CC=$GCC_CLASSIC
Chris@4 487 fi
Chris@4 488 fi
Chris@4 489
Chris@4 490 echo >> configure.log
Chris@4 491
Chris@4 492 # conduct a series of tests to resolve eight possible cases of using "vs" or "s" printf functions
Chris@4 493 # (using stdarg or not), with or without "n" (proving size of buffer), and with or without a
Chris@4 494 # return value. The most secure result is vsnprintf() with a return value. snprintf() with a
Chris@4 495 # return value is secure as well, but then gzprintf() will be limited to 20 arguments.
Chris@4 496 cat > $test.c <<EOF
Chris@4 497 #include <stdio.h>
Chris@4 498 #include <stdarg.h>
Chris@4 499 #include "zconf.h"
Chris@4 500 int main()
Chris@4 501 {
Chris@4 502 #ifndef STDC
Chris@4 503 choke me
Chris@4 504 #endif
Chris@4 505 return 0;
Chris@4 506 }
Chris@4 507 EOF
Chris@4 508 if try $CC -c $CFLAGS $test.c; then
Chris@4 509 echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." | tee -a configure.log
Chris@4 510
Chris@4 511 echo >> configure.log
Chris@4 512 cat > $test.c <<EOF
Chris@4 513 #include <stdio.h>
Chris@4 514 #include <stdarg.h>
Chris@4 515 int mytest(const char *fmt, ...)
Chris@4 516 {
Chris@4 517 char buf[20];
Chris@4 518 va_list ap;
Chris@4 519 va_start(ap, fmt);
Chris@4 520 vsnprintf(buf, sizeof(buf), fmt, ap);
Chris@4 521 va_end(ap);
Chris@4 522 return 0;
Chris@4 523 }
Chris@4 524 int main()
Chris@4 525 {
Chris@4 526 return (mytest("Hello%d\n", 1));
Chris@4 527 }
Chris@4 528 EOF
Chris@4 529 if try $CC $CFLAGS -o $test $test.c; then
Chris@4 530 echo "Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log
Chris@4 531
Chris@4 532 echo >> configure.log
Chris@4 533 cat >$test.c <<EOF
Chris@4 534 #include <stdio.h>
Chris@4 535 #include <stdarg.h>
Chris@4 536 int mytest(const char *fmt, ...)
Chris@4 537 {
Chris@4 538 int n;
Chris@4 539 char buf[20];
Chris@4 540 va_list ap;
Chris@4 541 va_start(ap, fmt);
Chris@4 542 n = vsnprintf(buf, sizeof(buf), fmt, ap);
Chris@4 543 va_end(ap);
Chris@4 544 return n;
Chris@4 545 }
Chris@4 546 int main()
Chris@4 547 {
Chris@4 548 return (mytest("Hello%d\n", 1));
Chris@4 549 }
Chris@4 550 EOF
Chris@4 551
Chris@4 552 if try $CC -c $CFLAGS $test.c; then
Chris@4 553 echo "Checking for return value of vsnprintf()... Yes." | tee -a configure.log
Chris@4 554 else
Chris@4 555 CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
Chris@4 556 SFLAGS="$SFLAGS -DHAS_vsnprintf_void"
Chris@4 557 echo "Checking for return value of vsnprintf()... No." | tee -a configure.log
Chris@4 558 echo " WARNING: apparently vsnprintf() does not return a value. zlib" | tee -a configure.log
Chris@4 559 echo " can build but will be open to possible string-format security" | tee -a configure.log
Chris@4 560 echo " vulnerabilities." | tee -a configure.log
Chris@4 561 fi
Chris@4 562 else
Chris@4 563 CFLAGS="$CFLAGS -DNO_vsnprintf"
Chris@4 564 SFLAGS="$SFLAGS -DNO_vsnprintf"
Chris@4 565 echo "Checking for vsnprintf() in stdio.h... No." | tee -a configure.log
Chris@4 566 echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log
Chris@4 567 echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
Chris@4 568 echo " vulnerabilities." | tee -a configure.log
Chris@4 569
Chris@4 570 echo >> configure.log
Chris@4 571 cat >$test.c <<EOF
Chris@4 572 #include <stdio.h>
Chris@4 573 #include <stdarg.h>
Chris@4 574 int mytest(const char *fmt, ...)
Chris@4 575 {
Chris@4 576 int n;
Chris@4 577 char buf[20];
Chris@4 578 va_list ap;
Chris@4 579 va_start(ap, fmt);
Chris@4 580 n = vsprintf(buf, fmt, ap);
Chris@4 581 va_end(ap);
Chris@4 582 return n;
Chris@4 583 }
Chris@4 584 int main()
Chris@4 585 {
Chris@4 586 return (mytest("Hello%d\n", 1));
Chris@4 587 }
Chris@4 588 EOF
Chris@4 589
Chris@4 590 if try $CC -c $CFLAGS $test.c; then
Chris@4 591 echo "Checking for return value of vsprintf()... Yes." | tee -a configure.log
Chris@4 592 else
Chris@4 593 CFLAGS="$CFLAGS -DHAS_vsprintf_void"
Chris@4 594 SFLAGS="$SFLAGS -DHAS_vsprintf_void"
Chris@4 595 echo "Checking for return value of vsprintf()... No." | tee -a configure.log
Chris@4 596 echo " WARNING: apparently vsprintf() does not return a value. zlib" | tee -a configure.log
Chris@4 597 echo " can build but will be open to possible string-format security" | tee -a configure.log
Chris@4 598 echo " vulnerabilities." | tee -a configure.log
Chris@4 599 fi
Chris@4 600 fi
Chris@4 601 else
Chris@4 602 echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." | tee -a configure.log
Chris@4 603
Chris@4 604 echo >> configure.log
Chris@4 605 cat >$test.c <<EOF
Chris@4 606 #include <stdio.h>
Chris@4 607 int mytest()
Chris@4 608 {
Chris@4 609 char buf[20];
Chris@4 610 snprintf(buf, sizeof(buf), "%s", "foo");
Chris@4 611 return 0;
Chris@4 612 }
Chris@4 613 int main()
Chris@4 614 {
Chris@4 615 return (mytest());
Chris@4 616 }
Chris@4 617 EOF
Chris@4 618
Chris@4 619 if try $CC $CFLAGS -o $test $test.c; then
Chris@4 620 echo "Checking for snprintf() in stdio.h... Yes." | tee -a configure.log
Chris@4 621
Chris@4 622 echo >> configure.log
Chris@4 623 cat >$test.c <<EOF
Chris@4 624 #include <stdio.h>
Chris@4 625 int mytest()
Chris@4 626 {
Chris@4 627 char buf[20];
Chris@4 628 return snprintf(buf, sizeof(buf), "%s", "foo");
Chris@4 629 }
Chris@4 630 int main()
Chris@4 631 {
Chris@4 632 return (mytest());
Chris@4 633 }
Chris@4 634 EOF
Chris@4 635
Chris@4 636 if try $CC -c $CFLAGS $test.c; then
Chris@4 637 echo "Checking for return value of snprintf()... Yes." | tee -a configure.log
Chris@4 638 else
Chris@4 639 CFLAGS="$CFLAGS -DHAS_snprintf_void"
Chris@4 640 SFLAGS="$SFLAGS -DHAS_snprintf_void"
Chris@4 641 echo "Checking for return value of snprintf()... No." | tee -a configure.log
Chris@4 642 echo " WARNING: apparently snprintf() does not return a value. zlib" | tee -a configure.log
Chris@4 643 echo " can build but will be open to possible string-format security" | tee -a configure.log
Chris@4 644 echo " vulnerabilities." | tee -a configure.log
Chris@4 645 fi
Chris@4 646 else
Chris@4 647 CFLAGS="$CFLAGS -DNO_snprintf"
Chris@4 648 SFLAGS="$SFLAGS -DNO_snprintf"
Chris@4 649 echo "Checking for snprintf() in stdio.h... No." | tee -a configure.log
Chris@4 650 echo " WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log
Chris@4 651 echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
Chris@4 652 echo " vulnerabilities." | tee -a configure.log
Chris@4 653
Chris@4 654 echo >> configure.log
Chris@4 655 cat >$test.c <<EOF
Chris@4 656 #include <stdio.h>
Chris@4 657 int mytest()
Chris@4 658 {
Chris@4 659 char buf[20];
Chris@4 660 return sprintf(buf, "%s", "foo");
Chris@4 661 }
Chris@4 662 int main()
Chris@4 663 {
Chris@4 664 return (mytest());
Chris@4 665 }
Chris@4 666 EOF
Chris@4 667
Chris@4 668 if try $CC -c $CFLAGS $test.c; then
Chris@4 669 echo "Checking for return value of sprintf()... Yes." | tee -a configure.log
Chris@4 670 else
Chris@4 671 CFLAGS="$CFLAGS -DHAS_sprintf_void"
Chris@4 672 SFLAGS="$SFLAGS -DHAS_sprintf_void"
Chris@4 673 echo "Checking for return value of sprintf()... No." | tee -a configure.log
Chris@4 674 echo " WARNING: apparently sprintf() does not return a value. zlib" | tee -a configure.log
Chris@4 675 echo " can build but will be open to possible string-format security" | tee -a configure.log
Chris@4 676 echo " vulnerabilities." | tee -a configure.log
Chris@4 677 fi
Chris@4 678 fi
Chris@4 679 fi
Chris@4 680
Chris@4 681 # see if we can hide zlib internal symbols that are linked between separate source files
Chris@4 682 if test "$gcc" -eq 1; then
Chris@4 683 echo >> configure.log
Chris@4 684 cat > $test.c <<EOF
Chris@4 685 #define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
Chris@4 686 int ZLIB_INTERNAL foo;
Chris@4 687 int main()
Chris@4 688 {
Chris@4 689 return 0;
Chris@4 690 }
Chris@4 691 EOF
Chris@4 692 if tryboth $CC -c $CFLAGS $test.c; then
Chris@4 693 CFLAGS="$CFLAGS -DHAVE_HIDDEN"
Chris@4 694 SFLAGS="$SFLAGS -DHAVE_HIDDEN"
Chris@4 695 echo "Checking for attribute(visibility) support... Yes." | tee -a configure.log
Chris@4 696 else
Chris@4 697 echo "Checking for attribute(visibility) support... No." | tee -a configure.log
Chris@4 698 fi
Chris@4 699 fi
Chris@4 700
Chris@4 701 echo >> configure.log
Chris@4 702
Chris@4 703 # find a four-byte unsiged integer type for crc calculations
Chris@4 704 cat > $test.c <<EOF
Chris@4 705 #include <stdio.h>
Chris@4 706 #define is32(n,t) for(n=1,k=0;n;n<<=1,k++);if(k==32){puts(t);return 0;}
Chris@4 707 int main() {
Chris@4 708 int k;
Chris@4 709 unsigned i;
Chris@4 710 unsigned long l;
Chris@4 711 unsigned short s;
Chris@4 712 is32(i, "unsigned")
Chris@4 713 is32(l, "unsigned long")
Chris@4 714 is32(s, "unsigned short")
Chris@4 715 return 1;
Chris@4 716 }
Chris@4 717 EOF
Chris@4 718 Z_U4=""
Chris@4 719 if try $CC $CFLAGS $test.c -o $test && Z_U4=`./$test` && test -n "$Z_U4"; then
Chris@4 720 sed < zconf.h "/#define Z_U4/s/\/\* \.\/configure may/#define Z_U4 $Z_U4 \/* .\/configure put the/" > zconf.temp.h
Chris@4 721 mv zconf.temp.h zconf.h
Chris@4 722 echo "Looking for a four-byte integer type... Found." | tee -a configure.log
Chris@4 723 else
Chris@4 724 echo "Looking for a four-byte integer type... Not found." | tee -a configure.log
Chris@4 725 fi
Chris@4 726
Chris@4 727 # clean up files produced by running the compiler and linker
Chris@4 728 rm -f $test.[co] $test $test$shared_ext $test.gcno
Chris@4 729
Chris@4 730 # show the results in the log
Chris@4 731 echo >> configure.log
Chris@4 732 echo ALL = $ALL >> configure.log
Chris@4 733 echo AR = $AR >> configure.log
Chris@4 734 echo ARFLAGS = $ARFLAGS >> configure.log
Chris@4 735 echo CC = $CC >> configure.log
Chris@4 736 echo CFLAGS = $CFLAGS >> configure.log
Chris@4 737 echo CPP = $CPP >> configure.log
Chris@4 738 echo EXE = $EXE >> configure.log
Chris@4 739 echo LDCONFIG = $LDCONFIG >> configure.log
Chris@4 740 echo LDFLAGS = $LDFLAGS >> configure.log
Chris@4 741 echo LDSHARED = $LDSHARED >> configure.log
Chris@4 742 echo LDSHAREDLIBC = $LDSHAREDLIBC >> configure.log
Chris@4 743 echo OBJC = $OBJC >> configure.log
Chris@4 744 echo PIC_OBJC = $PIC_OBJC >> configure.log
Chris@4 745 echo RANLIB = $RANLIB >> configure.log
Chris@4 746 echo SFLAGS = $SFLAGS >> configure.log
Chris@4 747 echo SHAREDLIB = $SHAREDLIB >> configure.log
Chris@4 748 echo SHAREDLIBM = $SHAREDLIBM >> configure.log
Chris@4 749 echo SHAREDLIBV = $SHAREDLIBV >> configure.log
Chris@4 750 echo STATICLIB = $STATICLIB >> configure.log
Chris@4 751 echo TEST = $TEST >> configure.log
Chris@4 752 echo VER = $VER >> configure.log
Chris@4 753 echo Z_U4 = $Z_U4 >> configure.log
Chris@4 754 echo exec_prefix = $exec_prefix >> configure.log
Chris@4 755 echo includedir = $includedir >> configure.log
Chris@4 756 echo libdir = $libdir >> configure.log
Chris@4 757 echo mandir = $mandir >> configure.log
Chris@4 758 echo prefix = $prefix >> configure.log
Chris@4 759 echo sharedlibdir = $sharedlibdir >> configure.log
Chris@4 760 echo uname = $uname >> configure.log
Chris@4 761 echo -------------------- >> configure.log
Chris@4 762 echo >> configure.log
Chris@4 763 echo >> configure.log
Chris@4 764
Chris@4 765 # udpate Makefile with the configure results
Chris@4 766 sed < Makefile.in "
Chris@4 767 /^CC *=/s#=.*#=$CC#
Chris@4 768 /^CFLAGS *=/s#=.*#=$CFLAGS#
Chris@4 769 /^SFLAGS *=/s#=.*#=$SFLAGS#
Chris@4 770 /^LDFLAGS *=/s#=.*#=$LDFLAGS#
Chris@4 771 /^LDSHARED *=/s#=.*#=$LDSHARED#
Chris@4 772 /^CPP *=/s#=.*#=$CPP#
Chris@4 773 /^STATICLIB *=/s#=.*#=$STATICLIB#
Chris@4 774 /^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
Chris@4 775 /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
Chris@4 776 /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
Chris@4 777 /^AR *=/s#=.*#=$AR#
Chris@4 778 /^ARFLAGS *=/s#=.*#=$ARFLAGS#
Chris@4 779 /^RANLIB *=/s#=.*#=$RANLIB#
Chris@4 780 /^LDCONFIG *=/s#=.*#=$LDCONFIG#
Chris@4 781 /^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
Chris@4 782 /^EXE *=/s#=.*#=$EXE#
Chris@4 783 /^prefix *=/s#=.*#=$prefix#
Chris@4 784 /^exec_prefix *=/s#=.*#=$exec_prefix#
Chris@4 785 /^libdir *=/s#=.*#=$libdir#
Chris@4 786 /^sharedlibdir *=/s#=.*#=$sharedlibdir#
Chris@4 787 /^includedir *=/s#=.*#=$includedir#
Chris@4 788 /^mandir *=/s#=.*#=$mandir#
Chris@4 789 /^OBJC *=/s#=.*#= $OBJC#
Chris@4 790 /^PIC_OBJC *=/s#=.*#= $PIC_OBJC#
Chris@4 791 /^all: */s#:.*#: $ALL#
Chris@4 792 /^test: */s#:.*#: $TEST#
Chris@4 793 " > Makefile
Chris@4 794
Chris@4 795 # create zlib.pc with the configure results
Chris@4 796 sed < zlib.pc.in "
Chris@4 797 /^CC *=/s#=.*#=$CC#
Chris@4 798 /^CFLAGS *=/s#=.*#=$CFLAGS#
Chris@4 799 /^CPP *=/s#=.*#=$CPP#
Chris@4 800 /^LDSHARED *=/s#=.*#=$LDSHARED#
Chris@4 801 /^STATICLIB *=/s#=.*#=$STATICLIB#
Chris@4 802 /^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
Chris@4 803 /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
Chris@4 804 /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
Chris@4 805 /^AR *=/s#=.*#=$AR#
Chris@4 806 /^ARFLAGS *=/s#=.*#=$ARFLAGS#
Chris@4 807 /^RANLIB *=/s#=.*#=$RANLIB#
Chris@4 808 /^EXE *=/s#=.*#=$EXE#
Chris@4 809 /^prefix *=/s#=.*#=$prefix#
Chris@4 810 /^exec_prefix *=/s#=.*#=$exec_prefix#
Chris@4 811 /^libdir *=/s#=.*#=$libdir#
Chris@4 812 /^sharedlibdir *=/s#=.*#=$sharedlibdir#
Chris@4 813 /^includedir *=/s#=.*#=$includedir#
Chris@4 814 /^mandir *=/s#=.*#=$mandir#
Chris@4 815 /^LDFLAGS *=/s#=.*#=$LDFLAGS#
Chris@4 816 " | sed -e "
Chris@4 817 s/\@VERSION\@/$VER/g;
Chris@4 818 " > zlib.pc