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='-include zconf.h'
29 ZINCOUT='-I. -I$(SRCDIR)'
33 # set command prefix for cross-compilation
34 if [ -n "${CHOST}" ]; then
35 uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`"
36 CROSS_PREFIX="${CHOST}-"
39 # destination name for static library
42 # extract zlib version numbers from zlib.h
43 VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}zlib.h`
44 VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < ${SRCDIR}zlib.h`
45 VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
46 VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
48 # establish commands for library building
49 if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then
50 AR=${AR-"${CROSS_PREFIX}ar"}
51 test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
54 test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
56 ARFLAGS=${ARFLAGS-"rc"}
57 if "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null || test $? -lt 126; then
58 RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"}
59 test -n "${CROSS_PREFIX}" && echo Using ${RANLIB} | tee -a configure.log
61 RANLIB=${RANLIB-"ranlib"}
63 if "${CROSS_PREFIX}nm" --version >/dev/null 2>/dev/null || test $? -lt 126; then
64 NM=${NM-"${CROSS_PREFIX}nm"}
65 test -n "${CROSS_PREFIX}" && echo Using ${NM} | tee -a configure.log
70 # set defaults before processing command line options
71 LDCONFIG=${LDCONFIG-"ldconfig"}
72 LDSHAREDLIBC="${LDSHAREDLIBC--lc}"
74 prefix=${prefix-/usr/local}
75 exec_prefix=${exec_prefix-'${prefix}'}
76 libdir=${libdir-'${exec_prefix}/lib'}
77 sharedlibdir=${sharedlibdir-'${libdir}'}
78 includedir=${includedir-'${prefix}/include'}
79 mandir=${mandir-'${prefix}/share/man'}
93 OBJC='$(OBJZ) $(OBJG)'
94 PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)'
96 # leave this script, optionally in a bad way
99 if test "$*" != "0"; then
100 echo "** $0 aborting." | tee -a configure.log
102 rm -f $test.[co] $test $test$shared_ext $test.gcno ./--version
103 echo -------------------- >> configure.log
104 echo >> configure.log
105 echo >> configure.log
109 # process command line options
114 echo 'usage:' | tee -a configure.log
115 echo ' configure [--const] [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log
116 echo ' [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log
117 echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log
119 -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;;
120 -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;;
121 -l*=* | --libdir=*) libdir=`echo $1 | sed 's/.*=//'`; shift ;;
122 --sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/.*=//'`; shift ;;
123 -i*=* | --includedir=*) includedir=`echo $1 | sed 's/.*=//'`;shift ;;
124 -u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;;
125 -p* | --prefix) prefix="$2"; shift; shift ;;
126 -e* | --eprefix) exec_prefix="$2"; shift; shift ;;
127 -l* | --libdir) libdir="$2"; shift; shift ;;
128 -i* | --includedir) includedir="$2"; shift; shift ;;
129 -s* | --shared | --enable-shared) shared=1; shift ;;
130 -t | --static) shared=0; shift ;;
131 --solo) solo=1; shift ;;
132 --cover) cover=1; shift ;;
133 -z* | --zprefix) zprefix=1; shift ;;
134 -6* | --64) build64=1; shift ;;
135 -a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
136 --sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;;
137 --localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;;
138 -c* | --const) zconst=1; shift ;;
139 -w* | --warn) warn=1; shift ;;
140 -d* | --debug) debug=1; shift ;;
141 --sanitize) sanitize=1; shift ;;
143 echo "unknown option: $1" | tee -a configure.log
144 echo "$0 --help for help" | tee -a configure.log
149 # temporary file name
152 # put arguments in log, also put test file in log if used in arguments
157 echo === $test.c === >> configure.log
158 cat $test.c >> configure.log
159 echo === >> configure.log;;
161 echo $* >> configure.log
164 # check for gcc vs. cc and set compile and link flags based on the system identified by uname
166 extern int getchar();
167 int hello() {return getchar();}
170 if test -z "$CC"; then
171 echo Checking for ${CROSS_PREFIX}gcc... | tee -a configure.log
172 if ${CROSS_PREFIX}gcc -v >/dev/null 2>&1; then
173 cc=${CROSS_PREFIX}gcc
178 cflags=${CFLAGS-"-O3"}
179 # to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
184 case `$cc -v 2>&1` in
190 if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
191 echo ... using gcc >> configure.log
193 CFLAGS="${CFLAGS--O3}"
194 SFLAGS="${CFLAGS--O3} -fPIC"
195 if test "$ARCHS"; then
196 CFLAGS="${CFLAGS} ${ARCHS}"
197 LDFLAGS="${LDFLAGS} ${ARCHS}"
199 if test $build64 -eq 1; then
200 CFLAGS="${CFLAGS} -m64"
201 SFLAGS="${SFLAGS} -m64"
203 if test "$warn" -eq 1; then
204 if test "$zconst" -eq 1; then
205 CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -pedantic -DZLIB_CONST"
207 CFLAGS="${CFLAGS} -Wall -Wextra -pedantic"
210 if test $sanitize -eq 1; then
211 CFLAGS="${CFLAGS} -fsanitize=address"
213 if test $debug -eq 1; then
214 CFLAGS="${CFLAGS} -DZLIB_DEBUG"
215 SFLAGS="${SFLAGS} -DZLIB_DEBUG"
217 if test -z "$uname"; then
218 uname=`(uname -s || echo unknown) 2>/dev/null`
221 Linux* | linux* | GNU | GNU/* | solaris*)
222 LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;;
223 *BSD | *bsd* | DragonFly)
224 LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"}
225 LDCONFIG="ldconfig -m" ;;
226 CYGWIN* | Cygwin* | cygwin* | OS/2*)
230 rm -f $test.[co] $test $test$shared_ext
231 echo "Please use win32/Makefile.gcc instead." | tee -a configure.log
233 LDSHARED=${LDSHARED-"$cc -shared"}
236 QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
237 # (alain.bonnefoy@icbt.com)
238 LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
240 LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
241 case `(uname -m || echo unknown) 2>/dev/null` in
244 SHAREDLIB='libz.so' ;;
247 SHAREDLIB='libz.sl' ;;
251 SHAREDLIB=libz$shared_ext
252 SHAREDLIBV=libz.$VER$shared_ext
253 SHAREDLIBM=libz.$VER1$shared_ext
254 LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
255 if libtool -V 2>&1 | grep Apple > /dev/null; then
258 AR="/usr/bin/libtool"
261 *) LDSHARED=${LDSHARED-"$cc -shared"} ;;
264 # find system name and corresponding cc options
267 echo ... using $CC >> configure.log
268 if test -z "$uname"; then
269 uname=`(uname -sr || echo unknown) 2>/dev/null`
272 HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
273 CFLAGS=${CFLAGS-"-O"}
274 # LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
275 LDSHARED=${LDSHARED-"ld -b"}
276 case `(uname -m || echo unknown) 2>/dev/null` in
279 SHAREDLIB='libz.so' ;;
282 SHAREDLIB='libz.sl' ;;
284 IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
285 CFLAGS=${CFLAGS-"-ansi -O2"}
286 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
287 OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
288 CFLAGS=${CFLAGS-"-O -std1"}
289 LDFLAGS="${LDFLAGS} -Wl,-rpath,."
290 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;;
291 OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
292 CFLAGS=${CFLAGS-"-O -std1"}
293 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
294 QNX*) SFLAGS=${CFLAGS-"-4 -O"}
295 CFLAGS=${CFLAGS-"-4 -O"}
296 LDSHARED=${LDSHARED-"cc"}
297 RANLIB=${RANLIB-"true"}
300 SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
301 CFLAGS=${CFLAGS-"-O3"}
302 LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;;
303 SunOS\ 5* | solaris*)
304 LDSHARED=${LDSHARED-"cc -G -h libz$shared_ext.$VER1"}
305 SFLAGS=${CFLAGS-"-fast -KPIC"}
306 CFLAGS=${CFLAGS-"-fast"}
307 if test $build64 -eq 1; then
308 # old versions of SunPRO/Workshop/Studio don't support -m64,
309 # but newer ones do. Check for it.
310 flag64=`$CC -flags | egrep -- '^-m64'`
311 if test x"$flag64" != x"" ; then
312 CFLAGS="${CFLAGS} -m64"
313 SFLAGS="${SFLAGS} -m64"
315 case `(uname -m || echo unknown) 2>/dev/null` in
317 SFLAGS="$SFLAGS -xarch=amd64"
318 CFLAGS="$CFLAGS -xarch=amd64" ;;
320 SFLAGS="$SFLAGS -xarch=v9"
321 CFLAGS="$CFLAGS -xarch=v9" ;;
325 if test -n "$ZINC"; then
326 ZINC='-I- -I. -I$(SRCDIR)'
329 SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
330 CFLAGS=${CFLAGS-"-O2"}
331 LDSHARED=${LDSHARED-"ld"} ;;
332 SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
333 CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"}
334 LDSHARED=${LDSHARED-"cc -xarch=v9b"} ;;
335 UNIX_System_V\ 4.2.0)
336 SFLAGS=${CFLAGS-"-KPIC -O"}
337 CFLAGS=${CFLAGS-"-O"}
338 LDSHARED=${LDSHARED-"cc -G"} ;;
340 SFLAGS=${CFLAGS-"-Kconform_pic -O"}
341 CFLAGS=${CFLAGS-"-O"}
342 LDSHARED=${LDSHARED-"cc -G"} ;;
344 SFLAGS=${CFLAGS-"-KPIC -O"}
345 CFLAGS=${CFLAGS-"-O"}
346 LDSHARED=${LDSHARED-"cc -G"} ;;
347 AIX*) # Courtesy of dbakker@arrayasolutions.com
348 SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
349 CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
350 LDSHARED=${LDSHARED-"xlc -G"} ;;
351 # send working options for other systems to zlib@gzip.org
352 *) SFLAGS=${CFLAGS-"-O"}
353 CFLAGS=${CFLAGS-"-O"}
354 LDSHARED=${LDSHARED-"cc -shared"} ;;
358 # destination names for shared library if not defined above
359 SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
360 SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
361 SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
363 echo >> configure.log
365 # define functions for testing compiler and library characteristics and logging the results
370 if ($CC -c $CFLAGS $test.c) 2>/dev/null; then
374 test "`( $* ) 2>&1 | tee -a configure.log`" = ""
376 echo - using any output from compiler to indicate an error >> configure.log
383 if test "$got" != ""; then
384 printf "%s\n" "$got" >> configure.log
386 if test $ret -ne 0; then
387 echo "(exit code "$ret")" >> configure.log
398 if test "$got" != ""; then
399 printf "%s\n" "$got" >> configure.log
401 if test $ret -ne 0; then
402 echo "(exit code "$ret")" >> configure.log
409 int foo() { return 0; }
411 echo "Checking for obsessive-compulsive compiler options..." >> configure.log
412 if try $CC -c $CFLAGS $test.c; then
415 echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log
419 echo >> configure.log
421 # see if shared library build supported
423 extern int getchar();
424 int hello() {return getchar();}
426 if test $shared -eq 1; then
427 echo Checking for shared library support... | tee -a configure.log
428 # we must test in two steps (cc then ld), required at least on SunOS 4.x
429 if try $CC -w -c $SFLAGS $test.c &&
430 try $LDSHARED $SFLAGS -o $test$shared_ext $test.o; then
431 echo Building shared library $SHAREDLIBV with $CC. | tee -a configure.log
432 elif test -z "$old_cc" -a -z "$old_cflags"; then
433 echo No shared library support. | tee -a configure.log
436 echo 'No shared library support; try without defining CC and CFLAGS' | tee -a configure.log
440 if test $shared -eq 0; then
443 TEST="all teststatic"
447 echo Building static library $STATICLIB version $VER with $CC. | tee -a configure.log
450 TEST="all teststatic testshared"
453 # check for underscores in external names for use by assembler code
457 echo >> configure.log
458 show "$NM $test.o | grep _hello"
459 if test "`$NM $test.o | grep _hello | tee -a configure.log`" = ""; then
460 CPP="$CPP -DNO_UNDERLINE"
461 echo Checking for underline in external names... No. | tee -a configure.log
463 echo Checking for underline in external names... Yes. | tee -a configure.log
467 echo >> configure.log
475 if try $CC -c $CFLAGS $test.c; then
476 echo "Checking for size_t... Yes." | tee -a configure.log
478 echo "Checking for size_t... No." | tee -a configure.log
479 # find a size_t integer type
480 # check for long long
484 if try $CC -c $CFLAGS $test.c; then
485 echo "Checking for long long... Yes." | tee -a configure.log
489 if (sizeof(void *) <= sizeof(int)) puts("int");
490 else if (sizeof(void *) <= sizeof(long)) puts("long");
491 else puts("z_longlong");
496 echo "Checking for long long... No." | tee -a configure.log
500 if (sizeof(void *) <= sizeof(int)) puts("int");
506 if try $CC $CFLAGS -o $test $test.c; then
508 echo "Checking for a pointer-size integer type..." $sizet"." | tee -a configure.log
509 CFLAGS="${CFLAGS} -DNO_SIZE_T=${sizet}"
510 SFLAGS="${SFLAGS} -DNO_SIZE_T=${sizet}"
512 echo "Checking for a pointer-size integer type... not found." | tee -a configure.log
516 echo >> configure.log
518 # check for large file support, and if none, check for fseeko()
520 #include <sys/types.h>
523 if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then
524 CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1"
525 SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1"
527 TEST="${TEST} test64"
528 echo "Checking for off64_t... Yes." | tee -a configure.log
529 echo "Checking for fseeko... Yes." | tee -a configure.log
531 echo "Checking for off64_t... No." | tee -a configure.log
532 echo >> configure.log
540 if try $CC $CFLAGS -o $test $test.c; then
541 echo "Checking for fseeko... Yes." | tee -a configure.log
543 CFLAGS="${CFLAGS} -DNO_FSEEKO"
544 SFLAGS="${SFLAGS} -DNO_FSEEKO"
545 echo "Checking for fseeko... No." | tee -a configure.log
549 echo >> configure.log
551 # check for strerror() for use by gz* functions
555 int main() { return strlen(strerror(errno)); }
557 if try $CC $CFLAGS -o $test $test.c; then
558 echo "Checking for strerror... Yes." | tee -a configure.log
560 CFLAGS="${CFLAGS} -DNO_STRERROR"
561 SFLAGS="${SFLAGS} -DNO_STRERROR"
562 echo "Checking for strerror... No." | tee -a configure.log
565 # copy clean zconf.h for subsequent edits
566 cp -p ${SRCDIR}zconf.h.in zconf.h
568 echo >> configure.log
570 # check for unistd.h and save result in zconf.h
573 int main() { return 0; }
575 if try $CC -c $CFLAGS $test.c; then
576 sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
577 mv zconf.temp.h zconf.h
578 echo "Checking for unistd.h... Yes." | tee -a configure.log
580 echo "Checking for unistd.h... No." | tee -a configure.log
583 echo >> configure.log
585 # check for stdarg.h and save result in zconf.h
588 int main() { return 0; }
590 if try $CC -c $CFLAGS $test.c; then
591 sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
592 mv zconf.temp.h zconf.h
593 echo "Checking for stdarg.h... Yes." | tee -a configure.log
595 echo "Checking for stdarg.h... No." | tee -a configure.log
598 # if the z_ prefix was requested, save that in zconf.h
599 if test $zprefix -eq 1; then
600 sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h
601 mv zconf.temp.h zconf.h
602 echo >> configure.log
603 echo "Using z_ prefix on all symbols." | tee -a configure.log
606 # if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists
607 if test $solo -eq 1; then
608 sed '/#define ZCONF_H/a\
611 ' < zconf.h > zconf.temp.h
612 mv zconf.temp.h zconf.h
614 PIC_OBJC='$(PIC_OBJZ)'
617 # if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
618 if test $cover -eq 1; then
619 CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
620 if test -n "$GCC_CLASSIC"; then
625 echo >> configure.log
627 # conduct a series of tests to resolve eight possible cases of using "vs" or "s" printf functions
628 # (using stdarg or not), with or without "n" (proving size of buffer), and with or without a
629 # return value. The most secure result is vsnprintf() with a return value. snprintf() with a
630 # return value is secure as well, but then gzprintf() will be limited to 20 arguments.
643 if try $CC -c $CFLAGS $test.c; then
644 echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." | tee -a configure.log
646 echo >> configure.log
650 int mytest(const char *fmt, ...)
655 vsnprintf(buf, sizeof(buf), fmt, ap);
661 return (mytest("Hello%d\n", 1));
664 if try $CC $CFLAGS -o $test $test.c; then
665 echo "Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log
667 echo >> configure.log
671 int mytest(const char *fmt, ...)
677 n = vsnprintf(buf, sizeof(buf), fmt, ap);
683 return (mytest("Hello%d\n", 1));
687 if try $CC -c $CFLAGS $test.c; then
688 echo "Checking for return value of vsnprintf()... Yes." | tee -a configure.log
690 CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
691 SFLAGS="$SFLAGS -DHAS_vsnprintf_void"
692 echo "Checking for return value of vsnprintf()... No." | tee -a configure.log
693 echo " WARNING: apparently vsnprintf() does not return a value. zlib" | tee -a configure.log
694 echo " can build but will be open to possible string-format security" | tee -a configure.log
695 echo " vulnerabilities." | tee -a configure.log
698 CFLAGS="$CFLAGS -DNO_vsnprintf"
699 SFLAGS="$SFLAGS -DNO_vsnprintf"
700 echo "Checking for vsnprintf() in stdio.h... No." | tee -a configure.log
701 echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log
702 echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
703 echo " vulnerabilities." | tee -a configure.log
705 echo >> configure.log
709 int mytest(const char *fmt, ...)
715 n = vsprintf(buf, fmt, ap);
721 return (mytest("Hello%d\n", 1));
725 if try $CC -c $CFLAGS $test.c; then
726 echo "Checking for return value of vsprintf()... Yes." | tee -a configure.log
728 CFLAGS="$CFLAGS -DHAS_vsprintf_void"
729 SFLAGS="$SFLAGS -DHAS_vsprintf_void"
730 echo "Checking for return value of vsprintf()... No." | tee -a configure.log
731 echo " WARNING: apparently vsprintf() does not return a value. zlib" | tee -a configure.log
732 echo " can build but will be open to possible string-format security" | tee -a configure.log
733 echo " vulnerabilities." | tee -a configure.log
737 echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." | tee -a configure.log
739 echo >> configure.log
745 snprintf(buf, sizeof(buf), "%s", "foo");
754 if try $CC $CFLAGS -o $test $test.c; then
755 echo "Checking for snprintf() in stdio.h... Yes." | tee -a configure.log
757 echo >> configure.log
763 return snprintf(buf, sizeof(buf), "%s", "foo");
771 if try $CC -c $CFLAGS $test.c; then
772 echo "Checking for return value of snprintf()... Yes." | tee -a configure.log
774 CFLAGS="$CFLAGS -DHAS_snprintf_void"
775 SFLAGS="$SFLAGS -DHAS_snprintf_void"
776 echo "Checking for return value of snprintf()... No." | tee -a configure.log
777 echo " WARNING: apparently snprintf() does not return a value. zlib" | tee -a configure.log
778 echo " can build but will be open to possible string-format security" | tee -a configure.log
779 echo " vulnerabilities." | tee -a configure.log
782 CFLAGS="$CFLAGS -DNO_snprintf"
783 SFLAGS="$SFLAGS -DNO_snprintf"
784 echo "Checking for snprintf() in stdio.h... No." | tee -a configure.log
785 echo " WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log
786 echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
787 echo " vulnerabilities." | tee -a configure.log
789 echo >> configure.log
795 return sprintf(buf, "%s", "foo");
803 if try $CC -c $CFLAGS $test.c; then
804 echo "Checking for return value of sprintf()... Yes." | tee -a configure.log
806 CFLAGS="$CFLAGS -DHAS_sprintf_void"
807 SFLAGS="$SFLAGS -DHAS_sprintf_void"
808 echo "Checking for return value of sprintf()... No." | tee -a configure.log
809 echo " WARNING: apparently sprintf() does not return a value. zlib" | tee -a configure.log
810 echo " can build but will be open to possible string-format security" | tee -a configure.log
811 echo " vulnerabilities." | tee -a configure.log
816 # see if we can hide zlib internal symbols that are linked between separate source files
817 if test "$gcc" -eq 1; then
818 echo >> configure.log
820 #define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
821 int ZLIB_INTERNAL foo;
827 if tryboth $CC -c $CFLAGS $test.c; then
828 CFLAGS="$CFLAGS -DHAVE_HIDDEN"
829 SFLAGS="$SFLAGS -DHAVE_HIDDEN"
830 echo "Checking for attribute(visibility) support... Yes." | tee -a configure.log
832 echo "Checking for attribute(visibility) support... No." | tee -a configure.log
836 # show the results in the log
837 echo >> configure.log
838 echo ALL = $ALL >> configure.log
839 echo AR = $AR >> configure.log
840 echo ARFLAGS = $ARFLAGS >> configure.log
841 echo CC = $CC >> configure.log
842 echo CFLAGS = $CFLAGS >> configure.log
843 echo CPP = $CPP >> configure.log
844 echo EXE = $EXE >> configure.log
845 echo LDCONFIG = $LDCONFIG >> configure.log
846 echo LDFLAGS = $LDFLAGS >> configure.log
847 echo LDSHARED = $LDSHARED >> configure.log
848 echo LDSHAREDLIBC = $LDSHAREDLIBC >> configure.log
849 echo OBJC = $OBJC >> configure.log
850 echo PIC_OBJC = $PIC_OBJC >> configure.log
851 echo RANLIB = $RANLIB >> configure.log
852 echo SFLAGS = $SFLAGS >> configure.log
853 echo SHAREDLIB = $SHAREDLIB >> configure.log
854 echo SHAREDLIBM = $SHAREDLIBM >> configure.log
855 echo SHAREDLIBV = $SHAREDLIBV >> configure.log
856 echo STATICLIB = $STATICLIB >> configure.log
857 echo TEST = $TEST >> configure.log
858 echo VER = $VER >> configure.log
859 echo SRCDIR = $SRCDIR >> configure.log
860 echo exec_prefix = $exec_prefix >> configure.log
861 echo includedir = $includedir >> configure.log
862 echo libdir = $libdir >> configure.log
863 echo mandir = $mandir >> configure.log
864 echo prefix = $prefix >> configure.log
865 echo sharedlibdir = $sharedlibdir >> configure.log
866 echo uname = $uname >> configure.log
868 # udpate Makefile with the configure results
869 sed < ${SRCDIR}Makefile.in "
871 /^CFLAGS *=/s#=.*#=$CFLAGS#
872 /^SFLAGS *=/s#=.*#=$SFLAGS#
873 /^LDFLAGS *=/s#=.*#=$LDFLAGS#
874 /^LDSHARED *=/s#=.*#=$LDSHARED#
875 /^CPP *=/s#=.*#=$CPP#
876 /^STATICLIB *=/s#=.*#=$STATICLIB#
877 /^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
878 /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
879 /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
881 /^ARFLAGS *=/s#=.*#=$ARFLAGS#
882 /^RANLIB *=/s#=.*#=$RANLIB#
883 /^LDCONFIG *=/s#=.*#=$LDCONFIG#
884 /^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
885 /^EXE *=/s#=.*#=$EXE#
886 /^SRCDIR *=/s#=.*#=$SRCDIR#
887 /^ZINC *=/s#=.*#=$ZINC#
888 /^ZINCOUT *=/s#=.*#=$ZINCOUT#
889 /^prefix *=/s#=.*#=$prefix#
890 /^exec_prefix *=/s#=.*#=$exec_prefix#
891 /^libdir *=/s#=.*#=$libdir#
892 /^sharedlibdir *=/s#=.*#=$sharedlibdir#
893 /^includedir *=/s#=.*#=$includedir#
894 /^mandir *=/s#=.*#=$mandir#
895 /^OBJC *=/s#=.*#= $OBJC#
896 /^PIC_OBJC *=/s#=.*#= $PIC_OBJC#
897 /^all: */s#:.*#: $ALL#
898 /^test: */s#:.*#: $TEST#
901 # create zlib.pc with the configure results
902 sed < ${SRCDIR}zlib.pc.in "
904 /^CFLAGS *=/s#=.*#=$CFLAGS#
905 /^CPP *=/s#=.*#=$CPP#
906 /^LDSHARED *=/s#=.*#=$LDSHARED#
907 /^STATICLIB *=/s#=.*#=$STATICLIB#
908 /^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
909 /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
910 /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
912 /^ARFLAGS *=/s#=.*#=$ARFLAGS#
913 /^RANLIB *=/s#=.*#=$RANLIB#
914 /^EXE *=/s#=.*#=$EXE#
915 /^prefix *=/s#=.*#=$prefix#
916 /^exec_prefix *=/s#=.*#=$exec_prefix#
917 /^libdir *=/s#=.*#=$libdir#
918 /^sharedlibdir *=/s#=.*#=$sharedlibdir#
919 /^includedir *=/s#=.*#=$includedir#
920 /^mandir *=/s#=.*#=$mandir#
921 /^LDFLAGS *=/s#=.*#=$LDFLAGS#
923 s/\@VERSION\@/$VER/g;