@@ -20,6 +20,282 @@ You have another version of autoconf. It may work, but is not guaranteed to.
2020If you have problems, you may need to regenerate the build system entirely.
2121To do so, use the procedure documented by the package, typically 'autoreconf'.] )] )
2222
23+ dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
24+ dnl serial 11 (pkg-config-0.29.1)
25+ dnl
26+ dnl Copyright © 2004 Scott James Remnant <[email protected] >.27+ dnl Copyright © 2012-2015 Dan Nicholson <[email protected] >28+ dnl
29+ dnl This program is free software; you can redistribute it and/or modify
30+ dnl it under the terms of the GNU General Public License as published by
31+ dnl the Free Software Foundation; either version 2 of the License, or
32+ dnl (at your option) any later version.
33+ dnl
34+ dnl This program is distributed in the hope that it will be useful, but
35+ dnl WITHOUT ANY WARRANTY; without even the implied warranty of
36+ dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
37+ dnl General Public License for more details.
38+ dnl
39+ dnl You should have received a copy of the GNU General Public License
40+ dnl along with this program; if not, write to the Free Software
41+ dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
42+ dnl 02111-1307, USA.
43+ dnl
44+ dnl As a special exception to the GNU General Public License, if you
45+ dnl distribute this file as part of a program that contains a
46+ dnl configuration script generated by Autoconf, you may include it under
47+ dnl the same distribution terms that you use for the rest of that
48+ dnl program.
49+
50+ dnl PKG_PREREQ(MIN-VERSION)
51+ dnl -----------------------
52+ dnl Since: 0.29
53+ dnl
54+ dnl Verify that the version of the pkg-config macros are at least
55+ dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
56+ dnl installed version of pkg-config, this checks the developer's version
57+ dnl of pkg.m4 when generating configure.
58+ dnl
59+ dnl To ensure that this macro is defined, also add:
60+ dnl m4_ifndef([PKG_PREREQ],
61+ dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
62+ dnl
63+ dnl See the "Since" comment for each macro you use to see what version
64+ dnl of the macros you require.
65+ m4_defun([ PKG_PREREQ] ,
66+ [ m4_define ( [ PKG_MACROS_VERSION] , [ 0.29.1] )
67+ m4_if ( m4_version_compare ( PKG_MACROS_VERSION , [ $1 ] ) , - 1 ,
68+ [ m4_fatal ( [ pkg.m4 version $1 or higher is required but ] PKG_MACROS_VERSION [ found] ) ] )
69+ ] )dnl PKG_PREREQ
70+
71+ dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
72+ dnl ----------------------------------
73+ dnl Since: 0.16
74+ dnl
75+ dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
76+ dnl first found in the path. Checks that the version of pkg-config found
77+ dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
78+ dnl used since that's the first version where most current features of
79+ dnl pkg-config existed.
80+ AC_DEFUN ( [ PKG_PROG_PKG_CONFIG] ,
81+ [ m4_pattern_forbid ( [ ^_?PKG_[ A-Z_] +$] )
82+ m4_pattern_allow ( [ ^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$] )
83+ m4_pattern_allow ( [ ^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$] )
84+ AC_ARG_VAR ( [ PKG_CONFIG] , [ path to pkg-config utility] )
85+ AC_ARG_VAR ( [ PKG_CONFIG_PATH] , [ directories to add to pkg-config's search path] )
86+ AC_ARG_VAR ( [ PKG_CONFIG_LIBDIR] , [ path overriding pkg-config's built-in search path] )
87+
88+ if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
89+ AC_PATH_TOOL ( [ PKG_CONFIG] , [ pkg-config] )
90+ fi
91+ if test -n "$PKG_CONFIG"; then
92+ _pkg_min_version=m4_default ( [ $1 ] , [ 0.9.0] )
93+ AC_MSG_CHECKING ( [ pkg-config is at least version $_pkg_min_version] )
94+ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
95+ AC_MSG_RESULT ( [ yes] )
96+ else
97+ AC_MSG_RESULT ( [ no] )
98+ PKG_CONFIG=""
99+ fi
100+ fi[ ] dnl
101+ ] ) dnl PKG_PROG_PKG_CONFIG
102+
103+ dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
104+ dnl -------------------------------------------------------------------
105+ dnl Since: 0.18
106+ dnl
107+ dnl Check to see whether a particular set of modules exists. Similar to
108+ dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
109+ dnl
110+ dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
111+ dnl only at the first occurence in configure.ac, so if the first place
112+ dnl it's called might be skipped (such as if it is within an "if", you
113+ dnl have to call PKG_CHECK_EXISTS manually
114+ AC_DEFUN ( [ PKG_CHECK_EXISTS] ,
115+ [ AC_REQUIRE ( [ PKG_PROG_PKG_CONFIG] ) dnl
116+ if test -n "$PKG_CONFIG" && \
117+ AC_RUN_LOG([ $PKG_CONFIG --exists --print-errors "$1 "] ); then
118+ m4_default ( [ $2 ] , [ :] )
119+ m4_ifvaln ( [ $3 ] , [ else
120+ $3 ] ) dnl
121+ fi] )
122+
123+ dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
124+ dnl ---------------------------------------------
125+ dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
126+ dnl pkg_failed based on the result.
127+ m4_define ( [ _PKG_CONFIG] ,
128+ [ if test -n "$$1 "; then
129+ pkg_cv_[ ] $1 ="$$1 "
130+ elif test -n "$PKG_CONFIG"; then
131+ PKG_CHECK_EXISTS([ $3 ] ,
132+ [ pkg_cv_[ ] $1 =`$PKG_CONFIG --[ ] $2 "$3 " 2>/dev/null`
133+ test "x$?" != "x0" && pkg_failed=yes ] ,
134+ [ pkg_failed=yes] )
135+ else
136+ pkg_failed=untried
137+ fi[ ] dnl
138+ ] ) dnl _PKG_CONFIG
139+
140+ dnl _PKG_SHORT_ERRORS_SUPPORTED
141+ dnl ---------------------------
142+ dnl Internal check to see if pkg-config supports short errors.
143+ AC_DEFUN ( [ _PKG_SHORT_ERRORS_SUPPORTED] ,
144+ [ AC_REQUIRE ( [ PKG_PROG_PKG_CONFIG] )
145+ if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
146+ _pkg_short_errors_supported=yes
147+ else
148+ _pkg_short_errors_supported=no
149+ fi[ ] dnl
150+ ] ) dnl _PKG_SHORT_ERRORS_SUPPORTED
151+
152+
153+ dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
154+ dnl [ACTION-IF-NOT-FOUND])
155+ dnl --------------------------------------------------------------
156+ dnl Since: 0.4.0
157+ dnl
158+ dnl Note that if there is a possibility the first call to
159+ dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
160+ dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
161+ AC_DEFUN ( [ PKG_CHECK_MODULES] ,
162+ [ AC_REQUIRE ( [ PKG_PROG_PKG_CONFIG] ) dnl
163+ AC_ARG_VAR ( [ $1 ] [ _CFLAGS] , [ C compiler flags for $1 , overriding pkg-config] ) dnl
164+ AC_ARG_VAR ( [ $1 ] [ _LIBS] , [ linker flags for $1 , overriding pkg-config] ) dnl
165+
166+ pkg_failed=no
167+ AC_MSG_CHECKING ( [ for $1 ] )
168+
169+ _PKG_CONFIG([ $1 ] [ _CFLAGS] , [ cflags] , [ $2 ] )
170+ _PKG_CONFIG([ $1 ] [ _LIBS] , [ libs] , [ $2 ] )
171+
172+ m4_define ( [ _PKG_TEXT] , [ Alternatively, you may set the environment variables $1 [ ] _CFLAGS
173+ and $1 [ ] _LIBS to avoid the need to call pkg-config.
174+ See the pkg-config man page for more details.] )
175+
176+ if test $pkg_failed = yes; then
177+ AC_MSG_RESULT ( [ no] )
178+ _PKG_SHORT_ERRORS_SUPPORTED
179+ if test $_pkg_short_errors_supported = yes; then
180+ $1 [ ] _PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2 " 2>&1`
181+ else
182+ $1 [ ] _PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2 " 2>&1`
183+ fi
184+ # Put the nasty error message in config.log where it belongs
185+ echo "$$1 [ ] _PKG_ERRORS" >&AS_MESSAGE_LOG_FD
186+
187+ m4_default ( [ $4 ] , [ AC_MSG_ERROR (
188+ [ Package requirements ($2 ) were not met:
189+
190+ $$1 _PKG_ERRORS
191+
192+ Consider adjusting the PKG_CONFIG_PATH environment variable if you
193+ installed software in a non-standard prefix.
194+
195+ _PKG_TEXT] ) [ ] dnl
196+ ] )
197+ elif test $pkg_failed = untried; then
198+ AC_MSG_RESULT ( [ no] )
199+ m4_default ( [ $4 ] , [ AC_MSG_FAILURE (
200+ [ The pkg-config script could not be found or is too old. Make sure it
201+ is in your PATH or set the PKG_CONFIG environment variable to the full
202+ path to pkg-config.
203+
204+ _PKG_TEXT
205+
206+ To get pkg-config, see <http://pkg-config.freedesktop.org/>.] ) [ ] dnl
207+ ] )
208+ else
209+ $1 [ ] _CFLAGS=$pkg_cv_[ ] $1 [ ] _CFLAGS
210+ $1 [ ] _LIBS=$pkg_cv_[ ] $1 [ ] _LIBS
211+ AC_MSG_RESULT ( [ yes] )
212+ $3
213+ fi[ ] dnl
214+ ] ) dnl PKG_CHECK_MODULES
215+
216+
217+ dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
218+ dnl [ACTION-IF-NOT-FOUND])
219+ dnl ---------------------------------------------------------------------
220+ dnl Since: 0.29
221+ dnl
222+ dnl Checks for existence of MODULES and gathers its build flags with
223+ dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
224+ dnl and VARIABLE-PREFIX_LIBS from --libs.
225+ dnl
226+ dnl Note that if there is a possibility the first call to
227+ dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
228+ dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
229+ dnl configure.ac.
230+ AC_DEFUN ( [ PKG_CHECK_MODULES_STATIC] ,
231+ [ AC_REQUIRE ( [ PKG_PROG_PKG_CONFIG] ) dnl
232+ _save_PKG_CONFIG=$PKG_CONFIG
233+ PKG_CONFIG="$PKG_CONFIG --static"
234+ PKG_CHECK_MODULES($@ )
235+ PKG_CONFIG=$_save_PKG_CONFIG[ ] dnl
236+ ] ) dnl PKG_CHECK_MODULES_STATIC
237+
238+
239+ dnl PKG_INSTALLDIR([DIRECTORY])
240+ dnl -------------------------
241+ dnl Since: 0.27
242+ dnl
243+ dnl Substitutes the variable pkgconfigdir as the location where a module
244+ dnl should install pkg-config .pc files. By default the directory is
245+ dnl $libdir/pkgconfig, but the default can be changed by passing
246+ dnl DIRECTORY. The user can override through the --with-pkgconfigdir
247+ dnl parameter.
248+ AC_DEFUN ( [ PKG_INSTALLDIR] ,
249+ [ m4_pushdef ( [ pkg_default] , [ m4_default ( [ $1 ] , [ '${libdir}/pkgconfig'] ) ] )
250+ m4_pushdef ( [ pkg_description] ,
251+ [ pkg-config installation directory @<:@ ] pkg_default [ @:>@ ] )
252+ AC_ARG_WITH ( [ pkgconfigdir] ,
253+ [ AS_HELP_STRING ( [ --with-pkgconfigdir] , pkg_description ) ] ,,
254+ [ with_pkgconfigdir=] pkg_default )
255+ AC_SUBST ( [ pkgconfigdir] , [ $with_pkgconfigdir] )
256+ m4_popdef ( [ pkg_default] )
257+ m4_popdef ( [ pkg_description] )
258+ ] ) dnl PKG_INSTALLDIR
259+
260+
261+ dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
262+ dnl --------------------------------
263+ dnl Since: 0.27
264+ dnl
265+ dnl Substitutes the variable noarch_pkgconfigdir as the location where a
266+ dnl module should install arch-independent pkg-config .pc files. By
267+ dnl default the directory is $datadir/pkgconfig, but the default can be
268+ dnl changed by passing DIRECTORY. The user can override through the
269+ dnl --with-noarch-pkgconfigdir parameter.
270+ AC_DEFUN ( [ PKG_NOARCH_INSTALLDIR] ,
271+ [ m4_pushdef ( [ pkg_default] , [ m4_default ( [ $1 ] , [ '${datadir}/pkgconfig'] ) ] )
272+ m4_pushdef ( [ pkg_description] ,
273+ [ pkg-config arch-independent installation directory @<:@ ] pkg_default [ @:>@ ] )
274+ AC_ARG_WITH ( [ noarch-pkgconfigdir] ,
275+ [ AS_HELP_STRING ( [ --with-noarch-pkgconfigdir] , pkg_description ) ] ,,
276+ [ with_noarch_pkgconfigdir=] pkg_default )
277+ AC_SUBST ( [ noarch_pkgconfigdir] , [ $with_noarch_pkgconfigdir] )
278+ m4_popdef ( [ pkg_default] )
279+ m4_popdef ( [ pkg_description] )
280+ ] ) dnl PKG_NOARCH_INSTALLDIR
281+
282+
283+ dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
284+ dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
285+ dnl -------------------------------------------
286+ dnl Since: 0.28
287+ dnl
288+ dnl Retrieves the value of the pkg-config variable for the given module.
289+ AC_DEFUN ( [ PKG_CHECK_VAR] ,
290+ [ AC_REQUIRE ( [ PKG_PROG_PKG_CONFIG] ) dnl
291+ AC_ARG_VAR ( [ $1 ] , [ value of $3 for $2 , overriding pkg-config] ) dnl
292+
293+ _PKG_CONFIG([ $1 ] , [ variable="] [ $3 ] [ "] , [ $2 ] )
294+ AS_VAR_COPY ( [ $1 ] , [ pkg_cv_] [ $1 ] )
295+
296+ AS_VAR_IF ( [ $1 ] , [ ""] , [ $5 ] , [ $4 ] ) dnl
297+ ] ) dnl PKG_CHECK_VAR
298+
23299# Copyright (C) 2002-2014 Free Software Foundation, Inc.
24300#
25301# This file is free software; the Free Software Foundation
0 commit comments