2 # This file is part of the aMule Project.
4 # Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
6 # Any parts of this program derived from the xMule, lMule or eMule project,
7 # or contributed by third-party developers are copyrighted by their
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 dnl ----------------------------------------------------
26 dnl MULE_CHECK_ZLIB([MIN_ZLIB_VERSION = 1.1.4], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
28 dnl check if zlib is on the system and is at least MIN_ZLIB_VERSION
30 dnl Add support for --with-zlib command-line parameter.
31 dnl PREFIX may be a directory prefix where zlib is installed, e.g. /usr/local
32 dnl or may be one of the following special keywords:
33 dnl sys - use system zlib
35 dnl Will set the output variables:
39 dnl ----------------------------------------------------
40 AC_DEFUN([MULE_CHECK_ZLIB],
42 m4_define([MIN_ZLIB_VERSION], [m4_ifval([$1], [$1], [1.1.4])])dnl
43 m4_define([zver_max], [m4_bregexp(MIN_ZLIB_VERSION, [\([0-9]+\)\.\([0-9]+\)\.\([0-9]+\)], [\1])])dnl
44 m4_define([zver_mid], [m4_bregexp(MIN_ZLIB_VERSION, [\([0-9]+\)\.\([0-9]+\)\.\([0-9]+\)], [\2])])dnl
45 m4_define([zver_min], [m4_bregexp(MIN_ZLIB_VERSION, [\([0-9]+\)\.\([0-9]+\)\.\([0-9]+\)], [\3])])dnl
47 AC_ARG_WITH([zlib], AS_HELP_STRING([--with-zlib=PREFIX], [use zlib in PREFIX]))
49 case "${with_zlib:-yes}" in
56 zlib_prefix="$with_zlib"
59 MULE_BACKUP([CPPFLAGS])
60 MULE_BACKUP([LDFLAGS])
62 AS_IF([test -n "$zlib_prefix"],
64 ZLIB_CPPFLAGS="-I$zlib_prefix/include"
65 ZLIB_LDFLAGS="-L$zlib_prefix/lib"
66 MULE_APPEND([CPPFLAGS], [$ZLIB_CPPFLAGS])
67 MULE_APPEND([LDFLAGS], [$ZLIB_LDFLAGS])
73 MULE_PREPEND([LIBS], [$ZLIB_LIBS])
75 AC_MSG_CHECKING([for zlib >= $1])
80 ]], [dnl Do not use double-quoting here!
81 char *zver = zlibVersion();
82 FILE *f=fopen("conftestval", "w");
85 zver[[0]] > 'zver_max' ||
86 (zver[[0]] == 'zver_max' &&
87 (zver[[2]] > 'zver_mid' ||
88 (zver[[2]] == 'zver_mid' &&
89 zver[[4]] >= 'zver_min'))) ? "yes" : "no");
91 f=fopen("conftestver", "w");
93 fprintf(f, "%s", ZLIB_VERSION);
98 AS_IF([test -f conftestval], [result=`cat conftestval`], [result=no])
99 AS_IF([test ${result:-no} = yes],
101 AS_IF([test -f conftestver],
103 ZLIB_VERSION=`cat conftestver`
104 z_version=" (version $ZLIB_VERSION)"
107 AC_MSG_RESULT([$result$z_version])
110 AC_MSG_RESULT([$result])
119 printf("\nZLIB_VERSION_START" ZLIB_VERSION "ZLIB_VERSION_END\n\n");
123 ZLIB_VERSION=`grep -a '^ZLIB_VERSION_START.*ZLIB_VERSION_END$' conftest$ac_exeext | sed 's/^ZLIB_VERSION_START\(.*\)ZLIB_VERSION_END$/\1/'`
124 cross_zver_max="`echo $ZLIB_VERSION | cut -d. -f1`"
125 cross_zver_mid="`echo $ZLIB_VERSION | cut -d. -f2`"
126 cross_zver_min="`echo $ZLIB_VERSION | cut -d. -f3`"
127 MULE_IF([test "$cross_zver_max" -gt "zver_max"], [result=yes],
128 [test "$cross_zver_max" -eq "zver_max"], [
129 MULE_IF([test "$cross_zver_mid" -gt "zver_mid"], [result=yes],
130 [test "$cross_zver_mid" -eq "zver_mid"],
131 [MULE_IF([test "$cross_zver_min" -ge "zver_min"], [result=yes])])
133 AS_IF([test ${result:-no} = yes], [z_version=" (version $ZLIB_VERSION)"])
135 AC_MSG_RESULT([$result$z_version])
138 MULE_RESTORE([CPPFLAGS])
139 MULE_RESTORE([LDFLAGS])
142 AS_IF([test ${result:-no} = no], [
149 AC_SUBST([ZLIB_CPPFLAGS])dnl
150 AC_SUBST([ZLIB_LDFLAGS])dnl
151 AC_SUBST([ZLIB_LIBS])dnl
152 m4_undefine([zver_max])dnl
153 m4_undefine([zver_mid])dnl
154 m4_undefine([zver_min])dnl
155 m4_undefine([MIN_ZLIB_VERSION])dnl