1# extra_pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- 2# 3# Copyright (c) 2008-2012 Erik de Castro Lopo <erikd@mega-nerd.com> 4# Copyright (c) 2004 Scott James Remnant <scott@netsplit.com>. 5# 6# This program is free software; you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation; either version 2 of the License, or 9# (at your option) any later version. 10# 11# This program is distributed in the hope that it will be useful, but 12# WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14# General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with this program; if not, write to the Free Software 18# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19# 20# As a special exception to the GNU General Public License, if you 21# distribute this file as part of a program that contains a 22# configuration script generated by Autoconf, you may include it under 23# the same distribution terms that you use for the rest of that program. 24 25# -------------------------------------------------------------- 26# PKG_CHECK_MOD_VERSION(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], 27# [ACTION-IF-NOT-FOUND]) 28# 29# This is a very slight modification to the macro PKG_CHECK_MODULES that 30# is in the original pkg.m4 file. It prints the versions in the checking 31# message (erikd@mega-nerd.com). 32 33AC_DEFUN([PKG_CHECK_MOD_VERSION], 34[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl 35AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl 36AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl 37 38pkg_failed=no 39AC_MSG_CHECKING([for $2 ]) 40 41_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) 42_PKG_CONFIG([$1][_LIBS], [libs], [$2]) 43 44pkg_link_saved_CFLAGS=$CFLAGS 45pkg_link_saved_LIBS=$LIBS 46 47eval "pkg_CFLAGS=\${pkg_cv_[]$1[]_CFLAGS}" 48eval "pkg_LIBS=\${pkg_cv_[]$1[]_LIBS}" 49 50CFLAGS="$CFLAGS $pkg_CFLAGS" 51LIBS="$LIBS $pkg_LIBS" 52 53AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [puts ("")])], pkg_link=yes, pkg_link=no) 54 55CFLAGS=$pkg_link_saved_CFLAGS 56LIBS=$pkg_link_saved_LIBS 57 58if test $pkg_link = no ; then 59 $as_echo_n "link failed ... " 60 pkg_failed=yes 61 fi 62 63m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS 64and $1[]_LIBS to avoid the need to call pkg-config. 65See the pkg-config man page for more details.]) 66 67if test $pkg_failed = yes; then 68 _PKG_SHORT_ERRORS_SUPPORTED 69 if test $_pkg_short_errors_supported = yes; then 70 $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"` 71 else 72 $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` 73 fi 74 # Put the nasty error message in config.log where it belongs 75 echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD 76 77 ifelse([$4], , [AC_MSG_ERROR(dnl 78[Package requirements ($2) were not met: 79 80$$1_PKG_ERRORS 81 82Consider adjusting the PKG_CONFIG_PATH environment variable if you 83installed software in a non-standard prefix. 84 85_PKG_TEXT 86])], 87 [AC_MSG_RESULT([no]) 88 $4]) 89elif test $pkg_failed = untried; then 90 ifelse([$4], , [AC_MSG_FAILURE(dnl 91[The pkg-config script could not be found or is too old. Make sure it 92is in your PATH or set the PKG_CONFIG environment variable to the full 93path to pkg-config. 94 95_PKG_TEXT 96 97To get pkg-config, see <http://pkg-config.freedesktop.org/>.])], 98 [$4]) 99else 100 $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS 101 $1[]_LIBS=$pkg_cv_[]$1[]_LIBS 102 AC_MSG_RESULT([yes]) 103 ifelse([$3], , :, [$3]) 104fi[]dnl 105])# PKG_CHECK_MOD_VERSION 106