cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo Sirainen# configure script for zlib.
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo Sirainen# Normally configure builds both a static and a shared library.
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo Sirainen# If you want to build just a static library, use: ./configure --static
a1607f6001a9949e1cf9d49eb0aa936dbb4c77ffTimo Sirainen# To impose specific compiler or flags or install directory, use for example:
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo Sirainen# prefix=$HOME CC=cc CFLAGS="-O4" ./configure
00d58fcfe8191d6ce7efa801d289a5c0fe88d1aeTimo Sirainen# or for csh/tcsh users:
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo Sirainen# (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure)
f6d57a2c182f63cd52819f0abb3c3d9f828afe19Timo Sirainen# Incorrect settings of CC or CFLAGS may prevent creating a shared library.
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo Sirainen# If you have problems, try without defining CC and CFLAGS before reporting
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo Sirainenecho -------------------- >> configure.log
8e371a3ce32bd64288786855b8ce0cb63f19f7d1Timo Sirainenif [ -n "${CHOST}" ]; then
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`"
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo SirainenVER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo SirainenVER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < zlib.h`
f6d57a2c182f63cd52819f0abb3c3d9f828afe19Timo SirainenVER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h`
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo SirainenVER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h`
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo Sirainenif "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then
8e371a3ce32bd64288786855b8ce0cb63f19f7d1Timo Sirainen test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo Sirainen test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
cbc61fcb33b370d049c16a3c44568b4deb4e2b33Timo Sirainenif "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null || test $? -lt 126; then
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo Sirainen test -n "${CROSS_PREFIX}" && echo Using ${RANLIB} | tee -a configure.log
8e371a3ce32bd64288786855b8ce0cb63f19f7d1Timo Sirainenif "${CROSS_PREFIX}nm" --version >/dev/null 2>/dev/null || test $? -lt 126; then
8e371a3ce32bd64288786855b8ce0cb63f19f7d1Timo Sirainen test -n "${CROSS_PREFIX}" && echo Using ${NM} | tee -a configure.log
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo Sirainen echo ' configure [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo Sirainen echo ' [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo Sirainen echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log
cbc61fcb33b370d049c16a3c44568b4deb4e2b33Timo Sirainen -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;;
e07bf3772a2bc075de4915ad0961beb8d083c22dTimo Sirainen -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;;
e07bf3772a2bc075de4915ad0961beb8d083c22dTimo Sirainen -l*=* | --libdir=*) libdir=`echo $1 | sed 's/.*=//'`; shift ;;
73b50eecfc31750a312e2f940023f522eb07178cTimo Sirainen --sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/.*=//'`; shift ;;
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo Sirainen -i*=* | --includedir=*) includedir=`echo $1 | sed 's/.*=//'`;shift ;;
cbc61fcb33b370d049c16a3c44568b4deb4e2b33Timo Sirainen -u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;;
e07bf3772a2bc075de4915ad0961beb8d083c22dTimo Sirainen -e* | --eprefix) exec_prefix="$2"; shift; shift ;;
e07bf3772a2bc075de4915ad0961beb8d083c22dTimo Sirainen -i* | --includedir) includedir="$2"; shift; shift ;;
e07bf3772a2bc075de4915ad0961beb8d083c22dTimo Sirainen -s* | --shared | --enable-shared) shared=1; shift ;;
bbd4c4cf902539c25c471157eb9849459734759cTimo Sirainen -a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
bbd4c4cf902539c25c471157eb9849459734759cTimo Sirainen --sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;;
bbd4c4cf902539c25c471157eb9849459734759cTimo Sirainen --localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;;
bbd4c4cf902539c25c471157eb9849459734759cTimo Sirainen *) echo "unknown option: $1"; echo "$0 --help for help" | tee -a configure.log; exit 1 ;;
bbd4c4cf902539c25c471157eb9849459734759cTimo Sirainen echo === $test.c === >> configure.log
d66be2bebfa96e7d3d20e2153f60e6e25dcc9a18Timo Sirainen test "`( $* ) 2>&1 | tee -a configure.log`" = ""
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainen echo - using any output from compiler to indicate an error >> configure.log
fd35227c47190afc832579ca5c76524792701bf7Timo Sirainen if test $ret -ne 0; then
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo Sirainenextern int getchar();
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo Sirainenint hello() {return getchar();}
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo Sirainentest -z "$CC" && echo Checking for ${CROSS_PREFIX}gcc... | tee -a configure.log
d66be2bebfa96e7d3d20e2153f60e6e25dcc9a18Timo Sirainen# to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
fd35227c47190afc832579ca5c76524792701bf7Timo Sirainenif test "$gcc" -eq 1 && ($cc -c $cflags $test.c) >> configure.log 2>&1; then
bbd4c4cf902539c25c471157eb9849459734759cTimo Sirainen if test -z "$uname"; then
bbd4c4cf902539c25c471157eb9849459734759cTimo Sirainen uname=`(uname -s || echo unknown) 2>/dev/null`
bbd4c4cf902539c25c471157eb9849459734759cTimo Sirainen LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"} ;;
bbd4c4cf902539c25c471157eb9849459734759cTimo Sirainen LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"}
2e263a9d901483a902720a30c474761bd3324fe8Timo Sirainen# temporary bypass
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainen echo "Please use win32/Makefile.gcc instead." | tee -a configure.log
bbd4c4cf902539c25c471157eb9849459734759cTimo Sirainen QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
1dc6f277f5ac6a3dd5cd6aa75a7ef691de9acb7aTimo Sirainen # (alain.bonnefoy@icbt.com)
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainen LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo Sirainen case `(uname -m || echo unknown) 2>/dev/null` in
73b50eecfc31750a312e2f940023f522eb07178cTimo Sirainen LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo Sirainen # find system name and corresponding cc options
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo Sirainen if test -z "$uname"; then
73b50eecfc31750a312e2f940023f522eb07178cTimo Sirainen uname=`(uname -sr || echo unknown) 2>/dev/null`
539977f9257bd8985be5a8093658da266ae9cd19Timo Sirainen# LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
539977f9257bd8985be5a8093658da266ae9cd19Timo Sirainen case `(uname -m || echo unknown) 2>/dev/null` in
539977f9257bd8985be5a8093658da266ae9cd19Timo Sirainen LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
cbc61fcb33b370d049c16a3c44568b4deb4e2b33Timo Sirainen LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;;
cbc61fcb33b370d049c16a3c44568b4deb4e2b33Timo Sirainen LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo Sirainen SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
bd4d0a1a7c0626452b8d82f37e3ec07267ac9896Timo Sirainen case `(uname -m || echo unknown) 2>/dev/null` in
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo Sirainen SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
539977f9257bd8985be5a8093658da266ae9cd19Timo Sirainen CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"}
56963ffad65b860c827553dfaf09fb766cb7e20eTimo Sirainen AIX*) # Courtesy of dbakker@arrayasolutions.com
f6d57a2c182f63cd52819f0abb3c3d9f828afe19Timo Sirainen # send working options for other systems to zlib@gzip.org
f6d57a2c182f63cd52819f0abb3c3d9f828afe19Timo SirainenSHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
cf7164ece50797a67fc4bfb5889022ac93a36a8aTimo SirainenSHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
f6d57a2c182f63cd52819f0abb3c3d9f828afe19Timo Sirainen echo Checking for shared library support... | tee -a configure.log
f6d57a2c182f63cd52819f0abb3c3d9f828afe19Timo Sirainen # we must test in two steps (cc then ld), required at least on SunOS 4.x
f6d57a2c182f63cd52819f0abb3c3d9f828afe19Timo Sirainen try $LDSHARED $SFLAGS -o $test$shared_ext $test.o; then
f6d57a2c182f63cd52819f0abb3c3d9f828afe19Timo Sirainen echo Building shared library $SHAREDLIBV with $CC. | tee -a configure.log
f6d57a2c182f63cd52819f0abb3c3d9f828afe19Timo Sirainen elif test -z "$old_cc" -a -z "$old_cflags"; then
f6d57a2c182f63cd52819f0abb3c3d9f828afe19Timo Sirainen echo No shared library support. | tee -a configure.log
f6d57a2c182f63cd52819f0abb3c3d9f828afe19Timo Sirainen echo 'No shared library support; try without defining CC and CFLAGS' | tee -a configure.log
9514dbd41faad453406fc3a10aca791417a9ce75Timo Sirainen echo Building static library $STATICLIB version $VER with $CC. | tee -a configure.log
539977f9257bd8985be5a8093658da266ae9cd19Timo Sirainen if test "`$NM $test.o | grep _hello | tee -a configure.log`" = ""; then
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen echo Checking for underline in external names... No. | tee -a configure.log
539977f9257bd8985be5a8093658da266ae9cd19Timo Sirainen echo Checking for underline in external names... Yes. | tee -a configure.log
4073f0dbf3277f981a8fcee3b89ea15aaf380a7fTimo Sirainen#include <sys/types.h>
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainenoff64_t dummy = 0;
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainenif try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then
5666a3d6a7ea89362b8d9e8b39b15424cd9d6388Timo Sirainen echo "Checking for off64_t... Yes." | tee -a configure.log
5666a3d6a7ea89362b8d9e8b39b15424cd9d6388Timo Sirainen echo "Checking for fseeko... Yes." | tee -a configure.log
539977f9257bd8985be5a8093658da266ae9cd19Timo Sirainen echo "Checking for off64_t... No." | tee -a configure.log
5666a3d6a7ea89362b8d9e8b39b15424cd9d6388Timo Sirainen#include <stdio.h>
5666a3d6a7ea89362b8d9e8b39b15424cd9d6388Timo Sirainenint main(void) {
5666a3d6a7ea89362b8d9e8b39b15424cd9d6388Timo Sirainen fseeko(NULL, 0, 0);
5666a3d6a7ea89362b8d9e8b39b15424cd9d6388Timo Sirainen echo "Checking for fseeko... Yes." | tee -a configure.log
echo >> configure.log
sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
echo >> configure.log
sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
echo >> configure.log
echo >> configure.log
echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." | tee -a configure.log
echo >> configure.log
echo >> configure.log
echo >> configure.log
echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." | tee -a configure.log
echo >> configure.log
echo >> configure.log
echo >> configure.log
echo >> configure.log
echo >> configure.log
echo -------------------- >> configure.log
echo >> configure.log
echo >> configure.log
/^CC *=/s#=.*#=$CC#
/^CFLAGS *=/s#=.*#=$CFLAGS#
/^SFLAGS *=/s#=.*#=$SFLAGS#
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
/^LDSHARED *=/s#=.*#=$LDSHARED#
/^CPP *=/s#=.*#=$CPP#
/^STATICLIB *=/s#=.*#=$STATICLIB#
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
/^AR *=/s#=.*#=$AR#
/^ARFLAGS *=/s#=.*#=$ARFLAGS#
/^RANLIB *=/s#=.*#=$RANLIB#
/^LDCONFIG *=/s#=.*#=$LDCONFIG#
/^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
/^EXE *=/s#=.*#=$EXE#
/^prefix *=/s#=.*#=$prefix#
/^exec_prefix *=/s#=.*#=$exec_prefix#
/^libdir *=/s#=.*#=$libdir#
/^sharedlibdir *=/s#=.*#=$sharedlibdir#
/^includedir *=/s#=.*#=$includedir#
/^mandir *=/s#=.*#=$mandir#
/^OBJC *=/s#=.*#= $OBJC#
/^PIC_OBJC *=/s#=.*#= $PIC_OBJC#
/^all: */s#:.*#: $ALL#
/^test: */s#:.*#: $TEST#
/^CC *=/s#=.*#=$CC#
/^CFLAGS *=/s#=.*#=$CFLAGS#
/^CPP *=/s#=.*#=$CPP#
/^LDSHARED *=/s#=.*#=$LDSHARED#
/^STATICLIB *=/s#=.*#=$STATICLIB#
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
/^AR *=/s#=.*#=$AR#
/^ARFLAGS *=/s#=.*#=$ARFLAGS#
/^RANLIB *=/s#=.*#=$RANLIB#
/^EXE *=/s#=.*#=$EXE#
/^prefix *=/s#=.*#=$prefix#
/^exec_prefix *=/s#=.*#=$exec_prefix#
/^libdir *=/s#=.*#=$libdir#
/^sharedlibdir *=/s#=.*#=$sharedlibdir#
/^includedir *=/s#=.*#=$includedir#
/^mandir *=/s#=.*#=$mandir#
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
s/\@VERSION\@/$VER/g;