configure 27.8 KB
Newer Older
M
Mark Adler 已提交
1
#!/bin/sh
M
Mark Adler 已提交
2
# configure script for zlib.
M
Mark Adler 已提交
3
#
M
Mark Adler 已提交
4 5
# Normally configure builds both a static and a shared library.
# If you want to build just a static library, use: ./configure --static
M
Mark Adler 已提交
6
#
M
Mark Adler 已提交
7 8 9 10 11
# To impose specific compiler or flags or install directory, use for example:
#    prefix=$HOME CC=cc CFLAGS="-O4" ./configure
# or for csh/tcsh users:
#    (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure)

M
Mark Adler 已提交
12 13 14 15
# Incorrect settings of CC or CFLAGS may prevent creating a shared library.
# If you have problems, try without defining CC and CFLAGS before reporting
# an error.

M
Mark Adler 已提交
16
# start off configure.log
17 18 19 20
echo -------------------- >> configure.log
echo $0 $* >> configure.log
date >> configure.log

21 22 23 24 25 26 27 28 29 30 31 32
# get source directory
SRCDIR=`dirname $0`
if test $SRCDIR = "."; then
    ZINC=""
    ZINCOUT="-I."
    SRCDIR=""
else
    ZINC='-include zconf.h'
    ZINCOUT='-I. -I$(SRCDIR)'
    SRCDIR="$SRCDIR/"
fi

M
Mark Adler 已提交
33
# set command prefix for cross-compilation
M
Mark Adler 已提交
34
if [ -n "${CHOST}" ]; then
M
Mark Adler 已提交
35
    uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`"
M
Mark Adler 已提交
36 37 38
    CROSS_PREFIX="${CHOST}-"
fi

M
Mark Adler 已提交
39
# destination name for static library
M
Mark Adler 已提交
40
STATICLIB=libz.a
M
Mark Adler 已提交
41 42

# extract zlib version numbers from zlib.h
43 44 45 46
VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}zlib.h`
VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < ${SRCDIR}zlib.h`
VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
M
Mark Adler 已提交
47 48

# establish commands for library building
M
Mark Adler 已提交
49
if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then
M
Mark Adler 已提交
50
    AR=${AR-"${CROSS_PREFIX}ar"}
51
    test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
M
Mark Adler 已提交
52 53
else
    AR=${AR-"ar"}
54
    test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
M
Mark Adler 已提交
55
fi
56
ARFLAGS=${ARFLAGS-"rc"}
M
Mark Adler 已提交
57
if "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null || test $? -lt 126; then
M
Mark Adler 已提交
58
    RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"}
59
    test -n "${CROSS_PREFIX}" && echo Using ${RANLIB} | tee -a configure.log
M
Mark Adler 已提交
60 61 62
else
    RANLIB=${RANLIB-"ranlib"}
fi
M
Mark Adler 已提交
63
if "${CROSS_PREFIX}nm" --version >/dev/null 2>/dev/null || test $? -lt 126; then
M
Mark Adler 已提交
64
    NM=${NM-"${CROSS_PREFIX}nm"}
65
    test -n "${CROSS_PREFIX}" && echo Using ${NM} | tee -a configure.log
M
Mark Adler 已提交
66 67 68
else
    NM=${NM-"nm"}
fi
M
Mark Adler 已提交
69 70

# set defaults before processing command line options
M
Mark Adler 已提交
71
LDCONFIG=${LDCONFIG-"ldconfig"}
M
Mark Adler 已提交
72
LDSHAREDLIBC="${LDSHAREDLIBC--lc}"
M
Mark Adler 已提交
73
ARCHS=
M
Mark Adler 已提交
74
prefix=${prefix-/usr/local}
M
Mark Adler 已提交
75 76
exec_prefix=${exec_prefix-'${prefix}'}
libdir=${libdir-'${exec_prefix}/lib'}
M
Mark Adler 已提交
77
sharedlibdir=${sharedlibdir-'${libdir}'}
M
Mark Adler 已提交
78
includedir=${includedir-'${prefix}/include'}
M
Mark Adler 已提交
79
mandir=${mandir-'${prefix}/share/man'}
M
Mark Adler 已提交
80
shared_ext='.so'
M
Mark Adler 已提交
81
shared=1
82
solo=0
83
cover=0
M
Mark Adler 已提交
84
zprefix=0
85
zconst=0
M
Mark Adler 已提交
86
build64=0
M
Mark Adler 已提交
87
gcc=0
88
warn=0
89
debug=0
S
shuaiyutao 已提交
90
sanitize=0
M
Mark Adler 已提交
91 92
old_cc="$CC"
old_cflags="$CFLAGS"
93 94
OBJC='$(OBJZ) $(OBJG)'
PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)'
M
Mark Adler 已提交
95

96 97 98 99 100 101 102 103 104 105 106 107 108
# leave this script, optionally in a bad way
leave()
{
  if test "$*" != "0"; then
    echo "** $0 aborting." | tee -a configure.log
  fi
  rm -f $test.[co] $test $test$shared_ext $test.gcno ./--version
  echo -------------------- >> configure.log
  echo >> configure.log
  echo >> configure.log
  exit $1
}

M
Mark Adler 已提交
109
# process command line options
M
Mark Adler 已提交
110 111
while test $# -ge 1
do
M
Mark Adler 已提交
112
case "$1" in
M
Mark Adler 已提交
113
    -h* | --help)
114
      echo 'usage:' | tee -a configure.log
115
      echo '  configure [--const] [--zprefix] [--prefix=PREFIX]  [--eprefix=EXPREFIX]' | tee -a configure.log
116 117
      echo '    [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log
      echo '    [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log
M
Mark Adler 已提交
118
        exit 0 ;;
M
Mark Adler 已提交
119 120 121
    -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;;
    -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;;
    -l*=* | --libdir=*) libdir=`echo $1 | sed 's/.*=//'`; shift ;;
M
Mark Adler 已提交
122
    --sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/.*=//'`; shift ;;
