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
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=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < ${SRCDIR}zlib.h`
48 VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
49 VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
51 # establish commands for library building
52 if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then
53 AR=${AR-"${CROSS_PREFIX}ar"}
54 test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
57 test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
59 ARFLAGS=${ARFLAGS-"rc"}
60 if "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null || test $? -lt 126; then
61 RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"}
62 test -n "${CROSS_PREFIX}" && echo Using ${RANLIB} | tee -a configure.log
64 RANLIB=${RANLIB-"ranlib"}
66 if "${CROSS_PREFIX}nm" --version >/dev/null 2>/dev/null || test $? -lt 126; then
67 NM=${NM-"${CROSS_PREFIX}nm"}
68 test -n "${CROSS_PREFIX}" && echo Using ${NM} | tee -a configure.log
73 # set defaults before processing command line options
74 LDCONFIG=${LDCONFIG-"ldconfig"}
75 LDSHAREDLIBC="${LDSHAREDLIBC--lc}"
77 prefix=${prefix-/usr/local}
78 exec_prefix=${exec_prefix-'${prefix}'}
79 libdir=${libdir-'${exec_prefix}/lib'}
80 sharedlibdir=${sharedlibdir-'${libdir}'}
81 includedir=${includedir-'${prefix}/include'}
82 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 -f $test.[co] $test $test$shared_ext $test.gcno ./--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) sanitize=1; shift ;;
146 echo "unknown option: $1" | tee -a configure.log
147 echo "$0 --help for help" | tee -a configure.log
152 # temporary file name
155 # put arguments in log, also put test file in log if used in arguments
160 echo === $test.c === >> configure.log
161 cat $test.c >> configure.log
162 echo === >> configure.log;;
164 echo $* >> configure.log
167 # check for gcc vs. cc and set compile and link flags based on the system identified by uname
169 extern int getchar();
170 int hello() {return getchar();}
173 if test -z "$CC"; then
174 echo Checking for ${CROSS_PREFIX}gcc... | tee -a configure.log
175 if ${CROSS_PREFIX}gcc -v >/dev/null 2>&1; then
176 cc=${CROSS_PREFIX}gcc
188 case `$cc -v 2>&1` in
194 if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
195 echo ... using gcc >> configure.log
197 CFLAGS="${CFLAGS--O3}"
198 SFLAGS="${CFLAGS--O3} -fPIC"
199 if test "$ARCHS"; then
200 CFLAGS="${CFLAGS} ${ARCHS}"
201 LDFLAGS="${LDFLAGS} ${ARCHS}"
203 if test $build64 -eq 1; then
204 CFLAGS="${CFLAGS} -m64"
205 SFLAGS="${SFLAGS} -m64"
207 if test "$warn" -eq 1; then
208 if test "$zconst" -eq 1; then
209 CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -DZLIB_CONST"
211 CFLAGS="${CFLAGS} -Wall -Wextra"
214 if test $sanitize -eq 1; then
215 CFLAGS="${CFLAGS} -g -fsanitize=address"
217 if test $debug -eq 1; then
218 CFLAGS="${CFLAGS} -DZLIB_DEBUG"
219 SFLAGS="${SFLAGS} -DZLIB_DEBUG"
221 if test -z "$uname"; then
222 uname=`(uname -s || echo unknown) 2>/dev/null`
225 Linux* | linux* | *-linux* | GNU | GNU/* | solaris*)
228 LDFLAGS="${LDFLAGS} -Wl,--no-warn-rwx-segments" ;;
230 LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;;
231 *BSD | *bsd* | DragonFly)
232 LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"}
233 LDCONFIG="ldconfig -m" ;;
234 CYGWIN* | Cygwin* | cygwin* | *-cygwin* | OS/2*)
236 MINGW* | mingw* | *-mingw*)
237 rm -f $test.[co] $test $test$shared_ext
238 echo "If this doesn't work for you, try win32/Makefile.gcc." | tee -a configure.log
239 LDSHARED=${LDSHARED-"$cc -shared"}
242 QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
243 # (alain.bonnefoy@icbt.com)
244 LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
246 LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
247 case `(uname -m || echo unknown) 2>/dev/null` in
250 SHAREDLIB='libz.so' ;;
253 SHAREDLIB='libz.sl' ;;
256 LDFLAGS="${LDFLAGS} -Wl,-brtl" ;;
257 Darwin* | darwin* | *-darwin*)
259 SHAREDLIB=libz$shared_ext
260 SHAREDLIBV=libz.$VER$shared_ext
261 SHAREDLIBM=libz.$VER1$shared_ext
262 LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
263 if libtool -V 2>&1 | grep Apple > /dev/null; then
266 AR="/usr/bin/libtool"
270 LDSHARED=${LDSHARED-"$cc -shared"} ;;
273 # find system name and corresponding cc options
276 echo ... using $CC >> configure.log
277 if test -z "$uname"; then
278 uname=`(uname -sr || echo unknown) 2>/dev/null`
281 HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
282 CFLAGS=${CFLAGS-"-O"}
283 # LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
284 LDSHARED=${LDSHARED-"ld -b"}
285 case `(uname -m || echo unknown) 2>/dev/null` in
288 SHAREDLIB='libz.so' ;;
291 SHAREDLIB='libz.sl' ;;
293 IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
294 CFLAGS=${CFLAGS-"-ansi -O2"}
295 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
296 OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
297 CFLAGS=${CFLAGS-"-O -std1"}
298 LDFLAGS="${LDFLAGS} -Wl,-rpath,."
299 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;;
300 OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
301 CFLAGS=${CFLAGS-"-O -std1"}
302 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
303 QNX*) SFLAGS=${CFLAGS-"-4 -O"}
304 CFLAGS=${CFLAGS-"-4 -O"}
305 LDSHARED=${LDSHARED-"cc"}
306 RANLIB=${RANLIB-"true"}
309 SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
310 CFLAGS=${CFLAGS-"-O3"}
311 LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;;
312 SunOS\ 5* | solaris*)
313 LDSHARED=${LDSHARED-"cc -G -h libz$shared_ext.$VER1"}
314 SFLAGS=${CFLAGS-"-fast -KPIC"}
315 CFLAGS=${CFLAGS-"-fast"}
316 if test $build64 -eq 1; then
317 # old versions of SunPRO/Workshop/Studio don't support -m64,
318 # but newer ones do. Check for it.
319 flag64=`$CC -flags | egrep -- '^-m64'`
320 if test x"$flag64" != x"" ; then
321 CFLAGS="${CFLAGS} -m64"
322 SFLAGS="${SFLAGS} -m64"
324 case `(uname -m || echo unknown) 2>/dev/null` in
326 SFLAGS="$SFLAGS -xarch=amd64"
327 CFLAGS="$CFLAGS -xarch=amd64" ;;
329 SFLAGS="$SFLAGS -xarch=v9"
330 CFLAGS="$CFLAGS -xarch=v9" ;;
334 if test -n "$ZINC"; then
335 ZINC='-I- -I. -I$(SRCDIR)'
338 SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
339 CFLAGS=${CFLAGS-"-O2"}
340 LDSHARED=${LDSHARED-"ld"} ;;
341 SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
342 CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"}
343 LDSHARED=${LDSHARED-"cc -xarch=v9b"} ;;
344 UNIX_System_V\ 4.2.0)
345 SFLAGS=${CFLAGS-"-KPIC -O"}
346 CFLAGS=${CFLAGS-"-O"}
347 LDSHARED=${LDSHARED-"cc -G"} ;;
349 SFLAGS=${CFLAGS-"-Kconform_pic -O"}
350 CFLAGS=${CFLAGS-"-O"}
351 LDSHARED=${LDSHARED-"cc -G"} ;;
353 SFLAGS=${CFLAGS-"-KPIC -O"}
354 CFLAGS=${CFLAGS-"-O"}
355 LDSHARED=${LDSHARED-"cc -G"} ;;
356 AIX*) # Courtesy of dbakker@arrayasolutions.com
357 SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
358 CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
359 LDSHARED=${LDSHARED-"xlc -G"} ;;
360 # send working options for other systems to zlib@gzip.org
361 *) SFLAGS=${CFLAGS-"-O"}
362 CFLAGS=${CFLAGS-"-O"}
363 LDSHARED=${LDSHARED-"cc -shared"} ;;
367 # destination names for shared library if not defined above
368 SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
369 SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
370 SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
372 echo >> configure.log
374 # define functions for testing compiler and library characteristics and logging the results
379 if ($CC -c $CFLAGS $test.c) 2>/dev/null; then
383 test "`( $* ) 2>&1 | tee -a configure.log`" = ""
385 echo - using any output from compiler to indicate an error >> 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
407 if test "$got" != ""; then
408 printf "%s\n" "$got" >> configure.log
410 if test $ret -ne 0; then
411 echo "(exit code "$ret")" >> configure.log
418 int foo() { return 0; }
420 echo "Checking for obsessive-compulsive compiler options..." >> configure.log
421 if try $CC -c $CFLAGS $test.c; then
424 echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log
428 echo >> configure.log
430 # see if shared library build supported
432 extern int getchar();
433 int hello() {return getchar();}
435 if test $shared -eq 1; then
436 echo Checking for shared library support... | tee -a configure.log
437 # we must test in two steps (cc then ld), required at least on SunOS 4.x
438 if try $CC -w -c $SFLAGS $test.c &&
439 try $LDSHARED $SFLAGS -o $test$shared_ext $test.o; then
440 echo Building shared library $SHAREDLIBV with $CC. | tee -a configure.log
441 elif test -z "$old_cc" -a -z "$old_cflags"; then
442 echo No shared library support. | tee -a configure.log
445 echo 'No shared library support; try without defining CC and CFLAGS' | tee -a configure.log
449 if test $shared -eq 0; then
452 TEST="all teststatic"
456 echo Building static library $STATICLIB version $VER with $CC. | tee -a configure.log
459 TEST="all teststatic testshared"
462 echo >> configure.log
470 if try $CC -c $CFLAGS $test.c; then
471 echo "Checking for size_t... Yes." | tee -a configure.log
473 echo "Checking for size_t... No." | tee -a configure.log
474 # find a size_t integer type
475 # check for long long
479 if try $CC -c $CFLAGS $test.c; then
480 echo "Checking for long long... Yes." | tee -a configure.log
484 if (sizeof(void *) <= sizeof(int)) puts("int");
485 else if (sizeof(void *) <= sizeof(long)) puts("long");
486 else puts("z_longlong");
491 echo "Checking for long long... No." | tee -a configure.log
495 if (sizeof(void *) <= sizeof(int)) puts("int");
501 if try $CC $CFLAGS -o $test $test.c; then
503 echo "Checking for a pointer-size integer type..." $sizet"." | tee -a configure.log
504 CFLAGS="${CFLAGS} -DNO_SIZE_T=${sizet}"
505 SFLAGS="${SFLAGS} -DNO_SIZE_T=${sizet}"
507 echo "Checking for a pointer-size integer type... not found." | tee -a configure.log
511 echo >> configure.log
513 # check for large file support, and if none, check for fseeko()
515 #include <sys/types.h>
518 if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then
519 CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1"
520 SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1"
522 TEST="${TEST} test64"
523 echo "Checking for off64_t... Yes." | tee -a configure.log
524 echo "Checking for fseeko... Yes." | tee -a configure.log
526 echo "Checking for off64_t... No." | tee -a configure.log
527 echo >> configure.log
535 if try $CC $CFLAGS -o $test $test.c; then
536 echo "Checking for fseeko... Yes." | tee -a configure.log
538 CFLAGS="${CFLAGS} -DNO_FSEEKO"
539 SFLAGS="${SFLAGS} -DNO_FSEEKO"
540 echo "Checking for fseeko... No." | tee -a configure.log
544 echo >> configure.log
546 # check for strerror() for use by gz* functions
550 int main() { return strlen(strerror(errno)); }
552 if try $CC $CFLAGS -o $test $test.c; then
553 echo "Checking for strerror... Yes." | tee -a configure.log
555 CFLAGS="${CFLAGS} -DNO_STRERROR"
556 SFLAGS="${SFLAGS} -DNO_STRERROR"
557 echo "Checking for strerror... No." | tee -a configure.log
560 # copy clean zconf.h for subsequent edits
561 cp -p ${SRCDIR}zconf.h.in zconf.h
563 echo >> configure.log
565 # check for unistd.h and save result in zconf.h
568 int main() { return 0; }
570 if try $CC -c $CFLAGS $test.c; then
571 sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
572 mv zconf.temp.h zconf.h
573 echo "Checking for unistd.h... Yes." | tee -a configure.log
575 echo "Checking for unistd.h... No." | tee -a configure.log
578 echo >> configure.log
580 # check for stdarg.h and save result in zconf.h
583 int main() { return 0; }
585 if try $CC -c $CFLAGS $test.c; then
586 sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
587 mv zconf.temp.h zconf.h
588 echo "Checking for stdarg.h... Yes." | tee -a configure.log
590 echo "Checking for stdarg.h... No." | tee -a configure.log
593 # if the z_ prefix was requested, save that in zconf.h
594 if test $zprefix -eq 1; then
595 sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h
596 mv zconf.temp.h zconf.h
597 echo >> configure.log
598 echo "Using z_ prefix on all symbols." | tee -a configure.log
601 # if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists
602 if test $solo -eq 1; then
603 sed '/#define ZCONF_H/a\
606 ' < zconf.h > zconf.temp.h
607 mv zconf.temp.h zconf.h
609 PIC_OBJC='$(PIC_OBJZ)'
612 # if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
613 if test $cover -eq 1; then
614 CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
615 if test -n "$GCC_CLASSIC"; then
620 echo >> configure.log
622 # conduct a series of tests to resolve eight possible cases of using "vs" or "s" printf functions
623 # (using stdarg or not), with or without "n" (proving size of buffer), and with or without a
624 # return value. The most secure result is vsnprintf() with a return value. snprintf() with a
625 # return value is secure as well, but then gzprintf() will be limited to 20 arguments.
638 if try $CC -c $CFLAGS $test.c; then
639 echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." | tee -a configure.log
641 echo >> configure.log
645 int mytest(const char *fmt, ...)
650 vsnprintf(buf, sizeof(buf), fmt, ap);
656 return (mytest("Hello%d\n", 1));
659 if try $CC $CFLAGS -o $test $test.c; then
660 echo "Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log
662 echo >> configure.log
666 int mytest(const char *fmt, ...)
672 n = vsnprintf(buf, sizeof(buf), fmt, ap);
678 return (mytest("Hello%d\n", 1));
682 if try $CC -c $CFLAGS $test.c; then
683 echo "Checking for return value of vsnprintf()... Yes." | tee -a configure.log
685 CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
686 SFLAGS="$SFLAGS -DHAS_vsnprintf_void"
687 echo "Checking for return value of vsnprintf()... No." | tee -a configure.log
688 echo " WARNING: apparently vsnprintf() does not return a value. zlib" | tee -a configure.log
689 echo " can build but will be open to possible string-format security" | tee -a configure.log
690 echo " vulnerabilities." | tee -a configure.log
693 CFLAGS="$CFLAGS -DNO_vsnprintf"
694 SFLAGS="$SFLAGS -DNO_vsnprintf"
695 echo "Checking for vsnprintf() in stdio.h... No." | tee -a configure.log
696 echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log
697 echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
698 echo " vulnerabilities." | tee -a configure.log
700 echo >> configure.log
704 int mytest(const char *fmt, ...)
710 n = vsprintf(buf, fmt, ap);
716 return (mytest("Hello%d\n", 1));
720 if try $CC -c $CFLAGS $test.c; then
721 echo "Checking for return value of vsprintf()... Yes." | tee -a configure.log
723 CFLAGS="$CFLAGS -DHAS_vsprintf_void"
724 SFLAGS="$SFLAGS -DHAS_vsprintf_void"
725 echo "Checking for return value of vsprintf()... No." | tee -a configure.log
726 echo " WARNING: apparently vsprintf() does not return a value. zlib" | tee -a configure.log
727 echo " can build but will be open to possible string-format security" | tee -a configure.log
728 echo " vulnerabilities." | tee -a configure.log
732 echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." | tee -a configure.log
734 echo >> configure.log
740 snprintf(buf, sizeof(buf), "%s", "foo");
749 if try $CC $CFLAGS -o $test $test.c; then
750 echo "Checking for snprintf() in stdio.h... Yes." | tee -a configure.log
752 echo >> configure.log
758 return snprintf(buf, sizeof(buf), "%s", "foo");
766 if try $CC -c $CFLAGS $test.c; then
767 echo "Checking for return value of snprintf()... Yes." | tee -a configure.log
769 CFLAGS="$CFLAGS -DHAS_snprintf_void"
770 SFLAGS="$SFLAGS -DHAS_snprintf_void"
771 echo "Checking for return value of snprintf()... No." | tee -a configure.log
772 echo " WARNING: apparently snprintf() does not return a value. zlib" | tee -a configure.log
773 echo " can build but will be open to possible string-format security" | tee -a configure.log
774 echo " vulnerabilities." | tee -a configure.log
777 CFLAGS="$CFLAGS -DNO_snprintf"
778 SFLAGS="$SFLAGS -DNO_snprintf"
779 echo "Checking for snprintf() in stdio.h... No." | tee -a configure.log
780 echo " WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log
781 echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
782 echo " vulnerabilities." | tee -a configure.log
784 echo >> configure.log
790 return sprintf(buf, "%s", "foo");
798 if try $CC -c $CFLAGS $test.c; then
799 echo "Checking for return value of sprintf()... Yes." | tee -a configure.log
801 CFLAGS="$CFLAGS -DHAS_sprintf_void"
802 SFLAGS="$SFLAGS -DHAS_sprintf_void"
803 echo "Checking for return value of sprintf()... No." | tee -a configure.log
804 echo " WARNING: apparently sprintf() does not return a value. zlib" | tee -a configure.log
805 echo " can build but will be open to possible string-format security" | tee -a configure.log
806 echo " vulnerabilities." | tee -a configure.log
811 # see if we can hide zlib internal symbols that are linked between separate source files
812 if test "$gcc" -eq 1; then
813 echo >> configure.log
815 #define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
816 int ZLIB_INTERNAL foo;
822 if tryboth $CC -c $CFLAGS $test.c; then
823 CFLAGS="$CFLAGS -DHAVE_HIDDEN"
824 SFLAGS="$SFLAGS -DHAVE_HIDDEN"
825 echo "Checking for attribute(visibility) support... Yes." | tee -a configure.log
827 echo "Checking for attribute(visibility) support... No." | tee -a configure.log
831 # show the results in the log
832 echo >> configure.log
833 echo ALL = $ALL >> configure.log
834 echo AR = $AR >> configure.log
835 echo ARFLAGS = $ARFLAGS >> configure.log
836 echo CC = $CC >> configure.log
837 echo CFLAGS = $CFLAGS >> configure.log
838 echo CPP = $CPP >> configure.log
839 echo EXE = $EXE >> configure.log
840 echo LDCONFIG = $LDCONFIG >> configure.log
841 echo LDFLAGS = $LDFLAGS >> configure.log
842 echo LDSHARED = $LDSHARED >> configure.log
843 echo LDSHAREDLIBC = $LDSHAREDLIBC >> configure.log
844 echo OBJC = $OBJC >> configure.log
845 echo PIC_OBJC = $PIC_OBJC >> configure.log
846 echo RANLIB = $RANLIB >> configure.log
847 echo SFLAGS = $SFLAGS >> configure.log
848 echo SHAREDLIB = $SHAREDLIB >> configure.log
849 echo SHAREDLIBM = $SHAREDLIBM >> configure.log
850 echo SHAREDLIBV = $SHAREDLIBV >> configure.log
851 echo STATICLIB = $STATICLIB >> configure.log
852 echo TEST = $TEST >> configure.log
853 echo VER = $VER >> configure.log
854 echo SRCDIR = $SRCDIR >> configure.log
855 echo exec_prefix = $exec_prefix >> configure.log
856 echo includedir = $includedir >> configure.log
857 echo libdir = $libdir >> configure.log
858 echo mandir = $mandir >> configure.log
859 echo prefix = $prefix >> configure.log
860 echo sharedlibdir = $sharedlibdir >> configure.log
861 echo uname = $uname >> configure.log
863 # udpate Makefile with the configure results
864 sed < ${SRCDIR}Makefile.in "
866 /^CFLAGS *=/s#=.*#=$CFLAGS#
867 /^SFLAGS *=/s#=.*#=$SFLAGS#
868 /^LDFLAGS *=/s#=.*#=$LDFLAGS#
869 /^LDSHARED *=/s#=.*#=$LDSHARED#
870 /^CPP *=/s#=.*#=$CPP#
871 /^STATICLIB *=/s#=.*#=$STATICLIB#
872 /^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
873 /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
874 /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
876 /^ARFLAGS *=/s#=.*#=$ARFLAGS#
877 /^RANLIB *=/s#=.*#=$RANLIB#
878 /^LDCONFIG *=/s#=.*#=$LDCONFIG#
879 /^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
880 /^EXE *=/s#=.*#=$EXE#
881 /^SRCDIR *=/s#=.*#=$SRCDIR#
882 /^ZINC *=/s#=.*#=$ZINC#
883 /^ZINCOUT *=/s#=.*#=$ZINCOUT#
884 /^prefix *=/s#=.*#=$prefix#
885 /^exec_prefix *=/s#=.*#=$exec_prefix#
886 /^libdir *=/s#=.*#=$libdir#
887 /^sharedlibdir *=/s#=.*#=$sharedlibdir#
888 /^includedir *=/s#=.*#=$includedir#
889 /^mandir *=/s#=.*#=$mandir#
890 /^OBJC *=/s#=.*#= $OBJC#
891 /^PIC_OBJC *=/s#=.*#= $PIC_OBJC#
892 /^all: */s#:.*#: $ALL#
893 /^test: */s#:.*#: $TEST#
896 # create zlib.pc with the configure results
897 sed < ${SRCDIR}zlib.pc.in "
899 /^CFLAGS *=/s#=.*#=$CFLAGS#
900 /^CPP *=/s#=.*#=$CPP#
901 /^LDSHARED *=/s#=.*#=$LDSHARED#
902 /^STATICLIB *=/s#=.*#=$STATICLIB#
903 /^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
904 /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
905 /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
907 /^ARFLAGS *=/s#=.*#=$ARFLAGS#
908 /^RANLIB *=/s#=.*#=$RANLIB#
909 /^EXE *=/s#=.*#=$EXE#
910 /^prefix *=/s#=.*#=$prefix#
911 /^exec_prefix *=/s#=.*#=$exec_prefix#
912 /^libdir *=/s#=.*#=$libdir#
913 /^sharedlibdir *=/s#=.*#=$sharedlibdir#
914 /^includedir *=/s#=.*#=$includedir#
915 /^mandir *=/s#=.*#=$mandir#
916 /^LDFLAGS *=/s#=.*#=$LDFLAGS#
918 s/\@VERSION\@/$VER/g;