SUBDIRS=my_lib product LIBDIR=lib .PHONY: clean debug subdirs $(SUBDIRS) subdirs: $(SUBDIRS) $(SUBDIRS): $(MAKE) -C $@ all: $(LIBDIR) subdirs for dir in $(SUBDIRS); do \ $(MAKE) -C $$dir \ done debug: for dir in $(SUBDIRS); do \ $(MAKE) -C $$dir $(MAKECMDGOALS); \ done product: my_lib $(LIBDIR): mkdir $@ clean: for dir in $(SUBDIRS); do \ $(MAKE) -C $$dir $(MAKECMDGOALS); \ done