Skip to content

Commit

Permalink
Backport new-style 'PKG_PROG_PKG_CONFIG' macro from pkg-config 0.29.2.
Browse files Browse the repository at this point in the history
Since the definition of this macro has been changed to error-out if a new
introduced second parameter is ommited and the pkg-conf executable is not
found on the system, the configure script from the release tarballs will
fail in certain minimal bootstrap environments, that do not include a
pkg-config executable (or the provided version is too old).

The backport of a compatibility is needed to be able to regenerate the
build-system on older systems, which do not offer a variant of the macro
definition with an optional second parameter.

Fixes #198.
  • Loading branch information
besser82 committed Dec 31, 2024
1 parent 785c7bd commit 22067e5
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
# serial 11 (pkg-config-0.29.1)
# pkg.m4 - Macros to locate and use pkg-config. -*- Autoconf -*-
# serial 12 (pkg-config-0.29.2)

# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
# Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
Expand All @@ -25,6 +25,47 @@
# the same distribution terms that you use for the rest of that
# program.

# PKG_PROG_PKG_CONFIG_COMPAT([MIN-VERSION], [ACTION-IF-NOT-FOUND])
# ---------------------------------------------------------
# Backported from pkg-config 0.29.2.
#
# Search for the pkg-config tool and set the PKG_CONFIG variable to
# first found in the path. Checks that the version of pkg-config found
# is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
# used since that's the first version where most current features of
# pkg-config existed.
#
# If pkg-config is not found or older than specified, it will result
# in an empty PKG_CONFIG variable. To avoid widespread issues with
# scripts not checking it, ACTION-IF-NOT-FOUND defaults to aborting.
# You can specify [PKG_CONFIG=false] as an action instead, which would
# result in pkg-config tests failing, but no bogus error messages.
AC_DEFUN([PKG_PROG_PKG_CONFIG_COMPAT],
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
fi
if test -n "$PKG_CONFIG"; then
_pkg_min_version=m4_default([$1], [0.9.0])
AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
PKG_CONFIG=""
fi
fi
if test -z "$PKG_CONFIG"; then
m4_default([$2], [AC_MSG_ERROR([pkg-config not found])])
fi[]
])

# PKG_INSTALLDIR_COMPAT([DIRECTORY])
# -------------------------
# Backported from pkg-config 0.27.
Expand Down
12 changes: 4 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,15 @@ AH_BOTTOM(
# PKG_INSTALLDIR may not be defined, but we have a
# compatibility replacement.
m4_pattern_allow([PKG_INSTALLDIR])
PKG_PROG_PKG_CONFIG_COMPAT([0.27], [PKG_CONFIG=false])
AS_IF([test x"$PKG_CONFIG" != xfalse],
[PKG_INSTALLDIR],
[PKG_INSTALLDIR_COMPAT])

# Checks for programs.
AC_CANONICAL_HOST
AC_PROG_CC

# Dependencies
PKG_PROG_PKG_CONFIG
if $PKG_CONFIG --atleast-pkgconfig-version 0.27; then
PKG_INSTALLDIR
else
PKG_INSTALLDIR_COMPAT
fi

# C99 language and library features are used unconditionally.
# Don't even try to build with an older compiler.
case "$ac_prog_cc_stdc" in
Expand Down

0 comments on commit 22067e5

Please sign in to comment.