On Mon, Dec 12, 2011 at 10:26 PM, Mark Galeck (CW) <[email protected]> wrote:
> Why does this bomb:
>
> .SECONDEXPANSION:
> foobar: $$(shell echo prereq;)
>        touch $@
>
>>make foobar
> makefile:2: *** unterminated call to function `shell': missing `)'.  Stop.
>
> Without the ";" it is fine.  Why?  (I need the ; for the real, larger, file, 
> here it is just the SSCCE)

Because of the levels of parsing done by make.  When make parses that
line, it see a single variable expansion for the variable '$'.  So,
the semicolon is *not* eaten by variable expansion, but rather is seen
and parsed as the semicolon that (optionally) separates prerequisites
from the first command in the rule, ala:

target : prereq ; command

It doesn't know that you mean for the semicolon to be eaten by
variable second-expansion, so it treats everything between the colon
and the semicolon as the prerequisites, which are expanded again
later, and everything after the semicolon as the first command in the
rules.

The solution is to hide the semicolon from the first round of make
expansion, ala:

.SECONDEXPANSION:
semi=;
foobar: $$(shell echo prereq$${semi})
       touch $@


Philip Guenther

_______________________________________________
Help-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to