M
Mark Adler 已提交
123 124
    -i*=* | --includedir=*) includedir=`echo $1 | sed 's/.*=//'`;shift ;;
    -u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;;
M
Mark Adler 已提交
125 126 127 128 129 130
    -p* | --prefix) prefix="$2"; shift; shift ;;
    -e* | --eprefix) exec_prefix="$2"; shift; shift ;;
    -l* | --libdir) libdir="$2"; shift; shift ;;
    -i* | --includedir) includedir="$2"; shift; shift ;;
    -s* | --shared | --enable-shared) shared=1; shift ;;
    -t | --static) shared=0; shift ;;
131
    --solo) solo=1; shift ;;
132
    --cover) cover=1; shift ;;
M
Mark Adler 已提交
133
    -z* | --zprefix) zprefix=1; shift ;;
M
Mark Adler 已提交
134
    -6* | --64) build64=1; shift ;;
M
Mark Adler 已提交
135
    -a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
136 137
    --sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;;
    --localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;;
138
    -c* | --const) zconst=1; shift ;;
139
    -w* | --warn) warn=1; shift ;;
140
    -d* | --debug) debug=1; shift ;;
S
shuaiyutao 已提交
141
    --sanitize) sanitize=1; shift ;;
142 143 144 145
    *)
      echo "unknown option: $1" | tee -a configure.log
      echo "$0 --help for help" | tee -a configure.log
      leave 1;;
M
Mark Adler 已提交
146 147
    esac
done
M
Mark Adler 已提交
148

149
# temporary file name
M
Mark Adler 已提交
150
test=ztest$$
151

152
# put arguments in log, also put test file in log if used in arguments
153 154 155 156 157 158 159 160 161 162 163
show()
{
  case "$*" in
    *$test.c*)
      echo === $test.c === >> configure.log
      cat $test.c >> configure.log
      echo === >> configure.log;;
  esac
  echo $* >> configure.log
}

M
Mark Adler 已提交
164
# check for gcc vs. cc and set compile and link flags based on the system identified by uname
M
Mark Adler 已提交
165
cat > $test.c <<EOF
M
Mark Adler 已提交
166 167
extern int getchar();
int hello() {return getchar();}
M
Mark Adler 已提交
168
EOF
M
Mark Adler 已提交
169

S
shuaiyutao 已提交
170 171 172 173 174 175 176 177
if test -z "$CC"; then
  echo Checking for ${CROSS_PREFIX}gcc... | tee -a configure.log
  if ${CROSS_PREFIX}gcc -v >/dev/null 2>&1; then
    cc=${CROSS_PREFIX}gcc
  else
    cc=${CROSS_PREFIX}cc
  fi
fi
M
Mark Adler 已提交
178
cflags=${CFLAGS-"-O3"}
M
Mark Adler 已提交
179
# to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
M
Mark Adler 已提交
180
case "$cc" in
M
Mark Adler 已提交
181
  *gcc*) gcc=1 ;;
M
Mark Adler 已提交
182
  *clang*) gcc=1 ;;
M
Mark Adler 已提交
183
esac
M
Mark Adler 已提交
184 185
case `$cc -v 2>&1` in
  *gcc*) gcc=1 ;;
M
Mark Adler 已提交
186
  *clang*) gcc=1 ;;
M
Mark Adler 已提交
187
esac
M
Mark Adler 已提交
188

189 190
show $cc -c $test.c
if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
191
  echo ... using gcc >> configure.log
M
Mark Adler 已提交
192
  CC="$cc"
M
Mark Adler 已提交
193
  CFLAGS="${CFLAGS--O3}"
M
Mark Adler 已提交
194
  SFLAGS="${CFLAGS--O3} -fPIC"
M
Mark Adler 已提交
195 196 197 198
  if test "$ARCHS"; then
    CFLAGS="${CFLAGS} ${ARCHS}"
    LDFLAGS="${LDFLAGS} ${ARCHS}"
  fi
M
Mark Adler 已提交
199 200 201 202
  if test $build64 -eq 1; then
    CFLAGS="${CFLAGS} -m64"
    SFLAGS="${SFLAGS} -m64"
  fi
203
  if test "$warn" -eq 1; then
204 205 206 207 208
    if test "$zconst" -eq 1; then
      CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -pedantic -DZLIB_CONST"
    else
      CFLAGS="${CFLAGS} -Wall -Wextra -pedantic"
    fi
M
Mark Adler 已提交
209
  fi
S
shuaiyutao 已提交
210 211 212
  if test $sanitize -eq 1; then
    CFLAGS="${CFLAGS} -fsanitize=address"
  fi
213 214 215 216
  if test $debug -eq 1; then
    CFLAGS="${CFLAGS} -DZLIB_DEBUG"
    SFLAGS="${SFLAGS} -DZLIB_DEBUG"
  fi
M
Mark Adler 已提交
217
  if test -z "$uname"; then
M
Mark Adler 已提交
218 219 220
    uname=`(uname -s || echo unknown) 2>/dev/null`
  fi
  case "$uname" in
