]> git.lizzy.rs Git - zlib.git/blob - configure
zlib 0.99
[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 impose specific compiler or flags or install directory, use for example:
8 #    prefix=$HOME CC=cc CFLAGS="-O4" ./configure
9 # or for csh/tcsh users:
10 #    (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure)
11 # LDSHARED is the command to be used to create a shared library
12
13 LIBS=libz.a
14 VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
15 AR=${AR-"ar rc"}
16 prefix=${prefix-/usr/local}
17 exec_prefix=${exec_prefix-$prefix}
18
19 test -z "$CC" && echo Checking for gcc...
20 test=ztest$$
21 cat > $test.c <<EOF
22 int hello() { printf("hello\n"); }
23 EOF
24 if test -z "$CC" && (gcc -c -O3 $test.c) 2>/dev/null; then
25   CC=gcc
26   SFLAGS=${CFLAGS-"-fPIC -O3"}
27   CFLAGS=${CFLAGS-"-O3"}
28   LDSHARED=${LDSHARED-"gcc -shared"}
29 else
30   # find system name and corresponding cc options
31   CC=${CC-cc}
32   case `(uname -sr || echo unknown) 2>/dev/null` in
33   SunOS\ 5*) SFLAGS=${CFLAGS-"-fast -xcg89 -KPIC -R."}
34              CFLAGS=${CFLAGS-"-fast -xcg89"}
35              LDSHARED=${LDSHARED-"cc -G"};;
36   SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
37              CFLAGS=${CFLAGS-"-O2"}
38              LDSHARED=${LDSHARED-"ld"};;
39   IRIX*)     SFLAGS=${CFLAGS-"-O2 -rpath ."}
40              CFLAGS=${CFLAGS-"-O2"}
41              LDSHARED=${LDSHARED-"cc -shared"};;
42   QNX*)      SFLAGS=${CFLAGS-"-4 -O -Q"}
43              CFLAGS=${CFLAGS-"-4 -O -Q"}
44              LDSHARED=${LDSHARED-"cc"}
45              LIBS=zlib.lib
46              AR="cc -A";;
47   # send working options for other systems to gzip@prep.ai.mit.edu
48   *)         SFLAGS=${CFLAGS-"-O"}
49              CFLAGS=${CFLAGS-"-O"}
50              LDSHARED=${LDSHARED-"-shared"};;
51   esac
52 fi
53
54 echo Checking for shared library support...
55 # we must test in two steps (cc then ld), required at least on SunOS 4.x
56 if test "`$CC -c $SFLAGS $test.c 2>&1`" = "" &&
57    test "`$LDSHARED -o $test.so $test.o 2>&1`" = ""; then
58   CFLAGS="$SFLAGS"
59   LIBS='libz.so.$(VER)'
60   echo Building shared library libz.so.$VER with $CC.
61 else
62   LDSHARED="$CC"
63   echo Building static library $LIBS version $VER with $CC.
64 fi
65 rm -f $test.[co] $test.so
66
67 # udpate Makefile
68 # ed -s Makefile <<EOF
69 sed < Makefile.in "
70 /^CC *=/s/=.*/=$CC/
71 /^CFLAGS *=/s/=.*/=$CFLAGS/
72 /^LDSHARED *=/s/=.*/=$LDSHARED/
73 /^LIBS *=/s,=.*,=$LIBS,
74 /^AR *=/s/=.*/=$AR/
75 /^VER *=/s/=.*/=$VER/
76 /^prefix *=/s,=.*,=$prefix,
77 /^exec_prefix *=/s,=.*,=$exec_prefix,
78 " > Makefile
79 #w
80 #q
81 #EOF