external/zlib-1.2.11/configure
author Sam Lantinga <slouken@libsdl.org>
Fri, 26 Oct 2018 14:58:01 -0700
changeset 617 d64228a395fc
parent 521 9ed2f7d4a251
permissions -rwxr-xr-x
Fixed webp library detection when cross-compiling for Windows
slouken@521
     1
#!/bin/sh
slouken@521
     2
# configure script for zlib.
slouken@521
     3
#
slouken@521
     4
# Normally configure builds both a static and a shared library.
slouken@521
     5
# If you want to build just a static library, use: ./configure --static
slouken@521
     6
#
slouken@521
     7
# To impose specific compiler or flags or install directory, use for example:
slouken@521
     8
#    prefix=$HOME CC=cc CFLAGS="-O4" ./configure
slouken@521
     9
# or for csh/tcsh users:
slouken@521
    10
#    (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure)
slouken@521
    11
slouken@521
    12
# Incorrect settings of CC or CFLAGS may prevent creating a shared library.
slouken@521
    13
# If you have problems, try without defining CC and CFLAGS before reporting
slouken@521
    14
# an error.
slouken@521
    15
slouken@521
    16
# start off configure.log
slouken@521
    17
echo -------------------- >> configure.log
slouken@521
    18
echo $0 $* >> configure.log
slouken@521
    19
date >> configure.log
slouken@521
    20
slouken@521
    21
# get source directory
slouken@521
    22
SRCDIR=`dirname $0`
slouken@521
    23
if test $SRCDIR = "."; then
slouken@521
    24
    ZINC=""
slouken@521
    25
    ZINCOUT="-I."
slouken@521
    26
    SRCDIR=""
slouken@521
    27
else
slouken@521
    28
    ZINC='-include zconf.h'
slouken@521
    29
    ZINCOUT='-I. -I$(SRCDIR)'
slouken@521
    30
    SRCDIR="$SRCDIR/"
slouken@521
    31
fi
slouken@521
    32
slouken@521
    33
# set command prefix for cross-compilation
slouken@521
    34
if [ -n "${CHOST}" ]; then
slouken@521
    35
    uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`"
slouken@521
    36
    CROSS_PREFIX="${CHOST}-"
slouken@521
    37
fi
slouken@521
    38
slouken@521
    39
# destination name for static library
slouken@521
    40
STATICLIB=libz.a
slouken@521
    41
slouken@521
    42
# extract zlib version numbers from zlib.h
slouken@521
    43
VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}zlib.h`
slouken@521
    44
VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < ${SRCDIR}zlib.h`
slouken@521
    45
VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
slouken@521
    46
VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
slouken@521
    47
slouken@521
    48
# establish commands for library building
slouken@521
    49
if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then
slouken@521
    50
    AR=${AR-"${CROSS_PREFIX}ar"}
slouken@521
    51
    test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
slouken@521
    52
else
slouken@521
    53
    AR=${AR-"ar"}
slouken@521
    54
    test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
slouken@521
    55
fi
slouken@521
    56
ARFLAGS=${ARFLAGS-"rc"}
slouken@521
    57
if "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null || test $? -lt 126; then
slouken@521
    58
    RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"}
slouken@521
    59
    test -n "${CROSS_PREFIX}" && echo Using ${RANLIB} | tee -a configure.log
slouken@521
    60
else
slouken@521
    61
    RANLIB=${RANLIB-"ranlib"}
slouken@521
    62
fi
slouken@521
    63
if "${CROSS_PREFIX}nm" --version >/dev/null 2>/dev/null || test $? -lt 126; then
slouken@521
    64
    NM=${NM-"${CROSS_PREFIX}nm"}
slouken@521
    65
    test -n "${CROSS_PREFIX}" && echo Using ${NM} | tee -a configure.log
slouken@521
    66
else
slouken@521
    67
    NM=${NM-"nm"}
slouken@521
    68
fi
slouken@521
    69
slouken@521
    70
# set defaults before processing command line options
slouken@521
    71
LDCONFIG=${LDCONFIG-"ldconfig"}
slouken@521
    72
LDSHAREDLIBC="${LDSHAREDLIBC--lc}"
slouken@521
    73
ARCHS=
slouken@521
    74
prefix=${prefix-/usr/local}
slouken@521
    75
exec_prefix=${exec_prefix-'${prefix}'}
slouken@521
    76
libdir=${libdir-'${exec_prefix}/lib'}
slouken@521
    77
sharedlibdir=${sharedlibdir-'${libdir}'}
slouken@521
    78
includedir=${includedir-'${prefix}/include'}
slouken@521
    79
mandir=${mandir-'${prefix}/share/man'}
slouken@521
    80
shared_ext='.so'
slouken@521
    81
shared=1
slouken@521
    82
solo=0
slouken@521
    83
cover=0
slouken@521
    84
zprefix=0
slouken@521
    85
zconst=0
slouken@521
    86
build64=0
slouken@521
    87
gcc=0
slouken@521
    88
warn=0
slouken@521
    89
debug=0
slouken@521
    90
old_cc="$CC"
slouken@521
    91
old_cflags="$CFLAGS"
slouken@521
    92
OBJC='$(OBJZ) $(OBJG)'
slouken@521
    93
PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)'
slouken@521
    94
slouken@521
    95
# leave this script, optionally in a bad way
slouken@521
    96
leave()
slouken@521
    97
{
slouken@521
    98
  if test "$*" != "0"; then
slouken@521
    99
    echo "** $0 aborting." | tee -a configure.log
slouken@521
   100
  fi
slouken@521
   101
  rm -f $test.[co] $test $test$shared_ext $test.gcno ./--version
slouken@521
   102
  echo -------------------- >> configure.log
slouken@521
   103
  echo >> configure.log
slouken@521
   104
  echo >> configure.log
slouken@521
   105
  exit $1
slouken@521
   106
}
slouken@521
   107
slouken@521
   108
# process command line options
slouken@521
   109
while test $# -ge 1
slouken@521
   110
do
slouken@521
   111
case "$1" in
slouken@521
   112
    -h* | --help)
slouken@521
   113
      echo 'usage:' | tee -a configure.log
slouken@521
   114
      echo '  configure [--const] [--zprefix] [--prefix=PREFIX]  [--eprefix=EXPREFIX]' | tee -a configure.log
slouken@521
   115
      echo '    [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log
slouken@521
   116
      echo '    [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log
slouken@521
   117
        exit 0 ;;
slouken@521
   118
    -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;;
slouken@521
   119
    -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;;
slouken@521
   120
    -l*=* | --libdir=*) libdir=`echo $1 | sed 's/.*=//'`; shift ;;
slouken@521
   121
    --sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/.*=//'`; shift ;;
