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 test -z "$CC" && echo Checking for ${CROSS_PREFIX}gcc... | tee -a configure.log
171 cc=${CC-${CROSS_PREFIX}gcc}
172 cflags=${CFLAGS-"-O3"}
173 # to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
178 case `$cc -v 2>&1` in
184 if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
185 echo ... using gcc >> configure.log
187 CFLAGS="${CFLAGS--O3}"
188 SFLAGS="${CFLAGS--O3} -fPIC"
189 if test "$ARCHS"; then
190 CFLAGS="${CFLAGS} ${ARCHS}"
191 LDFLAGS="${LDFLAGS} ${ARCHS}"
193 if test $build64 -eq 1; then
194 CFLAGS="${CFLAGS} -m64"
195 SFLAGS="${SFLAGS} -m64"
197 if test "$warn" -eq 1; then
198 if test "$zconst" -eq 1; then
199 CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -pedantic -DZLIB_CONST"
201 CFLAGS="${CFLAGS} -Wall -Wextra -pedantic"
204 if test $sanitize -eq 1; then
205 CFLAGS="${CFLAGS} -fsanitize=address"
207 if test $debug -eq 1; then
208 CFLAGS="${CFLAGS} -DZLIB_DEBUG"
209 SFLAGS="${SFLAGS} -DZLIB_DEBUG"
211 if test -z "$uname"; then
212 uname=`(uname -s || echo unknown) 2>/dev/null`
215 Linux* | linux* | GNU | GNU/* | solaris*)
216 LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;;
217 *BSD | *bsd* | DragonFly)
218 LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"}
219 LDCONFIG="ldconfig -m" ;;
220 CYGWIN* | Cygwin* | cygwin* | OS/2*)
224 rm -f $test.[co] $test $test$shared_ext
225 echo "Please use win32/Makefile.gcc instead." | tee -a configure.log
227 LDSHARED=${LDSHARED-"$cc -shared"}
230 QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
231 # (alain.bonnefoy@icbt.com)
232 LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
234 LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
235 case `(uname -m || echo unknown) 2>/dev/null` in
238 SHAREDLIB='libz.so' ;;
241 SHAREDLIB='libz.sl' ;;
245 SHAREDLIB=libz$shared_ext
246 SHAREDLIBV=libz.$VER$shared_ext
247 SHAREDLIBM=libz.$VER1$shared_ext
248 LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
249 if libtool -V 2>&1 | grep Apple > /dev/null; then
252 AR="/usr/bin/libtool"
255 *) LDSHARED=${LDSHARED-"$cc -shared"} ;;
258 # find system name and corresponding cc options
261 echo ... using $CC >> configure.log
262 if test -z "$uname"; then
263 uname=`(uname -sr || echo unknown) 2>/dev/null`
266 HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
267 CFLAGS=${CFLAGS-"-O"}
268 # LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
269 LDSHARED=${LDSHARED-"ld -b"}
270 case `(uname -m || echo unknown) 2>/dev/null` in
273 SHAREDLIB='libz.so' ;;
276 SHAREDLIB='libz.sl' ;;
278 IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
279 CFLAGS=${CFLAGS-"-ansi -O2"}
280 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
281 OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
282 CFLAGS=${CFLAGS-"-O -std1"}
283 LDFLAGS="${LDFLAGS} -Wl,-rpath,."
284 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;;
285 OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
286 CFLAGS=${CFLAGS-"-O -std1"}
287 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
288 QNX*) SFLAGS=${CFLAGS-"-4 -O"}
289 CFLAGS=${CFLAGS-"-4 -O"}
290 LDSHARED=${LDSHARED-"cc"}
291 RANLIB=${RANLIB-"true"}
294 SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
295 CFLAGS=${CFLAGS-"-O3"}
296 LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;;
297 SunOS\ 5* | solaris*)
298 LDSHARED=${LDSHARED-"cc -G -h libz$shared_ext.$VER1"}
299 SFLAGS=${CFLAGS-"-fast -KPIC"}
300 CFLAGS=${CFLAGS-"-fast"}
301 if test $build64 -eq 1; then
302 # old versions of SunPRO/Workshop/Studio don't support -m64,
303 # but newer ones do. Check for it.
304 flag64=`$CC -flags | egrep -- '^-m64'`
305 if test x"$flag64" != x"" ; then
306 CFLAGS="${CFLAGS} -m64"
307 SFLAGS="${SFLAGS} -m64"
309 case `(uname -m || echo unknown) 2>/dev/null` in
311 SFLAGS="$SFLAGS -xarch=amd64"
312 CFLAGS="$CFLAGS -xarch=amd64" ;;
314 SFLAGS="$SFLAGS -xarch=v9"
315 CFLAGS="$CFLAGS -xarch=v9" ;;
319 if test -n "$ZINC"; then
320 ZINC='-I- -I. -I$(SRCDIR)'
323 SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
324 CFLAGS=${CFLAGS-"-O2"}
325 LDSHARED=${LDSHARED-"ld"} ;;
326 SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
327 CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"}
328 LDSHARED=${LDSHARED-"cc -xarch=v9b"} ;;
329 UNIX_System_V\ 4.2.0)
330 SFLAGS=${CFLAGS-"-KPIC -O"}
331 CFLAGS=${CFLAGS-"-O"}
332 LDSHARED=${LDSHARED-"cc -G"} ;;
334 SFLAGS=${CFLAGS-"-Kconform_pic -O"}
335 CFLAGS=${CFLAGS-"-O"}
336 LDSHARED=${LDSHARED-"cc -G"} ;;
338 SFLAGS=${CFLAGS-"-KPIC -O"}
339 CFLAGS=${CFLAGS-"-O"}
340 LDSHARED=${LDSHARED-"cc -G"} ;;
341 AIX*) # Courtesy of dbakker@arrayasolutions.com
342 SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
343 CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
344 LDSHARED=${LDSHARED-"xlc -G"} ;;
345 # send working options for other systems to zlib@gzip.org
346 *) SFLAGS=${CFLAGS-"-O"}
347 CFLAGS=${CFLAGS-"-O"}
348 LDSHARED=${LDSHARED-"cc -shared"} ;;
352 # destination names for shared library if not defined above
353 SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
354 SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
355 SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
357 echo >> configure.log
359 # define functions for testing compiler and library characteristics and logging the results
364 if ($CC -c $CFLAGS $test.c) 2>/dev/null; then
368 test "`( $* ) 2>&1 | tee -a configure.log`" = ""
370 echo - using any output from compiler to indicate an error >> configure.log
377 if test "$got" != ""; then
378 printf "%s\n" "$got" >> configure.log
380 if test $ret -ne 0; then
381 echo "(exit code "$ret")" >> configure.log
392 if test "$got" != ""; then
393 printf "%s\n" "$got" >> configure.log
395 if test $ret -ne 0; then
396 echo "(exit code "$ret")" >> configure.log
403 int foo() { return 0; }
405 echo "Checking for obsessive-compulsive compiler options..." >> configure.log
406 if try $CC -c $CFLAGS $test.c; then
409 echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log
413 echo >> configure.log
415 # see if shared library build supported
417 extern int getchar();
418 int hello() {return getchar();}
420 if test $shared -eq 1; then
421 echo Checking for shared library support... | tee -a configure.log
422 # we must test in two steps (cc then ld), required at least on SunOS 4.x
423 if try $CC -w -c $SFLAGS $test.c &&
424 try $LDSHARED $SFLAGS -o $test$shared_ext $test.o; then
425 echo Building shared library $SHAREDLIBV with $CC. | tee -a configure.log
426 elif test -z "$old_cc" -a -z "$old_cflags"; then
427 echo No shared library support. | tee -a configure.log
430 echo 'No shared library support; try without defining CC and CFLAGS' | tee -a configure.log
434 if test $shared -eq 0; then
437 TEST="all teststatic"
441 echo Building static library $STATICLIB version $VER with $CC. | tee -a configure.log
444 TEST="all teststatic testshared"
447 # check for underscores in external names for use by assembler code
451 echo >> configure.log
452 show "$NM $test.o | grep _hello"
453 if test "`$NM $test.o | grep _hello | tee -a configure.log`" = ""; then
454 CPP="$CPP -DNO_UNDERLINE"
455 echo Checking for underline in external names... No. | tee -a configure.log
457 echo Checking for underline in external names... Yes. | tee -a configure.log
461 echo >> configure.log
469 if try $CC -c $CFLAGS $test.c; then
470 echo "Checking for size_t... Yes." | tee -a configure.log
472 echo "Checking for size_t... No." | tee -a configure.log
473 # find a size_t integer type
474 # check for long long
478 if try $CC -c $CFLAGS $test.c; then
479 echo "Checking for long long... Yes." | tee -a configure.log
483 if (sizeof(void *) <= sizeof(int)) puts("int");
484 else if (sizeof(void *) <= sizeof(long)) puts("long");
485 else puts("z_longlong");
490 echo "Checking for long long... No." | tee -a configure.log
494 if (sizeof(void *) <= sizeof(int)) puts("int");
500 if try $CC $CFLAGS -o $test $test.c; then
502 echo "Checking for a pointer-size integer type..." $sizet"." | tee -a configure.log
503 CFLAGS="${CFLAGS} -DNO_SIZE_T=${sizet}"
504 SFLAGS="${SFLAGS} -DNO_SIZE_T=${sizet}"
506 echo "Checking for a pointer-size integer type... not found." | tee -a configure.log
510 echo >> configure.log
512 # check for large file support, and if none, check for fseeko()
514 #include <sys/types.h>
517 if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then
518 CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1"
519 SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1"
521 TEST="${TEST} test64"
522 echo "Checking for off64_t... Yes." | tee -a configure.log
523 echo "Checking for fseeko... Yes." | tee -a configure.log
525 echo "Checking for off64_t... No." | tee -a configure.log
526 echo >> configure.log
534 if try $CC $CFLAGS -o $test $test.c; then
535 echo "Checking for fseeko... Yes." | tee -a configure.log
537 CFLAGS="${CFLAGS} -DNO_FSEEKO"
538 SFLAGS="${SFLAGS} -DNO_FSEEKO"
539 echo "Checking for fseeko... No." | tee -a configure.log
543 echo >> configure.log
545 # check for strerror() for use by gz* functions
549 int main() { return strlen(strerror(errno)); }
551 if try $CC $CFLAGS -o $test $test.c; then
552 echo "Checking for strerror... Yes." | tee -a configure.log
554 CFLAGS="${CFLAGS} -DNO_STRERROR"
555 SFLAGS="${SFLAGS} -DNO_STRERROR"
556 echo "Checking for strerror... No." | tee -a configure.log
559 # copy clean zconf.h for subsequent edits
560 cp -p ${SRCDIR}zconf.h.in zconf.h
562 echo >> configure.log
564 # check for unistd.h and save result in zconf.h
567 int main() { return 0; }
569 if try $CC -c $CFLAGS $test.c; then
570 sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
571 mv zconf.temp.h zconf.h
572 echo "Checking for unistd.h... Yes." | tee -a configure.log
574 echo "Checking for unistd.h... No." | tee -a configure.log
577 echo >> configure.log
579 # check for stdarg.h and save result in zconf.h
582 int main() { return 0; }
584 if try $CC -c $CFLAGS $test.c; then
585 sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
586 mv zconf.temp.h zconf.h
587 echo "Checking for stdarg.h... Yes." | tee -a configure.log
589 echo "Checking for stdarg.h... No." | tee -a configure.log
592 # if the z_ prefix was requested, save that in zconf.h
593 if test $zprefix -eq 1; then
594 sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h
595 mv zconf.temp.h zconf.h
596 echo >> configure.log
597 echo "Using z_ prefix on all symbols." | tee -a configure.log
600 # if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists
601 if test $solo -eq 1; then
602 sed '/#define ZCONF_H/a\
605 ' < zconf.h > zconf.temp.h
606 mv zconf.temp.h zconf.h
608 PIC_OBJC='$(PIC_OBJZ)'
611 # if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
612 if test $cover -eq 1; then
613 CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
614 if test -n "$GCC_CLASSIC"; then
619 echo >> configure.log
621 # conduct a series of tests to resolve eight possible cases of using "vs" or "s" printf functions
622 # (using stdarg or not), with or without "n" (proving size of buffer), and with or without a
623 # return value. The most secure result is vsnprintf() with a return value. snprintf() with a
624 # return value is secure as well, but then gzprintf() will be limited to 20 arguments.
637 if try $CC -c $CFLAGS $test.c; then
638 echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." | tee -a configure.log
640 echo >> configure.log
644 int mytest(const char *fmt, ...)
649 vsnprintf(buf, sizeof(buf), fmt, ap);
655 return (mytest("Hello%d\n", 1));
658 if try $CC $CFLAGS -o $test $test.c; then
659 echo "Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log
661 echo >> configure.log
665 int mytest(const char *fmt, ...)
671 n = vsnprintf(buf, sizeof(buf), fmt, ap);
677 return (mytest("Hello%d\n", 1));
681 if try $CC -c $CFLAGS $test.c; then
682 echo "Checking for return value of vsnprintf()... Yes." | tee -a configure.log
684 CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
685 SFLAGS="$SFLAGS -DHAS_vsnprintf_void"
686 echo "Checking for return value of vsnprintf()... No." | tee -a configure.log
687 echo " WARNING: apparently vsnprintf() does not return a value. zlib" | tee -a configure.log
688 echo " can build but will be open to possible string-format security" | tee -a configure.log
689 echo " vulnerabilities." | tee -a configure.log
692 CFLAGS="$CFLAGS -DNO_vsnprintf"
693 SFLAGS="$SFLAGS -DNO_vsnprintf"
694 echo "Checking for vsnprintf() in stdio.h... No." | tee -a configure.log
695 echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log
696 echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
697 echo " vulnerabilities." | tee -a configure.log
699 echo >> configure.log
703 int mytest(const char *fmt, ...)
709 n = vsprintf(buf, fmt, ap);
715 return (mytest("Hello%d\n", 1));
719 if try $CC -c $CFLAGS $test.c; then
720 echo "Checking for return value of vsprintf()... Yes." | tee -a configure.log
722 CFLAGS="$CFLAGS -DHAS_vsprintf_void"
723 SFLAGS="$SFLAGS -DHAS_vsprintf_void"
724 echo "Checking for return value of vsprintf()... No." | tee -a configure.log
725 echo " WARNING: apparently vsprintf() does not return a value. zlib" | tee -a configure.log
726 echo " can build but will be open to possible string-format security" | tee -a configure.log
727 echo " vulnerabilities." | tee -a configure.log
731 echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." | tee -a configure.log
733 echo >> configure.log
739 snprintf(buf, sizeof(buf), "%s", "foo");
748 if try $CC $CFLAGS -o $test $test.c; then
749 echo "Checking for snprintf() in stdio.h... Yes." | tee -a configure.log
751 echo >> configure.log
757 return snprintf(buf, sizeof(buf), "%s", "foo");
765 if try $CC -c $CFLAGS $test.c; then
766 echo "Checking for return value of snprintf()... Yes." | tee -a configure.log
768 CFLAGS="$CFLAGS -DHAS_snprintf_void"
769 SFLAGS="$SFLAGS -DHAS_snprintf_void"
770 echo "Checking for return value of snprintf()... No." | tee -a configure.log
771 echo " WARNING: apparently snprintf() does not return a value. zlib" | tee -a configure.log
772 echo " can build but will be open to possible string-format security" | tee -a configure.log
773 echo " vulnerabilities." | tee -a configure.log
776 CFLAGS="$CFLAGS -DNO_snprintf"
777 SFLAGS="$SFLAGS -DNO_snprintf"
778 echo "Checking for snprintf() in stdio.h... No." | tee -a configure.log
779 echo " WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log
780 echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
781 echo " vulnerabilities." | tee -a configure.log
783 echo >> configure.log
789 return sprintf(buf, "%s", "foo");
797 if try $CC -c $CFLAGS $test.c; then
798 echo "Checking for return value of sprintf()... Yes." | tee -a configure.log
800 CFLAGS="$CFLAGS -DHAS_sprintf_void"
801 SFLAGS="$SFLAGS -DHAS_sprintf_void"
802 echo "Checking for return value of sprintf()... No." | tee -a configure.log
803 echo " WARNING: apparently sprintf() does not return a value. zlib" | tee -a configure.log
804 echo " can build but will be open to possible string-format security" | tee -a configure.log
805 echo " vulnerabilities." | tee -a configure.log
810 # see if we can hide zlib internal symbols that are linked between separate source files
811 if test "$gcc" -eq 1; then
812 echo >> configure.log
814 #define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
815 int ZLIB_INTERNAL foo;
821 if tryboth $CC -c $CFLAGS $test.c; then
822 CFLAGS="$CFLAGS -DHAVE_HIDDEN"
823 SFLAGS="$SFLAGS -DHAVE_HIDDEN"
824 echo "Checking for attribute(visibility) support... Yes." | tee -a configure.log
826 echo "Checking for attribute(visibility) support... No." | tee -a configure.log
830 # show the results in the log
831 echo >> configure.log
832 echo ALL = $ALL >> configure.log
833 echo AR = $AR >> configure.log
834 echo ARFLAGS = $ARFLAGS >> configure.log
835 echo CC = $CC >> configure.log
836 echo CFLAGS = $CFLAGS >> configure.log
837 echo CPP = $CPP >> configure.log
838 echo EXE = $EXE >> configure.log
839 echo LDCONFIG = $LDCONFIG >> configure.log
840 echo LDFLAGS = $LDFLAGS >> configure.log
841 echo LDSHARED = $LDSHARED >> configure.log
842 echo LDSHAREDLIBC = $LDSHAREDLIBC >> configure.log
843 echo OBJC = $OBJC >> configure.log
844 echo PIC_OBJC = $PIC_OBJC >> configure.log
845 echo RANLIB = $RANLIB >> configure.log
846 echo SFLAGS = $SFLAGS >> configure.log
847 echo SHAREDLIB = $SHAREDLIB >> configure.log
848 echo SHAREDLIBM = $SHAREDLIBM >> configure.log
849 echo SHAREDLIBV = $SHAREDLIBV >> configure.log
850 echo STATICLIB = $STATICLIB >> configure.log
851 echo TEST = $TEST >> configure.log
852 echo VER = $VER >> configure.log
853 echo SRCDIR = $SRCDIR >> configure.log
854 echo exec_prefix = $exec_prefix >> configure.log
855 echo includedir = $includedir >> configure.log
856 echo libdir = $libdir >> configure.log
857 echo mandir = $mandir >> configure.log
858 echo prefix = $prefix >> configure.log
859 echo sharedlibdir = $sharedlibdir >> configure.log
860 echo uname = $uname >> configure.log
862 # udpate Makefile with the configure results
863 sed < ${SRCDIR}Makefile.in "
865 /^CFLAGS *=/s#=.*#=$CFLAGS#
866 /^SFLAGS *=/s#=.*#=$SFLAGS#
867 /^LDFLAGS *=/s#=.*#=$LDFLAGS#
868 /^LDSHARED *=/s#=.*#=$LDSHARED#
869 /^CPP *=/s#=.*#=$CPP#
870 /^STATICLIB *=/s#=.*#=$STATICLIB#
871 /^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
872 /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
873 /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
875 /^ARFLAGS *=/s#=.*#=$ARFLAGS#
876 /^RANLIB *=/s#=.*#=$RANLIB#
877 /^LDCONFIG *=/s#=.*#=$LDCONFIG#
878 /^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
879 /^EXE *=/s#=.*#=$EXE#
880 /^SRCDIR *=/s#=.*#=$SRCDIR#
881 /^ZINC *=/s#=.*#=$ZINC#
882 /^ZINCOUT *=/s#=.*#=$ZINCOUT#
883 /^prefix *=/s#=.*#=$prefix#
884 /^exec_prefix *=/s#=.*#=$exec_prefix#
885 /^libdir *=/s#=.*#=$libdir#
886 /^sharedlibdir *=/s#=.*#=$sharedlibdir#
887 /^includedir *=/s#=.*#=$includedir#
888 /^mandir *=/s#=.*#=$mandir#
889 /^OBJC *=/s#=.*#= $OBJC#
890 /^PIC_OBJC *=/s#=.*#= $PIC_OBJC#
891 /^all: */s#:.*#: $ALL#
892 /^test: */s#:.*#: $TEST#
895 # create zlib.pc with the configure results
896 sed < ${SRCDIR}zlib.pc.in "
898 /^CFLAGS *=/s#=.*#=$CFLAGS#
899 /^CPP *=/s#=.*#=$CPP#
900 /^LDSHARED *=/s#=.*#=$LDSHARED#
901 /^STATICLIB *=/s#=.*#=$STATICLIB#
902 /^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
903 /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
904 /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
906 /^ARFLAGS *=/s#=.*#=$ARFLAGS#
907 /^RANLIB *=/s#=.*#=$RANLIB#
908 /^EXE *=/s#=.*#=$EXE#
909 /^prefix *=/s#=.*#=$prefix#
910 /^exec_prefix *=/s#=.*#=$exec_prefix#
911 /^libdir *=/s#=.*#=$libdir#
912 /^sharedlibdir *=/s#=.*#=$sharedlibdir#
913 /^includedir *=/s#=.*#=$includedir#
914 /^mandir *=/s#=.*#=$mandir#
915 /^LDFLAGS *=/s#=.*#=$LDFLAGS#
917 s/\@VERSION\@/$VER/g;