[coreboot-gerrit] New patch to review for coreboot: Move object files to $(obj)/<class>/

Nico Huber (nico.h@gmx.de) gerrit at coreboot.org
Sat Jan 23 03:42:30 CET 2016


Nico Huber (nico.h at gmx.de) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13181

-gerrit

commit 2570bef466edf05f357407ec900a5cd6df00bc7f
Author: Nico Huber <nico.h at gmx.de>
Date:   Sat Jan 23 01:24:33 2016 +0100

    Move object files to $(obj)/<class>/
    
    Instead of tagging object files with .<class>, move them to a <class>
    directory below $(obj)/. This way we can keep a 1:1 mapping between
    source- and object-file names.
    
    The 1:1 mapping is a prerequisite for Ada, where the compiler refuses
    any other object-file name.
    
    Change-Id: Idb7a8abec4ea0a37021d9fc24cc8583c4d3bf67c
    Signed-off-by: Nico Huber <nico.h at gmx.de>
---
 Makefile                     |  2 +-
 Makefile.inc                 | 16 ++--------------
 src/arch/x86/car.ld          |  4 ++--
 src/cpu/x86/Makefile.inc     |  2 +-
 src/cpu/x86/smm/Makefile.inc |  6 ++++--
 src/include/memlayout.h      |  8 ++++----
 6 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/Makefile b/Makefile
index 3652559..561e30b 100644
--- a/Makefile
+++ b/Makefile
@@ -184,7 +184,7 @@ add-special-class= \
 # Only .c and .S get converted to .o, other files (like .ld) keep their name.
 # $1 stage name
 # $2 file path (list)
-src-to-obj=$(foreach file,$(2),$(subst .$(1),,$(basename $(patsubst src/%,$(obj)/%,$(file)))).$(1)$(patsubst %.c,%.o,$(patsubst %.S,%.o,$(suffix $(file)))))
+src-to-obj=$(patsubst src/%,$(obj)/$(1)/%,$(patsubst $(obj)/%,$(obj)/$(1)/%,$(patsubst %.c,%.o,$(patsubst %.S,%.o,$(subst .$(1),,$(2))))))
 
 # Clean -y variables, include Makefile.inc
 # Add paths to files in X-y to X-srcs
diff --git a/Makefile.inc b/Makefile.inc
index 16b1608..2b7dfa2 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -415,18 +415,6 @@ ramstage-y+=$(obj)/mainboard/$(MAINBOARDDIR)/static.c
 romstage-y+=$(obj)/mainboard/$(MAINBOARDDIR)/static.c
 verstage-y+=$(obj)/mainboard/$(MAINBOARDDIR)/static.c
 
-$(obj)/%.ramstage.o $(abspath $(obj))/%.ramstage.o: $(obj)/%.c $(obj)/config.h $(OPTION_TABLE_H)
-	@printf "    CC         $(subst $(obj)/,,$(@))\n"
-	$(CC_ramstage) -MMD $(CFLAGS_ramstage) $(CPPFLAGS_ramstage) $(ramstage-c-ccopts) -c -o $@ $<
-
-$(obj)/%.romstage.o $(abspath $(obj))/%.romstage.o: $(obj)/%.c $(obj)/config.h $(OPTION_TABLE_H)
-	@printf "    CC         $(subst $(obj)/,,$(@))\n"
-	$(CC_romstage) -MMD $(CFLAGS_romstage) $(CPPFLAGS_romstage) $(romstage-c-ccopts) -c -o $@ $<
-
-$(obj)/%.bootblock.o $(abspath $(obj))/%.bootblock.o: $(obj)/%.c $(obj)/config.h $(OPTION_TABLE_H)
-	@printf "    CC         $(subst $(obj)/,,$(@))\n"
-	$(CC_bootblock) -MMD $(CFLAGS_bootblock) $(CPPFLAGS_bootblock) $(bootblock-c-ccopts) -c -o $@ $<
-
 $(objgenerated)/libverstage.a: $$(libverstage-objs)
 	rm -f $@
 	$(AR_libverstage) rcsT $@ $^
