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