1# ZLIB_CHECK_CONFIG ([DEFAULT-ACTION]) 2# ---------------------------------------------------------- 3# 4# Checks for zlib. 5# 6# This macro #defines HAVE_ZLIB_H if required header files are 7# found, and sets @ZLIB_LDFLAGS@ and @ZLIB_CFLAGS@ to the necessary 8# values. 9# 10# This macro is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 14AC_DEFUN([ZLIB_TRY_LINK], 15[ 16found_zlib=$1 17AC_TRY_LINK( 18[ 19#include <zlib.h> 20], 21[ 22 z_stream defstream; 23 deflateInit(&defstream, Z_BEST_COMPRESSION); 24], 25found_zlib="yes") 26])dnl 27 28AC_DEFUN([ZLIB_CHECK_CONFIG], 29[ 30 AC_ARG_WITH([zlib],[ 31If you want to specify zlib installation directories: 32AC_HELP_STRING([--with-zlib@<:@=DIR@:>@], [use zlib from given base install directory (DIR), default is to search through a number of common places for the zlib files.])], 33 [ 34 test "x$withval" = "xyes" && withval=/usr 35 ZLIB_CFLAGS="-I$withval/include" 36 ZLIB_LDFLAGS="-L$withval/lib" 37 _zlib_dir_set="yes" 38 ] 39 ) 40 41 AC_ARG_WITH([zlib-include], 42 AC_HELP_STRING([--with-zlib-include=DIR], 43 [use zlib include headers from given path.] 44 ), 45 [ 46 ZLIB_CFLAGS="-I$withval" 47 _zlib_dir_set="yes" 48 ] 49 ) 50 51 AC_ARG_WITH([zlib-lib], 52 AC_HELP_STRING([--with-zlib-lib=DIR], 53 [use zlib libraries from given path.] 54 ), 55 [ 56 ZLIB_LDFLAGS="-L$withval" 57 _zlib_dir_set="yes" 58 ] 59 ) 60 61 AC_MSG_CHECKING(for zlib support) 62 63 ZLIB_LIBS="-lz" 64 65 if test -n "$_zlib_dir_set" -o -f /usr/include/zlib.h; then 66 found_zlib="yes" 67 elif test -f /usr/local/include/zlib.h; then 68 ZLIB_CFLAGS="-I/usr/local/include" 69 ZLIB_LDFLAGS="-L/usr/local/lib" 70 found_zlib="yes" 71 elif test -f /usr/pkg/include/zlib.h; then 72 ZLIB_CFLAGS="-I/usr/pkg/include" 73 ZLIB_LDFLAGS="-L/usr/pkg/lib" 74 found_zlib="yes" 75 else 76 found_zlib="no" 77 AC_MSG_RESULT(no) 78 fi 79 80 if test "x$found_zlib" = "xyes"; then 81 am_save_CFLAGS="$CFLAGS" 82 am_save_LDFLAGS="$LDFLAGS" 83 am_save_LIBS="$LIBS" 84 85 CFLAGS="$CFLAGS $ZLIB_CFLAGS" 86 LDFLAGS="$LDFLAGS $ZLIB_LDFLAGS" 87 LIBS="$LIBS $ZLIB_LIBS" 88 89 ZLIB_TRY_LINK([no]) 90 91 CFLAGS="$am_save_CFLAGS" 92 LDFLAGS="$am_save_LDFLAGS" 93 LIBS="$am_save_LIBS" 94 fi 95 96 if test "x$found_zlib" = "xyes"; then 97 AC_DEFINE([HAVE_ZLIB], 1, [Define to 1 if you have the 'zlib' library (-lz)]) 98 AC_MSG_RESULT(yes) 99 else 100 ZLIB_CFLAGS="" 101 ZLIB_LDFLAGS="" 102 ZLIB_LIBS="" 103 fi 104 105 AC_SUBST(ZLIB_CFLAGS) 106 AC_SUBST(ZLIB_LDFLAGS) 107 AC_SUBST(ZLIB_LIBS) 108])dnl 109