@@ -437,8 +425,8 @@ clean-abuild:
 	rm -rf coreboot-builds
 
 clean-for-update-target:
-	rm -f $(obj)/ramstage* $(obj)/coreboot.romstage $(obj)/coreboot.pre* $(obj)/coreboot.bootblock $(obj)/coreboot.a
-	rm -rf $(obj)/bootblock* $(obj)/romstage* $(obj)/location.*
+	rm -f $(obj)/ramstage?* $(obj)/coreboot.romstage $(obj)/coreboot.pre* $(obj)/coreboot.bootblock $(obj)/coreboot.a
+	rm -rf $(obj)/bootblock?* $(obj)/romstage?* $(obj)/location.*
 	rm -f $(obj)/option_table.* $(obj)/crt0.S $(obj)/ldscript
 	rm -f $(obj)/mainboard/$(MAINBOARDDIR)/static.c $(obj)/mainboard/$(MAINBOARDDIR)/config.py $(obj)/mainboard/$(MAINBOARDDIR)/static.dot
 	rm -f $(obj)/mainboard/$(MAINBOARDDIR)/crt0.s $(obj)/mainboard/$(MAINBOARDDIR)/crt0.disasm
diff --git a/src/arch/x86/car.ld b/src/arch/x86/car.ld
index e5669dc..191dcaf 100644
--- a/src/arch/x86/car.ld
+++ b/src/arch/x86/car.ld
@@ -55,8 +55,8 @@
 
 . = 0xffffff00;
 .illegal_globals . : {
-	*(EXCLUDE_FILE ("*/libagesa.*.a:" "*/buildOpts.romstage.o" "*/agesawrapper.romstage.o" "*/vendorcode/amd/agesa/*" "*/vendorcode/amd/cimx/*") .data)
-		*(EXCLUDE_FILE ("*/libagesa.*.a:" "*/buildOpts.romstage.o" "*/agesawrapper.romstage.o" "*/vendorcode/amd/agesa/*" "*/vendorcode/amd/cimx/*") .data.*)
+	*(EXCLUDE_FILE ("*/libagesa.*.a:" "*/romstage*/buildOpts.o" "*/romstage*/agesawrapper.o" "*/vendorcode/amd/agesa/*" "*/vendorcode/amd/cimx/*") .data)
+		*(EXCLUDE_FILE ("*/libagesa.*.a:" "*/romstage*/buildOpts.o" "*/romstage*/agesawrapper.o" "*/vendorcode/amd/agesa/*" "*/vendorcode/amd/cimx/*") .data.*)
 	*(.bss)
 	*(.bss.*)
 	*(.sbss)
diff --git a/src/cpu/x86/Makefile.inc b/src/cpu/x86/Makefile.inc
index 1d5493b..3ce2417 100644
--- a/src/cpu/x86/Makefile.inc
+++ b/src/cpu/x86/Makefile.inc
@@ -30,4 +30,4 @@ $(SIPI_BIN): $(SIPI_RMOD)
 
 $(call src-to-obj,ramstage,$(SIPI_BIN).manual): $(SIPI_BIN)
 	@printf "    OBJCOPY    $(subst $(obj)/,,$(@))\n"
-	cd $(dir $@); $(OBJCOPY_rmodules_$(ARCH-ramstage-y)) -I binary $(notdir $<) $(target-objcopy) $(notdir $@)
+	cd $(dir $<); $(OBJCOPY_rmodules_$(ARCH-ramstage-y)) -I binary $(notdir $<) $(target-objcopy) $(abspath $@)
diff --git a/src/cpu/x86/smm/Makefile.inc b/src/cpu/x86/smm/Makefile.inc
index 46abd05..1459aff 100644
--- a/src/cpu/x86/smm/Makefile.inc
+++ b/src/cpu/x86/smm/Makefile.inc
@@ -13,6 +13,8 @@
 ## GNU General Public License for more details.
 ##
 
+additional-dirs += $(obj)/cpu/x86/smm
+
 ramstage-$(CONFIG_BACKUP_DEFAULT_SMM_REGION) += backup_default_smm.c
 
 ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
@@ -34,7 +36,7 @@ $(obj)/cpu/x86/smm/smm.o: $$(smm-objs) $(COMPILER_RT_smm)
 # ELF symbol names.
 $(call src-to-obj,ramstage,$(obj)/cpu/x86/smm/smm.manual): $(obj)/cpu/x86/smm/smm
 	@printf "    OBJCOPY    $(subst $(obj)/,,$(@))\n"
-	cd $(dir $@); $(OBJCOPY_smm) -I binary $(notdir $<) $(target-objcopy) $(notdir $@)
+	cd $(dir $<); $(OBJCOPY_smm) -I binary $(notdir $<) $(target-objcopy) $(abspath $@)
 
 ifeq ($(CONFIG_SMM_TSEG),y)
 
@@ -64,7 +66,7 @@ $(obj)/cpu/x86/smm/smmstub: $(obj)/cpu/x86/smm/smmstub.elf.rmod
 
 $(call src-to-obj,ramstage,$(obj)/cpu/x86/smm/smmstub.manual): $(obj)/cpu/x86/smm/smmstub
 	@printf "    OBJCOPY    $(subst $(obj)/,,$(@))\n"
-	cd $(dir $@); $(OBJCOPY_smmstub) -I binary $(notdir $<) $(target-objcopy) $(notdir $@)
+	cd $(dir $<); $(OBJCOPY_smmstub) -I binary $(notdir $<) $(target-objcopy) $(abspath $@)
 
 # C-based SMM handler.
 
diff --git a/src/include/memlayout.h b/src/include/memlayout.h
index 42d5608..e62782a 100644
--- a/src/include/memlayout.h
+++ b/src/include/memlayout.h
@@ -106,7 +106,7 @@
 		SET_COUNTER(bootblock, addr) \
 		_ = ASSERT(_eprogram - _program <= sz, \
 			STR(Bootblock exceeded its allotted size! (sz))); \
-		INCLUDE "lib/program.bootblock.ld"
+		INCLUDE "bootblock/lib/program.ld"
 #else
 	#define BOOTBLOCK(addr, sz) \
 		SET_COUNTER(bootblock, addr) \
@@ -118,7 +118,7 @@
 		SET_COUNTER(romstage, addr) \
 		_ = ASSERT(_eprogram - _program <= sz, \
 			STR(Romstage exceeded its allotted size! (sz))); \
-		INCLUDE "lib/program.romstage.ld"
+		INCLUDE "romstage/lib/program.ld"
 #else
 	#define ROMSTAGE(addr, sz) \
 		SET_COUNTER(romstage, addr) \
@@ -130,7 +130,7 @@
 		SET_COUNTER(ramstage, addr) \
 		_ = ASSERT(_eprogram - _program <= sz, \
 			STR(Ramstage exceeded its allotted size! (sz))); \
-		INCLUDE "lib/program.ramstage.ld"
+		INCLUDE "ramstage/lib/program.ld"
 #else
 	#define RAMSTAGE(addr, sz) \
 		SET_COUNTER(ramstage, addr) \
@@ -149,7 +149,7 @@
 		SET_COUNTER(verstage, addr) \
 		_ = ASSERT(_eprogram - _program <= sz, \
 			STR(Verstage exceeded its allotted size! (sz))); \
-		INCLUDE "lib/program.verstage.ld"
+		INCLUDE "verstage/lib/program.ld"
 
 	#define OVERLAP_VERSTAGE_ROMSTAGE(addr, size) VERSTAGE(addr, size)
 #else



More information about the coreboot-gerrit mailing list