1
dnl This Source Code Form is subject to the terms of the Mozilla Public
2
dnl License, v. 2.0. If a copy of the MPL was not distributed with this
3
dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
dnl Usage: MOZ_ZLIB_CHECK([version])
7
AC_DEFUN([MOZ_ZLIB_CHECK],
12
MOZ_ARG_WITH_STRING(system-zlib,
13
[ --with-system-zlib[=PFX]
14
Use system libz [installed at prefix PFX]],
17
if test -z "$MOZ_ZLIB_LIBS$MOZ_ZLIB_CFLAGS$SKIP_LIBRARY_CHECKS"; then
19
_SAVE_LDFLAGS=$LDFLAGS
22
if test -n "${ZLIB_DIR}" -a "${ZLIB_DIR}" != "yes"; then
23
MOZ_ZLIB_CFLAGS="-I${ZLIB_DIR}/include"
24
MOZ_ZLIB_LIBS="-L${ZLIB_DIR}/lib"
25
CFLAGS="$MOZ_ZLIB_CFLAGS $CFLAGS"
26
LDFLAGS="$MOZ_ZLIB_LIBS $LDFLAGS"
28
if test -z "$ZLIB_DIR" -o "$ZLIB_DIR" = no; then
31
AC_CHECK_LIB(z, gzread, [MOZ_NATIVE_ZLIB=1 MOZ_ZLIB_LIBS="$MOZ_ZLIB_LIBS -lz"],
33
if test "$MOZ_NATIVE_ZLIB" = 1; then
34
MOZZLIBNUM=`echo $MOZZLIB | awk -F. changequote(<<, >>)'{printf "0x%x\n", (((<<$>>1 * 16 + <<$>>2) * 16) + <<$>>3) * 16 + <<$>>4}'changequote([, ])`
35
AC_TRY_COMPILE([ #include <stdio.h>
38
[ #if ZLIB_VERNUM < $MOZZLIBNUM
39
#error "Insufficient zlib version ($MOZZLIBNUM required)."
42
AC_MSG_ERROR([Insufficient zlib version for --with-system-zlib ($MOZZLIB required)]))
46
LDFLAGS=$_SAVE_LDFLAGS
50
AC_SUBST(MOZ_ZLIB_CFLAGS)
51
AC_SUBST(MOZ_ZLIB_LIBS)
52
AC_SUBST(MOZ_NATIVE_ZLIB)