gnu make - "define" and "endef" syntax-rules in makefile -


from docs:

note lines beginning recipe prefix character considered part of recipe, define or endef strings appearing on such line not considered make directives.


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, define or endef strings appearing on such line not considered make directives.

agree?


Comments

Popular posts from this blog

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -