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
24 VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
26 RANLIB=${RANLIB-"ranlib"}
27 prefix=${prefix-/usr/local}
28 exec_prefix=${exec_prefix-'${prefix}'}
29 libdir=${libdir-'${exec_prefix}/lib'}
30 includedir=${includedir-'${prefix}/include'}
42 echo ' configure [--shared] [--prefix=PREFIX] [--exec_prefix=EXPREFIX]'
43 echo ' [--libdir=LIBDIR] [--includedir=INCLUDEDIR]'
45 -p*=* | --p*=*) prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
46 -e*=* | --e*=*) exec_prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
47 -l*=* | --libdir=*) libdir=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
48 -i*=* | --includedir=*) includedir=`echo $1 | sed 's/[-a-z_]*=//'`;shift;;
49 -p* | --p*) prefix="$2"; shift; shift;;
50 -e* | --e*) exec_prefix="$2"; shift; shift;;
51 -l* | --l*) libdir="$2"; shift; shift;;
52 -i* | --i*) includedir="$2"; shift; shift;;
53 -s* | --s*) shared=1; shift;;
57 if [ $shared -eq 1 ]; then
58 LDFLAGS="-L. ${SHAREDLIB}"
64 int hello() {return getchar();}
67 test -z "$CC" && echo Checking for gcc...
69 cflags=${CFLAGS-"-O3"}
70 # to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
75 if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
77 SFLAGS=${CFLAGS-"-fPIC -O3"}
79 case `(uname -s || echo unknown) 2>/dev/null` in
80 Linux | linux) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1"};;
81 HP-UX*) LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
84 *) LDSHARED=${LDSHARED-"$cc -shared"};;
87 # find system name and corresponding cc options
89 case `(uname -sr || echo unknown) 2>/dev/null` in
90 HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
92 # LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
93 LDSHARED=${LDSHARED-"ld -b"}
96 IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
97 CFLAGS=${CFLAGS-"-ansi -O2"}
98 LDSHARED=${LDSHARED-"cc -shared"};;
99 OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
100 CFLAGS=${CFLAGS-"-O -std1"}
101 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,$SHAREDLIB -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"};;
102 OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
103 CFLAGS=${CFLAGS-"-O -std1"}
104 LDSHARED=${LDSHARED-"cc -shared"};;
105 QNX*) SFLAGS=${CFLAGS-"-4 -O"}
106 CFLAGS=${CFLAGS-"-4 -O"}
107 LDSHARED=${LDSHARED-"cc"}
108 RANLIB=${RANLIB-"true"}
110 SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
111 CFLAGS=${CFLAGS-"-O3"}
112 LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};;
113 SunOS\ 5*) SFLAGS=${CFLAGS-"-fast -xcg89 -KPIC -R."}
114 CFLAGS=${CFLAGS-"-fast -xcg89"}
115 LDSHARED=${LDSHARED-"cc -G"};;
116 SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
117 CFLAGS=${CFLAGS-"-O2"}
118 LDSHARED=${LDSHARED-"ld"};;
119 UNIX_System_V\ 4.2.0)
120 SFLAGS=${CFLAGS-"-KPIC -O"}
121 CFLAGS=${CFLAGS-"-O"}
122 LDSHARED=${LDSHARED-"cc -G"};;
124 SFLAGS=${CFLAGS-"-Kconform_pic -O"}
125 CFLAGS=${CFLAGS-"-O"}
126 LDSHARED=${LDSHARED-"cc -G"};;
128 SFLAGS=${CFLAGS-"-KPIC -O"}
129 CFLAGS=${CFLAGS-"-O"}
130 LDSHARED=${LDSHARED-"cc -G"};;
131 AIX*) # Courtesy of dbakker@arrayasolutions.com
132 SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
133 CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
134 LDSHARED=${LDSHARED-"xlc -G"};;
135 # send working options for other systems to support@gzip.org
136 *) SFLAGS=${CFLAGS-"-O"}
137 CFLAGS=${CFLAGS-"-O"}
138 LDSHARED=${LDSHARED-"cc -shared"};;
142 if test $shared -eq 1; then
143 echo Checking for shared library support...
144 # we must test in two steps (cc then ld), required at least on SunOS 4.x
145 if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" &&
146 test "`($LDSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then
148 LIBS="$SHAREDLIB.$VER"
149 echo Building shared library $SHAREDLIB.$VER with $CC.
150 elif test -z "$old_cc" -a -z "$old_cflags"; then
151 echo No shared library suppport.
154 echo 'No shared library suppport; try without defining CC and CFLAGS'
158 if test $shared -eq 0; then
160 echo Building static library $LIBS version $VER with $CC.
165 int main() { return 0; }
167 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
168 sed < zconf.in.h "/HAVE_UNISTD_H/s%0%1%" > zconf.h
169 echo "Checking for unistd.h... Yes."
171 cp -p zconf.in.h zconf.h
172 echo "Checking for unistd.h... No."
179 #if (defined(__MSDOS__) || defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__STDC__) || defined(__cplusplus) || defined(__OS2__)) && !defined(STDC)
193 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
194 echo "Checking whether to use vsnprintf() or snprintf()... using vsnprintf()"
200 int mytest(char *fmt, ...)
206 vsnprintf(buf, sizeof(buf), fmt, ap);
213 return (mytest("Hello%d\n", 1));
217 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
218 echo "Checking for vsnprintf() in stdio.h... Yes."
224 int mytest(char *fmt, ...)
231 i = vsnprintf(buf, sizeof(buf), fmt, ap);
238 return (mytest("Hello%d\n", 1));
242 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
243 echo "Checking for return value of vsnprintf()... Yes."
245 CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
246 echo "Checking for return value of vsnprintf()... No."
247 echo " WARNING: apparently vsnprintf() does not return a value. zlib"
248 echo " can build but will be open to possible string-format security"
249 echo " vulnerabilities."
252 CFLAGS="$CFLAGS -DNO_vsnprintf"
253 echo "Checking for vsnprintf() in stdio.h... No."
254 echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib"
255 echo " can build but will be open to possible buffer-overflow security"
256 echo " vulnerabilities."
262 int mytest(char *fmt, ...)
269 i = vsprintf(buf, fmt, ap);
276 return (mytest("Hello%d\n", 1));
280 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
281 echo "Checking for return value of vsprintf()... Yes."
283 CFLAGS="$CFLAGS -DHAS_vsprintf_void"
284 echo "Checking for return value of vsprintf()... No."
285 echo " WARNING: apparently vsprintf() does not return a value. zlib"
286 echo " can build but will be open to possible string-format security"
287 echo " vulnerabilities."
291 echo "Checking whether to use vsnprintf() or snprintf()... using snprintf()"
301 snprintf(buf, sizeof(buf), "%s", "foo");
311 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
312 echo "Checking for snprintf() in stdio.h... Yes."
318 int mytest(char *fmt, ...)
323 i = snprintf(buf, sizeof(buf), "%s", "foo");
333 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
334 echo "Checking for return value of snprintf()... Yes."
336 CFLAGS="$CFLAGS -DHAS_snprintf_void"
337 echo "Checking for return value of snprintf()... No."
338 echo " WARNING: apparently snprintf() does not return a value. zlib"
339 echo " can build but will be open to possible string-format security"
340 echo " vulnerabilities."
343 CFLAGS="$CFLAGS -DNO_snprintf"
344 echo "Checking for snprintf() in stdio.h... No."
345 echo " WARNING: snprintf() not found, falling back to sprintf(). zlib"
346 echo " can build but will be open to possible buffer-overflow security"
347 echo " vulnerabilities."
353 int mytest(char *fmt, ...)
358 i = sprintf(buf, "%s", "foo");
368 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
369 echo "Checking for return value of sprintf()... Yes."
371 CFLAGS="$CFLAGS -DHAS_sprintf_void"
372 echo "Checking for return value of sprintf()... No."
373 echo " WARNING: apparently sprintf() does not return a value. zlib"
374 echo " can build but will be open to possible string-format security"
375 echo " vulnerabilities."
382 int main() { return 0; }
384 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
385 echo "Checking for errno.h... Yes."
387 echo "Checking for errno.h... No."
388 CFLAGS="$CFLAGS -DNO_ERRNO_H"
392 #include <sys/types.h>
393 #include <sys/mman.h>
394 #include <sys/stat.h>
396 return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0);
399 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
400 CFLAGS="$CFLAGS -DUSE_MMAP"
401 echo Checking for mmap support... Yes.
403 echo Checking for mmap support... No.
409 if test "`nm $test.o | grep _hello`" = ""; then
410 CPP="$CPP -DNO_UNDERLINE"
411 echo Checking for underline in external names... No.
413 echo Checking for underline in external names... Yes.
417 rm -f $test.[co] $test$shared_ext
422 /^CFLAGS *=/s%=.*%=$CFLAGS%
423 /^CPP *=/s%=.*%=$CPP%
424 /^LDSHARED *=/s%=.*%=$LDSHARED%
425 /^LIBS *=/s%=.*%=$LIBS%
426 /^SHAREDLIB *=/s%=.*%=$SHAREDLIB%
428 /^RANLIB *=/s%=.*%=$RANLIB%
429 /^VER *=/s%=.*%=$VER%
430 /^prefix *=/s%=.*%=$prefix%
431 /^exec_prefix *=/s%=.*%=$exec_prefix%
432 /^libdir *=/s%=.*%=$libdir%
433 /^includedir *=/s%=.*%=$includedir%
434 /^LDFLAGS *=/s%=.*%=$LDFLAGS%