configure revision 1.1.1.2
11.1Schristos#!/bin/sh
21.1.1.2Schristos# configure script for zlib.
31.1Schristos#
41.1.1.2Schristos# Normally configure builds both a static and a shared library.
51.1.1.2Schristos# If you want to build just a static library, use: ./configure --static
61.1Schristos#
71.1Schristos# To impose specific compiler or flags or install directory, use for example:
81.1Schristos#    prefix=$HOME CC=cc CFLAGS="-O4" ./configure
91.1Schristos# or for csh/tcsh users:
101.1Schristos#    (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure)
111.1Schristos
121.1Schristos# Incorrect settings of CC or CFLAGS may prevent creating a shared library.
131.1Schristos# If you have problems, try without defining CC and CFLAGS before reporting
141.1Schristos# an error.
151.1Schristos
161.1.1.2Schristos# start off configure.log
171.1.1.2Schristosecho -------------------- >> configure.log
181.1.1.2Schristosecho $0 $* >> configure.log
191.1.1.2Schristosdate >> configure.log
201.1.1.2Schristos
211.1.1.2Schristos# get source directory
221.1.1.2SchristosSRCDIR=`dirname $0`
231.1.1.2Schristosif test $SRCDIR = "."; then
241.1.1.2Schristos    ZINC=""
251.1.1.2Schristos    ZINCOUT="-I."
261.1.1.2Schristos    SRCDIR=""
271.1.1.2Schristoselse
281.1.1.2Schristos    ZINC='-include zconf.h'
291.1.1.2Schristos    ZINCOUT='-I. -I$(SRCDIR)'
301.1.1.2Schristos    SRCDIR="$SRCDIR/"
311.1.1.2Schristosfi
321.1.1.2Schristos
331.1.1.2Schristos# set command prefix for cross-compilation
341.1.1.2Schristosif [ -n "${CHOST}" ]; then
351.1.1.2Schristos    uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`"
361.1.1.2Schristos    CROSS_PREFIX="${CHOST}-"
371.1.1.2Schristosfi
381.1.1.2Schristos
391.1.1.2Schristos# destination name for static library
401.1.1.2SchristosSTATICLIB=libz.a
411.1.1.2Schristos
421.1.1.2Schristos# extract zlib version numbers from zlib.h
431.1.1.2SchristosVER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}zlib.h`
441.1.1.2SchristosVER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < ${SRCDIR}zlib.h`
451.1.1.2SchristosVER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
461.1.1.2SchristosVER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
471.1.1.2Schristos
481.1.1.2Schristos# establish commands for library building
491.1.1.2Schristosif "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then
501.1.1.2Schristos    AR=${AR-"${CROSS_PREFIX}ar"}
511.1.1.2Schristos    test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
521.1.1.2Schristoselse
531.1.1.2Schristos    AR=${AR-"ar"}
541.1.1.2Schristos    test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
551.1.1.2Schristosfi
561.1.1.2SchristosARFLAGS=${ARFLAGS-"rc"}
571.1.1.2Schristosif "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null || test $? -lt 126; then
581.1.1.2Schristos    RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"}
591.1.1.2Schristos    test -n "${CROSS_PREFIX}" && echo Using ${RANLIB} | tee -a configure.log
601.1.1.2Schristoselse
611.1.1.2Schristos    RANLIB=${RANLIB-"ranlib"}
621.1.1.2Schristosfi
631.1.1.2Schristosif "${CROSS_PREFIX}nm" --version >/dev/null 2>/dev/null || test $? -lt 126; then
641.1.1.2Schristos    NM=${NM-"${CROSS_PREFIX}nm"}
651.1.1.2Schristos    test -n "${CROSS_PREFIX}" && echo Using ${NM} | tee -a configure.log
661.1.1.2Schristoselse
671.1.1.2Schristos    NM=${NM-"nm"}
681.1.1.2Schristosfi
691.1.1.2Schristos
701.1.1.2Schristos# set defaults before processing command line options
711.1.1.2SchristosLDCONFIG=${LDCONFIG-"ldconfig"}
721.1.1.2SchristosLDSHAREDLIBC="${LDSHAREDLIBC--lc}"
731.1.1.2SchristosARCHS=
741.1Schristosprefix=${prefix-/usr/local}
751.1Schristosexec_prefix=${exec_prefix-'${prefix}'}
761.1Schristoslibdir=${libdir-'${exec_prefix}/lib'}
771.1.1.2Schristossharedlibdir=${sharedlibdir-'${libdir}'}
781.1Schristosincludedir=${includedir-'${prefix}/include'}
791.1Schristosmandir=${mandir-'${prefix}/share/man'}
801.1Schristosshared_ext='.so'
811.1.1.2Schristosshared=1
821.1.1.2Schristossolo=0
831.1.1.2Schristoscover=0
841.1.1.2Schristoszprefix=0
851.1.1.2Schristoszconst=0
861.1.1.2Schristosbuild64=0
871.1Schristosgcc=0
881.1.1.2Schristoswarn=0
891.1.1.2Schristosdebug=0
901.1Schristosold_cc="$CC"
911.1Schristosold_cflags="$CFLAGS"
921.1.1.2SchristosOBJC='$(OBJZ) $(OBJG)'
931.1.1.2SchristosPIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)'
941.1.1.2Schristos
951.1.1.2Schristos# leave this script, optionally in a bad way
961.1.1.2Schristosleave()
971.1.1.2Schristos{
981.1.1.2Schristos  if test "$*" != "0"; then
991.1.1.2Schristos    echo "** $0 aborting." | tee -a configure.log
1001.1.1.2Schristos  fi
1011.1.1.2Schristos  rm -f $test.[co] $test $test$shared_ext $test.gcno ./--version
1021.1.1.2Schristos  echo -------------------- >> configure.log
1031.1.1.2Schristos  echo >> configure.log
1041.1.1.2Schristos  echo >> configure.log
1051.1.1.2Schristos  exit $1
1061.1.1.2Schristos}
1071.1Schristos
1081.1.1.2Schristos# process command line options
1091.1Schristoswhile test $# -ge 1
1101.1Schristosdo
1111.1Schristoscase "$1" in
1121.1.1.2Schristos    -h* | --help)
1131.1.1.2Schristos      echo 'usage:' | tee -a configure.log
1141.1.1.2Schristos      echo '  configure [--const] [--zprefix] [--prefix=PREFIX]  [--eprefix=EXPREFIX]' | tee -a configure.log
1151.1.1.2Schristos      echo '    [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log
1161.1.1.2Schristos      echo '    [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log
1171.1.1.2Schristos        exit 0 ;;
1181.1.1.2Schristos    -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;;
1191.1.1.2Schristos    -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;;
1201.1.1.2Schristos    -l*=* | --libdir=*) libdir=`echo $1 | sed 's/.*=//'`; shift ;;
1211.1.1.2Schristos    --sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/.*=//'`; shift ;;
1221.1.1.2Schristos    -i*=* | --includedir=*) includedir=`echo $1 | sed 's/.*=//'`;shift ;;
1231.1.1.2Schristos    -u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;;
1241.1.1.2Schristos    -p* | --prefix) prefix="$2"; shift; shift ;;
1251.1.1.2Schristos    -e* | --eprefix) exec_prefix="$2"; shift; shift ;;
1261.1.1.2Schristos    -l* | --libdir) libdir="$2"; shift; shift ;;
1271.1.1.2Schristos    -i* | --includedir) includedir="$2"; shift; shift ;;
1281.1.1.2Schristos    -s* | --shared | --enable-shared) shared=1; shift ;;
1291.1.1.2Schristos    -t | --static) shared=0; shift ;;
1301.1.1.2Schristos    --solo) solo=1; shift ;;
1311.1.1.2Schristos    --cover) cover=1; shift ;;
1321.1.1.2Schristos    -z* | --zprefix) zprefix=1; shift ;;
1331.1.1.2Schristos    -6* | --64) build64=1; shift ;;
1341.1.1.2Schristos    -a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
1351.1.1.2Schristos    --sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;;
1361.1.1.2Schristos    --localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;;
1371.1.1.2Schristos    -c* | --const) zconst=1; shift ;;
1381.1.1.2Schristos    -w* | --warn) warn=1; shift ;;
1391.1.1.2Schristos    -d* | --debug) debug=1; shift ;;
1401.1.1.2Schristos    *)
1411.1.1.2Schristos      echo "unknown option: $1" | tee -a configure.log
1421.1.1.2Schristos      echo "$0 --help for help" | tee -a configure.log
1431.1.1.2Schristos      leave 1;;
1441.1Schristos    esac
1451.1Schristosdone
1461.1Schristos
1471.1.1.2Schristos# temporary file name
1481.1Schristostest=ztest$$
1491.1.1.2Schristos
1501.1.1.2Schristos# put arguments in log, also put test file in log if used in arguments
1511.1.1.2Schristosshow()
1521.1.1.2Schristos{
1531.1.1.2Schristos  case "$*" in
1541.1.1.2Schristos    *$test.c*)
1551.1.1.2Schristos      echo === $test.c === >> configure.log
1561.1.1.2Schristos      cat $test.c >> configure.log
1571.1.1.2Schristos      echo === >> configure.log;;
1581.1.1.2Schristos  esac
1591.1.1.2Schristos  echo $* >> configure.log
1601.1.1.2Schristos}
1611.1.1.2Schristos
1621.1.1.2Schristos# check for gcc vs. cc and set compile and link flags based on the system identified by uname
1631.1Schristoscat > $test.c <<EOF
1641.1Schristosextern int getchar();
1651.1Schristosint hello() {return getchar();}
1661.1SchristosEOF
1671.1Schristos
1681.1.1.2Schristostest -z "$CC" && echo Checking for ${CROSS_PREFIX}gcc... | tee -a configure.log
1691.1.1.2Schristoscc=${CC-${CROSS_PREFIX}gcc}
1701.1Schristoscflags=${CFLAGS-"-O3"}
1711.1Schristos# to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
1721.1Schristoscase "$cc" in
1731.1.1.2Schristos  *gcc*) gcc=1 ;;
1741.1.1.2Schristos  *clang*) gcc=1 ;;
1751.1.1.2Schristosesac
1761.1.1.2Schristoscase `$cc -v 2>&1` in
1771.1.1.2Schristos  *gcc*) gcc=1 ;;
1781.1.1.2Schristos  *clang*) gcc=1 ;;
1791.1Schristosesac
1801.1Schristos
1811.1.1.2Schristosshow $cc -c $test.c
1821.1.1.2Schristosif test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
1831.1.1.2Schristos  echo ... using gcc >> configure.log
1841.1Schristos  CC="$cc"
1851.1.1.2Schristos  CFLAGS="${CFLAGS--O3}"
1861.1.1.2Schristos  SFLAGS="${CFLAGS--O3} -fPIC"
1871.1.1.2Schristos  if test "$ARCHS"; then
1881.1.1.2Schristos    CFLAGS="${CFLAGS} ${ARCHS}"
1891.1.1.2Schristos    LDFLAGS="${LDFLAGS} ${ARCHS}"
1901.1.1.2Schristos  fi
1911.1.1.2Schristos  if test $build64 -eq 1; then
1921.1.1.2Schristos    CFLAGS="${CFLAGS} -m64"
1931.1.1.2Schristos    SFLAGS="${SFLAGS} -m64"
1941.1.1.2Schristos  fi
1951.1.1.2Schristos  if test "$warn" -eq 1; then
1961.1.1.2Schristos    if test "$zconst" -eq 1; then
1971.1.1.2Schristos      CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -pedantic -DZLIB_CONST"
1981.1.1.2Schristos    else
1991.1.1.2Schristos      CFLAGS="${CFLAGS} -Wall -Wextra -pedantic"
2001.1.1.2Schristos    fi
2011.1.1.2Schristos  fi
2021.1.1.2Schristos  if test $debug -eq 1; then
2031.1.1.2Schristos    CFLAGS="${CFLAGS} -DZLIB_DEBUG"
2041.1.1.2Schristos    SFLAGS="${SFLAGS} -DZLIB_DEBUG"
2051.1.1.2Schristos  fi
2061.1.1.2Schristos  if test -z "$uname"; then
2071.1.1.2Schristos    uname=`(uname -s || echo unknown) 2>/dev/null`
2081.1.1.2Schristos  fi
2091.1.1.2Schristos  case "$uname" in
2101.1.1.2Schristos  Linux* | linux* | GNU | GNU/* | solaris*)
2111.1.1.2Schristos        LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;;
2121.1.1.2Schristos  *BSD | *bsd* | DragonFly)
2131.1.1.2Schristos        LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"}
2141.1.1.2Schristos        LDCONFIG="ldconfig -m" ;;
2151.1.1.2Schristos  CYGWIN* | Cygwin* | cygwin* | OS/2*)
2161.1.1.2Schristos        EXE='.exe' ;;
2171.1.1.2Schristos  MINGW* | mingw*)
2181.1.1.2Schristos# temporary bypass
2191.1.1.2Schristos        rm -f $test.[co] $test $test$shared_ext
2201.1.1.2Schristos        echo "Please use win32/Makefile.gcc instead." | tee -a configure.log
2211.1.1.2Schristos        leave 1
2221.1.1.2Schristos        LDSHARED=${LDSHARED-"$cc -shared"}
2231.1.1.2Schristos        LDSHAREDLIBC=""
2241.1.1.2Schristos        EXE='.exe' ;;
2251.1Schristos  QNX*)  # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
2261.1Schristos         # (alain.bonnefoy@icbt.com)
2271.1.1.2Schristos                 LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
2281.1Schristos  HP-UX*)
2291.1Schristos         LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
2301.1Schristos         case `(uname -m || echo unknown) 2>/dev/null` in
2311.1Schristos         ia64)
2321.1Schristos                 shared_ext='.so'
2331.1.1.2Schristos                 SHAREDLIB='libz.so' ;;
2341.1Schristos         *)
2351.1Schristos                 shared_ext='.sl'
2361.1.1.2Schristos                 SHAREDLIB='libz.sl' ;;
2371.1.1.2Schristos         esac ;;
2381.1.1.2Schristos  Darwin* | darwin*)
2391.1.1.2Schristos             shared_ext='.dylib'
2401.1Schristos             SHAREDLIB=libz$shared_ext
2411.1Schristos             SHAREDLIBV=libz.$VER$shared_ext
2421.1Schristos             SHAREDLIBM=libz.$VER1$shared_ext
2431.1.1.2Schristos             LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
2441.1.1.2Schristos             if libtool -V 2>&1 | grep Apple > /dev/null; then
2451.1.1.2Schristos                 AR="libtool"
2461.1.1.2Schristos             else
2471.1.1.2Schristos                 AR="/usr/bin/libtool"
2481.1.1.2Schristos             fi
2491.1.1.2Schristos             ARFLAGS="-o" ;;
2501.1.1.2Schristos  *)             LDSHARED=${LDSHARED-"$cc -shared"} ;;
2511.1Schristos  esac
2521.1Schristoselse
2531.1Schristos  # find system name and corresponding cc options
2541.1Schristos  CC=${CC-cc}
2551.1.1.2Schristos  gcc=0
2561.1.1.2Schristos  echo ... using $CC >> configure.log
2571.1.1.2Schristos  if test -z "$uname"; then
2581.1.1.2Schristos    uname=`(uname -sr || echo unknown) 2>/dev/null`
2591.1.1.2Schristos  fi
2601.1.1.2Schristos  case "$uname" in
2611.1Schristos  HP-UX*)    SFLAGS=${CFLAGS-"-O +z"}
2621.1Schristos             CFLAGS=${CFLAGS-"-O"}
2631.1Schristos#            LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
2641.1Schristos             LDSHARED=${LDSHARED-"ld -b"}
2651.1Schristos         case `(uname -m || echo unknown) 2>/dev/null` in
2661.1Schristos         ia64)
2671.1Schristos             shared_ext='.so'
2681.1.1.2Schristos             SHAREDLIB='libz.so' ;;
2691.1Schristos         *)
2701.1Schristos             shared_ext='.sl'
2711.1.1.2Schristos             SHAREDLIB='libz.sl' ;;
2721.1.1.2Schristos         esac ;;
2731.1Schristos  IRIX*)     SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
2741.1Schristos             CFLAGS=${CFLAGS-"-ansi -O2"}
2751.1.1.2Schristos             LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
2761.1Schristos  OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
2771.1Schristos             CFLAGS=${CFLAGS-"-O -std1"}
2781.1.1.2Schristos             LDFLAGS="${LDFLAGS} -Wl,-rpath,."
2791.1.1.2Schristos             LDSHARED=${LDSHARED-"cc -shared  -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;;
2801.1Schristos  OSF1*)     SFLAGS=${CFLAGS-"-O -std1"}
2811.1Schristos             CFLAGS=${CFLAGS-"-O -std1"}
2821.1.1.2Schristos             LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
2831.1Schristos  QNX*)      SFLAGS=${CFLAGS-"-4 -O"}
2841.1Schristos             CFLAGS=${CFLAGS-"-4 -O"}
2851.1Schristos             LDSHARED=${LDSHARED-"cc"}
2861.1Schristos             RANLIB=${RANLIB-"true"}
2871.1.1.2Schristos             AR="cc"
2881.1.1.2Schristos             ARFLAGS="-A" ;;
2891.1Schristos  SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
2901.1Schristos             CFLAGS=${CFLAGS-"-O3"}
2911.1.1.2Schristos             LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;;
2921.1.1.2Schristos  SunOS\ 5* | solaris*)
2931.1.1.2Schristos         LDSHARED=${LDSHARED-"cc -G -h libz$shared_ext.$VER1"}
2941.1.1.2Schristos         SFLAGS=${CFLAGS-"-fast -KPIC"}
2951.1.1.2Schristos         CFLAGS=${CFLAGS-"-fast"}
2961.1.1.2Schristos         if test $build64 -eq 1; then
2971.1.1.2Schristos             # old versions of SunPRO/Workshop/Studio don't support -m64,
2981.1.1.2Schristos             # but newer ones do.  Check for it.
2991.1.1.2Schristos             flag64=`$CC -flags | egrep -- '^-m64'`
3001.1.1.2Schristos             if test x"$flag64" != x"" ; then
3011.1.1.2Schristos                 CFLAGS="${CFLAGS} -m64"
3021.1.1.2Schristos                 SFLAGS="${SFLAGS} -m64"
3031.1.1.2Schristos             else
3041.1.1.2Schristos                 case `(uname -m || echo unknown) 2>/dev/null` in
3051.1.1.2Schristos                   i86*)
3061.1.1.2Schristos                     SFLAGS="$SFLAGS -xarch=amd64"
3071.1.1.2Schristos                     CFLAGS="$CFLAGS -xarch=amd64" ;;
3081.1.1.2Schristos                   *)
3091.1.1.2Schristos                     SFLAGS="$SFLAGS -xarch=v9"
3101.1.1.2Schristos                     CFLAGS="$CFLAGS -xarch=v9" ;;
3111.1.1.2Schristos                 esac
3121.1.1.2Schristos             fi
3131.1.1.2Schristos         fi
3141.1.1.2Schristos         if test -n "$ZINC"; then
3151.1.1.2Schristos             ZINC='-I- -I. -I$(SRCDIR)'
3161.1.1.2Schristos         fi
3171.1.1.2Schristos         ;;
3181.1Schristos  SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
3191.1Schristos             CFLAGS=${CFLAGS-"-O2"}
3201.1.1.2Schristos             LDSHARED=${LDSHARED-"ld"} ;;
3211.1.1.2Schristos  SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
3221.1.1.2Schristos             CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"}
3231.1.1.2Schristos             LDSHARED=${LDSHARED-"cc -xarch=v9b"} ;;
3241.1Schristos  UNIX_System_V\ 4.2.0)
3251.1Schristos             SFLAGS=${CFLAGS-"-KPIC -O"}
3261.1Schristos             CFLAGS=${CFLAGS-"-O"}
3271.1.1.2Schristos             LDSHARED=${LDSHARED-"cc -G"} ;;
3281.1Schristos  UNIX_SV\ 4.2MP)
3291.1Schristos             SFLAGS=${CFLAGS-"-Kconform_pic -O"}
3301.1Schristos             CFLAGS=${CFLAGS-"-O"}
3311.1.1.2Schristos             LDSHARED=${LDSHARED-"cc -G"} ;;
3321.1Schristos  OpenUNIX\ 5)
3331.1Schristos             SFLAGS=${CFLAGS-"-KPIC -O"}
3341.1Schristos             CFLAGS=${CFLAGS-"-O"}
3351.1.1.2Schristos             LDSHARED=${LDSHARED-"cc -G"} ;;
3361.1Schristos  AIX*)  # Courtesy of dbakker@arrayasolutions.com
3371.1Schristos             SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
3381.1Schristos             CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
3391.1.1.2Schristos             LDSHARED=${LDSHARED-"xlc -G"} ;;
3401.1.1.2Schristos  # send working options for other systems to zlib@gzip.org
3411.1Schristos  *)         SFLAGS=${CFLAGS-"-O"}
3421.1Schristos             CFLAGS=${CFLAGS-"-O"}
3431.1.1.2Schristos             LDSHARED=${LDSHARED-"cc -shared"} ;;
3441.1Schristos  esac
3451.1Schristosfi
3461.1Schristos
3471.1.1.2Schristos# destination names for shared library if not defined above
3481.1SchristosSHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
3491.1SchristosSHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
3501.1SchristosSHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
3511.1Schristos
3521.1.1.2Schristosecho >> configure.log
3531.1.1.2Schristos
3541.1.1.2Schristos# define functions for testing compiler and library characteristics and logging the results
3551.1.1.2Schristos
3561.1.1.2Schristoscat > $test.c <<EOF
3571.1.1.2Schristos#error error
3581.1.1.2SchristosEOF
3591.1.1.2Schristosif ($CC -c $CFLAGS $test.c) 2>/dev/null; then
3601.1.1.2Schristos  try()
3611.1.1.2Schristos  {
3621.1.1.2Schristos    show $*
3631.1.1.2Schristos    test "`( $* ) 2>&1 | tee -a configure.log`" = ""
3641.1.1.2Schristos  }
3651.1.1.2Schristos  echo - using any output from compiler to indicate an error >> configure.log
3661.1.1.2Schristoselse
3671.1.1.2Schristos  try()
3681.1.1.2Schristos  {
3691.1.1.2Schristos    show $*
3701.1.1.2Schristos    ( $* ) >> configure.log 2>&1
3711.1.1.2Schristos    ret=$?
3721.1.1.2Schristos    if test $ret -ne 0; then
3731.1.1.2Schristos      echo "(exit code "$ret")" >> configure.log
3741.1.1.2Schristos    fi
3751.1.1.2Schristos    return $ret
3761.1.1.2Schristos  }
3771.1.1.2Schristosfi
3781.1.1.2Schristos
3791.1.1.2Schristostryboth()
3801.1.1.2Schristos{
3811.1.1.2Schristos  show $*
3821.1.1.2Schristos  got=`( $* ) 2>&1`
3831.1.1.2Schristos  ret=$?
3841.1.1.2Schristos  printf %s "$got" >> configure.log
3851.1.1.2Schristos  if test $ret -ne 0; then
3861.1.1.2Schristos    return $ret
3871.1.1.2Schristos  fi
3881.1.1.2Schristos  test "$got" = ""
3891.1.1.2Schristos}
3901.1.1.2Schristos
3911.1.1.2Schristoscat > $test.c << EOF
3921.1.1.2Schristosint foo() { return 0; }
3931.1.1.2SchristosEOF
3941.1.1.2Schristosecho "Checking for obsessive-compulsive compiler options..." >> configure.log
3951.1.1.2Schristosif try $CC -c $CFLAGS $test.c; then
3961.1.1.2Schristos  :
3971.1.1.2Schristoselse
3981.1.1.2Schristos  echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log
3991.1.1.2Schristos  leave 1
4001.1.1.2Schristosfi
4011.1.1.2Schristos
4021.1.1.2Schristosecho >> configure.log
4031.1.1.2Schristos
4041.1.1.2Schristos# see if shared library build supported
4051.1.1.2Schristoscat > $test.c <<EOF
4061.1.1.2Schristosextern int getchar();
4071.1.1.2Schristosint hello() {return getchar();}
4081.1.1.2SchristosEOF
4091.1Schristosif test $shared -eq 1; then
4101.1.1.2Schristos  echo Checking for shared library support... | tee -a configure.log
4111.1Schristos  # we must test in two steps (cc then ld), required at least on SunOS 4.x
4121.1.1.2Schristos  if try $CC -w -c $SFLAGS $test.c &&
4131.1.1.2Schristos     try $LDSHARED $SFLAGS -o $test$shared_ext $test.o; then
4141.1.1.2Schristos    echo Building shared library $SHAREDLIBV with $CC. | tee -a configure.log
4151.1Schristos  elif test -z "$old_cc" -a -z "$old_cflags"; then
4161.1.1.2Schristos    echo No shared library support. | tee -a configure.log
4171.1Schristos    shared=0;
4181.1Schristos  else
4191.1.1.2Schristos    echo 'No shared library support; try without defining CC and CFLAGS' | tee -a configure.log
4201.1Schristos    shared=0;
4211.1Schristos  fi
4221.1Schristosfi
4231.1Schristosif test $shared -eq 0; then
4241.1Schristos  LDSHARED="$CC"
4251.1.1.2Schristos  ALL="static"
4261.1.1.2Schristos  TEST="all teststatic"
4271.1.1.2Schristos  SHAREDLIB=""
4281.1.1.2Schristos  SHAREDLIBV=""
4291.1.1.2Schristos  SHAREDLIBM=""
4301.1.1.2Schristos  echo Building static library $STATICLIB version $VER with $CC. | tee -a configure.log
4311.1.1.2Schristoselse
4321.1.1.2Schristos  ALL="static shared"
4331.1.1.2Schristos  TEST="all teststatic testshared"
4341.1.1.2Schristosfi
4351.1.1.2Schristos
4361.1.1.2Schristos# check for underscores in external names for use by assembler code
4371.1.1.2SchristosCPP=${CPP-"$CC -E"}
4381.1.1.2Schristoscase $CFLAGS in
4391.1.1.2Schristos  *ASMV*)
4401.1.1.2Schristos    echo >> configure.log
4411.1.1.2Schristos    show "$NM $test.o | grep _hello"
4421.1.1.2Schristos    if test "`$NM $test.o | grep _hello | tee -a configure.log`" = ""; then
4431.1.1.2Schristos      CPP="$CPP -DNO_UNDERLINE"
4441.1.1.2Schristos      echo Checking for underline in external names... No. | tee -a configure.log
4451.1.1.2Schristos    else
4461.1.1.2Schristos      echo Checking for underline in external names... Yes. | tee -a configure.log
4471.1.1.2Schristos    fi ;;
4481.1.1.2Schristosesac
4491.1.1.2Schristos
4501.1.1.2Schristosecho >> configure.log
4511.1.1.2Schristos
4521.1.1.2Schristos# check for size_t
4531.1.1.2Schristoscat > $test.c <<EOF
4541.1.1.2Schristos#include <stdio.h>
4551.1.1.2Schristos#include <stdlib.h>
4561.1.1.2Schristossize_t dummy = 0;
4571.1.1.2SchristosEOF
4581.1.1.2Schristosif try $CC -c $CFLAGS $test.c; then
4591.1.1.2Schristos  echo "Checking for size_t... Yes." | tee -a configure.log
4601.1.1.2Schristos  need_sizet=0
4611.1.1.2Schristoselse
4621.1.1.2Schristos  echo "Checking for size_t... No." | tee -a configure.log
4631.1.1.2Schristos  need_sizet=1
4641.1.1.2Schristosfi
4651.1.1.2Schristos
4661.1.1.2Schristosecho >> configure.log
4671.1.1.2Schristos
4681.1.1.2Schristos# find the size_t integer type, if needed
4691.1.1.2Schristosif test $need_sizet -eq 1; then
4701.1.1.2Schristos  cat > $test.c <<EOF
4711.1.1.2Schristoslong long dummy = 0;
4721.1.1.2SchristosEOF
4731.1.1.2Schristos  if try $CC -c $CFLAGS $test.c; then
4741.1.1.2Schristos    echo "Checking for long long... Yes." | tee -a configure.log
4751.1.1.2Schristos    cat > $test.c <<EOF
4761.1.1.2Schristos#include <stdio.h>
4771.1.1.2Schristosint main(void) {
4781.1.1.2Schristos    if (sizeof(void *) <= sizeof(int)) puts("int");
4791.1.1.2Schristos    else if (sizeof(void *) <= sizeof(long)) puts("long");
4801.1.1.2Schristos    else puts("z_longlong");
4811.1.1.2Schristos    return 0;
4821.1.1.2Schristos}
4831.1.1.2SchristosEOF
4841.1.1.2Schristos  else
4851.1.1.2Schristos    echo "Checking for long long... No." | tee -a configure.log
4861.1.1.2Schristos    cat > $test.c <<EOF
4871.1.1.2Schristos#include <stdio.h>
4881.1.1.2Schristosint main(void) {
4891.1.1.2Schristos    if (sizeof(void *) <= sizeof(int)) puts("int");
4901.1.1.2Schristos    else puts("long");
4911.1.1.2Schristos    return 0;
4921.1.1.2Schristos}
4931.1.1.2SchristosEOF
4941.1.1.2Schristos  fi
4951.1.1.2Schristos  if try $CC $CFLAGS -o $test $test.c; then
4961.1.1.2Schristos    sizet=`./$test`
4971.1.1.2Schristos    echo "Checking for a pointer-size integer type..." $sizet"." | tee -a configure.log
4981.1.1.2Schristos  else
4991.1.1.2Schristos    echo "Failed to find a pointer-size integer type." | tee -a configure.log
5001.1.1.2Schristos    leave 1
5011.1.1.2Schristos  fi
5021.1.1.2Schristosfi
5031.1.1.2Schristos
5041.1.1.2Schristosif test $need_sizet -eq 1; then
5051.1.1.2Schristos  CFLAGS="${CFLAGS} -DNO_SIZE_T=${sizet}"
5061.1.1.2Schristos  SFLAGS="${SFLAGS} -DNO_SIZE_T=${sizet}"
5071.1.1.2Schristosfi
5081.1.1.2Schristos
5091.1.1.2Schristosecho >> configure.log
5101.1.1.2Schristos
5111.1.1.2Schristos# check for large file support, and if none, check for fseeko()
5121.1.1.2Schristoscat > $test.c <<EOF
5131.1.1.2Schristos#include <sys/types.h>
5141.1.1.2Schristosoff64_t dummy = 0;
5151.1.1.2SchristosEOF
5161.1.1.2Schristosif try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then
5171.1.1.2Schristos  CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1"
5181.1.1.2Schristos  SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1"
5191.1.1.2Schristos  ALL="${ALL} all64"
5201.1.1.2Schristos  TEST="${TEST} test64"
5211.1.1.2Schristos  echo "Checking for off64_t... Yes." | tee -a configure.log
5221.1.1.2Schristos  echo "Checking for fseeko... Yes." | tee -a configure.log
5231.1.1.2Schristoselse
5241.1.1.2Schristos  echo "Checking for off64_t... No." | tee -a configure.log
5251.1.1.2Schristos  echo >> configure.log
5261.1.1.2Schristos  cat > $test.c <<EOF
5271.1.1.2Schristos#include <stdio.h>
5281.1.1.2Schristosint main(void) {
5291.1.1.2Schristos  fseeko(NULL, 0, 0);
5301.1.1.2Schristos  return 0;
5311.1.1.2Schristos}
5321.1.1.2SchristosEOF
5331.1.1.2Schristos  if try $CC $CFLAGS -o $test $test.c; then
5341.1.1.2Schristos    echo "Checking for fseeko... Yes." | tee -a configure.log
5351.1.1.2Schristos  else
5361.1.1.2Schristos    CFLAGS="${CFLAGS} -DNO_FSEEKO"
5371.1.1.2Schristos    SFLAGS="${SFLAGS} -DNO_FSEEKO"
5381.1.1.2Schristos    echo "Checking for fseeko... No." | tee -a configure.log
5391.1.1.2Schristos  fi
5401.1.1.2Schristosfi
5411.1.1.2Schristos
5421.1.1.2Schristosecho >> configure.log
5431.1.1.2Schristos
5441.1.1.2Schristos# check for strerror() for use by gz* functions
5451.1.1.2Schristoscat > $test.c <<EOF
5461.1.1.2Schristos#include <string.h>
5471.1.1.2Schristos#include <errno.h>
5481.1.1.2Schristosint main() { return strlen(strerror(errno)); }
5491.1.1.2SchristosEOF
5501.1.1.2Schristosif try $CC $CFLAGS -o $test $test.c; then
5511.1.1.2Schristos  echo "Checking for strerror... Yes." | tee -a configure.log
5521.1Schristoselse
5531.1.1.2Schristos  CFLAGS="${CFLAGS} -DNO_STRERROR"
5541.1.1.2Schristos  SFLAGS="${SFLAGS} -DNO_STRERROR"
5551.1.1.2Schristos  echo "Checking for strerror... No." | tee -a configure.log
5561.1Schristosfi
5571.1Schristos
5581.1.1.2Schristos# copy clean zconf.h for subsequent edits
5591.1.1.2Schristoscp -p ${SRCDIR}zconf.h.in zconf.h
5601.1.1.2Schristos
5611.1.1.2Schristosecho >> configure.log
5621.1.1.2Schristos
5631.1.1.2Schristos# check for unistd.h and save result in zconf.h
5641.1Schristoscat > $test.c <<EOF
5651.1Schristos#include <unistd.h>
5661.1Schristosint main() { return 0; }
5671.1SchristosEOF
5681.1.1.2Schristosif try $CC -c $CFLAGS $test.c; then
5691.1.1.2Schristos  sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
5701.1.1.2Schristos  mv zconf.temp.h zconf.h
5711.1.1.2Schristos  echo "Checking for unistd.h... Yes." | tee -a configure.log
5721.1Schristoselse
5731.1.1.2Schristos  echo "Checking for unistd.h... No." | tee -a configure.log
5741.1.1.2Schristosfi
5751.1.1.2Schristos
5761.1.1.2Schristosecho >> configure.log
5771.1.1.2Schristos
5781.1.1.2Schristos# check for stdarg.h and save result in zconf.h
5791.1.1.2Schristoscat > $test.c <<EOF
5801.1.1.2Schristos#include <stdarg.h>
5811.1.1.2Schristosint main() { return 0; }
5821.1.1.2SchristosEOF
5831.1.1.2Schristosif try $CC -c $CFLAGS $test.c; then
5841.1.1.2Schristos  sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
5851.1.1.2Schristos  mv zconf.temp.h zconf.h
5861.1.1.2Schristos  echo "Checking for stdarg.h... Yes." | tee -a configure.log
5871.1.1.2Schristoselse
5881.1.1.2Schristos  echo "Checking for stdarg.h... No." | tee -a configure.log
5891.1.1.2Schristosfi
5901.1.1.2Schristos
5911.1.1.2Schristos# if the z_ prefix was requested, save that in zconf.h
5921.1.1.2Schristosif test $zprefix -eq 1; then
5931.1.1.2Schristos  sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h
5941.1.1.2Schristos  mv zconf.temp.h zconf.h
5951.1.1.2Schristos  echo >> configure.log
5961.1.1.2Schristos  echo "Using z_ prefix on all symbols." | tee -a configure.log
5971.1.1.2Schristosfi
5981.1.1.2Schristos
5991.1.1.2Schristos# if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists
6001.1.1.2Schristosif test $solo -eq 1; then
6011.1.1.2Schristos  sed '/#define ZCONF_H/a\
6021.1.1.2Schristos#define Z_SOLO
6031.1.1.2Schristos
6041.1.1.2Schristos' < zconf.h > zconf.temp.h
6051.1.1.2Schristos  mv zconf.temp.h zconf.h
6061.1.1.2SchristosOBJC='$(OBJZ)'
6071.1.1.2SchristosPIC_OBJC='$(PIC_OBJZ)'
6081.1.1.2Schristosfi
6091.1.1.2Schristos
6101.1.1.2Schristos# if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
6111.1.1.2Schristosif test $cover -eq 1; then
6121.1.1.2Schristos  CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
6131.1.1.2Schristos  if test -n "$GCC_CLASSIC"; then
6141.1.1.2Schristos    CC=$GCC_CLASSIC
6151.1.1.2Schristos  fi
6161.1Schristosfi
6171.1Schristos
6181.1.1.2Schristosecho >> configure.log
6191.1.1.2Schristos
6201.1.1.2Schristos# conduct a series of tests to resolve eight possible cases of using "vs" or "s" printf functions
6211.1.1.2Schristos# (using stdarg or not), with or without "n" (proving size of buffer), and with or without a
6221.1.1.2Schristos# return value.  The most secure result is vsnprintf() with a return value.  snprintf() with a
6231.1.1.2Schristos# return value is secure as well, but then gzprintf() will be limited to 20 arguments.
6241.1Schristoscat > $test.c <<EOF
6251.1Schristos#include <stdio.h>
6261.1Schristos#include <stdarg.h>
6271.1Schristos#include "zconf.h"
6281.1Schristosint main()
6291.1Schristos{
6301.1Schristos#ifndef STDC
6311.1Schristos  choke me
6321.1Schristos#endif
6331.1Schristos  return 0;
6341.1Schristos}
6351.1SchristosEOF
6361.1.1.2Schristosif try $CC -c $CFLAGS $test.c; then
6371.1.1.2Schristos  echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." | tee -a configure.log
6381.1Schristos
6391.1.1.2Schristos  echo >> configure.log
6401.1Schristos  cat > $test.c <<EOF
6411.1Schristos#include <stdio.h>
6421.1Schristos#include <stdarg.h>
6431.1.1.2Schristosint mytest(const char *fmt, ...)
6441.1Schristos{
6451.1Schristos  char buf[20];
6461.1Schristos  va_list ap;
6471.1Schristos  va_start(ap, fmt);
6481.1Schristos  vsnprintf(buf, sizeof(buf), fmt, ap);
6491.1Schristos  va_end(ap);
6501.1Schristos  return 0;
6511.1Schristos}
6521.1Schristosint main()
6531.1Schristos{
6541.1Schristos  return (mytest("Hello%d\n", 1));
6551.1Schristos}
6561.1SchristosEOF
6571.1.1.2Schristos  if try $CC $CFLAGS -o $test $test.c; then
6581.1.1.2Schristos    echo "Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log
6591.1Schristos
6601.1.1.2Schristos    echo >> configure.log
6611.1Schristos    cat >$test.c <<EOF
6621.1Schristos#include <stdio.h>
6631.1Schristos#include <stdarg.h>
6641.1.1.2Schristosint mytest(const char *fmt, ...)
6651.1Schristos{
6661.1Schristos  int n;
6671.1Schristos  char buf[20];
6681.1Schristos  va_list ap;
6691.1Schristos  va_start(ap, fmt);
6701.1Schristos  n = vsnprintf(buf, sizeof(buf), fmt, ap);
6711.1Schristos  va_end(ap);
6721.1Schristos  return n;
6731.1Schristos}
6741.1Schristosint main()
6751.1Schristos{
6761.1Schristos  return (mytest("Hello%d\n", 1));
6771.1Schristos}
6781.1SchristosEOF
6791.1Schristos
6801.1.1.2Schristos    if try $CC -c $CFLAGS $test.c; then
6811.1.1.2Schristos      echo "Checking for return value of vsnprintf()... Yes." | tee -a configure.log
6821.1Schristos    else
6831.1Schristos      CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
6841.1.1.2Schristos      SFLAGS="$SFLAGS -DHAS_vsnprintf_void"
6851.1.1.2Schristos      echo "Checking for return value of vsnprintf()... No." | tee -a configure.log
6861.1.1.2Schristos      echo "  WARNING: apparently vsnprintf() does not return a value. zlib" | tee -a configure.log
6871.1.1.2Schristos      echo "  can build but will be open to possible string-format security" | tee -a configure.log
6881.1.1.2Schristos      echo "  vulnerabilities." | tee -a configure.log
6891.1Schristos    fi
6901.1Schristos  else
6911.1Schristos    CFLAGS="$CFLAGS -DNO_vsnprintf"
6921.1.1.2Schristos    SFLAGS="$SFLAGS -DNO_vsnprintf"
6931.1.1.2Schristos    echo "Checking for vsnprintf() in stdio.h... No." | tee -a configure.log
6941.1.1.2Schristos    echo "  WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log
6951.1.1.2Schristos    echo "  can build but will be open to possible buffer-overflow security" | tee -a configure.log
6961.1.1.2Schristos    echo "  vulnerabilities." | tee -a configure.log
6971.1Schristos
6981.1.1.2Schristos    echo >> configure.log
6991.1Schristos    cat >$test.c <<EOF
7001.1Schristos#include <stdio.h>
7011.1Schristos#include <stdarg.h>
7021.1.1.2Schristosint mytest(const char *fmt, ...)
7031.1Schristos{
7041.1Schristos  int n;
7051.1Schristos  char buf[20];
7061.1Schristos  va_list ap;
7071.1Schristos  va_start(ap, fmt);
7081.1Schristos  n = vsprintf(buf, fmt, ap);
7091.1Schristos  va_end(ap);
7101.1Schristos  return n;
7111.1Schristos}
7121.1Schristosint main()
7131.1Schristos{
7141.1Schristos  return (mytest("Hello%d\n", 1));
7151.1Schristos}
7161.1SchristosEOF
7171.1Schristos
7181.1.1.2Schristos    if try $CC -c $CFLAGS $test.c; then
7191.1.1.2Schristos      echo "Checking for return value of vsprintf()... Yes." | tee -a configure.log
7201.1Schristos    else
7211.1Schristos      CFLAGS="$CFLAGS -DHAS_vsprintf_void"
7221.1.1.2Schristos      SFLAGS="$SFLAGS -DHAS_vsprintf_void"
7231.1.1.2Schristos      echo "Checking for return value of vsprintf()... No." | tee -a configure.log
7241.1.1.2Schristos      echo "  WARNING: apparently vsprintf() does not return a value. zlib" | tee -a configure.log
7251.1.1.2Schristos      echo "  can build but will be open to possible string-format security" | tee -a configure.log
7261.1.1.2Schristos      echo "  vulnerabilities." | tee -a configure.log
7271.1Schristos    fi
7281.1Schristos  fi
7291.1Schristoselse
7301.1.1.2Schristos  echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." | tee -a configure.log
7311.1Schristos
7321.1.1.2Schristos  echo >> configure.log
7331.1Schristos  cat >$test.c <<EOF
7341.1Schristos#include <stdio.h>
7351.1Schristosint mytest()
7361.1Schristos{
7371.1Schristos  char buf[20];
7381.1Schristos  snprintf(buf, sizeof(buf), "%s", "foo");
7391.1Schristos  return 0;
7401.1Schristos}
7411.1Schristosint main()
7421.1Schristos{
7431.1Schristos  return (mytest());
7441.1Schristos}
7451.1SchristosEOF
7461.1Schristos
7471.1.1.2Schristos  if try $CC $CFLAGS -o $test $test.c; then
7481.1.1.2Schristos    echo "Checking for snprintf() in stdio.h... Yes." | tee -a configure.log
7491.1Schristos
7501.1.1.2Schristos    echo >> configure.log
7511.1Schristos    cat >$test.c <<EOF
7521.1Schristos#include <stdio.h>
7531.1Schristosint mytest()
7541.1Schristos{
7551.1Schristos  char buf[20];
7561.1Schristos  return snprintf(buf, sizeof(buf), "%s", "foo");
7571.1Schristos}
7581.1Schristosint main()
7591.1Schristos{
7601.1Schristos  return (mytest());
7611.1Schristos}
7621.1SchristosEOF
7631.1Schristos
7641.1.1.2Schristos    if try $CC -c $CFLAGS $test.c; then
7651.1.1.2Schristos      echo "Checking for return value of snprintf()... Yes." | tee -a configure.log
7661.1Schristos    else
7671.1Schristos      CFLAGS="$CFLAGS -DHAS_snprintf_void"
7681.1.1.2Schristos      SFLAGS="$SFLAGS -DHAS_snprintf_void"
7691.1.1.2Schristos      echo "Checking for return value of snprintf()... No." | tee -a configure.log
7701.1.1.2Schristos      echo "  WARNING: apparently snprintf() does not return a value. zlib" | tee -a configure.log
7711.1.1.2Schristos      echo "  can build but will be open to possible string-format security" | tee -a configure.log
7721.1.1.2Schristos      echo "  vulnerabilities." | tee -a configure.log
7731.1Schristos    fi
7741.1Schristos  else
7751.1Schristos    CFLAGS="$CFLAGS -DNO_snprintf"
7761.1.1.2Schristos    SFLAGS="$SFLAGS -DNO_snprintf"
7771.1.1.2Schristos    echo "Checking for snprintf() in stdio.h... No." | tee -a configure.log
7781.1.1.2Schristos    echo "  WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log
7791.1.1.2Schristos    echo "  can build but will be open to possible buffer-overflow security" | tee -a configure.log
7801.1.1.2Schristos    echo "  vulnerabilities." | tee -a configure.log
7811.1Schristos
7821.1.1.2Schristos    echo >> configure.log
7831.1Schristos    cat >$test.c <<EOF
7841.1Schristos#include <stdio.h>
7851.1Schristosint mytest()
7861.1Schristos{
7871.1Schristos  char buf[20];
7881.1Schristos  return sprintf(buf, "%s", "foo");
7891.1Schristos}
7901.1Schristosint main()
7911.1Schristos{
7921.1Schristos  return (mytest());
7931.1Schristos}
7941.1SchristosEOF
7951.1Schristos
7961.1.1.2Schristos    if try $CC -c $CFLAGS $test.c; then
7971.1.1.2Schristos      echo "Checking for return value of sprintf()... Yes." | tee -a configure.log
7981.1Schristos    else
7991.1Schristos      CFLAGS="$CFLAGS -DHAS_sprintf_void"
8001.1.1.2Schristos      SFLAGS="$SFLAGS -DHAS_sprintf_void"
8011.1.1.2Schristos      echo "Checking for return value of sprintf()... No." | tee -a configure.log
8021.1.1.2Schristos      echo "  WARNING: apparently sprintf() does not return a value. zlib" | tee -a configure.log
8031.1.1.2Schristos      echo "  can build but will be open to possible string-format security" | tee -a configure.log
8041.1.1.2Schristos      echo "  vulnerabilities." | tee -a configure.log
8051.1Schristos    fi
8061.1Schristos  fi
8071.1Schristosfi
8081.1Schristos
8091.1.1.2Schristos# see if we can hide zlib internal symbols that are linked between separate source files
8101.1.1.2Schristosif test "$gcc" -eq 1; then
8111.1.1.2Schristos  echo >> configure.log
8121.1.1.2Schristos  cat > $test.c <<EOF
8131.1.1.2Schristos#define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
8141.1.1.2Schristosint ZLIB_INTERNAL foo;
8151.1.1.2Schristosint main()
8161.1.1.2Schristos{
8171.1.1.2Schristos  return 0;
8181.1Schristos}
8191.1SchristosEOF
8201.1.1.2Schristos  if tryboth $CC -c $CFLAGS $test.c; then
8211.1.1.2Schristos    CFLAGS="$CFLAGS -DHAVE_HIDDEN"
8221.1.1.2Schristos    SFLAGS="$SFLAGS -DHAVE_HIDDEN"
8231.1.1.2Schristos    echo "Checking for attribute(visibility) support... Yes." | tee -a configure.log
8241.1.1.2Schristos  else
8251.1.1.2Schristos    echo "Checking for attribute(visibility) support... No." | tee -a configure.log
8261.1.1.2Schristos  fi
8271.1Schristosfi
8281.1Schristos
8291.1.1.2Schristos# show the results in the log
8301.1.1.2Schristosecho >> configure.log
8311.1.1.2Schristosecho ALL = $ALL >> configure.log
8321.1.1.2Schristosecho AR = $AR >> configure.log
8331.1.1.2Schristosecho ARFLAGS = $ARFLAGS >> configure.log
8341.1.1.2Schristosecho CC = $CC >> configure.log
8351.1.1.2Schristosecho CFLAGS = $CFLAGS >> configure.log
8361.1.1.2Schristosecho CPP = $CPP >> configure.log
8371.1.1.2Schristosecho EXE = $EXE >> configure.log
8381.1.1.2Schristosecho LDCONFIG = $LDCONFIG >> configure.log
8391.1.1.2Schristosecho LDFLAGS = $LDFLAGS >> configure.log
8401.1.1.2Schristosecho LDSHARED = $LDSHARED >> configure.log
8411.1.1.2Schristosecho LDSHAREDLIBC = $LDSHAREDLIBC >> configure.log
8421.1.1.2Schristosecho OBJC = $OBJC >> configure.log
8431.1.1.2Schristosecho PIC_OBJC = $PIC_OBJC >> configure.log
8441.1.1.2Schristosecho RANLIB = $RANLIB >> configure.log
8451.1.1.2Schristosecho SFLAGS = $SFLAGS >> configure.log
8461.1.1.2Schristosecho SHAREDLIB = $SHAREDLIB >> configure.log
8471.1.1.2Schristosecho SHAREDLIBM = $SHAREDLIBM >> configure.log
8481.1.1.2Schristosecho SHAREDLIBV = $SHAREDLIBV >> configure.log
8491.1.1.2Schristosecho STATICLIB = $STATICLIB >> configure.log
8501.1.1.2Schristosecho TEST = $TEST >> configure.log
8511.1.1.2Schristosecho VER = $VER >> configure.log
8521.1.1.2Schristosecho Z_U4 = $Z_U4 >> configure.log
8531.1.1.2Schristosecho SRCDIR = $SRCDIR >> configure.log
8541.1.1.2Schristosecho exec_prefix = $exec_prefix >> configure.log
8551.1.1.2Schristosecho includedir = $includedir >> configure.log
8561.1.1.2Schristosecho libdir = $libdir >> configure.log
8571.1.1.2Schristosecho mandir = $mandir >> configure.log
8581.1.1.2Schristosecho prefix = $prefix >> configure.log
8591.1.1.2Schristosecho sharedlibdir = $sharedlibdir >> configure.log
8601.1.1.2Schristosecho uname = $uname >> configure.log
8611.1Schristos
8621.1.1.2Schristos# udpate Makefile with the configure results
8631.1.1.2Schristossed < ${SRCDIR}Makefile.in "
8641.1.1.2Schristos/^CC *=/s#=.*#=$CC#
8651.1.1.2Schristos/^CFLAGS *=/s#=.*#=$CFLAGS#
8661.1.1.2Schristos/^SFLAGS *=/s#=.*#=$SFLAGS#
8671.1.1.2Schristos/^LDFLAGS *=/s#=.*#=$LDFLAGS#
8681.1.1.2Schristos/^LDSHARED *=/s#=.*#=$LDSHARED#
8691.1.1.2Schristos/^CPP *=/s#=.*#=$CPP#
8701.1.1.2Schristos/^STATICLIB *=/s#=.*#=$STATICLIB#
8711.1.1.2Schristos/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
8721.1.1.2Schristos/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
8731.1.1.2Schristos/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
8741.1.1.2Schristos/^AR *=/s#=.*#=$AR#
8751.1.1.2Schristos/^ARFLAGS *=/s#=.*#=$ARFLAGS#
8761.1.1.2Schristos/^RANLIB *=/s#=.*#=$RANLIB#
8771.1.1.2Schristos/^LDCONFIG *=/s#=.*#=$LDCONFIG#
8781.1.1.2Schristos/^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
8791.1.1.2Schristos/^EXE *=/s#=.*#=$EXE#
8801.1.1.2Schristos/^SRCDIR *=/s#=.*#=$SRCDIR#
8811.1.1.2Schristos/^ZINC *=/s#=.*#=$ZINC#
8821.1.1.2Schristos/^ZINCOUT *=/s#=.*#=$ZINCOUT#
8831.1.1.2Schristos/^prefix *=/s#=.*#=$prefix#
8841.1.1.2Schristos/^exec_prefix *=/s#=.*#=$exec_prefix#
8851.1.1.2Schristos/^libdir *=/s#=.*#=$libdir#
8861.1.1.2Schristos/^sharedlibdir *=/s#=.*#=$sharedlibdir#
8871.1.1.2Schristos/^includedir *=/s#=.*#=$includedir#
8881.1.1.2Schristos/^mandir *=/s#=.*#=$mandir#
8891.1.1.2Schristos/^OBJC *=/s#=.*#= $OBJC#
8901.1.1.2Schristos/^PIC_OBJC *=/s#=.*#= $PIC_OBJC#
8911.1.1.2Schristos/^all: */s#:.*#: $ALL#
8921.1.1.2Schristos/^test: */s#:.*#: $TEST#
8931.1.1.2Schristos" > Makefile
8941.1Schristos
8951.1.1.2Schristos# create zlib.pc with the configure results
8961.1.1.2Schristossed < ${SRCDIR}zlib.pc.in "
8971.1Schristos/^CC *=/s#=.*#=$CC#
8981.1Schristos/^CFLAGS *=/s#=.*#=$CFLAGS#
8991.1Schristos/^CPP *=/s#=.*#=$CPP#
9001.1Schristos/^LDSHARED *=/s#=.*#=$LDSHARED#
9011.1.1.2Schristos/^STATICLIB *=/s#=.*#=$STATICLIB#
9021.1Schristos/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
9031.1Schristos/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
9041.1Schristos/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
9051.1Schristos/^AR *=/s#=.*#=$AR#
9061.1.1.2Schristos/^ARFLAGS *=/s#=.*#=$ARFLAGS#
9071.1Schristos/^RANLIB *=/s#=.*#=$RANLIB#
9081.1Schristos/^EXE *=/s#=.*#=$EXE#
9091.1Schristos/^prefix *=/s#=.*#=$prefix#
9101.1Schristos/^exec_prefix *=/s#=.*#=$exec_prefix#
9111.1Schristos/^libdir *=/s#=.*#=$libdir#
9121.1.1.2Schristos/^sharedlibdir *=/s#=.*#=$sharedlibdir#
9131.1Schristos/^includedir *=/s#=.*#=$includedir#
9141.1Schristos/^mandir *=/s#=.*#=$mandir#
9151.1Schristos/^LDFLAGS *=/s#=.*#=$LDFLAGS#
9161.1.1.2Schristos" | sed -e "
9171.1.1.2Schristoss/\@VERSION\@/$VER/g;
9181.1.1.2Schristos" > zlib.pc
9191.1.1.2Schristos
9201.1.1.2Schristos# done
9211.1.1.2Schristosleave 0
922