2 # configure script for zlib.
4 # Normally configure builds both a static and a shared library.
5 # If you want to build just a static library, use: ./configure --static
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)
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
16 # start off configure.log
17 echo -------------------- >> configure.log
18 echo $0 $* >> configure.log
21 # get source directory
23 if test $SRCDIR = "."; then
28 ZINC='-I. -include zconf.h'
29 ZINCOUT='-I. -I$(SRCDIR)'
33 # set command prefix for cross-compilation
34 if [ -n "${CHOST}" ]; then
37 CROSS_PREFIX="${CHOST}-"
39 mname=`(uname -a || echo unknown) 2>/dev/null`
42 # destination name for static library
45 # extract zlib version numbers from zlib.h
46 VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}zlib.h`
47 VER3=`echo ${VER}|sed -n -e 's/\([0-9]\{1,\}\(\\.[0-9]\{1,\}\)\{1,2\}\).*/\1/p'`
48 VER1=`echo ${VER}|sed -n -e 's/\([0-9]\{1,\}\)\\..*/\1/p'`
50 # establish commands for library building
51 if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then
52 AR=${AR-"${CROSS_PREFIX}ar"}
53 test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
56 test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
58 ARFLAGS=${ARFLAGS-"rc"}
59 if "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null || test $? -lt 126; then
60 RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"}
61 test -n "${CROSS_PREFIX}" && echo Using ${RANLIB} | tee -a configure.log
63 RANLIB=${RANLIB-"ranlib"}
65 if "${CROSS_PREFIX}nm" --version >/dev/null 2>/dev/null || test $? -lt 126; then
66 NM=${NM-"${CROSS_PREFIX}nm"}
67 test -n "${CROSS_PREFIX}" && echo Using ${NM} | tee -a configure.log
72 # set defaults before processing command line options
73 LDCONFIG=${LDCONFIG-"ldconfig"}
74 LDSHAREDLIBC="${LDSHAREDLIBC--lc}"
76 prefix=${prefix-/usr/local}
77 exec_prefix=${exec_prefix-'${prefix}'}
78 libdir=${libdir-'${exec_prefix}/lib'}
79 sharedlibdir=${sharedlibdir-'${libdir}'}
80 includedir=${includedir-'${prefix}/include'}
81 mandir=${mandir-'${prefix}/share/man'}
96 OBJC='$(OBJZ) $(OBJG)'
97 PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)'
99 # leave this script, optionally in a bad way
102 if test "$*" != "0"; then
103 echo "** $0 aborting." | tee -a configure.log
105 rm -rf $test.[co] $test $test$shared_ext $test.gcno $test.dSYM ./--version
106 echo -------------------- >> configure.log
107 echo >> configure.log
108 echo >> configure.log
112 # process command line options
117 echo 'usage:' | tee -a configure.log
118 echo ' configure [--const] [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log
119 echo ' [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log
120 echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log
122 -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;;
123 -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;;
124 -l*=* | --libdir=*) libdir=`echo $1 | sed 's/.*=//'`; shift ;;
125 --sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/.*=//'`; shift ;;
126 -i*=* | --includedir=*) includedir=`echo $1 | sed 's/.*=//'`;shift ;;
127 -u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;;
128 -p* | --prefix) prefix="$2"; shift; shift ;;
129 -e* | --eprefix) exec_prefix="$2"; shift; shift ;;
130 -l* | --libdir) libdir="$2"; shift; shift ;;
131 -i* | --includedir) includedir="$2"; shift; shift ;;
132 -s* | --shared | --enable-shared) shared=1; shift ;;
133 -t | --static) shared=0; shift ;;
134 --solo) solo=1; shift ;;
135 --cover) cover=1; shift ;;
136 -z* | --zprefix) zprefix=1; shift ;;
137 -6* | --64) build64=1; shift ;;
138 -a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
139 --sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;;
140 --localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;;
141 -c* | --const) zconst=1; shift ;;
142 -w* | --warn) warn=1; shift ;;
143 -d* | --debug) debug=1; shift ;;
144 --sanitize) address=1; shift ;;
145 --address) address=1; shift ;;
146 --memory) memory=1; shift ;;
148 echo "unknown option: $1" | tee -a configure.log
149 echo "$0 --help for help" | tee -a configure.log
154 # temporary file name
157 # put arguments in log, also put test file in log if used in arguments
162 echo === $test.c === >> configure.log
163 cat $test.c >> configure.log
164 echo === >> configure.log;;
166 echo $* >> configure.log
169 # check for gcc vs. cc and set compile and link flags based on the system identified by uname
171 extern int getchar();
172 int hello() {return getchar();}
175 if test -z "$CC"; then
176 echo Checking for ${CROSS_PREFIX}gcc... | tee -a configure.log
177 if ${CROSS_PREFIX}gcc -v >/dev/null 2>&1; then
178 cc=${CROSS_PREFIX}gcc
190 case `$cc -v 2>&1` in
196 if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
197 echo ... using gcc >> configure.log
199 CFLAGS="${CFLAGS--O3}"
200 SFLAGS="${CFLAGS--O3} -fPIC"
201 if test "$ARCHS"; then
202 CFLAGS="${CFLAGS} ${ARCHS}"
203 LDFLAGS="${LDFLAGS} ${ARCHS}"
205 if test $build64 -eq 1; then
206 CFLAGS="${CFLAGS} -m64"
207 SFLAGS="${SFLAGS} -m64"
209 if test "$warn" -eq 1; then
210 if test "$zconst" -eq 1; then
211 CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -DZLIB_CONST"
213 CFLAGS="${CFLAGS} -Wall -Wextra"
216 if test $address -eq 1; then
217 CFLAGS="${CFLAGS} -g -fsanitize=address -fno-omit-frame-pointer"
219 if test $memory -eq 1; then
220 CFLAGS="${CFLAGS} -g -fsanitize=memory -fno-omit-frame-pointer"
222 if test $debug -eq 1; then
223 CFLAGS="${CFLAGS} -DZLIB_DEBUG"
224 SFLAGS="${SFLAGS} -DZLIB_DEBUG"
226 if test -z "$uname"; then
227 uname=`(uname -s || echo unknown) 2>/dev/null`
230 Linux* | linux* | *-linux* | GNU | GNU/* | solaris*)
233 LDFLAGS="${LDFLAGS} -Wl,--no-warn-rwx-segments" ;;
235 LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;;
236 *BSD | *bsd* | DragonFly)
237 LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"}
238 LDCONFIG="ldconfig -m" ;;
239 CYGWIN* | Cygwin* | cygwin* | *-cygwin* | OS/2*)
241 MINGW* | mingw* | *-mingw*)
242 rm -f $test.[co] $test $test$shared_ext
243 echo "If this doesn't work for you, try win32/Makefile.gcc." | tee -a configure.log
244 LDSHARED=${LDSHARED-"$cc -shared"}
247 QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
248 # (alain.bonnefoy@icbt.com)
249 LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
251 LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
252 case `(uname -m || echo unknown) 2>/dev/null` in
255 SHAREDLIB='libz.so' ;;
258 SHAREDLIB='libz.sl' ;;
261 LDFLAGS="${LDFLAGS} -Wl,-brtl" ;;
262 Darwin* | darwin* | *-darwin*)
264 SHAREDLIB=libz$shared_ext
265 SHAREDLIBV=libz.$VER$shared_ext
266 SHAREDLIBM=libz.$VER1$shared_ext
267 LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
268 if "${CROSS_PREFIX}libtool" -V 2>&1 | grep Apple > /dev/null; then
269 AR="${CROSS_PREFIX}libtool"
270 elif libtool -V 2>&1 | grep Apple > /dev/null; then
273 AR="/usr/bin/libtool"
277 LDSHARED=${LDSHARED-"$cc -shared"} ;;
280 # find system name and corresponding cc options
283 echo ... using $CC >> configure.log
284 if test -z "$uname"; then
285 uname=`(uname -sr || echo unknown) 2>/dev/null`
288 HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
289 CFLAGS=${CFLAGS-"-O"}
290 # LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
291 LDSHARED=${LDSHARED-"ld -b"}
292 case `(uname -m || echo unknown) 2>/dev/null` in
295 SHAREDLIB='libz.so' ;;
298 SHAREDLIB='libz.sl' ;;
300 IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
301 CFLAGS=${CFLAGS-"-ansi -O2"}
302 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
303 OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
304 CFLAGS=${CFLAGS-"-O -std1"}
305 LDFLAGS="${LDFLAGS} -Wl,-rpath,."
306 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;;
307 OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
308 CFLAGS=${CFLAGS-"-O -std1"}
309 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
310 QNX*) SFLAGS=${CFLAGS-"-4 -O"}
311 CFLAGS=${CFLAGS-"-4 -O"}
312 LDSHARED=${LDSHARED-"cc"}
313 RANLIB=${RANLIB-"true"}
316 SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
317 CFLAGS=${CFLAGS-"-O3"}
318 LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;;
319 SunOS\ 5* | solaris*)
320 LDSHARED=${LDSHARED-"cc -G -h libz$shared_ext.$VER1"}
321 SFLAGS=${CFLAGS-"-fast -KPIC"}
322 CFLAGS=${CFLAGS-"-fast"}
323 if test $build64 -eq 1; then
324 # old versions of SunPRO/Workshop/Studio don't support -m64,
325 # but newer ones do. Check for it.
326 flag64=`$CC -flags | egrep -- '^-m64'`
327 if test x"$flag64" != x"" ; then
328 CFLAGS="${CFLAGS} -m64"
329 SFLAGS="${SFLAGS} -m64"
331 case `(uname -m || echo unknown) 2>/dev/null` in
333 SFLAGS="$SFLAGS -xarch=amd64"
334 CFLAGS="$CFLAGS -xarch=amd64" ;;
336 SFLAGS="$SFLAGS -xarch=v9"
337 CFLAGS="$CFLAGS -xarch=v9" ;;
341 if test -n "$ZINC"; then
342 ZINC='-I- -I. -I$(SRCDIR)'
345 SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
346 CFLAGS=${CFLAGS-"-O2"}
347 LDSHARED=${LDSHARED-"ld"} ;;
348 SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
349 CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"}
350 LDSHARED=${LDSHARED-"cc -xarch=v9b"} ;;
351 UNIX_System_V\ 4.2.0)
352 SFLAGS=${CFLAGS-"-KPIC -O"}
353 CFLAGS=${CFLAGS-"-O"}
354 LDSHARED=${LDSHARED-"cc -G"} ;;
356 SFLAGS=${CFLAGS-"-Kconform_pic -O"}
357 CFLAGS=${CFLAGS-"-O"}
358 LDSHARED=${LDSHARED-"cc -G"} ;;
360 SFLAGS=${CFLAGS-"-KPIC -O"}
361 CFLAGS=${CFLAGS-"-O"}
362 LDSHARED=${LDSHARED-"cc -G"} ;;
363 AIX*) # Courtesy of dbakker@arrayasolutions.com
364 SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
365 CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
366 LDSHARED=${LDSHARED-"xlc -G"} ;;
367 # send working options for other systems to zlib@gzip.org
368 *) SFLAGS=${CFLAGS-"-O"}
369 CFLAGS=${CFLAGS-"-O"}
370 LDSHARED=${LDSHARED-"cc -shared"} ;;
374 # destination names for shared library if not defined above
375 SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
376 SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
377 SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
379 echo >> configure.log
381 # define functions for testing compiler and library characteristics and logging the results
386 if ($CC -c $CFLAGS $test.c) 2>/dev/null; then
390 test "`( $* ) 2>&1 | tee -a configure.log`" = ""
392 echo - using any output from compiler to indicate an error >> configure.log
399 if test "$got" != ""; then
400 printf "%s\n" "$got" >> configure.log
402 if test $ret -ne 0; then
403 echo "(exit code "$ret")" >> configure.log
414 if test "$got" != ""; then
415 printf "%s\n" "$got" >> configure.log
417 if test $ret -ne 0; then
418 echo "(exit code "$ret")" >> configure.log
425 int foo() { return 0; }
427 echo "Checking for obsessive-compulsive compiler options..." >> configure.log
428 if try $CC -c $CFLAGS $test.c; then
431 echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log
435 echo >> configure.log
437 # see if shared library build supported
439 extern int getchar();
440 int hello() {return getchar();}
442 if test $shared -eq 1; then
443 echo Checking for shared library support... | tee -a configure.log
444 # we must test in two steps (cc then ld), required at least on SunOS 4.x
445 if try $CC -c $SFLAGS $test.c &&
446 try $LDSHARED $SFLAGS -o $test$shared_ext $test.o; then
447 echo Building shared library $SHAREDLIBV with $CC. | tee -a configure.log
448 elif test -z "$old_cc" -a -z "$old_cflags"; then
449 echo No shared library support. | tee -a configure.log
452 echo 'No shared library support; try without defining CC and CFLAGS' | tee -a configure.log
456 if test $shared -eq 0; then
459 TEST="all teststatic"
463 echo Building static library $STATICLIB version $VER with $CC. | tee -a configure.log
466 TEST="all teststatic testshared"
469 echo >> configure.log
477 if try $CC -c $CFLAGS $test.c; then
478 echo "Checking for size_t... Yes." | tee -a configure.log
480 echo "Checking for size_t... No." | tee -a configure.log
481 # find a size_t integer type
482 # check for long long
486 if try $CC -c $CFLAGS $test.c; then
487 echo "Checking for long long... Yes." | tee -a configure.log
491 if (sizeof(void *) <= sizeof(int)) puts("int");
492 else if (sizeof(void *) <= sizeof(long)) puts("long");
493 else puts("z_longlong");
498 echo "Checking for long long... No." | tee -a configure.log
502 if (sizeof(void *) <= sizeof(int)) puts("int");
508 if try $CC $CFLAGS -o $test $test.c; then
510 echo "Checking for a pointer-size integer type..." $sizet"." | tee -a configure.log
511 CFLAGS="${CFLAGS} -DNO_SIZE_T=${sizet}"
512 SFLAGS="${SFLAGS} -DNO_SIZE_T=${sizet}"
514 echo "Checking for a pointer-size integer type... not found." | tee -a configure.log
518 echo >> configure.log
520 # check for large file support, and if none, check for fseeko()
522 #include <sys/types.h>
525 if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then
526 CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1"
527 SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1"
529 TEST="${TEST} test64"
530 echo "Checking for off64_t... Yes." | tee -a configure.log
531 echo "Checking for fseeko... Yes." | tee -a configure.log
533 echo "Checking for off64_t... No." | tee -a configure.log
534 echo >> configure.log
542 if try $CC $CFLAGS -o $test $test.c; then
543 echo "Checking for fseeko... Yes." | tee -a configure.log
545 CFLAGS="${CFLAGS} -DNO_FSEEKO"
546 SFLAGS="${SFLAGS} -DNO_FSEEKO"
547 echo "Checking for fseeko... No." | tee -a configure.log
551 echo >> configure.log
553 # check for strerror() for use by gz* functions
557 int main() { return strlen(strerror(errno)); }
559 if try $CC $CFLAGS -o $test $test.c; then
560 echo "Checking for strerror... Yes." | tee -a configure.log
562 CFLAGS="${CFLAGS} -DNO_STRERROR"
563 SFLAGS="${SFLAGS} -DNO_STRERROR"
564 echo "Checking for strerror... No." | tee -a configure.log
567 # copy clean zconf.h for subsequent edits
568 cp -p ${SRCDIR}zconf.h.in zconf.h
570 echo >> configure.log
572 # check for unistd.h and save result in zconf.h
575 int main() { return 0; }
577 if try $CC -c $CFLAGS $test.c; then
578 sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
579 mv zconf.temp.h zconf.h
580 echo "Checking for unistd.h... Yes." | tee -a configure.log
582 echo "Checking for unistd.h... No." | tee -a configure.log
585 echo >> configure.log
587 # check for stdarg.h and save result in zconf.h
590 int main() { return 0; }
592 if try $CC -c $CFLAGS $test.c; then
593 sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
594 mv zconf.temp.h zconf.h
595 echo "Checking for stdarg.h... Yes." | tee -a configure.log
597 echo "Checking for stdarg.h... No." | tee -a configure.log
600 # if the z_ prefix was requested, save that in zconf.h
601 if test $zprefix -eq 1; then
602 sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h
603 mv zconf.temp.h zconf.h
604 echo >> configure.log
605 echo "Using z_ prefix on all symbols." | tee -a configure.log
608 # if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists
609 if test $solo -eq 1; then
610 sed '/#define ZCONF_H/a\
613 ' < zconf.h > zconf.temp.h
614 mv zconf.temp.h zconf.h
616 PIC_OBJC='$(PIC_OBJZ)'
619 # if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
620 if test $cover -eq 1; then
621 CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
622 if test -n "$GCC_CLASSIC"; then
627 echo >> configure.log
629 # conduct a series of tests to resolve eight possible cases of using "vs" or "s" printf functions
630 # (using stdarg or not), with or without "n" (proving size of buffer), and with or without a
631 # return value. The most secure result is vsnprintf() with a return value. snprintf() with a
632 # return value is secure as well, but then gzprintf() will be limited to 20 arguments.
645 if try $CC -c $CFLAGS $test.c; then
646 echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." | tee -a configure.log
648 echo >> configure.log
652 int mytest(const char *fmt, ...)
657 vsnprintf(buf, sizeof(buf), fmt, ap);
663 return (mytest("Hello%d\n", 1));
666 if try $CC $CFLAGS -o $test $test.c; then
667 echo "Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log
669 echo >> configure.log
673 int mytest(const char *fmt, ...)
679 n = vsnprintf(buf, sizeof(buf), fmt, ap);
685 return (mytest("Hello%d\n", 1));
689 if try $CC -c $CFLAGS $test.c; then
690 echo "Checking for return value of vsnprintf()... Yes." | tee -a configure.log
692 CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
693 SFLAGS="$SFLAGS -DHAS_vsnprintf_void"
694 echo "Checking for return value of vsnprintf()... No." | tee -a configure.log
695 echo " WARNING: apparently vsnprintf() does not return a value. zlib" | tee -a configure.log
696 echo " can build but will be open to possible string-format security" | tee -a configure.log
697 echo " vulnerabilities." | tee -a configure.log
700 CFLAGS="$CFLAGS -DNO_vsnprintf"
701 SFLAGS="$SFLAGS -DNO_vsnprintf"
702 echo "Checking for vsnprintf() in stdio.h... No." | tee -a configure.log
703 echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log
704 echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
705 echo " vulnerabilities." | tee -a configure.log
707 echo >> configure.log
711 int mytest(const char *fmt, ...)
717 n = vsprintf(buf, fmt, ap);
723 return (mytest("Hello%d\n", 1));
727 if try $CC -c $CFLAGS $test.c; then
728 echo "Checking for return value of vsprintf()... Yes." | tee -a configure.log
730 CFLAGS="$CFLAGS -DHAS_vsprintf_void"
731 SFLAGS="$SFLAGS -DHAS_vsprintf_void"
732 echo "Checking for return value of vsprintf()... No." | tee -a configure.log
733 echo " WARNING: apparently vsprintf() does not return a value. zlib" | tee -a configure.log
734 echo " can build but will be open to possible string-format security" | tee -a configure.log
735 echo " vulnerabilities." | tee -a configure.log
739 echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." | tee -a configure.log
741 echo >> configure.log
747 snprintf(buf, sizeof(buf), "%s", "foo");
756 if try $CC $CFLAGS -o $test $test.c; then
757 echo "Checking for snprintf() in stdio.h... Yes." | tee -a configure.log
759 echo >> configure.log
765 return snprintf(buf, sizeof(buf), "%s", "foo");
773 if try $CC -c $CFLAGS $test.c; then
774 echo "Checking for return value of snprintf()... Yes." | tee -a configure.log
776 CFLAGS="$CFLAGS -DHAS_snprintf_void"
777 SFLAGS="$SFLAGS -DHAS_snprintf_void"
778 echo "Checking for return value of snprintf()... No." | tee -a configure.log
779 echo " WARNING: apparently snprintf() does not return a value. zlib" | tee -a configure.log
780 echo " can build but will be open to possible string-format security" | tee -a configure.log
781 echo " vulnerabilities." | tee -a configure.log
784 CFLAGS="$CFLAGS -DNO_snprintf"
785 SFLAGS="$SFLAGS -DNO_snprintf"
786 echo "Checking for snprintf() in stdio.h... No." | tee -a configure.log
787 echo " WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log
788 echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
789 echo " vulnerabilities." | tee -a configure.log
791 echo >> configure.log
797 return sprintf(buf, "%s", "foo");
805 if try $CC -c $CFLAGS $test.c; then
806 echo "Checking for return value of sprintf()... Yes." | tee -a configure.log
808 CFLAGS="$CFLAGS -DHAS_sprintf_void"
809 SFLAGS="$SFLAGS -DHAS_sprintf_void"
810 echo "Checking for return value of sprintf()... No." | tee -a configure.log
811 echo " WARNING: apparently sprintf() does not return a value. zlib" | tee -a configure.log
812 echo " can build but will be open to possible string-format security" | tee -a configure.log
813 echo " vulnerabilities." | tee -a configure.log
818 # see if we can hide zlib internal symbols that are linked between separate source files
819 if test "$gcc" -eq 1; then
820 echo >> configure.log
822 #define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
823 int ZLIB_INTERNAL foo;
829 if tryboth $CC -c $CFLAGS $test.c; then
830 CFLAGS="$CFLAGS -DHAVE_HIDDEN"
831 SFLAGS="$SFLAGS -DHAVE_HIDDEN"
832 echo "Checking for attribute(visibility) support... Yes." | tee -a configure.log
834 echo "Checking for attribute(visibility) support... No." | tee -a configure.log
838 # show the results in the log
839 echo >> configure.log
840 echo ALL = $ALL >> configure.log
841 echo AR = $AR >> configure.log
842 echo ARFLAGS = $ARFLAGS >> configure.log
843 echo CC = $CC >> configure.log
844 echo CFLAGS = $CFLAGS >> configure.log
845 echo CPP = $CPP >> configure.log
846 echo EXE = $EXE >> configure.log
847 echo LDCONFIG = $LDCONFIG >> configure.log
848 echo LDFLAGS = $LDFLAGS >> configure.log
849 echo LDSHARED = $LDSHARED >> configure.log
850 echo LDSHAREDLIBC = $LDSHAREDLIBC >> configure.log
851 echo OBJC = $OBJC >> configure.log
852 echo PIC_OBJC = $PIC_OBJC >> configure.log
853 echo RANLIB = $RANLIB >> configure.log
854 echo SFLAGS = $SFLAGS >> configure.log
855 echo SHAREDLIB = $SHAREDLIB >> configure.log
856 echo SHAREDLIBM = $SHAREDLIBM >> configure.log
857 echo SHAREDLIBV = $SHAREDLIBV >> configure.log
858 echo STATICLIB = $STATICLIB >> configure.log
859 echo TEST = $TEST >> configure.log
860 echo VER = $VER >> configure.log
861 echo SRCDIR = $SRCDIR >> configure.log
862 echo exec_prefix = $exec_prefix >> configure.log
863 echo includedir = $includedir >> configure.log
864 echo libdir = $libdir >> configure.log
865 echo mandir = $mandir >> configure.log
866 echo prefix = $prefix >> configure.log
867 echo sharedlibdir = $sharedlibdir >> configure.log
868 echo uname = $uname >> configure.log
870 # update Makefile with the configure results
871 sed < ${SRCDIR}Makefile.in "
873 /^CFLAGS *=/s#=.*#=$CFLAGS#
874 /^SFLAGS *=/s#=.*#=$SFLAGS#
875 /^LDFLAGS *=/s#=.*#=$LDFLAGS#
876 /^LDSHARED *=/s#=.*#=$LDSHARED#
877 /^CPP *=/s#=.*#=$CPP#
878 /^STATICLIB *=/s#=.*#=$STATICLIB#
879 /^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
880 /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
881 /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
883 /^ARFLAGS *=/s#=.*#=$ARFLAGS#
884 /^RANLIB *=/s#=.*#=$RANLIB#
885 /^LDCONFIG *=/s#=.*#=$LDCONFIG#
886 /^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
887 /^EXE *=/s#=.*#=$EXE#
888 /^SRCDIR *=/s#=.*#=$SRCDIR#
889 /^ZINC *=/s#=.*#=$ZINC#
890 /^ZINCOUT *=/s#=.*#=$ZINCOUT#
891 /^prefix *=/s#=.*#=$prefix#
892 /^exec_prefix *=/s#=.*#=$exec_prefix#
893 /^libdir *=/s#=.*#=$libdir#
894 /^sharedlibdir *=/s#=.*#=$sharedlibdir#
895 /^includedir *=/s#=.*#=$includedir#
896 /^mandir *=/s#=.*#=$mandir#
897 /^OBJC *=/s#=.*#= $OBJC#
898 /^PIC_OBJC *=/s#=.*#= $PIC_OBJC#
899 /^all: */s#:.*#: $ALL#
900 /^test: */s#:.*#: $TEST#
903 # create zlib.pc with the configure results
904 sed < ${SRCDIR}zlib.pc.in "
906 /^CFLAGS *=/s#=.*#=$CFLAGS#
907 /^CPP *=/s#=.*#=$CPP#
908 /^LDSHARED *=/s#=.*#=$LDSHARED#
909 /^STATICLIB *=/s#=.*#=$STATICLIB#
910 /^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
911 /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
912 /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
914 /^ARFLAGS *=/s#=.*#=$ARFLAGS#
915 /^RANLIB *=/s#=.*#=$RANLIB#
916 /^EXE *=/s#=.*#=$EXE#
917 /^prefix *=/s#=.*#=$prefix#
918 /^exec_prefix *=/s#=.*#=$exec_prefix#
919 /^libdir *=/s#=.*#=$libdir#
920 /^sharedlibdir *=/s#=.*#=$sharedlibdir#
921 /^includedir *=/s#=.*#=$includedir#
922 /^mandir *=/s#=.*#=$mandir#
923 /^LDFLAGS *=/s#=.*#=$LDFLAGS#
925 s/\@VERSION\@/$VER/g;