aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/zlib/configure
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/zlib/configure')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/zlib/configure818
1 files changed, 818 insertions, 0 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/zlib/configure b/libraries/irrlicht-1.8/source/Irrlicht/zlib/configure
new file mode 100644
index 0000000..36c7d8e
--- /dev/null
+++ b/libraries/irrlicht-1.8/source/Irrlicht/zlib/configure
@@ -0,0 +1,818 @@
1#!/bin/sh
2# configure script for zlib.
3#
4# Normally configure builds both a static and a shared library.
5# If you want to build just a static library, use: ./configure --static
6#
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)
11
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
14# an error.
15
16# start off configure.log
17echo -------------------- >> configure.log
18echo $0 $* >> configure.log
19date >> configure.log
20
21# set command prefix for cross-compilation
22if [ -n "${CHOST}" ]; then
23 uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`"
24 CROSS_PREFIX="${CHOST}-"
25fi
26
27# destination name for static library
28STATICLIB=libz.a
29
30# extract zlib version numbers from zlib.h
31VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
32VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < zlib.h`
33VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h`
34VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h`
35
36# establish commands for library building
37if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then
38 AR=${AR-"${CROSS_PREFIX}ar"}
39 test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
40else
41 AR=${AR-"ar"}
42 test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
43fi
44ARFLAGS=${ARFLAGS-"rc"}
45if "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null || test $? -lt 126; then
46 RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"}
47 test -n "${CROSS_PREFIX}" && echo Using ${RANLIB} | tee -a configure.log
48else
49 RANLIB=${RANLIB-"ranlib"}
50fi
51if "${CROSS_PREFIX}nm" --version >/dev/null 2>/dev/null || test $? -lt 126; then
52 NM=${NM-"${CROSS_PREFIX}nm"}
53 test -n "${CROSS_PREFIX}" && echo Using ${NM} | tee -a configure.log
54else
55 NM=${NM-"nm"}
56fi
57
58# set defaults before processing command line options
59LDCONFIG=${LDCONFIG-"ldconfig"}
60LDSHAREDLIBC="${LDSHAREDLIBC--lc}"
61ARCHS=
62prefix=${prefix-/usr/local}
63exec_prefix=${exec_prefix-'${prefix}'}
64libdir=${libdir-'${exec_prefix}/lib'}
65sharedlibdir=${sharedlibdir-'${libdir}'}
66includedir=${includedir-'${prefix}/include'}
67mandir=${mandir-'${prefix}/share/man'}
68shared_ext='.so'
69shared=1
70solo=0
71cover=0
72zprefix=0
73build64=0
74gcc=0
75old_cc="$CC"
76old_cflags="$CFLAGS"
77OBJC='$(OBJZ) $(OBJG)'
78PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)'
79
80# process command line options
81while test $# -ge 1
82do
83case "$1" in
84 -h* | --help)
85 echo 'usage:' | tee -a configure.log
86 echo ' configure [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log
87 echo ' [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log
88 echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log
89 exit 0 ;;
90 -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;;
91 -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;;
92 -l*=* | --libdir=*) libdir=`echo $1 | sed 's/.*=//'`; shift ;;
93 --sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/.*=//'`; shift ;;
94 -i*=* | --includedir=*) includedir=`echo $1 | sed 's/.*=//'`;shift ;;
95 -u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;;
96 -p* | --prefix) prefix="$2"; shift; shift ;;
97 -e* | --eprefix) exec_prefix="$2"; shift; shift ;;
98 -l* | --libdir) libdir="$2"; shift; shift ;;
99 -i* | --includedir) includedir="$2"; shift; shift ;;
100 -s* | --shared | --enable-shared) shared=1; shift ;;
101 -t | --static) shared=0; shift ;;
102 --solo) solo=1; shift ;;
103 --cover) cover=1; shift ;;
104 -z* | --zprefix) zprefix=1; shift ;;
105 -6* | --64) build64=1; shift ;;
106 -a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
107 --sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;;
108 --localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;;
109 *) echo "unknown option: $1"; echo "$0 --help for help" | tee -a configure.log; exit 1 ;;
110 esac
111done
112
113# define functions for testing compiler and library characteristics and logging the results
114test=ztest$$
115
116show()
117{
118 case "$*" in
119 *$test.c*)
120 echo === $test.c === >> configure.log
121 cat $test.c >> configure.log
122 echo === >> configure.log;;
123 esac
124 echo $* >> configure.log
125}
126
127cat > $test.c <<EOF
128#error error
129EOF
130if ($CC -c $CFLAGS $test.c) 2>/dev/null; then
131 try()
132 {
133 show $*
134 test "`( $* ) 2>&1 | tee -a configure.log`" = ""
135 }
136 echo - using any output from compiler to indicate an error >> configure.log
137else
138 try()
139 {
140 show $*
141 ( $* ) >> configure.log 2>&1
142 ret=$?
143 if test $ret -ne 0; then
144 echo "(exit code "$ret")" >> configure.log
145 fi
146 return $ret
147 }
148fi
149
150tryboth()
151{
152 show $*
153 got=`( $* ) 2>&1`
154 ret=$?
155 printf %s "$got" >> configure.log
156 if test $ret -ne 0; then
157 return $ret
158 fi
159 test "$got" = ""
160}
161
162echo >> configure.log
163
164# check for gcc vs. cc and set compile and link flags based on the system identified by uname
165cat > $test.c <<EOF
166extern int getchar();
167int hello() {return getchar();}
168EOF
169
170test -z "$CC" && echo Checking for ${CROSS_PREFIX}gcc... | tee -a configure.log
171cc=${CC-${CROSS_PREFIX}gcc}
172cflags=${CFLAGS-"-O3"}
173# to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
174case "$cc" in
175 *gcc*) gcc=1 ;;
176 *clang*) gcc=1 ;;
177esac
178case `$cc -v 2>&1` in
179 *gcc*) gcc=1 ;;
180esac
181
182show $cc -c $cflags $test.c
183if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) >> configure.log 2>&1; then
184 echo ... using gcc >> configure.log
185 CC="$cc"
186 CFLAGS="${CFLAGS--O3} ${ARCHS}"
187 SFLAGS="${CFLAGS--O3} -fPIC"
188 LDFLAGS="${LDFLAGS} ${ARCHS}"
189 if test $build64 -eq 1; then
190 CFLAGS="${CFLAGS} -m64"
191 SFLAGS="${SFLAGS} -m64"
192 fi
193 if test "${ZLIBGCCWARN}" = "YES"; then
194 CFLAGS="${CFLAGS} -Wall -Wextra -pedantic"
195 fi
196 if test -z "$uname"; then
197 uname=`(uname -s || echo unknown) 2>/dev/null`
198 fi
199 case "$uname" in
200 Linux* | linux* | GNU | GNU/* | solaris*)
201 LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"} ;;
202 *BSD | *bsd* | DragonFly)
203 LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"}
204 LDCONFIG="ldconfig -m" ;;
205 CYGWIN* | Cygwin* | cygwin* | OS/2*)
206 EXE='.exe' ;;
207 MINGW* | mingw*)
208# temporary bypass
209 rm -f $test.[co] $test $test$shared_ext
210 echo "Please use win32/Makefile.gcc instead." | tee -a configure.log
211 exit 1
212 LDSHARED=${LDSHARED-"$cc -shared"}
213 LDSHAREDLIBC=""
214 EXE='.exe' ;;
215 QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
216 # (alain.bonnefoy@icbt.com)
217 LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
218 HP-UX*)
219 LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
220 case `(uname -m || echo unknown) 2>/dev/null` in
221 ia64)
222 shared_ext='.so'
223 SHAREDLIB='libz.so' ;;
224 *)
225 shared_ext='.sl'
226 SHAREDLIB='libz.sl' ;;
227 esac ;;
228 Darwin* | darwin*)
229 shared_ext='.dylib'
230 SHAREDLIB=libz$shared_ext
231 SHAREDLIBV=libz.$VER$shared_ext
232 SHAREDLIBM=libz.$VER1$shared_ext
233 LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
234 AR="/usr/bin/libtool"
235 ARFLAGS="-o" ;;
236 *) LDSHARED=${LDSHARED-"$cc -shared"} ;;
237 esac
238else
239 # find system name and corresponding cc options
240 CC=${CC-cc}
241 gcc=0
242 echo ... using $CC >> configure.log
243 if test -z "$uname"; then
244 uname=`(uname -sr || echo unknown) 2>/dev/null`
245 fi
246 case "$uname" in
247 HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
248 CFLAGS=${CFLAGS-"-O"}
249# LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
250 LDSHARED=${LDSHARED-"ld -b"}
251 case `(uname -m || echo unknown) 2>/dev/null` in
252 ia64)
253 shared_ext='.so'
254 SHAREDLIB='libz.so' ;;
255 *)
256 shared_ext='.sl'
257 SHAREDLIB='libz.sl' ;;
258 esac ;;
259 IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
260 CFLAGS=${CFLAGS-"-ansi -O2"}
261 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
262 OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
263 CFLAGS=${CFLAGS-"-O -std1"}
264 LDFLAGS="${LDFLAGS} -Wl,-rpath,."
265 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;;
266 OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
267 CFLAGS=${CFLAGS-"-O -std1"}
268 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
269 QNX*) SFLAGS=${CFLAGS-"-4 -O"}
270 CFLAGS=${CFLAGS-"-4 -O"}
271 LDSHARED=${LDSHARED-"cc"}
272 RANLIB=${RANLIB-"true"}
273 AR="cc"
274 ARFLAGS="-A" ;;
275 SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
276 CFLAGS=${CFLAGS-"-O3"}
277 LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;;
278 SunOS\ 5* | solaris*)
279 LDSHARED=${LDSHARED-"cc -G -h libz$shared_ext.$VER1"}
280 SFLAGS=${CFLAGS-"-fast -KPIC"}
281 CFLAGS=${CFLAGS-"-fast"}
282 if test $build64 -eq 1; then
283 # old versions of SunPRO/Workshop/Studio don't support -m64,
284 # but newer ones do. Check for it.
285 flag64=`$CC -flags | egrep -- '^-m64'`
286 if test x"$flag64" != x"" ; then
287 CFLAGS="${CFLAGS} -m64"
288 SFLAGS="${SFLAGS} -m64"
289 else
290 case `(uname -m || echo unknown) 2>/dev/null` in
291 i86*)
292 SFLAGS="$SFLAGS -xarch=amd64"
293 CFLAGS="$CFLAGS -xarch=amd64" ;;
294 *)
295 SFLAGS="$SFLAGS -xarch=v9"
296 CFLAGS="$CFLAGS -xarch=v9" ;;
297 esac
298 fi
299 fi
300 ;;
301 SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
302 CFLAGS=${CFLAGS-"-O2"}
303 LDSHARED=${LDSHARED-"ld"} ;;
304 SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
305 CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"}
306 LDSHARED=${LDSHARED-"cc -xarch=v9b"} ;;
307 UNIX_System_V\ 4.2.0)
308 SFLAGS=${CFLAGS-"-KPIC -O"}
309 CFLAGS=${CFLAGS-"-O"}
310 LDSHARED=${LDSHARED-"cc -G"} ;;
311 UNIX_SV\ 4.2MP)
312 SFLAGS=${CFLAGS-"-Kconform_pic -O"}
313 CFLAGS=${CFLAGS-"-O"}
314 LDSHARED=${LDSHARED-"cc -G"} ;;
315 OpenUNIX\ 5)
316 SFLAGS=${CFLAGS-"-KPIC -O"}
317 CFLAGS=${CFLAGS-"-O"}
318 LDSHARED=${LDSHARED-"cc -G"} ;;
319 AIX*) # Courtesy of dbakker@arrayasolutions.com
320 SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
321 CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
322 LDSHARED=${LDSHARED-"xlc -G"} ;;
323 # send working options for other systems to zlib@gzip.org
324 *) SFLAGS=${CFLAGS-"-O"}
325 CFLAGS=${CFLAGS-"-O"}
326 LDSHARED=${LDSHARED-"cc -shared"} ;;
327 esac
328fi
329
330# destination names for shared library if not defined above
331SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
332SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
333SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
334
335echo >> configure.log
336
337# see if shared library build supported
338if test $shared -eq 1; then
339 echo Checking for shared library support... | tee -a configure.log
340 # we must test in two steps (cc then ld), required at least on SunOS 4.x
341 if try $CC -w -c $SFLAGS $test.c &&
342 try $LDSHARED $SFLAGS -o $test$shared_ext $test.o; then
343 echo Building shared library $SHAREDLIBV with $CC. | tee -a configure.log
344 elif test -z "$old_cc" -a -z "$old_cflags"; then
345 echo No shared library support. | tee -a configure.log
346 shared=0;
347 else
348 echo 'No shared library support; try without defining CC and CFLAGS' | tee -a configure.log
349 shared=0;
350 fi
351fi
352if test $shared -eq 0; then
353 LDSHARED="$CC"
354 ALL="static"
355 TEST="all teststatic"
356 SHAREDLIB=""
357 SHAREDLIBV=""
358 SHAREDLIBM=""
359 echo Building static library $STATICLIB version $VER with $CC. | tee -a configure.log
360else
361 ALL="static shared"
362 TEST="all teststatic testshared"
363fi
364
365echo >> configure.log
366
367# check for underscores in external names for use by assembler code
368CPP=${CPP-"$CC -E"}
369case $CFLAGS in
370 *ASMV*)
371 echo >> configure.log
372 show "$NM $test.o | grep _hello"
373 if test "`$NM $test.o | grep _hello | tee -a configure.log`" = ""; then
374 CPP="$CPP -DNO_UNDERLINE"
375 echo Checking for underline in external names... No. | tee -a configure.log
376 else
377 echo Checking for underline in external names... Yes. | tee -a configure.log
378 fi ;;
379esac
380
381echo >> configure.log
382
383# check for large file support, and if none, check for fseeko()
384cat > $test.c <<EOF
385#include <sys/types.h>
386off64_t dummy = 0;
387EOF
388if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then
389 CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1"
390 SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1"
391 ALL="${ALL} all64"
392 TEST="${TEST} test64"
393 echo "Checking for off64_t... Yes." | tee -a configure.log
394 echo "Checking for fseeko... Yes." | tee -a configure.log
395else
396 echo "Checking for off64_t... No." | tee -a configure.log
397 echo >> configure.log
398 cat > $test.c <<EOF
399#include <stdio.h>
400int main(void) {
401 fseeko(NULL, 0, 0);
402 return 0;
403}
404EOF
405 if try $CC $CFLAGS -o $test $test.c; then
406 echo "Checking for fseeko... Yes." | tee -a configure.log
407 else
408 CFLAGS="${CFLAGS} -DNO_FSEEKO"
409 SFLAGS="${SFLAGS} -DNO_FSEEKO"
410 echo "Checking for fseeko... No." | tee -a configure.log
411 fi
412fi
413
414echo >> configure.log
415
416# check for strerror() for use by gz* functions
417cat > $test.c <<EOF
418#include <string.h>
419#include <errno.h>
420int main() { return strlen(strerror(errno)); }
421EOF
422if try $CC $CFLAGS -o $test $test.c; then
423 echo "Checking for strerror... Yes." | tee -a configure.log
424else
425 CFLAGS="${CFLAGS} -DNO_STRERROR"
426 SFLAGS="${SFLAGS} -DNO_STRERROR"
427 echo "Checking for strerror... No." | tee -a configure.log
428fi
429
430# copy clean zconf.h for subsequent edits
431cp -p zconf.h.in zconf.h
432
433echo >> configure.log
434
435# check for unistd.h and save result in zconf.h
436cat > $test.c <<EOF
437#include <unistd.h>
438int main() { return 0; }
439EOF
440if try $CC -c $CFLAGS $test.c; then
441 sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
442 mv zconf.temp.h zconf.h
443 echo "Checking for unistd.h... Yes." | tee -a configure.log
444else
445 echo "Checking for unistd.h... No." | tee -a configure.log
446fi
447
448echo >> configure.log
449
450# check for stdarg.h and save result in zconf.h
451cat > $test.c <<EOF
452#include <stdarg.h>
453int main() { return 0; }
454EOF
455if try $CC -c $CFLAGS $test.c; then
456 sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
457 mv zconf.temp.h zconf.h
458 echo "Checking for stdarg.h... Yes." | tee -a configure.log
459else
460 echo "Checking for stdarg.h... No." | tee -a configure.log
461fi
462
463# if the z_ prefix was requested, save that in zconf.h
464if test $zprefix -eq 1; then
465 sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h
466 mv zconf.temp.h zconf.h
467 echo >> configure.log
468 echo "Using z_ prefix on all symbols." | tee -a configure.log
469fi
470
471# if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists
472if test $solo -eq 1; then
473 sed '/#define ZCONF_H/a\
474#define Z_SOLO
475
476' < zconf.h > zconf.temp.h
477 mv zconf.temp.h zconf.h
478OBJC='$(OBJZ)'
479PIC_OBJC='$(PIC_OBJZ)'
480fi
481
482# if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
483if test $cover -eq 1; then
484 CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
485 if test -n "$GCC_CLASSIC"; then
486 CC=$GCC_CLASSIC
487 fi
488fi
489
490echo >> configure.log
491
492# conduct a series of tests to resolve eight possible cases of using "vs" or "s" printf functions
493# (using stdarg or not), with or without "n" (proving size of buffer), and with or without a
494# return value. The most secure result is vsnprintf() with a return value. snprintf() with a
495# return value is secure as well, but then gzprintf() will be limited to 20 arguments.
496cat > $test.c <<EOF
497#include <stdio.h>
498#include <stdarg.h>
499#include "zconf.h"
500int main()
501{
502#ifndef STDC
503 choke me
504#endif
505 return 0;
506}
507EOF
508if try $CC -c $CFLAGS $test.c; then
509 echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." | tee -a configure.log
510
511 echo >> configure.log
512 cat > $test.c <<EOF
513#include <stdio.h>
514#include <stdarg.h>
515int mytest(const char *fmt, ...)
516{
517 char buf[20];
518 va_list ap;
519 va_start(ap, fmt);
520 vsnprintf(buf, sizeof(buf), fmt, ap);
521 va_end(ap);
522 return 0;
523}
524int main()
525{
526 return (mytest("Hello%d\n", 1));
527}
528EOF
529 if try $CC $CFLAGS -o $test $test.c; then
530 echo "Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log
531
532 echo >> configure.log
533 cat >$test.c <<EOF
534#include <stdio.h>
535#include <stdarg.h>
536int mytest(const char *fmt, ...)
537{
538 int n;
539 char buf[20];
540 va_list ap;
541 va_start(ap, fmt);
542 n = vsnprintf(buf, sizeof(buf), fmt, ap);
543 va_end(ap);
544 return n;
545}
546int main()
547{
548 return (mytest("Hello%d\n", 1));
549}
550EOF
551
552 if try $CC -c $CFLAGS $test.c; then
553 echo "Checking for return value of vsnprintf()... Yes." | tee -a configure.log
554 else
555 CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
556 SFLAGS="$SFLAGS -DHAS_vsnprintf_void"
557 echo "Checking for return value of vsnprintf()... No." | tee -a configure.log
558 echo " WARNING: apparently vsnprintf() does not return a value. zlib" | tee -a configure.log
559 echo " can build but will be open to possible string-format security" | tee -a configure.log
560 echo " vulnerabilities." | tee -a configure.log
561 fi
562 else
563 CFLAGS="$CFLAGS -DNO_vsnprintf"
564 SFLAGS="$SFLAGS -DNO_vsnprintf"
565 echo "Checking for vsnprintf() in stdio.h... No." | tee -a configure.log
566 echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log
567 echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
568 echo " vulnerabilities." | tee -a configure.log
569
570 echo >> configure.log
571 cat >$test.c <<EOF
572#include <stdio.h>
573#include <stdarg.h>
574int mytest(const char *fmt, ...)
575{
576 int n;
577 char buf[20];
578 va_list ap;
579 va_start(ap, fmt);
580 n = vsprintf(buf, fmt, ap);
581 va_end(ap);
582 return n;
583}
584int main()
585{
586 return (mytest("Hello%d\n", 1));
587}
588EOF
589
590 if try $CC -c $CFLAGS $test.c; then
591 echo "Checking for return value of vsprintf()... Yes." | tee -a configure.log
592 else
593 CFLAGS="$CFLAGS -DHAS_vsprintf_void"
594 SFLAGS="$SFLAGS -DHAS_vsprintf_void"
595 echo "Checking for return value of vsprintf()... No." | tee -a configure.log
596 echo " WARNING: apparently vsprintf() does not return a value. zlib" | tee -a configure.log
597 echo " can build but will be open to possible string-format security" | tee -a configure.log
598 echo " vulnerabilities." | tee -a configure.log
599 fi
600 fi
601else
602 echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." | tee -a configure.log
603
604 echo >> configure.log
605 cat >$test.c <<EOF
606#include <stdio.h>
607int mytest()
608{
609 char buf[20];
610 snprintf(buf, sizeof(buf), "%s", "foo");
611 return 0;
612}
613int main()
614{
615 return (mytest());
616}
617EOF
618
619 if try $CC $CFLAGS -o $test $test.c; then
620 echo "Checking for snprintf() in stdio.h... Yes." | tee -a configure.log
621
622 echo >> configure.log
623 cat >$test.c <<EOF
624#include <stdio.h>
625int mytest()
626{
627 char buf[20];
628 return snprintf(buf, sizeof(buf), "%s", "foo");
629}
630int main()
631{
632 return (mytest());
633}
634EOF
635
636 if try $CC -c $CFLAGS $test.c; then
637 echo "Checking for return value of snprintf()... Yes." | tee -a configure.log
638 else
639 CFLAGS="$CFLAGS -DHAS_snprintf_void"
640 SFLAGS="$SFLAGS -DHAS_snprintf_void"
641 echo "Checking for return value of snprintf()... No." | tee -a configure.log
642 echo " WARNING: apparently snprintf() does not return a value. zlib" | tee -a configure.log
643 echo " can build but will be open to possible string-format security" | tee -a configure.log
644 echo " vulnerabilities." | tee -a configure.log
645 fi
646 else
647 CFLAGS="$CFLAGS -DNO_snprintf"
648 SFLAGS="$SFLAGS -DNO_snprintf"
649 echo "Checking for snprintf() in stdio.h... No." | tee -a configure.log
650 echo " WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log
651 echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
652 echo " vulnerabilities." | tee -a configure.log
653
654 echo >> configure.log
655 cat >$test.c <<EOF
656#include <stdio.h>
657int mytest()
658{
659 char buf[20];
660 return sprintf(buf, "%s", "foo");
661}
662int main()
663{
664 return (mytest());
665}
666EOF
667
668 if try $CC -c $CFLAGS $test.c; then
669 echo "Checking for return value of sprintf()... Yes." | tee -a configure.log
670 else
671 CFLAGS="$CFLAGS -DHAS_sprintf_void"
672 SFLAGS="$SFLAGS -DHAS_sprintf_void"
673 echo "Checking for return value of sprintf()... No." | tee -a configure.log
674 echo " WARNING: apparently sprintf() does not return a value. zlib" | tee -a configure.log
675 echo " can build but will be open to possible string-format security" | tee -a configure.log
676 echo " vulnerabilities." | tee -a configure.log
677 fi
678 fi
679fi
680
681# see if we can hide zlib internal symbols that are linked between separate source files
682if test "$gcc" -eq 1; then
683 echo >> configure.log
684 cat > $test.c <<EOF
685#define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
686int ZLIB_INTERNAL foo;
687int main()
688{
689 return 0;
690}
691EOF
692 if tryboth $CC -c $CFLAGS $test.c; then
693 CFLAGS="$CFLAGS -DHAVE_HIDDEN"
694 SFLAGS="$SFLAGS -DHAVE_HIDDEN"
695 echo "Checking for attribute(visibility) support... Yes." | tee -a configure.log
696 else
697 echo "Checking for attribute(visibility) support... No." | tee -a configure.log
698 fi
699fi
700
701echo >> configure.log
702
703# find a four-byte unsiged integer type for crc calculations
704cat > $test.c <<EOF
705#include <stdio.h>
706#define is32(n,t) for(n=1,k=0;n;n<<=1,k++);if(k==32){puts(t);return 0;}
707int main() {
708 int k;
709 unsigned i;
710 unsigned long l;
711 unsigned short s;
712 is32(i, "unsigned")
713 is32(l, "unsigned long")
714 is32(s, "unsigned short")
715 return 1;
716}
717EOF
718Z_U4=""
719if try $CC $CFLAGS $test.c -o $test && Z_U4=`./$test` && test -n "$Z_U4"; then
720 sed < zconf.h "/#define Z_U4/s/\/\* \.\/configure may/#define Z_U4 $Z_U4 \/* .\/configure put the/" > zconf.temp.h
721 mv zconf.temp.h zconf.h
722 echo "Looking for a four-byte integer type... Found." | tee -a configure.log
723else
724 echo "Looking for a four-byte integer type... Not found." | tee -a configure.log
725fi
726
727# clean up files produced by running the compiler and linker
728rm -f $test.[co] $test $test$shared_ext $test.gcno
729
730# show the results in the log
731echo >> configure.log
732echo ALL = $ALL >> configure.log
733echo AR = $AR >> configure.log
734echo ARFLAGS = $ARFLAGS >> configure.log
735echo CC = $CC >> configure.log
736echo CFLAGS = $CFLAGS >> configure.log
737echo CPP = $CPP >> configure.log
738echo EXE = $EXE >> configure.log
739echo LDCONFIG = $LDCONFIG >> configure.log
740echo LDFLAGS = $LDFLAGS >> configure.log
741echo LDSHARED = $LDSHARED >> configure.log
742echo LDSHAREDLIBC = $LDSHAREDLIBC >> configure.log
743echo OBJC = $OBJC >> configure.log
744echo PIC_OBJC = $PIC_OBJC >> configure.log
745echo RANLIB = $RANLIB >> configure.log
746echo SFLAGS = $SFLAGS >> configure.log
747echo SHAREDLIB = $SHAREDLIB >> configure.log
748echo SHAREDLIBM = $SHAREDLIBM >> configure.log
749echo SHAREDLIBV = $SHAREDLIBV >> configure.log
750echo STATICLIB = $STATICLIB >> configure.log
751echo TEST = $TEST >> configure.log
752echo VER = $VER >> configure.log
753echo Z_U4 = $Z_U4 >> configure.log
754echo exec_prefix = $exec_prefix >> configure.log
755echo includedir = $includedir >> configure.log
756echo libdir = $libdir >> configure.log
757echo mandir = $mandir >> configure.log
758echo prefix = $prefix >> configure.log
759echo sharedlibdir = $sharedlibdir >> configure.log
760echo uname = $uname >> configure.log
761echo -------------------- >> configure.log
762echo >> configure.log
763echo >> configure.log
764
765# udpate Makefile with the configure results
766sed < Makefile.in "
767/^CC *=/s#=.*#=$CC#
768/^CFLAGS *=/s#=.*#=$CFLAGS#
769/^SFLAGS *=/s#=.*#=$SFLAGS#
770/^LDFLAGS *=/s#=.*#=$LDFLAGS#
771/^LDSHARED *=/s#=.*#=$LDSHARED#
772/^CPP *=/s#=.*#=$CPP#
773/^STATICLIB *=/s#=.*#=$STATICLIB#
774/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
775/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
776/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
777/^AR *=/s#=.*#=$AR#
778/^ARFLAGS *=/s#=.*#=$ARFLAGS#
779/^RANLIB *=/s#=.*#=$RANLIB#
780/^LDCONFIG *=/s#=.*#=$LDCONFIG#
781/^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
782/^EXE *=/s#=.*#=$EXE#
783/^prefix *=/s#=.*#=$prefix#
784/^exec_prefix *=/s#=.*#=$exec_prefix#
785/^libdir *=/s#=.*#=$libdir#
786/^sharedlibdir *=/s#=.*#=$sharedlibdir#
787/^includedir *=/s#=.*#=$includedir#
788/^mandir *=/s#=.*#=$mandir#
789/^OBJC *=/s#=.*#= $OBJC#
790/^PIC_OBJC *=/s#=.*#= $PIC_OBJC#
791/^all: */s#:.*#: $ALL#
792/^test: */s#:.*#: $TEST#
793" > Makefile
794
795# create zlib.pc with the configure results
796sed < zlib.pc.in "
797/^CC *=/s#=.*#=$CC#
798/^CFLAGS *=/s#=.*#=$CFLAGS#
799/^CPP *=/s#=.*#=$CPP#
800/^LDSHARED *=/s#=.*#=$LDSHARED#
801/^STATICLIB *=/s#=.*#=$STATICLIB#
802/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
803/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
804/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
805/^AR *=/s#=.*#=$AR#
806/^ARFLAGS *=/s#=.*#=$ARFLAGS#
807/^RANLIB *=/s#=.*#=$RANLIB#
808/^EXE *=/s#=.*#=$EXE#
809/^prefix *=/s#=.*#=$prefix#
810/^exec_prefix *=/s#=.*#=$exec_prefix#
811/^libdir *=/s#=.*#=$libdir#
812/^sharedlibdir *=/s#=.*#=$sharedlibdir#
813/^includedir *=/s#=.*#=$includedir#
814/^mandir *=/s#=.*#=$mandir#
815/^LDFLAGS *=/s#=.*#=$LDFLAGS#
816" | sed -e "
817s/\@VERSION\@/$VER/g;
818" > zlib.pc