]> git.saurik.com Git - wxWidgets.git/blob - src/zlib/configure
corrected conditional compilation
[wxWidgets.git] / src / zlib / 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 # 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
19 # an error.
20
21 LIBS=libz.a
22 SHAREDLIB=libz.so
23 VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
24 AR=${AR-"ar rc"}
25 RANLIB=${RANLIB-"ranlib"}
26 prefix=${prefix-/usr/local}
27 shared_ext='.so'
28 shared=0
29 gcc=0
30 old_cc="$CC"
31 old_cflags="$CFLAGS"
32
33 case "$1" in
34 -h* | --h*) echo 'syntax: configure [ --shared ] [--prefix PREFIX]'; exit 0;;
35 -p*=* | --p*=*) prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
36 -p* | --p*) prefix="$2"; shift; shift;;
37 -s* | --s*) shared=1; shift;;
38 esac
39
40 test=ztest$$
41 cat > $test.c <<EOF
42 extern int getchar();
43 int hello() {return getchar();}
44 EOF
45
46 test -z "$CC" && echo Checking for gcc...
47 cc=${CC-gcc}
48 cflags=${CFLAGS-"-O3"}
49 case "$cc" in
50 *gcc*) gcc=1;;
51 esac
52
53 if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
54 CC="$cc"
55 SFLAGS=${CFLAGS-"-fPIC -O3"}
56 CFLAGS="$cflags"
57 case `(uname -s || echo unknown) 2>/dev/null` in
58 Linux | linux) LDSHARED=${LDSHARED-"gcc -shared -Wl,-soname,libz.so.1"};;
59 *) LDSHARED=${LDSHARED-"gcc -shared"};;
60 esac
61 else
62 # find system name and corresponding cc options
63 CC=${CC-cc}
64 case `(uname -sr || echo unknown) 2>/dev/null` in
65 HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
66 CFLAGS=${CFLAGS-"-O"}
67 # LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
68 LDSHARED=${LDSHARED-"ld -b"}
69 shared_ext='.sl'
70 SHAREDLIB='libz.sl';;
71 IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
72 CFLAGS=${CFLAGS-"-ansi -O2"}
73 LDSHARED=${LDSHARED-"cc -shared"};;
74 OSF1) SFLAGS=${CFLAGS-"-O -std1"}
75 CFLAGS=${CFLAGS-"-O -std1"}
76 LDSHARED=${LDSHARED-"cc -shared"};;
77 QNX*) SFLAGS=${CFLAGS-"-4 -O"}
78 CFLAGS=${CFLAGS-"-4 -O"}
79 LDSHARED=${LDSHARED-"cc"}
80 RANLIB=${RANLIB-"true"}
81 AR="cc -A";;
82 SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
83 CFLAGS=${CFLAGS-"-O3"}
84 LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};;
85 SunOS\ 5*) SFLAGS=${CFLAGS-"-fast -xcg89 -KPIC -R."}
86 CFLAGS=${CFLAGS-"-fast -xcg89"}
87 LDSHARED=${LDSHARED-"cc -G"};;
88 SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
89 CFLAGS=${CFLAGS-"-O2"}
90 LDSHARED=${LDSHARED-"ld"};;
91 UNIX_System_V\ 4.2.0)
92 SFLAGS=${CFLAGS-"-KPIC -O"}
93 CFLAGS=${CFLAGS-"-O"}
94 LDSHARED=${LDSHARED-"cc -G"};;
95 UNIX_SV\ 4.2MP)
96 SFLAGS=${CFLAGS-"-Kconform_pic -O"}
97 CFLAGS=${CFLAGS-"-O"}
98 LDSHARED=${LDSHARED-"cc -G"};;
99 # send working options for other systems to support@gzip.org
100 *) SFLAGS=${CFLAGS-"-O"}
101 CFLAGS=${CFLAGS-"-O"}
102 LDSHARED=${LDSHARED-"cc -shared"};;
103 esac
104 fi
105
106 if test $shared -eq 1; then
107 echo Checking for shared library support...
108 # we must test in two steps (cc then ld), required at least on SunOS 4.x
109 if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" &&
110 test "`($LDSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then
111 CFLAGS="$SFLAGS"
112 LIBS="$SHAREDLIB.$VER"
113 echo Building shared library $SHAREDLIB.$VER with $CC.
114 elif test -z "$old_cc" -a -z "$old_cflags"; then
115 echo No shared library suppport.
116 shared=0;
117 else
118 echo 'No shared library suppport; try without defining CC and CFLAGS'
119 shared=0;
120 fi
121 fi
122 if test $shared -eq 0; then
123 LDSHARED="$CC"
124 echo Building static library $LIBS version $VER with $CC.
125 fi
126
127 if test -f /usr/include/unistd.h; then
128 CFLAGS="$CFLAGS -DHAVE_UNISTD_H"
129 fi
130
131 if test ! -f /usr/include/errno.h; then
132 CFLAGS="$CFLAGS -DNO_ERRNO_H"
133 fi
134
135 cat > $test.c <<EOF
136 #include <sys/types.h>
137 #include <sys/mman.h>
138 #include <sys/stat.h>
139 caddr_t hello() {
140 return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0);
141 }
142 EOF
143 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
144 CFLAGS="$CFLAGS -DUSE_MMAP"
145 echo Checking for mmap support... Yes.
146 else
147 echo Checking for mmap support... No.
148 fi
149
150 rm -f $test.[co] $test$shared_ext
151
152 # udpate Makefile
153 sed < Makefile.in "
154 /^CC *=/s%=.*%=$CC%
155 /^CFLAGS *=/s%=.*%=$CFLAGS%
156 /^LDSHARED *=/s%=.*%=$LDSHARED%
157 /^LIBS *=/s%=.*%=$LIBS%
158 /^SHAREDLIB *=/s%=.*%=$SHAREDLIB%
159 /^AR *=/s%=.*%=$AR%
160 /^RANLIB *=/s%=.*%=$RANLIB%
161 /^VER *=/s%=.*%=$VER%
162 /^prefix *=/s%=.*%=$prefix%
163 " > Makefile