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'}
92 OBJC='$(OBJZ) $(OBJG)'
93 PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)'
95 # leave this script, optionally in a bad way
98 if test "$*" != "0"; then
99 echo "** $0 aborting." | tee -a configure.log
101 rm -f $test.[co] $test $test$shared_ext $test.gcno ./--version
102 echo -------------------- >> configure.log
103 echo >> configure.log
104 echo >> configure.log
108 # process command line options
113 echo 'usage:' | tee -a configure.log
114 echo ' configure [--const] [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log
115 echo ' [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log
116 echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log
118 -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;;
119 -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;;
120 -l*=* | --libdir=*) libdir=`echo $1 | sed 's/.*=//'`; shift ;;
121 --sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/.*=//'`; shift ;;
122 -i*=* | --includedir=*) includedir=`echo $1 | sed 's/.*=//'`;shift ;;
123 -u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;;
124 -p* | --prefix) prefix="$2"; shift; shift ;;
125 -e* | --eprefix) exec_prefix="$2"; shift; shift ;;
126 -l* | --libdir) libdir="$2"; shift; shift ;;
127 -i* | --includedir) includedir="$2"; shift; shift ;;
128 -s* | --shared | --enable-shared) shared=1; shift ;;
129 -t | --static) shared=0; shift ;;
130 --solo) solo=1; shift ;;
131 --cover) cover=1; shift ;;
132 -z* | --zprefix) zprefix=1; shift ;;
133 -6* | --64) build64=1; shift ;;
134 -a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
135 --sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;;
136 --localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;;
137 -c* | --const) zconst=1; shift ;;
138 -w* | --warn) warn=1; shift ;;
139 -d* | --debug) debug=1; shift ;;
141 echo "unknown option: $1" | tee -a configure.log
142 echo "$0 --help for help" | tee -a configure.log
147 # temporary file name
150 # put arguments in log, also put test file in log if used in arguments
155 echo === $test.c === >> configure.log
156 cat $test.c >> configure.log
157 echo === >> configure.log;;
159 echo $* >> configure.log
162 # check for gcc vs. cc and set compile and link flags based on the system identified by uname
164 extern int getchar();
165 int hello() {return getchar();}
168 test -z "$CC" && echo Checking for ${CROSS_PREFIX}gcc... | tee -a configure.log
169 cc=${CC-${CROSS_PREFIX}gcc}
170 cflags=${CFLAGS-"-O3"}
171 # to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
176 case `$cc -v 2>&1` in
182 if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
183 echo ... using gcc >> configure.log
185 CFLAGS="${CFLAGS--O3}"
186 SFLAGS="${CFLAGS--O3} -fPIC"
187 if test "$ARCHS"; then
188 CFLAGS="${CFLAGS} ${ARCHS}"
189 LDFLAGS="${LDFLAGS} ${ARCHS}"
191 if test $build64 -eq 1; then
192 CFLAGS="${CFLAGS} -m64"
193 SFLAGS="${SFLAGS} -m64"
195 if test "$warn" -eq 1; then
196 if test "$zconst" -eq 1; then
197 CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -pedantic -DZLIB_CONST -fsanitize=address"
199 CFLAGS="${CFLAGS} -Wall -Wextra -pedantic -fsanitize=address"
202 if test $debug -eq 1; then
203 CFLAGS="${CFLAGS} -DZLIB_DEBUG"
204 SFLAGS="${SFLAGS} -DZLIB_DEBUG"
206 if test -z "$uname"; then
207 uname=`(uname -s || echo unknown) 2>/dev/null`
210 Linux* | linux* | GNU | GNU/* | solaris*)
211 LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;;
212 *BSD | *bsd* | DragonFly)
213 LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"}
214 LDCONFIG="ldconfig -m" ;;
215 CYGWIN* | Cygwin* | cygwin* | OS/2*)
219 rm -f $test.[co] $test $test$shared_ext
220 echo "Please use win32/Makefile.gcc instead." | tee -a configure.log
222 LDSHARED=${LDSHARED-"$cc -shared"}
225 QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
226 # (alain.bonnefoy@icbt.com)
227 LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
229 LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
230 case `(uname -m || echo unknown) 2>/dev/null` in
233 SHAREDLIB='libz.so' ;;
236 SHAREDLIB='libz.sl' ;;
240 SHAREDLIB=libz$shared_ext
241 SHAREDLIBV=libz.$VER$shared_ext
242 SHAREDLIBM=libz.$VER1$shared_ext
243 LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
244 if libtool -V 2>&1 | grep Apple > /dev/null; then
247 AR="/usr/bin/libtool"
250 *) LDSHARED=${LDSHARED-"$cc -shared"} ;;
253 # find system name and corresponding cc options
256 echo ... using $CC >> configure.log
257 if test -z "$uname"; then
258 uname=`(uname -sr || echo unknown) 2>/dev/null`
261 HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
262 CFLAGS=${CFLAGS-"-O"}
263 # LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
264 LDSHARED=${LDSHARED-"ld -b"}
265 case `(uname -m || echo unknown) 2>/dev/null` in
268 SHAREDLIB='libz.so' ;;
271 SHAREDLIB='libz.sl' ;;
273 IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
274 CFLAGS=${CFLAGS-"-ansi -O2"}
275 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
276 OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
277 CFLAGS=${CFLAGS-"-O -std1"}
278 LDFLAGS="${LDFLAGS} -Wl,-rpath,."
279 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;;
280 OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
281 CFLAGS=${CFLAGS-"-O -std1"}
282 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
283 QNX*) SFLAGS=${CFLAGS-"-4 -O"}
284 CFLAGS=${CFLAGS-"-4 -O"}
285 LDSHARED=${LDSHARED-"cc"}
286 RANLIB=${RANLIB-"true"}
289 SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
290 CFLAGS=${CFLAGS-"-O3"}
291 LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;;
292 SunOS\ 5* | solaris*)
293 LDSHARED=${LDSHARED-"cc -G -h libz$shared_ext.$VER1"}
294 SFLAGS=${CFLAGS-"-fast -KPIC"}
295 CFLAGS=${CFLAGS-"-fast"}
296 if test $build64 -eq 1; then
297 # old versions of SunPRO/Workshop/Studio don't support -m64,
298 # but newer ones do. Check for it.
299 flag64=`$CC -flags | egrep -- '^-m64'`
300 if test x"$flag64" != x"" ; then
301 CFLAGS="${CFLAGS} -m64"
302 SFLAGS="${SFLAGS} -m64"
304 case `(uname -m || echo unknown) 2>/dev/null` in
306 SFLAGS="$SFLAGS -xarch=amd64"
307 CFLAGS="$CFLAGS -xarch=amd64" ;;
309 SFLAGS="$SFLAGS -xarch=v9"
310 CFLAGS="$CFLAGS -xarch=v9" ;;
314 if test -n "$ZINC"; then
315 ZINC='-I- -I. -I$(SRCDIR)'
318 SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
319 CFLAGS=${CFLAGS-"-O2"}
320 LDSHARED=${LDSHARED-"ld"} ;;
321 SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
322 CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"}
323 LDSHARED=${LDSHARED-"cc -xarch=v9b"} ;;
324 UNIX_System_V\ 4.2.0)
325 SFLAGS=${CFLAGS-"-KPIC -O"}
326 CFLAGS=${CFLAGS-"-O"}
327 LDSHARED=${LDSHARED-"cc -G"} ;;
329 SFLAGS=${CFLAGS-"-Kconform_pic -O"}
330 CFLAGS=${CFLAGS-"-O"}
331 LDSHARED=${LDSHARED-"cc -G"} ;;
333 SFLAGS=${CFLAGS-"-KPIC -O"}
334 CFLAGS=${CFLAGS-"-O"}
335 LDSHARED=${LDSHARED-"cc -G"} ;;
336 AIX*) # Courtesy of dbakker@arrayasolutions.com
337 SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
338 CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
339 LDSHARED=${LDSHARED-"xlc -G"} ;;
340 # send working options for other systems to zlib@gzip.org
341 *) SFLAGS=${CFLAGS-"-O"}
342 CFLAGS=${CFLAGS-"-O"}
343 LDSHARED=${LDSHARED-"cc -shared"} ;;
347 # destination names for shared library if not defined above
348 SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
349 SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
350 SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
352 echo >> configure.log
354 # define functions for testing compiler and library characteristics and logging the results
359 if ($CC -c $CFLAGS $test.c) 2>/dev/null; then
363 test "`( $* ) 2>&1 | tee -a configure.log`" = ""
365 echo - using any output from compiler to indicate an error >> configure.log
372 if test "$got" != ""; then
373 printf "%s\n" "$got" >> configure.log
375 if test $ret -ne 0; then
376 echo "(exit code "$ret")" >> configure.log
387 if test "$got" != ""; then
388 printf "%s\n" "$got" >> configure.log
390 if test $ret -ne 0; then
391 echo "(exit code "$ret")" >> configure.log
398 int foo() { return 0; }
400 echo "Checking for obsessive-compulsive compiler options..." >> configure.log
401 if try $CC -c $CFLAGS $test.c; then
404 echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log
408 echo >> configure.log
410 # see if shared library build supported
412 extern int getchar();
413 int hello() {return getchar();}
415 if test $shared -eq 1; then
416 echo Checking for shared library support... | tee -a configure.log
417 # we must test in two steps (cc then ld), required at least on SunOS 4.x
418 if try $CC -w -c $SFLAGS $test.c &&
419 try $LDSHARED $SFLAGS -o $test$shared_ext $test.o; then
420 echo Building shared library $SHAREDLIBV with $CC. | tee -a configure.log
421 elif test -z "$old_cc" -a -z "$old_cflags"; then
422 echo No shared library support. | tee -a configure.log
425 echo 'No shared library support; try without defining CC and CFLAGS' | tee -a configure.log
429 if test $shared -eq 0; then
432 TEST="all teststatic"
436 echo Building static library $STATICLIB version $VER with $CC. | tee -a configure.log
439 TEST="all teststatic testshared"
442 # check for underscores in external names for use by assembler code
446 echo >> configure.log
447 show "$NM $test.o | grep _hello"
448 if test "`$NM $test.o | grep _hello | tee -a configure.log`" = ""; then
449 CPP="$CPP -DNO_UNDERLINE"
450 echo Checking for underline in external names... No. | tee -a configure.log
452 echo Checking for underline in external names... Yes. | tee -a configure.log
456 echo >> configure.log
464 if try $CC -c $CFLAGS $test.c; then
465 echo "Checking for size_t... Yes." | tee -a configure.log
467 echo "Checking for size_t... No." | tee -a configure.log
468 # find a size_t integer type
469 # check for long long
473 if try $CC -c $CFLAGS $test.c; then
474 echo "Checking for long long... Yes." | tee -a configure.log
478 if (sizeof(void *) <= sizeof(int)) puts("int");
479 else if (sizeof(void *) <= sizeof(long)) puts("long");
480 else puts("z_longlong");
485 echo "Checking for long long... No." | tee -a configure.log
489 if (sizeof(void *) <= sizeof(int)) puts("int");
495 if try $CC $CFLAGS -o $test $test.c; then
497 echo "Checking for a pointer-size integer type..." $sizet"." | tee -a configure.log
498 CFLAGS="${CFLAGS} -DNO_SIZE_T=${sizet}"
499 SFLAGS="${SFLAGS} -DNO_SIZE_T=${sizet}"
501 echo "Checking for a pointer-size integer type... not found." | tee -a configure.log
505 echo >> configure.log
507 # check for large file support, and if none, check for fseeko()
509 #include <sys/types.h>
512 if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then
513 CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1"
514 SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1"
516 TEST="${TEST} test64"
517 echo "Checking for off64_t... Yes." | tee -a configure.log
518 echo "Checking for fseeko... Yes." | tee -a configure.log
520 echo "Checking for off64_t... No." | tee -a configure.log
521 echo >> configure.log
529 if try $CC $CFLAGS -o $test $test.c; then
530 echo "Checking for fseeko... Yes." | tee -a configure.log
532 CFLAGS="${CFLAGS} -DNO_FSEEKO"
533 SFLAGS="${SFLAGS} -DNO_FSEEKO"
534 echo "Checking for fseeko... No." | tee -a configure.log
538 echo >> configure.log
540 # check for strerror() for use by gz* functions
544 int main() { return strlen(strerror(errno)); }
546 if try $CC $CFLAGS -o $test $test.c; then
547 echo "Checking for strerror... Yes." | tee -a configure.log
549 CFLAGS="${CFLAGS} -DNO_STRERROR"
550 SFLAGS="${SFLAGS} -DNO_STRERROR"
551 echo "Checking for strerror... No." | tee -a configure.log
554 # copy clean zconf.h for subsequent edits
555 cp -p ${SRCDIR}zconf.h.in zconf.h
557 echo >> configure.log
559 # check for unistd.h and save result in zconf.h
562 int main() { return 0; }
564 if try $CC -c $CFLAGS $test.c; then
565 sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
566 mv zconf.temp.h zconf.h
567 echo "Checking for unistd.h... Yes." | tee -a configure.log
569 echo "Checking for unistd.h... No." | tee -a configure.log
572 echo >> configure.log
574 # check for stdarg.h and save result in zconf.h
577 int main() { return 0; }
579 if try $CC -c $CFLAGS $test.c; then
580 sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
581 mv zconf.temp.h zconf.h
582 echo "Checking for stdarg.h... Yes." | tee -a configure.log
584 echo "Checking for stdarg.h... No." | tee -a configure.log
587 # if the z_ prefix was requested, save that in zconf.h
588 if test $zprefix -eq 1; then
589 sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h
590 mv zconf.temp.h zconf.h
591 echo >> configure.log
592 echo "Using z_ prefix on all symbols." | tee -a configure.log
595 # if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists
596 if test $solo -eq 1; then
597 sed '/#define ZCONF_H/a\
600 ' < zconf.h > zconf.temp.h
601 mv zconf.temp.h zconf.h
603 PIC_OBJC='$(PIC_OBJZ)'
606 # if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
607 if test $cover -eq 1; then
608 CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
609 if test -n "$GCC_CLASSIC"; then
614 echo >> configure.log
616 # conduct a series of tests to resolve eight possible cases of using "vs" or "s" printf functions
617 # (using stdarg or not), with or without "n" (proving size of buffer), and with or without a
618 # return value. The most secure result is vsnprintf() with a return value. snprintf() with a
619 # return value is secure as well, but then gzprintf() will be limited to 20 arguments.
632 if try $CC -c $CFLAGS $test.c; then
633 echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." | tee -a configure.log
635 echo >> configure.log
639 int mytest(const char *fmt, ...)
644 vsnprintf(buf, sizeof(buf), fmt, ap);
650 return (mytest("Hello%d\n", 1));
653 if try $CC $CFLAGS -o $test $test.c; then
654 echo "Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log
656 echo >> configure.log
660 int mytest(const char *fmt, ...)
666 n = vsnprintf(buf, sizeof(buf), fmt, ap);
672 return (mytest("Hello%d\n", 1));
676 if try $CC -c $CFLAGS $test.c; then
677 echo "Checking for return value of vsnprintf()... Yes." | tee -a configure.log
679 CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
680 SFLAGS="$SFLAGS -DHAS_vsnprintf_void"
681 echo "Checking for return value of vsnprintf()... No." | tee -a configure.log
682 echo " WARNING: apparently vsnprintf() does not return a value. zlib" | tee -a configure.log
683 echo " can build but will be open to possible string-format security" | tee -a configure.log
684 echo " vulnerabilities." | tee -a configure.log
687 CFLAGS="$CFLAGS -DNO_vsnprintf"
688 SFLAGS="$SFLAGS -DNO_vsnprintf"
689 echo "Checking for vsnprintf() in stdio.h... No." | tee -a configure.log
690 echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log
691 echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
692 echo " vulnerabilities." | tee -a configure.log
694 echo >> configure.log
698 int mytest(const char *fmt, ...)
704 n = vsprintf(buf, fmt, ap);
710 return (mytest("Hello%d\n", 1));
714 if try $CC -c $CFLAGS $test.c; then
715 echo "Checking for return value of vsprintf()... Yes." | tee -a configure.log
717 CFLAGS="$CFLAGS -DHAS_vsprintf_void"
718 SFLAGS="$SFLAGS -DHAS_vsprintf_void"
719 echo "Checking for return value of vsprintf()... No." | tee -a configure.log
720 echo " WARNING: apparently vsprintf() does not return a value. zlib" | tee -a configure.log
721 echo " can build but will be open to possible string-format security" | tee -a configure.log
722 echo " vulnerabilities." | tee -a configure.log
726 echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." | tee -a configure.log
728 echo >> configure.log
734 snprintf(buf, sizeof(buf), "%s", "foo");
743 if try $CC $CFLAGS -o $test $test.c; then
744 echo "Checking for snprintf() in stdio.h... Yes." | tee -a configure.log
746 echo >> configure.log
752 return snprintf(buf, sizeof(buf), "%s", "foo");
760 if try $CC -c $CFLAGS $test.c; then
761 echo "Checking for return value of snprintf()... Yes." | tee -a configure.log
763 CFLAGS="$CFLAGS -DHAS_snprintf_void"
764 SFLAGS="$SFLAGS -DHAS_snprintf_void"
765 echo "Checking for return value of snprintf()... No." | tee -a configure.log
766 echo " WARNING: apparently snprintf() does not return a value. zlib" | tee -a configure.log
767 echo " can build but will be open to possible string-format security" | tee -a configure.log
768 echo " vulnerabilities." | tee -a configure.log
771 CFLAGS="$CFLAGS -DNO_snprintf"
772 SFLAGS="$SFLAGS -DNO_snprintf"
773 echo "Checking for snprintf() in stdio.h... No." | tee -a configure.log
774 echo " WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log
775 echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
776 echo " vulnerabilities." | tee -a configure.log
778 echo >> configure.log
784 return sprintf(buf, "%s", "foo");
792 if try $CC -c $CFLAGS $test.c; then
793 echo "Checking for return value of sprintf()... Yes." | tee -a configure.log
795 CFLAGS="$CFLAGS -DHAS_sprintf_void"
796 SFLAGS="$SFLAGS -DHAS_sprintf_void"
797 echo "Checking for return value of sprintf()... No." | tee -a configure.log
798 echo " WARNING: apparently sprintf() does not return a value. zlib" | tee -a configure.log
799 echo " can build but will be open to possible string-format security" | tee -a configure.log
800 echo " vulnerabilities." | tee -a configure.log
805 # see if we can hide zlib internal symbols that are linked between separate source files
806 if test "$gcc" -eq 1; then
807 echo >> configure.log
809 #define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
810 int ZLIB_INTERNAL foo;
816 if tryboth $CC -c $CFLAGS $test.c; then
817 CFLAGS="$CFLAGS -DHAVE_HIDDEN"
818 SFLAGS="$SFLAGS -DHAVE_HIDDEN"
819 echo "Checking for attribute(visibility) support... Yes." | tee -a configure.log
821 echo "Checking for attribute(visibility) support... No." | tee -a configure.log
825 # show the results in the log
826 echo >> configure.log
827 echo ALL = $ALL >> configure.log
828 echo AR = $AR >> configure.log
829 echo ARFLAGS = $ARFLAGS >> configure.log
830 echo CC = $CC >> configure.log
831 echo CFLAGS = $CFLAGS >> configure.log
832 echo CPP = $CPP >> configure.log
833 echo EXE = $EXE >> configure.log
834 echo LDCONFIG = $LDCONFIG >> configure.log
835 echo LDFLAGS = $LDFLAGS >> configure.log
836 echo LDSHARED = $LDSHARED >> configure.log
837 echo LDSHAREDLIBC = $LDSHAREDLIBC >> configure.log
838 echo OBJC = $OBJC >> configure.log
839 echo PIC_OBJC = $PIC_OBJC >> configure.log
840 echo RANLIB = $RANLIB >> configure.log
841 echo SFLAGS = $SFLAGS >> configure.log
842 echo SHAREDLIB = $SHAREDLIB >> configure.log
843 echo SHAREDLIBM = $SHAREDLIBM >> configure.log
844 echo SHAREDLIBV = $SHAREDLIBV >> configure.log
845 echo STATICLIB = $STATICLIB >> configure.log
846 echo TEST = $TEST >> configure.log
847 echo VER = $VER >> configure.log
848 echo SRCDIR = $SRCDIR >> configure.log
849 echo exec_prefix = $exec_prefix >> configure.log
850 echo includedir = $includedir >> configure.log
851 echo libdir = $libdir >> configure.log
852 echo mandir = $mandir >> configure.log
853 echo prefix = $prefix >> configure.log
854 echo sharedlibdir = $sharedlibdir >> configure.log
855 echo uname = $uname >> configure.log
857 # udpate Makefile with the configure results
858 sed < ${SRCDIR}Makefile.in "
860 /^CFLAGS *=/s#=.*#=$CFLAGS#
861 /^SFLAGS *=/s#=.*#=$SFLAGS#
862 /^LDFLAGS *=/s#=.*#=$LDFLAGS#
863 /^LDSHARED *=/s#=.*#=$LDSHARED#
864 /^CPP *=/s#=.*#=$CPP#
865 /^STATICLIB *=/s#=.*#=$STATICLIB#
866 /^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
867 /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
868 /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
870 /^ARFLAGS *=/s#=.*#=$ARFLAGS#
871 /^RANLIB *=/s#=.*#=$RANLIB#
872 /^LDCONFIG *=/s#=.*#=$LDCONFIG#
873 /^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
874 /^EXE *=/s#=.*#=$EXE#
875 /^SRCDIR *=/s#=.*#=$SRCDIR#
876 /^ZINC *=/s#=.*#=$ZINC#
877 /^ZINCOUT *=/s#=.*#=$ZINCOUT#
878 /^prefix *=/s#=.*#=$prefix#
879 /^exec_prefix *=/s#=.*#=$exec_prefix#
880 /^libdir *=/s#=.*#=$libdir#
881 /^sharedlibdir *=/s#=.*#=$sharedlibdir#
882 /^includedir *=/s#=.*#=$includedir#
883 /^mandir *=/s#=.*#=$mandir#
884 /^OBJC *=/s#=.*#= $OBJC#
885 /^PIC_OBJC *=/s#=.*#= $PIC_OBJC#
886 /^all: */s#:.*#: $ALL#
887 /^test: */s#:.*#: $TEST#
890 # create zlib.pc with the configure results
891 sed < ${SRCDIR}zlib.pc.in "
893 /^CFLAGS *=/s#=.*#=$CFLAGS#
894 /^CPP *=/s#=.*#=$CPP#
895 /^LDSHARED *=/s#=.*#=$LDSHARED#
896 /^STATICLIB *=/s#=.*#=$STATICLIB#
897 /^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
898 /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
899 /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
901 /^ARFLAGS *=/s#=.*#=$ARFLAGS#
902 /^RANLIB *=/s#=.*#=$RANLIB#
903 /^EXE *=/s#=.*#=$EXE#
904 /^prefix *=/s#=.*#=$prefix#
905 /^exec_prefix *=/s#=.*#=$exec_prefix#
906 /^libdir *=/s#=.*#=$libdir#
907 /^sharedlibdir *=/s#=.*#=$sharedlibdir#
908 /^includedir *=/s#=.*#=$includedir#
909 /^mandir *=/s#=.*#=$mandir#
910 /^LDFLAGS *=/s#=.*#=$LDFLAGS#
912 s/\@VERSION\@/$VER/g;