annotate src/zlib-1.2.7/configure @ 169:223a55898ab9 tip default

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