|
Packit |
8f70b4 |
# ===========================================================================
|
|
Packit |
8f70b4 |
# http://www.gnu.org/software/autoconf-archive/ax_check_zlib.html
|
|
Packit |
8f70b4 |
# ===========================================================================
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
# SYNOPSIS
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
# AX_CHECK_ZLIB([action-if-found], [action-if-not-found])
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
# DESCRIPTION
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
# This macro searches for an installed zlib library. If nothing was
|
|
Packit |
8f70b4 |
# specified when calling configure, it searches first in /usr/local and
|
|
Packit |
8f70b4 |
# then in /usr, /opt/local and /sw. If the --with-zlib=DIR is specified,
|
|
Packit |
8f70b4 |
# it will try to find it in DIR/include/zlib.h and DIR/lib/libz.a. If
|
|
Packit |
8f70b4 |
# --without-zlib is specified, the library is not searched at all.
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
# If either the header file (zlib.h) or the library (libz) is not found,
|
|
Packit |
8f70b4 |
# shell commands 'action-if-not-found' is run. If 'action-if-not-found' is
|
|
Packit |
8f70b4 |
# not specified, the configuration exits on error, asking for a valid zlib
|
|
Packit |
8f70b4 |
# installation directory or --without-zlib.
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
# If both header file and library are found, shell commands
|
|
Packit |
8f70b4 |
# 'action-if-found' is run. If 'action-if-found' is not specified, the
|
|
Packit |
8f70b4 |
# default action appends '-I${ZLIB_HOME}/include' to CPFLAGS, appends
|
|
Packit |
8f70b4 |
# '-L$ZLIB_HOME}/lib' to LDFLAGS, prepends '-lz' to LIBS, and calls
|
|
Packit |
8f70b4 |
# AC_DEFINE(HAVE_LIBZ). You should use autoheader to include a definition
|
|
Packit |
8f70b4 |
# for this symbol in a config.h file. Sample usage in a C/C++ source is as
|
|
Packit |
8f70b4 |
# follows:
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
# #ifdef HAVE_LIBZ
|
|
Packit |
8f70b4 |
# #include <zlib.h>
|
|
Packit |
8f70b4 |
# #endif /* HAVE_LIBZ */
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
# LICENSE
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
# Copyright (c) 2008 Loic Dachary <loic@senga.org>
|
|
Packit |
8f70b4 |
# Copyright (c) 2010 Bastien Chevreux <bach@chevreux.org>
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
# This program is free software; you can redistribute it and/or modify it
|
|
Packit |
8f70b4 |
# under the terms of the GNU General Public License as published by the
|
|
Packit |
8f70b4 |
# Free Software Foundation; either version 2 of the License, or (at your
|
|
Packit |
8f70b4 |
# option) any later version.
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
# This program is distributed in the hope that it will be useful, but
|
|
Packit |
8f70b4 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
8f70b4 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
Packit |
8f70b4 |
# Public License for more details.
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
# You should have received a copy of the GNU General Public License along
|
|
Packit |
8f70b4 |
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
# As a special exception, the respective Autoconf Macro's copyright owner
|
|
Packit |
8f70b4 |
# gives unlimited permission to copy, distribute and modify the configure
|
|
Packit |
8f70b4 |
# scripts that are the output of Autoconf when processing the Macro. You
|
|
Packit |
8f70b4 |
# need not follow the terms of the GNU General Public License when using
|
|
Packit |
8f70b4 |
# or distributing such scripts, even though portions of the text of the
|
|
Packit |
8f70b4 |
# Macro appear in them. The GNU General Public License (GPL) does govern
|
|
Packit |
8f70b4 |
# all other use of the material that constitutes the Autoconf Macro.
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
# This special exception to the GPL applies to versions of the Autoconf
|
|
Packit |
8f70b4 |
# Macro released by the Autoconf Archive. When you make and distribute a
|
|
Packit |
8f70b4 |
# modified version of the Autoconf Macro, you may extend this special
|
|
Packit |
8f70b4 |
# exception to the GPL to apply to your modified version as well.
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
#serial 14
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
AU_ALIAS([CHECK_ZLIB], [AX_CHECK_ZLIB])
|
|
Packit |
8f70b4 |
AC_DEFUN([AX_CHECK_ZLIB],
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
# Handle user hints
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
[AC_MSG_CHECKING(if zlib is wanted)
|
|
Packit |
8f70b4 |
zlib_places="/usr/local /usr /opt/local /sw"
|
|
Packit |
8f70b4 |
AC_ARG_WITH([zlib],
|
|
Packit |
8f70b4 |
[ --with-zlib=DIR root directory path of zlib installation @<:@defaults to
|
|
Packit |
8f70b4 |
/usr/local or /usr if not found in /usr/local@:>@
|
|
Packit |
8f70b4 |
--without-zlib to disable zlib usage completely],
|
|
Packit |
8f70b4 |
[if test "$withval" != no ; then
|
|
Packit |
8f70b4 |
AC_MSG_RESULT(yes)
|
|
Packit |
8f70b4 |
if test -d "$withval"
|
|
Packit |
8f70b4 |
then
|
|
Packit |
8f70b4 |
zlib_places="$withval $zlib_places"
|
|
Packit |
8f70b4 |
else
|
|
Packit |
8f70b4 |
AC_MSG_WARN([Sorry, $withval does not exist, checking usual places])
|
|
Packit |
8f70b4 |
fi
|
|
Packit |
8f70b4 |
else
|
|
Packit |
8f70b4 |
zlib_places=
|
|
Packit |
8f70b4 |
AC_MSG_RESULT(no)
|
|
Packit |
8f70b4 |
fi],
|
|
Packit |
8f70b4 |
[AC_MSG_RESULT(yes)])
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
# Locate zlib, if wanted
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
if test -n "${zlib_places}"
|
|
Packit |
8f70b4 |
then
|
|
Packit |
8f70b4 |
# check the user supplied or any other more or less 'standard' place:
|
|
Packit |
8f70b4 |
# Most UNIX systems : /usr/local and /usr
|
|
Packit |
8f70b4 |
# MacPorts / Fink on OSX : /opt/local respectively /sw
|
|
Packit |
8f70b4 |
for ZLIB_HOME in ${zlib_places} ; do
|
|
Packit |
8f70b4 |
if test -f "${ZLIB_HOME}/include/zlib.h"; then break; fi
|
|
Packit |
8f70b4 |
ZLIB_HOME=""
|
|
Packit |
8f70b4 |
done
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
ZLIB_OLD_LDFLAGS="$LDFLAGS"
|
|
Packit |
8f70b4 |
ZLIB_OLD_CPPFLAGS="$CPPFLAGS"
|
|
Packit |
8f70b4 |
if test -n "${ZLIB_HOME}"; then
|
|
Packit |
8f70b4 |
LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
|
|
Packit |
8f70b4 |
CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
|
|
Packit |
8f70b4 |
fi
|
|
Packit |
8f70b4 |
AC_LANG_SAVE
|
|
Packit |
8f70b4 |
AC_LANG_C
|
|
Packit |
8f70b4 |
AC_CHECK_LIB([z], [inflateEnd], [zlib_cv_libz=yes], [zlib_cv_libz=no])
|
|
Packit |
8f70b4 |
AC_CHECK_HEADER([zlib.h], [zlib_cv_zlib_h=yes], [zlib_cv_zlib_h=no])
|
|
Packit |
8f70b4 |
AC_LANG_RESTORE
|
|
Packit |
8f70b4 |
if test "$zlib_cv_libz" = "yes" && test "$zlib_cv_zlib_h" = "yes"
|
|
Packit |
8f70b4 |
then
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
# If both library and header were found, action-if-found
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
m4_ifblank([$1],[
|
|
Packit |
8f70b4 |
test "$enable_rpath" = yes -a "$ZLIB_HOME" != /usr && \
|
|
Packit |
8f70b4 |
LDFLAGS="$LDFLAGS -R${ZLIB_HOME}/lib"
|
|
Packit |
8f70b4 |
LIBS="-lz $LIBS"
|
|
Packit |
8f70b4 |
AC_DEFINE([HAVE_LIBZ], [1],
|
|
Packit |
8f70b4 |
[Define to 1 if you have `z' library (-lz)])
|
|
Packit |
8f70b4 |
],[
|
|
Packit |
8f70b4 |
# Restore variables
|
|
Packit |
8f70b4 |
LDFLAGS="$ZLIB_OLD_LDFLAGS"
|
|
Packit |
8f70b4 |
CPPFLAGS="$ZLIB_OLD_CPPFLAGS"
|
|
Packit |
8f70b4 |
$1
|
|
Packit |
8f70b4 |
])
|
|
Packit |
8f70b4 |
else
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
# If either header or library was not found, action-if-not-found
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
m4_default([$2],[
|
|
Packit |
8f70b4 |
AC_MSG_ERROR([either specify a valid zlib installation with --with-zlib=DIR or disable zlib usage with --without-zlib])
|
|
Packit |
8f70b4 |
])
|
|
Packit |
8f70b4 |
fi
|
|
Packit |
8f70b4 |
fi
|
|
Packit |
8f70b4 |
])
|