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`
25 RANLIB=${RANLIB-"ranlib"}
26 prefix=${prefix-/usr/local}
27 exec_prefix=${exec_prefix-'${prefix}'}
28 libdir=${libdir-'${exec_prefix}/lib'}
29 includedir=${includedir-'${prefix}/include'}
41 echo ' configure [--shared] [--prefix=PREFIX] [--exec_prefix=EXPREFIX]'
42 echo ' [--libdir=LIBDIR] [--includedir=INCLUDEDIR]'
44 -p*=* | --p*=*) prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
45 -e*=* | --e*=*) exec_prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
46 -l*=* | --libdir=*) libdir=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
47 -i*=* | --includedir=*) includedir=`echo $1 | sed 's/[-a-z_]*=//'`;shift;;
48 -p* | --p*) prefix="$2"; shift; shift;;
49 -e* | --e*) exec_prefix="$2"; shift; shift;;
50 -l* | --l*) libdir="$2"; shift; shift;;
51 -i* | --i*) includedir="$2"; shift; shift;;
52 -s* | --s*) shared=1; shift;;
59 int hello() {return getchar();}
62 test -z "$CC" && echo Checking for gcc...
64 cflags=${CFLAGS-"-O3"}
65 # to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
70 if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
72 SFLAGS=${CFLAGS-"-fPIC -O3"}
74 case `(uname -s || echo unknown) 2>/dev/null` in
75 Linux | linux) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1"};;
76 HP-UX*) LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
79 *) LDSHARED=${LDSHARED-"$cc -shared"};;
82 # find system name and corresponding cc options
84 case `(uname -sr || echo unknown) 2>/dev/null` in
85 HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
87 # LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
88 LDSHARED=${LDSHARED-"ld -b"}
91 IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
92 CFLAGS=${CFLAGS-"-ansi -O2"}
93 LDSHARED=${LDSHARED-"cc -shared"};;
94 OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
95 CFLAGS=${CFLAGS-"-O -std1"}
96 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,$SHAREDLIB -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"};;
97 OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
98 CFLAGS=${CFLAGS-"-O -std1"}
99 LDSHARED=${LDSHARED-"cc -shared"};;
100 QNX*) SFLAGS=${CFLAGS-"-4 -O"}
101 CFLAGS=${CFLAGS-"-4 -O"}
102 LDSHARED=${LDSHARED-"cc"}
103 RANLIB=${RANLIB-"true"}
105 SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
106 CFLAGS=${CFLAGS-"-O3"}
107 LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};;
108 SunOS\ 5*) SFLAGS=${CFLAGS-"-fast -xcg89 -KPIC -R."}
109 CFLAGS=${CFLAGS-"-fast -xcg89"}
110 LDSHARED=${LDSHARED-"cc -G"};;
111 SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
112 CFLAGS=${CFLAGS-"-O2"}
113 LDSHARED=${LDSHARED-"ld"};;
114 UNIX_System_V\ 4.2.0)
115 SFLAGS=${CFLAGS-"-KPIC -O"}
116 CFLAGS=${CFLAGS-"-O"}
117 LDSHARED=${LDSHARED-"cc -G"};;
119 SFLAGS=${CFLAGS-"-Kconform_pic -O"}
120 CFLAGS=${CFLAGS-"-O"}
121 LDSHARED=${LDSHARED-"cc -G"};;
123 SFLAGS=${CFLAGS-"-KPIC -O"}
124 CFLAGS=${CFLAGS-"-O"}
125 LDSHARED=${LDSHARED-"cc -G"};;
126 # send working options for other systems to support@gzip.org
127 *) SFLAGS=${CFLAGS-"-O"}
128 CFLAGS=${CFLAGS-"-O"}
129 LDSHARED=${LDSHARED-"cc -shared"};;
133 if test $shared -eq 1; then
134 echo Checking for shared library support...
135 # we must test in two steps (cc then ld), required at least on SunOS 4.x
136 if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" &&
137 test "`($LDSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then
139 LIBS="$SHAREDLIB.$VER"
140 echo Building shared library $SHAREDLIB.$VER with $CC.
141 elif test -z "$old_cc" -a -z "$old_cflags"; then
142 echo No shared library suppport.
145 echo 'No shared library suppport; try without defining CC and CFLAGS'
149 if test $shared -eq 0; then
151 echo Building static library $LIBS version $VER with $CC.
156 int main() { return 0; }
158 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
159 sed < zconf.in.h "/HAVE_UNISTD_H/s%0%1%" > zconf.h
160 echo "Checking for unistd.h... Yes."
162 cp -p zconf.in.h zconf.h
163 echo "Checking for unistd.h... No."
170 #if (defined(__MSDOS__) || defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__STDC__) || defined(__cplusplus) || defined(__OS2__)) && !defined(STDC)
184 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
185 echo "Checking whether to use vsnprintf() or snprintf()... using vsnprintf()"
191 int mytest(char *fmt, ...)
197 vsnprintf(buf, sizeof(buf), fmt, ap);
204 return (mytest("Hello%d\n", 1));
208 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
209 echo "Checking for vsnprintf() in stdio.h... Yes."
215 int mytest(char *fmt, ...)
222 i = vsnprintf(buf, sizeof(buf), fmt, ap);
229 return (mytest("Hello%d\n", 1));
233 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
234 echo "Checking for return value of vsnprintf()... Yes."
236 CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
237 echo "Checking for return value of vsnprintf()... No."
238 echo " WARNING: apparently vsnprintf() does not return a value. zlib"
239 echo " can build but will be open to possible string-format security"
240 echo " vulnerabilities."
243 CFLAGS="$CFLAGS -DNO_vsnprintf"
244 echo "Checking for vsnprintf() in stdio.h... No."
245 echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib"
246 echo " can build but will be open to possible buffer-overflow security"
247 echo " vulnerabilities."
253 int mytest(char *fmt, ...)
260 i = vsprintf(buf, fmt, ap);
267 return (mytest("Hello%d\n", 1));
271 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
272 echo "Checking for return value of vsprintf()... Yes."
274 CFLAGS="$CFLAGS -DHAS_vsprintf_void"
275 echo "Checking for return value of vsprintf()... No."
276 echo " WARNING: apparently vsprintf() does not return a value. zlib"
277 echo " can build but will be open to possible string-format security"
278 echo " vulnerabilities."
282 echo "Checking whether to use vsnprintf() or snprintf()... using snprintf()"
292 snprintf(buf, sizeof(buf), "%s", "foo");
302 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
303 echo "Checking for snprintf() in stdio.h... Yes."
309 int mytest(char *fmt, ...)
314 i = snprintf(buf, sizeof(buf), "%s", "foo");
324 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
325 echo "Checking for return value of snprintf()... Yes."
327 CFLAGS="$CFLAGS -DHAS_snprintf_void"
328 echo "Checking for return value of snprintf()... No."
329 echo " WARNING: apparently snprintf() does not return a value. zlib"
330 echo " can build but will be open to possible string-format security"
331 echo " vulnerabilities."
334 CFLAGS="$CFLAGS -DNO_snprintf"
335 echo "Checking for snprintf() in stdio.h... No."
336 echo " WARNING: snprintf() not found, falling back to sprintf(). zlib"
337 echo " can build but will be open to possible buffer-overflow security"
338 echo " vulnerabilities."
344 int mytest(char *fmt, ...)
349 i = sprintf(buf, "%s", "foo");
359 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
360 echo "Checking for return value of sprintf()... Yes."
362 CFLAGS="$CFLAGS -DHAS_sprintf_void"
363 echo "Checking for return value of sprintf()... No."
364 echo " WARNING: apparently sprintf() does not return a value. zlib"
365 echo " can build but will be open to possible string-format security"
366 echo " vulnerabilities."
373 int main() { return 0; }
375 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
376 echo "Checking for errno.h... Yes."
378 echo "Checking for errno.h... No."
379 CFLAGS="$CFLAGS -DNO_ERRNO_H"
383 #include <sys/types.h>
384 #include <sys/mman.h>
385 #include <sys/stat.h>
387 return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0);
390 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
391 CFLAGS="$CFLAGS -DUSE_MMAP"
392 echo Checking for mmap support... Yes.
394 echo Checking for mmap support... No.
400 if test "`nm $test.o | grep _hello`" = ""; then
401 CPP="$CPP -DNO_UNDERLINE"
402 echo Checking for underline in external names... No.
404 echo Checking for underline in external names... Yes.
408 rm -f $test.[co] $test$shared_ext
413 /^CFLAGS *=/s%=.*%=$CFLAGS%
414 /^CPP *=/s%=.*%=$CPP%
415 /^LDSHARED *=/s%=.*%=$LDSHARED%
416 /^LIBS *=/s%=.*%=$LIBS%
417 /^SHAREDLIB *=/s%=.*%=$SHAREDLIB%
419 /^RANLIB *=/s%=.*%=$RANLIB%
420 /^VER *=/s%=.*%=$VER%
421 /^prefix *=/s%=.*%=$prefix%
422 /^exec_prefix *=/s%=.*%=$exec_prefix%
423 /^libdir *=/s%=.*%=$libdir%
424 /^includedir *=/s%=.*%=$includedir%