acx_with_external_zlib.m4 [plain text]
AC_DEFUN([ACX_WITH_EXTERNAL_ZLIB],[
AC_ARG_WITH([external-zlib],
AC_HELP_STRING([--with-external-zlib],
[Use the specified ZLIB library (defaults to
the version distributed with the CVS source)]),
[with_external_zlib=$withval],
[with_external_zlib=no])
if test -n "$acx_zlib_cv_external_zlib"; then
AC_MSG_CHECKING([for external ZLIB])
else :; fi
AC_CACHE_VAL([acx_zlib_cv_external_zlib], [
acx_zlib_save_CPPFLAGS=$CPPFLAGS
for acx_zlib_cv_external_zlib in yes /usr/local no; do
if test x$acx_zlib_cv_external_zlib = xno; then
break
fi
if test x$acx_zlib_cv_external_zlib = xyes; then
AC_MSG_CHECKING([for external ZLIB])
AC_MSG_RESULT([])
else
CPPFLAGS="$acx_zlib_save_CPPFLAGS -I$acx_zlib_cv_external_zlib/include"
AC_MSG_CHECKING([for external ZLIB in $acx_zlib_cv_external_zlib])
AC_MSG_RESULT([])
fi
unset ac_cv_header_zlib_h
AC_CHECK_HEADERS([zlib.h])
if test "$ac_cv_header_zlib_h" = yes; then
break
fi
done
CPPFLAGS=$acx_zlib_save_CPPFLAGS
AC_MSG_CHECKING([for external ZLIB])
])AC_MSG_RESULT([$acx_zlib_cv_external_zlib])
AC_MSG_CHECKING([selected ZLIB])
if test "x$with_external_zlib" = xno; then
AC_MSG_RESULT([package])
else
AC_MSG_RESULT([external])
fi
if test "x$acx_zlib_cv_external_zlib" != xno; then
LOCAL_ZLIB_VERSION=`sed -n '/^ s/^ p;}' <$srcdir/zlib/zlib.h 2>&AS_MESSAGE_LOG_FD`
ACX_EXTRACT_HEADER_DEFN([ZLIB_VERSION], [zlib.h])
ZLIB_VERSION=`echo "$ZLIB_VERSION" |sed 's/"//g'`
ASX_VERSION_COMPARE([$LOCAL_ZLIB_VERSION], [$ZLIB_VERSION],
[if test "x$with_external_zlib" = xno; then
AC_MSG_WARN(
[Found external ZLIB with a more recent version than the
package version ($ZLIB_VERSION > $LOCAL_ZLIB_VERSION). configure with the
--with-external-zlib option to select the more recent version.])
fi],
[],
[if test "x$with_external_zlib" != xno; then
AC_MSG_WARN(
[Package ZLIB is more recent than requested external version
($LOCAL_ZLIB_VERSION > $ZLIB_VERSION). configure with the --without-external-zlib
option to select the more recent version.])
fi])
fi
if test x$with_external_zlib = xyes; then
with_external_zlib=$acx_zlib_cv_external_zlib
fi
if test x$with_external_zlib != xyes \
&& test x$with_external_zlib != no; then
if test -z "$CPPFLAGS"; then
CPPFLAGS="-I$with_external_zlib/include"
else
CPPFLAGS="$CPPFLAGS -I$with_external_zlib/include"
fi
if test -z "$LDFLAGS"; then
LDFLAGS="-L$with_external_zlib/lib"
else
LDFLAGS="$LDFLAGS -L$with_external_zlib/lib"
fi
fi
ZLIB_CPPFLAGS=
ZLIB_LIBS=
ZLIB_SUBDIRS=
if test x$with_external_zlib = xno; then
ZLIB_CPPFLAGS='-I$(top_srcdir)/zlib'
ZLIB_LIBS='$(top_builddir)/zlib/libz.a'
ZLIB_SUBDIRS=zlib
else
if test -z "$LIBS"; then
LIBS=-lz
else
LIBS="$LIBS -lz"
fi
AC_MSG_CHECKING([that ZLIB library works])
AC_TRY_LINK([ [int i = Z_OK; const char *version = zlibVersion();],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([ZLIB failed to link])])
fi
AC_SUBST(ZLIB_SUBDIRS)AC_SUBST(ZLIB_CPPFLAGS)AC_SUBST(ZLIB_LIBS)])