diff options
author | Jasper Lievisse Adriaanse <jasper@cvs.openbsd.org> | 2014-03-31 18:16:25 +0000 |
---|---|---|
committer | Jasper Lievisse Adriaanse <jasper@cvs.openbsd.org> | 2014-03-31 18:16:25 +0000 |
commit | 4bc9de77ae84e9bc2f969a9fc881dee1bda72e80 (patch) | |
tree | 3f95e3b2d1e4bb3e9ccbf0c0a8ee1a8459266bd4 /usr.bin/pkg-config | |
parent | b5b00b75ecd4287a0f09230ce7e81c1e019f23ec (diff) |
if it looks like a variable, expands like a variable and resolves like a
variable, then it need not be a variable.
add a way out the variable expansion loop when the returned value from the
values hash looks like a variable.
this resolves an issue where using --define-variable=libdir=${libdir} would
create and infinite loop of looking up the value of libdir. such as triggered
by the x11/gnome/empathy configure script.
tested in a bulk build as well as builds of base and xenocara
ok aja@
Diffstat (limited to 'usr.bin/pkg-config')
-rw-r--r-- | usr.bin/pkg-config/OpenBSD/PkgConfig.pm | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/usr.bin/pkg-config/OpenBSD/PkgConfig.pm b/usr.bin/pkg-config/OpenBSD/PkgConfig.pm index 4855e1f9841..28227e730d8 100644 --- a/usr.bin/pkg-config/OpenBSD/PkgConfig.pm +++ b/usr.bin/pkg-config/OpenBSD/PkgConfig.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PkgConfig.pm,v 1.4 2014/03/18 20:54:34 espie Exp $ +# $OpenBSD: PkgConfig.pm,v 1.5 2014/03/31 18:16:24 jasper Exp $ # # Copyright (c) 2006 Marc Espie <espie@openbsd.org> # @@ -194,7 +194,11 @@ sub expanded sub { my $var = shift; if (defined $extra->{$var}) { - return $extra->{$var}; + if ($extra->{$var} =~ m/\$\{.*\}/ ) { + return undef; + } else { + return $extra->{$var}; + } } elsif (defined $self->{variables}->{$var}) { return $self->{variables}->{$var}; } else { @@ -202,7 +206,14 @@ sub expanded } }; - while ($v =~ s/\$\{(.*?)\}/&$get_value($1)/ge) { + # Expand all variables, unless the returned value is defined as an + # as an unexpandable variable (such as with --defined-variable). + while ($v =~ m/\$\{(.*?)\}/) { + unless (defined &$get_value($1)) { + $v =~ s/\$\{(.*?)\}/$extra->{$1}/g; + last; + } + $v =~ s/\$\{(.*?)\}/&$get_value($1)/ge; } return $v; } |