1 dnl ----------------------------------------------------
4 dnl Add support for --with-zlib command-line parameter.
5 dnl PREFIX may be a directory prefix where zlib is installed, e.g. /usr/local
6 dnl or may be one of the following special keywords:
7 dnl sys - use system zlib
8 dnl ----------------------------------------------------
9 AC_DEFUN([AC_OPTIONS_ZLIB],
15 [use zlib in PREFIX]),
21 dnl ----------------------------------------------------
22 dnl AC_CHECK_ZLIB([MIN_ZLIB_VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
23 dnl check if zlib is on the system and is at least MIN_ZLIB_VERSION
24 dnl ----------------------------------------------------
25 AC_DEFUN([AC_CHECK_ZLIB],
26 [AC_REQUIRE([AC_OPTIONS_ZLIB])dnl
27 m4_define([ac_zver_max], [m4_bregexp([$1], [\([0-9]+\)\.\([0-9]+\)\.\([0-9]+\)], [\1])])dnl
28 m4_define([ac_zver_mid], [m4_bregexp([$1], [\([0-9]+\)\.\([0-9]+\)\.\([0-9]+\)], [\2])])dnl
29 m4_define([ac_zver_min], [m4_bregexp([$1], [\([0-9]+\)\.\([0-9]+\)\.\([0-9]+\)], [\3])])dnl
33 ifelse([$3], , :, [$3])
38 ac_zlib_prefix="$ac_zlib"
41 if test -n "$ac_zlib_prefix"; then
42 ac_tmp_CPPFLAGS="$CPPFLAGS"
43 ac_tmp_LDFLAGS="$LDFLAGS"
44 CPPFLAGS="$CPPFLAGS -I$ac_zlib_prefix/include"
45 LDFLAGS="-L$ac_zlib_prefix/lib"
49 AC_MSG_CHECKING([for zlib >= $1])
54 ]], [dnl Do not use double-quoting here!
55 char *zver = zlibVersion();
56 FILE *f=fopen("conftestval", "w");
59 zver[[0]] > 'ac_zver_max' ||
60 (zver[[0]] == 'ac_zver_max' &&
61 (zver[[2]] > 'ac_zver_mid' ||
62 (zver[[2]] == 'ac_zver_mid' &&
63 zver[[4]] >= 'ac_zver_min'))) ? "yes" : "no");
65 f=fopen("conftestver", "w");
67 fprintf(f, "%s", ZLIB_VERSION);
72 if test -f conftestval; then
73 result=`cat conftestval`
77 if test x$result = xyes; then
78 if test -f conftestver; then
79 ZLIB_VERSION=`cat conftestver`
80 z_version=" (version $ZLIB_VERSION)"
85 AC_MSG_RESULT([$result$z_version])
88 AC_MSG_RESULT([$result])
97 printf("\nZLIB_VERSION_START" ZLIB_VERSION "ZLIB_VERSION_END\n\n");
101 ZLIB_VERSION=`grep -a '^ZLIB_VERSION_START.*ZLIB_VERSION_END$' conftest$ac_exeext | sed 's/^ZLIB_VERSION_START\(.*\)ZLIB_VERSION_END$/\1/'`
102 ac_cross_zver_max="`echo $ZLIB_VERSION | cut -d. -f1`"
103 ac_cross_zver_mid="`echo $ZLIB_VERSION | cut -d. -f2`"
104 ac_cross_zver_min="`echo $ZLIB_VERSION | cut -d. -f3`"
105 if test "$ac_cross_zver_max" -gt "ac_zver_max"; then
107 elif test "$ac_cross_zver_max" -eq "ac_zver_max"; then
108 if test "$ac_cross_zver_mid" -gt "ac_zver_mid"; then
110 elif "$ac_cross_zver_mid" -eq "ac_zver_mid"; then
111 if test "$ac_cross_zver_min" -ge "ac_zver_min"; then
116 if test x$result = xyes; then
117 z_version=" (version $ZLIB_VERSION)"
120 AC_MSG_RESULT([$result$z_version])
122 AS_IF([test x$result = xno], [
123 if test "${ac_tmp_CPPFLAGS+set}" = set; then
124 CPPFLAGS="$ac_tmp_CPPFLAGS"
126 if test "${ac_tmp_LDFLAGS+set}" = set; then
127 LDFLAGS="$ac_tmp_LDFLAGS"
133 m4_undefine([ac_zver_max])dnl
134 m4_undefine([ac_zver_mid])dnl
135 m4_undefine([ac_zver_min])dnl