VirtualBox

source: vbox/trunk/src/libs/zlib-1.2.12/configure@ 95259

Last change on this file since 95259 was 95239, checked in by vboxsync, 2 years ago

libs/zlib: Upgrade to 1.2.12, bugref:8515

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette