gnu make - "define" and "endef" syntax-rules in makefile -
from docs:
note lines beginning recipe prefix character considered part of recipe,
defineorendefstrings appearing on such line not consideredmakedirectives.
my worry is, not case.
as evident, following makfile:
ifeq "x" "y" define xxx else foo = 1 endef else bar = 2 endif :: @echo 'foo is: "$(foo)"' @echo 'bar is: "$(bar)"' running, get:
$ make foo is: "" bar is: "2"
going makefile, evident lines 3 , 4 inside ifeq directive, i.e.
ifeq "x" "y" define xxx else foo = 1 endef else bar = 2 endif are ignored make.
put simply, make ignores these 2 lines, within define xx
else foo = 1 because inside define, , therefore, make not evaluate else directive (i.e. else part, ifeq "x" "y").
but, make parses endef line (5th line in ifeq block), directive end define directive.
hence, after ending define block endef line, make parse later lines, is:
else bar = 2 endif as part of ifeq block, , because opening directive ifeq "x" "y" evaluated false, make take else part true statement, , assign value 2 variable bar, , on.
why important?
because, clearly, make allows here endef line parsed directive, though, prefixed <tab> character.
that in clear violation of documentation, quoted above:
note lines beginning recipe prefix character considered part of recipe,
defineorendefstrings appearing on such line not consideredmakedirectives.
agree?
Comments
Post a Comment