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
19 VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
21 RANLIB=${RANLIB-"ranlib"}
22 prefix=${prefix-/usr/local}
23 exec_prefix=${exec_prefix-$prefix}
28 -s* | --s*) shared=1; shift;;
29 -h* | --h*) echo 'syntax: configure [ --shared ]'; exit 0;;
32 test -z "$CC" && echo Checking for gcc...
35 int hello() { printf("hello\n"); }
37 if test -z "$CC" -o "$CC" = "gcc" && (gcc -c -O3 $test.c) 2>/dev/null; then
39 SFLAGS=${CFLAGS-"-fPIC -O3"}
40 CFLAGS=${CFLAGS-"-O3"}
41 case `(uname -s || echo unknown) 2>/dev/null` in
42 Linux | linux) LDSHARED=${LDSHARED-"gcc -shared -Wl,-soname,libz.so.1"};;
43 *) LDSHARED=${LDSHARED-"gcc -shared"};;
46 # find system name and corresponding cc options
48 case `(uname -sr || echo unknown) 2>/dev/null` in
49 SunOS\ 5*) SFLAGS=${CFLAGS-"-fast -xcg89 -KPIC -R."}
50 CFLAGS=${CFLAGS-"-fast -xcg89"}
51 LDSHARED=${LDSHARED-"cc -G"};;
52 SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
53 CFLAGS=${CFLAGS-"-O2"}
54 LDSHARED=${LDSHARED-"ld"};;
55 IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
56 CFLAGS=${CFLAGS-"-ansi -O2"}
57 LDSHARED=${LDSHARED-"cc -shared"};;
58 QNX*) SFLAGS=${CFLAGS-"-4 -O"}
59 CFLAGS=${CFLAGS-"-4 -O"}
60 LDSHARED=${LDSHARED-"cc"}
61 RANLIB=${RANLIB-"true"}
63 SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
64 CFLAGS=${CFLAGS-"-O3"}
65 LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};;
66 HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
68 LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
72 SFLAGS=${CFLAGS-"-KPIC -O"}
74 LDSHARED=${LDSHARED-"cc -G"};;
75 # send working options for other systems to support@gzip.org
76 *) SFLAGS=${CFLAGS-"-O"}
78 LDSHARED=${LDSHARED-"cc -shared"};;
82 if test $shared -eq 1; then
83 echo Checking for shared library support...
84 # we must test in two steps (cc then ld), required at least on SunOS 4.x
85 if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" &&
86 test "`($LDSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then
88 LIBS="$SHAREDLIB.$VER"
89 echo Building shared library $SHAREDLIB.$VER with $CC.
91 echo No shared library suppport.
95 if test $shared -eq 0; then
97 echo Building static library $LIBS version $VER with $CC.
99 rm -f $test.[co] $test$shared_ext
101 if test -f /usr/include/unistd.h; then
102 CFLAGS="$CFLAGS -DHAVE_UNISTD_H"
105 if test ! -f /usr/include/errno.h; then
106 CFLAGS="$CFLAGS -DNO_ERRNO_H"
112 /^CFLAGS *=/s/=.*/=$CFLAGS/
113 /^LDSHARED *=/s%=.*%=$LDSHARED%
114 /^LIBS *=/s,=.*,=$LIBS,
115 /^SHAREDLIB *=/s,=.*,=$SHAREDLIB,
117 /^RANLIB *=/s,=.*,=$RANLIB,
118 /^VER *=/s/=.*/=$VER/
119 /^prefix *=/s,=.*,=$prefix,
120 /^exec_prefix *=/s,=.*,=$exec_prefix,