cbfstool: Build vboot library
Currently cbfstool cherry-picks a few files from vboot and hopes these files will work standalone without any dependencies. This is pretty brittle (for example, CL:2084062 will break it), and could be improved by building the whole vboot library and then linking against it. Therefore, this patch creates a new target $(VBOOT_HOSTLIB) and includes it as a dependency for cbfstool and ifittool. To prevent building the vboot lib twice (one for cbfstool and the other for futility) when building coreboot tools together, add the variable 'VBOOT_BUILD' in Makefile to define a shared build path among different tools so that vboot files don't need to be recompiled. Also ignore *.o.d and *.a for vboot library. BRANCH=none BUG=none TEST=make -C util/cbfstool TEST=make -C util/futility TEST=Run 'make tools' and make sure common files such as 2sha1.c are compiled only once TEST=emerge-nami coreboot-utils Change-Id: Ifc826896d895f53d69ea559a88f75672c2ec3146 Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/39390 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
parent
b3884dc59b
commit
0beddb5e23
|
@ -54,11 +54,13 @@ util/crossgcc/xgcc
|
||||||
site-local
|
site-local
|
||||||
|
|
||||||
*.\#
|
*.\#
|
||||||
|
*.a
|
||||||
*.bin
|
*.bin
|
||||||
*.debug
|
*.debug
|
||||||
!Kconfig.debug
|
!Kconfig.debug
|
||||||
*.elf
|
*.elf
|
||||||
*.o
|
*.o
|
||||||
|
*.o.d
|
||||||
*.out
|
*.out
|
||||||
*.pyc
|
*.pyc
|
||||||
*.sw[po]
|
*.sw[po]
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -42,6 +42,8 @@ objutil ?= $(obj)/util
|
||||||
objk := $(objutil)/kconfig
|
objk := $(objutil)/kconfig
|
||||||
absobj := $(abspath $(obj))
|
absobj := $(abspath $(obj))
|
||||||
|
|
||||||
|
VBOOT_HOST_BUILD ?= $(abspath $(objutil)/vboot_lib)
|
||||||
|
|
||||||
COREBOOT_EXPORTS := COREBOOT_EXPORTS
|
COREBOOT_EXPORTS := COREBOOT_EXPORTS
|
||||||
COREBOOT_EXPORTS += top src srck obj objutil objk
|
COREBOOT_EXPORTS += top src srck obj objutil objk
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ INSTALL ?= /usr/bin/env install
|
||||||
OBJCOPY ?= objcopy
|
OBJCOPY ?= objcopy
|
||||||
|
|
||||||
VBOOT_SOURCE ?= $(top)/3rdparty/vboot
|
VBOOT_SOURCE ?= $(top)/3rdparty/vboot
|
||||||
|
VBOOT_HOST_BUILD ?= $(abspath $(objutil)/vboot_lib)
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: cbfstool ifittool fmaptool rmodtool ifwitool cbfs-compression-tool
|
all: cbfstool ifittool fmaptool rmodtool ifwitool cbfs-compression-tool
|
||||||
|
@ -35,6 +36,7 @@ clean:
|
||||||
$(RM) $(objutil)/cbfstool/ifwitool $(ifwiobj)
|
$(RM) $(objutil)/cbfstool/ifwitool $(ifwiobj)
|
||||||
$(RM) $(objutil)/cbfstool/ifittool $(ifitobj)
|
$(RM) $(objutil)/cbfstool/ifittool $(ifitobj)
|
||||||
$(RM) $(objutil)/cbfstool/cbfs-compression-tool $(cbfscompobj)
|
$(RM) $(objutil)/cbfstool/cbfs-compression-tool $(cbfscompobj)
|
||||||
|
$(RM) -r $(VBOOT_HOST_BUILD)
|
||||||
|
|
||||||
linux_trampoline.c: linux_trampoline.S
|
linux_trampoline.c: linux_trampoline.S
|
||||||
rm -f linux_trampoline.c
|
rm -f linux_trampoline.c
|
||||||
|
|
|
@ -27,11 +27,6 @@ cbfsobj += cbfs.o
|
||||||
cbfsobj += fsp_relocate.o
|
cbfsobj += fsp_relocate.o
|
||||||
cbfsobj += mem_pool.o
|
cbfsobj += mem_pool.o
|
||||||
cbfsobj += region.o
|
cbfsobj += region.o
|
||||||
# CRYPTOLIB
|
|
||||||
cbfsobj += 2sha_utility.o
|
|
||||||
cbfsobj += 2sha1.o
|
|
||||||
cbfsobj += 2sha256.o
|
|
||||||
cbfsobj += 2sha512.o
|
|
||||||
# FMAP
|
# FMAP
|
||||||
cbfsobj += fmap.o
|
cbfsobj += fmap.o
|
||||||
cbfsobj += kv_pair.o
|
cbfsobj += kv_pair.o
|
||||||
|
@ -81,11 +76,6 @@ ifitobj += rmodule.o
|
||||||
ifitobj += cbfs.o
|
ifitobj += cbfs.o
|
||||||
ifitobj += mem_pool.o
|
ifitobj += mem_pool.o
|
||||||
ifitobj += region.o
|
ifitobj += region.o
|
||||||
# CRYPTOLIB
|
|
||||||
ifitobj += 2sha_utility.o
|
|
||||||
ifitobj += 2sha1.o
|
|
||||||
ifitobj += 2sha256.o
|
|
||||||
ifitobj += 2sha512.o
|
|
||||||
# FMAP
|
# FMAP
|
||||||
ifitobj += fmap.o
|
ifitobj += fmap.o
|
||||||
ifitobj += kv_pair.o
|
ifitobj += kv_pair.o
|
||||||
|
@ -136,6 +126,17 @@ else
|
||||||
TOOLCFLAGS+=-std=c11
|
TOOLCFLAGS+=-std=c11
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
VBOOT_HOSTLIB = $(VBOOT_HOST_BUILD)/libvboot_host.a
|
||||||
|
|
||||||
|
$(VBOOT_HOSTLIB):
|
||||||
|
printf " MAKE $(subst $(objutil)/,,$(@))\n"
|
||||||
|
unset CFLAGS LDFLAGS; $(MAKE) -C $(VBOOT_SOURCE) \
|
||||||
|
BUILD=$(VBOOT_HOST_BUILD) \
|
||||||
|
CC="$(HOSTCC)" \
|
||||||
|
$(if $(HOSTPKGCONFIG), PKG_CONFIG="$(HOSTPKGCONFIG)") \
|
||||||
|
V=$(V) \
|
||||||
|
hostlib
|
||||||
|
|
||||||
$(objutil)/cbfstool/%.o: $(objutil)/cbfstool/%.c
|
$(objutil)/cbfstool/%.o: $(objutil)/cbfstool/%.c
|
||||||
printf " HOSTCC $(subst $(objutil)/,,$(@))\n"
|
printf " HOSTCC $(subst $(objutil)/,,$(@))\n"
|
||||||
$(HOSTCC) $(TOOLCPPFLAGS) $(TOOLCFLAGS) $(HOSTCFLAGS) -c -o $@ $<
|
$(HOSTCC) $(TOOLCPPFLAGS) $(TOOLCFLAGS) $(HOSTCFLAGS) -c -o $@ $<
|
||||||
|
@ -156,10 +157,6 @@ $(objutil)/cbfstool/%.o: $(top)/util/cbfstool/lzma/C/%.c
|
||||||
printf " HOSTCC $(subst $(objutil)/,,$(@))\n"
|
printf " HOSTCC $(subst $(objutil)/,,$(@))\n"
|
||||||
$(HOSTCC) $(TOOLCPPFLAGS) $(TOOLCFLAGS) $(HOSTCFLAGS) -c -o $@ $<
|
$(HOSTCC) $(TOOLCPPFLAGS) $(TOOLCFLAGS) $(HOSTCFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
$(objutil)/cbfstool/%.o: $(VBOOT_SOURCE)/firmware/2lib/%.c
|
|
||||||
printf " HOSTCC $(subst $(objutil)/,,$(@))\n"
|
|
||||||
$(HOSTCC) $(TOOLCPPFLAGS) $(TOOLCFLAGS) $(HOSTCFLAGS) -c -o $@ $<
|
|
||||||
|
|
||||||
$(objutil)/cbfstool/%.o: $(top)/src/commonlib/%.c
|
$(objutil)/cbfstool/%.o: $(top)/src/commonlib/%.c
|
||||||
printf " HOSTCC $(subst $(objutil)/,,$(@))\n"
|
printf " HOSTCC $(subst $(objutil)/,,$(@))\n"
|
||||||
$(HOSTCC) $(TOOLCPPFLAGS) $(TOOLCFLAGS) $(HOSTCFLAGS) -c -o $@ $<
|
$(HOSTCC) $(TOOLCPPFLAGS) $(TOOLCFLAGS) $(HOSTCFLAGS) -c -o $@ $<
|
||||||
|
@ -172,9 +169,9 @@ $(objutil)/cbfstool/%.o: $(top)/util/cbfstool/lz4/lib/%.c
|
||||||
printf " HOSTCC $(subst $(objutil)/,,$(@))\n"
|
printf " HOSTCC $(subst $(objutil)/,,$(@))\n"
|
||||||
$(HOSTCC) $(TOOLCPPFLAGS) $(TOOLCFLAGS) $(HOSTCFLAGS) -c -o $@ $<
|
$(HOSTCC) $(TOOLCPPFLAGS) $(TOOLCFLAGS) $(HOSTCFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
$(objutil)/cbfstool/cbfstool: $(addprefix $(objutil)/cbfstool/,$(cbfsobj))
|
$(objutil)/cbfstool/cbfstool: $(addprefix $(objutil)/cbfstool/,$(cbfsobj)) $(VBOOT_HOSTLIB)
|
||||||
printf " HOSTCC $(subst $(objutil)/,,$(@)) (link)\n"
|
printf " HOSTCC $(subst $(objutil)/,,$(@)) (link)\n"
|
||||||
$(HOSTCC) $(TOOLLDFLAGS) -o $@ $(addprefix $(objutil)/cbfstool/,$(cbfsobj))
|
$(HOSTCC) -v $(TOOLLDFLAGS) -o $@ $(addprefix $(objutil)/cbfstool/,$(cbfsobj)) $(VBOOT_HOSTLIB)
|
||||||
|
|
||||||
$(objutil)/cbfstool/fmaptool: $(addprefix $(objutil)/cbfstool/,$(fmapobj))
|
$(objutil)/cbfstool/fmaptool: $(addprefix $(objutil)/cbfstool/,$(fmapobj))
|
||||||
printf " HOSTCC $(subst $(objutil)/,,$(@)) (link)\n"
|
printf " HOSTCC $(subst $(objutil)/,,$(@)) (link)\n"
|
||||||
|
@ -188,9 +185,9 @@ $(objutil)/cbfstool/ifwitool: $(addprefix $(objutil)/cbfstool/,$(ifwiobj))
|
||||||
printf " HOSTCC $(subst $(objutil)/,,$(@)) (link)\n"
|
printf " HOSTCC $(subst $(objutil)/,,$(@)) (link)\n"
|
||||||
$(HOSTCC) $(TOOLLDFLAGS) -o $@ $(addprefix $(objutil)/cbfstool/,$(ifwiobj))
|
$(HOSTCC) $(TOOLLDFLAGS) -o $@ $(addprefix $(objutil)/cbfstool/,$(ifwiobj))
|
||||||
|
|
||||||
$(objutil)/cbfstool/ifittool: $(addprefix $(objutil)/cbfstool/,$(ifitobj))
|
$(objutil)/cbfstool/ifittool: $(addprefix $(objutil)/cbfstool/,$(ifitobj)) $(VBOOT_HOSTLIB)
|
||||||
printf " HOSTCC $(subst $(objutil)/,,$(@)) (link)\n"
|
printf " HOSTCC $(subst $(objutil)/,,$(@)) (link)\n"
|
||||||
$(HOSTCC) $(TOOLLDFLAGS) -o $@ $(addprefix $(objutil)/cbfstool/,$(ifitobj))
|
$(HOSTCC) $(TOOLLDFLAGS) -o $@ $(addprefix $(objutil)/cbfstool/,$(ifitobj)) $(VBOOT_HOSTLIB)
|
||||||
|
|
||||||
$(objutil)/cbfstool/cbfs-compression-tool: $(addprefix $(objutil)/cbfstool/,$(cbfscompobj))
|
$(objutil)/cbfstool/cbfs-compression-tool: $(addprefix $(objutil)/cbfstool/,$(cbfscompobj))
|
||||||
printf " HOSTCC $(subst $(objutil)/,,$(@)) (link)\n"
|
printf " HOSTCC $(subst $(objutil)/,,$(@)) (link)\n"
|
||||||
|
@ -208,9 +205,6 @@ $(objutil)/cbfstool/fmd_scanner.o: TOOLCFLAGS += -Wno-redundant-decls
|
||||||
$(objutil)/cbfstool/fmd_scanner.o: TOOLCFLAGS += -Wno-unused-function
|
$(objutil)/cbfstool/fmd_scanner.o: TOOLCFLAGS += -Wno-unused-function
|
||||||
# Tolerate lzma sdk warnings
|
# Tolerate lzma sdk warnings
|
||||||
$(objutil)/cbfstool/LzmaEnc.o: TOOLCFLAGS += -Wno-sign-compare -Wno-cast-qual
|
$(objutil)/cbfstool/LzmaEnc.o: TOOLCFLAGS += -Wno-sign-compare -Wno-cast-qual
|
||||||
# Tolerate vboot warnings
|
|
||||||
$(objutil)/cbfstool/2sha_utility.o: TOOLCFLAGS += -Wno-sign-compare
|
|
||||||
$(objutil)/cbfstool/2sha1.o: TOOLCFLAGS += -Wno-cast-qual
|
|
||||||
# Tolerate commonlib warnings
|
# Tolerate commonlib warnings
|
||||||
$(objutil)/cbfstool/region.o: TOOLCFLAGS += -Wno-sign-compare -Wno-cast-qual
|
$(objutil)/cbfstool/region.o: TOOLCFLAGS += -Wno-sign-compare -Wno-cast-qual
|
||||||
$(objutil)/cbfstool/cbfs.o: TOOLCFLAGS += -Wno-sign-compare -Wno-cast-qual
|
$(objutil)/cbfstool/cbfs.o: TOOLCFLAGS += -Wno-sign-compare -Wno-cast-qual
|
||||||
|
|
|
@ -4,6 +4,7 @@ RM ?= rm
|
||||||
|
|
||||||
HOSTCC ?= $(CC)
|
HOSTCC ?= $(CC)
|
||||||
VBOOT_SOURCE ?= $(top)/3rdparty/vboot
|
VBOOT_SOURCE ?= $(top)/3rdparty/vboot
|
||||||
|
VBOOT_HOST_BUILD ?= $(abspath $(objutil)/vboot_lib)
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: $(objutil)/futility/futility
|
all: $(objutil)/futility/futility
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
additional-dirs += $(objutil)/futility
|
additional-dirs += $(objutil)/futility
|
||||||
|
|
||||||
$(objutil)/futility/build/futility/futility:
|
VBOOT_FUTILITY = $(VBOOT_HOST_BUILD)/futility/futility
|
||||||
|
|
||||||
|
$(VBOOT_FUTILITY):
|
||||||
@printf " MAKE $(subst $(objutil)/,,$(@))\n"
|
@printf " MAKE $(subst $(objutil)/,,$(@))\n"
|
||||||
unset CFLAGS LDFLAGS; $(MAKE) -C $(VBOOT_SOURCE) \
|
unset CFLAGS LDFLAGS; $(MAKE) -C $(VBOOT_SOURCE) \
|
||||||
BUILD=$(abspath $@/../..) \
|
BUILD=$(VBOOT_HOST_BUILD) \
|
||||||
CC="$(HOSTCC)" \
|
CC="$(HOSTCC)" \
|
||||||
$(if $(HOSTPKGCONFIG), PKG_CONFIG="$(HOSTPKGCONFIG)") \
|
$(if $(HOSTPKGCONFIG), PKG_CONFIG="$(HOSTPKGCONFIG)") \
|
||||||
V=$(V) \
|
V=$(V) \
|
||||||
$(abspath $@)
|
$@
|
||||||
|
|
||||||
$(objutil)/futility/futility: $(objutil)/futility/build/futility/futility
|
$(objutil)/futility/futility: $(VBOOT_FUTILITY)
|
||||||
|
mkdir -p $(dir $@)
|
||||||
cp $< $@.tmp
|
cp $< $@.tmp
|
||||||
mv $@.tmp $@
|
mv $@.tmp $@
|
||||||
|
|
Loading…
Reference in New Issue