summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2015-09-26 13:08:04 -0700
committerDan Nicholson <dbn.lists@gmail.com>2015-09-26 15:02:36 -0700
commitb51cd2165d8e1478fa6b67115e5a79c432b39c9b (patch)
tree66d69967003b678e89925982f765b93484f95978
parent7e8b0bf6d9e003fe9877fac55ce31205d2433e18 (diff)
m4: Add PKG_PREREQ version checking macro
While PKG_PROG_PKG_CONFIG checks the version of pkg-config available at build time, it doesn't check the version of the pkg-config macros being used. PKG_PREREQ (like AC_PREREQ or LT_PREREQ) can be used to check the version of the macros in use when configure is being generated by the developer. https://bugs.freedesktop.org/show_bug.cgi?id=89267
-rw-r--r--pkg-config-guide.html4
-rw-r--r--pkg-config.16
-rw-r--r--pkg.m4.in21
3 files changed, 31 insertions, 0 deletions
diff --git a/pkg-config-guide.html b/pkg-config-guide.html
index 16c43e2..c666fe5 100644
--- a/pkg-config-guide.html
+++ b/pkg-config-guide.html
@@ -342,6 +342,10 @@ $ pkg-config --modversion hello
projects.</p>
<ul>
+ <li><b>PKG_PREREQ(MIN-VERSION)</b>: Ensures that the version of the
+ <tt>pkg-config</tt> <tt>autoconf</tt> macros in use is at least
+ <tt>MIN-VERSION</tt>.</li>
+
<li><b>PKG_PROG_PKG_CONFIG([MIN-VERSION])</b>: Locates the
<tt>pkg-config</tt> tool on the system and checks the version for
compatibility.</li>
diff --git a/pkg-config.1 b/pkg-config.1
index 74bb70a..11e6292 100644
--- a/pkg-config.1
+++ b/pkg-config.1
@@ -423,6 +423,12 @@ VARIABLE-PREFIX will simply use the _LIBS and _CFLAGS variables set from
the previous usage without calling \fIpkg-config\fP again.
.\"
.TP
+.I "PKG_PREREQ(MIN-VERSION)"
+Checks that the version of the pkg-config autoconf macros in use is at
+least MIN-VERSION. This can be used to ensure a particular pkg-config
+macro will be available.
+.\"
+.TP
.I "PKG_PROG_PKG_CONFIG([MIN-VERSION])"
Defines the PKG_CONFIG variable to the best pkg-config available,
diff --git a/pkg.m4.in b/pkg.m4.in
index 62995f0..0a1536a 100644
--- a/pkg.m4.in
+++ b/pkg.m4.in
@@ -22,6 +22,27 @@
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
+# PKG_PREREQ(MIN-VERSION)
+# -------------------------------------
+# Since: 0.29
+#
+# Verify that the version of the pkg-config macros are at least
+# MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
+# installed version of pkg-config, this checks the developer's version
+# of pkg.m4 when generating configure.
+#
+# To ensure that this macro is defined, also add:
+# m4_ifndef([PKG_PREREQ],
+# [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
+#
+# See the "Since" comment for each macro you use to see what version of
+# the macros you require.
+m4_defun([PKG_PREREQ],
+[m4_define([PKG_MACROS_VERSION], [@VERSION@])
+m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
+ [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
+])# PKG_PREREQ
+
# PKG_PROG_PKG_CONFIG([MIN-VERSION])
# ----------------------------------
AC_DEFUN([PKG_PROG_PKG_CONFIG],