configure 17 KB

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