mips: Simplify architecture specific Makefile.inc

The mips Makefile was inherited from x86 and so included lots
of stuff that is necessary on x86 but nowhere else.
That cruft is now gone.

It also adopts the non-x86 approach of handling linker scripts,
hardcoding an include to ldoptions there, instead of manual
concatenation (of just one file plus options).

This is inspired by the commit listed below, but rewritten to match
upstream, and split in smaller pieces to keep intent clear.

Change-Id: Ibf0c7096f9425572d8f83837aa6a253fd91e212c
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Based-On-Change-Id: I50af7dacf616e0f8ff4c43f4acc679089ad7022b
Based-On-Signed-off-by: Julius Werner <jwerner@chromium.org>
Based-On-Reviewed-on: https://chromium-review.googlesource.com/219170
Reviewed-on: http://review.coreboot.org/9163
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@google.com>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
This commit is contained in:
Patrick Georgi 2015-03-30 13:40:29 +02:00 committed by Patrick Georgi
parent 10f86b0bd8
commit 6b65f0d8bd
4 changed files with 11 additions and 55 deletions

View File

@ -35,6 +35,8 @@ endif
ifeq ($(CONFIG_ARCH_BOOTBLOCK_MIPS),y) ifeq ($(CONFIG_ARCH_BOOTBLOCK_MIPS),y)
bootblock-y += boot.c bootblock-y += boot.c
bootblock-y += bootblock.S
bootblock-y += bootblock_simple.c
bootblock-$(CONFIG_BOOTBLOCK_CONSOLE) += early_console.c bootblock-$(CONFIG_BOOTBLOCK_CONSOLE) += early_console.c
bootblock-y += stages.c bootblock-y += stages.c
bootblock-y += timer.c bootblock-y += timer.c
@ -44,44 +46,15 @@ bootblock-y += ../../lib/memset.c
bootblock_lds = $(src)/arch/mips/bootblock.ld bootblock_lds = $(src)/arch/mips/bootblock.ld
bootblock_inc += $(src)/arch/mips/bootblock.S
bootblock_inc += $(objgenerated)/bootblock.inc
# Much of the assembly code is generated by the compiler, and may contain # Much of the assembly code is generated by the compiler, and may contain
# terms which the preprocessor will happily go on to replace. For example # terms which the preprocessor will happily go on to replace. For example
# "mips" would be replaced with "1". Clear all the built in definitions to # "mips" would be replaced with "1". Clear all the built in definitions to
# prevent that. # prevent that.
bootblock-S-ccopts += -undef bootblock-S-ccopts += -undef
$(objgenerated)/bootblock.ld: $$(bootblock_lds) $(obj)/ldoptions $(objcbfs)/bootblock.debug: $(src)/arch/mips/bootblock.ld $$(bootblock-objs) $(obj)/config.h $(obj)/ldoptions
@printf " GEN $(subst $(obj)/,,$(@))\n"
printf '$(foreach ldscript,ldoptions $(bootblock_lds),INCLUDE "$(ldscript)"\n)' > $@
$(objgenerated)/bootblock_inc.S: $$(bootblock_inc)
@printf " GEN $(subst $(obj)/,,$(@))\n"
printf '$(foreach crt0,$(bootblock_inc),#include "$(crt0)"\n)' > $@
$(objgenerated)/bootblock.o: $(objgenerated)/bootblock.s
@printf " CC $(subst $(obj)/,,$(@))\n"
$(CC_bootblock) $(bootblock-S-ccopts) -Wa,-acdlns -c -o $@ $< > $(basename $@).disasm
$(objgenerated)/bootblock.s: $(objgenerated)/bootblock_inc.S $(obj)/config.h $(obj)/build.h
@printf " CC $(subst $(obj)/,,$(@))\n"
$(CC_bootblock) $(bootblock-S-ccopts) -MMD -x assembler-with-cpp -E \
-I$(src)/include -I$(src)/arch/mips/include -I$(obj) \
-include $(obj)/build.h -include $(obj)/config.h -I. \
-I$(src) $< -o $@
$(objgenerated)/bootblock.inc: $(src)/arch/mips/$(subst ",,$(CONFIG_BOOTBLOCK_SOURCE)) $(bootblock_custom) $(obj)/config.h
@printf " CC $(subst $(obj)/,,$(@))\n"
$(CC_bootblock) $(bootblock-c-ccopts) $(CFLAGS_bootblock) -MM \
-MT$(objgenerated)/bootblock.inc \
$< > $(objgenerated)/bootblock.inc.d
$(CC_bootblock) $(bootblock-c-ccopts) -c -S $(CFLAGS_bootblock) -I. $< -o $@
$(objcbfs)/bootblock.debug: $(objgenerated)/bootblock.o $(objgenerated)/bootblock.ld $$(bootblock-objs) $(obj)/config.h
@printf " LINK $(subst $(obj)/,,$(@))\n" @printf " LINK $(subst $(obj)/,,$(@))\n"
$(CC_bootblock) $(CFLAGS_bootblock) -nostdlib -Wl,--gc-sections -nostartfiles -include $(obj)/config.h -static -o $@ -L$(obj) -T $(objgenerated)/bootblock.ld -Wl,--start-group $(objgenerated)/bootblock.o $(bootblock-objs) -Wl,--end-group $(LD_bootblock) --gc-sections -static -o $@ -L$(obj) -T $(src)/arch/mips/bootblock.ld --start-group $(bootblock-objs) --end-group
endif # CONFIG_ARCH_BOOTBLOCK_MIPS endif # CONFIG_ARCH_BOOTBLOCK_MIPS
@ -99,17 +72,9 @@ romstage-y += ../../lib/memcpy.c
romstage-y += ../../lib/memmove.c romstage-y += ../../lib/memmove.c
romstage-y += ../../lib/memset.c romstage-y += ../../lib/memset.c
romstage-lds = $(src)/arch/mips/romstage.ld $(objcbfs)/romstage.debug: $$(romstage-objs) $(src)/arch/mips/romstage.ld $(obj)/ldoptions
$(objcbfs)/romstage.debug: $$(romstage-objs) $(objgenerated)/romstage.ld
@printf " LINK $(subst $(obj)/,,$(@))\n" @printf " LINK $(subst $(obj)/,,$(@))\n"
$(CC_romstage) -nostdlib -Wl,--gc-sections -nostartfiles -static -o $@ -L$(obj) -T $(objgenerated)/romstage.ld -Wl,--start-group $(romstage-objs) -Wl,--end-group $(LD_romstage) --gc-sections -static -o $@ -L$(obj) -T $(src)/arch/mips/romstage.ld --start-group $(romstage-objs) --end-group
$(objgenerated)/romstage.ld: $$(romstage-lds) $(obj)/ldoptions
@printf " GEN $(subst $(obj)/,,$(@))\n"
rm -f $@
printf '$(foreach ldscript,ldoptions $(romstage-lds),INCLUDE "$(ldscript:$(obj)/%=%)"\n)' >> $@.tmp
mv $@.tmp $@
endif # CONFIG_ARCH_ROMSTAGE_MIPS endif # CONFIG_ARCH_ROMSTAGE_MIPS
@ -129,20 +94,8 @@ ramstage-y += ../../lib/memmove.c
ramstage-y += ../../lib/memset.c ramstage-y += ../../lib/memset.c
ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c) ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c)
ramstage-lds = $(src)/arch/mips/ramstage.ld $(objcbfs)/ramstage.debug: $$(ramstage-objs) $(src)/arch/mips/ramstage.ld $(obj)/ldoptions
$(objgenerated)/ramstage.ld: $$(ramstage-lds) $(obj)/ldoptions
@printf " GEN $(subst $(obj)/,,$(@))\n"
rm -f $@
printf '$(foreach ldscript,ldoptions $(ramstage-lds),INCLUDE "$(ldscript:$(obj)/%=%)"\n)' >> $@.tmp
mv $@.tmp $@
$(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.o $(objgenerated)/ramstage.ld
@printf " CC $(subst $(obj)/,,$(@))\n" @printf " CC $(subst $(obj)/,,$(@))\n"
$(CC_ramstage) -nostdlib -Wl,--gc-sections -nostartfiles -static -o $@ -L$(obj) -T $(objgenerated)/ramstage.ld $< $(LD_ramstage) --gc-sections -static -o $@ -L$(obj) -T $(src)/arch/mips/ramstage.ld --start-group $(ramstage-objs) --end-group
$(objgenerated)/ramstage.o: $$(ramstage-objs)
@printf " CC $(subst $(obj)/,,$(@))\n"
$(CC_ramstage) $(CFLAGS_ramstage) -nostdlib -r -o $@ -Wl,--start-group $(ramstage-objs) -Wl,--end-group
endif # CONFIG_ARCH_RAMSTAGE_MIPS endif # CONFIG_ARCH_RAMSTAGE_MIPS

View File

@ -20,6 +20,7 @@
*/ */
OUTPUT_ARCH(mips) OUTPUT_ARCH(mips)
INCLUDE ldoptions
ENTRY(_start) ENTRY(_start)

View File

@ -24,6 +24,7 @@
*/ */
OUTPUT_ARCH(mips) OUTPUT_ARCH(mips)
INCLUDE ldoptions
ENTRY(stage_entry) ENTRY(stage_entry)

View File

@ -20,6 +20,7 @@
*/ */
OUTPUT_ARCH(mips) OUTPUT_ARCH(mips)
INCLUDE ldoptions
ENTRY(stage_entry) ENTRY(stage_entry)