]> git.lizzy.rs Git - zlib.git/blob - configure
zlib 1.0.7
[zlib.git] / configure
1 #!/bin/sh
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"
6 #
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
10 #
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
16
17 LIBS=libz.a
18 SHAREDLIB=libz.so
19 VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
20 AR=${AR-"ar rc"}
21 RANLIB=${RANLIB-"ranlib"}
22 prefix=${prefix-/usr/local}
23 exec_prefix=${exec_prefix-$prefix}
24 shared_ext='.so'
25 shared=0
26
27 case "$1" in
28   -s* | --s*) shared=1; shift;;
29   -h* | --h*) echo 'syntax: configure [ --shared ]'; exit 0;;
30 esac
31
32 test -z "$CC" && echo Checking for gcc...
33 test=ztest$$
34 cat > $test.c <<EOF
35 int hello() { printf("hello\n"); }
36 EOF
37 if test -z "$CC" -o "$CC" = "gcc" && (gcc -c -O3 $test.c) 2>/dev/null; then
38   CC=gcc
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"};;
44   esac
45 else
46   # find system name and corresponding cc options
47   CC=${CC-cc}
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"}
62              AR="cc -A";;
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"}
67              CFLAGS=${CFLAGS-"-O"}
68              LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
69              shared_ext='.sl'
70              SHAREDLIB='libz.sl';;
71   UNIX_System_V\ 4.2.0) 
72              SFLAGS=${CFLAGS-"-KPIC -O"}
73              CFLAGS=${CFLAGS-"-O"}
74              LDSHARED=${LDSHARED-"cc -G"};;
75   # send working options for other systems to support@gzip.org
76   *)         SFLAGS=${CFLAGS-"-O"}
77              CFLAGS=${CFLAGS-"-O"}
78              LDSHARED=${LDSHARED-"cc -shared"};;
79   esac
80 fi
81
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
87     CFLAGS="$SFLAGS"
88     LIBS="$SHAREDLIB.$VER"
89     echo Building shared library $SHAREDLIB.$VER with $CC.
90   else
91     echo No shared library suppport.
92     shared=0;
93   fi
94 fi
95 if test $shared -eq 0; then
96   LDSHARED="$CC"
97   echo Building static library $LIBS version $VER with $CC.
98 fi
99 rm -f $test.[co] $test$shared_ext
100
101 if test -f /usr/include/unistd.h; then
102   CFLAGS="$CFLAGS -DHAVE_UNISTD_H"
103 fi
104
105 if test ! -f /usr/include/errno.h; then
106   CFLAGS="$CFLAGS -DNO_ERRNO_H"
107 fi
108
109 # udpate Makefile
110 sed < Makefile.in "
111 /^CC *=/s,=.*,=$CC,
112 /^CFLAGS *=/s/=.*/=$CFLAGS/
113 /^LDSHARED *=/s%=.*%=$LDSHARED%
114 /^LIBS *=/s,=.*,=$LIBS,
115 /^SHAREDLIB *=/s,=.*,=$SHAREDLIB,
116 /^AR *=/s,=.*,=$AR,
117 /^RANLIB *=/s,=.*,=$RANLIB,
118 /^VER *=/s/=.*/=$VER/
119 /^prefix *=/s,=.*,=$prefix,
120 /^exec_prefix *=/s,=.*,=$exec_prefix,
121 " > Makefile