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