Use one make-up to complete the build (I'm not a fan of recursive creation). Do not use $(shell) as it kills performance. Place assembly products in a temporary directory.
Sketch:
subdir1-srcs := $(addprefix subdir1/,1.cc 2.cc 3.cc) subdir1-objs := ${subdir1-srcs:subdir1/%.cc=subdir1/obj/%.o) bin/prog1: ${subdir1-objs} ; gcc $^ -o $@ ${subdir1-objs}: subdir1/obj/%.o: subdir1/%.cc
Do you see a boiler plate here? Several functions along with $(eval) should allow you to write:
$(call build,bin/prog1,subdir1,1.cc 2.cc 3.cc) $(call build,bin/prog2,subdir2,a.cc b.cc c.cc d.cc)
for these purposes, they are automatically added as dependencies of the fake all and beautifully -j compatible ones (just enter make -j5 all to build).
bobbogo
source share