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