Skip to content

Commit 2d89185

Browse files
committed
Update pkg.m4 to pkg-config-0.29
1 parent b72850d commit 2d89185

File tree

1 file changed

+174
-97
lines changed

1 file changed

+174
-97
lines changed

scripts/autotools/m4/pkg.m4

Lines changed: 174 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,61 @@
1-
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
2-
# serial 1 (pkg-config-0.24)
3-
#
4-
# Copyright © 2004 Scott James Remnant <[email protected]>.
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-
# PKG_PROG_PKG_CONFIG([MIN-VERSION])
26-
# ----------------------------------
1+
# https://gitlab.freedesktop.org/pkg-config/pkg-config/-/blob/pkg-config-0.29.2/pkg.m4.in
2+
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
3+
# serial 12 (pkg-config-0.29)
4+
5+
dnl Copyright © 2004 Scott James Remnant <[email protected]>.
6+
dnl Copyright © 2012-2015 Dan Nicholson <[email protected]>
7+
dnl
8+
dnl This program is free software; you can redistribute it and/or modify
9+
dnl it under the terms of the GNU General Public License as published by
10+
dnl the Free Software Foundation; either version 2 of the License, or
11+
dnl (at your option) any later version.
12+
dnl
13+
dnl This program is distributed in the hope that it will be useful, but
14+
dnl WITHOUT ANY WARRANTY; without even the implied warranty of
15+
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
dnl General Public License for more details.
17+
dnl
18+
dnl You should have received a copy of the GNU General Public License
19+
dnl along with this program; if not, write to the Free Software
20+
dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21+
dnl 02111-1307, USA.
22+
dnl
23+
dnl As a special exception to the GNU General Public License, if you
24+
dnl distribute this file as part of a program that contains a
25+
dnl configuration script generated by Autoconf, you may include it under
26+
dnl the same distribution terms that you use for the rest of that
27+
dnl program.
28+
29+
dnl PKG_PREREQ(MIN-VERSION)
30+
dnl -----------------------
31+
dnl Since: 0.29
32+
dnl
33+
dnl Verify that the version of the pkg-config macros are at least
34+
dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
35+
dnl installed version of pkg-config, this checks the developer's version
36+
dnl of pkg.m4 when generating configure.
37+
dnl
38+
dnl To ensure that this macro is defined, also add:
39+
dnl m4_ifndef([PKG_PREREQ],
40+
dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
41+
dnl
42+
dnl See the "Since" comment for each macro you use to see what version
43+
dnl of the macros you require.
44+
m4_defun([PKG_PREREQ],
45+
[m4_define([PKG_MACROS_VERSION], [0.29])
46+
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
47+
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
48+
])dnl PKG_PREREQ
49+
50+
dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
51+
dnl ----------------------------------
52+
dnl Since: 0.16
53+
dnl
54+
dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
55+
dnl first found in the path. Checks that the version of pkg-config found
56+
dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
57+
dnl used since that's the first version where most current features of
58+
dnl pkg-config existed.
2759
AC_DEFUN([PKG_PROG_PKG_CONFIG],
2860
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
2961
m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
@@ -33,30 +65,31 @@ AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
3365
AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
3466
3567
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
36-
AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
68+
AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
3769
fi
3870
if test -n "$PKG_CONFIG"; then
39-
_pkg_min_version=m4_default([$1], [0.9.0])
40-
AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
41-
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
42-
AC_MSG_RESULT([yes])
43-
else
44-
AC_MSG_RESULT([no])
45-
PKG_CONFIG=""
46-
fi
71+
_pkg_min_version=m4_default([$1], [0.9.0])
72+
AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
73+
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
74+
AC_MSG_RESULT([yes])
75+
else
76+
AC_MSG_RESULT([no])
77+
PKG_CONFIG=""
78+
fi
4779
fi[]dnl
48-
])# PKG_PROG_PKG_CONFIG
49-
50-
# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
51-
#
52-
# Check to see whether a particular set of modules exists. Similar
53-
# to PKG_CHECK_MODULES(), but does not set variables or print errors.
54-
#
55-
# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
56-
# only at the first occurence in configure.ac, so if the first place
57-
# it's called might be skipped (such as if it is within an "if", you
58-
# have to call PKG_CHECK_EXISTS manually
59-
# --------------------------------------------------------------
80+
])dnl PKG_PROG_PKG_CONFIG
81+
82+
dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
83+
dnl -------------------------------------------------------------------
84+
dnl Since: 0.18
85+
dnl
86+
dnl Check to see whether a particular set of modules exists. Similar to
87+
dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
88+
dnl
89+
dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
90+
dnl only at the first occurence in configure.ac, so if the first place
91+
dnl it's called might be skipped (such as if it is within an "if", you
92+
dnl have to call PKG_CHECK_EXISTS manually
6093
AC_DEFUN([PKG_CHECK_EXISTS],
6194
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
6295
if test -n "$PKG_CONFIG" && \
@@ -66,50 +99,51 @@ m4_ifvaln([$3], [else
6699
$3])dnl
67100
fi])
68101

