MAKEFLAGS = --no-builtin-rules # ------------------------------------------------------------------ # Stuff common to top-level "launcher" makefiles # ------------------------------------------------------------------ .PHONY: all clean COMPONENTS ?= $(error The 'COMPONENTS' variable must be defined before including TopLevel.mk) all: $(COMPONENTS) clean: $(COMPONENTS:%=clean-%) define COMPONENT_TEMPLATE $(1): @$(MAKE) --no-print-directory --file=$$($(1)_MK) Build/$(1)/%: @$(MAKE) --no-print-directory --file=$$($(1)_MK) $@ clean-$(1): @-$(MAKE) --no-print-directory --file=$$($(1)_MK) clean .PHONY: $(1) clean-$(1) endef $(foreach component,$(COMPONENTS),$(eval $(call COMPONENT_TEMPLATE,$(component))))