cannam@125: # extra_pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- cannam@125: # cannam@125: # Copyright (c) 2008-2012 Erik de Castro Lopo cannam@125: # Copyright (c) 2004 Scott James Remnant . cannam@125: # cannam@125: # This program is free software; you can redistribute it and/or modify cannam@125: # it under the terms of the GNU General Public License as published by cannam@125: # the Free Software Foundation; either version 2 of the License, or cannam@125: # (at your option) any later version. cannam@125: # cannam@125: # This program is distributed in the hope that it will be useful, but cannam@125: # WITHOUT ANY WARRANTY; without even the implied warranty of cannam@125: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU cannam@125: # General Public License for more details. cannam@125: # cannam@125: # You should have received a copy of the GNU General Public License cannam@125: # along with this program; if not, write to the Free Software cannam@125: # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. cannam@125: # cannam@125: # As a special exception to the GNU General Public License, if you cannam@125: # distribute this file as part of a program that contains a cannam@125: # configuration script generated by Autoconf, you may include it under cannam@125: # the same distribution terms that you use for the rest of that program. cannam@125: cannam@125: # -------------------------------------------------------------- cannam@125: # PKG_CHECK_MOD_VERSION(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], cannam@125: # [ACTION-IF-NOT-FOUND]) cannam@125: # cannam@125: # This is a very slight modification to the macro PKG_CHECK_MODULES that cannam@125: # is in the original pkg.m4 file. It prints the versions in the checking cannam@125: # message (erikd@mega-nerd.com). cannam@125: cannam@125: AC_DEFUN([PKG_CHECK_MOD_VERSION], cannam@125: [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl cannam@125: AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl cannam@125: AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl cannam@125: cannam@125: pkg_failed=no cannam@125: AC_MSG_CHECKING([for $2 ]) cannam@125: cannam@125: _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) cannam@125: _PKG_CONFIG([$1][_LIBS], [libs], [$2]) cannam@125: cannam@125: pkg_link_saved_CFLAGS=$CFLAGS cannam@125: pkg_link_saved_LIBS=$LIBS cannam@125: cannam@125: eval "pkg_CFLAGS=\${pkg_cv_[]$1[]_CFLAGS}" cannam@125: eval "pkg_LIBS=\${pkg_cv_[]$1[]_LIBS}" cannam@125: cannam@125: CFLAGS="$CFLAGS $pkg_CFLAGS" cannam@125: LIBS="$LIBS $pkg_LIBS" cannam@125: cannam@125: AC_TRY_LINK([], puts ("");, pkg_link=yes, pkg_link=no) cannam@125: cannam@125: CFLAGS=$pkg_link_saved_CFLAGS cannam@125: LIBS=$pkg_link_saved_LIBS cannam@125: cannam@125: if test $pkg_link = no ; then cannam@125: $as_echo_n "link failed ... " cannam@125: pkg_failed=yes cannam@125: fi cannam@125: cannam@125: m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS cannam@125: and $1[]_LIBS to avoid the need to call pkg-config. cannam@125: See the pkg-config man page for more details.]) cannam@125: cannam@125: if test $pkg_failed = yes; then cannam@125: _PKG_SHORT_ERRORS_SUPPORTED cannam@125: if test $_pkg_short_errors_supported = yes; then cannam@125: $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"` cannam@125: else cannam@125: $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` cannam@125: fi cannam@125: # Put the nasty error message in config.log where it belongs cannam@125: echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD cannam@125: cannam@125: ifelse([$4], , [AC_MSG_ERROR(dnl cannam@125: [Package requirements ($2) were not met: cannam@125: cannam@125: $$1_PKG_ERRORS cannam@125: cannam@125: Consider adjusting the PKG_CONFIG_PATH environment variable if you cannam@125: installed software in a non-standard prefix. cannam@125: cannam@125: _PKG_TEXT cannam@125: ])], cannam@125: [AC_MSG_RESULT([no]) cannam@125: $4]) cannam@125: elif test $pkg_failed = untried; then cannam@125: ifelse([$4], , [AC_MSG_FAILURE(dnl cannam@125: [The pkg-config script could not be found or is too old. Make sure it cannam@125: is in your PATH or set the PKG_CONFIG environment variable to the full cannam@125: path to pkg-config. cannam@125: cannam@125: _PKG_TEXT cannam@125: cannam@125: To get pkg-config, see .])], cannam@125: [$4]) cannam@125: else cannam@125: $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS cannam@125: $1[]_LIBS=$pkg_cv_[]$1[]_LIBS cannam@125: AC_MSG_RESULT([yes]) cannam@125: ifelse([$3], , :, [$3]) cannam@125: fi[]dnl cannam@125: ])# PKG_CHECK_MOD_VERSION