On Tue, 2015-07-14 at 09:20 +0100, David Barrass wrote: > $(LIBOBJS) : $(LIBSRCLIST) > ---> $(TOOLPATH)/$(CC) -c -o $@ -I$(INCDIR) $<
You don't provide any details on the contents of LIBOBJS or LIBSRCLIST but I assume they are a set of object files and sources respectively. > This appears to work and the target obj directory gets filled with the > correctly-named module name and so the automatic variable $@ seems to > be working as I expect but the object files are all the same size and > in fact have all been created by compiling the first (and only first) > prerequisite in the list. Yes. > My understanding is that $< gets the first prerequsite from > $(LIBSRCLIST), executes the rule and then moves no to the next source > file in the list. That is not so; if you can point out where that misunderstanding came from maybe we can improve the documentation. In make each explicit rule is run exactly one time: make never "loops" through a set of prerequisites in a rule, except to try to rebuild those prerequisites. If you write a rule like this: foo.o bar.o biz.o : foo.c bar.c biz.c ... Then make interprets this exactly as if you had written: foo.o : foo.c bar.c biz.c ... bar.o : foo.c bar.c biz.c ... biz.o : foo.c bar.c biz.c ... Perhaps now you can see why make is behaving as it does. For each object file, the first prerequisite is "foo.c" so that's what is being compiled by your compiler. The simplest way to accomplish what you want is with VPATH. Set that variable to the list of source directory paths: VPATH = src1 src2 src3 src4 Now you can write a pattern rule like this: $(OBJDIR)/%.o : %.c $(TOOLPATH)/$(CC) -c -o $@ -I$(INCDIR) $< and it will work. You can read about VPATH (and vpath) here: http://www.gnu.org/software/make/manual/html_node/Directory-Search.html _______________________________________________ Help-make mailing list Help-make@gnu.org https://lists.gnu.org/mailman/listinfo/help-make