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