69-
# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
70-
# ---------------------------------------------
102+
dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
103+
dnl ---------------------------------------------
104+
dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
105+
dnl pkg_failed based on the result.
71106
m4_define([_PKG_CONFIG],
72107
[if test -n "$$1"; then
73108
pkg_cv_[]$1="$$1"
74109
elif test -n "$PKG_CONFIG"; then
75110
PKG_CHECK_EXISTS([$3],
76111
[pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
77-
test "x$?" != "x0" && pkg_failed=yes ],
78-
[pkg_failed=yes])
112+
test "x$?" != "x0" && pkg_failed=yes ],
113+
[pkg_failed=yes])
79114
else
80115
pkg_failed=untried
81116
fi[]dnl
82-
])# _PKG_CONFIG
117+
])dnl _PKG_CONFIG
83118

84-
# _PKG_SHORT_ERRORS_SUPPORTED
85-
# -----------------------------
119+
dnl _PKG_SHORT_ERRORS_SUPPORTED
120+
dnl ---------------------------
121+
dnl Internal check to see if pkg-config supports short errors.
86122
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
87123
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
88124
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
89125
_pkg_short_errors_supported=yes
90126
else
91127
_pkg_short_errors_supported=no
92128
fi[]dnl
93-
])# _PKG_SHORT_ERRORS_SUPPORTED
94-
95-
96-
# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
97-
# [ACTION-IF-NOT-FOUND])
98-
#
99-
#
100-
# Note that if there is a possibility the first call to
101-
# PKG_CHECK_MODULES might not happen, you should be sure to include an
102-
# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
103-
#
104-
#
105-
# --------------------------------------------------------------
129+
])dnl _PKG_SHORT_ERRORS_SUPPORTED
130+
131+
132+
dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
133+
dnl [ACTION-IF-NOT-FOUND])
134+
dnl --------------------------------------------------------------
135+
dnl Since: 0.4.0
136+
dnl
137+
dnl Note that if there is a possibility the first call to
138+
dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
139+
dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
106140
AC_DEFUN([PKG_CHECK_MODULES],
107141
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
108142
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
109143
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
110144
111145
pkg_failed=no
112-
AC_MSG_CHECKING([for $1])
146+
AC_MSG_CHECKING([for $2])
113147
114148
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
115149
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
@@ -119,17 +153,17 @@ and $1[]_LIBS to avoid the need to call pkg-config.
119153
See the pkg-config man page for more details.])
120154
121155
if test $pkg_failed = yes; then
122-
AC_MSG_RESULT([no])
156+
AC_MSG_RESULT([no])
123157
_PKG_SHORT_ERRORS_SUPPORTED
124158
if test $_pkg_short_errors_supported = yes; then
125-
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
126-
else
127-
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
159+
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
160+
else
161+
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
128162
fi
129-
# Put the nasty error message in config.log where it belongs
130-
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
163+
# Put the nasty error message in config.log where it belongs
164+
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
131165
132-
m4_default([$4], [AC_MSG_ERROR(
166+
m4_default([$4], [AC_MSG_ERROR(
133167
[Package requirements ($2) were not met:
134168
135169
$$1_PKG_ERRORS
@@ -140,8 +174,8 @@ installed software in a non-standard prefix.
140174
_PKG_TEXT])[]dnl
141175
])
142176
elif test $pkg_failed = untried; then
143-
AC_MSG_RESULT([no])
144-
m4_default([$4], [AC_MSG_FAILURE(
177+
AC_MSG_RESULT([no])
178+
m4_default([$4], [AC_MSG_FAILURE(
145179
[The pkg-config script could not be found or is too old. Make sure it
146180
is in your PATH or set the PKG_CONFIG environment variable to the full
147181
path to pkg-config.
@@ -151,21 +185,45 @@ _PKG_TEXT
151185
To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
152186
])
153187
else
154-
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
155-
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
188+
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
189+
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
156190
AC_MSG_RESULT([yes])
157-
$3
191+
$3
158192
fi[]dnl
159-
])# PKG_CHECK_MODULES
193+
])dnl PKG_CHECK_MODULES
160194

161195

162-
# PKG_INSTALLDIR(DIRECTORY)
163-
# -------------------------
164-
# Substitutes the variable pkgconfigdir as the location where a module
165-
# should install pkg-config .pc files. By default the directory is
166-
# $libdir/pkgconfig, but the default can be changed by passing
167-
# DIRECTORY. The user can override through the --with-pkgconfigdir
168-
# parameter.
196+
dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
197+
dnl [ACTION-IF-NOT-FOUND])
198+
dnl ---------------------------------------------------------------------
199+
dnl Since: 0.29
200+
dnl
201+
dnl Checks for existence of MODULES and gathers its build flags with
202+
dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
203+
dnl and VARIABLE-PREFIX_LIBS from --libs.
204+
dnl
205+
dnl Note that if there is a possibility the first call to
206+
dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
207+
dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
208+
dnl configure.ac.
209+
AC_DEFUN([PKG_CHECK_MODULES_STATIC],
210+
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
211+
_save_PKG_CONFIG=$PKG_CONFIG
212+
PKG_CONFIG="$PKG_CONFIG --static"
213+
PKG_CHECK_MODULES($@)
214+
PKG_CONFIG=$_save_PKG_CONFIG[]dnl
215+
])dnl PKG_CHECK_MODULES_STATIC
216+
217+
218+
dnl PKG_INSTALLDIR([DIRECTORY])
219+
dnl -------------------------
220+
dnl Since: 0.27
221+
dnl
222+
dnl Substitutes the variable pkgconfigdir as the location where a module
223+
dnl should install pkg-config .pc files. By default the directory is
224+
dnl $libdir/pkgconfig, but the default can be changed by passing
225+
dnl DIRECTORY. The user can override through the --with-pkgconfigdir
226+
dnl parameter.
169227
AC_DEFUN([PKG_INSTALLDIR],
170228
[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
171229
m4_pushdef([pkg_description],
@@ -176,16 +234,18 @@ AC_ARG_WITH([pkgconfigdir],
176234
AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
177235
m4_popdef([pkg_default])
178236
m4_popdef([pkg_description])
179-
]) dnl PKG_INSTALLDIR
237+
])dnl PKG_INSTALLDIR
180238

181239

182-
# PKG_NOARCH_INSTALLDIR(DIRECTORY)
183-
# -------------------------
184-
# Substitutes the variable noarch_pkgconfigdir as the location where a
185-
# module should install arch-independent pkg-config .pc files. By
186-
# default the directory is $datadir/pkgconfig, but the default can be
187-
# changed by passing DIRECTORY. The user can override through the
188-
# --with-noarch-pkgconfigdir parameter.
240+
dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
241+
dnl --------------------------------
242+
dnl Since: 0.27
243+
dnl
244+
dnl Substitutes the variable noarch_pkgconfigdir as the location where a
245+
dnl module should install arch-independent pkg-config .pc files. By
246+
dnl default the directory is $datadir/pkgconfig, but the default can be
247+
dnl changed by passing DIRECTORY. The user can override through the
248+
dnl --with-noarch-pkgconfigdir parameter.
189249
AC_DEFUN([PKG_NOARCH_INSTALLDIR],
190250
[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
191251
m4_pushdef([pkg_description],
@@ -196,4 +256,21 @@ AC_ARG_WITH([noarch-pkgconfigdir],
196256
AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
197257
m4_popdef([pkg_default])
198258
m4_popdef([pkg_description])
199-
]) dnl PKG_NOARCH_INSTALLDIR
259+
])dnl PKG_NOARCH_INSTALLDIR
260+
261+
262+
dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
263+
dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
264+
dnl -------------------------------------------
265+
dnl Since: 0.28
266+
dnl
267+
dnl Retrieves the value of the pkg-config variable for the given module.
268+
AC_DEFUN([PKG_CHECK_VAR],
269+
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
270+
AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
271+
272+
_PKG_CONFIG([$1], [variable="][$3]["], [$2])
273+
AS_VAR_COPY([$1], [pkg_cv_][$1])
274+
275+
AS_VAR_IF([$1], [""], [$5], [$4])dnl
276+
])dnl PKG_CHECK_VAR

0 commit comments

Comments
 (0)