1#!/bin/sh
2# configure script for zlib.
3#
4# Normally configure builds both a static and a shared library.
5# If you want to build just a static library, use: ./configure --static
6#
7# To impose specific compiler or flags or install directory, use for example:
8#    prefix=$HOME CC=cc CFLAGS="-O4" ./configure
9# or for csh/tcsh users:
10#    (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure)
11
12# Incorrect settings of CC or CFLAGS may prevent creating a shared library.
13# If you have problems, try without defining CC and CFLAGS before reporting
14# an error.
15
16if [ -n "${CHOST}" ]; then
17    uname="$(echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/')"
18    CROSS_PREFIX="${CHOST}-"
19fi
20
21STATICLIB=libz.a
22LDFLAGS="${LDFLAGS} -L. ${STATICLIB}"
23VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
24VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < zlib.h`
25VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h`
26VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h`
27if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then
28    AR=${AR-"${CROSS_PREFIX}ar"}
29    test -n "${CROSS_PREFIX}" && echo Using ${AR}
30else
31    AR=${AR-"ar"}
32    test -n "${CROSS_PREFIX}" && echo Using ${AR}
33fi
34AR_RC="${AR} rc"
35if "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null || test $? -lt 126; then
36    RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"}
37    test -n "${CROSS_PREFIX}" && echo Using ${RANLIB}
38else
39    RANLIB=${RANLIB-"ranlib"}
40fi
41if "${CROSS_PREFIX}nm" --version >/dev/null 2>/dev/null || test $? -lt 126; then
42    NM=${NM-"${CROSS_PREFIX}nm"}
43    test -n "${CROSS_PREFIX}" && echo Using ${NM}
44else
45    NM=${NM-"nm"}
46fi
47LDCONFIG=${LDCONFIG-"ldconfig"}
48LDSHAREDLIBC="${LDSHAREDLIBC--lc}"
49prefix=${prefix-/usr/local}
50exec_prefix=${exec_prefix-'${prefix}'}
51libdir=${libdir-'${exec_prefix}/lib'}
52sharedlibdir=${sharedlibdir-'${libdir}'}
53includedir=${includedir-'${prefix}/include'}
54mandir=${mandir-'${prefix}/share/man'}
55shared_ext='.so'
56shared=1
57zprefix=0
58build64=0
59gcc=0
60old_cc="$CC"
61old_cflags="$CFLAGS"
62
63while test $# -ge 1
64do
65case "$1" in
66    -h* | --help)
67      echo 'usage:'
68      echo '  configure [--zprefix] [--prefix=PREFIX]  [--eprefix=EXPREFIX]'
69      echo '    [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]'
70      echo '    [--includedir=INCLUDEDIR]'
71        exit 0 ;;
72    -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;;
73    -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;;
74    -l*=* | --libdir=*) libdir=`echo $1 | sed 's/.*=//'`; shift ;;
75    --sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/.*=//'`; shift ;;
76    -i*=* | --includedir=*) includedir=`echo $1 | sed 's/.*=//'`;shift ;;
77    -u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;;
78    -p* | --prefix) prefix="$2"; shift; shift ;;
79    -e* | --eprefix) exec_prefix="$2"; shift; shift ;;
80    -l* | --libdir) libdir="$2"; shift; shift ;;
81    -i* | --includedir) includedir="$2"; shift; shift ;;
82    -s* | --shared | --enable-shared) shared=1; shift ;;
83    -t | --static) shared=0; shift ;;
84    -z* | --zprefix) zprefix=1; shift ;;
85    -6* | --64) build64=1; shift ;;
86    --sysconfdir=*) echo "ignored option: --sysconfdir"; shift ;;
87    --localstatedir=*) echo "ignored option: --localstatedir"; shift ;;
88    *) echo "unknown option: $1"; echo "$0 --help for help"; exit 1 ;;
89    esac
90done
91
92test=ztest$$
93cat > $test.c <<EOF
94extern int getchar();
95int hello() {return getchar();}
96EOF
97
98test -z "$CC" && echo Checking for ${CROSS_PREFIX}gcc...
99cc=${CC-${CROSS_PREFIX}gcc}
100cflags=${CFLAGS-"-O3"}
101# to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
102case "$cc" in
103  *gcc*) gcc=1 ;;
104esac
105
106if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
107  CC="$cc"
108  SFLAGS="${CFLAGS--O3} -fPIC"
109  CFLAGS="${CFLAGS--O3}"
110  if test $build64 -eq 1; then
111    CFLAGS="${CFLAGS} -m64"
112    SFLAGS="${SFLAGS} -m64"
113  fi
114  if test "${ZLIBGCCWARN}" = "YES"; then
115    CFLAGS="${CFLAGS} -Wall -Wextra -pedantic"
116  fi
117  if test -z "$uname"; then
118    uname=`(uname -s || echo unknown) 2>/dev/null`
119  fi
120  case "$uname" in
121  Linux* | linux* | GNU | GNU/* | *BSD | DragonFly) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"} ;;
122  CYGWIN* | Cygwin* | cygwin* | OS/2*)
123        EXE='.exe' ;;
124  MINGW*|mingw*)
125# temporary bypass
126        rm -f $test.[co] $test $test$shared_ext
127        echo "Please use win32/Makefile.gcc instead."
128        exit 1
129        LDSHARED=${LDSHARED-"$cc -shared"}
130        LDSHAREDLIBC=""
131        EXE='.exe' ;;
132  QNX*)  # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
133         # (alain.bonnefoy@icbt.com)
134                 LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
135  HP-UX*)
136         LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
137         case `(uname -m || echo unknown) 2>/dev/null` in
138         ia64)
139                 shared_ext='.so'
140                 SHAREDLIB='libz.so' ;;
141         *)
142                 shared_ext='.sl'
143                 SHAREDLIB='libz.sl' ;;
144         esac ;;
145  Darwin*)   shared_ext='.dylib'
146             SHAREDLIB=libz$shared_ext
147             SHAREDLIBV=libz.$VER$shared_ext
148             SHAREDLIBM=libz.$VER1$shared_ext
149             LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"} ;;
150  *)             LDSHARED=${LDSHARED-"$cc -shared"} ;;
151  esac
152else
153  # find system name and corresponding cc options
154  CC=${CC-cc}
155  gcc=0
156  if test -z "$uname"; then
157    uname=`(uname -sr || echo unknown) 2>/dev/null`
158  fi
159  case "$uname" in
160  HP-UX*)    SFLAGS=${CFLAGS-"-O +z"}
161             CFLAGS=${CFLAGS-"-O"}
162#            LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
163             LDSHARED=${LDSHARED-"ld -b"}
164         case `(uname -m || echo unknown) 2>/dev/null` in
165         ia64)
166             shared_ext='.so'
167             SHAREDLIB='libz.so' ;;
168         *)
169             shared_ext='.sl'
170             SHAREDLIB='libz.sl' ;;
171         esac ;;
172  IRIX*)     SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
173             CFLAGS=${CFLAGS-"-ansi -O2"}
174             LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
175  OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
176             CFLAGS=${CFLAGS-"-O -std1"}
177             LDFLAGS="${LDFLAGS} -Wl,-rpath,."
178             LDSHARED=${LDSHARED-"cc -shared  -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;;
179  OSF1*)     SFLAGS=${CFLAGS-"-O -std1"}
180             CFLAGS=${CFLAGS-"-O -std1"}
181             LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
182  QNX*)      SFLAGS=${CFLAGS-"-4 -O"}
183             CFLAGS=${CFLAGS-"-4 -O"}
184             LDSHARED=${LDSHARED-"cc"}
185             RANLIB=${RANLIB-"true"}
186             AR_RC="cc -A" ;;
187  SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
188             CFLAGS=${CFLAGS-"-O3"}
189             LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;;
190  SunOS\ 5*) LDSHARED=${LDSHARED-"cc -G"}
191         case `(uname -m || echo unknown) 2>/dev/null` in
192         i86*)
193             SFLAGS=${CFLAGS-"-xpentium -fast -KPIC -R."}
194             CFLAGS=${CFLAGS-"-xpentium -fast"} ;;
195         *)
196             SFLAGS=${CFLAGS-"-fast -xcg92 -KPIC -R."}
197             CFLAGS=${CFLAGS-"-fast -xcg92"} ;;
198         esac ;;
199  SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
200             CFLAGS=${CFLAGS-"-O2"}
201             LDSHARED=${LDSHARED-"ld"} ;;
202  SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
203             CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"}
204             LDSHARED=${LDSHARED-"cc -xarch=v9b"} ;;
205  UNIX_System_V\ 4.2.0)
206             SFLAGS=${CFLAGS-"-KPIC -O"}
207             CFLAGS=${CFLAGS-"-O"}
208             LDSHARED=${LDSHARED-"cc -G"} ;;
209  UNIX_SV\ 4.2MP)
210             SFLAGS=${CFLAGS-"-Kconform_pic -O"}
211             CFLAGS=${CFLAGS-"-O"}
212             LDSHARED=${LDSHARED-"cc -G"} ;;
213  OpenUNIX\ 5)
214             SFLAGS=${CFLAGS-"-KPIC -O"}
215             CFLAGS=${CFLAGS-"-O"}
216             LDSHARED=${LDSHARED-"cc -G"} ;;
217  AIX*)  # Courtesy of dbakker@arrayasolutions.com
218             SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
219             CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
220             LDSHARED=${LDSHARED-"xlc -G"} ;;
221  # send working options for other systems to zlib@gzip.org
222  *)         SFLAGS=${CFLAGS-"-O"}
223             CFLAGS=${CFLAGS-"-O"}
224             LDSHARED=${LDSHARED-"cc -shared"} ;;
225  esac
226fi
227
228SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
229SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
230SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
231
232if test $shared -eq 1; then
233  echo Checking for shared library support...
234  # we must test in two steps (cc then ld), required at least on SunOS 4.x
235  if test "`($CC -w -c $SFLAGS $test.c) 2>&1`" = "" &&
236     test "`($LDSHARED $SFLAGS -o $test$shared_ext $test.o) 2>&1`" = ""; then
237    echo Building shared library $SHAREDLIBV with $CC.
238  elif test -z "$old_cc" -a -z "$old_cflags"; then
239    echo No shared library support.
240    shared=0;
241  else
242    echo Tested $CC -w -c $SFLAGS $test.c
243    $CC -w -c $SFLAGS $test.c
244    echo Tested $LDSHARED $SFLAGS -o $test$shared_ext $test.o
245    $LDSHARED $SFLAGS -o $test$shared_ext $test.o
246    echo 'No shared library support; try without defining CC and CFLAGS'
247    shared=0;
248  fi
249fi
250if test $shared -eq 0; then
251  LDSHARED="$CC"
252  ALL="static"
253  TEST="all teststatic"
254  SHAREDLIB=""
255  SHAREDLIBV=""
256  SHAREDLIBM=""
257  echo Building static library $STATICLIB version $VER with $CC.
258else
259  ALL="static shared"
260  TEST="all teststatic testshared"
261fi
262
263cat > $test.c <<EOF
264#include <sys/types.h>
265off64_t dummy = 0;
266EOF
267if test "`($CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c) 2>&1`" = ""; then
268  CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1"
269  SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1"
270  ALL="${ALL} all64"
271  TEST="${TEST} test64"
272  echo "Checking for off64_t... Yes."
273  echo "Checking for fseeko... Yes."
274else
275  echo "Checking for off64_t... No."
276  cat > $test.c <<EOF
277#include <stdio.h>
278int main(void) {
279  fseeko(NULL, 0, 0);
280  return 0;
281}
282EOF
283  if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
284    echo "Checking for fseeko... Yes."
285  else
286    CFLAGS="${CFLAGS} -DNO_FSEEKO"
287    SFLAGS="${SFLAGS} -DNO_FSEEKO"
288    echo "Checking for fseeko... No."
289  fi
290fi
291
292cp -p zconf.h.in zconf.h
293
294cat > $test.c <<EOF
295#include <unistd.h>
296int main() { return 0; }
297EOF
298if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
299  sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
300  mv zconf.temp.h zconf.h
301  echo "Checking for unistd.h... Yes."
302else
303  echo "Checking for unistd.h... No."
304fi
305
306if test $zprefix -eq 1; then
307  sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h
308  mv zconf.temp.h zconf.h
309  echo "Using z_ prefix on all symbols."
310fi
311
312cat > $test.c <<EOF
313#include <stdio.h>
314#include <stdarg.h>
315#include "zconf.h"
316
317int main()
318{
319#ifndef STDC
320  choke me
321#endif
322
323  return 0;
324}
325EOF
326
327if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
328  echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()."
329
330  cat > $test.c <<EOF
331#include <stdio.h>
332#include <stdarg.h>
333
334int mytest(const char *fmt, ...)
335{
336  char buf[20];
337  va_list ap;
338
339  va_start(ap, fmt);
340  vsnprintf(buf, sizeof(buf), fmt, ap);
341  va_end(ap);
342  return 0;
343}
344
345int main()
346{
347  return (mytest("Hello%d\n", 1));
348}
349EOF
350
351  if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
352    echo "Checking for vsnprintf() in stdio.h... Yes."
353
354    cat >$test.c <<EOF
355#include <stdio.h>
356#include <stdarg.h>
357
358int mytest(const char *fmt, ...)
359{
360  int n;
361  char buf[20];
362  va_list ap;
363
364  va_start(ap, fmt);
365  n = vsnprintf(buf, sizeof(buf), fmt, ap);
366  va_end(ap);
367  return n;
368}
369
370int main()
371{
372  return (mytest("Hello%d\n", 1));
373}
374EOF
375
376    if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
377      echo "Checking for return value of vsnprintf()... Yes."
378    else
379      CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
380      SFLAGS="$SFLAGS -DHAS_vsnprintf_void"
381      echo "Checking for return value of vsnprintf()... No."
382      echo "  WARNING: apparently vsnprintf() does not return a value. zlib"
383      echo "  can build but will be open to possible string-format security"
384      echo "  vulnerabilities."
385    fi
386  else
387    CFLAGS="$CFLAGS -DNO_vsnprintf"
388    SFLAGS="$SFLAGS -DNO_vsnprintf"
389    echo "Checking for vsnprintf() in stdio.h... No."
390    echo "  WARNING: vsnprintf() not found, falling back to vsprintf(). zlib"
391    echo "  can build but will be open to possible buffer-overflow security"
392    echo "  vulnerabilities."
393
394    cat >$test.c <<EOF
395#include <stdio.h>
396#include <stdarg.h>
397
398int mytest(const char *fmt, ...)
399{
400  int n;
401  char buf[20];
402  va_list ap;
403
404  va_start(ap, fmt);
405  n = vsprintf(buf, fmt, ap);
406  va_end(ap);
407  return n;
408}
409
410int main()
411{
412  return (mytest("Hello%d\n", 1));
413}
414EOF
415
416    if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
417      echo "Checking for return value of vsprintf()... Yes."
418    else
419      CFLAGS="$CFLAGS -DHAS_vsprintf_void"
420      SFLAGS="$SFLAGS -DHAS_vsprintf_void"
421      echo "Checking for return value of vsprintf()... No."
422      echo "  WARNING: apparently vsprintf() does not return a value. zlib"
423      echo "  can build but will be open to possible string-format security"
424      echo "  vulnerabilities."
425    fi
426  fi
427else
428  echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()."
429
430  cat >$test.c <<EOF
431#include <stdio.h>
432
433int mytest()
434{
435  char buf[20];
436
437  snprintf(buf, sizeof(buf), "%s", "foo");
438  return 0;
439}
440
441int main()
442{
443  return (mytest());
444}
445EOF
446
447  if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
448    echo "Checking for snprintf() in stdio.h... Yes."
449
450    cat >$test.c <<EOF
451#include <stdio.h>
452
453int mytest()
454{
455  char buf[20];
456
457  return snprintf(buf, sizeof(buf), "%s", "foo");
458}
459
460int main()
461{
462  return (mytest());
463}
464EOF
465
466    if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
467      echo "Checking for return value of snprintf()... Yes."
468    else
469      CFLAGS="$CFLAGS -DHAS_snprintf_void"
470      SFLAGS="$SFLAGS -DHAS_snprintf_void"
471      echo "Checking for return value of snprintf()... No."
472      echo "  WARNING: apparently snprintf() does not return a value. zlib"
473      echo "  can build but will be open to possible string-format security"
474      echo "  vulnerabilities."
475    fi
476  else
477    CFLAGS="$CFLAGS -DNO_snprintf"
478    SFLAGS="$SFLAGS -DNO_snprintf"
479    echo "Checking for snprintf() in stdio.h... No."
480    echo "  WARNING: snprintf() not found, falling back to sprintf(). zlib"
481    echo "  can build but will be open to possible buffer-overflow security"
482    echo "  vulnerabilities."
483
484    cat >$test.c <<EOF
485#include <stdio.h>
486
487int mytest()
488{
489  char buf[20];
490
491  return sprintf(buf, "%s", "foo");
492}
493
494int main()
495{
496  return (mytest());
497}
498EOF
499
500    if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
501      echo "Checking for return value of sprintf()... Yes."
502    else
503      CFLAGS="$CFLAGS -DHAS_sprintf_void"
504      SFLAGS="$SFLAGS -DHAS_sprintf_void"
505      echo "Checking for return value of sprintf()... No."
506      echo "  WARNING: apparently sprintf() does not return a value. zlib"
507      echo "  can build but will be open to possible string-format security"
508      echo "  vulnerabilities."
509    fi
510  fi
511fi
512
513if test "$gcc" -eq 1; then
514  cat > $test.c <<EOF
515#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33)
516#  define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
517#else
518#  define ZLIB_INTERNAL
519#endif
520int ZLIB_INTERNAL foo;
521int main()
522{
523  return 0;
524}
525EOF
526  if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
527    echo "Checking for attribute(visibility) support... Yes."
528  else
529    CFLAGS="$CFLAGS -DNO_VIZ"
530    SFLAGS="$SFLAGS -DNO_VIZ"
531    echo "Checking for attribute(visibility) support... No."
532  fi
533fi
534
535CPP=${CPP-"$CC -E"}
536case $CFLAGS in
537  *ASMV*)
538    if test "`$NM $test.o | grep _hello`" = ""; then
539      CPP="$CPP -DNO_UNDERLINE"
540      echo Checking for underline in external names... No.
541    else
542      echo Checking for underline in external names... Yes.
543    fi ;;
544esac
545
546rm -f $test.[co] $test $test$shared_ext
547
548# udpate Makefile
549sed < Makefile.in "
550/^CC *=/s#=.*#=$CC#
551/^CFLAGS *=/s#=.*#=$CFLAGS#
552/^SFLAGS *=/s#=.*#=$SFLAGS#
553/^LDFLAGS *=/s#=.*#=$LDFLAGS#
554/^LDSHARED *=/s#=.*#=$LDSHARED#
555/^CPP *=/s#=.*#=$CPP#
556/^STATICLIB *=/s#=.*#=$STATICLIB#
557/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
558/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
559/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
560/^AR *=/s#=.*#=$AR_RC#
561/^RANLIB *=/s#=.*#=$RANLIB#
562/^LDCONFIG *=/s#=.*#=$LDCONFIG#
563/^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
564/^EXE *=/s#=.*#=$EXE#
565/^prefix *=/s#=.*#=$prefix#
566/^exec_prefix *=/s#=.*#=$exec_prefix#
567/^libdir *=/s#=.*#=$libdir#
568/^sharedlibdir *=/s#=.*#=$sharedlibdir#
569/^includedir *=/s#=.*#=$includedir#
570/^mandir *=/s#=.*#=$mandir#
571/^all: */s#:.*#: $ALL#
572/^test: */s#:.*#: $TEST#
573" > Makefile
574
575sed < zlib.pc.in "
576/^CC *=/s#=.*#=$CC#
577/^CFLAGS *=/s#=.*#=$CFLAGS#
578/^CPP *=/s#=.*#=$CPP#
579/^LDSHARED *=/s#=.*#=$LDSHARED#
580/^STATICLIB *=/s#=.*#=$STATICLIB#
581/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
582/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
583/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
584/^AR *=/s#=.*#=$AR_RC#
585/^RANLIB *=/s#=.*#=$RANLIB#
586/^EXE *=/s#=.*#=$EXE#
587/^prefix *=/s#=.*#=$prefix#
588/^exec_prefix *=/s#=.*#=$exec_prefix#
589/^libdir *=/s#=.*#=$libdir#
590/^sharedlibdir *=/s#=.*#=$sharedlibdir#
591/^includedir *=/s#=.*#=$includedir#
592/^mandir *=/s#=.*#=$mandir#
593/^LDFLAGS *=/s#=.*#=$LDFLAGS#
594" | sed -e "
595s/\@VERSION\@/$VER/g;
596" > zlib.pc
597