make has a weird rule for line joining in recipes, where the \ is
retained. This is very annoying espcially when writing little scripts
in other languages in recipes. The GNU make documentation suggests
using a `define' block, in which the \ are still necessary, but
vanish. But that separates out the recipe from the rule, and also
demands that the recipe text be given a name.
(Note that .ONESHELL offers an alternative but sadly is not available
on a per-rule basis. This is even less sensible with non-recursive
make, where you might want different directories to have different
settings.)
So, provide &\ which does the other thing, swallowing the newline and
discarding the &\, even in rules.
Add a test case too.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
&\& => & general escaping mechanism
&\$ => $
+&\NEWLINE eats the newline and vanishes
&$VARIABLE => $(sub_dir_VARIABLE) or $(TOP_VARIABLE)
VARIABLE is ASCII starting with a letter and matching \w+
o $1;
if (s{^\\$esc}{}) { o "$$esclitr" }
elsif (s{^\\\$}{}) { o '$' }
+ elsif (s{^\\\s+$}{}) { }
elsif (s{^$esc}{}) { o "$$esclitr$$esclitr" }
elsif (m{^(?=$caps_re)}) { o $var_prefix }
elsif (s{^\$([A-Za-z]\w+)}{}) { o "\$(${var_prefix}$1)" }
sub_dir_TARGETS_sometarget1
sub_dir_TARGETS_sometarget2
+line joining
+
# doctests:
sub/dir/all:: $(sub_dir_TARGETS)
&TARGETS_sometarget1
&TARGETS_sometarget2
+line &\
+joining
+
# doctests:
&:include &doctest.sd.mk