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