Author: oxygene Date: Sat Mar 6 22:18:43 2010 New Revision: 5195 URL: http://tracker.coreboot.org/trac/coreboot/changeset/5195
Log: More readable recursive descent macro in Makefile
Signed-off-by: Patrick Georgi patrick.georgi@coresystems.de Acked-by: Stefan Reinauer stepan@coresystems.de
Modified: trunk/Makefile
Modified: trunk/Makefile ============================================================================== --- trunk/Makefile Sat Mar 6 19:16:25 2010 (r5194) +++ trunk/Makefile Sat Mar 6 22:18:43 2010 (r5195) @@ -119,8 +119,32 @@ crt0s:= ldscripts:= types:=obj initobj driver smmobj -includemakefiles=$(foreach type,$(2), $(eval $(type)-y:=)) $(eval subdirs-y:=) $(eval -include $(1)) $(if $(strip $(3)),$(foreach type,$(2),$(eval $(type)s+=$$(patsubst util/%,$(obj)/util/%,$$(patsubst src/%,$(obj)/%,$$(addprefix $(dir $(1)),$$($(type)-y))))))) $(eval subdirs+=$$(subst $(PWD)/,,$$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y))))) -evaluate_subdirs=$(eval cursubdirs:=$(subdirs)) $(eval subdirs:=) $(foreach dir,$(cursubdirs),$(eval $(call includemakefiles,$(dir)/Makefile.inc,$(types),$(1)))) $(if $(subdirs),$(eval $(call evaluate_subdirs, $(1)))) + +# Clean -y variables, include Makefile.inc +# If $(3) is non-empty, add paths to files in X-y, and add them to Xs +# Add subdirs-y to subdirs +includemakefiles= \ + $(foreach type,$(2), $(eval $(type)-y:=)) \ + $(eval subdirs-y:=) \ + $(eval -include $(1)) \ + $(if $(strip $(3)), \ + $(foreach type,$(2), \ + $(eval $(type)s+= \ + $$(patsubst util/%, \ + $(obj)/util/%, \ + $$(patsubst src/%, \ + $(obj)/%, \ + $$(addprefix $(dir $(1)),$$($(type)-y))))))) \ + $(eval subdirs+=$$(subst $(PWD)/,,$$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y))))) + +# For each path in $(subdirs) call includemakefiles, passing $(1) as $(3) +# Repeat until subdirs is empty +evaluate_subdirs= \ + $(eval cursubdirs:=$(subdirs)) \ + $(eval subdirs:=) \ + $(foreach dir,$(cursubdirs), \ + $(eval $(call includemakefiles,$(dir)/Makefile.inc,$(types),$(1)))) \ + $(if $(subdirs),$(eval $(call evaluate_subdirs, $(1))))
# collect all object files eligible for building subdirs:=$(PLATFORM-y) $(BUILD-y)