1 ## Copyright (C) 1996-2015 The Squid Software Foundation and contributors
3 ## Squid software is distributed under GPLv2+ license and includes
4 ## contributions from numerous individuals and organizations.
5 ## Please see the COPYING and CONTRIBUTORS files for details.
8 # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
9 # serial 1 (pkg-config-0.24)
11 # Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
13 # This program is free software; you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 2 of the License, or
16 # (at your option) any later version.
18 # This program is distributed in the hope that it will be useful, but
19 # WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 # General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 # As a special exception to the GNU General Public License, if you
28 # distribute this file as part of a program that contains a
29 # configuration script generated by Autoconf, you may include it under
30 # the same distribution terms that you use for the rest of that program.
32 # PKG_PROG_PKG_CONFIG([MIN-VERSION])
33 # ----------------------------------
34 AC_DEFUN([PKG_PROG_PKG_CONFIG],
35 [m4_pattern_forbid([^_?PKG_[A-Z_]+$])
36 m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
37 AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
38 AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
39 AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
41 if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
42 AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
44 if test -n "$PKG_CONFIG"; then
45 _pkg_min_version=m4_default([$1], [0.9.0])
46 AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
47 if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
54 ])# PKG_PROG_PKG_CONFIG
56 # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
58 # Check to see whether a particular set of modules exists. Similar
59 # to PKG_CHECK_MODULES(), but does not set variables or print errors.
61 # Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
62 # only at the first occurence in configure.ac, so if the first place
63 # it's called might be skipped (such as if it is within an "if", you
64 # have to call PKG_CHECK_EXISTS manually
65 # --------------------------------------------------------------
66 AC_DEFUN([PKG_CHECK_EXISTS],
67 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
68 if test -n "$PKG_CONFIG" && \
69 AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
75 # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
76 # ---------------------------------------------
77 m4_define([_PKG_CONFIG],
78 [if test -n "$$1"; then
80 elif test -n "$PKG_CONFIG"; then
81 PKG_CHECK_EXISTS([$3],
82 [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
89 # _PKG_SHORT_ERRORS_SUPPORTED
90 # -----------------------------
91 AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
92 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])
93 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
94 _pkg_short_errors_supported=yes
96 _pkg_short_errors_supported=no
98 ])# _PKG_SHORT_ERRORS_SUPPORTED
101 # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
102 # [ACTION-IF-NOT-FOUND])
105 # Note that if there is a possibility the first call to
106 # PKG_CHECK_MODULES might not happen, you should be sure to include an
107 # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
110 # --------------------------------------------------------------
111 AC_DEFUN([PKG_CHECK_MODULES],
112 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
113 AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
114 AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
117 AC_MSG_CHECKING([for $1])
119 _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
120 _PKG_CONFIG([$1][_LIBS], [libs], [$2])
122 m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
123 and $1[]_LIBS to avoid the need to call pkg-config.
124 See the pkg-config man page for more details.])
126 if test $pkg_failed = yes; then
128 _PKG_SHORT_ERRORS_SUPPORTED
129 if test $_pkg_short_errors_supported = yes; then
130 $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
132 $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
134 # Put the nasty error message in config.log where it belongs
135 echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
137 m4_default([$4], [AC_MSG_ERROR(
138 [Package requirements ($2) were not met:
142 Consider adjusting the PKG_CONFIG_PATH environment variable if you
143 installed software in a non-standard prefix.
147 elif test $pkg_failed = untried; then
149 m4_default([$4], [AC_MSG_FAILURE(
150 [The pkg-config script could not be found or is too old. Make sure it
151 is in your PATH or set the PKG_CONFIG environment variable to the full
156 To get pkg-config, see <http://pkg-config.freedesktop.org/>.])dnl
159 $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
160 $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
164 ])# PKG_CHECK_MODULES