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"};;
86 LDSHARED
=${LDSHARED-"$cc -shared $SFLAGS"}
87 case `(uname -m || echo unknown) 2>/dev/null` in
95 Darwin
*) shared_ext
='.dylib'
96 SHAREDLIB
=libz
$shared_ext
97 SHAREDLIBV
=libz.
$VER$shared_ext
98 SHAREDLIBM
=libz.
$VER1$shared_ext
99 LDSHARED
=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER"};;
100 *) LDSHARED
=${LDSHARED-"$cc -shared"};;
103 # find system name and corresponding cc options
105 case `(uname -sr || echo unknown) 2>/dev/null` in
106 HP-UX
*) SFLAGS
=${CFLAGS-"-O +z"}
107 CFLAGS
=${CFLAGS-"-O"}
108 # LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
109 LDSHARED
=${LDSHARED-"ld -b"}
110 case `(uname -m || echo unknown) 2>/dev/null` in
113 SHAREDLIB
='libz.so';;
116 SHAREDLIB
='libz.sl';;
118 IRIX
*) SFLAGS
=${CFLAGS-"-ansi -O2 -rpath ."}
119 CFLAGS
=${CFLAGS-"-ansi -O2"}
120 LDSHARED
=${LDSHARED-"cc -shared"};;
121 OSF1\ V4
*) SFLAGS
=${CFLAGS-"-O -std1"}
122 CFLAGS
=${CFLAGS-"-O -std1"}
123 LDSHARED
=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"};;
124 OSF1
*) SFLAGS
=${CFLAGS-"-O -std1"}
125 CFLAGS
=${CFLAGS-"-O -std1"}
126 LDSHARED
=${LDSHARED-"cc -shared"};;
127 QNX
*) SFLAGS
=${CFLAGS-"-4 -O"}
128 CFLAGS
=${CFLAGS-"-4 -O"}
129 LDSHARED
=${LDSHARED-"cc"}
130 RANLIB
=${RANLIB-"true"}
132 SCO_SV\
3.2*) SFLAGS
=${CFLAGS-"-O3 -dy -KPIC "}
133 CFLAGS
=${CFLAGS-"-O3"}
134 LDSHARED
=${LDSHARED-"cc -dy -KPIC -G"};;
135 SunOS\
5*) SFLAGS
=${CFLAGS-"-fast -xcg89 -KPIC -R."}
136 CFLAGS
=${CFLAGS-"-fast -xcg89"}
137 LDSHARED
=${LDSHARED-"cc -G"};;
138 SunOS\
4*) SFLAGS
=${CFLAGS-"-O2 -PIC"}
139 CFLAGS
=${CFLAGS-"-O2"}
140 LDSHARED
=${LDSHARED-"ld"};;
141 SunStudio\
9*) SFLAGS
=${CFLAGS-"-DUSE_MMAP -fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
142 CFLAGS
=${CFLAGS-"-DUSE_MMAP -fast -xtarget=ultra3 -xarch=v9b"}
143 LDSHARED
=${LDSHARED-"cc -xarch=v9b"};;
144 UNIX_System_V\
4.2.0)
145 SFLAGS
=${CFLAGS-"-KPIC -O"}
146 CFLAGS
=${CFLAGS-"-O"}
147 LDSHARED
=${LDSHARED-"cc -G"};;
149 SFLAGS
=${CFLAGS-"-Kconform_pic -O"}
150 CFLAGS
=${CFLAGS-"-O"}
151 LDSHARED
=${LDSHARED-"cc -G"};;
153 SFLAGS
=${CFLAGS-"-KPIC -O"}
154 CFLAGS
=${CFLAGS-"-O"}
155 LDSHARED
=${LDSHARED-"cc -G"};;
156 AIX
*) # Courtesy of dbakker@arrayasolutions.com
157 SFLAGS
=${CFLAGS-"-O -qmaxmem=8192"}
158 CFLAGS
=${CFLAGS-"-O -qmaxmem=8192"}
159 LDSHARED
=${LDSHARED-"xlc -G"};;
160 # send working options for other systems to support@gzip.org
161 *) SFLAGS
=${CFLAGS-"-O"}
162 CFLAGS
=${CFLAGS-"-O"}
163 LDSHARED
=${LDSHARED-"cc -shared"};;
167 SHAREDLIB
=${SHAREDLIB-"libz$shared_ext"}
168 SHAREDLIBV
=${SHAREDLIBV-"libz$shared_ext.$VER"}
169 SHAREDLIBM
=${SHAREDLIBM-"libz$shared_ext.$VER1"}
171 if test $shared -eq 1; then
172 echo Checking
for shared library support...
173 # we must test in two steps (cc then ld), required at least on SunOS 4.x
174 if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" &&
175 test "`($LDSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then
178 echo Building shared library
$SHAREDLIBV with
$CC.
179 elif test -z "$old_cc" -a -z "$old_cflags"; then
180 echo No shared library support.
183 echo 'No shared library support; try without defining CC and CFLAGS'
187 if test $shared -eq 0; then
189 echo Building static library
$LIBS version
$VER with
$CC.
191 LDFLAGS
="-L. ${SHAREDLIBV}"
196 int main() { return 0; }
198 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
199 sed < zconf.
in.h
"/HAVE_UNISTD_H/s%0%1%" > zconf.h
200 echo "Checking for unistd.h... Yes."
202 cp -p zconf.
in.h zconf.h
203 echo "Checking for unistd.h... No."
221 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
222 echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()"
228 int mytest(char *fmt, ...)
234 vsnprintf(buf, sizeof(buf), fmt, ap);
241 return (mytest("Hello%d\n", 1));
245 if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
246 echo "Checking for vsnprintf() in stdio.h... Yes."
252 int mytest(char *fmt, ...)
259 n = vsnprintf(buf, sizeof(buf), fmt, ap);
266 return (mytest("Hello%d\n", 1));
270 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
271 echo "Checking for return value of vsnprintf()... Yes."
273 CFLAGS
="$CFLAGS -DHAS_vsnprintf_void"
274 echo "Checking for return value of vsnprintf()... No."
275 echo " WARNING: apparently vsnprintf() does not return a value. zlib"
276 echo " can build but will be open to possible string-format security"
277 echo " vulnerabilities."
280 CFLAGS
="$CFLAGS -DNO_vsnprintf"
281 echo "Checking for vsnprintf() in stdio.h... No."
282 echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib"
283 echo " can build but will be open to possible buffer-overflow security"
284 echo " vulnerabilities."
290 int mytest(char *fmt, ...)
297 n = vsprintf(buf, fmt, ap);
304 return (mytest("Hello%d\n", 1));
308 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
309 echo "Checking for return value of vsprintf()... Yes."
311 CFLAGS
="$CFLAGS -DHAS_vsprintf_void"
312 echo "Checking for return value of vsprintf()... No."
313 echo " WARNING: apparently vsprintf() does not return a value. zlib"
314 echo " can build but will be open to possible string-format security"
315 echo " vulnerabilities."
319 echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()"
328 snprintf(buf, sizeof(buf), "%s", "foo");
338 if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
339 echo "Checking for snprintf() in stdio.h... Yes."
348 return snprintf(buf, sizeof(buf), "%s", "foo");
357 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
358 echo "Checking for return value of snprintf()... Yes."
360 CFLAGS
="$CFLAGS -DHAS_snprintf_void"
361 echo "Checking for return value of snprintf()... No."
362 echo " WARNING: apparently snprintf() does not return a value. zlib"
363 echo " can build but will be open to possible string-format security"
364 echo " vulnerabilities."
367 CFLAGS
="$CFLAGS -DNO_snprintf"
368 echo "Checking for snprintf() in stdio.h... No."
369 echo " WARNING: snprintf() not found, falling back to sprintf(). zlib"
370 echo " can build but will be open to possible buffer-overflow security"
371 echo " vulnerabilities."
380 return sprintf(buf, "%s", "foo");
389 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
390 echo "Checking for return value of sprintf()... Yes."
392 CFLAGS
="$CFLAGS -DHAS_sprintf_void"
393 echo "Checking for return value of sprintf()... No."
394 echo " WARNING: apparently sprintf() does not return a value. zlib"
395 echo " can build but will be open to possible string-format security"
396 echo " vulnerabilities."
403 int main() { return 0; }
405 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
406 echo "Checking for errno.h... Yes."
408 echo "Checking for errno.h... No."
409 CFLAGS
="$CFLAGS -DNO_ERRNO_H"
413 #include <sys/types.h>
414 #include <sys/mman.h>
415 #include <sys/stat.h>
417 return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0);
420 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
421 CFLAGS
="$CFLAGS -DUSE_MMAP"
422 echo Checking
for mmap support... Yes.
424 echo Checking
for mmap support... No.
430 if test "`nm $test.o | grep _hello`" = ""; then
431 CPP
="$CPP -DNO_UNDERLINE"
432 echo Checking
for underline
in external names... No.
434 echo Checking
for underline
in external names... Yes.
438 rm -f $test.
[co
] $test $test$shared_ext
443 /^CFLAGS *=/s#=.*#=$CFLAGS#
444 /^CPP *=/s#=.*#=$CPP#
445 /^LDSHARED *=/s#=.*#=$LDSHARED#
446 /^LIBS *=/s#=.*#=$LIBS#
447 /^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
448 /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
449 /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
451 /^RANLIB *=/s#=.*#=$RANLIB#
452 /^EXE *=/s#=.*#=$EXE#
453 /^prefix *=/s#=.*#=$prefix#
454 /^exec_prefix *=/s#=.*#=$exec_prefix#
455 /^libdir *=/s#=.*#=$libdir#
456 /^includedir *=/s#=.*#=$includedir#
457 /^mandir *=/s#=.*#=$mandir#
458 /^LDFLAGS *=/s#=.*#=$LDFLAGS#