source: trunk/third/zlib/configure @ 15211

Revision 15211, 6.5 KB checked in by ghudson, 24 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r15210, which included commits to RCS files with non-trunk default branches.
  • Property svn:executable set to *
Line 
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
21LIBS=libz.a
22SHAREDLIB=libz.so
23VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
24AR=${AR-"ar rc"}
25RANLIB=${RANLIB-"ranlib"}
26prefix=${prefix-/usr/local}
27exec_prefix=${exec_prefix-'${prefix}'}
28libdir=${libdir-'${exec_prefix}/lib'}
29includedir=${includedir-'${prefix}/include'}
30shared_ext='.so'
31shared=0
32gcc=0
33old_cc="$CC"
34old_cflags="$CFLAGS"
35
36while test $# -ge 1
37do
38case "$1" in
39    -h* | --h*)
40      echo 'usage:'
41      echo '  configure [--shared] [--prefix=PREFIX]  [--exec_prefix=EXPREFIX]'
42      echo '     [--libdir=LIBDIR] [--includedir=INCLUDEDIR]'
43        exit 0;;
44    -p*=* | --p*=*) prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
45    -e*=* | --e*=*) exec_prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
46    -l*=* | --libdir=*) libdir=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
47    -i*=* | --includedir=*) includedir=`echo $1 | sed 's/[-a-z_]*=//'`;shift;;
48    -p* | --p*) prefix="$2"; shift; shift;;
49    -e* | --e*) exec_prefix="$2"; shift; shift;;
50    -l* | --l*) libdir="$2"; shift; shift;;
51    -i* | --i*) includedir="$2"; shift; shift;;
52    -s* | --s*) shared=1; shift;;
53    esac
54done
55
56test=ztest$$
57cat > $test.c <<EOF
58extern int getchar();
59int hello() {return getchar();}
60EOF
61
62test -z "$CC" && echo Checking for gcc...
63cc=${CC-gcc}
64cflags=${CFLAGS-"-O3"}
65# to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
66case "$cc" in
67  *gcc*) gcc=1;;
68esac
69
70if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
71  CC="$cc"
72  SFLAGS=${CFLAGS-"-fPIC -O3"}
73  CFLAGS="$cflags"
74  case `(uname -s || echo unknown) 2>/dev/null` in
75  Linux | linux) LDSHARED=${LDSHARED-"gcc -shared -Wl,-soname,libz.so.1"};;
76  *)             LDSHARED=${LDSHARED-"gcc -shared"};;
77  esac
78else
79  # find system name and corresponding cc options
80  CC=${CC-cc}
81  case `(uname -sr || echo unknown) 2>/dev/null` in
82  HP-UX*)    SFLAGS=${CFLAGS-"-O +z"}
83             CFLAGS=${CFLAGS-"-O"}
84#            LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
85             LDSHARED=${LDSHARED-"ld -b"}
86             shared_ext='.sl'
87             SHAREDLIB='libz.sl';;
88  IRIX*)     SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
89             CFLAGS=${CFLAGS-"-ansi -O2"}
90             LDSHARED=${LDSHARED-"cc -shared"};;
91  OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
92             CFLAGS=${CFLAGS-"-O -std1"}
93             LDSHARED=${LDSHARED-"cc -shared  -Wl,-soname,$SHAREDLIB -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"};;
94  OSF1*)     SFLAGS=${CFLAGS-"-O -std1"}
95             CFLAGS=${CFLAGS-"-O -std1"}
96             LDSHARED=${LDSHARED-"cc -shared"};;
97  QNX*)      SFLAGS=${CFLAGS-"-4 -O"}
98             CFLAGS=${CFLAGS-"-4 -O"}
99             LDSHARED=${LDSHARED-"cc"}
100             RANLIB=${RANLIB-"true"}
101             AR="cc -A";;
102  SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
103             CFLAGS=${CFLAGS-"-O3"}
104             LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};;
105  SunOS\ 5*) SFLAGS=${CFLAGS-"-fast -xcg89 -KPIC -R."}
106             CFLAGS=${CFLAGS-"-fast -xcg89"}
107             LDSHARED=${LDSHARED-"cc -G"};;
108  SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
109             CFLAGS=${CFLAGS-"-O2"}
110             LDSHARED=${LDSHARED-"ld"};;
111  UNIX_System_V\ 4.2.0)
112             SFLAGS=${CFLAGS-"-KPIC -O"}
113             CFLAGS=${CFLAGS-"-O"}
114             LDSHARED=${LDSHARED-"cc -G"};;
115  UNIX_SV\ 4.2MP)
116             SFLAGS=${CFLAGS-"-Kconform_pic -O"}
117             CFLAGS=${CFLAGS-"-O"}
118             LDSHARED=${LDSHARED-"cc -G"};;
119  # send working options for other systems to support@gzip.org
120  *)         SFLAGS=${CFLAGS-"-O"}
121             CFLAGS=${CFLAGS-"-O"}
122             LDSHARED=${LDSHARED-"cc -shared"};;
123  esac
124fi
125
126if test $shared -eq 1; then
127  echo Checking for shared library support...
128  # we must test in two steps (cc then ld), required at least on SunOS 4.x
129  if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" &&
130     test "`($LDSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then
131    CFLAGS="$SFLAGS"
132    LIBS="$SHAREDLIB.$VER"
133    echo Building shared library $SHAREDLIB.$VER with $CC.
134  elif test -z "$old_cc" -a -z "$old_cflags"; then
135    echo No shared library suppport.
136    shared=0;
137  else
138    echo 'No shared library suppport; try without defining CC and CFLAGS'
139    shared=0;
140  fi
141fi
142if test $shared -eq 0; then
143  LDSHARED="$CC"
144  echo Building static library $LIBS version $VER with $CC.
145fi
146
147cat > $test.c <<EOF
148#include <unistd.h>
149int main() { return 0; }
150EOF
151if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
152  CFLAGS="$CFLAGS -DHAVE_UNISTD_H"
153  echo "Checking for unistd.h... Yes."
154else
155  echo "Checking for unistd.h... No."
156fi
157
158cat > $test.c <<EOF
159#include <errno.h>
160int main() { return 0; }
161EOF
162if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
163  echo "Checking for errno.h...  Yes."
164else
165  echo "Checking for errno.h...  No."
166  CFLAGS="$CFLAGS -DNO_ERRNO_H"
167fi
168
169cat > $test.c <<EOF
170#include <sys/types.h>
171#include <sys/mman.h>
172#include <sys/stat.h>
173caddr_t hello() {
174  return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0);
175}
176EOF
177if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
178  CFLAGS="$CFLAGS -DUSE_MMAP"
179  echo Checking for mmap support... Yes.
180else
181  echo Checking for mmap support... No.
182fi
183
184CPP=${CPP-"$CC -E"}
185case $CFLAGS in
186  *ASMV*)
187    if test "`nm $test.o | grep _hello`" = ""; then
188      CPP="$CPP -DNO_UNDERLINE"
189      echo Checking for underline in external names... No.
190    else
191      echo Checking for underline in external names... Yes.
192    fi;;
193esac
194
195rm -f $test.[co] $test$shared_ext
196
197# udpate Makefile
198sed < Makefile.in "
199/^CC *=/s%=.*%=$CC%
200/^CFLAGS *=/s%=.*%=$CFLAGS%
201/^CPP *=/s%=.*%=$CPP%
202/^LDSHARED *=/s%=.*%=$LDSHARED%
203/^LIBS *=/s%=.*%=$LIBS%
204/^SHAREDLIB *=/s%=.*%=$SHAREDLIB%
205/^AR *=/s%=.*%=$AR%
206/^RANLIB *=/s%=.*%=$RANLIB%
207/^VER *=/s%=.*%=$VER%
208/^prefix *=/s%=.*%=$prefix%
209/^exec_prefix *=/s%=.*%=$exec_prefix%
210/^libdir *=/s%=.*%=$libdir%
211/^includedir *=/s%=.*%=$includedir%
212" > Makefile
Note: See TracBrowser for help on using the repository browser.