221
  Linux* | linux* | GNU | GNU/* | solaris*)
222
        LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;;
223
  *BSD | *bsd* | DragonFly)
224
        LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"}
225
        LDCONFIG="ldconfig -m" ;;
M
Mark Adler 已提交
226 227
  CYGWIN* | Cygwin* | cygwin* | OS/2*)
        EXE='.exe' ;;
M
Mark Adler 已提交
228
  MINGW* | mingw*)
M
Mark Adler 已提交
229 230
# temporary bypass
        rm -f $test.[co] $test $test$shared_ext
231
        echo "Please use win32/Makefile.gcc instead." | tee -a configure.log
232
        leave 1
M
Mark Adler 已提交
233
        LDSHARED=${LDSHARED-"$cc -shared"}
M
Mark Adler 已提交
234 235
        LDSHAREDLIBC=""
        EXE='.exe' ;;
M
Mark Adler 已提交
236 237
  QNX*)  # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
         # (alain.bonnefoy@icbt.com)
M
Mark Adler 已提交
238
                 LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
M
Mark Adler 已提交
239 240 241 242 243
  HP-UX*)
         LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
         case `(uname -m || echo unknown) 2>/dev/null` in
         ia64)
                 shared_ext='.so'
M
Mark Adler 已提交
244
                 SHAREDLIB='libz.so' ;;
M
Mark Adler 已提交
245
         *)
M
Mark Adler 已提交
246
                 shared_ext='.sl'
M
Mark Adler 已提交
247 248
                 SHAREDLIB='libz.sl' ;;
         esac ;;
M
Mark Adler 已提交
249 250
  Darwin* | darwin*)
             shared_ext='.dylib'
M
Mark Adler 已提交
251 252 253
             SHAREDLIB=libz$shared_ext
             SHAREDLIBV=libz.$VER$shared_ext
             SHAREDLIBM=libz.$VER1$shared_ext
M
Mark Adler 已提交
254
             LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
255
             if libtool -V 2>&1 | grep Apple > /dev/null; then
256 257 258 259
                 AR="libtool"
             else
                 AR="/usr/bin/libtool"
             fi
260
             ARFLAGS="-o" ;;
M
Mark Adler 已提交
261
  *)             LDSHARED=${LDSHARED-"$cc -shared"} ;;
M
Mark Adler 已提交
262
  esac
M
Mark Adler 已提交
263 264 265
else
  # find system name and corresponding cc options
  CC=${CC-cc}
M
Mark Adler 已提交
266
  gcc=0
267
  echo ... using $CC >> configure.log
M
Mark Adler 已提交
268
  if test -z "$uname"; then
M
Mark Adler 已提交
269 270 271
    uname=`(uname -sr || echo unknown) 2>/dev/null`
  fi
  case "$uname" in
M
Mark Adler 已提交
272
  HP-UX*)    SFLAGS=${CFLAGS-"-O +z"}
M
Mark Adler 已提交
273 274 275
             CFLAGS=${CFLAGS-"-O"}
#            LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
             LDSHARED=${LDSHARED-"ld -b"}
M
Mark Adler 已提交
276 277 278
         case `(uname -m || echo unknown) 2>/dev/null` in
         ia64)
             shared_ext='.so'
M
Mark Adler 已提交
279
             SHAREDLIB='libz.so' ;;
M
Mark Adler 已提交
280
         *)
M
Mark Adler 已提交
281
             shared_ext='.sl'
M
Mark Adler 已提交
282 283
             SHAREDLIB='libz.sl' ;;
         esac ;;
M
Mark Adler 已提交
284
  IRIX*)     SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
M
Mark Adler 已提交
285
             CFLAGS=${CFLAGS-"-ansi -O2"}
M
Mark Adler 已提交
286
             LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
M
Mark Adler 已提交
287
  OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
M
Mark Adler 已提交
288
             CFLAGS=${CFLAGS-"-O -std1"}
M
Mark Adler 已提交
289 290
             LDFLAGS="${LDFLAGS} -Wl,-rpath,."
             LDSHARED=${LDSHARED-"cc -shared  -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;;
M
Mark Adler 已提交
291
  OSF1*)     SFLAGS=${CFLAGS-"-O -std1"}
M
Mark Adler 已提交
292
             CFLAGS=${CFLAGS-"-O -std1"}
M
Mark Adler 已提交
293
             LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
M
Mark Adler 已提交
294 295
  QNX*)      SFLAGS=${CFLAGS-"-4 -O"}
             CFLAGS=${CFLAGS-"-4 -O"}
M
Mark Adler 已提交
296
             LDSHARED=${LDSHARED-"cc"}
M
Mark Adler 已提交
297
             RANLIB=${RANLIB-"true"}
298 299
             AR="cc"
             ARFLAGS="-A" ;;
M
Mark Adler 已提交
300
  SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
M
Mark Adler 已提交
301
             CFLAGS=${CFLAGS-"-O3"}
M
Mark Adler 已提交
302
             LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;;
M
Mark Adler 已提交
303
  SunOS\ 5* | solaris*)
304
         LDSHARED=${LDSHARED-"cc -G -h libz$shared_ext.$VER1"}
305
         SFLAGS=${CFLAGS-"-fast -KPIC"}
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
         CFLAGS=${CFLAGS-"-fast"}
         if test $build64 -eq 1; then
             # old versions of SunPRO/Workshop/Studio don't support -m64,
             # but newer ones do.  Check for it.
             flag64=`$CC -flags | egrep -- '^-m64'`
             if test x"$flag64" != x"" ; then
                 CFLAGS="${CFLAGS} -m64"
                 SFLAGS="${SFLAGS} -m64"
             else
                 case `(uname -m || echo unknown) 2>/dev/null` in
                   i86*)
                     SFLAGS="$SFLAGS -xarch=amd64"
                     CFLAGS="$CFLAGS -xarch=amd64" ;;
                   *)
                     SFLAGS="$SFLAGS -xarch=v9"
                     CFLAGS="$CFLAGS -xarch=v9" ;;
                 esac
             fi
         fi
325 326 327
         if test -n "$ZINC"; then
             ZINC='-I- -I. -I$(SRCDIR)'
         fi
328
         ;;
M
Mark Adler 已提交
329
  SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
M
Mark Adler 已提交
330
             CFLAGS=${CFLAGS-"-O2"}
M
Mark Adler 已提交
331
             LDSHARED=${LDSHARED-"ld"} ;;
M
Mark Adler 已提交
332 333
  SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
             CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"}
M
Mark Adler 已提交
334
             LDSHARED=${LDSHARED-"cc -xarch=v9b"} ;;
M
Mark Adler 已提交
335 336 337
  UNIX_System_V\ 4.2.0)
             SFLAGS=${CFLAGS-"-KPIC -O"}
             CFLAGS=${CFLAGS-"-O"}
M
Mark Adler 已提交
338
             LDSHARED=${LDSHARED-"cc -G"} ;;
M
Mark Adler 已提交
339
  UNIX_SV\ 4.2MP)
M
Mark Adler 已提交
340 341
             SFLAGS=${CFLAGS-"-Kconform_pic -O"}
             CFLAGS=${CFLAGS-"-O"}
M
Mark Adler 已提交
342
             LDSHARED=${LDSHARED-"cc -G"} ;;
M
Mark Adler 已提交
343 344 345
  OpenUNIX\ 5)
             SFLAGS=${CFLAGS-"-KPIC -O"}
             CFLAGS=${CFLAGS-"-O"}
M
Mark Adler 已提交
346
             LDSHARED=${LDSHARED-"cc -G"} ;;
M
Mark Adler 已提交
347
  AIX*)  # Courtesy of dbakker@arrayasolutions.com
M
Mark Adler 已提交
348 349
             SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
             CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
M
Mark Adler 已提交
350
             LDSHARED=${LDSHARED-"xlc -G"} ;;
M
Mark Adler 已提交
351
  # send working options for other systems to zlib@gzip.org
M
Mark Adler 已提交
352
  *)         SFLAGS=${CFLAGS-"-O"}
M
Mark Adler 已提交
353
             CFLAGS=${CFLAGS-"-O"}
M
Mark Adler 已提交
354
             LDSHARED=${LDSHARED-"cc -shared"} ;;
M
Mark Adler 已提交
355 356 357
  esac
fi

M
Mark Adler 已提交
358
# destination names for shared library if not defined above
M
Mark Adler 已提交
359 360 361 362
SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}

363 364
echo >> configure.log

365 366 367 368 369 370 371 372 373 374 375 376 377
# define functions for testing compiler and library characteristics and logging the results

cat > $test.c <<EOF
#error error
EOF
if ($CC -c $CFLAGS $test.c) 2>/dev/null; then
  try()
  {
    show $*
    test "`( $* ) 2>&1 | tee -a configure.log`" = ""
  }
  echo - using any output from compiler to indicate an error >> configure.log
else
M
Mark Adler 已提交
378 379 380
  try()
  {
    show $*
S
shuaiyutao 已提交
381
    got=`( $* ) 2>&1`
M
Mark Adler 已提交
382
    ret=$?
S
shuaiyutao 已提交
383 384 385
    if test "$got" != ""; then
      printf "%s\n" "$got" >> configure.log
    fi
M
Mark Adler 已提交
386 387 388 389 390
    if test $ret -ne 0; then
      echo "(exit code "$ret")" >> configure.log
    fi
    return $ret
  }
391 392 393 394 395 396 397
fi

tryboth()
{
  show $*
  got=`( $* ) 2>&1`
  ret=$?
S
shuaiyutao 已提交
398 399 400
  if test "$got" != ""; then
    printf "%s\n" "$got" >> configure.log
  fi
401
  if test $ret -ne 0; then
S
shuaiyutao 已提交
402
    echo "(exit code "$ret")" >> configure.log
403 404 405 406 407 408 409 410 411
    return $ret
  fi
  test "$got" = ""
}

cat > $test.c << EOF
int foo() { return 0; }
EOF
echo "Checking for obsessive-compulsive compiler options..." >> configure.log
M
Mark Adler 已提交
412 413 414
if try $CC -c $CFLAGS $test.c; then
  :
else
415 416 417 418 419 420
  echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log
  leave 1
fi

echo >> configure.log

M
Mark Adler 已提交
421
# see if shared library build supported
422 423 424 425
cat > $test.c <<EOF
extern int getchar();
int hello() {return getchar();}
EOF
M
Mark Adler 已提交
426
if test $shared -eq 1; then
427
  echo Checking for shared library support... | tee -a configure.log
M
Mark Adler 已提交
428
  # we must test in two steps (cc then ld), required at least on SunOS 4.x
429 430
  if try $CC -w -c $SFLAGS $test.c &&
     try $LDSHARED $SFLAGS -o $test$shared_ext $test.o; then
431
    echo Building shared library $SHAREDLIBV with $CC. | tee -a configure.log
M
Mark Adler 已提交
432
  elif test -z "$old_cc" -a -z "$old_cflags"; then
433
    echo No shared library support. | tee -a configure.log
M
Mark Adler 已提交
434
    shared=0;
M
Mark Adler 已提交
435
  else
436
    echo 'No shared library support; try without defining CC and CFLAGS' | tee -a configure.log
M
Mark Adler 已提交
437
    shared=0;
M
Mark Adler 已提交
438 439 440
  fi
fi
if test $shared -eq 0; then
M
Mark Adler 已提交
441
  LDSHARED="$CC"
M
Mark Adler 已提交
442 443
  ALL="static"
  TEST="all teststatic"
M
Mark Adler 已提交
444 445 446
  SHAREDLIB=""
  SHAREDLIBV=""
  SHAREDLIBM=""
447
  echo Building static library $STATICLIB version $VER with $CC. | tee -a configure.log
M
Mark Adler 已提交
448
else
M
Mark Adler 已提交
449 450
  ALL="static shared"
  TEST="all teststatic testshared"
M
Mark Adler 已提交
451 452
fi

M
Mark Adler 已提交
453
# check for underscores in external names for use by assembler code
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468
CPP=${CPP-"$CC -E"}
case $CFLAGS in
  *ASMV*)
    echo >> configure.log
    show "$NM $test.o | grep _hello"
    if test "`$NM $test.o | grep _hello | tee -a configure.log`" = ""; then
      CPP="$CPP -DNO_UNDERLINE"
      echo Checking for underline in external names... No. | tee -a configure.log
    else
      echo Checking for underline in external names... Yes. | tee -a configure.log
    fi ;;
esac

echo >> configure.log

M
Mark Adler 已提交
469 470 471 472 473 474 475 476 477 478
# check for size_t
cat > $test.c <<EOF
#include <stdio.h>
#include <stdlib.h>
size_t dummy = 0;
EOF
if try $CC -c $CFLAGS $test.c; then
  echo "Checking for size_t... Yes." | tee -a configure.log
else
  echo "Checking for size_t... No." | tee -a configure.log
S
shuaiyutao 已提交
479 480 481
  # find a size_t integer type
  # check for long long
  cat > $test.c << EOF
M
Mark Adler 已提交
482 483 484 485 486 487 488 489 490
long long dummy = 0;
EOF
  if try $CC -c $CFLAGS $test.c; then
    echo "Checking for long long... Yes." | tee -a configure.log
    cat > $test.c <<EOF
#include <stdio.h>
int main(void) {
    if (sizeof(void *) <= sizeof(int)) puts("int");
    else if (sizeof(void *) <= sizeof(long)) puts("long");
491
    else puts("z_longlong");
M
Mark Adler 已提交
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508
    return 0;
}
EOF
  else
    echo "Checking for long long... No." | tee -a configure.log
    cat > $test.c <<EOF
#include <stdio.h>
int main(void) {
    if (sizeof(void *) <= sizeof(int)) puts("int");
    else puts("long");
    return 0;
}
EOF
  fi
  if try $CC $CFLAGS -o $test $test.c; then
    sizet=`./$test`
    echo "Checking for a pointer-size integer type..." $sizet"." | tee -a configure.log
S
shuaiyutao 已提交
509 510
    CFLAGS="${CFLAGS} -DNO_SIZE_T=${sizet}"
    SFLAGS="${SFLAGS} -DNO_SIZE_T=${sizet}"
M
Mark Adler 已提交
511
  else
S
shuaiyutao 已提交
512
    echo "Checking for a pointer-size integer type... not found." | tee -a configure.log
M
Mark Adler 已提交
513 514 515 516 517
  fi
fi

echo >> configure.log

M
Mark Adler 已提交
518
# check for large file support, and if none, check for fseeko()
M
Mark Adler 已提交
519 520 521 522
cat > $test.c <<EOF
#include <sys/types.h>
off64_t dummy = 0;
EOF
523
if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then
M
Mark Adler 已提交
524 525
  CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1"
  SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1"
M
Mark Adler 已提交
526 527
  ALL="${ALL} all64"
  TEST="${TEST} test64"
528 529
  echo "Checking for off64_t... Yes." | tee -a configure.log
  echo "Checking for fseeko... Yes." | tee -a configure.log
M
Mark Adler 已提交
530
else
531 532
  echo "Checking for off64_t... No." | tee -a configure.log
  echo >> configure.log
M
Mark Adler 已提交
533 534 535 536 537 538 539
  cat > $test.c <<EOF
#include <stdio.h>
int main(void) {
  fseeko(NULL, 0, 0);
  return 0;
}
EOF
540
  if try $CC $CFLAGS -o $test $test.c; then
541
    echo "Checking for fseeko... Yes." | tee -a configure.log
M
Mark Adler 已提交
542 543 544
  else
    CFLAGS="${CFLAGS} -DNO_FSEEKO"
    SFLAGS="${SFLAGS} -DNO_FSEEKO"
545
    echo "Checking for fseeko... No." | tee -a configure.log
M
Mark Adler 已提交
546
  fi
M
Mark Adler 已提交
547
fi
M
Mark Adler 已提交
548

M
Mark Adler 已提交
549 550
echo >> configure.log

M
Mark Adler 已提交
551
# check for strerror() for use by gz* functions
M
Mark Adler 已提交
552 553 554 555 556 557 558 559 560 561 562 563 564
cat > $test.c <<EOF
#include <string.h>
#include <errno.h>
int main() { return strlen(strerror(errno)); }
EOF
if try $CC $CFLAGS -o $test $test.c; then
  echo "Checking for strerror... Yes." | tee -a configure.log
else
  CFLAGS="${CFLAGS} -DNO_STRERROR"
  SFLAGS="${SFLAGS} -DNO_STRERROR"
  echo "Checking for strerror... No." | tee -a configure.log
fi

M
Mark Adler 已提交
565
# copy clean zconf.h for subsequent edits
566
cp -p ${SRCDIR}zconf.h.in zconf.h
M
Mark Adler 已提交
567

568 569
echo >> configure.log

M
Mark Adler 已提交
570
# check for unistd.h and save result in zconf.h
M
Mark Adler 已提交
571 572 573 574
cat > $test.c <<EOF
#include <unistd.h>
int main() { return 0; }
EOF
575
if try $CC -c $CFLAGS $test.c; then
M
Mark Adler 已提交
576
  sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
M
Mark Adler 已提交
577
  mv zconf.temp.h zconf.h
578
  echo "Checking for unistd.h... Yes." | tee -a configure.log
M
Mark Adler 已提交
579
else
580
  echo "Checking for unistd.h... No." | tee -a configure.log
M
Mark Adler 已提交
581 582
fi

583 584
echo >> configure.log

M
Mark Adler 已提交
585
# check for stdarg.h and save result in zconf.h
M
Mark Adler 已提交
586 587 588 589
cat > $test.c <<EOF
#include <stdarg.h>
int main() { return 0; }
EOF
590
if try $CC -c $CFLAGS $test.c; then
M
Mark Adler 已提交
591 592
  sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
  mv zconf.temp.h zconf.h
593
  echo "Checking for stdarg.h... Yes." | tee -a configure.log
M
Mark Adler 已提交
594
else
595
  echo "Checking for stdarg.h... No." | tee -a configure.log
M
Mark Adler 已提交
596 597
fi

M
Mark Adler 已提交
598
# if the z_ prefix was requested, save that in zconf.h
M
Mark Adler 已提交
599
if test $zprefix -eq 1; then
M
Mark Adler 已提交
600
  sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h
M
Mark Adler 已提交
601
  mv zconf.temp.h zconf.h
602 603
  echo >> configure.log
  echo "Using z_ prefix on all symbols." | tee -a configure.log
M
Mark Adler 已提交
604 605
fi

M
Mark Adler 已提交
606
# if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists
607 608 609 610 611 612 613 614 615 616
if test $solo -eq 1; then
  sed '/#define ZCONF_H/a\
#define Z_SOLO

' < zconf.h > zconf.temp.h
  mv zconf.temp.h zconf.h
OBJC='$(OBJZ)'
PIC_OBJC='$(PIC_OBJZ)'
fi

M
Mark Adler 已提交
617
# if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
618 619
if test $cover -eq 1; then
  CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
620 621 622
  if test -n "$GCC_CLASSIC"; then
    CC=$GCC_CLASSIC
  fi
623 624
fi

625 626
echo >> configure.log

M
Mark Adler 已提交
627 628 629 630
# conduct a series of tests to resolve eight possible cases of using "vs" or "s" printf functions
# (using stdarg or not), with or without "n" (proving size of buffer), and with or without a
# return value.  The most secure result is vsnprintf() with a return value.  snprintf() with a
# return value is secure as well, but then gzprintf() will be limited to 20 arguments.
M
Mark Adler 已提交
631
cat > $test.c <<EOF
M
Mark Adler 已提交
632
#include <stdio.h>
M
Mark Adler 已提交
633 634
#include <stdarg.h>
#include "zconf.h"
M
Mark Adler 已提交
635
int main()
M
Mark Adler 已提交
636 637 638 639 640 641 642
{
#ifndef STDC
  choke me
#endif
  return 0;
}
EOF
643
if try $CC -c $CFLAGS $test.c; then
644
  echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." | tee -a configure.log
M
Mark Adler 已提交
645

646
  echo >> configure.log
M
Mark Adler 已提交
647 648 649
  cat > $test.c <<EOF
#include <stdio.h>
#include <stdarg.h>
M
Mark Adler 已提交
650
int mytest(const char *fmt, ...)
M
Mark Adler 已提交
651 652 653 654 655 656 657 658 659 660 661 662 663
{
  char buf[20];
  va_list ap;
  va_start(ap, fmt);
  vsnprintf(buf, sizeof(buf), fmt, ap);
  va_end(ap);
  return 0;
}
int main()
{
  return (mytest("Hello%d\n", 1));
}
EOF
664
  if try $CC $CFLAGS -o $test $test.c; then
665
    echo "Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log
M
Mark Adler 已提交
666

667
    echo >> configure.log
M
Mark Adler 已提交
668 669 670
    cat >$test.c <<EOF
#include <stdio.h>
#include <stdarg.h>
M
Mark Adler 已提交
671
int mytest(const char *fmt, ...)
M
Mark Adler 已提交
672
{
M
Mark Adler 已提交
673
  int n;
M
Mark Adler 已提交
674 675 676
  char buf[20];
  va_list ap;
  va_start(ap, fmt);
M
Mark Adler 已提交
677
  n = vsnprintf(buf, sizeof(buf), fmt, ap);
M
Mark Adler 已提交
678
  va_end(ap);
M
Mark Adler 已提交
679
  return n;
M
Mark Adler 已提交
680 681 682 683 684 685 686
}
int main()
{
  return (mytest("Hello%d\n", 1));
}
EOF

687
    if try $CC -c $CFLAGS $test.c; then
688
      echo "Checking for return value of vsnprintf()... Yes." | tee -a configure.log
M
Mark Adler 已提交
689 690
    else
      CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
M
Mark Adler 已提交
691
      SFLAGS="$SFLAGS -DHAS_vsnprintf_void"
692 693 694 695
      echo "Checking for return value of vsnprintf()... No." | tee -a configure.log
      echo "  WARNING: apparently vsnprintf() does not return a value. zlib" | tee -a configure.log
      echo "  can build but will be open to possible string-format security" | tee -a configure.log
      echo "  vulnerabilities." | tee -a configure.log
M
Mark Adler 已提交
696 697 698
    fi
  else
    CFLAGS="$CFLAGS -DNO_vsnprintf"
M
Mark Adler 已提交
699
    SFLAGS="$SFLAGS -DNO_vsnprintf"
700 701 702 703
    echo "Checking for vsnprintf() in stdio.h... No." | tee -a configure.log
    echo "  WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log
    echo "  can build but will be open to possible buffer-overflow security" | tee -a configure.log
    echo "  vulnerabilities." | tee -a configure.log
M
Mark Adler 已提交
704

705
    echo >> configure.log
M
Mark Adler 已提交
706 707 708
    cat >$test.c <<EOF
#include <stdio.h>
#include <stdarg.h>
M
Mark Adler 已提交
709
int mytest(const char *fmt, ...)
M
Mark Adler 已提交
710
{
M
Mark Adler 已提交
711
  int n;
M
Mark Adler 已提交
712 713 714
  char buf[20];
  va_list ap;
  va_start(ap, fmt);
M
Mark Adler 已提交
715
  n = vsprintf(buf, fmt, ap);
M
Mark Adler 已提交
716
  va_end(ap);
M
Mark Adler 已提交
717
  return n;
M
Mark Adler 已提交
718
}
M
Mark Adler 已提交
719
int main()
M
Mark Adler 已提交
720 721 722 723 724
{
  return (mytest("Hello%d\n", 1));
}
EOF

725
    if try $CC -c $CFLAGS $test.c; then
726
      echo "Checking for return value of vsprintf()... Yes." | tee -a configure.log
M
Mark Adler 已提交
727 728
    else
      CFLAGS="$CFLAGS -DHAS_vsprintf_void"
M
Mark Adler 已提交
729
      SFLAGS="$SFLAGS -DHAS_vsprintf_void"
730 731 732 733
      echo "Checking for return value of vsprintf()... No." | tee -a configure.log
      echo "  WARNING: apparently vsprintf() does not return a value. zlib" | tee -a configure.log
      echo "  can build but will be open to possible string-format security" | tee -a configure.log
      echo "  vulnerabilities." | tee -a configure.log
M
Mark Adler 已提交
734 735 736
    fi
  fi
else
737
  echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." | tee -a configure.log
M
Mark Adler 已提交
738

739
  echo >> configure.log
M
Mark Adler 已提交
740 741
  cat >$test.c <<EOF
#include <stdio.h>
M
Mark Adler 已提交
742
int mytest()
M
Mark Adler 已提交
743 744 745 746 747
{
  char buf[20];
  snprintf(buf, sizeof(buf), "%s", "foo");
  return 0;
}
M
Mark Adler 已提交
748
int main()
M
Mark Adler 已提交
749 750 751 752 753
{
  return (mytest());
}
EOF

754
  if try $CC $CFLAGS -o $test $test.c; then
755
    echo "Checking for snprintf() in stdio.h... Yes." | tee -a configure.log
M
Mark Adler 已提交
756

757
    echo >> configure.log
M
Mark Adler 已提交
758 759
    cat >$test.c <<EOF
#include <stdio.h>
M
Mark Adler 已提交
760
int mytest()
M
Mark Adler 已提交
761 762
{
  char buf[20];
M
Mark Adler 已提交
763
  return snprintf(buf, sizeof(buf), "%s", "foo");
M
Mark Adler 已提交
764
}
M
Mark Adler 已提交
765
int main()
M
Mark Adler 已提交
766 767 768 769 770
{
  return (mytest());
}
EOF

771
    if try $CC -c $CFLAGS $test.c; then
772
      echo "Checking for return value of snprintf()... Yes." | tee -a configure.log
M
Mark Adler 已提交
773 774
    else
      CFLAGS="$CFLAGS -DHAS_snprintf_void"
M
Mark Adler 已提交
775
      SFLAGS="$SFLAGS -DHAS_snprintf_void"
776 777 778 779
      echo "Checking for return value of snprintf()... No." | tee -a configure.log
      echo "  WARNING: apparently snprintf() does not return a value. zlib" | tee -a configure.log
      echo "  can build but will be open to possible string-format security" | tee -a configure.log
      echo "  vulnerabilities." | tee -a configure.log
M
Mark Adler 已提交
780 781 782
    fi
  else
    CFLAGS="$CFLAGS -DNO_snprintf"
M
Mark Adler 已提交
783
    SFLAGS="$SFLAGS -DNO_snprintf"
784 785 786 787
    echo "Checking for snprintf() in stdio.h... No." | tee -a configure.log
    echo "  WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log
    echo "  can build but will be open to possible buffer-overflow security" | tee -a configure.log
    echo "  vulnerabilities." | tee -a configure.log
M
Mark Adler 已提交
788

789
    echo >> configure.log
M
Mark Adler 已提交
790 791
    cat >$test.c <<EOF
#include <stdio.h>
M
Mark Adler 已提交
792
int mytest()
M
Mark Adler 已提交
793 794
{
  char buf[20];
M
Mark Adler 已提交
795
  return sprintf(buf, "%s", "foo");
M
Mark Adler 已提交
796
}
M
Mark Adler 已提交
797
int main()
M
Mark Adler 已提交
798 799 800 801 802
{
  return (mytest());
}
EOF

803
    if try $CC -c $CFLAGS $test.c; then
804
      echo "Checking for return value of sprintf()... Yes." | tee -a configure.log
M
Mark Adler 已提交
805 806
    else
      CFLAGS="$CFLAGS -DHAS_sprintf_void"
M
Mark Adler 已提交
807
      SFLAGS="$SFLAGS -DHAS_sprintf_void"
808 809 810 811
      echo "Checking for return value of sprintf()... No." | tee -a configure.log
      echo "  WARNING: apparently sprintf() does not return a value. zlib" | tee -a configure.log
      echo "  can build but will be open to possible string-format security" | tee -a configure.log
      echo "  vulnerabilities." | tee -a configure.log
M
Mark Adler 已提交
812 813 814 815
    fi
  fi
fi

M
Mark Adler 已提交
816
# see if we can hide zlib internal symbols that are linked between separate source files
M
Mark Adler 已提交
817
if test "$gcc" -eq 1; then
818
  echo >> configure.log
M
Mark Adler 已提交
819
  cat > $test.c <<EOF
820
#define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
M
Mark Adler 已提交
821
int ZLIB_INTERNAL foo;
M
Mark Adler 已提交
822 823 824 825 826
int main()
{
  return 0;
}
EOF
827
  if tryboth $CC -c $CFLAGS $test.c; then
828 829
    CFLAGS="$CFLAGS -DHAVE_HIDDEN"
    SFLAGS="$SFLAGS -DHAVE_HIDDEN"
830
    echo "Checking for attribute(visibility) support... Yes." | tee -a configure.log
M
Mark Adler 已提交
831
  else
832
    echo "Checking for attribute(visibility) support... No." | tee -a configure.log
M
Mark Adler 已提交
833
  fi
M
Mark Adler 已提交
834 835
fi

836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858
# show the results in the log
echo >> configure.log
echo ALL = $ALL >> configure.log
echo AR = $AR >> configure.log
echo ARFLAGS = $ARFLAGS >> configure.log
echo CC = $CC >> configure.log
echo CFLAGS = $CFLAGS >> configure.log
echo CPP = $CPP >> configure.log
echo EXE = $EXE >> configure.log
echo LDCONFIG = $LDCONFIG >> configure.log
echo LDFLAGS = $LDFLAGS >> configure.log
echo LDSHARED = $LDSHARED >> configure.log
echo LDSHAREDLIBC = $LDSHAREDLIBC >> configure.log
echo OBJC = $OBJC >> configure.log
echo PIC_OBJC = $PIC_OBJC >> configure.log
echo RANLIB = $RANLIB >> configure.log
echo SFLAGS = $SFLAGS >> configure.log
echo SHAREDLIB = $SHAREDLIB >> configure.log
echo SHAREDLIBM = $SHAREDLIBM >> configure.log
echo SHAREDLIBV = $SHAREDLIBV >> configure.log
echo STATICLIB = $STATICLIB >> configure.log
echo TEST = $TEST >> configure.log
echo VER = $VER >> configure.log
859
echo SRCDIR = $SRCDIR >> configure.log
860 861 862 863 864 865 866 867
echo exec_prefix = $exec_prefix >> configure.log
echo includedir = $includedir >> configure.log
echo libdir = $libdir >> configure.log
echo mandir = $mandir >> configure.log
echo prefix = $prefix >> configure.log
echo sharedlibdir = $sharedlibdir >> configure.log
echo uname = $uname >> configure.log

M
Mark Adler 已提交
868
# udpate Makefile with the configure results
869
sed < ${SRCDIR}Makefile.in "
M
Mark Adler 已提交
870 871
/^CC *=/s#=.*#=$CC#
/^CFLAGS *=/s#=.*#=$CFLAGS#
M
Mark Adler 已提交
872
/^SFLAGS *=/s#=.*#=$SFLAGS#
M
Mark Adler 已提交
873
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
M
Mark Adler 已提交
874
/^LDSHARED *=/s#=.*#=$LDSHARED#
M
Mark Adler 已提交
875
/^CPP *=/s#=.*#=$CPP#
M
Mark Adler 已提交
876
/^STATICLIB *=/s#=.*#=$STATICLIB#
M
Mark Adler 已提交
877 878 879
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
880 881
/^AR *=/s#=.*#=$AR#
/^ARFLAGS *=/s#=.*#=$ARFLAGS#
M
Mark Adler 已提交
882
/^RANLIB *=/s#=.*#=$RANLIB#
M
Mark Adler 已提交
883 884
/^LDCONFIG *=/s#=.*#=$LDCONFIG#
/^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
M
Mark Adler 已提交
885
/^EXE *=/s#=.*#=$EXE#
886 887 888
/^SRCDIR *=/s#=.*#=$SRCDIR#
/^ZINC *=/s#=.*#=$ZINC#
/^ZINCOUT *=/s#=.*#=$ZINCOUT#
M
Mark Adler 已提交
889 890 891
/^prefix *=/s#=.*#=$prefix#
/^exec_prefix *=/s#=.*#=$exec_prefix#
/^libdir *=/s#=.*#=$libdir#
M
Mark Adler 已提交
892
/^sharedlibdir *=/s#=.*#=$sharedlibdir#
M
Mark Adler 已提交
893 894
/^includedir *=/s#=.*#=$includedir#
/^mandir *=/s#=.*#=$mandir#
895 896
/^OBJC *=/s#=.*#= $OBJC#
/^PIC_OBJC *=/s#=.*#= $PIC_OBJC#
M
Mark Adler 已提交
897 898
/^all: */s#:.*#: $ALL#
/^test: */s#:.*#: $TEST#
M
Mark Adler 已提交
899
" > Makefile
M
Mark Adler 已提交
900

