I want to create a target audience. In particular: I have one source file, and I want to create different objects that are added to the corresponding language folder. This single source file will differ in C-Flags, the compiler will receive. While I used it in a static way, it works very well.
de/info.o en/info.o es/info.o : info.c $(ECHO) (DEP) $< for $@
Now I thought it would be great if it were a bit more dynamic, if I add a new language-dependent file. So I used a wildcard:
de/%.o en/%.o es/%.o : %.c $(ECHO) (DEP) $< for $@
But now he just makes the first goal and ignores the rest. Make-Debug prints the following:
Successfully remade target file `de/info.o'. Considering target file `en/info.o'. File `en/info.o' was considered already.
Just in case: No, objects do not exist. Thus, there is no goal, but there is a dependency, so make must follow the rules.
EDIT: Found a solution to this problem.
define FOO $(1)/%.o : %.c $(ECHO) $$< for $(1) endef $(foreach lang,$(LANGUAGE_LIST), $(eval $(call FOO,$(lang))))
Inspired by: http://www.gnu.org/software/make/manual/make.html#Eval-Function
makefile gnu-make
Mario
source share