Search code examples
foreachmakefileevalcall

Makefile $(eval $(call)) function


simple code in makefile

define fun
@echo this is function
endef

78 all:
79   $(foreach objdir, $(OBJECTDIRS), $(eval $(call fun)))

the err message is : Makefile:79:* missing separator. Stop.**

Note: i have checked the $(OBJECTDIRS) is not empty and $(oobjdir) too

if i change the code to flowing lines:

define fun
@echo this is function
endef

all:
 $(call fun())

then it's running good


Solution

  • The make eval function evaluates the text you give is as a makefile (expects makefile sytnax).

    The text @echo this is a function is NOT a makefile.

    In other words, if you create a Makefile and you put into it the text:

    @echo this is a function
    

    (by itself, with nothing else) and you run make on that makefile, you'll get this same missing separator error.