Blame m4/ax_check_zlib.m4

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