Home | History | Annotate | Line # | Download | only in zlib
configure revision 1.1
      1  1.1  christos #!/bin/sh
      2  1.1  christos # configure script for zlib. This script is needed only if
      3  1.1  christos # you wish to build a shared library and your system supports them,
      4  1.1  christos # of if you need special compiler, flags or install directory.
      5  1.1  christos # Otherwise, you can just use directly "make test; make install"
      6  1.1  christos #
      7  1.1  christos # To create a shared library, use "configure --shared"; by default a static
      8  1.1  christos # library is created. If the primitive shared library support provided here
      9  1.1  christos # does not work, use ftp://prep.ai.mit.edu/pub/gnu/libtool-*.tar.gz
     10  1.1  christos #
     11  1.1  christos # To impose specific compiler or flags or install directory, use for example:
     12  1.1  christos #    prefix=$HOME CC=cc CFLAGS="-O4" ./configure
     13  1.1  christos # or for csh/tcsh users:
     14  1.1  christos #    (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure)
     15  1.1  christos # LDSHARED is the command to be used to create a shared library
     16  1.1  christos 
     17  1.1  christos # Incorrect settings of CC or CFLAGS may prevent creating a shared library.
     18  1.1  christos # If you have problems, try without defining CC and CFLAGS before reporting
     19  1.1  christos # an error.
     20  1.1  christos 
     21  1.1  christos LIBS=libz.a
     22  1.1  christos LDFLAGS="-L. ${LIBS}"
     23  1.1  christos VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
     24  1.1  christos VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h`
     25  1.1  christos VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h`
     26  1.1  christos AR=${AR-"ar rc"}
     27  1.1  christos RANLIB=${RANLIB-"ranlib"}
     28  1.1  christos prefix=${prefix-/usr/local}
     29  1.1  christos exec_prefix=${exec_prefix-'${prefix}'}
     30  1.1  christos libdir=${libdir-'${exec_prefix}/lib'}
     31  1.1  christos includedir=${includedir-'${prefix}/include'}
     32  1.1  christos mandir=${mandir-'${prefix}/share/man'}
     33  1.1  christos shared_ext='.so'
     34  1.1  christos shared=0
     35  1.1  christos gcc=0
     36  1.1  christos old_cc="$CC"
     37  1.1  christos old_cflags="$CFLAGS"
     38  1.1  christos 
     39  1.1  christos while test $# -ge 1
     40  1.1  christos do
     41  1.1  christos case "$1" in
     42  1.1  christos     -h* | --h*)
     43  1.1  christos       echo 'usage:'
     44  1.1  christos       echo '  configure [--shared] [--prefix=PREFIX]  [--exec_prefix=EXPREFIX]'
     45  1.1  christos       echo '     [--libdir=LIBDIR] [--includedir=INCLUDEDIR]'
     46  1.1  christos         exit 0;;
     47  1.1  christos     -p*=* | --p*=*) prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
     48  1.1  christos     -e*=* | --e*=*) exec_prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
     49  1.1  christos     -l*=* | --libdir=*) libdir=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
     50  1.1  christos     -i*=* | --includedir=*) includedir=`echo $1 | sed 's/[-a-z_]*=//'`;shift;;
     51  1.1  christos     -p* | --p*) prefix="$2"; shift; shift;;
     52  1.1  christos     -e* | --e*) exec_prefix="$2"; shift; shift;;
     53  1.1  christos     -l* | --l*) libdir="$2"; shift; shift;;
     54  1.1  christos     -i* | --i*) includedir="$2"; shift; shift;;
     55  1.1  christos     -s* | --s*) shared=1; shift;;
     56  1.1  christos     *) echo "unknown option: $1"; echo "$0 --help for help"; exit 1;;
     57  1.1  christos     esac
     58  1.1  christos done
     59  1.1  christos 
     60  1.1  christos test=ztest$$
     61  1.1  christos cat > $test.c <<EOF
     62  1.1  christos extern int getchar();
     63  1.1  christos int hello() {return getchar();}
     64  1.1  christos EOF
     65  1.1  christos 
     66  1.1  christos test -z "$CC" && echo Checking for gcc...
     67  1.1  christos cc=${CC-gcc}
     68  1.1  christos cflags=${CFLAGS-"-O3"}
     69  1.1  christos # to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
     70  1.1  christos case "$cc" in
     71  1.1  christos   *gcc*) gcc=1;;
     72  1.1  christos esac
     73  1.1  christos 
     74  1.1  christos if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
     75  1.1  christos   CC="$cc"
     76  1.1  christos   SFLAGS=${CFLAGS-"-fPIC -O3"}
     77  1.1  christos   CFLAGS="$cflags"
     78  1.1  christos   case `(uname -s || echo unknown) 2>/dev/null` in
     79  1.1  christos   Linux | linux | GNU | GNU/*) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1"};;
     80  1.1  christos   CYGWIN* | Cygwin* | cygwin* | OS/2* )
     81  1.1  christos              EXE='.exe';;
     82  1.1  christos   QNX*)  # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
     83  1.1  christos          # (alain.bonnefoy (at] icbt.com)
     84  1.1  christos                  LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"};;
     85  1.1  christos   HP-UX*)
     86  1.1  christos          LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
     87  1.1  christos          case `(uname -m || echo unknown) 2>/dev/null` in
     88  1.1  christos          ia64)
     89  1.1  christos                  shared_ext='.so'
     90  1.1  christos                  SHAREDLIB='libz.so';;
     91  1.1  christos          *)
     92  1.1  christos                  shared_ext='.sl'
     93  1.1  christos                  SHAREDLIB='libz.sl';;
     94  1.1  christos          esac;;
     95  1.1  christos   Darwin*)   shared_ext='.dylib'
     96  1.1  christos              SHAREDLIB=libz$shared_ext
     97  1.1  christos              SHAREDLIBV=libz.$VER$shared_ext
     98  1.1  christos              SHAREDLIBM=libz.$VER1$shared_ext
     99  1.1  christos              LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER"};;
    100  1.1  christos   *)             LDSHARED=${LDSHARED-"$cc -shared"};;
    101  1.1  christos   esac
    102  1.1  christos else
    103  1.1  christos   # find system name and corresponding cc options
    104  1.1  christos   CC=${CC-cc}
    105  1.1  christos   case `(uname -sr || echo unknown) 2>/dev/null` in
    106  1.1  christos   HP-UX*)    SFLAGS=${CFLAGS-"-O +z"}
    107  1.1  christos              CFLAGS=${CFLAGS-"-O"}
    108  1.1  christos #            LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
    109  1.1  christos              LDSHARED=${LDSHARED-"ld -b"}
    110  1.1  christos          case `(uname -m || echo unknown) 2>/dev/null` in
    111  1.1  christos          ia64)
    112  1.1  christos              shared_ext='.so'
    113  1.1  christos              SHAREDLIB='libz.so';;
    114  1.1  christos          *)
    115  1.1  christos              shared_ext='.sl'
    116  1.1  christos              SHAREDLIB='libz.sl';;
    117  1.1  christos          esac;;
    118  1.1  christos   IRIX*)     SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
    119  1.1  christos              CFLAGS=${CFLAGS-"-ansi -O2"}
    120  1.1  christos              LDSHARED=${LDSHARED-"cc -shared"};;
    121  1.1  christos   OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
    122  1.1  christos              CFLAGS=${CFLAGS-"-O -std1"}
    123  1.1  christos              LDSHARED=${LDSHARED-"cc -shared  -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"};;
    124  1.1  christos   OSF1*)     SFLAGS=${CFLAGS-"-O -std1"}
    125  1.1  christos              CFLAGS=${CFLAGS-"-O -std1"}
    126  1.1  christos              LDSHARED=${LDSHARED-"cc -shared"};;
    127  1.1  christos   QNX*)      SFLAGS=${CFLAGS-"-4 -O"}
    128  1.1  christos              CFLAGS=${CFLAGS-"-4 -O"}
    129  1.1  christos              LDSHARED=${LDSHARED-"cc"}
    130  1.1  christos              RANLIB=${RANLIB-"true"}
    131  1.1  christos              AR="cc -A";;
    132  1.1  christos   SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
    133  1.1  christos              CFLAGS=${CFLAGS-"-O3"}
    134  1.1  christos              LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};;
    135  1.1  christos   SunOS\ 5*) SFLAGS=${CFLAGS-"-fast -xcg89 -KPIC -R."}
    136  1.1  christos              CFLAGS=${CFLAGS-"-fast -xcg89"}
    137  1.1  christos              LDSHARED=${LDSHARED-"cc -G"};;
    138  1.1  christos   SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
    139  1.1  christos              CFLAGS=${CFLAGS-"-O2"}
    140  1.1  christos              LDSHARED=${LDSHARED-"ld"};;
    141  1.1  christos   SunStudio\ 9*) SFLAGS=${CFLAGS-"-DUSE_MMAP -fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
    142  1.1  christos              CFLAGS=${CFLAGS-"-DUSE_MMAP -fast -xtarget=ultra3 -xarch=v9b"}
    143  1.1  christos              LDSHARED=${LDSHARED-"cc -xarch=v9b"};;
    144  1.1  christos   UNIX_System_V\ 4.2.0)
    145  1.1  christos              SFLAGS=${CFLAGS-"-KPIC -O"}
    146  1.1  christos              CFLAGS=${CFLAGS-"-O"}
    147  1.1  christos              LDSHARED=${LDSHARED-"cc -G"};;
    148  1.1  christos   UNIX_SV\ 4.2MP)
    149  1.1  christos              SFLAGS=${CFLAGS-"-Kconform_pic -O"}
    150  1.1  christos              CFLAGS=${CFLAGS-"-O"}
    151  1.1  christos              LDSHARED=${LDSHARED-"cc -G"};;
    152  1.1  christos   OpenUNIX\ 5)
    153  1.1  christos              SFLAGS=${CFLAGS-"-KPIC -O"}
    154  1.1  christos              CFLAGS=${CFLAGS-"-O"}
    155  1.1  christos              LDSHARED=${LDSHARED-"cc -G"};;
    156  1.1  christos   AIX*)  # Courtesy of dbakker (at] arrayasolutions.com
    157  1.1  christos              SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
    158  1.1  christos              CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
    159  1.1  christos              LDSHARED=${LDSHARED-"xlc -G"};;
    160  1.1  christos   # send working options for other systems to support (at] gzip.org
    161  1.1  christos   *)         SFLAGS=${CFLAGS-"-O"}
    162  1.1  christos              CFLAGS=${CFLAGS-"-O"}
    163  1.1  christos              LDSHARED=${LDSHARED-"cc -shared"};;
    164  1.1  christos   esac
    165  1.1  christos fi
    166  1.1  christos 
    167  1.1  christos SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
    168  1.1  christos SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
    169  1.1  christos SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
    170  1.1  christos 
    171  1.1  christos if test $shared -eq 1; then
    172  1.1  christos   echo Checking for shared library support...
    173  1.1  christos   # we must test in two steps (cc then ld), required at least on SunOS 4.x
    174  1.1  christos   if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" &&
    175  1.1  christos      test "`($LDSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then
    176  1.1  christos     CFLAGS="$SFLAGS"
    177  1.1  christos     LIBS="$SHAREDLIBV"
    178  1.1  christos     echo Building shared library $SHAREDLIBV with $CC.
    179  1.1  christos   elif test -z "$old_cc" -a -z "$old_cflags"; then
    180  1.1  christos     echo No shared library support.
    181  1.1  christos     shared=0;
    182  1.1  christos   else
    183  1.1  christos     echo 'No shared library support; try without defining CC and CFLAGS'
    184  1.1  christos     shared=0;
    185  1.1  christos   fi
    186  1.1  christos fi
    187  1.1  christos if test $shared -eq 0; then
    188  1.1  christos   LDSHARED="$CC"
    189  1.1  christos   echo Building static library $LIBS version $VER with $CC.
    190  1.1  christos else
    191  1.1  christos   LDFLAGS="-L. ${SHAREDLIBV}"
    192  1.1  christos fi
    193  1.1  christos 
    194  1.1  christos cat > $test.c <<EOF
    195  1.1  christos #include <unistd.h>
    196  1.1  christos int main() { return 0; }
    197  1.1  christos EOF
    198  1.1  christos if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
    199  1.1  christos   sed < zconf.in.h "/HAVE_UNISTD_H/s%0%1%" > zconf.h
    200  1.1  christos   echo "Checking for unistd.h... Yes."
    201  1.1  christos else
    202  1.1  christos   cp -p zconf.in.h zconf.h
    203  1.1  christos   echo "Checking for unistd.h... No."
    204  1.1  christos fi
    205  1.1  christos 
    206  1.1  christos cat > $test.c <<EOF
    207  1.1  christos #include <stdio.h>
    208  1.1  christos #include <stdarg.h>
    209  1.1  christos #include "zconf.h"
    210  1.1  christos 
    211  1.1  christos int main()
    212  1.1  christos {
    213  1.1  christos #ifndef STDC
    214  1.1  christos   choke me
    215  1.1  christos #endif
    216  1.1  christos 
    217  1.1  christos   return 0;
    218  1.1  christos }
    219  1.1  christos EOF
    220  1.1  christos 
    221  1.1  christos if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
    222  1.1  christos   echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()"
    223  1.1  christos 
    224  1.1  christos   cat > $test.c <<EOF
    225  1.1  christos #include <stdio.h>
    226  1.1  christos #include <stdarg.h>
    227  1.1  christos 
    228  1.1  christos int mytest(char *fmt, ...)
    229  1.1  christos {
    230  1.1  christos   char buf[20];
    231  1.1  christos   va_list ap;
    232  1.1  christos 
    233  1.1  christos   va_start(ap, fmt);
    234  1.1  christos   vsnprintf(buf, sizeof(buf), fmt, ap);
    235  1.1  christos   va_end(ap);
    236  1.1  christos   return 0;
    237  1.1  christos }
    238  1.1  christos 
    239  1.1  christos int main()
    240  1.1  christos {
    241  1.1  christos   return (mytest("Hello%d\n", 1));
    242  1.1  christos }
    243  1.1  christos EOF
    244  1.1  christos 
    245  1.1  christos   if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
    246  1.1  christos     echo "Checking for vsnprintf() in stdio.h... Yes."
    247  1.1  christos 
    248  1.1  christos     cat >$test.c <<EOF
    249  1.1  christos #include <stdio.h>
    250  1.1  christos #include <stdarg.h>
    251  1.1  christos 
    252  1.1  christos int mytest(char *fmt, ...)
    253  1.1  christos {
    254  1.1  christos   int n;
    255  1.1  christos   char buf[20];
    256  1.1  christos   va_list ap;
    257  1.1  christos 
    258  1.1  christos   va_start(ap, fmt);
    259  1.1  christos   n = vsnprintf(buf, sizeof(buf), fmt, ap);
    260  1.1  christos   va_end(ap);
    261  1.1  christos   return n;
    262  1.1  christos }
    263  1.1  christos 
    264  1.1  christos int main()
    265  1.1  christos {
    266  1.1  christos   return (mytest("Hello%d\n", 1));
    267  1.1  christos }
    268  1.1  christos EOF
    269  1.1  christos 
    270  1.1  christos     if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
    271  1.1  christos       echo "Checking for return value of vsnprintf()... Yes."
    272  1.1  christos     else
    273  1.1  christos       CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
    274  1.1  christos       echo "Checking for return value of vsnprintf()... No."
    275  1.1  christos       echo "  WARNING: apparently vsnprintf() does not return a value. zlib"
    276  1.1  christos       echo "  can build but will be open to possible string-format security"
    277  1.1  christos       echo "  vulnerabilities."
    278  1.1  christos     fi
    279  1.1  christos   else
    280  1.1  christos     CFLAGS="$CFLAGS -DNO_vsnprintf"
    281  1.1  christos     echo "Checking for vsnprintf() in stdio.h... No."
    282  1.1  christos     echo "  WARNING: vsnprintf() not found, falling back to vsprintf(). zlib"
    283  1.1  christos     echo "  can build but will be open to possible buffer-overflow security"
    284  1.1  christos     echo "  vulnerabilities."
    285  1.1  christos 
    286  1.1  christos     cat >$test.c <<EOF
    287  1.1  christos #include <stdio.h>
    288  1.1  christos #include <stdarg.h>
    289  1.1  christos 
    290  1.1  christos int mytest(char *fmt, ...)
    291  1.1  christos {
    292  1.1  christos   int n;
    293  1.1  christos   char buf[20];
    294  1.1  christos   va_list ap;
    295  1.1  christos 
    296  1.1  christos   va_start(ap, fmt);
    297  1.1  christos   n = vsprintf(buf, fmt, ap);
    298  1.1  christos   va_end(ap);
    299  1.1  christos   return n;
    300  1.1  christos }
    301  1.1  christos 
    302  1.1  christos int main()
    303  1.1  christos {
    304  1.1  christos   return (mytest("Hello%d\n", 1));
    305  1.1  christos }
    306  1.1  christos EOF
    307  1.1  christos 
    308  1.1  christos     if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
    309  1.1  christos       echo "Checking for return value of vsprintf()... Yes."
    310  1.1  christos     else
    311  1.1  christos       CFLAGS="$CFLAGS -DHAS_vsprintf_void"
    312  1.1  christos       echo "Checking for return value of vsprintf()... No."
    313  1.1  christos       echo "  WARNING: apparently vsprintf() does not return a value. zlib"
    314  1.1  christos       echo "  can build but will be open to possible string-format security"
    315  1.1  christos       echo "  vulnerabilities."
    316  1.1  christos     fi
    317  1.1  christos   fi
    318  1.1  christos else
    319  1.1  christos   echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()"
    320  1.1  christos 
    321  1.1  christos   cat >$test.c <<EOF
    322  1.1  christos #include <stdio.h>
    323  1.1  christos 
    324  1.1  christos int mytest()
    325  1.1  christos {
    326  1.1  christos   char buf[20];
    327  1.1  christos 
    328  1.1  christos   snprintf(buf, sizeof(buf), "%s", "foo");
    329  1.1  christos   return 0;
    330  1.1  christos }
    331  1.1  christos 
    332  1.1  christos int main()
    333  1.1  christos {
    334  1.1  christos   return (mytest());
    335  1.1  christos }
    336  1.1  christos EOF
    337  1.1  christos 
    338  1.1  christos   if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
    339  1.1  christos     echo "Checking for snprintf() in stdio.h... Yes."
    340  1.1  christos 
    341  1.1  christos     cat >$test.c <<EOF
    342  1.1  christos #include <stdio.h>
    343  1.1  christos 
    344  1.1  christos int mytest()
    345  1.1  christos {
    346  1.1  christos   char buf[20];
    347  1.1  christos 
    348  1.1  christos   return snprintf(buf, sizeof(buf), "%s", "foo");
    349  1.1  christos }
    350  1.1  christos 
    351  1.1  christos int main()
    352  1.1  christos {
    353  1.1  christos   return (mytest());
    354  1.1  christos }
    355  1.1  christos EOF
    356  1.1  christos 
    357  1.1  christos     if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
    358  1.1  christos       echo "Checking for return value of snprintf()... Yes."
    359  1.1  christos     else
    360  1.1  christos       CFLAGS="$CFLAGS -DHAS_snprintf_void"
    361  1.1  christos       echo "Checking for return value of snprintf()... No."
    362  1.1  christos       echo "  WARNING: apparently snprintf() does not return a value. zlib"
    363  1.1  christos       echo "  can build but will be open to possible string-format security"
    364  1.1  christos       echo "  vulnerabilities."
    365  1.1  christos     fi
    366  1.1  christos   else
    367  1.1  christos     CFLAGS="$CFLAGS -DNO_snprintf"
    368  1.1  christos     echo "Checking for snprintf() in stdio.h... No."
    369  1.1  christos     echo "  WARNING: snprintf() not found, falling back to sprintf(). zlib"
    370  1.1  christos     echo "  can build but will be open to possible buffer-overflow security"
    371  1.1  christos     echo "  vulnerabilities."
    372  1.1  christos 
    373  1.1  christos     cat >$test.c <<EOF
    374  1.1  christos #include <stdio.h>
    375  1.1  christos 
    376  1.1  christos int mytest()
    377  1.1  christos {
    378  1.1  christos   char buf[20];
    379  1.1  christos 
    380  1.1  christos   return sprintf(buf, "%s", "foo");
    381  1.1  christos }
    382  1.1  christos 
    383  1.1  christos int main()
    384  1.1  christos {
    385  1.1  christos   return (mytest());
    386  1.1  christos }
    387  1.1  christos EOF
    388  1.1  christos 
    389  1.1  christos     if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
    390  1.1  christos       echo "Checking for return value of sprintf()... Yes."
    391  1.1  christos     else
    392  1.1  christos       CFLAGS="$CFLAGS -DHAS_sprintf_void"
    393  1.1  christos       echo "Checking for return value of sprintf()... No."
    394  1.1  christos       echo "  WARNING: apparently sprintf() does not return a value. zlib"
    395  1.1  christos       echo "  can build but will be open to possible string-format security"
    396  1.1  christos       echo "  vulnerabilities."
    397  1.1  christos     fi
    398  1.1  christos   fi
    399  1.1  christos fi
    400  1.1  christos 
    401  1.1  christos cat >$test.c <<EOF
    402  1.1  christos #include <errno.h>
    403  1.1  christos int main() { return 0; }
    404  1.1  christos EOF
    405  1.1  christos if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
    406  1.1  christos   echo "Checking for errno.h... Yes."
    407  1.1  christos else
    408  1.1  christos   echo "Checking for errno.h... No."
    409  1.1  christos   CFLAGS="$CFLAGS -DNO_ERRNO_H"
    410  1.1  christos fi
    411  1.1  christos 
    412  1.1  christos cat > $test.c <<EOF
    413  1.1  christos #include <sys/types.h>
    414  1.1  christos #include <sys/mman.h>
    415  1.1  christos #include <sys/stat.h>
    416  1.1  christos caddr_t hello() {
    417  1.1  christos   return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0);
    418  1.1  christos }
    419  1.1  christos EOF
    420  1.1  christos if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
    421  1.1  christos   CFLAGS="$CFLAGS -DUSE_MMAP"
    422  1.1  christos   echo Checking for mmap support... Yes.
    423  1.1  christos else
    424  1.1  christos   echo Checking for mmap support... No.
    425  1.1  christos fi
    426  1.1  christos 
    427  1.1  christos CPP=${CPP-"$CC -E"}
    428  1.1  christos case $CFLAGS in
    429  1.1  christos   *ASMV*)
    430  1.1  christos     if test "`nm $test.o | grep _hello`" = ""; then
    431  1.1  christos       CPP="$CPP -DNO_UNDERLINE"
    432  1.1  christos       echo Checking for underline in external names... No.
    433  1.1  christos     else
    434  1.1  christos       echo Checking for underline in external names... Yes.
    435  1.1  christos     fi;;
    436  1.1  christos esac
    437  1.1  christos 
    438  1.1  christos rm -f $test.[co] $test $test$shared_ext
    439  1.1  christos 
    440  1.1  christos # udpate Makefile
    441  1.1  christos sed < Makefile.in "
    442  1.1  christos /^CC *=/s#=.*#=$CC#
    443  1.1  christos /^CFLAGS *=/s#=.*#=$CFLAGS#
    444  1.1  christos /^CPP *=/s#=.*#=$CPP#
    445  1.1  christos /^LDSHARED *=/s#=.*#=$LDSHARED#
    446  1.1  christos /^LIBS *=/s#=.*#=$LIBS#
    447  1.1  christos /^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
    448  1.1  christos /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
    449  1.1  christos /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
    450  1.1  christos /^AR *=/s#=.*#=$AR#
    451  1.1  christos /^RANLIB *=/s#=.*#=$RANLIB#
    452  1.1  christos /^EXE *=/s#=.*#=$EXE#
    453  1.1  christos /^prefix *=/s#=.*#=$prefix#
    454  1.1  christos /^exec_prefix *=/s#=.*#=$exec_prefix#
    455  1.1  christos /^libdir *=/s#=.*#=$libdir#
    456  1.1  christos /^includedir *=/s#=.*#=$includedir#
    457  1.1  christos /^mandir *=/s#=.*#=$mandir#
    458  1.1  christos /^LDFLAGS *=/s#=.*#=$LDFLAGS#
    459  1.1  christos " > Makefile
    460