slouken@521
   122
    -i*=* | --includedir=*) includedir=`echo $1 | sed 's/.*=//'`;shift ;;
slouken@521
   123
    -u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;;
slouken@521
   124
    -p* | --prefix) prefix="$2"; shift; shift ;;
slouken@521
   125
    -e* | --eprefix) exec_prefix="$2"; shift; shift ;;
slouken@521
   126
    -l* | --libdir) libdir="$2"; shift; shift ;;
slouken@521
   127
    -i* | --includedir) includedir="$2"; shift; shift ;;
slouken@521
   128
    -s* | --shared | --enable-shared) shared=1; shift ;;
slouken@521
   129
    -t | --static) shared=0; shift ;;
slouken@521
   130
    --solo) solo=1; shift ;;
slouken@521
   131
    --cover) cover=1; shift ;;
slouken@521
   132
    -z* | --zprefix) zprefix=1; shift ;;
slouken@521
   133
    -6* | --64) build64=1; shift ;;
slouken@521
   134
    -a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
slouken@521
   135
    --sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;;
slouken@521
   136
    --localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;;
slouken@521
   137
    -c* | --const) zconst=1; shift ;;
slouken@521
   138
    -w* | --warn) warn=1; shift ;;
slouken@521
   139
    -d* | --debug) debug=1; shift ;;
slouken@521
   140
    *)
slouken@521
   141
      echo "unknown option: $1" | tee -a configure.log
slouken@521
   142
      echo "$0 --help for help" | tee -a configure.log
slouken@521
   143
      leave 1;;
slouken@521
   144
    esac
slouken@521
   145
done
slouken@521
   146
slouken@521
   147
# temporary file name
slouken@521
   148
test=ztest$$
slouken@521
   149
slouken@521
   150
# put arguments in log, also put test file in log if used in arguments
slouken@521
   151
show()
slouken@521
   152
{
slouken@521
   153
  case "$*" in
slouken@521
   154
    *$test.c*)
slouken@521
   155
      echo === $test.c === >> configure.log
slouken@521
   156
      cat $test.c >> configure.log
slouken@521
   157
      echo === >> configure.log;;
slouken@521
   158
  esac
slouken@521
   159
  echo $* >> configure.log
slouken@521
   160
}
slouken@521
   161
slouken@521
   162
# check for gcc vs. cc and set compile and link flags based on the system identified by uname
slouken@521
   163
cat > $test.c <<EOF
slouken@521
   164
extern int getchar();
slouken@521
   165
int hello() {return getchar();}
slouken@521
   166
EOF
slouken@521
   167
slouken@521
   168
test -z "$CC" && echo Checking for ${CROSS_PREFIX}gcc... | tee -a configure.log
slouken@521
   169
cc=${CC-${CROSS_PREFIX}gcc}
slouken@521
   170
cflags=${CFLAGS-"-O3"}
slouken@521
   171
# to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
slouken@521
   172
case "$cc" in
slouken@521
   173
  *gcc*) gcc=1 ;;
slouken@521
   174
  *clang*) gcc=1 ;;
slouken@521
   175
esac
slouken@521
   176
case `$cc -v 2>&1` in
slouken@521
   177
  *gcc*) gcc=1 ;;
slouken@521
   178
  *clang*) gcc=1 ;;
slouken@521
   179
esac
slouken@521
   180
slouken@521
   181
show $cc -c $test.c
slouken@521
   182
if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
slouken@521
   183
  echo ... using gcc >> configure.log
slouken@521
   184
  CC="$cc"
slouken@521
   185
  CFLAGS="${CFLAGS--O3}"
slouken@521
   186
  SFLAGS="${CFLAGS--O3} -fPIC"
slouken@521
   187
  if test "$ARCHS"; then
slouken@521
   188
    CFLAGS="${CFLAGS} ${ARCHS}"
slouken@521
   189
    LDFLAGS="${LDFLAGS} ${ARCHS}"
slouken@521
   190
  fi
slouken@521
   191
  if test $build64 -eq 1; then
slouken@521
   192
    CFLAGS="${CFLAGS} -m64"
slouken@521
   193
    SFLAGS="${SFLAGS} -m64"
slouken@521
   194
  fi
slouken@521
   195
  if test "$warn" -eq 1; then
slouken@521
   196
    if test "$zconst" -eq 1; then
slouken@521
   197
      CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -pedantic -DZLIB_CONST"
slouken@521
   198
    else
slouken@521
   199
      CFLAGS="${CFLAGS} -Wall -Wextra -pedantic"
slouken@521
   200
    fi
slouken@521
   201
  fi
slouken@521
   202
  if test $debug -eq 1; then
slouken@521
   203
    CFLAGS="${CFLAGS} -DZLIB_DEBUG"
slouken@521
   204
    SFLAGS="${SFLAGS} -DZLIB_DEBUG"
slouken@521
   205
  fi
slouken@521
   206
  if test -z "$uname"; then
slouken@521
   207
    uname=`(uname -s || echo unknown) 2>/dev/null`
slouken@521
   208
  fi
slouken@521
   209
  case "$uname" in
