Index | Thread | Search

From:
Jeremie Courreges-Anglas <jca@wxcvbn.org>
Subject:
pkg-config relocatable .pc support
To:
tech@openbsd.org
Date:
Sun, 12 Jan 2025 14:57:34 +0100

Download raw body.

Thread
While debugging another issue, Antoine mentioned the lack of support
for relocatable .pc files in our pkg-config(1).  Adding support for
this seems easy.  Apparently this fixes some ports where ajacoutot@
had to patch out relocatable .pc support.

I don't remember whether the second hunk is actually needed but it
just doesn't make sense to write it down in a .pc.

Assuming it survives a full ports bulk build: ok?


Index: OpenBSD/PkgConfig.pm
===================================================================
RCS file: /cvs/src/usr.bin/pkg-config/OpenBSD/PkgConfig.pm,v
diff -u -p -r1.12 PkgConfig.pm
--- OpenBSD/PkgConfig.pm	11 Feb 2024 03:57:10 -0000	1.12
+++ OpenBSD/PkgConfig.pm	25 Nov 2024 18:27:22 -0000
@@ -15,6 +15,7 @@
 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 
 use v5.36;
+use File::Basename;
 
 
 # interface to the *.pc file format of pkg-config.
@@ -106,6 +107,8 @@ sub read_fh($class, $fh, $name = '')
 {
 	my $cfg = $class->new;
 
+	$cfg->add_variable('pcfiledir', File::Basename::dirname($name));
+
 	while (<$fh>) {
 		chomp;
 		# continuation lines
@@ -145,6 +148,8 @@ sub read_file($class, $filename)
 sub write_fh($self, $fh)
 {
 	foreach my $variable (@{$self->{vlist}}) {
+		# writing out pcfiledir makes no sense
+		next if $variable eq 'pcfiledir';
 		say $fh "$variable=", $self->{variables}{$variable};
 	}
 	print $fh "\n\n";

-- 
jca