From: Jeremie Courreges-Anglas Subject: Re: pkg-config relocatable .pc support To: George Koehler Cc: tech@openbsd.org Date: Mon, 13 Jan 2025 14:17:54 +0100 On Sun, Jan 12, 2025 at 08:53:35PM -0500, George Koehler wrote: > "use File::Basename;" imports "dirname" and a few other functions by > default. You can call "dirname($name)" without the "File::Basename::" > prefix, like src/usr.bin/pkg-config/pkg-config does with "basename". Thanks for the suggestion, but that doesn't work. At the call site we're within "package OpenBSD::PkgConfig;", so a bare dirname() would be looked up as OpenBSD::PkgConfig::dirname. Hence the fully qualified call used in the diff. > --gkoehler > > On Sun, 12 Jan 2025 14:57:34 +0100 > Jeremie Courreges-Anglas wrote: > > > 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