slouken@521
   210
  Linux* | linux* | GNU | GNU/* | solaris*)
slouken@521
   211
        LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;;
slouken@521
   212
  *BSD | *bsd* | DragonFly)
slouken@521
   213
        LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"}
slouken@521
   214
        LDCONFIG="ldconfig -m" ;;
slouken@521
   215
  CYGWIN* | Cygwin* | cygwin* | OS/2*)
slouken@521
   216
        EXE='.exe' ;;
slouken@521
   217
  MINGW* | mingw*)
slouken@521
   218
# temporary bypass
slouken@521
   219
        rm -f $test.[co] $test $test$shared_ext
slouken@521
   220
        echo "Please use win32/Makefile.gcc instead." | tee -a configure.log
slouken@521
   221
        leave 1
slouken@521
   222
        LDSHARED=${LDSHARED-"$cc -shared"}
slouken@521
   223
        LDSHAREDLIBC=""
slouken@521
   224
        EXE='.exe' ;;
slouken@521
   225
  QNX*)  # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
slouken@521
   226
         # (alain.bonnefoy@icbt.com)
slouken@521
   227
                 LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
slouken@521
   228
  HP-UX*)
slouken@521
   229
         LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
slouken@521
   230
         case `(uname -m || echo unknown) 2>/dev/null` in
slouken@521
   231
         ia64)
slouken@521
   232
                 shared_ext='.so'
slouken@521
   233
                 SHAREDLIB='libz.so' ;;
slouken@521
   234
         *)
slouken@521
   235
                 shared_ext='.sl'
slouken@521
   236
                 SHAREDLIB='libz.sl' ;;
slouken@521
   237
         esac ;;
slouken@521
   238
  Darwin* | darwin*)
slouken@521
   239
             shared_ext='.dylib'
slouken@521
   240
             SHAREDLIB=libz$shared_ext
slouken@521
   241
             SHAREDLIBV=libz.$VER$shared_ext
slouken@521
   242
             SHAREDLIBM=libz.$VER1$shared_ext
slouken@521
   243
             LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
slouken@521
   244
             if libtool -V 2>&1 | grep Apple > /dev/null; then
slouken@521
   245
                 AR="libtool"
slouken@521
   246
             else
slouken@521
   247
                 AR="/usr/bin/libtool"
slouken@521
   248
             fi
slouken@521
   249
             ARFLAGS="-o" ;;
slouken@521
   250
  *)             LDSHARED=${LDSHARED-"$cc -shared"} ;;
slouken@521
   251
  esac
slouken@521
   252
else
slouken@521
   253
  # find system name and corresponding cc options
slouken@521
   254
  CC=${CC-cc}
slouken@521
   255
  gcc=0
slouken@521
   256
  echo ... using $CC >> configure.log
slouken@521
   257
  if test -z "$uname"; then
slouken@521
   258
    uname=`(uname -sr || echo unknown) 2>/dev/null`
slouken@521
   259
  fi
slouken@521
   260
  case "$uname" in
slouken@521
   261
  HP-UX*)    SFLAGS=${CFLAGS-"-O +z"}
slouken@521
   262
             CFLAGS=${CFLAGS-"-O"}
slouken@521
   263
#            LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
slouken@521
   264
             LDSHARED=${LDSHARED-"ld -b"}
slouken@521
   265
         case `(uname -m || echo unknown) 2>/dev/null` in
slouken@521
   266
         ia64)
slouken@521
   267
             shared_ext='.so'
slouken@521
   268
             SHAREDLIB='libz.so' ;;
slouken@521
   269
         *)
slouken@521
   270
             shared_ext='.sl'
slouken@521
   271
             SHAREDLIB='libz.sl' ;;
slouken@521
   272
         esac ;;
slouken@521
   273
  IRIX*)     SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
slouken@521
   274
             CFLAGS=${CFLAGS-"-ansi -O2"}
slouken@521
   275
             LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
slouken@521
   276
  OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
slouken@521
   277
             CFLAGS=${CFLAGS-"-O -std1"}
slouken@521
   278
             LDFLAGS="${LDFLAGS} -Wl,-rpath,."
slouken@521
   279
             LDSHARED=${LDSHARED-"cc -shared  -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;;
slouken@521
   280
  OSF1*)     SFLAGS=${CFLAGS-"-O -std1"}
slouken@521
   281
             CFLAGS=${CFLAGS-"-O -std1"}
slouken@521
   282
             LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
slouken@521
   283
  QNX*)      SFLAGS=${CFLAGS-"-4 -O"}
slouken@521
   284
             CFLAGS=${CFLAGS-"-4 -O"}
slouken@521
   285
             LDSHARED=${LDSHARED-"cc"}
slouken@521
   286
             RANLIB=${RANLIB-"true"}
slouken@521
   287
             AR="cc"
slouken@521
   288
             ARFLAGS="-A" ;;
slouken@521
   289
  SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
slouken@521
   290
             CFLAGS=${CFLAGS-"-O3"}
slouken@521
   291
             LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;;
slouken@521
   292
  SunOS\ 5* | solaris*)
slouken@521
   293
         LDSHARED=${LDSHARED-"cc -G -h libz$shared_ext.$VER1"}
slouken@521
   294
         SFLAGS=${CFLAGS-"-fast -KPIC"}
slouken@521
   295
         CFLAGS=${CFLAGS-"-fast"}
slouken@521
   296
         if test $build64 -eq 1; then
slouken@521
   297
             # old versions of SunPRO/Workshop/Studio don't support -m64,
slouken@521
   298
             # but newer ones do.  Check for it.
slouken@521
   299
             flag64=`$CC -flags | egrep -- '^-m64'`
slouken@521
   300
             if test x"$flag64" != x"" ; then
slouken@521
   301
                 CFLAGS="${CFLAGS} -m64"
slouken@521
   302
                 SFLAGS="${SFLAGS} -m64"
slouken@521
   303
             else
slouken@521
   304
                 case `(uname -m || echo unknown) 2>/dev/null` in
slouken@521
   305
                   i86*)
slouken@521
   306
                     SFLAGS="$SFLAGS -xarch=amd64"
slouken@521
   307
                     CFLAGS="$CFLAGS -xarch=amd64" ;;
slouken@521
   308
                   *)
slouken@521
   309
                     SFLAGS="$SFLAGS -xarch=v9"
slouken@521
   310
                     CFLAGS="$CFLAGS -xarch=v9" ;;
slouken@521
   311
                 esac
slouken@521
   312
             fi
slouken@521
   313
         fi
slouken@521
   314
         if test -n "$ZINC"; then
slouken@521
   315
             ZINC='-I- -I. -I$(SRCDIR)'
slouken@521
   316
         fi
slouken@521
   317
         ;;
slouken@521
   318
  SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
slouken@521
   319
             CFLAGS=${CFLAGS-"-O2"}
slouken@521
   320
             LDSHARED=${LDSHARED-"ld"} ;;
slouken@521
   321
  SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
slouken@521
   322
             CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"}
slouken@521
   323
             LDSHARED=${LDSHARED-"cc -xarch=v9b"} ;;
slouken@521
   324
  UNIX_System_V\ 4.2.0)
slouken@521
   325
             SFLAGS=${CFLAGS-"-KPIC -O"}
slouken@521
   326
             CFLAGS=${CFLAGS-"-O"}
slouken@521
   327
             LDSHARED=${LDSHARED-"cc -G"} ;;
slouken@521
   328
  UNIX_SV\ 4.2MP)
slouken@521
   329
             SFLAGS=${CFLAGS-"-Kconform_pic -O"}
slouken@521
   330
             CFLAGS=${CFLAGS-"-O"}
slouken@521
   331
             LDSHARED=${LDSHARED-"cc -G"} ;;
slouken@521
   332
  OpenUNIX\ 5)
slouken@521
   333
             SFLAGS=${CFLAGS-"-KPIC -O"}
slouken@521
   334
             CFLAGS=${CFLAGS-"-O"}
slouken@521
   335
             LDSHARED=${LDSHARED-"cc -G"} ;;
slouken@521
   336
  AIX*)  # Courtesy of dbakker@arrayasolutions.com
slouken@521
   337
             SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
slouken@521
   338
             CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
slouken@521
   339
             LDSHARED=${LDSHARED-"xlc -G"} ;;
slouken@521
   340
  # send working options for other systems to zlib@gzip.org
slouken@521
   341
  *)         SFLAGS=${CFLAGS-"-O"}
slouken@521
   342
             CFLAGS=${CFLAGS-"-O"}
slouken@521
   343
             LDSHARED=${LDSHARED-"cc -shared"} ;;
slouken@521
   344
  esac
slouken@521
   345
fi
slouken@521
   346
slouken@521
   347
# destination names for shared library if not defined above
slouken@521
   348
SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
slouken@521
   349
SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
slouken@521
   350
SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
slouken@521
   351
slouken@521
   352
echo >> configure.log
slouken@521
   353
slouken@521
   354
# define functions for testing compiler and library characteristics and logging the results
slouken@521
   355
slouken@521
   356
cat > $test.c <<EOF
slouken@521
   357
#error error
slouken@521
   358
EOF
slouken@521
   359
if ($CC -c $CFLAGS $test.c) 2>/dev/null; then
slouken@521
   360
  try()
slouken@521
   361
  {
slouken@521
   362
    show $*
slouken@521
   363
    test "`( $* ) 2>&1 | tee -a configure.log`" = ""
slouken@521
   364
  }
slouken@521
   365
  echo - using any output from compiler to indicate an error >> configure.log
slouken@521
   366
else
slouken@521
   367
  try()
slouken@521
   368
  {
slouken@521
   369
    show $*
slouken@521
   370
    ( $* ) >> configure.log 2>&1
slouken@521
   371
    ret=$?
slouken@521
   372
    if test $ret -ne 0; then
slouken@521
   373
      echo "(exit code "$ret")" >> configure.log
slouken@521
   374
    fi
slouken@521
   375
    return $ret
slouken@521
   376
  }
slouken@521
   377
fi
slouken@521
   378
slouken@521
   379
tryboth()
slouken@521
   380
{
slouken@521
   381
  show $*
slouken@521
   382
  got=`( $* ) 2>&1`
slouken@521
   383
  ret=$?
slouken@521
   384
  printf %s "$got" >> configure.log
slouken@521
   385
  if test $ret -ne 0; then
slouken@521
   386
    return $ret
slouken@521
   387
  fi
slouken@521
   388
  test "$got" = ""
slouken@521
   389
}
slouken@521
   390
slouken@521
   391
cat > $test.c << EOF
slouken@521
   392
int foo() { return 0; }
slouken@521
   393
EOF
slouken@521
   394
echo "Checking for obsessive-compulsive compiler options..." >> configure.log
slouken@521
   395
if try $CC -c $CFLAGS $test.c; then
slouken@521
   396
  :
slouken@521
   397
else
slouken@521
   398
  echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log
slouken@521
   399
  leave 1
slouken@521
   400
fi
slouken@521
   401
slouken@521
   402
echo >> configure.log
slouken@521
   403
slouken@521
   404
# see if shared library build supported
slouken@521
   405
cat > $test.c <<EOF
slouken@521
   406
extern int getchar();
slouken@521
   407
int hello() {return getchar();}
slouken@521
   408
EOF
slouken@521
   409
if test $shared -eq 1; then
slouken@521
   410
  echo Checking for shared library support... | tee -a configure.log
slouken@521
   411
  # we must test in two steps (cc then ld), required at least on SunOS 4.x
slouken@521
   412
  if try $CC -w -c $SFLAGS $test.c &&
slouken@521
   413
     try $LDSHARED $SFLAGS -o $test$shared_ext $test.o; then
slouken@521
   414
    echo Building shared library $SHAREDLIBV with $CC. | tee -a configure.log
slouken@521
   415
  elif test -z "$old_cc" -a -z "$old_cflags"; then
slouken@521
   416
    echo No shared library support. | tee -a configure.log
slouken@521
   417
    shared=0;
slouken@521
   418
  else
slouken@521
   419
    echo 'No shared library support; try without defining CC and CFLAGS' | tee -a configure.log
slouken@521
   420
    shared=0;
slouken@521
   421
  fi
slouken@521
   422
fi
slouken@521
   423
if test $shared -eq 0; then
slouken@521
   424
  LDSHARED="$CC"
slouken@521
   425
  ALL="static"
slouken@521
   426
  TEST="all teststatic"
slouken@521
   427
  SHAREDLIB=""
slouken@521
   428
  SHAREDLIBV=""
slouken@521
   429
  SHAREDLIBM=""
slouken@521
   430
  echo Building static library $STATICLIB version $VER with $CC. | tee -a configure.log
slouken@521
   431
else
slouken@521
   432
  ALL="static shared"
slouken@521
   433
  TEST="all teststatic testshared"
slouken@521
   434
fi
slouken@521
   435
slouken@521
   436
# check for underscores in external names for use by assembler code
slouken@521
   437
CPP=${CPP-"$CC -E"}
slouken@521
   438
case $CFLAGS in
slouken@521
   439
  *ASMV*)
slouken@521
   440
    echo >> configure.log
slouken@521
   441
    show "$NM $test.o | grep _hello"
slouken@521
   442
    if test "`$NM $test.o | grep _hello | tee -a configure.log`" = ""; then
slouken@521
   443
      CPP="$CPP -DNO_UNDERLINE"
slouken@521
   444
      echo Checking for underline in external names... No. | tee -a configure.log
slouken@521
   445
    else
slouken@521
   446
      echo Checking for underline in external names... Yes. | tee -a configure.log
slouken@521
   447
    fi ;;
slouken@521
   448
esac
slouken@521
   449
slouken@521
   450
echo >> configure.log
slouken@521
   451
slouken@521
   452
# check for size_t
slouken@521
   453
cat > $test.c <<EOF
slouken@521
   454
#include <stdio.h>
slouken@521
   455
#include <stdlib.h>
slouken@521
   456
size_t dummy = 0;
slouken@521
   457
EOF
slouken@521
   458
if try $CC -c $CFLAGS $test.c; then
slouken@521
   459
  echo "Checking for size_t... Yes." | tee -a configure.log
slouken@521
   460
  need_sizet=0
slouken@521
   461
else
slouken@521
   462
  echo "Checking for size_t... No." | tee -a configure.log
slouken@521
   463
  need_sizet=1
slouken@521
   464
fi
slouken@521
   465
slouken@521
   466
echo >> configure.log
slouken@521
   467
slouken@521
   468
# find the size_t integer type, if needed
slouken@521
   469
if test $need_sizet -eq 1; then
slouken@521
   470
  cat > $test.c <<EOF
slouken@521
   471
long long dummy = 0;
slouken@521
   472
EOF
slouken@521
   473
  if try $CC -c $CFLAGS $test.c; then
slouken@521
   474
    echo "Checking for long long... Yes." | tee -a configure.log
slouken@521
   475
    cat > $test.c <<EOF
slouken@521
   476
#include <stdio.h>
slouken@521
   477
int main(void) {
slouken@521
   478
    if (sizeof(void *) <= sizeof(int)) puts("int");
slouken@521
   479
    else if (sizeof(void *) <= sizeof(long)) puts("long");
slouken@521
   480
    else puts("z_longlong");
slouken@521
   481
    return 0;
slouken@521
   482
}
slouken@521
   483
EOF
slouken@521
   484
  else
slouken@521
   485
    echo "Checking for long long... No." | tee -a configure.log
slouken@521
   486
    cat > $test.c <<EOF
slouken@521
   487
#include <stdio.h>
slouken@521
   488
int main(void) {
slouken@521
   489
    if (sizeof(void *) <= sizeof(int)) puts("int");
slouken@521
   490
    else puts("long");
slouken@521
   491
    return 0;
slouken@521
   492
}
slouken@521
   493
EOF
slouken@521
   494
  fi
slouken@521
   495
  if try $CC $CFLAGS -o $test $test.c; then
slouken@521
   496
    sizet=`./$test`
slouken@521
   497
    echo "Checking for a pointer-size integer type..." $sizet"." | tee -a configure.log
slouken@521
   498
  else
slouken@521
   499
    echo "Failed to find a pointer-size integer type." | tee -a configure.log
slouken@521
   500
    leave 1
slouken@521
   501
  fi
slouken@521
   502
fi
slouken@521
   503
slouken@521
   504
if test $need_sizet -eq 1; then
slouken@521
   505
  CFLAGS="${CFLAGS} -DNO_SIZE_T=${sizet}"
slouken@521
   506
  SFLAGS="${SFLAGS} -DNO_SIZE_T=${sizet}"
slouken@521
   507
fi
slouken@521
   508
slouken@521
   509
echo >> configure.log
slouken@521
   510
slouken@521
   511
# check for large file support, and if none, check for fseeko()
slouken@521
   512
cat > $test.c <<EOF
slouken@521
   513
#include <sys/types.h>
slouken@521
   514
off64_t dummy = 0;
slouken@521
   515
EOF
slouken@521
   516
if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then
slouken@521
   517
  CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1"
slouken@521
   518
  SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1"
slouken@521
   519
  ALL="${ALL} all64"
slouken@521
   520
  TEST="${TEST} test64"
slouken@521
   521
  echo "Checking for off64_t... Yes." | tee -a configure.log
slouken@521
   522
  echo "Checking for fseeko... Yes." | tee -a configure.log
slouken@521
   523
else
slouken@521
   524
  echo "Checking for off64_t... No." | tee -a configure.log
slouken@521
   525
  echo >> configure.log
slouken@521
   526
  cat > $test.c <<EOF
slouken@521
   527
#include <stdio.h>
slouken@521
   528
int main(void) {
slouken@521
   529
  fseeko(NULL, 0, 0);
slouken@521
   530
  return 0;
slouken@521
   531
}
slouken@521
   532
EOF
slouken@521
   533
  if try $CC $CFLAGS -o $test $test.c; then
slouken@521
   534
    echo "Checking for fseeko... Yes." | tee -a configure.log
slouken@521
   535
  else
slouken@521
   536
    CFLAGS="${CFLAGS} -DNO_FSEEKO"
slouken@521
   537
    SFLAGS="${SFLAGS} -DNO_FSEEKO"
slouken@521
   538
    echo "Checking for fseeko... No." | tee -a configure.log
slouken@521
   539
  fi
slouken@521
   540
fi
slouken@521
   541
slouken@521
   542
echo >> configure.log
slouken@521
   543
slouken@521
   544
# check for strerror() for use by gz* functions
slouken@521
   545
cat > $test.c <<EOF
slouken@521
   546
#include <string.h>
slouken@521
   547
#include <errno.h>
slouken@521
   548
int main() { return strlen(strerror(errno)); }
slouken@521
   549
EOF
slouken@521
   550
if try $CC $CFLAGS -o $test $test.c; then
slouken@521
   551
  echo "Checking for strerror... Yes." | tee -a configure.log
slouken@521
   552
else
slouken@521
   553
  CFLAGS="${CFLAGS} -DNO_STRERROR"
slouken@521
   554
  SFLAGS="${SFLAGS} -DNO_STRERROR"
slouken@521
   555
  echo "Checking for strerror... No." | tee -a configure.log
slouken@521
   556
fi
slouken@521
   557
slouken@521
   558
# copy clean zconf.h for subsequent edits
slouken@521
   559
cp -p ${SRCDIR}zconf.h.in zconf.h
slouken@521
   560
slouken@521
   561
echo >> configure.log
slouken@521
   562
slouken@521
   563
# check for unistd.h and save result in zconf.h
slouken@521
   564
cat > $test.c <<EOF
slouken@521
   565
#include <unistd.h>
slouken@521
   566
int main() { return 0; }
slouken@521
   567
EOF
slouken@521
   568
if try $CC -c $CFLAGS $test.c; then
slouken@521
   569
  sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
slouken@521
   570
  mv zconf.temp.h zconf.h
slouken@521
   571
  echo "Checking for unistd.h... Yes." | tee -a configure.log
slouken@521
   572
else
slouken@521
   573
  echo "Checking for unistd.h... No." | tee -a configure.log
slouken@521
   574
fi
slouken@521
   575
slouken@521
   576
echo >> configure.log
slouken@521
   577
slouken@521
   578
# check for stdarg.h and save result in zconf.h
slouken@521
   579
cat > $test.c <<EOF
slouken@521
   580
#include <stdarg.h>
slouken@521
   581
int main() { return 0; }
slouken@521
   582
EOF
slouken@521
   583
if try $CC -c $CFLAGS $test.c; then
slouken@521
   584
  sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
slouken@521
   585
  mv zconf.temp.h zconf.h
slouken@521
   586
  echo "Checking for stdarg.h... Yes." | tee -a configure.log
slouken@521
   587
else
slouken@521
   588
  echo "Checking for stdarg.h... No." | tee -a configure.log
slouken@521
   589
fi
slouken@521
   590
slouken@521
   591
# if the z_ prefix was requested, save that in zconf.h
slouken@521
   592
if test $zprefix -eq 1; then
slouken@521
   593
  sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h
slouken@521
   594
  mv zconf.temp.h zconf.h
slouken@521
   595
  echo >> configure.log
slouken@521
   596
  echo "Using z_ prefix on all symbols." | tee -a configure.log
slouken@521
   597
fi
slouken@521
   598
slouken@521
   599
# if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists
slouken@521
   600
if test $solo -eq 1; then
slouken@521
   601
  sed '/#define ZCONF_H/a\
slouken@521
   602
#define Z_SOLO
slouken@521
   603
slouken@521
   604
' < zconf.h > zconf.temp.h
slouken@521
   605
  mv zconf.temp.h zconf.h
slouken@521
   606
OBJC='$(OBJZ)'
slouken@521
   607
PIC_OBJC='$(PIC_OBJZ)'
slouken@521
   608
fi
slouken@521
   609
slouken@521
   610
# if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
slouken@521
   611
if test $cover -eq 1; then
slouken@521
   612
  CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
slouken@521
   613
  if test -n "$GCC_CLASSIC"; then
slouken@521
   614
    CC=$GCC_CLASSIC
slouken@521
   615
  fi
slouken@521
   616
fi
slouken@521
   617
slouken@521
   618
echo >> configure.log
slouken@521
   619
slouken@521
   620
# conduct a series of tests to resolve eight possible cases of using "vs" or "s" printf functions
slouken@521
   621
# (using stdarg or not), with or without "n" (proving size of buffer), and with or without a
slouken@521
   622
# return value.  The most secure result is vsnprintf() with a return value.  snprintf() with a
slouken@521
   623
# return value is secure as well, but then gzprintf() will be limited to 20 arguments.
slouken@521
   624
cat > $test.c <<EOF
slouken@521
   625
#include <stdio.h>
slouken@521
   626
#include <stdarg.h>
slouken@521
   627
#include "zconf.h"
slouken@521
   628
int main()
slouken@521
   629
{
slouken@521
   630
#ifndef STDC
slouken@521
   631
  choke me
slouken@521
   632
#endif
slouken@521
   633
  return 0;
slouken@521
   634
}
slouken@521
   635
EOF
slouken@521
   636
if try $CC -c $CFLAGS $test.c; then
slouken@521
   637
  echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." | tee -a configure.log
slouken@521
   638
slouken@521
   639
  echo >> configure.log
slouken@521
   640
  cat > $test.c <<EOF
slouken@521
   641
#include <stdio.h>
slouken@521
   642
#include <stdarg.h>
slouken@521
   643
int mytest(const char *fmt, ...)
slouken@521
   644
{
slouken@521
   645
  char buf[20];
slouken@521
   646
  va_list ap;
slouken@521
   647
  va_start(ap, fmt);
slouken@521
   648
  vsnprintf(buf, sizeof(buf), fmt, ap);
slouken@521
   649
  va_end(ap);
slouken@521
   650
  return 0;
slouken@521
   651
}
slouken@521
   652
int main()
slouken@521
   653
{
slouken@521
   654
  return (mytest("Hello%d\n", 1));
slouken@521
   655
}
slouken@521
   656
EOF
slouken@521
   657
  if try $CC $CFLAGS -o $test $test.c; then
slouken@521
   658
    echo "Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log
slouken@521
   659
slouken@521
   660
    echo >> configure.log
slouken@521
   661
    cat >$test.c <<EOF
slouken@521
   662
#include <stdio.h>
slouken@521
   663
#include <stdarg.h>
slouken@521
   664
int mytest(const char *fmt, ...)
slouken@521
   665
{
slouken@521
   666
  int n;
slouken@521
   667
  char buf[20];
slouken@521
   668
  va_list ap;
slouken@521
   669
  va_start(ap, fmt);
slouken@521
   670
  n = vsnprintf(buf, sizeof(buf), fmt, ap);
slouken@521
   671
  va_end(ap);
slouken@521
   672
  return n;
slouken@521
   673
}
slouken@521
   674
int main()
slouken@521
   675
{
slouken@521
   676
  return (mytest("Hello%d\n", 1));
slouken@521
   677
}
slouken@521
   678
EOF
slouken@521
   679
slouken@521
   680
    if try $CC -c $CFLAGS $test.c; then
slouken@521
   681
      echo "Checking for return value of vsnprintf()... Yes." | tee -a configure.log
slouken@521
   682
    else
slouken@521
   683
      CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
slouken@521
   684
      SFLAGS="$SFLAGS -DHAS_vsnprintf_void"
slouken@521
   685
      echo "Checking for return value of vsnprintf()... No." | tee -a configure.log
slouken@521
   686
      echo "  WARNING: apparently vsnprintf() does not return a value. zlib" | tee -a configure.log
slouken@521
   687
      echo "  can build but will be open to possible string-format security" | tee -a configure.log
slouken@521
   688
      echo "  vulnerabilities." | tee -a configure.log
slouken@521
   689
    fi
slouken@521
   690
  else
slouken@521
   691
    CFLAGS="$CFLAGS -DNO_vsnprintf"
slouken@521
   692
    SFLAGS="$SFLAGS -DNO_vsnprintf"
slouken@521
   693
    echo "Checking for vsnprintf() in stdio.h... No." | tee -a configure.log
slouken@521
   694
    echo "  WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log
slouken@521
   695
    echo "  can build but will be open to possible buffer-overflow security" | tee -a configure.log
slouken@521
   696
    echo "  vulnerabilities." | tee -a configure.log
slouken@521
   697
slouken@521
   698
    echo >> configure.log
slouken@521
   699
    cat >$test.c <<EOF
slouken@521
   700
#include <stdio.h>
slouken@521
   701
#include <stdarg.h>
slouken@521
   702
int mytest(const char *fmt, ...)
slouken@521
   703
{
slouken@521
   704
  int n;
slouken@521
   705
  char buf[20];
slouken@521
   706
  va_list ap;
slouken@521
   707
  va_start(ap, fmt);
slouken@521
   708
  n = vsprintf(buf, fmt, ap);
slouken@521
   709
  va_end(ap);
slouken@521
   710
  return n;
slouken@521
   711
}
slouken@521
   712
int main()
slouken@521
   713
{
slouken@521
   714
  return (mytest("Hello%d\n", 1));
slouken@521
   715
}
slouken@521
   716
EOF
slouken@521
   717
slouken@521
   718
    if try $CC -c $CFLAGS $test.c; then
slouken@521
   719
      echo "Checking for return value of vsprintf()... Yes." | tee -a configure.log
slouken@521
   720
    else
slouken@521
   721
      CFLAGS="$CFLAGS -DHAS_vsprintf_void"
slouken@521
   722
      SFLAGS="$SFLAGS -DHAS_vsprintf_void"
slouken@521
   723
      echo "Checking for return value of vsprintf()... No." | tee -a configure.log
slouken@521
   724
      echo "  WARNING: apparently vsprintf() does not return a value. zlib" | tee -a configure.log
slouken@521
   725
      echo "  can build but will be open to possible string-format security" | tee -a configure.log
slouken@521
   726
      echo "  vulnerabilities." | tee -a configure.log
slouken@521
   727
    fi
slouken@521
   728
  fi
slouken@521
   729
else
slouken@521
   730
  echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." | tee -a configure.log
slouken@521
   731
slouken@521
   732
  echo >> configure.log
slouken@521
   733
  cat >$test.c <<EOF
slouken@521
   734
#include <stdio.h>
slouken@521
   735
int mytest()
slouken@521
   736
{
slouken@521
   737
  char buf[20];
slouken@521
   738
  snprintf(buf, sizeof(buf), "%s", "foo");
slouken@521
   739
  return 0;
slouken@521
   740
}
slouken@521
   741
int main()
slouken@521
   742
{
slouken@521
   743
  return (mytest());
slouken@521
   744
}
slouken@521
   745
EOF
slouken@521
   746
slouken@521
   747
  if try $CC $CFLAGS -o $test $test.c; then
slouken@521
   748
    echo "Checking for snprintf() in stdio.h... Yes." | tee -a configure.log
slouken@521
   749
slouken@521
   750
    echo >> configure.log
slouken@521
   751
    cat >$test.c <<EOF
slouken@521
   752
#include <stdio.h>
slouken@521
   753
int mytest()
slouken@521
   754
{
slouken@521
   755
  char buf[20];
slouken@521
   756
  return snprintf(buf, sizeof(buf), "%s", "foo");
slouken@521
   757
}
slouken@521
   758
int main()
slouken@521
   759
{
slouken@521
   760
  return (mytest());
slouken@521
   761
}
slouken@521
   762
EOF
slouken@521
   763
slouken@521
   764
    if try $CC -c $CFLAGS $test.c; then
slouken@521
   765
      echo "Checking for return value of snprintf()... Yes." | tee -a configure.log
slouken@521
   766
    else
slouken@521
   767
      CFLAGS="$CFLAGS -DHAS_snprintf_void"
slouken@521
   768
      SFLAGS="$SFLAGS -DHAS_snprintf_void"
slouken@521
   769
      echo "Checking for return value of snprintf()... No." | tee -a configure.log
slouken@521
   770
      echo "  WARNING: apparently snprintf() does not return a value. zlib" | tee -a configure.log
slouken@521
   771
      echo "  can build but will be open to possible string-format security" | tee -a configure.log
slouken@521
   772
      echo "  vulnerabilities." | tee -a configure.log
slouken@521
   773
    fi
slouken@521
   774
  else
slouken@521
   775
    CFLAGS="$CFLAGS -DNO_snprintf"
slouken@521
   776
    SFLAGS="$SFLAGS -DNO_snprintf"
slouken@521
   777
    echo "Checking for snprintf() in stdio.h... No." | tee -a configure.log
slouken@521
   778
    echo "  WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log
slouken@521
   779
    echo "  can build but will be open to possible buffer-overflow security" | tee -a configure.log
slouken@521
   780
    echo "  vulnerabilities." | tee -a configure.log
slouken@521
   781
slouken@521
   782
    echo >> configure.log
slouken@521
   783
    cat >$test.c <<EOF
slouken@521
   784
#include <stdio.h>
slouken@521
   785
int mytest()
slouken@521
   786
{
slouken@521
   787
  char buf[20];
slouken@521
   788
  return sprintf(buf, "%s", "foo");
slouken@521
   789
}
slouken@521
   790
int main()
slouken@521
   791
{
slouken@521
   792
  return (mytest());
slouken@521
   793
}
slouken@521
   794
EOF
slouken@521
   795
slouken@521
   796
    if try $CC -c $CFLAGS $test.c; then
slouken@521
   797
      echo "Checking for return value of sprintf()... Yes." | tee -a configure.log
slouken@521
   798
    else
slouken@521
   799
      CFLAGS="$CFLAGS -DHAS_sprintf_void"
slouken@521
   800
      SFLAGS="$SFLAGS -DHAS_sprintf_void"
slouken@521
   801
      echo "Checking for return value of sprintf()... No." | tee -a configure.log
slouken@521
   802
      echo "  WARNING: apparently sprintf() does not return a value. zlib" | tee -a configure.log
slouken@521
   803
      echo "  can build but will be open to possible string-format security" | tee -a configure.log
slouken@521
   804
      echo "  vulnerabilities." | tee -a configure.log
slouken@521
   805
    fi
slouken@521
   806
  fi
slouken@521
   807
fi
slouken@521
   808
slouken@521
   809
# see if we can hide zlib internal symbols that are linked between separate source files
slouken@521
   810
if test "$gcc" -eq 1; then
slouken@521
   811
  echo >> configure.log
slouken@521
   812
  cat > $test.c <<EOF
slouken@521
   813
#define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
slouken@521
   814
int ZLIB_INTERNAL foo;
slouken@521
   815
int main()
slouken@521
   816
{
slouken@521
   817
  return 0;
slouken@521
   818
}
slouken@521
   819
EOF
slouken@521
   820
  if tryboth $CC -c $CFLAGS $test.c; then
slouken@521
   821
    CFLAGS="$CFLAGS -DHAVE_HIDDEN"
slouken@521
   822
    SFLAGS="$SFLAGS -DHAVE_HIDDEN"
slouken@521
   823
    echo "Checking for attribute(visibility) support... Yes." | tee -a configure.log
slouken@521
   824
  else
slouken@521
   825
    echo "Checking for attribute(visibility) support... No." | tee -a configure.log
slouken@521
   826
  fi
slouken@521
   827
fi
slouken@521
   828
slouken@521
   829
# show the results in the log
slouken@521
   830
echo >> configure.log
slouken@521
   831
echo ALL = $ALL >> configure.log
slouken@521
   832
echo AR = $AR >> configure.log
slouken@521
   833
echo ARFLAGS = $ARFLAGS >> configure.log
slouken@521
   834
echo CC = $CC >> configure.log
slouken@521
   835
echo CFLAGS = $CFLAGS >> configure.log
slouken@521
   836
echo CPP = $CPP >> configure.log
slouken@521
   837
echo EXE = $EXE >> configure.log
slouken@521
   838
echo LDCONFIG = $LDCONFIG >> configure.log
slouken@521
   839
echo LDFLAGS = $LDFLAGS >> configure.log
slouken@521
   840
echo LDSHARED = $LDSHARED >> configure.log
slouken@521
   841
echo LDSHAREDLIBC = $LDSHAREDLIBC >> configure.log
slouken@521
   842
echo OBJC = $OBJC >> configure.log
slouken@521
   843
echo PIC_OBJC = $PIC_OBJC >> configure.log
slouken@521
   844
echo RANLIB = $RANLIB >> configure.log
slouken@521
   845
echo SFLAGS = $SFLAGS >> configure.log
slouken@521
   846
echo SHAREDLIB = $SHAREDLIB >> configure.log
slouken@521
   847
echo SHAREDLIBM = $SHAREDLIBM >> configure.log
slouken@521
   848
echo SHAREDLIBV = $SHAREDLIBV >> configure.log
slouken@521
   849
echo STATICLIB = $STATICLIB >> configure.log
slouken@521
   850
echo TEST = $TEST >> configure.log
slouken@521
   851
echo VER = $VER >> configure.log
slouken@521
   852
echo Z_U4 = $Z_U4 >> configure.log
slouken@521
   853
echo SRCDIR = $SRCDIR >> configure.log
slouken@521
   854
echo exec_prefix = $exec_prefix >> configure.log
slouken@521
   855
echo includedir = $includedir >> configure.log
slouken@521
   856
echo libdir = $libdir >> configure.log
slouken@521
   857
echo mandir = $mandir >> configure.log
slouken@521
   858
echo prefix = $prefix >> configure.log
slouken@521
   859
echo sharedlibdir = $sharedlibdir >> configure.log
slouken@521
   860
echo uname = $uname >> configure.log
slouken@521
   861
slouken@521
   862
# udpate Makefile with the configure results
slouken@521
   863
sed < ${SRCDIR}Makefile.in "
slouken@521
   864
/^CC *=/s#=.*#=$CC#
slouken@521
   865
/^CFLAGS *=/s#=.*#=$CFLAGS#
slouken@521
   866
/^SFLAGS *=/s#=.*#=$SFLAGS#
slouken@521
   867
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
slouken@521
   868
/^LDSHARED *=/s#=.*#=$LDSHARED#
slouken@521
   869
/^CPP *=/s#=.*#=$CPP#
slouken@521
   870
/^STATICLIB *=/s#=.*#=$STATICLIB#
slouken@521
   871
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
slouken@521
   872
/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
slouken@521
   873
/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
slouken@521
   874
/^AR *=/s#=.*#=$AR#
slouken@521
   875
/^ARFLAGS *=/s#=.*#=$ARFLAGS#
slouken@521
   876
/^RANLIB *=/s#=.*#=$RANLIB#
slouken@521
   877
/^LDCONFIG *=/s#=.*#=$LDCONFIG#
slouken@521
   878
/^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
slouken@521
   879
/^EXE *=/s#=.*#=$EXE#
slouken@521
   880
/^SRCDIR *=/s#=.*#=$SRCDIR#
slouken@521
   881
/^ZINC *=/s#=.*#=$ZINC#
slouken@521
   882
/^ZINCOUT *=/s#=.*#=$ZINCOUT#
slouken@521
   883
/^prefix *=/s#=.*#=$prefix#
slouken@521
   884
/^exec_prefix *=/s#=.*#=$exec_prefix#
slouken@521
   885
/^libdir *=/s#=.*#=$libdir#
slouken@521
   886
/^sharedlibdir *=/s#=.*#=$sharedlibdir#
slouken@521
   887
/^includedir *=/s#=.*#=$includedir#
slouken@521
   888
/^mandir *=/s#=.*#=$mandir#
slouken@521
   889
/^OBJC *=/s#=.*#= $OBJC#
slouken@521
   890
/^PIC_OBJC *=/s#=.*#= $PIC_OBJC#
slouken@521
   891
/^all: */s#:.*#: $ALL#
slouken@521
   892
