Hi,

attached patch improves dependency tracking for coreboot.rom. make isn't
particularily reliable with deleting files after their rules failed (and
I'm not sure if this is a requirement, though some versions of make do it).
So if you build coreboot and forgot to put the payload at the right
spot, the next make run (after adding the payload) will not redo
coreboot.rom as coreboot.rom already exists.

This patch attacks this issue from two sides:
1. adds the files to add as dependencies of coreboot.rom, so make stops
before starting to work on coreboot.rom

2. creates coreboot.rom as coreboot.rom.tmp and renames the result after
all write operations succeeded. This helps should any of the operations
fail (eg. because the ELF parser in cbfstool is confused by the input file)


Signed-off-by: Patrick Georgi <[email protected]>
Index: src/arch/i386/Makefile.inc
===================================================================
--- src/arch/i386/Makefile.inc  (revision 5224)
+++ src/arch/i386/Makefile.inc  (working copy)
@@ -11,33 +11,47 @@
 
 #######################################################################
 # Build the final rom image
-$(obj)/coreboot.rom: $(obj)/coreboot.pre $(obj)/coreboot_ram $(CBFSTOOL)
-       cp $(obj)/coreboot.pre $@
+COREBOOT_ROM_DEPENDENCIES:=
+ifneq ($(CONFIG_PAYLOAD_NONE),y)
+COREBOOT_ROM_DEPENDENCIES+=$(CONFIG_FALLBACK_PAYLOAD_FILE)
+endif
+ifeq ($(CONFIG_VGA_BIOS),y)
+COREBOOT_ROM_DEPENDENCIES+=$(CONFIG_FALLBACK_VGA_BIOS_FILE)
+endif
+ifeq ($(CONFIG_INTEL_MBI),y)
+COREBOOT_ROM_DEPENDENCIES+=$(CONFIG_FALLBACK_MBI_FILE)
+endif
+ifeq ($(CONFIG_BOOTSPLASH),y)
+COREBOOT_ROM_DEPENDENCIES+=$(CONFIG_FALLBACK_BOOTSPLASH_FILE)
+endif
+$(obj)/coreboot.rom: $(obj)/coreboot.pre $(obj)/coreboot_ram $(CBFSTOOL) 
$(COREBOOT_ROM_DEPENDENCIES)
+       cp $(obj)/coreboot.pre [email protected]
        if [ -f fallback/coreboot_apc ]; \
        then \
-               $(CBFSTOOL) $@ add-stage fallback/coreboot_apc 
$(CONFIG_CBFS_PREFIX)/coreboot_apc $(CBFS_COMPRESS_FLAG); \
+               $(CBFSTOOL) [email protected] add-stage fallback/coreboot_apc 
$(CONFIG_CBFS_PREFIX)/coreboot_apc $(CBFS_COMPRESS_FLAG); \
        fi
-       $(CBFSTOOL) $@ add-stage $(obj)/coreboot_ram 
$(CONFIG_CBFS_PREFIX)/coreboot_ram $(CBFS_COMPRESS_FLAG)
+       $(CBFSTOOL) [email protected] add-stage $(obj)/coreboot_ram 
$(CONFIG_CBFS_PREFIX)/coreboot_ram $(CBFS_COMPRESS_FLAG)
 ifeq ($(CONFIG_PAYLOAD_NONE),y)
        @printf "    PAYLOAD    none (as specified by user)\n"
 else
        @printf "    PAYLOAD    $(CONFIG_FALLBACK_PAYLOAD_FILE) 
$(CBFS_PAYLOAD_COMPRESS_FLAG)\n"
-       $(CBFSTOOL) $(obj)/coreboot.rom add-payload 
$(CONFIG_FALLBACK_PAYLOAD_FILE) $(CONFIG_CBFS_PREFIX)/payload 
$(CBFS_PAYLOAD_COMPRESS_FLAG)
+       $(CBFSTOOL) [email protected] add-payload $(CONFIG_FALLBACK_PAYLOAD_FILE) 
$(CONFIG_CBFS_PREFIX)/payload $(CBFS_PAYLOAD_COMPRESS_FLAG)
 endif
 ifeq ($(CONFIG_VGA_BIOS),y)
        @printf "    VGABIOS    $(CONFIG_FALLBACK_VGA_BIOS_FILE) 
$(CONFIG_FALLBACK_VGA_BIOS_ID)\n"
-       $(CBFSTOOL) $(obj)/coreboot.rom add $(CONFIG_FALLBACK_VGA_BIOS_FILE) 
"pci$(CONFIG_FALLBACK_VGA_BIOS_ID).rom" optionrom
+       $(CBFSTOOL) [email protected] add $(CONFIG_FALLBACK_VGA_BIOS_FILE) 
"pci$(CONFIG_FALLBACK_VGA_BIOS_ID).rom" optionrom
 endif
 ifeq ($(CONFIG_INTEL_MBI),y)
        @printf "    MBI        $(CONFIG_FALLBACK_MBI_FILE)\n"
-       $(CBFSTOOL) $(obj)/coreboot.rom add $(CONFIG_FALLBACK_MBI_FILE) mbi.bin 
mbi
+       $(CBFSTOOL) [email protected] add $(CONFIG_FALLBACK_MBI_FILE) mbi.bin mbi
 endif
 ifeq ($(CONFIG_BOOTSPLASH),y)
        @printf "    BOOTSPLASH $(CONFIG_FALLBACK_BOOTSPLASH_FILE)\n"
-       $(CBFSTOOL) $(obj)/coreboot.rom add $(CONFIG_FALLBACK_BOOTSPLASH_FILE) 
bootsplash.jpg bootsplash
+       $(CBFSTOOL) [email protected] add $(CONFIG_FALLBACK_BOOTSPLASH_FILE) 
bootsplash.jpg bootsplash
 endif
+       mv [email protected] $@
        @printf "    CBFSPRINT  $(subst $(obj)/,,$(@))\n\n"
-       $(CBFSTOOL) $(obj)/coreboot.rom print
+       $(CBFSTOOL) $@ print
 
 #######################################################################
 # i386 specific tools
-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to