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