annotate src/zlib-1.2.8/configure @ 56:af97cad61ff0

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