Makefile: define build result directories
Final build results (.elf, .debug, .map) are to be placed under directory $(objcbfs), the default is: $(obj)/cbfs/$(CONFIG_CBFS_PREFIX)/ Intermediate build results (.o, .s, .S, .inc, .ld) that do not have a clear one-to-one relation to a file under src/ are to be placed under directory $(objgenerated), the default is: $(obj)/generated Also defines implicit rules for final build results: .debug -> .elf and .map .elf -> .bin Change-Id: I448c6b7c9a952e54170df42091d7db438025a795 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: http://review.coreboot.org/858 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
This commit is contained in:
parent
93b4ed91f6
commit
0db2ae3ac4
18
Makefile.inc
18
Makefile.inc
@ -27,14 +27,25 @@ ARCHDIR-$(CONFIG_ARCH_X86) := x86
|
|||||||
MAINBOARDDIR=$(call strip_quotes,$(CONFIG_MAINBOARD_DIR))
|
MAINBOARDDIR=$(call strip_quotes,$(CONFIG_MAINBOARD_DIR))
|
||||||
export MAINBOARDDIR
|
export MAINBOARDDIR
|
||||||
|
|
||||||
|
## Final build results, which CBFSTOOL uses to create the final
|
||||||
|
## rom image file, are placed under $(objcbfs).
|
||||||
|
## These typically have suffixes .debug .elf .bin and .map
|
||||||
|
export objcbfs := $(obj)/cbfs/$(CONFIG_CBFS_PREFIX)
|
||||||
|
|
||||||
|
## Based on the active configuration, Makefile conditionally collects
|
||||||
|
## the required assembly includes and saves them in a file.
|
||||||
|
## Such files that do not have a clear one-to-one relation to a source
|
||||||
|
## file under src/ are placed and built under $(objgenerated)
|
||||||
|
export objgenerated := $(obj)/generated
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# root rule to resolve if in build mode (ie. configuration exists)
|
# root rule to resolve if in build mode (ie. configuration exists)
|
||||||
real-target: $(obj)/config.h coreboot
|
real-target: $(obj)/config.h coreboot
|
||||||
coreboot: $(obj)/coreboot.rom
|
coreboot: build-dirs $(obj)/coreboot.rom
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# our phony targets
|
# our phony targets
|
||||||
PHONY+= clean-abuild coreboot lint lint-stable
|
PHONY+= clean-abuild coreboot lint lint-stable build-dirs
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# root source directories of coreboot
|
# root source directories of coreboot
|
||||||
@ -168,6 +179,9 @@ $(obj)/build.h: .xcompile
|
|||||||
$(obj)/ldoptions: $(obj)/config.h
|
$(obj)/ldoptions: $(obj)/config.h
|
||||||
awk '/^#define ([^"])* ([^"])*$$/ {gsub("\\r","",$$3); print $$2 " = " $$3 ";";}' $< > $@
|
awk '/^#define ([^"])* ([^"])*$$/ {gsub("\\r","",$$3); print $$2 " = " $$3 ";";}' $< > $@
|
||||||
|
|
||||||
|
build-dirs:
|
||||||
|
mkdir -p $(objcbfs) $(objgenerated)
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# Build the tools
|
# Build the tools
|
||||||
CBFSTOOL:=$(obj)/cbfstool
|
CBFSTOOL:=$(obj)/cbfstool
|
||||||
|
@ -138,6 +138,21 @@ $(obj)/cmos_layout.bin: $(NVRAMTOOL) $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.l
|
|||||||
@printf " OPTION $(subst $(obj)/,,$(@))\n"
|
@printf " OPTION $(subst $(obj)/,,$(@))\n"
|
||||||
$(NVRAMTOOL) -y $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout -L $@
|
$(NVRAMTOOL) -y $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout -L $@
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# Common recipes for all stages
|
||||||
|
|
||||||
|
$(objcbfs)/%.bin: $(objcbfs)/%.elf
|
||||||
|
@printf " OBJCOPY $(subst $(obj)/,,$(@))\n"
|
||||||
|
$(OBJCOPY) -O binary $< $@
|
||||||
|
|
||||||
|
$(objcbfs)/%.elf: $(objcbfs)/%.debug
|
||||||
|
@printf " OBJCOPY $(subst $(obj)/,,$(@))\n"
|
||||||
|
cp $< $@.tmp
|
||||||
|
$(NM) -n $@.tmp | sort > $(basename $@).map
|
||||||
|
$(OBJCOPY) --strip-debug $@.tmp
|
||||||
|
$(OBJCOPY) --add-gnu-debuglink=$< $@.tmp
|
||||||
|
mv $@.tmp $@
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# Build the coreboot_ram (stage 2)
|
# Build the coreboot_ram (stage 2)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user