SUBDIRS := ./public ./protocol ./system define make_subdir for d in $(SUBDIRS); do [ -f "$$d/makefile" ] && (cd "$$d" && make -f makefile $1) || true; done endef .PHONY: all clean rebuild all:; @$(call make_subdir,all) clean:; @$(call make_subdir,clean) rebuild: clean all