blob: b77a8a8cf95f75e9adc79b62a8b95d201dca21de [file] [log] [blame]
Martin v. Löwisd372aa82006-01-03 06:44:59 +00001#!/bin/sh
Martin v. Löwisce126ed2010-07-30 20:03:17 +00002# configure script for zlib.
Martin v. Löwisd372aa82006-01-03 06:44:59 +00003#
Martin v. Löwisce126ed2010-07-30 20:03:17 +00004# 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öwisd372aa82006-01-03 06:44:59 +00006#
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öwisd372aa82006-01-03 06:44:59 +000011
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
Christian Heimesc20bcde2013-10-21 12:03:09 +020016# start off configure.log
17echo -------------------- >> configure.log
18echo $0 $* >> configure.log
19date >> configure.log
20
21# set command prefix for cross-compilation
Martin v. Löwisce126ed2010-07-30 20:03:17 +000022if [ -n "${CHOST}" ]; then
Christian Heimesc20bcde2013-10-21 12:03:09 +020023 uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`"
Martin v. Löwisce126ed2010-07-30 20:03:17 +000024 CROSS_PREFIX="${CHOST}-"
25fi
26
Christian Heimesc20bcde2013-10-21 12:03:09 +020027# destination name for static library
Martin v. Löwisce126ed2010-07-30 20:03:17 +000028STATICLIB=libz.a
Christian Heimesc20bcde2013-10-21 12:03:09 +020029
30# extract zlib version numbers from zlib.h
Martin v. Löwisd372aa82006-01-03 06:44:59 +000031VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
Martin v. Löwisce126ed2010-07-30 20:03:17 +000032VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < zlib.h`
Martin v. Löwisd372aa82006-01-03 06:44:59 +000033VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h`
34VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h`
Christian Heimesc20bcde2013-10-21 12:03:09 +020035
36# establish commands for library building
Martin v. Löwisce126ed2010-07-30 20:03:17 +000037if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then
38 AR=${AR-"${CROSS_PREFIX}ar"}
Christian Heimesc20bcde2013-10-21 12:03:09 +020039 test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
Martin v. Löwisce126ed2010-07-30 20:03:17 +000040else
41 AR=${AR-"ar"}
Christian Heimesc20bcde2013-10-21 12:03:09 +020042 test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
Martin v. Löwisce126ed2010-07-30 20:03:17 +000043fi
Christian Heimesc20bcde2013-10-21 12:03:09 +020044ARFLAGS=${ARFLAGS-"rc"}
Martin v. Löwisce126ed2010-07-30 20:03:17 +000045if "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null || test $? -lt 126; then
46 RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"}
Christian Heimesc20bcde2013-10-21 12:03:09 +020047 test -n "${CROSS_PREFIX}" && echo Using ${RANLIB} | tee -a configure.log
Martin v. Löwisce126ed2010-07-30 20:03:17 +000048else
49 RANLIB=${RANLIB-"ranlib"}
50fi
51if "${CROSS_PREFIX}nm" --version >/dev/null 2>/dev/null || test $? -lt 126; then
52 NM=${NM-"${CROSS_PREFIX}nm"}
Christian Heimesc20bcde2013-10-21 12:03:09 +020053 test -n "${CROSS_PREFIX}" && echo Using ${NM} | tee -a configure.log
Martin v. Löwisce126ed2010-07-30 20:03:17 +000054else
55 NM=${NM-"nm"}
56fi
Christian Heimesc20bcde2013-10-21 12:03:09 +020057
58# set defaults before processing command line options
Martin v. Löwisce126ed2010-07-30 20:03:17 +000059LDCONFIG=${LDCONFIG-"ldconfig"}
60LDSHAREDLIBC="${LDSHAREDLIBC--lc}"
Christian Heimesc20bcde2013-10-21 12:03:09 +020061ARCHS=
Martin v. Löwisd372aa82006-01-03 06:44:59 +000062prefix=${prefix-/usr/local}
63exec_prefix=${exec_prefix-'${prefix}'}
64libdir=${libdir-'${exec_prefix}/lib'}
Martin v. Löwisce126ed2010-07-30 20:03:17 +000065sharedlibdir=${sharedlibdir-'${libdir}'}
Martin v. Löwisd372aa82006-01-03 06:44:59 +000066includedir=${includedir-'${prefix}/include'}
67mandir=${mandir-'${prefix}/share/man'}
68shared_ext='.so'
Martin v. Löwisce126ed2010-07-30 20:03:17 +000069shared=1
Christian Heimesc20bcde2013-10-21 12:03:09 +020070solo=0
71cover=0
Martin v. Löwisce126ed2010-07-30 20:03:17 +000072zprefix=0
Christian Heimesc20bcde2013-10-21 12:03:09 +020073zconst=0
Martin v. Löwisce126ed2010-07-30 20:03:17 +000074build64=0
Martin v. Löwisd372aa82006-01-03 06:44:59 +000075gcc=0
76old_cc="$CC"
77old_cflags="$CFLAGS"
Christian Heimesc20bcde2013-10-21 12:03:09 +020078OBJC='$(OBJZ) $(OBJG)'
79PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)'
Martin v. Löwisd372aa82006-01-03 06:44:59 +000080
Christian Heimesc20bcde2013-10-21 12:03:09 +020081# leave this script, optionally in a bad way
82leave()
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öwisd372aa82006-01-03 06:44:59 +000095while test $# -ge 1
96do
97case "$1" in
Martin v. Löwisce126ed2010-07-30 20:03:17 +000098 -h* | --help)
Christian Heimesc20bcde2013-10-21 12:03:09 +020099 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
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000103 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 ;;
Christian Heimesc20bcde2013-10-21 12:03:09 +0200116 --solo) solo=1; shift ;;
117 --cover) cover=1; shift ;;
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000118 -z* | --zprefix) zprefix=1; shift ;;
119 -6* | --64) build64=1; shift ;;
Christian Heimesc20bcde2013-10-21 12:03:09 +0200120 -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öwisd372aa82006-01-03 06:44:59 +0000128 esac
129done
130
Christian Heimesc20bcde2013-10-21 12:03:09 +0200131# temporary file name
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000132test=ztest$$
Christian Heimesc20bcde2013-10-21 12:03:09 +0200133
134# put arguments in log, also put test file in log if used in arguments
135show()
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öwisd372aa82006-01-03 06:44:59 +0000147cat > $test.c <<EOF
148extern int getchar();
149int hello() {return getchar();}
150EOF
151
Christian Heimesc20bcde2013-10-21 12:03:09 +0200152test -z "$CC" && echo Checking for ${CROSS_PREFIX}gcc... | tee -a configure.log
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000153cc=${CC-${CROSS_PREFIX}gcc}
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000154cflags=${CFLAGS-"-O3"}
155# to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
156case "$cc" in
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000157 *gcc*) gcc=1 ;;
Christian Heimesc20bcde2013-10-21 12:03:09 +0200158 *clang*) gcc=1 ;;
159esac
160case `$cc -v 2>&1` in
161 *gcc*) gcc=1 ;;
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000162esac
163
Christian Heimesc20bcde2013-10-21 12:03:09 +0200164show $cc -c $test.c
165if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
166 echo ... using gcc >> configure.log
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000167 CC="$cc"
Christian Heimesc20bcde2013-10-21 12:03:09 +0200168 CFLAGS="${CFLAGS--O3} ${ARCHS}"
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000169 SFLAGS="${CFLAGS--O3} -fPIC"
Christian Heimesc20bcde2013-10-21 12:03:09 +0200170 LDFLAGS="${LDFLAGS} ${ARCHS}"
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000171 if test $build64 -eq 1; then
172 CFLAGS="${CFLAGS} -m64"
173 SFLAGS="${SFLAGS} -m64"
174 fi
175 if test "${ZLIBGCCWARN}" = "YES"; then
Christian Heimesc20bcde2013-10-21 12:03:09 +0200176 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
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000181 fi
182 if test -z "$uname"; then
183 uname=`(uname -s || echo unknown) 2>/dev/null`
184 fi
185 case "$uname" in
Christian Heimesc20bcde2013-10-21 12:03:09 +0200186 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" ;;
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000191 CYGWIN* | Cygwin* | cygwin* | OS/2*)
192 EXE='.exe' ;;
Christian Heimesc20bcde2013-10-21 12:03:09 +0200193 MINGW* | mingw*)
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000194# temporary bypass
195 rm -f $test.[co] $test $test$shared_ext
Christian Heimesc20bcde2013-10-21 12:03:09 +0200196 echo "Please use win32/Makefile.gcc instead." | tee -a configure.log
197 leave 1
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000198 LDSHARED=${LDSHARED-"$cc -shared"}
199 LDSHAREDLIBC=""
200 EXE='.exe' ;;
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000201 QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
202 # (alain.bonnefoy@icbt.com)
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000203 LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000204 HP-UX*)
205 LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
206 case `(uname -m || echo unknown) 2>/dev/null` in
207 ia64)
208 shared_ext='.so'
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000209 SHAREDLIB='libz.so' ;;
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000210 *)
211 shared_ext='.sl'
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000212 SHAREDLIB='libz.sl' ;;
213 esac ;;
Christian Heimesc20bcde2013-10-21 12:03:09 +0200214 Darwin* | darwin*)
215 shared_ext='.dylib'
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000216 SHAREDLIB=libz$shared_ext
217 SHAREDLIBV=libz.$VER$shared_ext
218 SHAREDLIBM=libz.$VER1$shared_ext
Christian Heimesc20bcde2013-10-21 12:03:09 +0200219 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" ;;
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000226 *) LDSHARED=${LDSHARED-"$cc -shared"} ;;
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000227 esac
228else
229 # find system name and corresponding cc options
230 CC=${CC-cc}
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000231 gcc=0
Christian Heimesc20bcde2013-10-21 12:03:09 +0200232 echo ... using $CC >> configure.log
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000233 if test -z "$uname"; then
234 uname=`(uname -sr || echo unknown) 2>/dev/null`
235 fi
236 case "$uname" in
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000237 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'
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000244 SHAREDLIB='libz.so' ;;
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000245 *)
246 shared_ext='.sl'
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000247 SHAREDLIB='libz.sl' ;;
248 esac ;;
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000249 IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
250 CFLAGS=${CFLAGS-"-ansi -O2"}
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000251 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000252 OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
253 CFLAGS=${CFLAGS-"-O -std1"}
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000254 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öwisd372aa82006-01-03 06:44:59 +0000256 OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
257 CFLAGS=${CFLAGS-"-O -std1"}
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000258 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000259 QNX*) SFLAGS=${CFLAGS-"-4 -O"}
260 CFLAGS=${CFLAGS-"-4 -O"}
261 LDSHARED=${LDSHARED-"cc"}
262 RANLIB=${RANLIB-"true"}
Christian Heimesc20bcde2013-10-21 12:03:09 +0200263 AR="cc"
264 ARFLAGS="-A" ;;
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000265 SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
266 CFLAGS=${CFLAGS-"-O3"}
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000267 LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;;
Christian Heimesc20bcde2013-10-21 12:03:09 +0200268 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öwisd372aa82006-01-03 06:44:59 +0000291 SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
292 CFLAGS=${CFLAGS-"-O2"}
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000293 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öwisd372aa82006-01-03 06:44:59 +0000297 UNIX_System_V\ 4.2.0)
298 SFLAGS=${CFLAGS-"-KPIC -O"}
299 CFLAGS=${CFLAGS-"-O"}
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000300 LDSHARED=${LDSHARED-"cc -G"} ;;
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000301 UNIX_SV\ 4.2MP)
302 SFLAGS=${CFLAGS-"-Kconform_pic -O"}
303 CFLAGS=${CFLAGS-"-O"}
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000304 LDSHARED=${LDSHARED-"cc -G"} ;;
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000305 OpenUNIX\ 5)
306 SFLAGS=${CFLAGS-"-KPIC -O"}
307 CFLAGS=${CFLAGS-"-O"}
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000308 LDSHARED=${LDSHARED-"cc -G"} ;;
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000309 AIX*) # Courtesy of dbakker@arrayasolutions.com
310 SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
311 CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000312 LDSHARED=${LDSHARED-"xlc -G"} ;;
313 # send working options for other systems to zlib@gzip.org
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000314 *) SFLAGS=${CFLAGS-"-O"}
315 CFLAGS=${CFLAGS-"-O"}
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000316 LDSHARED=${LDSHARED-"cc -shared"} ;;
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000317 esac
318fi
319
Christian Heimesc20bcde2013-10-21 12:03:09 +0200320# destination names for shared library if not defined above
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000321SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
322SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
323SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
324
Christian Heimesc20bcde2013-10-21 12:03:09 +0200325echo >> configure.log
326
327# define functions for testing compiler and library characteristics and logging the results
328
329cat > $test.c <<EOF
330#error error
331EOF
332if ($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
339else
340try()
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}
350fi
351
352tryboth()
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
364cat > $test.c << EOF
365int foo() { return 0; }
366EOF
367echo "Checking for obsessive-compulsive compiler options..." >> configure.log
368if try $CC -c $CFLAGS $test.c; then
369 :
370else
371 echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log
372 leave 1
373fi
374
375echo >> configure.log
376
377# see if shared library build supported
378cat > $test.c <<EOF
379extern int getchar();
380int hello() {return getchar();}
381EOF
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000382if test $shared -eq 1; then
Christian Heimesc20bcde2013-10-21 12:03:09 +0200383 echo Checking for shared library support... | tee -a configure.log
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000384 # we must test in two steps (cc then ld), required at least on SunOS 4.x
Christian Heimesc20bcde2013-10-21 12:03:09 +0200385 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öwisd372aa82006-01-03 06:44:59 +0000388 elif test -z "$old_cc" -a -z "$old_cflags"; then
Christian Heimesc20bcde2013-10-21 12:03:09 +0200389 echo No shared library support. | tee -a configure.log
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000390 shared=0;
391 else
Christian Heimesc20bcde2013-10-21 12:03:09 +0200392 echo 'No shared library support; try without defining CC and CFLAGS' | tee -a configure.log
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000393 shared=0;
394 fi
395fi
396if test $shared -eq 0; then
397 LDSHARED="$CC"
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000398 ALL="static"
399 TEST="all teststatic"
400 SHAREDLIB=""
401 SHAREDLIBV=""
402 SHAREDLIBM=""
Christian Heimesc20bcde2013-10-21 12:03:09 +0200403 echo Building static library $STATICLIB version $VER with $CC. | tee -a configure.log
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000404else
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000405 ALL="static shared"
406 TEST="all teststatic testshared"
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000407fi
408
Christian Heimesc20bcde2013-10-21 12:03:09 +0200409# check for underscores in external names for use by assembler code
410CPP=${CPP-"$CC -E"}
411case $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 ;;
421esac
422
423echo >> configure.log
424
425# check for large file support, and if none, check for fseeko()
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000426cat > $test.c <<EOF
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000427#include <sys/types.h>
428off64_t dummy = 0;
429EOF
Christian Heimesc20bcde2013-10-21 12:03:09 +0200430if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000431 CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1"
432 SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1"
433 ALL="${ALL} all64"
434 TEST="${TEST} test64"
Christian Heimesc20bcde2013-10-21 12:03:09 +0200435 echo "Checking for off64_t... Yes." | tee -a configure.log
436 echo "Checking for fseeko... Yes." | tee -a configure.log
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000437else
Christian Heimesc20bcde2013-10-21 12:03:09 +0200438 echo "Checking for off64_t... No." | tee -a configure.log
439 echo >> configure.log
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000440 cat > $test.c <<EOF
441#include <stdio.h>
442int main(void) {
443 fseeko(NULL, 0, 0);
444 return 0;
445}
446EOF
Christian Heimesc20bcde2013-10-21 12:03:09 +0200447 if try $CC $CFLAGS -o $test $test.c; then
448 echo "Checking for fseeko... Yes." | tee -a configure.log
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000449 else
450 CFLAGS="${CFLAGS} -DNO_FSEEKO"
451 SFLAGS="${SFLAGS} -DNO_FSEEKO"
Christian Heimesc20bcde2013-10-21 12:03:09 +0200452 echo "Checking for fseeko... No." | tee -a configure.log
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000453 fi
454fi
455
Christian Heimesc20bcde2013-10-21 12:03:09 +0200456echo >> configure.log
457
458# check for strerror() for use by gz* functions
459cat > $test.c <<EOF
460#include <string.h>
461#include <errno.h>
462int main() { return strlen(strerror(errno)); }
463EOF
464if try $CC $CFLAGS -o $test $test.c; then
465 echo "Checking for strerror... Yes." | tee -a configure.log
466else
467 CFLAGS="${CFLAGS} -DNO_STRERROR"
468 SFLAGS="${SFLAGS} -DNO_STRERROR"
469 echo "Checking for strerror... No." | tee -a configure.log
470fi
471
472# copy clean zconf.h for subsequent edits
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000473cp -p zconf.h.in zconf.h
474
Christian Heimesc20bcde2013-10-21 12:03:09 +0200475echo >> configure.log
476
477# check for unistd.h and save result in zconf.h
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000478cat > $test.c <<EOF
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000479#include <unistd.h>
480int main() { return 0; }
481EOF
Christian Heimesc20bcde2013-10-21 12:03:09 +0200482if try $CC -c $CFLAGS $test.c; then
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000483 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
Christian Heimesc20bcde2013-10-21 12:03:09 +0200485 echo "Checking for unistd.h... Yes." | tee -a configure.log
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000486else
Christian Heimesc20bcde2013-10-21 12:03:09 +0200487 echo "Checking for unistd.h... No." | tee -a configure.log
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000488fi
489
Christian Heimesc20bcde2013-10-21 12:03:09 +0200490echo >> configure.log
491
492# check for stdarg.h and save result in zconf.h
493cat > $test.c <<EOF
494#include <stdarg.h>
495int main() { return 0; }
496EOF
497if 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
501else
502 echo "Checking for stdarg.h... No." | tee -a configure.log
503fi
504
505# if the z_ prefix was requested, save that in zconf.h
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000506if 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
Christian Heimesc20bcde2013-10-21 12:03:09 +0200509 echo >> configure.log
510 echo "Using z_ prefix on all symbols." | tee -a configure.log
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000511fi
512
Christian Heimesc20bcde2013-10-21 12:03:09 +0200513# if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists
514if 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
520OBJC='$(OBJZ)'
521PIC_OBJC='$(PIC_OBJZ)'
522fi
523
524# if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
525if 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
530fi
531
532echo >> 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öwisd372aa82006-01-03 06:44:59 +0000538cat > $test.c <<EOF
539#include <stdio.h>
540#include <stdarg.h>
541#include "zconf.h"
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000542int main()
543{
544#ifndef STDC
545 choke me
546#endif
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000547 return 0;
548}
549EOF
Christian Heimesc20bcde2013-10-21 12:03:09 +0200550if 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öwisd372aa82006-01-03 06:44:59 +0000552
Christian Heimesc20bcde2013-10-21 12:03:09 +0200553 echo >> configure.log
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000554 cat > $test.c <<EOF
555#include <stdio.h>
556#include <stdarg.h>
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000557int mytest(const char *fmt, ...)
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000558{
559 char buf[20];
560 va_list ap;
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000561 va_start(ap, fmt);
562 vsnprintf(buf, sizeof(buf), fmt, ap);
563 va_end(ap);
564 return 0;
565}
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000566int main()
567{
568 return (mytest("Hello%d\n", 1));
569}
570EOF
Christian Heimesc20bcde2013-10-21 12:03:09 +0200571 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öwisd372aa82006-01-03 06:44:59 +0000573
Christian Heimesc20bcde2013-10-21 12:03:09 +0200574 echo >> configure.log
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000575 cat >$test.c <<EOF
576#include <stdio.h>
577#include <stdarg.h>
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000578int mytest(const char *fmt, ...)
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000579{
580 int n;
581 char buf[20];
582 va_list ap;
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000583 va_start(ap, fmt);
584 n = vsnprintf(buf, sizeof(buf), fmt, ap);
585 va_end(ap);
586 return n;
587}
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000588int main()
589{
590 return (mytest("Hello%d\n", 1));
591}
592EOF
593
Christian Heimesc20bcde2013-10-21 12:03:09 +0200594 if try $CC -c $CFLAGS $test.c; then
595 echo "Checking for return value of vsnprintf()... Yes." | tee -a configure.log
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000596 else
597 CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000598 SFLAGS="$SFLAGS -DHAS_vsnprintf_void"
Christian Heimesc20bcde2013-10-21 12:03:09 +0200599 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öwisd372aa82006-01-03 06:44:59 +0000603 fi
604 else
605 CFLAGS="$CFLAGS -DNO_vsnprintf"
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000606 SFLAGS="$SFLAGS -DNO_vsnprintf"
Christian Heimesc20bcde2013-10-21 12:03:09 +0200607 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öwisd372aa82006-01-03 06:44:59 +0000611
Christian Heimesc20bcde2013-10-21 12:03:09 +0200612 echo >> configure.log
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000613 cat >$test.c <<EOF
614#include <stdio.h>
615#include <stdarg.h>
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000616int mytest(const char *fmt, ...)
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000617{
618 int n;
619 char buf[20];
620 va_list ap;
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000621 va_start(ap, fmt);
622 n = vsprintf(buf, fmt, ap);
623 va_end(ap);
624 return n;
625}
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000626int main()
627{
628 return (mytest("Hello%d\n", 1));
629}
630EOF
631
Christian Heimesc20bcde2013-10-21 12:03:09 +0200632 if try $CC -c $CFLAGS $test.c; then
633 echo "Checking for return value of vsprintf()... Yes." | tee -a configure.log
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000634 else
635 CFLAGS="$CFLAGS -DHAS_vsprintf_void"
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000636 SFLAGS="$SFLAGS -DHAS_vsprintf_void"
Christian Heimesc20bcde2013-10-21 12:03:09 +0200637 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öwisd372aa82006-01-03 06:44:59 +0000641 fi
642 fi
643else
Christian Heimesc20bcde2013-10-21 12:03:09 +0200644 echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." | tee -a configure.log
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000645
Christian Heimesc20bcde2013-10-21 12:03:09 +0200646 echo >> configure.log
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000647 cat >$test.c <<EOF
648#include <stdio.h>
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000649int mytest()
650{
651 char buf[20];
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000652 snprintf(buf, sizeof(buf), "%s", "foo");
653 return 0;
654}
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000655int main()
656{
657 return (mytest());
658}
659EOF
660
Christian Heimesc20bcde2013-10-21 12:03:09 +0200661 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öwisd372aa82006-01-03 06:44:59 +0000663
Christian Heimesc20bcde2013-10-21 12:03:09 +0200664 echo >> configure.log
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000665 cat >$test.c <<EOF
666#include <stdio.h>
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000667int mytest()
668{
669 char buf[20];
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000670 return snprintf(buf, sizeof(buf), "%s", "foo");
671}
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000672int main()
673{
674 return (mytest());
675}
676EOF
677
Christian Heimesc20bcde2013-10-21 12:03:09 +0200678 if try $CC -c $CFLAGS $test.c; then
679 echo "Checking for return value of snprintf()... Yes." | tee -a configure.log
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000680 else
681 CFLAGS="$CFLAGS -DHAS_snprintf_void"
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000682 SFLAGS="$SFLAGS -DHAS_snprintf_void"
Christian Heimesc20bcde2013-10-21 12:03:09 +0200683 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öwisd372aa82006-01-03 06:44:59 +0000687 fi
688 else
689 CFLAGS="$CFLAGS -DNO_snprintf"
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000690 SFLAGS="$SFLAGS -DNO_snprintf"
Christian Heimesc20bcde2013-10-21 12:03:09 +0200691 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öwisd372aa82006-01-03 06:44:59 +0000695
Christian Heimesc20bcde2013-10-21 12:03:09 +0200696 echo >> configure.log
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000697 cat >$test.c <<EOF
698#include <stdio.h>
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000699int mytest()
700{
701 char buf[20];
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000702 return sprintf(buf, "%s", "foo");
703}
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000704int main()
705{
706 return (mytest());
707}
708EOF
709
Christian Heimesc20bcde2013-10-21 12:03:09 +0200710 if try $CC -c $CFLAGS $test.c; then
711 echo "Checking for return value of sprintf()... Yes." | tee -a configure.log
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000712 else
713 CFLAGS="$CFLAGS -DHAS_sprintf_void"
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000714 SFLAGS="$SFLAGS -DHAS_sprintf_void"
Christian Heimesc20bcde2013-10-21 12:03:09 +0200715 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öwisd372aa82006-01-03 06:44:59 +0000719 fi
720 fi
721fi
722
Christian Heimesc20bcde2013-10-21 12:03:09 +0200723# see if we can hide zlib internal symbols that are linked between separate source files
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000724if test "$gcc" -eq 1; then
Christian Heimesc20bcde2013-10-21 12:03:09 +0200725 echo >> configure.log
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000726 cat > $test.c <<EOF
Christian Heimesc20bcde2013-10-21 12:03:09 +0200727#define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000728int ZLIB_INTERNAL foo;
729int main()
730{
731 return 0;
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000732}
733EOF
Christian Heimesc20bcde2013-10-21 12:03:09 +0200734 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
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000738 else
Christian Heimesc20bcde2013-10-21 12:03:09 +0200739 echo "Checking for attribute(visibility) support... No." | tee -a configure.log
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000740 fi
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000741fi
742
Christian Heimesc20bcde2013-10-21 12:03:09 +0200743# show the results in the log
744echo >> configure.log
745echo ALL = $ALL >> configure.log
746echo AR = $AR >> configure.log
747echo ARFLAGS = $ARFLAGS >> configure.log
748echo CC = $CC >> configure.log
749echo CFLAGS = $CFLAGS >> configure.log
750echo CPP = $CPP >> configure.log
751echo EXE = $EXE >> configure.log
752echo LDCONFIG = $LDCONFIG >> configure.log
753echo LDFLAGS = $LDFLAGS >> configure.log
754echo LDSHARED = $LDSHARED >> configure.log
755echo LDSHAREDLIBC = $LDSHAREDLIBC >> configure.log
756echo OBJC = $OBJC >> configure.log
757echo PIC_OBJC = $PIC_OBJC >> configure.log
758echo RANLIB = $RANLIB >> configure.log
759echo SFLAGS = $SFLAGS >> configure.log
760echo SHAREDLIB = $SHAREDLIB >> configure.log
761echo SHAREDLIBM = $SHAREDLIBM >> configure.log
762echo SHAREDLIBV = $SHAREDLIBV >> configure.log
763echo STATICLIB = $STATICLIB >> configure.log
764echo TEST = $TEST >> configure.log
765echo VER = $VER >> configure.log
766echo Z_U4 = $Z_U4 >> configure.log
767echo exec_prefix = $exec_prefix >> configure.log
768echo includedir = $includedir >> configure.log
769echo libdir = $libdir >> configure.log
770echo mandir = $mandir >> configure.log
771echo prefix = $prefix >> configure.log
772echo sharedlibdir = $sharedlibdir >> configure.log
773echo uname = $uname >> configure.log
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000774
Christian Heimesc20bcde2013-10-21 12:03:09 +0200775# udpate Makefile with the configure results
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000776sed < Makefile.in "
777/^CC *=/s#=.*#=$CC#
778/^CFLAGS *=/s#=.*#=$CFLAGS#
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000779/^SFLAGS *=/s#=.*#=$SFLAGS#
780/^LDFLAGS *=/s#=.*#=$LDFLAGS#
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000781/^LDSHARED *=/s#=.*#=$LDSHARED#
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000782/^CPP *=/s#=.*#=$CPP#
783/^STATICLIB *=/s#=.*#=$STATICLIB#
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000784/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
785/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
786/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
Christian Heimesc20bcde2013-10-21 12:03:09 +0200787/^AR *=/s#=.*#=$AR#
788/^ARFLAGS *=/s#=.*#=$ARFLAGS#
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000789/^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#
Christian Heimesc20bcde2013-10-21 12:03:09 +0200799/^OBJC *=/s#=.*#= $OBJC#
800/^PIC_OBJC *=/s#=.*#= $PIC_OBJC#
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000801/^all: */s#:.*#: $ALL#
802/^test: */s#:.*#: $TEST#
803" > Makefile
804
Christian Heimesc20bcde2013-10-21 12:03:09 +0200805# create zlib.pc with the configure results
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000806sed < 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#
Christian Heimesc20bcde2013-10-21 12:03:09 +0200815/^AR *=/s#=.*#=$AR#
816/^ARFLAGS *=/s#=.*#=$ARFLAGS#
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000817/^RANLIB *=/s#=.*#=$RANLIB#
818/^EXE *=/s#=.*#=$EXE#
819/^prefix *=/s#=.*#=$prefix#
820/^exec_prefix *=/s#=.*#=$exec_prefix#
821/^libdir *=/s#=.*#=$libdir#
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000822/^sharedlibdir *=/s#=.*#=$sharedlibdir#
Martin v. Löwisd372aa82006-01-03 06:44:59 +0000823/^includedir *=/s#=.*#=$includedir#
824/^mandir *=/s#=.*#=$mandir#
825/^LDFLAGS *=/s#=.*#=$LDFLAGS#
Martin v. Löwisce126ed2010-07-30 20:03:17 +0000826" | sed -e "
827s/\@VERSION\@/$VER/g;
828" > zlib.pc
Christian Heimesc20bcde2013-10-21 12:03:09 +0200829
830# done
831leave 0