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