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'}
39 -p*=* | --p*=*) prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
40 -e*=* | --e*=*) exec_prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
41 -l*=* | --libdir=*) libdir=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
42 -i*=* | --includedir=*) includedir=`echo $1 | sed 's/[-a-z_]*=//'`;shift;;
43 -p* | --p*) prefix="$2"; shift; shift;;
44 -e* | --e*) exec_prefix="$2"; shift; shift;;
45 -l* | --l*) libdir="$2"; shift; shift;;
46 -i* | --i*) includedir="$2"; shift; shift;;
47 -sh* | --sh*) shared=1; shift;;
52 echo ' configure [--shared] [--prefix=PREFIX] [--exec_prefix=EXPREFIX]'
53 echo ' [--libdir=LIBDIR] [--includedir=INCLUDEDIR]'
61 int hello() {return getchar();}
64 test -z "$CC" && echo Checking for gcc...
66 cflags=${CFLAGS-"-O3"}
67 # to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
72 if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
74 SFLAGS=${CFLAGS-"-fPIC -O3"}
76 case `(uname -s || echo unknown) 2>/dev/null` in
77 Linux | linux) LDSHARED=${LDSHARED-"gcc -shared -Wl,-soname,libz.so.1"};;
78 *) LDSHARED=${LDSHARED-"gcc -shared"};;
81 # find system name and corresponding cc options
83 case `(uname -sr || echo unknown) 2>/dev/null` in
84 HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
86 # LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
87 LDSHARED=${LDSHARED-"ld -b"}
90 IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
91 CFLAGS=${CFLAGS-"-ansi -O2"}
92 LDSHARED=${LDSHARED-"cc -shared"};;
93 OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
94 CFLAGS=${CFLAGS-"-O -std1"}
95 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,$SHAREDLIB -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"};;
96 OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
97 CFLAGS=${CFLAGS-"-O -std1"}
98 LDSHARED=${LDSHARED-"cc -shared"};;
99 QNX*) SFLAGS=${CFLAGS-"-4 -O"}
100 CFLAGS=${CFLAGS-"-4 -O"}
101 LDSHARED=${LDSHARED-"cc"}
102 RANLIB=${RANLIB-"true"}
104 SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
105 CFLAGS=${CFLAGS-"-O3"}
106 LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};;
107 SunOS\ 5*) SFLAGS=${CFLAGS-"-fast -xcg89 -KPIC -R."}
108 CFLAGS=${CFLAGS-"-fast -xcg89"}
109 LDSHARED=${LDSHARED-"cc -G"};;
110 SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
111 CFLAGS=${CFLAGS-"-O2"}
112 LDSHARED=${LDSHARED-"ld"};;
113 UNIX_System_V\ 4.2.0)
114 SFLAGS=${CFLAGS-"-KPIC -O"}
115 CFLAGS=${CFLAGS-"-O"}
116 LDSHARED=${LDSHARED-"cc -G"};;
118 SFLAGS=${CFLAGS-"-Kconform_pic -O"}
119 CFLAGS=${CFLAGS-"-O"}
120 LDSHARED=${LDSHARED-"cc -G"};;
121 # send working options for other systems to support@gzip.org
122 *) SFLAGS=${CFLAGS-"-O"}
123 CFLAGS=${CFLAGS-"-O"}
124 LDSHARED=${LDSHARED-"cc -shared"};;
128 if test $shared -eq 1; then
129 echo Checking for shared library support...
130 # we must test in two steps (cc then ld), required at least on SunOS 4.x
131 if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" &&
132 test "`($LDSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then
134 LIBS="$SHAREDLIB.$VER"
135 echo Building shared library $SHAREDLIB.$VER with $CC.
136 elif test -z "$old_cc" -a -z "$old_cflags"; then
137 echo No shared library suppport.
140 echo 'No shared library suppport; try without defining CC and CFLAGS'
144 if test $shared -eq 0; then
146 echo Building static library $LIBS version $VER with $CC.
151 int main() { return 0; }
153 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
154 CFLAGS="$CFLAGS -DHAVE_UNISTD_H"
155 echo "Checking for unistd.h... Yes."
157 echo "Checking for unistd.h... No."
162 int main() { return 0; }
164 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
165 echo "Checking for errno.h... Yes."
167 echo "Checking for errno.h... No."
168 CFLAGS="$CFLAGS -DNO_ERRNO_H"
172 #include <sys/types.h>
173 #include <sys/mman.h>
174 #include <sys/stat.h>
176 return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0);
179 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
180 CFLAGS="$CFLAGS -DUSE_MMAP"
181 echo Checking for mmap support... Yes.
183 echo Checking for mmap support... No.
189 if test "`nm $test.o | grep _hello`" = ""; then
190 CPP="$CPP -DNO_UNDERLINE"
191 echo Checking for underline in external names... No.
193 echo Checking for underline in external names... Yes.
197 rm -f $test.[co] $test$shared_ext
202 /^CFLAGS *=/s%=.*%=$CFLAGS%
203 /^CPP *=/s%=.*%=$CPP%
204 /^LDSHARED *=/s%=.*%=$LDSHARED%
205 /^LIBS *=/s%=.*%=$LIBS%
206 /^SHAREDLIB *=/s%=.*%=$SHAREDLIB%
208 /^RANLIB *=/s%=.*%=$RANLIB%
209 /^VER *=/s%=.*%=$VER%
210 /^prefix *=/s%=.*%=$prefix%
211 /^exec_prefix *=/s%=.*%=$exec_prefix%
212 /^libdir *=/s%=.*%=$libdir%
213 /^includedir *=/s%=.*%=$includedir%