Blame m4/pkg.m4

Packit 5e46da
# pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
Packit 5e46da
# serial 1 (pkg-config-0.24)
Packit 5e46da
# 
Packit 5e46da
# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
Packit 5e46da
#
Packit 5e46da
# This program is free software; you can redistribute it and/or modify
Packit 5e46da
# it under the terms of the GNU General Public License as published by
Packit 5e46da
# the Free Software Foundation; either version 2 of the License, or
Packit 5e46da
# (at your option) any later version.
Packit 5e46da
#
Packit 5e46da
# This program is distributed in the hope that it will be useful, but
Packit 5e46da
# WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 5e46da
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 5e46da
# General Public License for more details.
Packit 5e46da
#
Packit 5e46da
# You should have received a copy of the GNU General Public License
Packit 5e46da
# along with this program; if not, write to the Free Software
Packit 5e46da
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Packit 5e46da
#
Packit 5e46da
# As a special exception to the GNU General Public License, if you
Packit 5e46da
# distribute this file as part of a program that contains a
Packit 5e46da
# configuration script generated by Autoconf, you may include it under
Packit 5e46da
# the same distribution terms that you use for the rest of that program.
Packit 5e46da
Packit 5e46da
# PKG_PROG_PKG_CONFIG([MIN-VERSION])
Packit 5e46da
# ----------------------------------
Packit 5e46da
AC_DEFUN([PKG_PROG_PKG_CONFIG],
Packit 5e46da
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
Packit 5e46da
m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
Packit 5e46da
AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
Packit 5e46da
AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
Packit 5e46da
AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
Packit 5e46da
Packit 5e46da
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
Packit 5e46da
	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
Packit 5e46da
fi
Packit 5e46da
if test -n "$PKG_CONFIG"; then
Packit 5e46da
	_pkg_min_version=m4_default([$1], [0.9.0])
Packit 5e46da
	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
Packit 5e46da
	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
Packit 5e46da
		AC_MSG_RESULT([yes])
Packit 5e46da
	else
Packit 5e46da
		AC_MSG_RESULT([no])
Packit 5e46da
		PKG_CONFIG=""
Packit 5e46da
	fi
Packit 5e46da
fi[]dnl
Packit 5e46da
])# PKG_PROG_PKG_CONFIG
Packit 5e46da
Packit 5e46da
# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
Packit 5e46da
#
Packit 5e46da
# Check to see whether a particular set of modules exists.  Similar
Packit 5e46da
# to PKG_CHECK_MODULES(), but does not set variables or print errors.
Packit 5e46da
#
Packit 5e46da
# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
Packit 5e46da
# only at the first occurence in configure.ac, so if the first place
Packit 5e46da
# it's called might be skipped (such as if it is within an "if", you
Packit 5e46da
# have to call PKG_CHECK_EXISTS manually
Packit 5e46da
# --------------------------------------------------------------
Packit 5e46da
AC_DEFUN([PKG_CHECK_EXISTS],
Packit 5e46da
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
Packit 5e46da
if test -n "$PKG_CONFIG" && \
Packit 5e46da
    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
Packit 5e46da
  m4_default([$2], [:])
Packit 5e46da
m4_ifvaln([$3], [else
Packit 5e46da
  $3])dnl
Packit 5e46da
fi])
Packit 5e46da
Packit 5e46da
# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
Packit 5e46da
# ---------------------------------------------
Packit 5e46da
m4_define([_PKG_CONFIG],
Packit 5e46da
[if test -n "$$1"; then
Packit 5e46da
    pkg_cv_[]$1="$$1"
Packit 5e46da
 elif test -n "$PKG_CONFIG"; then
Packit 5e46da
    PKG_CHECK_EXISTS([$3],
Packit 5e46da
                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
Packit 5e46da
		     [pkg_failed=yes])
Packit 5e46da
 else
Packit 5e46da
    pkg_failed=untried
Packit 5e46da
fi[]dnl
Packit 5e46da
])# _PKG_CONFIG
Packit 5e46da
Packit 5e46da
# _PKG_SHORT_ERRORS_SUPPORTED
Packit 5e46da
# -----------------------------
Packit 5e46da
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
Packit 5e46da
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
Packit 5e46da
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
Packit 5e46da
        _pkg_short_errors_supported=yes
Packit 5e46da
else
Packit 5e46da
        _pkg_short_errors_supported=no
Packit 5e46da
fi[]dnl
Packit 5e46da
])# _PKG_SHORT_ERRORS_SUPPORTED
Packit 5e46da
Packit 5e46da
Packit 5e46da
# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
Packit 5e46da
# [ACTION-IF-NOT-FOUND])
Packit 5e46da
#
Packit 5e46da
#
Packit 5e46da
# Note that if there is a possibility the first call to
Packit 5e46da
# PKG_CHECK_MODULES might not happen, you should be sure to include an
Packit 5e46da
# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
Packit 5e46da
#
Packit 5e46da
#
Packit 5e46da
# --------------------------------------------------------------
Packit 5e46da
AC_DEFUN([PKG_CHECK_MODULES],
Packit 5e46da
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
Packit 5e46da
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
Packit 5e46da
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
Packit 5e46da
Packit 5e46da
pkg_failed=no
Packit 5e46da
AC_MSG_CHECKING([for $1])
Packit 5e46da
Packit 5e46da
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
Packit 5e46da
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
Packit 5e46da
Packit 5e46da
m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
Packit 5e46da
and $1[]_LIBS to avoid the need to call pkg-config.
Packit 5e46da
See the pkg-config man page for more details.])
Packit 5e46da
Packit 5e46da
if test $pkg_failed = yes; then
Packit 5e46da
   	AC_MSG_RESULT([no])
Packit 5e46da
        _PKG_SHORT_ERRORS_SUPPORTED
Packit 5e46da
        if test $_pkg_short_errors_supported = yes; then
Packit 5e46da
	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
Packit 5e46da
        else 
Packit 5e46da
	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
Packit 5e46da
        fi
Packit 5e46da
	# Put the nasty error message in config.log where it belongs
Packit 5e46da
	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
Packit 5e46da
Packit 5e46da
	m4_default([$4], [AC_MSG_ERROR(
Packit 5e46da
[Package requirements ($2) were not met:
Packit 5e46da
Packit 5e46da
$$1_PKG_ERRORS
Packit 5e46da
Packit 5e46da
Consider adjusting the PKG_CONFIG_PATH environment variable if you
Packit 5e46da
installed software in a non-standard prefix.
Packit 5e46da
Packit 5e46da
_PKG_TEXT])
Packit 5e46da
        ])
Packit 5e46da
elif test $pkg_failed = untried; then
Packit 5e46da
     	AC_MSG_RESULT([no])
Packit 5e46da
	m4_default([$4], [AC_MSG_FAILURE(
Packit 5e46da
[The pkg-config script could not be found or is too old.  Make sure it
Packit 5e46da
is in your PATH or set the PKG_CONFIG environment variable to the full
Packit 5e46da
path to pkg-config.
Packit 5e46da
Packit 5e46da
_PKG_TEXT
Packit 5e46da
Packit 5e46da
To get pkg-config, see <http://pkg-config.freedesktop.org/>.])
Packit 5e46da
        ])
Packit 5e46da
else
Packit 5e46da
	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
Packit 5e46da
	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
Packit 5e46da
        AC_MSG_RESULT([yes])
Packit 5e46da
	$3
Packit 5e46da
fi[]dnl
Packit 5e46da
])# PKG_CHECK_MODULES