configure revision 1.1.1.3
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.3Schristos    uname=${CHOST}
361.1.1.3Schristos    mname=${CHOST}
371.1.1.2Schristos    CROSS_PREFIX="${CHOST}-"
381.1.1.3Schristoselse
391.1.1.3Schristos    mname=`(uname -a || echo unknown) 2>/dev/null`
401.1.1.2Schristosfi
411.1.1.2Schristos
421.1.1.2Schristos# destination name for static library
431.1.1.2SchristosSTATICLIB=libz.a
441.1.1.2Schristos
451.1.1.2Schristos# extract zlib version numbers from zlib.h
461.1.1.2SchristosVER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}zlib.h`
471.1.1.2SchristosVER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < ${SRCDIR}zlib.h`
481.1.1.2SchristosVER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
491.1.1.2SchristosVER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
501.1.1.2Schristos
511.1.1.2Schristos# establish commands for library building
521.1.1.2Schristosif "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then
531.1.1.2Schristos    AR=${AR-"${CROSS_PREFIX}ar"}
541.1.1.2Schristos    test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
551.1.1.2Schristoselse
561.1.1.2Schristos    AR=${AR-"ar"}
571.1.1.2Schristos    test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
581.1.1.2Schristosfi
591.1.1.2SchristosARFLAGS=${ARFLAGS-"rc"}
601.1.1.2Schristosif "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null || test $? -lt 126; then
611.1.1.2Schristos    RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"}
621.1.1.2Schristos    test -n "${CROSS_PREFIX}" && echo Using ${RANLIB} | tee -a configure.log
631.1.1.2Schristoselse
641.1.1.2Schristos    RANLIB=${RANLIB-"ranlib"}
651.1.1.2Schristosfi
661.1.1.2Schristosif "${CROSS_PREFIX}nm" --version >/dev/null 2>/dev/null || test $? -lt 126; then
671.1.1.2Schristos    NM=${NM-"${CROSS_PREFIX}nm"}
681.1.1.2Schristos    test -n "${CROSS_PREFIX}" && echo Using ${NM} | tee -a configure.log
691.1.1.2Schristoselse
701.1.1.2Schristos    NM=${NM-"nm"}
711.1.1.2Schristosfi
721.1.1.2Schristos
731.1.1.2Schristos# set defaults before processing command line options
741.1.1.2SchristosLDCONFIG=${LDCONFIG-"ldconfig"}
751.1.1.2SchristosLDSHAREDLIBC="${LDSHAREDLIBC--lc}"
761.1.1.2SchristosARCHS=
771.1Schristosprefix=${prefix-/usr/local}
781.1Schristosexec_prefix=${exec_prefix-'${prefix}'}
791.1Schristoslibdir=${libdir-'${exec_prefix}/lib'}
801.1.1.2Schristossharedlibdir=${sharedlibdir-'${libdir}'}
811.1Schristosincludedir=${includedir-'${prefix}/include'}
821.1Schristosmandir=${mandir-'${prefix}/share/man'}
831.1Schristosshared_ext='.so'
841.1.1.2Schristosshared=1
851.1.1.2Schristossolo=0
861.1.1.2Schristoscover=0
871.1.1.2Schristoszprefix=0
881.1.1.2Schristoszconst=0
891.1.1.2Schristosbuild64=0
901.1Schristosgcc=0
911.1.1.2Schristoswarn=0
921.1.1.2Schristosdebug=0
931.1.1.3Schristossanitize=0
941.1Schristosold_cc="$CC"
951.1Schristosold_cflags="$CFLAGS"
961.1.1.2SchristosOBJC='$(OBJZ) $(OBJG)'
971.1.1.2SchristosPIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)'
981.1.1.2Schristos
991.1.1.2Schristos# leave this script, optionally in a bad way
1001.1.1.2Schristosleave()
1011.1.1.2Schristos{
1021.1.1.2Schristos  if test "$*" != "0"; then
1031.1.1.2Schristos    echo "** $0 aborting." | tee -a configure.log
1041.1.1.2Schristos  fi
1051.1.1.2Schristos  rm -f $test.[co] $test $test$shared_ext $test.gcno ./--version
1061.1.1.2Schristos  echo -------------------- >> configure.log
1071.1.1.2Schristos  echo >> configure.log
1081.1.1.2Schristos  echo >> configure.log
1091.1.1.2Schristos  exit $1
1101.1.1.2Schristos}
1111.1Schristos
1121.1.1.2Schristos# process command line options
1131.1Schristoswhile test $# -ge 1
1141.1Schristosdo
1151.1Schristoscase "$1" in
1161.1.1.2Schristos    -h* | --help)
1171.1.1.2Schristos      echo 'usage:' | tee -a configure.log
1181.1.1.2Schristos      echo '  configure [--const] [--zprefix] [--prefix=PREFIX]  [--eprefix=EXPREFIX]' | tee -a configure.log
1191.1.1.2Schristos      echo '    [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log
1201.1.1.2Schristos      echo '    [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log
1211.1.1.2Schristos        exit 0 ;;
1221.1.1.2Schristos    -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;;
1231.1.1.2Schristos    -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;;
1241.1.1.2Schristos    -l*=* | --libdir=*) libdir=`echo $1 | sed 's/.*=//'`; shift ;;
1251.1.1.2Schristos    --sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/.*=//'`; shift ;;
1261.1.1.2Schristos    -i*=* | --includedir=*) includedir=`echo $1 | sed 's/.*=//'`;shift ;;
1271.1.1.2Schristos    -u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;;
1281.1.1.2Schristos    -p* | --prefix) prefix="$2"; shift; shift ;;
1291.1.1.2Schristos    -e* | --eprefix) exec_prefix="$2"; shift; shift ;;
1301.1.1.2Schristos    -l* | --libdir) libdir="$2"; shift; shift ;;
1311.1.1.2Schristos    -i* | --includedir) includedir="$2"; shift; shift ;;
1321.1.1.2Schristos    -s* | --shared | --enable-shared) shared=1; shift ;;
1331.1.1.2Schristos    -t | --static) shared=0; shift ;;
1341.1.1.2Schristos    --solo) solo=1; shift ;;
1351.1.1.2Schristos    --cover) cover=1; shift ;;
1361.1.1.2Schristos    -z* | --zprefix) zprefix=1; shift ;;
1371.1.1.2Schristos    -6* | --64) build64=1; shift ;;
1381.1.1.2Schristos    -a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
1391.1.1.2Schristos    --sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;;
1401.1.1.2Schristos    --localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;;
1411.1.1.2Schristos    -c* | --const) zconst=1; shift ;;
1421.1.1.2Schristos    -w* | --warn) warn=1; shift ;;
1431.1.1.2Schristos    -d* | --debug) debug=1; shift ;;
1441.1.1.3Schristos    --sanitize) sanitize=1; shift ;;
1451.1.1.2Schristos    *)
1461.1.1.2Schristos      echo "unknown option: $1" | tee -a configure.log
1471.1.1.2Schristos      echo "$0 --help for help" | tee -a configure.log
1481.1.1.2Schristos      leave 1;;
1491.1Schristos    esac
1501.1Schristosdone
1511.1Schristos
1521.1.1.2Schristos# temporary file name
1531.1Schristostest=ztest$$
1541.1.1.2Schristos
1551.1.1.2Schristos# put arguments in log, also put test file in log if used in arguments
1561.1.1.2Schristosshow()
1571.1.1.2Schristos{
1581.1.1.2Schristos  case "$*" in
1591.1.1.2Schristos    *$test.c*)
1601.1.1.2Schristos      echo === $test.c === >> configure.log
1611.1.1.2Schristos      cat $test.c >> configure.log
1621.1.1.2Schristos      echo === >> configure.log;;
1631.1.1.2Schristos  esac
1641.1.1.2Schristos  echo $* >> configure.log
1651.1.1.2Schristos}
1661.1.1.2Schristos
1671.1.1.2Schristos# check for gcc vs. cc and set compile and link flags based on the system identified by uname
1681.1Schristoscat > $test.c <<EOF
1691.1Schristosextern int getchar();
1701.1Schristosint hello() {return getchar();}
1711.1SchristosEOF
1721.1Schristos
1731.1.1.3Schristosif test -z "$CC"; then
1741.1.1.3Schristos  echo Checking for ${CROSS_PREFIX}gcc... | tee -a configure.log
1751.1.1.3Schristos  if ${CROSS_PREFIX}gcc -v >/dev/null 2>&1; then
1761.1.1.3Schristos    cc=${CROSS_PREFIX}gcc
1771.1.1.3Schristos  else
1781.1.1.3Schristos    cc=${CROSS_PREFIX}cc
1791.1.1.3Schristos  fi
1801.1.1.3Schristoselse
1811.1.1.3Schristos  cc=${CC}
1821.1.1.3Schristosfi
1831.1.1.3Schristos
1841.1Schristoscase "$cc" in
1851.1.1.2Schristos  *gcc*) gcc=1 ;;
1861.1.1.2Schristos  *clang*) gcc=1 ;;
1871.1.1.2Schristosesac
1881.1.1.2Schristoscase `$cc -v 2>&1` in
1891.1.1.2Schristos  *gcc*) gcc=1 ;;
1901.1.1.2Schristos  *clang*) gcc=1 ;;
1911.1Schristosesac
1921.1Schristos
1931.1.1.2Schristosshow $cc -c $test.c
1941.1.1.2Schristosif test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
1951.1.1.2Schristos  echo ... using gcc >> configure.log
1961.1Schristos  CC="$cc"
1971.1.1.2Schristos  CFLAGS="${CFLAGS--O3}"
1981.1.1.2Schristos  SFLAGS="${CFLAGS--O3} -fPIC"
1991.1.1.2Schristos  if test "$ARCHS"; then
2001.1.1.2Schristos    CFLAGS="${CFLAGS} ${ARCHS}"
2011.1.1.2Schristos    LDFLAGS="${LDFLAGS} ${ARCHS}"
2021.1.1.2Schristos  fi
2031.1.1.2Schristos  if test $build64 -eq 1; then
2041.1.1.2Schristos    CFLAGS="${CFLAGS} -m64"
2051.1.1.2Schristos    SFLAGS="${SFLAGS} -m64"
2061.1.1.2Schristos  fi
2071.1.1.2Schristos  if test "$warn" -eq 1; then
2081.1.1.2Schristos    if test "$zconst" -eq 1; then
2091.1.1.3Schristos      CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -DZLIB_CONST"
2101.1.1.2Schristos    else
2111.1.1.3Schristos      CFLAGS="${CFLAGS} -Wall -Wextra"
2121.1.1.2Schristos    fi
2131.1.1.2Schristos  fi
2141.1.1.3Schristos  if test $sanitize -eq 1; then
2151.1.1.3Schristos    CFLAGS="${CFLAGS} -g -fsanitize=address"
2161.1.1.3Schristos  fi
2171.1.1.2Schristos  if test $debug -eq 1; then
2181.1.1.2Schristos    CFLAGS="${CFLAGS} -DZLIB_DEBUG"
2191.1.1.2Schristos    SFLAGS="${SFLAGS} -DZLIB_DEBUG"
2201.1.1.2Schristos  fi
2211.1.1.2Schristos  if test -z "$uname"; then
2221.1.1.2Schristos    uname=`(uname -s || echo unknown) 2>/dev/null`
2231.1.1.2Schristos  fi
2241.1.1.2Schristos  case "$uname" in
2251.1.1.3Schristos  Linux* | linux* | *-linux* | GNU | GNU/* | solaris*)
2261.1.1.3Schristos        case "$mname" in
2271.1.1.3Schristos        *sparc*)
2281.1.1.3Schristos            LDFLAGS="${LDFLAGS} -Wl,--no-warn-rwx-segments" ;;
2291.1.1.3Schristos        esac
2301.1.1.2Schristos        LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;;
2311.1.1.2Schristos  *BSD | *bsd* | DragonFly)
2321.1.1.2Schristos        LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"}
2331.1.1.2Schristos        LDCONFIG="ldconfig -m" ;;
2341.1.1.3Schristos  CYGWIN* | Cygwin* | cygwin* | *-cygwin* | OS/2*)
2351.1.1.2Schristos        EXE='.exe' ;;
2361.1.1.3Schristos  MINGW* | mingw* | *-mingw*)
2371.1.1.2Schristos        rm -f $test.[co] $test $test$shared_ext
2381.1.1.3Schristos        echo "If this doesn't work for you, try win32/Makefile.gcc." | tee -a configure.log
2391.1.1.2Schristos        LDSHARED=${LDSHARED-"$cc -shared"}
2401.1.1.2Schristos        LDSHAREDLIBC=""
2411.1.1.2Schristos        EXE='.exe' ;;
2421.1.1.3Schristos  QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
2431.1.1.3Schristos        # (alain.bonnefoy@icbt.com)
2441.1.1.3Schristos        LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
2451.1Schristos  HP-UX*)
2461.1.1.3Schristos        LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
2471.1.1.3Schristos        case `(uname -m || echo unknown) 2>/dev/null` in
2481.1.1.3Schristos        ia64)
2491.1.1.3Schristos            shared_ext='.so'
2501.1.1.3Schristos            SHAREDLIB='libz.so' ;;
2511.1.1.3Schristos        *)
2521.1.1.3Schristos            shared_ext='.sl'
2531.1.1.3Schristos            SHAREDLIB='libz.sl' ;;
2541.1.1.3Schristos        esac ;;
2551.1.1.3Schristos  AIX*)
2561.1.1.3Schristos        LDFLAGS="${LDFLAGS} -Wl,-brtl" ;;
2571.1.1.3Schristos  Darwin* | darwin* | *-darwin*)
2581.1.1.3Schristos        shared_ext='.dylib'
2591.1.1.3Schristos        SHAREDLIB=libz$shared_ext
2601.1.1.3Schristos        SHAREDLIBV=libz.$VER$shared_ext
2611.1.1.3Schristos        SHAREDLIBM=libz.$VER1$shared_ext
2621.1.1.3Schristos        LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
2631.1.1.3Schristos        if libtool -V 2>&1 | grep Apple > /dev/null; then
2641.1.1.3Schristos            AR="libtool"
2651.1.1.3Schristos        else
2661.1.1.3Schristos            AR="/usr/bin/libtool"
2671.1.1.3Schristos        fi
2681.1.1.3Schristos        ARFLAGS="-o" ;;
2691.1.1.3Schristos  *)
2701.1.1.3Schristos        LDSHARED=${LDSHARED-"$cc -shared"} ;;
2711.1Schristos  esac
2721.1Schristoselse
2731.1Schristos  # find system name and corresponding cc options
2741.1Schristos  CC=${CC-cc}
2751.1.1.2Schristos  gcc=0
2761.1.1.2Schristos  echo ... using $CC >> configure.log
2771.1.1.2Schristos  if test -z "$uname"; then
2781.1.1.2Schristos    uname=`(uname -sr || echo unknown) 2>/dev/null`
2791.1.1.2Schristos  fi
2801.1.1.2Schristos  case "$uname" in
2811.1Schristos  HP-UX*)    SFLAGS=${CFLAGS-"-O +z"}
2821.1Schristos             CFLAGS=${CFLAGS-"-O"}
2831.1Schristos#            LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
2841.1Schristos             LDSHARED=${LDSHARED-"ld -b"}
2851.1Schristos         case `(uname -m || echo unknown) 2>/dev/null` in
2861.1Schristos         ia64)
2871.1Schristos             shared_ext='.so'
2881.1.1.2Schristos             SHAREDLIB='libz.so' ;;
2891.1Schristos         *)
2901.1Schristos             shared_ext='.sl'
2911.1.1.2Schristos             SHAREDLIB='libz.sl' ;;
2921.1.1.2Schristos         esac ;;
2931.1Schristos  IRIX*)     SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
2941.1Schristos             CFLAGS=${CFLAGS-"-ansi -O2"}
2951.1.1.2Schristos             LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
2961.1Schristos  OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
2971.1Schristos             CFLAGS=${CFLAGS-"-O -std1"}
2981.1.1.2Schristos             LDFLAGS="${LDFLAGS} -Wl,-rpath,."
2991.1.1.2Schristos             LDSHARED=${LDSHARED-"cc -shared  -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;;
3001.1Schristos  OSF1*)     SFLAGS=${CFLAGS-"-O -std1"}
3011.1Schristos             CFLAGS=${CFLAGS-"-O -std1"}
3021.1.1.2Schristos             LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
3031.1Schristos  QNX*)      SFLAGS=${CFLAGS-"-4 -O"}
3041.1Schristos             CFLAGS=${CFLAGS-"-4 -O"}
3051.1Schristos             LDSHARED=${LDSHARED-"cc"}
3061.1Schristos             RANLIB=${RANLIB-"true"}
3071.1.1.2Schristos             AR="cc"
3081.1.1.2Schristos             ARFLAGS="-A" ;;
3091.1Schristos  SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
3101.1Schristos             CFLAGS=${CFLAGS-"-O3"}
3111.1.1.2Schristos             LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;;
3121.1.1.2Schristos  SunOS\ 5* | solaris*)
3131.1.1.2Schristos         LDSHARED=${LDSHARED-"cc -G -h libz$shared_ext.$VER1"}
3141.1.1.2Schristos         SFLAGS=${CFLAGS-"-fast -KPIC"}
3151.1.1.2Schristos         CFLAGS=${CFLAGS-"-fast"}
3161.1.1.2Schristos         if test $build64 -eq 1; then
3171.1.1.2Schristos             # old versions of SunPRO/Workshop/Studio don't support -m64,
3181.1.1.2Schristos             # but newer ones do.  Check for it.
3191.1.1.2Schristos             flag64=`$CC -flags | egrep -- '^-m64'`
3201.1.1.2Schristos             if test x"$flag64" != x"" ; then
3211.1.1.2Schristos                 CFLAGS="${CFLAGS} -m64"
3221.1.1.2Schristos                 SFLAGS="${SFLAGS} -m64"
3231.1.1.2Schristos             else
3241.1.1.2Schristos                 case `(uname -m || echo unknown) 2>/dev/null` in
3251.1.1.2Schristos                   i86*)
3261.1.1.2Schristos                     SFLAGS="$SFLAGS -xarch=amd64"
3271.1.1.2Schristos                     CFLAGS="$CFLAGS -xarch=amd64" ;;
3281.1.1.2Schristos                   *)
3291.1.1.2Schristos                     SFLAGS="$SFLAGS -xarch=v9"
3301.1.1.2Schristos                     CFLAGS="$CFLAGS -xarch=v9" ;;
3311.1.1.2Schristos                 esac
3321.1.1.2Schristos             fi
3331.1.1.2Schristos         fi
3341.1.1.2Schristos         if test -n "$ZINC"; then
3351.1.1.2Schristos             ZINC='-I- -I. -I$(SRCDIR)'
3361.1.1.2Schristos         fi
3371.1.1.2Schristos         ;;
3381.1Schristos  SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
3391.1Schristos             CFLAGS=${CFLAGS-"-O2"}
3401.1.1.2Schristos             LDSHARED=${LDSHARED-"ld"} ;;
3411.1.1.2Schristos  SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
3421.1.1.2Schristos             CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"}
3431.1.1.2Schristos             LDSHARED=${LDSHARED-"cc -xarch=v9b"} ;;
3441.1Schristos  UNIX_System_V\ 4.2.0)
3451.1Schristos             SFLAGS=${CFLAGS-"-KPIC -O"}
3461.1Schristos             CFLAGS=${CFLAGS-"-O"}
3471.1.1.2Schristos             LDSHARED=${LDSHARED-"cc -G"} ;;
3481.1Schristos  UNIX_SV\ 4.2MP)
3491.1Schristos             SFLAGS=${CFLAGS-"-Kconform_pic -O"}
3501.1Schristos             CFLAGS=${CFLAGS-"-O"}
3511.1.1.2Schristos             LDSHARED=${LDSHARED-"cc -G"} ;;
3521.1Schristos  OpenUNIX\ 5)
3531.1Schristos             SFLAGS=${CFLAGS-"-KPIC -O"}
3541.1Schristos             CFLAGS=${CFLAGS-"-O"}
3551.1.1.2Schristos             LDSHARED=${LDSHARED-"cc -G"} ;;
3561.1Schristos  AIX*)  # Courtesy of dbakker@arrayasolutions.com
3571.1Schristos             SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
3581.1Schristos             CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
3591.1.1.2Schristos             LDSHARED=${LDSHARED-"xlc -G"} ;;
3601.1.1.2Schristos  # send working options for other systems to zlib@gzip.org
3611.1Schristos  *)         SFLAGS=${CFLAGS-"-O"}
3621.1Schristos             CFLAGS=${CFLAGS-"-O"}
3631.1.1.2Schristos             LDSHARED=${LDSHARED-"cc -shared"} ;;
3641.1Schristos  esac
3651.1Schristosfi
3661.1Schristos
3671.1.1.2Schristos# destination names for shared library if not defined above
3681.1SchristosSHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
3691.1SchristosSHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
3701.1SchristosSHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
3711.1Schristos
3721.1.1.2Schristosecho >> configure.log
3731.1.1.2Schristos
3741.1.1.2Schristos# define functions for testing compiler and library characteristics and logging the results
3751.1.1.2Schristos
3761.1.1.2Schristoscat > $test.c <<EOF
3771.1.1.2Schristos#error error
3781.1.1.2SchristosEOF
3791.1.1.2Schristosif ($CC -c $CFLAGS $test.c) 2>/dev/null; then
3801.1.1.2Schristos  try()
3811.1.1.2Schristos  {
3821.1.1.2Schristos    show $*
3831.1.1.2Schristos    test "`( $* ) 2>&1 | tee -a configure.log`" = ""
3841.1.1.2Schristos  }
3851.1.1.2Schristos  echo - using any output from compiler to indicate an error >> configure.log
3861.1.1.2Schristoselse
3871.1.1.2Schristos  try()
3881.1.1.2Schristos  {
3891.1.1.2Schristos    show $*
3901.1.1.3Schristos    got=`( $* ) 2>&1`
3911.1.1.2Schristos    ret=$?
3921.1.1.3Schristos    if test "$got" != ""; then
3931.1.1.3Schristos      printf "%s\n" "$got" >> configure.log
3941.1.1.3Schristos    fi
3951.1.1.2Schristos    if test $ret -ne 0; then
3961.1.1.2Schristos      echo "(exit code "$ret")" >> configure.log
3971.1.1.2Schristos    fi
3981.1.1.2Schristos    return $ret
3991.1.1.2Schristos  }
4001.1.1.2Schristosfi
4011.1.1.2Schristos
4021.1.1.2Schristostryboth()
4031.1.1.2Schristos{
4041.1.1.2Schristos  show $*
4051.1.1.2Schristos  got=`( $* ) 2>&1`
4061.1.1.2Schristos  ret=$?
4071.1.1.3Schristos  if test "$got" != ""; then
4081.1.1.3Schristos    printf "%s\n" "$got" >> configure.log
4091.1.1.3Schristos  fi
4101.1.1.2Schristos  if test $ret -ne 0; then
4111.1.1.3Schristos    echo "(exit code "$ret")" >> configure.log
4121.1.1.2Schristos    return $ret
4131.1.1.2Schristos  fi
4141.1.1.2Schristos  test "$got" = ""
4151.1.1.2Schristos}
4161.1.1.2Schristos
4171.1.1.2Schristoscat > $test.c << EOF
4181.1.1.2Schristosint foo() { return 0; }
4191.1.1.2SchristosEOF
4201.1.1.2Schristosecho "Checking for obsessive-compulsive compiler options..." >> configure.log
4211.1.1.2Schristosif try $CC -c $CFLAGS $test.c; then
4221.1.1.2Schristos  :
4231.1.1.2Schristoselse
4241.1.1.2Schristos  echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log
4251.1.1.2Schristos  leave 1
4261.1.1.2Schristosfi
4271.1.1.2Schristos
4281.1.1.2Schristosecho >> configure.log
4291.1.1.2Schristos
4301.1.1.2Schristos# see if shared library build supported
4311.1.1.2Schristoscat > $test.c <<EOF
4321.1.1.2Schristosextern int getchar();
4331.1.1.2Schristosint hello() {return getchar();}
4341.1.1.2SchristosEOF
4351.1Schristosif test $shared -eq 1; then
4361.1.1.2Schristos  echo Checking for shared library support... | tee -a configure.log
4371.1Schristos  # we must test in two steps (cc then ld), required at least on SunOS 4.x
4381.1.1.2Schristos  if try $CC -w -c $SFLAGS $test.c &&
4391.1.1.2Schristos     try $LDSHARED $SFLAGS -o $test$shared_ext $test.o; then
4401.1.1.2Schristos    echo Building shared library $SHAREDLIBV with $CC. | tee -a configure.log
4411.1Schristos  elif test -z "$old_cc" -a -z "$old_cflags"; then
4421.1.1.2Schristos    echo No shared library support. | tee -a configure.log
4431.1Schristos    shared=0;
4441.1Schristos  else
4451.1.1.2Schristos    echo 'No shared library support; try without defining CC and CFLAGS' | tee -a configure.log
4461.1Schristos    shared=0;
4471.1Schristos  fi
4481.1Schristosfi
4491.1Schristosif test $shared -eq 0; then
4501.1Schristos  LDSHARED="$CC"
4511.1.1.2Schristos  ALL="static"
4521.1.1.2Schristos  TEST="all teststatic"
4531.1.1.2Schristos  SHAREDLIB=""
4541.1.1.2Schristos  SHAREDLIBV=""
4551.1.1.2Schristos  SHAREDLIBM=""
4561.1.1.2Schristos  echo Building static library $STATICLIB version $VER with $CC. | tee -a configure.log
4571.1.1.2Schristoselse
4581.1.1.2Schristos  ALL="static shared"
4591.1.1.2Schristos  TEST="all teststatic testshared"
4601.1.1.2Schristosfi
4611.1.1.2Schristos
4621.1.1.2Schristosecho >> configure.log
4631.1.1.2Schristos
4641.1.1.2Schristos# check for size_t
4651.1.1.2Schristoscat > $test.c <<EOF
4661.1.1.2Schristos#include <stdio.h>
4671.1.1.2Schristos#include <stdlib.h>
4681.1.1.2Schristossize_t dummy = 0;
4691.1.1.2SchristosEOF
4701.1.1.2Schristosif try $CC -c $CFLAGS $test.c; then
4711.1.1.2Schristos  echo "Checking for size_t... Yes." | tee -a configure.log
4721.1.1.2Schristoselse
4731.1.1.2Schristos  echo "Checking for size_t... No." | tee -a configure.log
4741.1.1.3Schristos  # find a size_t integer type
4751.1.1.3Schristos  # check for long long
4761.1.1.3Schristos  cat > $test.c << EOF
4771.1.1.2Schristoslong long dummy = 0;
4781.1.1.2SchristosEOF
4791.1.1.2Schristos  if try $CC -c $CFLAGS $test.c; then
4801.1.1.2Schristos    echo "Checking for long long... Yes." | tee -a configure.log
4811.1.1.2Schristos    cat > $test.c <<EOF
4821.1.1.2Schristos#include <stdio.h>
4831.1.1.2Schristosint main(void) {
4841.1.1.2Schristos    if (sizeof(void *) <= sizeof(int)) puts("int");
4851.1.1.2Schristos    else if (sizeof(void *) <= sizeof(long)) puts("long");
4861.1.1.2Schristos    else puts("z_longlong");
4871.1.1.2Schristos    return 0;
4881.1.1.2Schristos}
4891.1.1.2SchristosEOF
4901.1.1.2Schristos  else
4911.1.1.2Schristos    echo "Checking for long long... No." | tee -a configure.log
4921.1.1.2Schristos    cat > $test.c <<EOF
4931.1.1.2Schristos#include <stdio.h>
4941.1.1.2Schristosint main(void) {
4951.1.1.2Schristos    if (sizeof(void *) <= sizeof(int)) puts("int");
4961.1.1.2Schristos    else puts("long");
4971.1.1.2Schristos    return 0;
4981.1.1.2Schristos}
4991.1.1.2SchristosEOF
5001.1.1.2Schristos  fi
5011.1.1.2Schristos  if try $CC $CFLAGS -o $test $test.c; then
5021.1.1.2Schristos    sizet=`./$test`
5031.1.1.2Schristos    echo "Checking for a pointer-size integer type..." $sizet"." | tee -a configure.log
5041.1.1.3Schristos    CFLAGS="${CFLAGS} -DNO_SIZE_T=${sizet}"
5051.1.1.3Schristos    SFLAGS="${SFLAGS} -DNO_SIZE_T=${sizet}"
5061.1.1.2Schristos  else
5071.1.1.3Schristos    echo "Checking for a pointer-size integer type... not found." | tee -a configure.log
5081.1.1.2Schristos  fi
5091.1.1.2Schristosfi
5101.1.1.2Schristos
5111.1.1.2Schristosecho >> configure.log
5121.1.1.2Schristos
5131.1.1.2Schristos# check for large file support, and if none, check for fseeko()
5141.1.1.2Schristoscat > $test.c <<EOF
5151.1.1.2Schristos#include <sys/types.h>
5161.1.1.2Schristosoff64_t dummy = 0;
5171.1.1.2SchristosEOF
5181.1.1.2Schristosif try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then
5191.1.1.2Schristos  CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1"
5201.1.1.2Schristos  SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1"
5211.1.1.2Schristos  ALL="${ALL} all64"
5221.1.1.2Schristos  TEST="${TEST} test64"
5231.1.1.2Schristos  echo "Checking for off64_t... Yes." | tee -a configure.log
5241.1.1.2Schristos  echo "Checking for fseeko... Yes." | tee -a configure.log
5251.1.1.2Schristoselse
5261.1.1.2Schristos  echo "Checking for off64_t... No." | tee -a configure.log
5271.1.1.2Schristos  echo >> configure.log
5281.1.1.2Schristos  cat > $test.c <<EOF
5291.1.1.2Schristos#include <stdio.h>
5301.1.1.2Schristosint main(void) {
5311.1.1.2Schristos  fseeko(NULL, 0, 0);
5321.1.1.2Schristos  return 0;
5331.1.1.2Schristos}
5341.1.1.2SchristosEOF
5351.1.1.2Schristos  if try $CC $CFLAGS -o $test $test.c; then
5361.1.1.2Schristos    echo "Checking for fseeko... Yes." | tee -a configure.log
5371.1.1.2Schristos  else
5381.1.1.2Schristos    CFLAGS="${CFLAGS} -DNO_FSEEKO"
5391.1.1.2Schristos    SFLAGS="${SFLAGS} -DNO_FSEEKO"
5401.1.1.2Schristos    echo "Checking for fseeko... No." | tee -a configure.log
5411.1.1.2Schristos  fi
5421.1.1.2Schristosfi
5431.1.1.2Schristos
5441.1.1.2Schristosecho >> configure.log
5451.1.1.2Schristos
5461.1.1.2Schristos# check for strerror() for use by gz* functions
5471.1.1.2Schristoscat > $test.c <<EOF
5481.1.1.2Schristos#include <string.h>
5491.1.1.2Schristos#include <errno.h>
5501.1.1.2Schristosint main() { return strlen(strerror(errno)); }
5511.1.1.2SchristosEOF
5521.1.1.2Schristosif try $CC $CFLAGS -o $test $test.c; then
5531.1.1.2Schristos  echo "Checking for strerror... Yes." | tee -a configure.log
5541.1Schristoselse
5551.1.1.2Schristos  CFLAGS="${CFLAGS} -DNO_STRERROR"
5561.1.1.2Schristos  SFLAGS="${SFLAGS} -DNO_STRERROR"
5571.1.1.2Schristos  echo "Checking for strerror... No." | tee -a configure.log
5581.1Schristosfi
5591.1Schristos
5601.1.1.2Schristos# copy clean zconf.h for subsequent edits
5611.1.1.2Schristoscp -p ${SRCDIR}zconf.h.in zconf.h
5621.1.1.2Schristos
5631.1.1.2Schristosecho >> configure.log
5641.1.1.2Schristos
5651.1.1.2Schristos# check for unistd.h and save result in zconf.h
5661.1Schristoscat > $test.c <<EOF
5671.1Schristos#include <unistd.h>
5681.1Schristosint main() { return 0; }
5691.1SchristosEOF
5701.1.1.2Schristosif try $CC -c $CFLAGS $test.c; then
5711.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
5721.1.1.2Schristos  mv zconf.temp.h zconf.h
5731.1.1.2Schristos  echo "Checking for unistd.h... Yes." | tee -a configure.log
5741.1Schristoselse
5751.1.1.2Schristos  echo "Checking for unistd.h... No." | tee -a configure.log
5761.1.1.2Schristosfi
5771.1.1.2Schristos
5781.1.1.2Schristosecho >> configure.log
5791.1.1.2Schristos
5801.1.1.2Schristos# check for stdarg.h and save result in zconf.h
5811.1.1.2Schristoscat > $test.c <<EOF
5821.1.1.2Schristos#include <stdarg.h>
5831.1.1.2Schristosint main() { return 0; }
5841.1.1.2SchristosEOF
5851.1.1.2Schristosif try $CC -c $CFLAGS $test.c; then
5861.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
5871.1.1.2Schristos  mv zconf.temp.h zconf.h
5881.1.1.2Schristos  echo "Checking for stdarg.h... Yes." | tee -a configure.log
5891.1.1.2Schristoselse
5901.1.1.2Schristos  echo "Checking for stdarg.h... No." | tee -a configure.log
5911.1.1.2Schristosfi
5921.1.1.2Schristos
5931.1.1.2Schristos# if the z_ prefix was requested, save that in zconf.h
5941.1.1.2Schristosif test $zprefix -eq 1; then
5951.1.1.2Schristos  sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h
5961.1.1.2Schristos  mv zconf.temp.h zconf.h
5971.1.1.2Schristos  echo >> configure.log
5981.1.1.2Schristos  echo "Using z_ prefix on all symbols." | tee -a configure.log
5991.1.1.2Schristosfi
6001.1.1.2Schristos
6011.1.1.2Schristos# if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists
6021.1.1.2Schristosif test $solo -eq 1; then
6031.1.1.2Schristos  sed '/#define ZCONF_H/a\
6041.1.1.2Schristos#define Z_SOLO
6051.1.1.2Schristos
6061.1.1.2Schristos' < zconf.h > zconf.temp.h
6071.1.1.2Schristos  mv zconf.temp.h zconf.h
6081.1.1.2SchristosOBJC='$(OBJZ)'
6091.1.1.2SchristosPIC_OBJC='$(PIC_OBJZ)'
6101.1.1.2Schristosfi
6111.1.1.2Schristos
6121.1.1.2Schristos# if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
6131.1.1.2Schristosif test $cover -eq 1; then
6141.1.1.2Schristos  CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
6151.1.1.2Schristos  if test -n "$GCC_CLASSIC"; then
6161.1.1.2Schristos    CC=$GCC_CLASSIC
6171.1.1.2Schristos  fi
6181.1Schristosfi
6191.1Schristos
6201.1.1.2Schristosecho >> configure.log
6211.1.1.2Schristos
6221.1.1.2Schristos# conduct a series of tests to resolve eight possible cases of using "vs" or "s" printf functions
6231.1.1.2Schristos# (using stdarg or not), with or without "n" (proving size of buffer), and with or without a
6241.1.1.2Schristos# return value.  The most secure result is vsnprintf() with a return value.  snprintf() with a
6251.1.1.2Schristos# return value is secure as well, but then gzprintf() will be limited to 20 arguments.
6261.1Schristoscat > $test.c <<EOF
6271.1Schristos#include <stdio.h>
6281.1Schristos#include <stdarg.h>
6291.1Schristos#include "zconf.h"
6301.1Schristosint main()
6311.1Schristos{
6321.1Schristos#ifndef STDC
6331.1Schristos  choke me
6341.1Schristos#endif
6351.1Schristos  return 0;
6361.1Schristos}
6371.1SchristosEOF
6381.1.1.2Schristosif try $CC -c $CFLAGS $test.c; then
6391.1.1.2Schristos  echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." | tee -a configure.log
6401.1Schristos
6411.1.1.2Schristos  echo >> configure.log
6421.1Schristos  cat > $test.c <<EOF
6431.1Schristos#include <stdio.h>
6441.1Schristos#include <stdarg.h>
6451.1.1.2Schristosint mytest(const char *fmt, ...)
6461.1Schristos{
6471.1Schristos  char buf[20];
6481.1Schristos  va_list ap;
6491.1Schristos  va_start(ap, fmt);
6501.1Schristos  vsnprintf(buf, sizeof(buf), fmt, ap);
6511.1Schristos  va_end(ap);
6521.1Schristos  return 0;
6531.1Schristos}
6541.1Schristosint main()
6551.1Schristos{
6561.1Schristos  return (mytest("Hello%d\n", 1));
6571.1Schristos}
6581.1SchristosEOF
6591.1.1.2Schristos  if try $CC $CFLAGS -o $test $test.c; then
6601.1.1.2Schristos    echo "Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log
6611.1Schristos
6621.1.1.2Schristos    echo >> configure.log
6631.1Schristos    cat >$test.c <<EOF
6641.1Schristos#include <stdio.h>
6651.1Schristos#include <stdarg.h>
6661.1.1.2Schristosint mytest(const char *fmt, ...)
6671.1Schristos{
6681.1Schristos  int n;
6691.1Schristos  char buf[20];
6701.1Schristos  va_list ap;
6711.1Schristos  va_start(ap, fmt);
6721.1Schristos  n = vsnprintf(buf, sizeof(buf), fmt, ap);
6731.1Schristos  va_end(ap);
6741.1Schristos  return n;
6751.1Schristos}
6761.1Schristosint main()
6771.1Schristos{
6781.1Schristos  return (mytest("Hello%d\n", 1));
6791.1Schristos}
6801.1SchristosEOF
6811.1Schristos
6821.1.1.2Schristos    if try $CC -c $CFLAGS $test.c; then
6831.1.1.2Schristos      echo "Checking for return value of vsnprintf()... Yes." | tee -a configure.log
6841.1Schristos    else
6851.1Schristos      CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
6861.1.1.2Schristos      SFLAGS="$SFLAGS -DHAS_vsnprintf_void"
6871.1.1.2Schristos      echo "Checking for return value of vsnprintf()... No." | tee -a configure.log
6881.1.1.2Schristos      echo "  WARNING: apparently vsnprintf() does not return a value. zlib" | tee -a configure.log
6891.1.1.2Schristos      echo "  can build but will be open to possible string-format security" | tee -a configure.log
6901.1.1.2Schristos      echo "  vulnerabilities." | tee -a configure.log
6911.1Schristos    fi
6921.1Schristos  else
6931.1Schristos    CFLAGS="$CFLAGS -DNO_vsnprintf"
6941.1.1.2Schristos    SFLAGS="$SFLAGS -DNO_vsnprintf"
6951.1.1.2Schristos    echo "Checking for vsnprintf() in stdio.h... No." | tee -a configure.log
6961.1.1.2Schristos    echo "  WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log
6971.1.1.2Schristos    echo "  can build but will be open to possible buffer-overflow security" | tee -a configure.log
6981.1.1.2Schristos    echo "  vulnerabilities." | tee -a configure.log
6991.1Schristos
7001.1.1.2Schristos    echo >> configure.log
7011.1Schristos    cat >$test.c <<EOF
7021.1Schristos#include <stdio.h>
7031.1Schristos#include <stdarg.h>
7041.1.1.2Schristosint mytest(const char *fmt, ...)
7051.1Schristos{
7061.1Schristos  int n;
7071.1Schristos  char buf[20];
7081.1Schristos  va_list ap;
7091.1Schristos  va_start(ap, fmt);
7101.1Schristos  n = vsprintf(buf, fmt, ap);
7111.1Schristos  va_end(ap);
7121.1Schristos  return n;
7131.1Schristos}
7141.1Schristosint main()
7151.1Schristos{
7161.1Schristos  return (mytest("Hello%d\n", 1));
7171.1Schristos}
7181.1SchristosEOF
7191.1Schristos
7201.1.1.2Schristos    if try $CC -c $CFLAGS $test.c; then
7211.1.1.2Schristos      echo "Checking for return value of vsprintf()... Yes." | tee -a configure.log
7221.1Schristos    else
7231.1Schristos      CFLAGS="$CFLAGS -DHAS_vsprintf_void"
7241.1.1.2Schristos      SFLAGS="$SFLAGS -DHAS_vsprintf_void"
7251.1.1.2Schristos      echo "Checking for return value of vsprintf()... No." | tee -a configure.log
7261.1.1.2Schristos      echo "  WARNING: apparently vsprintf() does not return a value. zlib" | tee -a configure.log
7271.1.1.2Schristos      echo "  can build but will be open to possible string-format security" | tee -a configure.log
7281.1.1.2Schristos      echo "  vulnerabilities." | tee -a configure.log
7291.1Schristos    fi
7301.1Schristos  fi
7311.1Schristoselse
7321.1.1.2Schristos  echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." | tee -a configure.log
7331.1Schristos
7341.1.1.2Schristos  echo >> configure.log
7351.1Schristos  cat >$test.c <<EOF
7361.1Schristos#include <stdio.h>
7371.1Schristosint mytest()
7381.1Schristos{
7391.1Schristos  char buf[20];
7401.1Schristos  snprintf(buf, sizeof(buf), "%s", "foo");
7411.1Schristos  return 0;
7421.1Schristos}
7431.1Schristosint main()
7441.1Schristos{
7451.1Schristos  return (mytest());
7461.1Schristos}
7471.1SchristosEOF
7481.1Schristos
7491.1.1.2Schristos  if try $CC $CFLAGS -o $test $test.c; then
7501.1.1.2Schristos    echo "Checking for snprintf() in stdio.h... Yes." | tee -a configure.log
7511.1Schristos
7521.1.1.2Schristos    echo >> configure.log
7531.1Schristos    cat >$test.c <<EOF
7541.1Schristos#include <stdio.h>
7551.1Schristosint mytest()
7561.1Schristos{
7571.1Schristos  char buf[20];
7581.1Schristos  return snprintf(buf, sizeof(buf), "%s", "foo");
7591.1Schristos}
7601.1Schristosint main()
7611.1Schristos{
7621.1Schristos  return (mytest());
7631.1Schristos}
7641.1SchristosEOF
7651.1Schristos
7661.1.1.2Schristos    if try $CC -c $CFLAGS $test.c; then
7671.1.1.2Schristos      echo "Checking for return value of snprintf()... Yes." | tee -a configure.log
7681.1Schristos    else
7691.1Schristos      CFLAGS="$CFLAGS -DHAS_snprintf_void"
7701.1.1.2Schristos      SFLAGS="$SFLAGS -DHAS_snprintf_void"
7711.1.1.2Schristos      echo "Checking for return value of snprintf()... No." | tee -a configure.log
7721.1.1.2Schristos      echo "  WARNING: apparently snprintf() does not return a value. zlib" | tee -a configure.log
7731.1.1.2Schristos      echo "  can build but will be open to possible string-format security" | tee -a configure.log
7741.1.1.2Schristos      echo "  vulnerabilities." | tee -a configure.log
7751.1Schristos    fi
7761.1Schristos  else
7771.1Schristos    CFLAGS="$CFLAGS -DNO_snprintf"
7781.1.1.2Schristos    SFLAGS="$SFLAGS -DNO_snprintf"
7791.1.1.2Schristos    echo "Checking for snprintf() in stdio.h... No." | tee -a configure.log
7801.1.1.2Schristos    echo "  WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log
7811.1.1.2Schristos    echo "  can build but will be open to possible buffer-overflow security" | tee -a configure.log
7821.1.1.2Schristos    echo "  vulnerabilities." | tee -a configure.log
7831.1Schristos
7841.1.1.2Schristos    echo >> configure.log
7851.1Schristos    cat >$test.c <<EOF
7861.1Schristos#include <stdio.h>
7871.1Schristosint mytest()
7881.1Schristos{
7891.1Schristos  char buf[20];
7901.1Schristos  return sprintf(buf, "%s", "foo");
7911.1Schristos}
7921.1Schristosint main()
7931.1Schristos{
7941.1Schristos  return (mytest());
7951.1Schristos}
7961.1SchristosEOF
7971.1Schristos
7981.1.1.2Schristos    if try $CC -c $CFLAGS $test.c; then
7991.1.1.2Schristos      echo "Checking for return value of sprintf()... Yes." | tee -a configure.log
8001.1Schristos    else
8011.1Schristos      CFLAGS="$CFLAGS -DHAS_sprintf_void"
8021.1.1.2Schristos      SFLAGS="$SFLAGS -DHAS_sprintf_void"
8031.1.1.2Schristos      echo "Checking for return value of sprintf()... No." | tee -a configure.log
8041.1.1.2Schristos      echo "  WARNING: apparently sprintf() does not return a value. zlib" | tee -a configure.log
8051.1.1.2Schristos      echo "  can build but will be open to possible string-format security" | tee -a configure.log
8061.1.1.2Schristos      echo "  vulnerabilities." | tee -a configure.log
8071.1Schristos    fi
8081.1Schristos  fi
8091.1Schristosfi
8101.1Schristos
8111.1.1.2Schristos# see if we can hide zlib internal symbols that are linked between separate source files
8121.1.1.2Schristosif test "$gcc" -eq 1; then
8131.1.1.2Schristos  echo >> configure.log
8141.1.1.2Schristos  cat > $test.c <<EOF
8151.1.1.2Schristos#define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
8161.1.1.2Schristosint ZLIB_INTERNAL foo;
8171.1.1.2Schristosint main()
8181.1.1.2Schristos{
8191.1.1.2Schristos  return 0;
8201.1Schristos}
8211.1SchristosEOF
8221.1.1.2Schristos  if tryboth $CC -c $CFLAGS $test.c; then
8231.1.1.2Schristos    CFLAGS="$CFLAGS -DHAVE_HIDDEN"
8241.1.1.2Schristos    SFLAGS="$SFLAGS -DHAVE_HIDDEN"
8251.1.1.2Schristos    echo "Checking for attribute(visibility) support... Yes." | tee -a configure.log
8261.1.1.2Schristos  else
8271.1.1.2Schristos    echo "Checking for attribute(visibility) support... No." | tee -a configure.log
8281.1.1.2Schristos  fi
8291.1Schristosfi
8301.1Schristos
8311.1.1.2Schristos# show the results in the log
8321.1.1.2Schristosecho >> configure.log
8331.1.1.2Schristosecho ALL = $ALL >> configure.log
8341.1.1.2Schristosecho AR = $AR >> configure.log
8351.1.1.2Schristosecho ARFLAGS = $ARFLAGS >> configure.log
8361.1.1.2Schristosecho CC = $CC >> configure.log
8371.1.1.2Schristosecho CFLAGS = $CFLAGS >> configure.log
8381.1.1.2Schristosecho CPP = $CPP >> configure.log
8391.1.1.2Schristosecho EXE = $EXE >> configure.log
8401.1.1.2Schristosecho LDCONFIG = $LDCONFIG >> configure.log
8411.1.1.2Schristosecho LDFLAGS = $LDFLAGS >> configure.log
8421.1.1.2Schristosecho LDSHARED = $LDSHARED >> configure.log
8431.1.1.2Schristosecho LDSHAREDLIBC = $LDSHAREDLIBC >> configure.log
8441.1.1.2Schristosecho OBJC = $OBJC >> configure.log
8451.1.1.2Schristosecho PIC_OBJC = $PIC_OBJC >> configure.log
8461.1.1.2Schristosecho RANLIB = $RANLIB >> configure.log
8471.1.1.2Schristosecho SFLAGS = $SFLAGS >> configure.log
8481.1.1.2Schristosecho SHAREDLIB = $SHAREDLIB >> configure.log
8491.1.1.2Schristosecho SHAREDLIBM = $SHAREDLIBM >> configure.log
8501.1.1.2Schristosecho SHAREDLIBV = $SHAREDLIBV >> configure.log
8511.1.1.2Schristosecho STATICLIB = $STATICLIB >> configure.log
8521.1.1.2Schristosecho TEST = $TEST >> configure.log
8531.1.1.2Schristosecho VER = $VER >> configure.log
8541.1.1.2Schristosecho SRCDIR = $SRCDIR >> configure.log
8551.1.1.2Schristosecho exec_prefix = $exec_prefix >> configure.log
8561.1.1.2Schristosecho includedir = $includedir >> configure.log
8571.1.1.2Schristosecho libdir = $libdir >> configure.log
8581.1.1.2Schristosecho mandir = $mandir >> configure.log
8591.1.1.2Schristosecho prefix = $prefix >> configure.log
8601.1.1.2Schristosecho sharedlibdir = $sharedlibdir >> configure.log
8611.1.1.2Schristosecho uname = $uname >> configure.log
8621.1Schristos
8631.1.1.2Schristos# udpate Makefile with the configure results
8641.1.1.2Schristossed < ${SRCDIR}Makefile.in "
8651.1.1.2Schristos/^CC *=/s#=.*#=$CC#
8661.1.1.2Schristos/^CFLAGS *=/s#=.*#=$CFLAGS#
8671.1.1.2Schristos/^SFLAGS *=/s#=.*#=$SFLAGS#
8681.1.1.2Schristos/^LDFLAGS *=/s#=.*#=$LDFLAGS#
8691.1.1.2Schristos/^LDSHARED *=/s#=.*#=$LDSHARED#
8701.1.1.2Schristos/^CPP *=/s#=.*#=$CPP#
8711.1.1.2Schristos/^STATICLIB *=/s#=.*#=$STATICLIB#
8721.1.1.2Schristos/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
8731.1.1.2Schristos/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
8741.1.1.2Schristos/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
8751.1.1.2Schristos/^AR *=/s#=.*#=$AR#
8761.1.1.2Schristos/^ARFLAGS *=/s#=.*#=$ARFLAGS#
8771.1.1.2Schristos/^RANLIB *=/s#=.*#=$RANLIB#
8781.1.1.2Schristos/^LDCONFIG *=/s#=.*#=$LDCONFIG#
8791.1.1.2Schristos/^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
8801.1.1.2Schristos/^EXE *=/s#=.*#=$EXE#
8811.1.1.2Schristos/^SRCDIR *=/s#=.*#=$SRCDIR#
8821.1.1.2Schristos/^ZINC *=/s#=.*#=$ZINC#
8831.1.1.2Schristos/^ZINCOUT *=/s#=.*#=$ZINCOUT#
8841.1.1.2Schristos/^prefix *=/s#=.*#=$prefix#
8851.1.1.2Schristos/^exec_prefix *=/s#=.*#=$exec_prefix#
8861.1.1.2Schristos/^libdir *=/s#=.*#=$libdir#
8871.1.1.2Schristos/^sharedlibdir *=/s#=.*#=$sharedlibdir#
8881.1.1.2Schristos/^includedir *=/s#=.*#=$includedir#
8891.1.1.2Schristos/^mandir *=/s#=.*#=$mandir#
8901.1.1.2Schristos/^OBJC *=/s#=.*#= $OBJC#
8911.1.1.2Schristos/^PIC_OBJC *=/s#=.*#= $PIC_OBJC#
8921.1.1.2Schristos/^all: */s#:.*#: $ALL#
8931.1.1.2Schristos/^test: */s#:.*#: $TEST#
8941.1.1.2Schristos" > Makefile
8951.1Schristos
8961.1.1.2Schristos# create zlib.pc with the configure results
8971.1.1.2Schristossed < ${SRCDIR}zlib.pc.in "
8981.1Schristos/^CC *=/s#=.*#=$CC#
8991.1Schristos/^CFLAGS *=/s#=.*#=$CFLAGS#
9001.1Schristos/^CPP *=/s#=.*#=$CPP#
9011.1Schristos/^LDSHARED *=/s#=.*#=$LDSHARED#
9021.1.1.2Schristos/^STATICLIB *=/s#=.*#=$STATICLIB#
9031.1Schristos/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
9041.1Schristos/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
9051.1Schristos/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
9061.1Schristos/^AR *=/s#=.*#=$AR#
9071.1.1.2Schristos/^ARFLAGS *=/s#=.*#=$ARFLAGS#
9081.1Schristos/^RANLIB *=/s#=.*#=$RANLIB#
9091.1Schristos/^EXE *=/s#=.*#=$EXE#
9101.1Schristos/^prefix *=/s#=.*#=$prefix#
9111.1Schristos/^exec_prefix *=/s#=.*#=$exec_prefix#
9121.1Schristos/^libdir *=/s#=.*#=$libdir#
9131.1.1.2Schristos/^sharedlibdir *=/s#=.*#=$sharedlibdir#
9141.1Schristos/^includedir *=/s#=.*#=$includedir#
9151.1Schristos/^mandir *=/s#=.*#=$mandir#
9161.1Schristos/^LDFLAGS *=/s#=.*#=$LDFLAGS#
9171.1.1.2Schristos" | sed -e "
9181.1.1.2Schristoss/\@VERSION\@/$VER/g;
9191.1.1.2Schristos" > zlib.pc
9201.1.1.2Schristos
9211.1.1.2Schristos# done
9221.1.1.2Schristosleave 0
923