/^test: */s#:.*#: $TEST#
slouken@521
   893
" > Makefile
slouken@521
   894
slouken@521
   895
# create zlib.pc with the configure results
slouken@521
   896
sed < ${SRCDIR}zlib.pc.in "
slouken@521
   897
/^CC *=/s#=.*#=$CC#
slouken@521
   898
/^CFLAGS *=/s#=.*#=$CFLAGS#
slouken@521
   899
/^CPP *=/s#=.*#=$CPP#
slouken@521
   900
/^LDSHARED *=/s#=.*#=$LDSHARED#
slouken@521
   901
/^STATICLIB *=/s#=.*#=$STATICLIB#
slouken@521
   902
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
slouken@521
   903
/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
slouken@521
   904
/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
slouken@521
   905
/^AR *=/s#=.*#=$AR#
slouken@521
   906
/^ARFLAGS *=/s#=.*#=$ARFLAGS#
slouken@521
   907
/^RANLIB *=/s#=.*#=$RANLIB#
slouken@521
   908
/^EXE *=/s#=.*#=$EXE#
slouken@521
   909
/^prefix *=/s#=.*#=$prefix#
slouken@521
   910
/^exec_prefix *=/s#=.*#=$exec_prefix#
slouken@521
   911
/^libdir *=/s#=.*#=$libdir#
slouken@521
   912
/^sharedlibdir *=/s#=.*#=$sharedlibdir#
slouken@521
   913
/^includedir *=/s#=.*#=$includedir#
slouken@521
   914
/^mandir *=/s#=.*#=$mandir#
slouken@521
   915
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
slouken@521
   916
" | sed -e "
slouken@521
   917
s/\@VERSION\@/$VER/g;
slouken@521
   918
" > zlib.pc
slouken@521
   919
slouken@521
   920
# done
slouken@521
   921
leave 0