Hello list! I have this really large makefile and discovered the '$(eval..)' function was handy to use for this. Like:
define add_c_src VPATH += $(1) C_SRC += $(addprefix $(1)/, $(2)) $(info Number of 'C_SRC': $(words $(C_SRC))) endef $(eval $(call add_c_src, frmts/ceos, ceosopen.c)) $(eval $(call add_c_src, frmts/ceos2, ceos.c ceosrecipe.c ceossar.c)) # ... plus a lot more my-target.dll: $(C_SRC:.c=.obj) link whatever $^ ---------------- But I'm curious about how this gets expanded since the '$(info ..)' tells the length of 'C_SRC' *before* it's used: Number of 'C_SRC': 0 Number of 'C_SRC': 1 How does this gets expanded an executed? The chapter "8.1 The eval function" did not make it clear to me. But adding a: count_C_SRC: $(info Number of 'C_SRC': $(words $(C_SRC))) tells me the correct number. Another thing is that if I change to '# $(info ..', the 'Number of ..' gets printed after all (!) So a comment gets ignored here AFAICS. -- --gv