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 
  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 
  23 VER
=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h` 
  25 RANLIB
=${RANLIB-"ranlib"} 
  26 prefix
=${prefix-/usr/local} 
  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;; 
  43 int hello() {return getchar();} 
  46 test -z "$CC" && echo Checking 
for gcc...
 
  48 cflags
=${CFLAGS-"-O3"} 
  53 if test "$gcc" -eq 1 && ($cc -c $cflags $test.c
) 2>/dev
/null
; then 
  55   SFLAGS
=${CFLAGS-"-fPIC -O3"} 
  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"};; 
  62   # find system name and corresponding cc options 
  64   case `(uname -sr || echo unknown) 2>/dev/null` in 
  65   HP
-UX*)    SFLAGS
=${CFLAGS-"-O +z"} 
  67 #            LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"} 
  68              LDSHARED
=${LDSHARED-"ld -b"} 
  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"} 
  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"};; 
  92              SFLAGS
=${CFLAGS-"-KPIC -O"} 
  94              LDSHARED
=${LDSHARED-"cc -G"};; 
  96              SFLAGS
=${CFLAGS-"-Kconform_pic -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"};; 
 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 
 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.
 
 118     echo 'No shared library suppport; try without defining CC and CFLAGS' 
 122 if test $shared -eq 0; then 
 124   echo Building static library 
$LIBS version 
$VER with 
$CC.
 
 127 if test -f /usr
/include
/unistd.h
; then 
 128   CFLAGS
="$CFLAGS -DHAVE_UNISTD_H" 
 131 if test ! -f /usr
/include
/errno.h
; then 
 132   CFLAGS
="$CFLAGS -DNO_ERRNO_H" 
 136 #include <sys/types.h> 
 137 #include <sys/mman.h> 
 138 #include <sys/stat.h> 
 140   return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0);  
 143 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then 
 144   CFLAGS
="$CFLAGS -DUSE_MMAP" 
 145   echo Checking 
for mmap support... Yes.
 
 147   echo Checking 
for mmap support... No.
 
 150 rm -f $test.
[co
] $test$shared_ext 
 155 /^CFLAGS *=/s%=.*%=$CFLAGS% 
 156 /^LDSHARED *=/s%=.*%=$LDSHARED% 
 157 /^LIBS *=/s%=.*%=$LIBS% 
 158 /^SHAREDLIB *=/s%=.*%=$SHAREDLIB% 
 160 /^RANLIB *=/s%=.*%=$RANLIB% 
 161 /^VER *=/s%=.*%=$VER% 
 162 /^prefix *=/s%=.*%=$prefix%