Make Makefile.inc parser loop more generic
Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com> Acked-by: Stefan Reinauer <stefan.reinauer@coreboot.org> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@6371 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
parent
b159f7ab37
commit
58262656c6
75
Makefile
75
Makefile
|
@ -183,38 +183,51 @@ $(obj)/%.ramstage.o: $(obj)/%.c $(obj)/config.h
|
||||||
@printf " CC $(subst $(obj)/,,$(@))\n"
|
@printf " CC $(subst $(obj)/,,$(@))\n"
|
||||||
$(CC) -MMD $(CFLAGS) -c -o $@ $<
|
$(CC) -MMD $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
ramstage-srcs:=$(obj)/mainboard/$(MAINBOARDDIR)/static.c
|
# Add a new class of source/object files to the build system
|
||||||
romstage-srcs:=
|
add-class= \
|
||||||
driver-srcs:=
|
$(eval $(1)-srcs:=) \
|
||||||
smm-srcs:=
|
$(eval $(1)-objs:=) \
|
||||||
cbfs-files:=
|
$(eval classes+=$(1))
|
||||||
|
|
||||||
ramstage-objs:=
|
# Special classes are managed types with special behaviour
|
||||||
romstage-objs:=
|
# On parse time, for each entry in variable $(1)-y
|
||||||
driver-objs:=
|
# a handler $(1)-handler is executed with the arguments:
|
||||||
smm-objs:=
|
# * $(1): directory the parser is in
|
||||||
types:=ramstage romstage driver smm
|
# * $(2): current entry
|
||||||
|
add-special-class= \
|
||||||
|
$(eval $(1):=) \
|
||||||
|
$(eval special-classes+=$(1))
|
||||||
|
|
||||||
|
$(call add-class,ramstage)
|
||||||
|
$(call add-class,romstage)
|
||||||
|
$(call add-class,driver)
|
||||||
|
$(call add-class,smm)
|
||||||
|
|
||||||
|
$(call add-special-class,cbfs-files)
|
||||||
|
cbfs-files-handler= \
|
||||||
|
$(if $(wildcard $(1)$($(2)-file)), \
|
||||||
|
$(eval tmp-cbfs-file:= $(wildcard $(1)$($(2)-file))), \
|
||||||
|
$(eval tmp-cbfs-file:= $($(2)-file))) \
|
||||||
|
$(eval cbfs-files += $(tmp-cbfs-file)|$(2)|$($(2)-type)|$($(2)-position)) \
|
||||||
|
$(eval $(2)-name:=) \
|
||||||
|
$(eval $(2)-type:=) \
|
||||||
|
$(eval $(2)-position:=)
|
||||||
|
|
||||||
|
ramstage-srcs+=$(obj)/mainboard/$(MAINBOARDDIR)/static.c
|
||||||
|
|
||||||
# Clean -y variables, include Makefile.inc
|
# Clean -y variables, include Makefile.inc
|
||||||
# Add paths to files in X-y to X-srcs
|
# Add paths to files in X-y to X-srcs
|
||||||
# Add subdirs-y to subdirs
|
# Add subdirs-y to subdirs
|
||||||
includemakefiles= \
|
includemakefiles= \
|
||||||
$(foreach type,$(2), $(eval $(type)-y:=)) \
|
$(foreach class,classes subdirs $(classes) $(special-classes), $(eval $(class)-y:=)) \
|
||||||
$(eval subdirs-y:=) \
|
|
||||||
$(eval cbfs-files-y:=) \
|
|
||||||
$(eval -include $(1)) \
|
$(eval -include $(1)) \
|
||||||
$(foreach type,$(2), \
|
$(foreach class,$(classes-y), $(call add-class,$(class))) \
|
||||||
$(eval $(type)-srcs+= \
|
$(foreach class,$(classes), \
|
||||||
|
$(eval $(class)-srcs+= \
|
||||||
$$(subst $(top)/,, \
|
$$(subst $(top)/,, \
|
||||||
$$(abspath $$(addprefix $(dir $(1)),$$($(type)-y)))))) \
|
$$(abspath $$(addprefix $(dir $(1)),$$($(class)-y)))))) \
|
||||||
$(foreach file,$(cbfs-files-y), \
|
$(foreach special,$(special-classes), \
|
||||||
$(if $(wildcard $(dir $(1))$($(file)-file)), \
|
$(foreach item,$($(special)-y), $(call $(special)-handler,$(dir $(1)),$(item)))) \
|
||||||
$(eval tmp-cbfs-file:= $(wildcard $(dir $(1))$($(file)-file))), \
|
|
||||||
$(eval tmp-cbfs-file:= $($(file)-file))) \
|
|
||||||
$(eval cbfs-files += $(tmp-cbfs-file)|$(file)|$($(file)-type)|$($(file)-position)) \
|
|
||||||
$(eval $(file)-name:=) \
|
|
||||||
$(eval $(file)-type:=) \
|
|
||||||
$(eval $(file)-position:=)) \
|
|
||||||
$(eval subdirs+=$$(subst $(CURDIR)/,,$$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y)))))
|
$(eval subdirs+=$$(subst $(CURDIR)/,,$$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y)))))
|
||||||
|
|
||||||
# For each path in $(subdirs) call includemakefiles
|
# For each path in $(subdirs) call includemakefiles
|
||||||
|
@ -223,7 +236,7 @@ evaluate_subdirs= \
|
||||||
$(eval cursubdirs:=$(subdirs)) \
|
$(eval cursubdirs:=$(subdirs)) \
|
||||||
$(eval subdirs:=) \
|
$(eval subdirs:=) \
|
||||||
$(foreach dir,$(cursubdirs), \
|
$(foreach dir,$(cursubdirs), \
|
||||||
$(eval $(call includemakefiles,$(dir)/Makefile.inc,$(types)))) \
|
$(eval $(call includemakefiles,$(dir)/Makefile.inc))) \
|
||||||
$(if $(subdirs),$(eval $(call evaluate_subdirs)))
|
$(if $(subdirs),$(eval $(call evaluate_subdirs)))
|
||||||
|
|
||||||
# collect all object files eligible for building
|
# collect all object files eligible for building
|
||||||
|
@ -231,14 +244,10 @@ subdirs:=$(PLATFORM-y) $(BUILD-y)
|
||||||
$(eval $(call evaluate_subdirs))
|
$(eval $(call evaluate_subdirs))
|
||||||
|
|
||||||
src-to-obj=$(addsuffix .$(1).o, $(basename $(patsubst src/%, $(obj)/%, $($(1)-srcs))))
|
src-to-obj=$(addsuffix .$(1).o, $(basename $(patsubst src/%, $(obj)/%, $($(1)-srcs))))
|
||||||
|
$(foreach class,$(classes),$(eval $(class)-objs:=$(call src-to-obj,$(class))))
|
||||||
|
|
||||||
ramstage-objs:=$(call src-to-obj,ramstage)
|
allsrcs:=$(foreach var, $(addsuffix -srcs,$(classes)), $($(var)))
|
||||||
romstage-objs:=$(call src-to-obj,romstage)
|
allobjs:=$(foreach var, $(addsuffix -objs,$(classes)), $($(var)))
|
||||||
driver-objs:=$(call src-to-obj,driver)
|
|
||||||
smm-objs:=$(call src-to-obj,smm)
|
|
||||||
|
|
||||||
allsrcs:=$(foreach var, $(addsuffix -srcs,$(types)), $($(var)))
|
|
||||||
allobjs:=$(foreach var, $(addsuffix -objs,$(types)), $($(var)))
|
|
||||||
alldirs:=$(sort $(abspath $(dir $(allobjs))))
|
alldirs:=$(sort $(abspath $(dir $(allobjs))))
|
||||||
|
|
||||||
define ramstage-objs_asl_template
|
define ramstage-objs_asl_template
|
||||||
|
@ -274,7 +283,7 @@ $(eval $(call create_cc_template,smm,c))
|
||||||
$(eval $(call create_cc_template,smm,S))
|
$(eval $(call create_cc_template,smm,S))
|
||||||
|
|
||||||
foreach-src=$(foreach file,$($(1)-srcs),$(eval $(call $(1)-objs_$(subst .,,$(suffix $(file)))_template,$(subst src/,,$(basename $(file))))))
|
foreach-src=$(foreach file,$($(1)-srcs),$(eval $(call $(1)-objs_$(subst .,,$(suffix $(file)))_template,$(subst src/,,$(basename $(file))))))
|
||||||
$(eval $(foreach type,$(types),$(call foreach-src,$(type))))
|
$(eval $(foreach class,$(classes),$(call foreach-src,$(class))))
|
||||||
|
|
||||||
DEPENDENCIES = $(ramstage-objs:.o=.d) $(romstage-objs:.o=.d) $(driver-objs:.o=.d) $(smm-objs:.o=.d)
|
DEPENDENCIES = $(ramstage-objs:.o=.d) $(romstage-objs:.o=.d) $(driver-objs:.o=.d) $(smm-objs:.o=.d)
|
||||||
-include $(DEPENDENCIES)
|
-include $(DEPENDENCIES)
|
||||||
|
|
Loading…
Reference in New Issue