coreboot-kgpe-d16/util/cbfstool/Makefile
Yu-Ping Wu 0beddb5e23 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>
2020-03-23 08:34:23 +00:00

64 lines
1.9 KiB
Makefile

top ?= $(abspath ../..)
objutil ?= $(top)/util
CONFIG_FMD_GENPARSER ?= n
HOSTCC ?= $(CC)
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
INSTALL ?= /usr/bin/env install
OBJCOPY ?= objcopy
VBOOT_SOURCE ?= $(top)/3rdparty/vboot
VBOOT_HOST_BUILD ?= $(abspath $(objutil)/vboot_lib)
.PHONY: all
all: cbfstool ifittool fmaptool rmodtool ifwitool cbfs-compression-tool
cbfstool: $(objutil)/cbfstool/cbfstool
fmaptool: $(objutil)/cbfstool/fmaptool
rmodtool: $(objutil)/cbfstool/rmodtool
ifwitool: $(objutil)/cbfstool/ifwitool
ifittool: $(objutil)/cbfstool/ifittool
cbfs-compression-tool: $(objutil)/cbfstool/cbfs-compression-tool
.PHONY: clean cbfstool ifittool fmaptool rmodtool ifwitool cbfs-compression-tool
clean:
$(RM) fmd_parser.c fmd_parser.h fmd_scanner.c fmd_scanner.h
$(RM) $(objutil)/cbfstool/cbfstool $(cbfsobj)
$(RM) $(objutil)/cbfstool/fmaptool $(fmapobj)
$(RM) $(objutil)/cbfstool/rmodtool $(rmodobj)
$(RM) $(objutil)/cbfstool/ifwitool $(ifwiobj)
$(RM) $(objutil)/cbfstool/ifittool $(ifitobj)
$(RM) $(objutil)/cbfstool/cbfs-compression-tool $(cbfscompobj)
$(RM) -r $(VBOOT_HOST_BUILD)
linux_trampoline.c: linux_trampoline.S
rm -f linux_trampoline.c
$(CC) -m32 -o linux_trampoline linux_trampoline.S -ffreestanding -nostdlib -nostdinc -Wl,--defsym=_start=0
$(OBJCOPY) -Obinary -j .data linux_trampoline trampoline
echo "/* This file is automatically generated. Do not manually change */" > trampoline.c
xxd -c 16 -i trampoline >> trampoline.c
mv trampoline.c linux_trampoline.c
rm linux_trampoline trampoline
.PHONY: install
install: all
mkdir -p $(DESTDIR)$(BINDIR)
$(INSTALL) cbfstool $(DESTDIR)$(BINDIR)
$(INSTALL) fmaptool $(DESTDIR)$(BINDIR)
$(INSTALL) rmodtool $(DESTDIR)$(BINDIR)
$(INSTALL) ifwitool $(DESTDIR)$(BINDIR)
$(INSTALL) ifittool $(DESTDIR)$(BINDIR)
$(INSTALL) cbfs-compression-tool $(DESTDIR)$(BINDIR)
ifneq ($(V),1)
.SILENT:
endif
include Makefile.inc