1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/build/autoconf/zlib.m4 Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 1.4 +dnl This Source Code Form is subject to the terms of the Mozilla Public 1.5 +dnl License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 +dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + 1.8 +dnl Usage: MOZ_ZLIB_CHECK([version]) 1.9 + 1.10 +AC_DEFUN([MOZ_ZLIB_CHECK], 1.11 +[ 1.12 + 1.13 +MOZZLIB=$1 1.14 + 1.15 +MOZ_ARG_WITH_STRING(system-zlib, 1.16 +[ --with-system-zlib[=PFX] 1.17 + Use system libz [installed at prefix PFX]], 1.18 + ZLIB_DIR=$withval) 1.19 + 1.20 +if test -z "$MOZ_ZLIB_LIBS$MOZ_ZLIB_CFLAGS$SKIP_LIBRARY_CHECKS"; then 1.21 + _SAVE_CFLAGS=$CFLAGS 1.22 + _SAVE_LDFLAGS=$LDFLAGS 1.23 + _SAVE_LIBS=$LIBS 1.24 + 1.25 + if test -n "${ZLIB_DIR}" -a "${ZLIB_DIR}" != "yes"; then 1.26 + MOZ_ZLIB_CFLAGS="-I${ZLIB_DIR}/include" 1.27 + MOZ_ZLIB_LIBS="-L${ZLIB_DIR}/lib" 1.28 + CFLAGS="$MOZ_ZLIB_CFLAGS $CFLAGS" 1.29 + LDFLAGS="$MOZ_ZLIB_LIBS $LDFLAGS" 1.30 + fi 1.31 + if test -z "$ZLIB_DIR" -o "$ZLIB_DIR" = no; then 1.32 + MOZ_NATIVE_ZLIB= 1.33 + else 1.34 + AC_CHECK_LIB(z, gzread, [MOZ_NATIVE_ZLIB=1 MOZ_ZLIB_LIBS="$MOZ_ZLIB_LIBS -lz"], 1.35 + [MOZ_NATIVE_ZLIB=]) 1.36 + if test "$MOZ_NATIVE_ZLIB" = 1; then 1.37 + MOZZLIBNUM=`echo $MOZZLIB | awk -F. changequote(<<, >>)'{printf "0x%x\n", (((<<$>>1 * 16 + <<$>>2) * 16) + <<$>>3) * 16 + <<$>>4}'changequote([, ])` 1.38 + AC_TRY_COMPILE([ #include <stdio.h> 1.39 + #include <string.h> 1.40 + #include <zlib.h> ], 1.41 + [ #if ZLIB_VERNUM < $MOZZLIBNUM 1.42 + #error "Insufficient zlib version ($MOZZLIBNUM required)." 1.43 + #endif ], 1.44 + MOZ_NATIVE_ZLIB=1, 1.45 + AC_MSG_ERROR([Insufficient zlib version for --with-system-zlib ($MOZZLIB required)])) 1.46 + fi 1.47 + fi 1.48 + CFLAGS=$_SAVE_CFLAGS 1.49 + LDFLAGS=$_SAVE_LDFLAGS 1.50 + LIBS=$_SAVE_LIBS 1.51 +fi 1.52 + 1.53 +AC_SUBST(MOZ_ZLIB_CFLAGS) 1.54 +AC_SUBST(MOZ_ZLIB_LIBS) 1.55 +AC_SUBST(MOZ_NATIVE_ZLIB) 1.56 + 1.57 +])