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