2 # configure script for zlib. This script is needed only if
3 # you wish to build a shared library and your system supports them,
4 # of if you need special compiler, flags or install directory.
5 # Otherwise, you can just use directly "make test; make install"
7 # To create a shared library, use "configure --shared"; by default a static
8 # library is created. If the primitive shared library support provided here
9 # does not work, use ftp://prep.ai.mit.edu/pub/gnu/libtool-*.tar.gz
11 # To impose specific compiler or flags or install directory, use for example:
12 # prefix=$HOME CC=cc CFLAGS="-O4" ./configure
13 # or for csh/tcsh users:
14 # (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure)
15 # LDSHARED is the command to be used to create a shared library
17 # Incorrect settings of CC or CFLAGS may prevent creating a shared library.
18 # If you have problems, try without defining CC and CFLAGS before reporting
23 VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
24 VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h`
25 VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h`
27 RANLIB=${RANLIB-"ranlib"}
28 prefix=${prefix-/usr/local}
29 exec_prefix=${exec_prefix-'${prefix}'}
30 libdir=${libdir-'${exec_prefix}/lib'}
31 includedir=${includedir-'${prefix}/include'}
32 mandir=${mandir-'${prefix}/share/man'}
44 echo ' configure [--shared] [--prefix=PREFIX] [--exec_prefix=EXPREFIX]'
45 echo ' [--libdir=LIBDIR] [--includedir=INCLUDEDIR]'
47 -p*=* | --p*=*) prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
48 -e*=* | --e*=*) exec_prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
49 -l*=* | --libdir=*) libdir=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
50 -i*=* | --includedir=*) includedir=`echo $1 | sed 's/[-a-z_]*=//'`;shift;;
51 -p* | --p*) prefix="$2"; shift; shift;;
52 -e* | --e*) exec_prefix="$2"; shift; shift;;
53 -l* | --l*) libdir="$2"; shift; shift;;
54 -i* | --i*) includedir="$2"; shift; shift;;
55 -s* | --s*) shared=1; shift;;
56 *) echo "unknown option: $1"; echo "$0 --help for help"; exit 1;;
63 int hello() {return getchar();}
66 test -z "$CC" && echo Checking for gcc...
68 cflags=${CFLAGS-"-O3"}
69 # to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
74 if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
76 SFLAGS=${CFLAGS-"-fPIC -O3"}
78 case `(uname -s || echo unknown) 2>/dev/null` in
79 Linux | linux | GNU | GNU/*) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1"};;
80 CYGWIN* | Cygwin* | cygwin* | OS/2* )
82 QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
83 # (alain.bonnefoy@icbt.com)
84 LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"};;
85 HP-UX*) LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
88 Darwin*) shared_ext='.dylib'
89 SHAREDLIB=libz$shared_ext
90 SHAREDLIBV=libz.$VER$shared_ext
91 SHAREDLIBM=libz.$VER1$shared_ext
92 LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER"};;
93 *) LDSHARED=${LDSHARED-"$cc -shared"};;
96 # find system name and corresponding cc options
98 case `(uname -sr || echo unknown) 2>/dev/null` in
99 HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
100 CFLAGS=${CFLAGS-"-O"}
101 # LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
102 LDSHARED=${LDSHARED-"ld -b"}
104 SHAREDLIB='libz.sl';;
105 IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
106 CFLAGS=${CFLAGS-"-ansi -O2"}
107 LDSHARED=${LDSHARED-"cc -shared"};;
108 OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
109 CFLAGS=${CFLAGS-"-O -std1"}
110 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"};;
111 OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
112 CFLAGS=${CFLAGS-"-O -std1"}
113 LDSHARED=${LDSHARED-"cc -shared"};;
114 QNX*) SFLAGS=${CFLAGS-"-4 -O"}
115 CFLAGS=${CFLAGS-"-4 -O"}
116 LDSHARED=${LDSHARED-"cc"}
117 RANLIB=${RANLIB-"true"}
119 SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
120 CFLAGS=${CFLAGS-"-O3"}
121 LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};;
122 SunOS\ 5*) SFLAGS=${CFLAGS-"-fast -xcg89 -KPIC -R."}
123 CFLAGS=${CFLAGS-"-fast -xcg89"}
124 LDSHARED=${LDSHARED-"cc -G"};;
125 SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
126 CFLAGS=${CFLAGS-"-O2"}
127 LDSHARED=${LDSHARED-"ld"};;
128 SunStudio\ 9*) SFLAGS=${CFLAGS-"-DUSE_MMAP -fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
129 CFLAGS=${CFLAGS-"-DUSE_MMAP -fast -xtarget=ultra3 -xarch=v9b"}
130 LDSHARED=${LDSHARED-"cc -xarch=v9b"};;
131 UNIX_System_V\ 4.2.0)
132 SFLAGS=${CFLAGS-"-KPIC -O"}
133 CFLAGS=${CFLAGS-"-O"}
134 LDSHARED=${LDSHARED-"cc -G"};;
136 SFLAGS=${CFLAGS-"-Kconform_pic -O"}
137 CFLAGS=${CFLAGS-"-O"}
138 LDSHARED=${LDSHARED-"cc -G"};;
140 SFLAGS=${CFLAGS-"-KPIC -O"}
141 CFLAGS=${CFLAGS-"-O"}
142 LDSHARED=${LDSHARED-"cc -G"};;
143 AIX*) # Courtesy of dbakker@arrayasolutions.com
144 SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
145 CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
146 LDSHARED=${LDSHARED-"xlc -G"};;
147 # send working options for other systems to support@gzip.org
148 *) SFLAGS=${CFLAGS-"-O"}
149 CFLAGS=${CFLAGS-"-O"}
150 LDSHARED=${LDSHARED-"cc -shared"};;
154 SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
155 SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
156 SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
158 if test $shared -eq 1; then
159 echo Checking for shared library support...
160 # we must test in two steps (cc then ld), required at least on SunOS 4.x
161 if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" &&
162 test "`($LDSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then
165 echo Building shared library $SHAREDLIBV with $CC.
166 elif test -z "$old_cc" -a -z "$old_cflags"; then
167 echo No shared library support.
170 echo 'No shared library support; try without defining CC and CFLAGS'
174 if test $shared -eq 0; then
176 echo Building static library $LIBS version $VER with $CC.
178 LDFLAGS="-L. ${SHAREDLIBV}"
183 int main() { return 0; }
185 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
186 sed < zconf.in.h "/HAVE_UNISTD_H/s%0%1%" > zconf.h
187 echo "Checking for unistd.h... Yes."
189 cp -p zconf.in.h zconf.h
190 echo "Checking for unistd.h... No."
208 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
209 echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()"
215 int mytest(char *fmt, ...)
221 vsnprintf(buf, sizeof(buf), fmt, ap);
228 return (mytest("Hello%d\n", 1));
232 if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
233 echo "Checking for vsnprintf() in stdio.h... Yes."
239 int mytest(char *fmt, ...)
246 n = vsnprintf(buf, sizeof(buf), fmt, ap);
253 return (mytest("Hello%d\n", 1));
257 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
258 echo "Checking for return value of vsnprintf()... Yes."
260 CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
261 echo "Checking for return value of vsnprintf()... No."
262 echo " WARNING: apparently vsnprintf() does not return a value. zlib"
263 echo " can build but will be open to possible string-format security"
264 echo " vulnerabilities."
267 CFLAGS="$CFLAGS -DNO_vsnprintf"
268 echo "Checking for vsnprintf() in stdio.h... No."
269 echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib"
270 echo " can build but will be open to possible buffer-overflow security"
271 echo " vulnerabilities."
277 int mytest(char *fmt, ...)
284 n = vsprintf(buf, fmt, ap);
291 return (mytest("Hello%d\n", 1));
295 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
296 echo "Checking for return value of vsprintf()... Yes."
298 CFLAGS="$CFLAGS -DHAS_vsprintf_void"
299 echo "Checking for return value of vsprintf()... No."
300 echo " WARNING: apparently vsprintf() does not return a value. zlib"
301 echo " can build but will be open to possible string-format security"
302 echo " vulnerabilities."
306 echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()"
315 snprintf(buf, sizeof(buf), "%s", "foo");
325 if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
326 echo "Checking for snprintf() in stdio.h... Yes."
335 return snprintf(buf, sizeof(buf), "%s", "foo");
344 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
345 echo "Checking for return value of snprintf()... Yes."
347 CFLAGS="$CFLAGS -DHAS_snprintf_void"
348 echo "Checking for return value of snprintf()... No."
349 echo " WARNING: apparently snprintf() does not return a value. zlib"
350 echo " can build but will be open to possible string-format security"
351 echo " vulnerabilities."
354 CFLAGS="$CFLAGS -DNO_snprintf"
355 echo "Checking for snprintf() in stdio.h... No."
356 echo " WARNING: snprintf() not found, falling back to sprintf(). zlib"
357 echo " can build but will be open to possible buffer-overflow security"
358 echo " vulnerabilities."
367 return sprintf(buf, "%s", "foo");
376 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
377 echo "Checking for return value of sprintf()... Yes."
379 CFLAGS="$CFLAGS -DHAS_sprintf_void"
380 echo "Checking for return value of sprintf()... No."
381 echo " WARNING: apparently sprintf() does not return a value. zlib"
382 echo " can build but will be open to possible string-format security"
383 echo " vulnerabilities."
390 int main() { return 0; }
392 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
393 echo "Checking for errno.h... Yes."
395 echo "Checking for errno.h... No."
396 CFLAGS="$CFLAGS -DNO_ERRNO_H"
400 #include <sys/types.h>
401 #include <sys/mman.h>
402 #include <sys/stat.h>
404 return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0);
407 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
408 CFLAGS="$CFLAGS -DUSE_MMAP"
409 echo Checking for mmap support... Yes.
411 echo Checking for mmap support... No.
417 if test "`nm $test.o | grep _hello`" = ""; then
418 CPP="$CPP -DNO_UNDERLINE"
419 echo Checking for underline in external names... No.
421 echo Checking for underline in external names... Yes.
425 rm -f $test.[co] $test $test$shared_ext
430 /^CFLAGS *=/s#=.*#=$CFLAGS#
431 /^CPP *=/s#=.*#=$CPP#
432 /^LDSHARED *=/s#=.*#=$LDSHARED#
433 /^LIBS *=/s#=.*#=$LIBS#
434 /^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
435 /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
436 /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
438 /^RANLIB *=/s#=.*#=$RANLIB#
439 /^EXE *=/s#=.*#=$EXE#
440 /^prefix *=/s#=.*#=$prefix#
441 /^exec_prefix *=/s#=.*#=$exec_prefix#
442 /^libdir *=/s#=.*#=$libdir#
443 /^includedir *=/s#=.*#=$includedir#
444 /^mandir *=/s#=.*#=$mandir#
445 /^LDFLAGS *=/s#=.*#=$LDFLAGS#