# ex:ts=8 sw=4:
-# $OpenBSD: PkgConfig.pm,v 1.10 2023/06/08 08:55:27 espie Exp $
+# $OpenBSD: PkgConfig.pm,v 1.11 2023/09/22 07:29:14 espie Exp $
#
# Copyright (c) 2006 Marc Espie <espie@openbsd.org>
#
use v5.36;
+
# interface to the *.pc file format of pkg-config.
package OpenBSD::PkgConfig;
sub parse_value($self, $name, $value)
{
+ my $class = "OpenBSD::PkgConfig::NoExpand";
+ if ($value =~ m/\$\{.*\}/) {
+ $class = "OpenBSD::PkgConfig::ToExpand";
+ }
if (defined $parse->{$name}) {
- return $parse->{$name}($value);
+ return bless $parse->{$name}($value), $class;
} else {
- return [split /(?<!\\)\s+/o, $value];
+ return bless [split /(?<!\\)\s+/o, $value], $class;
}
}
if (defined $value) {
$v = $self->parse_value($name, $value);
} else {
- $v = [];
+ $v = bless [], "OpenBSD::PkgConfig::NoExpand";
}
$self->{properties}{$name} = $v;
}
}
}
if (defined $cfg->{properties}{Libs}) {
- $cfg->{properties}{Libs} =
- $cfg->compress_list($cfg->{properties}{Libs});
+ $cfg->{properties}{Libs} = bless
+ $cfg->compress_list($cfg->{properties}{Libs}),
+ ref($cfg->{properties}{Libs});
}
return $cfg;
}
if (!defined $l) {
return undef;
}
+ if ($l->noexpand) {
+ return [@$l];
+ }
my $r = [];
for my $v (@$l) {
my $w = $self->expanded($v, $extra);
}
}
+package OpenBSD::PkgConfig::NoExpand;
+our @ISA = qw(OpenBSD::PkgConfig);
+sub noexpand($)
+{
+ 1
+}
+
+package OpenBSD::PkgConfig::ToExpand;
+our @ISA = qw(OpenBSD::PkgConfig);
+sub noexpand($)
+{
+ 0
+}
1;