diff options
author | Patrick Georgi <patrick.georgi@coresystems.de> | 2010-03-06 21:18:43 +0000 |
---|---|---|
committer | Patrick Georgi <patrick.georgi@coresystems.de> | 2010-03-06 21:18:43 +0000 |
commit | 47d68d8b66841b0f42269691a79f5afdbe3f12e4 (patch) | |
tree | 56cc7e88e91b1bb9d8785974d8da5e3c4b27a931 | |
parent | 59356ca48b620b7be431455fa4c3332bc2a25a24 (diff) |
More readable recursive descent macro in Makefile
Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5195 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
-rw-r--r-- | Makefile | 28 |
1 files changed, 26 insertions, 2 deletions
@@ -119,8 +119,32 @@ smmobjs:= 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) |