Handle compiler options for source classes more generically

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@6372 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
Patrick Georgi 2011-02-17 20:48:45 +00:00 committed by Stefan Reinauer
parent 58262656c6
commit b8cdd9b450
1 changed files with 11 additions and 8 deletions

View File

@ -202,6 +202,11 @@ $(call add-class,ramstage)
$(call add-class,romstage) $(call add-class,romstage)
$(call add-class,driver) $(call add-class,driver)
$(call add-class,smm) $(call add-class,smm)
ramstage-S-ccopts:=-DASSEMBLY
romstage-c-ccopts:=-D__PRE_RAM__
romstage-S-ccopts:=-DASSEMBLY -D__PRE_RAM__
driver-S-ccopts:=-DASSEMBLY
$(call add-special-class,cbfs-files) $(call add-special-class,cbfs-files)
cbfs-files-handler= \ cbfs-files-handler= \
@ -266,21 +271,19 @@ define create_cc_template
# $1 obj class (ramstage, romstage, driver, smm) # $1 obj class (ramstage, romstage, driver, smm)
# $2 source suffix (c, S) # $2 source suffix (c, S)
# $3 additional compiler flags # $3 additional compiler flags
ifn$(EMPTY)def $(1)-objs_$(2)_template
de$(EMPTY)fine $(1)-objs_$(2)_template de$(EMPTY)fine $(1)-objs_$(2)_template
$(obj)/$$(1).$(1).o: src/$$(1).$(2) $(obj)/config.h $(obj)/$$(1).$(1).o: src/$$(1).$(2) $(obj)/config.h
@printf " CC $$$$(subst $$$$(obj)/,,$$$$(@))\n" @printf " CC $$$$(subst $$$$(obj)/,,$$$$(@))\n"
$(CC) $(3) -MMD $$$$(CFLAGS) -c -o $$$$@ $$$$< $(CC) $(3) -MMD $$$$(CFLAGS) -c -o $$$$@ $$$$<
en$(EMPTY)def en$(EMPTY)def
end$(EMPTY)if
endef endef
$(eval $(call create_cc_template,ramstage,c)) filetypes-of-class=$(subst .,,$(sort $(suffix $($(1)-srcs))))
$(eval $(call create_cc_template,ramstage,S,-DASSEMBLY)) $(foreach class,$(classes), \
$(eval $(call create_cc_template,romstage,c,-D__PRE_RAM__)) $(foreach type,$(call filetypes-of-class,$(class)), \
$(eval $(call create_cc_template,romstage,S,-DASSEMBLY -D__PRE_RAM__)) $(eval $(call create_cc_template,$(class),$(type),$($(class)-$(type)-ccopts)))))
$(eval $(call create_cc_template,driver,c))
$(eval $(call create_cc_template,driver,S,-DASSEMBLY))
$(eval $(call create_cc_template,smm,c))
$(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 class,$(classes),$(call foreach-src,$(class)))) $(eval $(foreach class,$(classes),$(call foreach-src,$(class))))