Blame m4/pkg.m4

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