From e42921790267d54054cde1596711219b72a184ad Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Wed, 26 Feb 2020 14:35:17 +0100 Subject: [PATCH] build.info: Implement simply substitutions in variable values Use case: having a variable with multiple source files in its value, and wanting to refer to the corresponding object file. $SRCS=foo.c bar.c SOURCE[program]=$SRCS DEPEND[${SRCS/.c/.o}]=prog.h GENERATE[prog.h]=... Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/11185) --- Configure | 49 ++++++++++++++++++++++++++++---- doc/internal/man7/build.info.pod | 16 +++++++++++ 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/Configure b/Configure index 737a471c1d..19c16f134c 100755 --- a/Configure +++ b/Configure @@ -1807,23 +1807,62 @@ if ($builder eq "unified") { # contains a dollar sign, it had better be escaped, or it will be # taken for a variable name prefix. my %variables = (); - my $variable_re = qr/\$(?P[[:alpha:]][[:alnum:]_]*)/; + # Variable name syntax + my $variable_name_re = qr/(?P[[:alpha:]][[:alnum:]_]*)/; + # Value modifier syntaxes + my $variable_subst_re = qr/\/(?P(?:\\\/|.)*?)\/(?P.*?)/; + # Put it all together + my $variable_re = qr/\$ + (?| + # Simple case, just the name + ${variable_name_re} + | + # Expressive case, with braces and possible + # modifier expressions + \{ + ${variable_name_re} + (?: + # Pile on modifier expressions, + # separated by | + ${variable_subst_re} + ) + \} + )/x; my $expand_variables = sub { my $value = ''; my $value_rest = shift; if ($ENV{CONFIGURE_DEBUG_VARIABLE_EXPAND}) { print STDERR - "DEBUG[\$expand_variables] Parsed '$value_rest' into:\n" + "DEBUG[\$expand_variables] Parsed '$value_rest' ...\n" } while ($value_rest =~ /(?. I +Variable references can be one of: + +=over 4 + +=item B<$>I or B<${>IB<}> + +Simple reference; the variable reference is replaced with its value, +verbatim. + +=item B<${>IBIBIB<}> + +Substitution reference; the variable reference is replaced with its +value, modified by replacing all occurences of I with I. + +=back + =head2 Scope Most of the statement values are accumulated globally from all the -- 2.25.1