M
Mark Adler 已提交
901
# create zlib.pc with the configure results
902
sed < ${SRCDIR}zlib.pc.in "
M
Mark Adler 已提交
903 904 905 906
/^CC *=/s#=.*#=$CC#
/^CFLAGS *=/s#=.*#=$CFLAGS#
/^CPP *=/s#=.*#=$CPP#
/^LDSHARED *=/s#=.*#=$LDSHARED#
M
Mark Adler 已提交
907
/^STATICLIB *=/s#=.*#=$STATICLIB#
M
Mark Adler 已提交
908 909 910
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
911 912
/^AR *=/s#=.*#=$AR#
/^ARFLAGS *=/s#=.*#=$ARFLAGS#
M
Mark Adler 已提交
913 914 915 916 917
/^RANLIB *=/s#=.*#=$RANLIB#
/^EXE *=/s#=.*#=$EXE#
/^prefix *=/s#=.*#=$prefix#
/^exec_prefix *=/s#=.*#=$exec_prefix#
/^libdir *=/s#=.*#=$libdir#
M
Mark Adler 已提交
918
/^sharedlibdir *=/s#=.*#=$sharedlibdir#
M
Mark Adler 已提交
919 920 921 922 923 924
/^includedir *=/s#=.*#=$includedir#
/^mandir *=/s#=.*#=$mandir#
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
" | sed -e "
s/\@VERSION\@/$VER/g;
" > zlib.pc
925 926 927

# done
leave 0