michael@0: dnl This Source Code Form is subject to the terms of the Mozilla Public michael@0: dnl License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: dnl Usage: MOZ_ZLIB_CHECK([version]) michael@0: michael@0: AC_DEFUN([MOZ_ZLIB_CHECK], michael@0: [ michael@0: michael@0: MOZZLIB=$1 michael@0: michael@0: MOZ_ARG_WITH_STRING(system-zlib, michael@0: [ --with-system-zlib[=PFX] michael@0: Use system libz [installed at prefix PFX]], michael@0: ZLIB_DIR=$withval) michael@0: michael@0: if test -z "$MOZ_ZLIB_LIBS$MOZ_ZLIB_CFLAGS$SKIP_LIBRARY_CHECKS"; then michael@0: _SAVE_CFLAGS=$CFLAGS michael@0: _SAVE_LDFLAGS=$LDFLAGS michael@0: _SAVE_LIBS=$LIBS michael@0: michael@0: if test -n "${ZLIB_DIR}" -a "${ZLIB_DIR}" != "yes"; then michael@0: MOZ_ZLIB_CFLAGS="-I${ZLIB_DIR}/include" michael@0: MOZ_ZLIB_LIBS="-L${ZLIB_DIR}/lib" michael@0: CFLAGS="$MOZ_ZLIB_CFLAGS $CFLAGS" michael@0: LDFLAGS="$MOZ_ZLIB_LIBS $LDFLAGS" michael@0: fi michael@0: if test -z "$ZLIB_DIR" -o "$ZLIB_DIR" = no; then michael@0: MOZ_NATIVE_ZLIB= michael@0: else michael@0: AC_CHECK_LIB(z, gzread, [MOZ_NATIVE_ZLIB=1 MOZ_ZLIB_LIBS="$MOZ_ZLIB_LIBS -lz"], michael@0: [MOZ_NATIVE_ZLIB=]) michael@0: if test "$MOZ_NATIVE_ZLIB" = 1; then michael@0: MOZZLIBNUM=`echo $MOZZLIB | awk -F. changequote(<<, >>)'{printf "0x%x\n", (((<<$>>1 * 16 + <<$>>2) * 16) + <<$>>3) * 16 + <<$>>4}'changequote([, ])` michael@0: AC_TRY_COMPILE([ #include michael@0: #include michael@0: #include ], michael@0: [ #if ZLIB_VERNUM < $MOZZLIBNUM michael@0: #error "Insufficient zlib version ($MOZZLIBNUM required)." michael@0: #endif ], michael@0: MOZ_NATIVE_ZLIB=1, michael@0: AC_MSG_ERROR([Insufficient zlib version for --with-system-zlib ($MOZZLIB required)])) michael@0: fi michael@0: fi michael@0: CFLAGS=$_SAVE_CFLAGS michael@0: LDFLAGS=$_SAVE_LDFLAGS michael@0: LIBS=$_SAVE_LIBS michael@0: fi michael@0: michael@0: AC_SUBST(MOZ_ZLIB_CFLAGS) michael@0: AC_SUBST(MOZ_ZLIB_LIBS) michael@0: AC_SUBST(MOZ_NATIVE_ZLIB) michael@0: michael@0: ])