Bug 1500160 [wpt PR 13600] - Add tests for simple dialog newline normalization, a...
[gecko.git] / build / autoconf / zlib.m4
blob49a2ccc8bf49386a513c02ca5fb3e9205d4097cf
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],
10 MOZZLIB=$1
12 MOZ_ARG_WITH_STRING(system-zlib,
13 [  --with-system-zlib[=PFX]
14                           Use system libz [installed at prefix PFX]],
15     ZLIB_DIR=$withval)
17 if test -z "$MOZ_ZLIB_LIBS$MOZ_ZLIB_CFLAGS$SKIP_LIBRARY_CHECKS"; then
18     _SAVE_CFLAGS=$CFLAGS
19     _SAVE_LDFLAGS=$LDFLAGS
20     _SAVE_LIBS=$LIBS
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"
27     fi
28     if test -z "$ZLIB_DIR" -o "$ZLIB_DIR" = no; then
29         MOZ_SYSTEM_ZLIB=
30     else
31         AC_CHECK_LIB(z, gzread, [MOZ_SYSTEM_ZLIB=1 MOZ_ZLIB_LIBS="$MOZ_ZLIB_LIBS -lz"],
32             [MOZ_SYSTEM_ZLIB=])
33         if test "$MOZ_SYSTEM_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>
36                              #include <string.h>
37                              #include <zlib.h> ],
38                            [ #if ZLIB_VERNUM < $MOZZLIBNUM
39                              #error "Insufficient zlib version ($MOZZLIBNUM required)."
40                              #endif ],
41                            MOZ_SYSTEM_ZLIB=1,
42                            AC_MSG_ERROR([Insufficient zlib version for --with-system-zlib ($MOZZLIB required)]))
43         fi
44     fi
45     CFLAGS=$_SAVE_CFLAGS
46     LDFLAGS=$_SAVE_LDFLAGS
47     LIBS=$_SAVE_LIBS
50 AC_SUBST_LIST(MOZ_ZLIB_CFLAGS)
51 AC_SUBST_LIST(MOZ_ZLIB_LIBS)
52 AC_SUBST(MOZ_SYSTEM_ZLIB)