On Wed, 2011-09-21 at 02:18 -0700, MD.Mahbubur Rahman wrote: > The following code works if the hi lighted change is made: > > define program-variables > $1_sources = $(filter %.c,$2) > $1_headers = $(filter %.h,$2) > $1_objects = $(subst .c,.o,$(filter %.c,$2)) > $($1_objects): $($1_headers) > endef > ls: $(ls_objects) > $(eval $(call program-variables,ls,ls.c ls.h glob.c glob.h)) > > Can some one help me why this is needed to make the code works???
In GNU make, normal functions must expand to no more than one logical line. The entire expansion, even if it contains newlines, is treated as a single logical line. That's why the original call did not work, because the "program-variables" variable contained newlines but when it was expanded by call it was treated as a single line. Hence the syntax error. The only exception to the above rule is the eval function: that function reads the value as if it were a real makefile, so it can parse multiple lines. Thus passing a complex, multiline expression (from the expansion of call, or not, it doesn't matter) to eval does what you want. _______________________________________________ Help-make mailing list [email protected] https://lists.gnu.org/mailman/listinfo/help-make
