&:endm .. endef
NAME is processed for &
+&${..$..} => ${eval ${call ..$$..}}
+ (matches { } pairs to find the end)
+ content is $-doubled (unless it contains $- to turn that off)
+
+ Together &:macro and &${...} provide a more reasonable macro
+ facility than raw make. They solve the problem that make
+ expansions cannot directly generate multiple rules, variable,
+ etc.; instead, `$(eval )' must be used, but that re-expands
+ the argument, meaning that all the literal text must be
+ $-doubled. This applies to the macro text and to the
+ arguments. Also `$(eval $(call ...))' is an unfortunate syntax.
+ Hence &:macro and &${...}.
+
While dollar-doubling:
- - - - - - - - - - -
}
for (;;) {
die if $ddbl && defined $buffering_output;
- unless (s{^(.*?)$esc}{}) { od $_; last; }
+ unless (@nest && $nest[0][0] eq 'Eval'
+ ? s{^(.*?)($esc|[{}])}{}
+ : s{^(.*?)($esc)}{}) { od $_; last; }
od $1;
+ if ($2 eq '{') {
+ $ddbl++;
+ next;
+ } elsif ($2 eq '}') {
+ next if --$ddbl;
+ $pop_nest->('Eval');
+ od '}}';
+ next;
+ }
if (s{^\\$esc}{}) { od "$$esclitr" }
elsif (s{^\\\$}{}) { oud '$' }
elsif (s{^\\\s+$}{}) { }
elsif (s{^\$\+}{}) { $ddbl=1; }
elsif (s{^\$\(}{}) { die unless $ddbl; oud "\$("; }
elsif (s{^\$(\d+)}{}) { die unless $ddbl; oud "\$($1)"; }
- elsif (s{^([~^]?)(?=[ \t])}{}) {
+ elsif (s{^\$\{}{}) {
+ die if $ddbl;
+ od '${eval ${call ';
+ $push_nest->('Eval',1);
+ } elsif (s{^([~^]?)(?=[ \t])}{}) {
my $prefix = $pfxmap{$1} // die;
my $after='';
if (m{([ \t])$esc}) { ($_,$after) = ($`, $1.$'); }
$e->{OutTop} = $1 eq 'nothing' ? '' : $1;
} elsif (# parse: expect other wordish things to be comments
m{^(?!or\b)\w{2,} }) {
+ } elsif (# adhoc: slightly special case for $(eval $(call
+ m{^\$\{.*}) {
+ $e->{Out} .= ' '.$&;
} elsif (m/^$/) {
} else {
confess "unk rhs $_ ?";
my ($e) = @_;
# adhoc: skip &:macro in already-doubling part
return 0 if $e->{In} =~ m{^\&\:macro};
+ # adhoc: skip &${ ie eval in already-doubling part
+ return 0 if $e->{In} =~ m{^\&\$\{};
return 0 if $e->{CQ};
return $e->{DD} || !grep {
# If there are two entries with the same In,