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