1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
Description: Honour PKG_CONFIG environment variable
autoconf and several other build system respect the PKG_CONFIG environment
variable. This is useful e.g. for cross-building, where the "correct"
pkg-config/pkgconf binary should be used. Cf. from
/usr/share/doc/pkgconf-bin/README.md.gz:
.
In terms of the autoconf macro, it is possible to specify the
PKG_CONFIG environment variable, so that you can test pkgconf without
overwriting your pkg‐config binary. Some other build systems may also
respect the PKG_CONFIG environment variable.
.
To set the environment variable on the bourne shell and clones
(i.e. bash), you can run:
.
$ export PKG_CONFIG=/usr/bin/pkgconf
.
In Debian, PKG_CONFIG is already set and/or exported by dpkg
(/usr/share/dpkg/buildtools.mk) and by debhelper's EUMM and MB build
helpers.
.
This patch uses the value of PKG_CONFIG if it's set instead of the
hard-coded `pkg-config`.
Origin: vendor
Bug: https://gitlab.gnome.org/GNOME/perl-extutils-pkgconfig/-/merge_requests/1
Forwarded: https://gitlab.gnome.org/GNOME/perl-extutils-pkgconfig/-/merge_requests/1
Author: gregor herrmann <gregoa@debian.org>
Last-Update: 2025-07-08
--- a/lib/ExtUtils/PkgConfig.pm
+++ b/lib/ExtUtils/PkgConfig.pm
@@ -26,6 +26,8 @@
$VERSION = '1.16';
+my $pkg_config = $ENV{PKG_CONFIG} // 'pkg-config';
+
sub import {
my $class = shift;
return unless @_;
@@ -53,16 +55,16 @@
libs-only-other/)
{
# simple
- $ans = `pkg-config --$function \"$modulename\"`;
+ $ans = `$pkg_config --$function \"$modulename\"`;
}
elsif ('static-libs' eq $function)
{
- $ans = `pkg-config --libs --static \"$modulename\"`;
+ $ans = `$pkg_config --libs --static \"$modulename\"`;
}
elsif ('variable' eq $function)
{
# variable
- $ans = `pkg-config --${function}=$arg \"$modulename\"`;
+ $ans = `$pkg_config --${function}=$arg \"$modulename\"`;
}
elsif (grep {$_ eq $function} qw/atleast-version
exact-version
@@ -70,7 +72,7 @@
{
# boolean
$ans = not system (
- "pkg-config --${function}=$arg \"$modulename\"");
+ "$pkg_config --${function}=$arg \"$modulename\"");
}
else
{
@@ -89,7 +91,7 @@
foreach my $candidate (@pkg_candidates)
{
- my $output = qx/pkg-config --exists "$candidate" 2>&1/;
+ my $output = qx/$pkg_config --exists "$candidate" 2>&1/;
if (0 == $CHILD_ERROR) {
return 1;
}
@@ -106,7 +108,7 @@
# recognizes
foreach my $candidate (@pkg_candidates)
{
- my $output = qx/pkg-config --exists --print-errors "$candidate" 2>&1/;
+ my $output = qx/$pkg_config --exists --print-errors "$candidate" 2>&1/;
if (0 == $CHILD_ERROR) {
push @pkgs_found, $candidate;
}
@@ -139,7 +141,7 @@
my %data = ();
$data{pkg} = $pkgs_found[0];
foreach my $what (qw/modversion cflags libs/) {
- $data{$what} = `pkg-config --$what \"$data{pkg}\"`;
+ $data{$what} = `$pkg_config --$what \"$data{pkg}\"`;
$data{$what} =~ s/[\015\012]+$//;
croak "*** can't find $what for \"$data{pkg}\"\n"
. "*** is it properly installed and available in PKG_CONFIG_PATH?\n"
|