summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-01-08 10:44:23 -0800
committerChromeBot <chrome-bot@google.com>2013-01-11 14:20:53 -0800
commit5d9bbf2bbd7b8dfad45d8ddfea6512987736e523 (patch)
tree6d720ac3bcd24aa618a08f7703012499eb27bdff
parentee327511af9ce0812eaadd56fc3e0e6fbdbc407f (diff)
downloadvboot-5d9bbf2bbd7b8dfad45d8ddfea6512987736e523.tar.gz
Unify vboot build into a single makefile
This is a necessary precursor to getting coverage working. BUG=chromium-os:26317 BRANCH=none TEST=manual sudo emerge vboot_reference emerge-link vboot_reference chromeos-u-boot emerge-daisy vboot_reference chromeos-u-boot Change-Id: Ibed91c64a5ca5fa486169d64fb01a9e868ce27e5 Signed-off-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit 13ed1f4812f810ee0a47b946ad990f1fa93f366c) Reviewed-on: https://gerrit.chromium.org/gerrit/40906 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
-rw-r--r--Makefile746
-rw-r--r--build.mk25
-rw-r--r--cgpt/Makefile74
-rw-r--r--firmware/Makefile135
-rw-r--r--host/Makefile46
-rw-r--r--tests/Makefile211
-rw-r--r--tests/bitmaps/Makefile8
-rw-r--r--tests/tpm_lite/Makefile45
-rw-r--r--utility/Makefile216
9 files changed, 678 insertions, 828 deletions
diff --git a/Makefile b/Makefile
index f040ba40..b9e47606 100644
--- a/Makefile
+++ b/Makefile
@@ -6,17 +6,16 @@ ifneq ($(V),1)
Q := @
endif
-export FIRMWARE_ARCH
-export MOCK_TPM
-export Q
-
# This Makefile normally builds in a 'build' subdir, but use
#
# make BUILD=<dir>
#
# to put the output somewhere else
+BUILD ?= $(shell pwd)/build
+
+# Target for 'make install'
+DESTDIR ?= /usr/bin
-#
# Provide default CC and CFLAGS for firmware builds; if you have any -D flags,
# please add them after this point (e.g., -DVBOOT_DEBUG).
#
@@ -54,19 +53,22 @@ CFLAGS ?= $(COMMON_FLAGS) \
-fvisibility=hidden -fno-strict-aliasing -fomit-frame-pointer
endif
-CC ?= gcc
-CXX ?= g++
-
-PKG_CONFIG ?= pkg-config
-ifneq ($(filter-out -static,$(LDFLAGS)),$(LDFLAGS))
-PKG_CONFIG += --static
-endif
-
# Fix compiling directly on host (outside of emake)
ifeq ($(ARCH),)
-export ARCH=amd64
+ARCH = amd64
endif
+# Some things only compile inside the Chromium OS chroot
+# TODO: is there a better way to detect this?
+ifneq ($(CROS_WORKON_SRCROOT),)
+IN_CHROOT = 1
+endif
+
+CC ?= gcc
+CXX ?= g++
+LD = $(CC)
+PKG_CONFIG ?= pkg-config
+
ifeq ($(FIRMWARE_ARCH),)
CFLAGS += -DCHROMEOS_ENVIRONMENT -Wall -Werror
endif
@@ -79,72 +81,680 @@ ifeq (${DISABLE_NDEBUG},)
CFLAGS += -DNDEBUG
endif
-export CC CXX PKG_CONFIG CFLAGS
+# Create / use dependency files
+CFLAGS += -MMD -MF $@.d
-export TOP = $(shell pwd)
-export FWDIR=$(TOP)/firmware
-export HOSTDIR=$(TOP)/host
-ifeq ($(FIRMWARE_ARCH),)
-export INCLUDES = -I$(FWDIR)/include -I$(FWDIR)/stub/include
-else
-export INCLUDES = -I$(FWDIR)/include -I$(FWDIR)/arch/$(FIRMWARE_ARCH)/include
+# Code coverage
+ifneq (${COV},)
+#COV_FLAGS = -O0 -fprofile-arcs -ftest-coverage
+COV_FLAGS = -O0 --coverage
+CFLAGS += $(COV_FLAGS)
+LDFLAGS += $(COV_FLAGS)
endif
-export BUILD ?= ${TOP}/build
-export FWLIB = ${BUILD}/vboot_fw.a
-export HOSTLIB = ${BUILD}/vboot_host.a
-export DUMPKERNELCONFIGLIB = ${BUILD}/libdump_kernel_config.a
+INCLUDES += \
+ -Ifirmware/include \
+ -Ifirmware/lib/include \
+ -Ifirmware/lib/cgptlib/include \
+ -Ifirmware/lib/cryptolib/include \
+ -Ifirmware/lib/tpm_lite/include
ifeq ($(FIRMWARE_ARCH),)
-SUBDIRS = firmware host utility cgpt tests tests/tpm_lite
+INCLUDES += -Ifirmware/stub/include
else
-SUBDIRS = firmware
-endif
-
-all:
- $(Q)set -e; \
- for d in $(shell find ${SUBDIRS} -name '*.c' -exec dirname {} \; |\
- sort -u); do \
- newdir=${BUILD}/$$d; \
- if [ ! -d $$newdir ]; then \
- mkdir -p $$newdir; \
- fi; \
- done; \
- [ -z "$(FIRMWARE_ARCH)" ] && $(MAKE) -C utility update_tlcl_structures; \
- for i in $(SUBDIRS); do \
- $(MAKE) -C $$i; \
- done
-
-libcgpt_cc:
- $(Q)mkdir -p ${BUILD}/cgpt ${BUILD}/firmware/lib/cgptlib ${BUILD}/firmware/stub
- $(Q)$(MAKE) -C cgpt libcgpt_cc
-
-cgptmanager_tests: libcgpt_cc
- $(Q)mkdir -p ${BUILD}/tests
- $(Q)$(MAKE) -C tests cgptmanager_tests
-
-libdump_kernel_config:
- $(Q)mkdir -p ${BUILD}/utility
- $(Q)$(MAKE) -C utility $(DUMPKERNELCONFIGLIB)
+INCLUDES += -Ifirmware/arch/$(FIRMWARE_ARCH)/include
+endif
+
+# Output libraries
+CGPTLIB := ${BUILD}/cgpt/libcgpt-cc.a
+DUMPKERNELCONFIGLIB := ${BUILD}/libdump_kernel_config.a
+FWLIB := ${BUILD}/vboot_fw.a
+HOSTLIB := ${BUILD}/vboot_host.a
+TEST_LIB := ${BUILD}/tests/test.a
+
+CRYPTO_LIBS := $(shell $(PKG_CONFIG) --libs libcrypto)
+
+ifneq ($(IN_CHROOT),)
+PC_BASE_VER ?= 125070
+PC_DEPS = libchrome-$(PC_BASE_VER)
+PC_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(PC_DEPS))
+PC_LDLIBS := $(shell $(PKG_CONFIG) --libs $(PC_DEPS))
+endif
+
+# Link with hostlib and crypto libs by default
+LIBS = $(HOSTLIB)
+LDLIBS = $(CRYPTO_LIBS)
+
+# Create output directories if necessary. Do this via explicit shell commands
+# so it happens before trying to generate/include dependencies.
+SUBDIRS := firmware host utility cgpt tests tests/tpm_lite
+_dir_create := $(foreach d, \
+ $(shell find $(SUBDIRS) -name '*.c' -exec dirname {} \; | sort -u), \
+ $(shell [ -d $(BUILD)/$(d) ] || mkdir -p $(BUILD)/$(d)))
+
+# First target
+all: fwlib $(if $(FIRMWARE_ARCH),,host_stuff)
+
+# Host targets
+host_stuff: fwlib hostlib cgpt utils tests
clean:
$(Q)/bin/rm -rf ${BUILD}
-install:
- $(Q)$(MAKE) -C utility install
- $(Q)$(MAKE) -C cgpt install
+install: cgpt_install utils_install
+
+# Coverage
+COV_INFO = $(BUILD)/coverage.info
+#coverage: runtests
+coverage:
+ rm -f $(COV_INFO)*
+ lcov --capture --directory . --base-directory . -o $(COV_INFO).1
+ lcov --remove $(COV_INFO).1 '/usr/*' -o $(COV_INFO)
+ genhtml $(COV_INFO) --output-directory $(BUILD)/coverage
+
+# Don't delete intermediate object files
+.SECONDARY:
+
+# Use second expansion phase for $$(LIBS) so dependencies on libraries are
+# properly evaluated for implicit rules.
+.SECONDEXPANSION:
+
+# -----------------------------------------------------------------------------
+# Firmware library
+
+# TPM-specific flags. These depend on the particular TPM we're targeting for.
+# They are needed here only for compiling parts of the firmware code into
+# user-level tests.
+
+# TPM_BLOCKING_CONTINUESELFTEST is defined if TPM_ContinueSelfTest blocks until
+# the self test has completed.
+
+$(FWLIB) : CFLAGS += -DTPM_BLOCKING_CONTINUESELFTEST
+
+# TPM_MANUAL_SELFTEST is defined if the self test must be started manually
+# (with a call to TPM_ContinueSelfTest) instead of starting automatically at
+# power on.
+#
+# We sincerely hope that TPM_BLOCKING_CONTINUESELFTEST and TPM_MANUAL_SELFTEST
+# are not both defined at the same time. (See comment in code.)
+
+# CFLAGS += -DTPM_MANUAL_SELFTEST
+
+ifeq ($(FIRMWARE_ARCH),i386)
+# Unrolling loops in cryptolib makes it faster
+$(FWLIB) : CFLAGS += -DUNROLL_LOOPS
+
+# Workaround for coreboot on x86, which will power off asynchronously
+# without giving us a chance to react. This is not an example of the Right
+# Way to do things. See chrome-os-partner:7689, and the commit message
+# that made this change.
+$(FWLIB) : CFLAGS += -DSAVE_LOCALE_IMMEDIATELY
+
+# On x86 we don't actually read the GBB data into RAM until it is needed.
+# Therefore it makes sense to cache it rather than reading it each time.
+# Enable this feature.
+$(FWLIB) : CFLAGS += -DCOPY_BMP_DATA
+endif
+
+ifeq ($(FIRMWARE_ARCH),)
+$(warning FIRMWARE_ARCH not defined; assuming local compile)
+
+# Disable rollback TPM when compiling locally, since otherwise
+# load_kernel_test attempts to talk to the TPM.
+$(FWLIB) : CFLAGS += -DDISABLE_ROLLBACK_TPM
+endif
+
+# find lib -iname '*.c' | sort
+FWLIB_SRCS = \
+ firmware/lib/cgptlib/cgptlib.c \
+ firmware/lib/cgptlib/cgptlib_internal.c \
+ firmware/lib/cgptlib/crc32.c \
+ firmware/lib/crc8.c \
+ firmware/lib/cryptolib/padding.c \
+ firmware/lib/cryptolib/rsa.c \
+ firmware/lib/cryptolib/rsa_utility.c \
+ firmware/lib/cryptolib/sha1.c \
+ firmware/lib/cryptolib/sha256.c \
+ firmware/lib/cryptolib/sha512.c \
+ firmware/lib/cryptolib/sha_utility.c \
+ firmware/lib/stateful_util.c \
+ firmware/lib/utility.c \
+ firmware/lib/utility_string.c \
+ firmware/lib/vboot_api_init.c \
+ firmware/lib/vboot_api_firmware.c \
+ firmware/lib/vboot_api_kernel.c \
+ firmware/lib/vboot_audio.c \
+ firmware/lib/vboot_common.c \
+ firmware/lib/vboot_display.c \
+ firmware/lib/vboot_firmware.c \
+ firmware/lib/vboot_kernel.c \
+ firmware/lib/vboot_nvstorage.c
+
+ifeq ($(MOCK_TPM),)
+FWLIB_SRCS += \
+ firmware/lib/rollback_index.c \
+ firmware/lib/tpm_bootmode.c \
+ firmware/lib/tpm_lite/tlcl.c
+else
+FWLIB_SRCS += \
+ firmware/lib/mocked_rollback_index.c \
+ firmware/lib/mocked_tpm_bootmode.c \
+ firmware/lib/tpm_lite/mocked_tlcl.c
+endif
+
+ifeq ($(FIRMWARE_ARCH),)
+# Include stub into firmware lib if compiling for host
+FWLIB_SRCS += \
+ firmware/stub/tpm_lite_stub.c \
+ firmware/stub/utility_stub.c \
+ firmware/stub/vboot_api_stub.c \
+ firmware/stub/vboot_api_stub_disk.c
+endif
+
+FWLIB_OBJS = $(FWLIB_SRCS:%.c=${BUILD}/%.o)
+ALL_OBJS += ${FWLIB_OBJS}
+
+ifeq ($(FIRMWARE_ARCH),)
+# Link test ensures firmware lib doesn't rely on outside libraries
+${BUILD}/firmware/linktest/main : LIBS = $(FWLIB)
+
+fwlib : ${BUILD}/firmware/linktest/main
+else
+fwlib : $(FWLIB)
+endif
+
+$(FWLIB) : $(FWLIB_OBJS)
+ @printf " RM $(subst $(BUILD)/,,$(@))\n"
+ $(Q)rm -f $@
+ @printf " AR $(subst $(BUILD)/,,$(@))\n"
+ $(Q)ar qc $@ $^
+
+# -----------------------------------------------------------------------------
+# Host library
+
+hostlib : $(HOSTLIB) ${BUILD}/host/linktest/main
+
+${BUILD}/host/% ${HOSTLIB} : INCLUDES += \
+ -Ihost/include\
+ -Ihost/arch/$(ARCH)/include
+
+HOSTLIB_SRCS = \
+ host/arch/$(ARCH)/lib/crossystem_arch.c \
+ host/lib/crossystem.c \
+ host/lib/file_keys.c \
+ host/lib/fmap.c \
+ host/lib/host_common.c \
+ host/lib/host_key.c \
+ host/lib/host_keyblock.c \
+ host/lib/host_misc.c \
+ host/lib/host_signature.c \
+ host/lib/signature_digest.c
+
+HOSTLIB_OBJS = $(HOSTLIB_SRCS:%.c=${BUILD}/%.o)
+ALL_OBJS += ${HOSTLIB_OBJS}
+
+# TODO: better way to make .a than duplicating this recipe each time?
+$(HOSTLIB) : $(HOSTLIB_OBJS) $(FWLIB_OBJS)
+ @printf " RM $(subst $(BUILD)/,,$(@))\n"
+ $(Q)rm -f $@
+ @printf " AR $(subst $(BUILD)/,,$(@))\n"
+ $(Q)ar qc $@ $^
+
+# -----------------------------------------------------------------------------
+# CGPT library and utility
+
+CGPT = ${BUILD}/cgpt/cgpt
+
+CGPT_SRCS = \
+ cgpt/cgpt.c \
+ cgpt/cgpt_add.c \
+ cgpt/cgpt_boot.c \
+ cgpt/cgpt_common.c \
+ cgpt/cgpt_create.c \
+ cgpt/cgpt_find.c \
+ cgpt/cgpt_legacy.c \
+ cgpt/cgpt_prioritize.c \
+ cgpt/cgpt_repair.c \
+ cgpt/cgpt_show.c \
+ cgpt/cmd_add.c \
+ cgpt/cmd_boot.c \
+ cgpt/cmd_create.c \
+ cgpt/cmd_find.c \
+ cgpt/cmd_legacy.c \
+ cgpt/cmd_prioritize.c \
+ cgpt/cmd_repair.c \
+ cgpt/cmd_show.c
+
+CGPT_OBJS = $(CGPT_SRCS:%.c=${BUILD}/%.o)
+ALL_OBJS += ${CGPT_OBJS}
+
+# TODO: why not make this include *all* the cgpt files, and simply have
+# cgpt link against it?
+# TODO: CgptManager.cc should move to the installer project. Shouldn't be
+# in libcgpt-cc.a.
+CGPTLIB_SRCS = \
+ cgpt/CgptManager.cc \
+ cgpt/cgpt_create.c \
+ cgpt/cgpt_add.c \
+ cgpt/cgpt_boot.c \
+ cgpt/cgpt_show.c \
+ cgpt/cgpt_repair.c \
+ cgpt/cgpt_prioritize.c \
+ cgpt/cgpt_common.c \
+ firmware/lib/cgptlib/crc32.c \
+ firmware/lib/cgptlib/cgptlib_internal.c \
+ firmware/stub/utility_stub.c
+
+CGPTLIB_OBJS = $(filter %.o, \
+ $(CGPTLIB_SRCS:%.c=${BUILD}/%.o) \
+ $(CGPTLIB_SRCS:%.cc=${BUILD}/%.o))
+ALL_OBJS += $(CGPTLIB_OBJS)
+
+cgpt : $(CGPT)
+.PHONY: cgpt
+
+libcgpt_cc : $(CGPTLIB)
+
+$(CGPTLIB) : INCLUDES += -Ifirmware/lib/cgptlib/include
+$(CGPTLIB) : $(CGPTLIB_OBJS)
+ @printf " RM $(subst $(BUILD)/,,$(@))\n"
+ $(Q)rm -f $@
+ @printf " AR $(subst $(BUILD)/,,$(@))\n"
+ $(Q)ar qc $@ $^
+
+$(CGPT) : INCLUDES += -Ifirmware/lib/cgptlib/include
+$(CGPT) : LDLIBS = -luuid
+$(CGPT) : LDFLAGS += -static
+$(CGPT) : $(CGPT_OBJS) $$(LIBS)
+ @printf " LDcgpt $(subst $(BUILD)/,,$(@))\n"
+ $(Q)$(LD) -o $(CGPT) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) $(LDLIBS)
+
+cgpt_install: $(CGPT)
+ mkdir -p $(DESTDIR)
+ cp -f $^ $(DESTDIR)
+ chmod a+rx $(patsubst ${BUILD}/cgpt/%,$(DESTDIR)/%,$^)
+
+# -----------------------------------------------------------------------------
+# Utilities
+
+${BUILD}/utility/% : INCLUDES += -Ihost/include -Iutility/include
+${BUILD}/utility/% : CFLAGS += $(PC_CFLAGS)
+
+AU_NAMES = \
+ crossystem \
+ dump_fmap \
+ gbb_utility
+AU_BINS := $(addprefix ${BUILD}/utility/,$(AU_NAMES))
+
+# Utilities for auto-update toolkits must be statically linked, and don't
+# use the crypto libs.
+${AU_BINS} : LDFLAGS += -static
+${AU_BINS} : CRYPTO_LIBS =
+
+# Scripts to install
+UTIL_SCRIPTS = \
+ utility/dev_debug_vboot \
+ utility/dev_make_keypair \
+ utility/enable_dev_usb_boot \
+ utility/vbutil_what_keys
+
+UTIL_NAMES = $(AU_NAMES) \
+ dev_sign_file \
+ dump_kernel_config \
+ dumpRSAPublicKey \
+ load_kernel_test \
+ pad_digest_utility \
+ signature_digest_utility \
+ tpm_init_temp_fix \
+ tpmc \
+ vbutil_ec \
+ vbutil_firmware \
+ vbutil_kernel \
+ vbutil_key \
+ vbutil_keyblock \
+ verify_data
+
+ifneq ($(IN_CHROOT),)
+UTIL_NAMES += mount-encrypted
+endif
+
+ifeq ($(MINIMAL),)
+UTIL_NAMES += \
+ bmpblk_font \
+ bmpblk_utility \
+ eficompress \
+ efidecompress
+endif
+
+UTIL_BINS = $(addprefix ${BUILD}/utility/,$(UTIL_NAMES))
+ALL_DEPS += $(addsuffix .d,${UTIL_BINS})
+
+utils : $(UTIL_BINS) $(UTIL_SCRIPTS)
+# TODO: change ebuild to pull scripts directly out of utility dir
+ $(Q)cp -f $(UTIL_SCRIPTS) $(BUILD)/utility
+ $(Q)chmod a+rx $(patsubst %,$(BUILD)/%,$(UTIL_SCRIPTS))
+
+utils_install : $(UTIL_BINS) $(UTIL_SCRIPTS)
+ mkdir -p $(DESTDIR)
+ cp -f $(UTIL_BINS) $(DESTDIR)
+ chmod a+rx $(patsubst %,$(DESTDIR)/%,$(UTIL_NAMES))
+ cp -f $(UTIL_SCRIPTS) $(DESTDIR)
+ chmod a+rx $(patsubst utility/%,$(DESTDIR)/%,$(UTIL_SCRIPTS))
+
+${BUILD}/utility/dump_kernel_config : LIBS += $(DUMPKERNELCONFIGLIB)
+${BUILD}/utility/dump_kernel_config : $$(LIBS) \
+ ${BUILD}/utility/dump_kernel_config_main.o
+ @printf " LDdkc $(subst $(BUILD)/,,$(@))\n"
+ $(Q)$(LD) $(CFLAGS) $(LDFLAGS) $^ -o $@ $(LIBS)
+
+# TODO: these build as both standalone utils and libs. Make standalone the
+# default so this is less crufty.
+${BUILD}/utility/eficompress.o : CFLAGS += -DSTANDALONE
+${BUILD}/utility/efidecompress.o : CFLAGS += -DSTANDALONE
+
+${BUILD}/utility/eficompress_lib.o : utility/eficompress.c
+ @printf " CC $(subst $(BUILD)/,,$(@))\n"
+ $(Q)$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
+${BUILD}/utility/efidecompress_lib.o : utility/efidecompress.c
+ @printf " CC $(subst $(BUILD)/,,$(@))\n"
+ $(Q)$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
+
+# GBB utility needs C++ linker
+${BUILD}/utility/gbb_utility : LD = $(CXX)
+${BUILD}/utility/gbb_utility : CFLAGS += -DWITH_UTIL_MAIN
+
+${BUILD}/utility/crossystem : ${BUILD}/utility/crossystem_main.o $$(LIBS)
+ @printf " LDcr $(subst $(BUILD)/,,$(@))\n"
+ $(Q)$(LD) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LIBS) $(LDLIBS)
+
+# TODO: Why isn't this the default? It's the only time this file is compiled.
+# (gbb_utility, too)
+${BUILD}/utility/bmpblk_utility.o : CFLAGS += -DWITH_UTIL_MAIN
+
+${BUILD}/utility/bmpblk_utility : LD = $(CXX)
+${BUILD}/utility/bmpblk_utility : LDLIBS = -llzma -lyaml
+${BUILD}/utility/bmpblk_utility : OBJS = \
+ ${BUILD}/utility/bmpblk_util.o \
+ ${BUILD}/utility/image_types.o \
+ ${BUILD}/utility/eficompress_lib.o \
+ ${BUILD}/utility/efidecompress_lib.o
+
+${BUILD}/utility/bmpblk_font: OBJS += ${BUILD}/utility/image_types.o
+
+# TODO: fix load_firmware_test util; it never got refactored for the new APIs
+
+# -----------------------------------------------------------------------------
+# Mount-encrypted utility for cryptohome
+
+# TODO: mount-encrypted should move to cryptohome and just link against
+# vboot-host.a for tlcl and crossystem.
+
+# The embedded libcrypto conflicts with the shipped openssl,
+# so mount-* builds without the common CFLAGS (and those includes).
+
+${BUILD}/utility/mount-helpers.o: \
+ utility/mount-helpers.c \
+ utility/mount-helpers.h \
+ utility/mount-encrypted.h
+ @printf " CCm-e $(subst $(BUILD)/,,$(@))\n"
+ $(Q)$(CC) -Wall -Werror -O2 -D_FORTIFY_SOURCE=2 -fstack-protector \
+ $(COV_FLAGS) \
+ $(shell $(PKG_CONFIG) --cflags glib-2.0 openssl) \
+ -c $< -o $@
+
+${BUILD}/utility/mount-encrypted: \
+ utility/mount-encrypted.c \
+ utility/mount-encrypted.h \
+ ${BUILD}/utility/mount-helpers.o $$(LIBS)
+ @printf " CCm-exe $(subst $(BUILD)/,,$(@))\n"
+ $(Q)$(CC) -Wall -Werror -O2 -D_FORTIFY_SOURCE=2 -fstack-protector \
+ $(shell $(PKG_CONFIG) --cflags glib-2.0 openssl) \
+ -Ifirmware/include \
+ -Ihost/include \
+ $(COV_FLAGS) \
+ $(LDFLAGS) \
+ $< -o $@ \
+ ${BUILD}/utility/mount-helpers.o $(LIBS) \
+ $(shell $(PKG_CONFIG) --libs glib-2.0 openssl) \
+ -lm
+ifneq (${COV},)
+ $(Q)mv -f mount-encrypted.gcno ${BUILD}/utility
+endif
+
+# -----------------------------------------------------------------------------
+# Utility to generate TLCL structure definition header file.
+
+${BUILD}/utility/tlcl_generator : CFLAGS += -fpack-struct
+${BUILD}/utility/tlcl_generator : LIBS =
+
+STRUCTURES_TMP=${BUILD}/tlcl_structures.tmp
+STRUCTURES_SRC=firmware/lib/tpm_lite/include/tlcl_structures.h
+
+update_tlcl_structures: ${BUILD}/utility/tlcl_generator
+ @printf " Rebuilding TLCL structures\n"
+ $(Q)${BUILD}/utility/tlcl_generator > $(STRUCTURES_TMP)
+ $(Q)cmp -s $(STRUCTURES_TMP) $(STRUCTURES_SRC) || \
+ ( echo "%% Updating structures.h %%" && \
+ cp $(STRUCTURES_TMP) $(STRUCTURES_SRC) )
+
+# -----------------------------------------------------------------------------
+# Library to dump kernel config
+
+libdump_kernel_config: $(DUMPKERNELCONFIGLIB)
+
+$(DUMPKERNELCONFIGLIB) : ${BUILD}/utility/dump_kernel_config.o
+ @printf " RM $(subst $(BUILD)/,,$(@))\n"
+ $(Q)rm -f $@
+ @printf " AR $(subst $(BUILD)/,,$(@))\n"
+ $(Q)ar qc $@ $^
+
+# -----------------------------------------------------------------------------
+# Tests
+
+# Allow multiple definitions, so tests can mock functions from other libraries
+${BUILD}/tests/% : CFLAGS += -Xlinker --allow-multiple-definition
+${BUILD}/tests/% : INCLUDES += -Ihost/include
+${BUILD}/tests/% : LDLIBS += -lrt -luuid
+${BUILD}/tests/% : LIBS += $(TEST_LIB)
+
+TEST_NAMES = \
+ cgptlib_test \
+ rollback_index2_tests \
+ rsa_padding_test \
+ rsa_utility_tests \
+ rsa_verify_benchmark \
+ sha_benchmark \
+ sha_tests \
+ stateful_util_tests \
+ tpm_bootmode_tests \
+ utility_string_tests \
+ utility_tests \
+ vboot_nvstorage_test \
+ vboot_api_init_tests \
+ vboot_api_devmode_tests \
+ vboot_api_firmware_tests \
+ vboot_api_kernel_tests \
+ vboot_audio_tests \
+ vboot_common_tests \
+ vboot_common2_tests \
+ vboot_common3_tests \
+ vboot_ec_tests \
+ vboot_firmware_tests
+
+ifneq ($(IN_CHROOT),)
+TEST_NAMES += CgptManagerTests
+endif
+
+TLCL_TEST_NAMES = \
+ earlyextend \
+ earlynvram \
+ earlynvram2 \
+ enable \
+ fastenable \
+ globallock \
+ redefine_unowned \
+ spaceperm \
+ testsetup \
+ timing \
+ writelimit
+TEST_NAMES += $(addprefix tpm_lite/tpmtest_,$(TLCL_TEST_NAMES))
+
+TEST_BINS = $(addprefix ${BUILD}/tests/,$(TEST_NAMES))
+ALL_DEPS += $(addsuffix .d,${TEST_BINS})
+
+tests : $(TEST_BINS)
+
+${TEST_LIB}: \
+ ${BUILD}/tests/test_common.o \
+ ${BUILD}/tests/timer_utils.o \
+ ${BUILD}/tests/crc32_test.o
+ @printf " RM $(subst $(BUILD)/,,$(@))\n"
+ $(Q)rm -f $@
+ @printf " AR $(subst $(BUILD)/,,$(@))\n"
+ $(Q)ar qc $@ $^
+
+# Compile rollback_index.c for unit test, so it uses the same implementation
+# as it does in the firmware.
+${BUILD}/tests/rollback_index_for_test.o : CFLAGS += -DROLLBACK_UNITTEST
+${BUILD}/tests/rollback_index_for_test.o : firmware/lib/rollback_index.c
+ @printf " CC $(subst $(BUILD)/,,$(@))\n"
+ $(Q)$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
+
+${BUILD}/tests/rollback_index2_tests: OBJS += \
+ ${BUILD}/tests/rollback_index_for_test.o
+
+${BUILD}/tests/vboot_audio_for_test.o : CFLAGS += -DCUSTOM_MUSIC
+${BUILD}/tests/vboot_audio_for_test.o : firmware/lib/vboot_audio.c
+ @printf " CC $(subst $(BUILD)/,,$(@))\n"
+ $(Q)$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
+
+${BUILD}/tests/vboot_audio_tests: OBJS += \
+ ${BUILD}/tests/vboot_audio_for_test.o \
+
+cgptmanager_tests: ${BUILD}/tests/CgptManagerTests
+
+${BUILD}/tests/CgptManagerTests : CFLAGS += -DWITH_UTIL_MAIN $(PC_CFLAGS)
+${BUILD}/tests/CgptManagerTests : LD = $(CXX)
+${BUILD}/tests/CgptManagerTests : LDLIBS += -lgtest -lgflags $(PC_LDLIBS)
+${BUILD}/tests/CgptManagerTests : LIBS = $(CGPTLIB)
+
+${BUILD}/tests/rollback_index_test.o : INCLUDES += -I/usr/include
+${BUILD}/tests/rollback_index_test : LIBS += -ltlcl
+
+# TPM tests have special naming
+# TODO: rename .c files to match test names
+${BUILD}/tests/tpm_lite/tpmtest_% : OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o
+${BUILD}/tests/tpm_lite/tpmtest_% : ${BUILD}/tests/tpm_lite/%.o $$(OBJS) \
+ $$(LIBS)
+ @printf " LDtpm $(subst $(BUILD)/,,$(@))\n"
+ $(Q)$(CC) $(CFLAGS) $(INCLUDES) $(LDFLAGS) $< $(OBJS) -o $@ \
+ $(LIBS) $(LDLIBS)
+
+# TODO: port these tests to new API, if not already eqivalent
+# functionality in other tests. These don't even compile at present.
+#
+# big_firmware_tests
+# big_kernel_tests
+# firmware_image_tests
+# firmware_rollback_tests
+# firmware_splicing_tests
+# firmware_verify_benchmark
+# kernel_image_tests
+# kernel_rollback_tests
+# kernel_splicing_tests
+# kernel_verify_benchmark
+# rollback_index_test
+# verify_firmware_fuzz_driver
+# verify_kernel_fuzz_driver
+
+# -----------------------------------------------------------------------------
+# Targets to run tests
+
+# Frequently-run tests
+runtests : runbmptests runcgpttests runfuzztests runmisctests
+
+# Generate test keys
+genkeys:
+ tests/gen_test_keys.sh
+
+# Generate test cases for fuzzing
+genfuzztestcases:
+ tests/gen_fuzz_test_cases.sh
+
+runbmptests: utils
+ cd tests/bitmaps && BMPBLK=${BUILD}/utility/bmpblk_utility \
+ ./TestBmpBlock.py -v
+
+runcgpttests : cgpt tests
+ ${BUILD}/tests/cgptlib_test
+ tests/run_cgpt_tests.sh ${BUILD}/cgpt/cgpt
+ifneq ($(IN_CHROOT),)
+ ${BUILD}/tests/CgptManagerTests --v=1
+endif
+
+# Exercise vbutil_kernel and vbutil_firmware
+runfuzztests: genfuzztestcases utils tests
+ tests/run_preamble_tests.sh
+ tests/run_vbutil_kernel_arg_tests.sh
+
+runmisctests : tests utils
+ ${BUILD}/tests/rollback_index2_tests
+ ${BUILD}/tests/rsa_utility_tests
+ ${BUILD}/tests/sha_tests
+ ${BUILD}/tests/stateful_util_tests
+ ${BUILD}/tests/tpm_bootmode_tests
+ ${BUILD}/tests/utility_string_tests
+ ${BUILD}/tests/utility_tests
+ ${BUILD}/tests/vboot_api_devmode_tests
+ ${BUILD}/tests/vboot_api_init_tests
+ ${BUILD}/tests/vboot_api_firmware_tests
+ ${BUILD}/tests/vboot_audio_tests
+ ${BUILD}/tests/vboot_firmware_tests
+ tests/run_rsa_tests.sh
+ tests/run_vboot_common_tests.sh
+ tests/run_vbutil_tests.sh
+
+# Run long tests, including all permutations of encryption keys (instead of
+# just the ones we use) and tests of currently-unused code (e.g. vboot_ec).
+# Not run by automated build.
+runlongtests : genkeys genfuzztestcases tests utils
+ tests/run_preamble_tests.sh --all
+ tests/run_vboot_common_tests.sh --all
+ tests/run_vboot_ec_tests.sh
+ tests/run_vbutil_tests.sh --all
+
+# TODO: tests to run when ported to new API
+# ./run_image_verification_tests.sh
+# # Splicing tests
+# ${BUILD}/tests/firmware_splicing_tests
+# ${BUILD}/tests/kernel_splicing_tests
+# # Rollback Tests
+# ${BUILD}/tests/firmware_rollback_tests
+# ${BUILD}/tests/kernel_rollback_tests
+
+# -----------------------------------------------------------------------------
+# Build rules
+
+${BUILD}/% : ${BUILD}/%.o $$(OBJS) $$(LIBS)
+ @printf " LD $(subst $(BUILD)/,,$(@))\n"
+ $(Q)$(LD) $(CFLAGS) $(INCLUDES) $(LDFLAGS) $< $(OBJS) -o $@ \
+ $(LIBS) $(LDLIBS)
+
+${BUILD}/%.o : %.c
+ @printf " CC $(subst $(BUILD)/,,$(@))\n"
+ $(Q)$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
-runtests:
- $(Q)$(MAKE) -C tests runtests
+${BUILD}/%.o : %.cc
+ @printf " CXX $(subst $(BUILD)/,,$(@))\n"
+ $(Q)$(CXX) $(CFLAGS) $(INCLUDES) -c -o $@ $<
-runlongtests:
- $(MAKE) -C tests runlongtests
+# -----------------------------------------------------------------------------
+# Dependencies must come last after ALL_OBJS has been accumulated
-runcgptmanagertests:
- $(Q)$(MAKE) -C tests runcgptmanagertests
+# TODO: I suspect this is missing some object files. Make a temp
+# target which cleans all known obj/exe's and see what's left; those
+# are the files which need deps.
-rbtest:
- $(Q)$(MAKE) -C tests rbtest
+ALL_DEPS += $(ALL_OBJS:%.o=%.o.d)
-runbmptests:
- $(Q)$(MAKE) -C tests runbmptests
+-include ${ALL_DEPS}
diff --git a/build.mk b/build.mk
deleted file mode 100644
index 4b10a121..00000000
--- a/build.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-ALL_OBJS = $(ALL_SRCS:%.c=${BUILD_ROOT}/%.o)
-ALL_DEPS = $(ALL_OBJS:%.o=%.o.d)
-
-#
-# For this target (all) to be built by default, the including file must not
-# define any other targets above the line including this file.
-#
-# This all: rule must be above the %.o: %.c rule below, otherwise the
-# rule below becomes the default target.
-#
-all: ${ALL_OBJS}
-
-${BUILD_ROOT}/%.o : %.c
- @printf " CC $(subst $(BUILD_ROOT)/,,$(@))\n"
- $(Q)$(CC) $(CFLAGS) $(INCLUDES) -MMD -MF $@.d -c -o $@ $<
-
-${BUILD_ROOT}/%.o : %.cc
- @printf " CXX $(subst $(BUILD_ROOT)/,,$(@))\n"
- $(Q)$(CXX) $(CFLAGS) $(INCLUDES) -MMD -MF $@.d -c -o $@ $<
-
--include ${ALL_DEPS}
diff --git a/cgpt/Makefile b/cgpt/Makefile
deleted file mode 100644
index c22a680c..00000000
--- a/cgpt/Makefile
+++ /dev/null
@@ -1,74 +0,0 @@
-# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-BUILD_ROOT := ${BUILD}/cgpt
-
-INCLUDES = -I$(FWDIR)/lib/cgptlib/include -I$(FWDIR)/include
-LIBS = ${HOSTLIB}
-LDLIBS += -luuid
-LDFLAGS += -static
-
-DESTDIR ?= /usr/bin
-
-PROGNAME = ${BUILD_ROOT}/cgpt
-
-LIB_CGPT_CC = ${BUILD_ROOT}/libcgpt-cc.a
-
-ALL_SRCS = \
- cgpt.c \
- cgpt_create.c \
- cgpt_add.c \
- cgpt_boot.c \
- cgpt_show.c \
- cgpt_repair.c \
- cgpt_prioritize.c \
- cgpt_find.c \
- cgpt_legacy.c \
- cmd_show.c \
- cmd_repair.c \
- cmd_create.c \
- cmd_add.c \
- cmd_boot.c \
- cmd_find.c \
- cmd_prioritize.c \
- cmd_legacy.c \
- cgpt_common.c
-
-LIB_CGPT_CC_SRCS = \
- CgptManager.cc \
- cgpt_create.c \
- cgpt_add.c \
- cgpt_boot.c \
- cgpt_show.c \
- cgpt_repair.c \
- cgpt_prioritize.c \
- cgpt_common.c \
- ../firmware/lib/cgptlib/crc32.c \
- ../firmware/lib/cgptlib/cgptlib_internal.c \
- ../firmware/stub/utility_stub.c
-
-main: $(PROGNAME)
-
-include ../build.mk
-
-LIB_CGPT_CC_OBJS = $(filter %.o, \
- $(LIB_CGPT_CC_SRCS:%.c=${BUILD_ROOT}/%.o) \
- $(LIB_CGPT_CC_SRCS:%.cc=${BUILD_ROOT}/%.o))
-LIB_CGPT_CC_DEPS = $(LIB_CGPT_CC_OBJS:%.o=%.o.d)
-
-libcgpt_cc: $(LIB_CGPT_CC)
-
-$(LIB_CGPT_CC): $(LIB_CGPT_CC_OBJS)
- rm -f $@
- ar qc $@ $^
-
-$(PROGNAME): $(ALL_OBJS) $(LIBS)
- $(CC) -o $(PROGNAME) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS)
-
-install: $(PROGNAME)
- mkdir -p $(DESTDIR)
- cp -f $^ $(DESTDIR)
- chmod a+rx $(patsubst ${BUILD_ROOT}/%,$(DESTDIR)/%,$^)
-
-.PHONY: all install
diff --git a/firmware/Makefile b/firmware/Makefile
deleted file mode 100644
index 1612da95..00000000
--- a/firmware/Makefile
+++ /dev/null
@@ -1,135 +0,0 @@
-# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# This Makefile is designed to be called from the top-level vboot_reference one
-
-FWTOP := $(shell pwd)
-LIBDIR = $(FWTOP)/lib
-STUBDIR = $(FWTOP)/stub
-TESTDIR = $(FWTOP)/linktest
-BUILD_ROOT := ${BUILD}/$(shell basename ${FWTOP})
-LIBS = $(FWLIB) # Firmware library must be self-contained
-
-# Disable rollback TPM when compiling locally, since otherwise
-# load_kernel_test attempts to talk to the TPM.
-ifeq ($(FIRMWARE_ARCH),)
-$(warning FIRMWARE_ARCH not defined, assuming local compile)
-CFLAGS += -DDISABLE_ROLLBACK_TPM
-endif
-
-# TPM-specific flags. These depend on the particular TPM we're targeting for.
-# They are needed here only for compiling parts of the firmware code into
-# user-level tests.
-
-# TPM_BLOCKING_CONTINUESELFTEST is defined if TPM_ContinueSelfTest blocks until
-# the self test has completed.
-
-CFLAGS += -DTPM_BLOCKING_CONTINUESELFTEST
-
-# TPM_MANUAL_SELFTEST is defined if the self test must be started manually
-# (with a call to TPM_ContinueSelfTest) instead of starting automatically at
-# power on.
-#
-# We sincerely hope that TPM_BLOCKING_CONTINUESELFTEST and TPM_MANUAL_SELFTEST
-# are not both defined at the same time. (See comment in code.)
-
-# CFLAGS += -DTPM_MANUAL_SELFTEST
-
-#
-# Unrolling loops in cryptolib makes it faster
-#
-
-ifeq ($(FIRMWARE_ARCH),i386)
-CFLAGS += -DUNROLL_LOOPS
-
-# Workaround for coreboot on x86, which will power off asynchronously
-# without giving us a chance to react. This is not an example of the Right
-# Way to do things. See chrome-os-partner:7689, and the commit message
-# that made this change.
-CFLAGS += -DSAVE_LOCALE_IMMEDIATELY
-
-# On x86 we don't actually read the GBB data into RAM until it is needed.
-# Therefore it makes sense to cache it rather than reading it each time.
-# Enable this feature.
-CFLAGS += -DCOPY_BMP_DATA
-endif
-
-INCLUDES = \
- -I$(FWTOP)/include \
- -I$(LIBDIR)/include \
- -I$(LIBDIR)/cgptlib/include \
- -I$(LIBDIR)/cryptolib/include \
- -I$(LIBDIR)/tpm_lite/include
-
-ifeq ($(FIRMWARE_ARCH),)
-INCLUDES += -I$(STUBDIR)/include
-else
-INCLUDES += -I$(FWDIR)/arch/$(FIRMWARE_ARCH)/include
-endif
-
-# find ./lib -iname '*.c' | sort
-LIB_SRCS = \
- ./lib/cgptlib/cgptlib.c \
- ./lib/cgptlib/cgptlib_internal.c \
- ./lib/cgptlib/crc32.c \
- ./lib/crc8.c \
- ./lib/cryptolib/padding.c \
- ./lib/cryptolib/rsa.c \
- ./lib/cryptolib/rsa_utility.c \
- ./lib/cryptolib/sha1.c \
- ./lib/cryptolib/sha256.c \
- ./lib/cryptolib/sha512.c \
- ./lib/cryptolib/sha_utility.c \
- ./lib/stateful_util.c \
- ./lib/utility.c \
- ./lib/utility_string.c \
- ./lib/vboot_api_init.c \
- ./lib/vboot_api_firmware.c \
- ./lib/vboot_api_kernel.c \
- ./lib/vboot_audio.c \
- ./lib/vboot_common.c \
- ./lib/vboot_display.c \
- ./lib/vboot_firmware.c \
- ./lib/vboot_kernel.c \
- ./lib/vboot_nvstorage.c
-
-ifeq ($(MOCK_TPM),)
-LIB_SRCS += \
- ./lib/rollback_index.c \
- ./lib/tpm_bootmode.c \
- ./lib/tpm_lite/tlcl.c
-else
-LIB_SRCS += \
- ./lib/mocked_rollback_index.c \
- ./lib/mocked_tpm_bootmode.c \
- ./lib/tpm_lite/mocked_tlcl.c
-endif
-
-LIB_OBJS = $(LIB_SRCS:%.c=${BUILD_ROOT}/%.o)
-
-STUB_SRCS = \
- ./stub/tpm_lite_stub.c \
- ./stub/utility_stub.c \
- ./stub/vboot_api_stub.c \
- ./stub/vboot_api_stub_disk.c
-
-STUB_OBJS = $(STUB_SRCS:%.c=${BUILD_ROOT}/%.o)
-
-ALL_SRCS = ${LIB_SRCS} ${STUB_SRCS}
-
-ifeq ($(FIRMWARE_ARCH),)
-test : $(STUB_OBJS) $(FWLIB)
- $(CC) $(CFLAGS) $(INCLUDES) -o $(BUILD_ROOT)/a.out \
- $(TESTDIR)/main.c $(STUB_OBJS) $(LIBS)
-else
-test : $(FWLIB)
-endif
-
-include ../build.mk
-
-$(FWLIB) : $(LIB_OBJS)
- @printf " RM $(@))\n"
- $(Q)rm -f $@
- @printf " AR $(@))\n"
- $(Q)ar qc $@ $^
diff --git a/host/Makefile b/host/Makefile
deleted file mode 100644
index c4b24d0b..00000000
--- a/host/Makefile
+++ /dev/null
@@ -1,46 +0,0 @@
-# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-HOSTTOP := $(shell pwd)
-TESTDIR = $(HOSTTOP)/linktest
-BUILD_ROOT := ${BUILD}/$(shell basename ${HOSTTOP})
-
-INCLUDES += \
- -I$(HOSTTOP)/include \
- -I$(HOSTTOP)/arch/$(ARCH)/include \
- -I$(FWDIR)/lib/include \
- -I$(FWDIR)/lib/cgptlib/include \
- -I$(FWDIR)/lib/cryptolib/include
-
-# find ./lib -iname '*.c' | sort
-LIB_SRCS = \
- ./arch/$(ARCH)/lib/crossystem_arch.c \
- ./lib/crossystem.c \
- ./lib/file_keys.c \
- ./lib/fmap.c \
- ./lib/host_common.c \
- ./lib/host_key.c \
- ./lib/host_keyblock.c \
- ./lib/host_misc.c \
- ./lib/host_signature.c \
- ./lib/signature_digest.c
-
-STUB_SRCS = \
- ../firmware/stub/tpm_lite_stub.c \
- ../firmware/stub/utility_stub.c \
- ../firmware/stub/vboot_api_stub.c
-
-ALL_SRCS = ${LIB_SRCS} ${STUB_SRCS}
-
-test : $(HOSTLIB)
- $(CC) $(CFLAGS) $(INCLUDES) -o $(BUILD_ROOT)/a.out $(TESTDIR)/main.c \
- $(HOSTLIB) -lcrypto
-
-include ../build.mk
-
-$(HOSTLIB) : $(ALL_OBJS) $(FWLIB)
- rm -rf $@ $(BUILD_ROOT)/.tmp
- mkdir -p $(BUILD_ROOT)/.tmp
- cd $(BUILD_ROOT)/.tmp ; ar x $(FWLIB)
- ar qc $@ $^ $(BUILD_ROOT)/.tmp/*.o
diff --git a/tests/Makefile b/tests/Makefile
deleted file mode 100644
index 0731e3b9..00000000
--- a/tests/Makefile
+++ /dev/null
@@ -1,211 +0,0 @@
-# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-PKG_CONFIG ?= pkg-config
-
-BASE_VER ?= 125070
-PC_DEPS = libchrome-$(BASE_VER)
-PC_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(PC_DEPS))
-PC_LIBS := $(shell $(PKG_CONFIG) --libs $(PC_DEPS))
-
-ifeq ($(FIRMWARE_ARCH),)
-CFLAGS += -DCHROMEOS_ENVIRONMENT
-CXXFLAGS += -DCHROMEOS_ENVIRONMENT
-endif
-
-INCLUDES += -I./include \
- -I$(FWDIR)/lib/include \
- -I$(FWDIR)/lib/cgptlib/include \
- -I$(FWDIR)/lib/cryptolib/include \
- -I$(FWDIR)/lib/tpm_lite/include \
- -I$(HOSTDIR)/include \
- $(PC_CFLAGS)
-
-BUILD_ROOT = ${BUILD}/tests
-
-TEST_NAMES = cgptlib_test \
- rollback_index2_tests \
- rsa_padding_test \
- rsa_utility_tests \
- rsa_verify_benchmark \
- sha_benchmark \
- sha_tests \
- stateful_util_tests \
- utility_string_tests \
- utility_tests \
- tpm_bootmode_tests \
- vboot_api_init_tests \
- vboot_api_firmware_tests \
- vboot_common_tests \
- vboot_common2_tests \
- vboot_common3_tests \
- vboot_ec_tests \
- vboot_firmware_tests \
- vboot_nvstorage_test \
- vboot_api_devmode_tests \
- vboot_audio_tests \
- vboot_api_kernel_tests
-
-TEST_BINS = $(addprefix ${BUILD_ROOT}/,$(TEST_NAMES))
-
-TEST_LIB = ${BUILD_ROOT}/test.a
-TEST_LIB_SRCS = test_common.c timer_utils.c crc32_test.c
-TEST_LIB_OBJS = $(TEST_LIB_SRCS:%.c=${BUILD_ROOT}/%.o)
-ALL_DEPS = $(addsuffix .d,${TEST_BINS} ${TEST_LIB_OBJS})
-# Allow multiple definitions, so tests can mock functions from other libraries
-CFLAGS += -MMD -MF $@.d -Xlinker --allow-multiple-definition
-CXXFLAGS += -MMD -MF $@.d -Xlinker --allow-multiple-definition
-LDLIBS += $(PC_LIBS) -luuid
-
-LIBS := ${TEST_LIB} $(HOSTLIB)
-
-ifneq (${RUNTESTS},)
-EXTRA_TARGET = runtests
-endif
-
-all: $(TEST_BINS) ${EXTRA_TARGET}
-
-rbtest: $(BUILD_ROOT)/rollback_index_test
-
-cgptmanager_tests: $(BUILD_ROOT)/CgptManagerTests
-
-${TEST_LIB}: ${TEST_LIB_OBJS}
- rm -f $@
- $(AR) rc $@ $^
-
-
-${BUILD_ROOT}/CgptManagerTests.o: CgptManagerTests.cc
- $(CXX) -DWITH_UTIL_MAIN $(CXXFLAGS) $(INCLUDES) -c $< -o $@
-
-${BUILD_ROOT}/CgptManagerTests: ${BUILD_ROOT}/CgptManagerTests.o
- $(CXX) $(CXXFLAGS) $(INCLUDES) $(LDFLAGS) $^ \
- ${BUILD}/cgpt/libcgpt-cc.a -lgtest -lgflags $(LDLIBS) -o $@
-
-${BUILD_ROOT}/vboot_audio_for_test.o : $(FWDIR)/lib/vboot_audio.c
- $(CC) $(CFLAGS) -DCUSTOM_MUSIC $(INCLUDES) \
- -MMD -MF $@.d -c -o $@ $<
-
-${BUILD_ROOT}/vboot_audio_tests: vboot_audio_tests.c \
- ${BUILD_ROOT}/vboot_audio_for_test.o ${LIBS}
- $(CC) $(CFLAGS) $(INCLUDES) $< ${BUILD_ROOT}/vboot_audio_for_test.o \
- ${LIBS} -o $@ -lcrypto -lrt
-
-${BUILD_ROOT}/rollback_index_test.o : rollback_index_test.c
- $(CC) $(CFLAGS) -I/usr/include $(INCLUDES) -MMD -MF $@.d -c -o $@ $<
-
-${BUILD_ROOT}/rollback_index_test: rollback_index_test.c ${HOSTLIB}
- $(CC) $(CFLAGS) -I/usr/include $(INCLUDES) $< -o $@ \
- -ltlcl ${HOSTLIB} -lcrypto -lrt
-
-# Compile rollback_index.c for unit test, so it uses the same implementation
-# as it does in the firmware.
-${BUILD_ROOT}/rollback_index_for_test.o : $(FWDIR)/lib/rollback_index.c
- $(CC) $(CFLAGS) -DROLLBACK_UNITTEST $(INCLUDES) \
- -MMD -MF $@.d -c -o $@ $<
-
-${BUILD_ROOT}/rollback_index2_tests: rollback_index2_tests.c \
- ${BUILD_ROOT}/rollback_index_for_test.o ${LIBS}
- $(CC) $(CFLAGS) $(INCLUDES) $< ${BUILD_ROOT}/rollback_index_for_test.o \
- ${LIBS} -o $@ -lcrypto -lrt
-
-${BUILD_ROOT}/%.o : %.c
- $(CC) $(CFLAGS) $(INCLUDES) -MMD -MF $@.d -c -o $@ $<
-
-${BUILD_ROOT}/%: %.c ${LIBS}
- $(CC) $(CFLAGS) $(INCLUDES) $< ${LIBS} -o $@ -lcrypto -lrt
-
-# TODO: port these tests to new API, if not already eqivalent
-# functionality in other tests
-#
-# big_firmware_tests
-# firmware_image_tests
-# firmware_rollback_tests
-# firmware_splicing_tests
-# firmware_verify_benchmark
-# verify_firmware_fuzz_driver
-#
-# big_kernel_tests
-# kernel_image_tests
-# kernel_rollback_tests
-# kernel_splicing_tests
-# kernel_verify_benchmark
-# verify_kernel_fuzz_driver
-
-# Generate test keys
-genkeys:
- ./gen_test_keys.sh
-
-# Run cgpt tests
-runcgpttests:
- ${BUILD_ROOT}/cgptlib_test
- ./run_cgpt_tests.sh ${BUILD}/cgpt/cgpt
-
-# Run CgptManager tests
-runcgptmanagertests:
- ${BUILD_ROOT}/CgptManagerTests --v=1
-
-# Run crypto tests
-runcryptotests:
- ./run_rsa_tests.sh
- ${BUILD_ROOT}/rsa_utility_tests
- ${BUILD_ROOT}/sha_tests
- ./run_vboot_common_tests.sh
-
-# Run other misc tests
-runmisctests:
- ./run_vbutil_tests.sh
- ${BUILD_ROOT}/rollback_index2_tests
- ${BUILD_ROOT}/stateful_util_tests
- ${BUILD_ROOT}/tpm_bootmode_tests
- ${BUILD_ROOT}/utility_string_tests
- ${BUILD_ROOT}/utility_tests
- ${BUILD_ROOT}/vboot_api_init_tests
- ${BUILD_ROOT}/vboot_api_firmware_tests
- ${BUILD_ROOT}/vboot_firmware_tests
-
-# Generate test cases for fuzzing
-genfuzztestcases:
- ./gen_fuzz_test_cases.sh
-
-# This will exercise vbutil_kernel and vbutil_firmware
-runfuzztests: genfuzztestcases
- ./run_preamble_tests.sh
- ./run_vbutil_kernel_arg_tests.sh
-
-# Run bmpblk_utility tests
-runbmptests:
- $(MAKE) BUILD=$(shell readlink -f ${BUILD}) -C bitmaps runtests
-
-runsoundtests:
- ${BUILD_ROOT}/vboot_api_devmode_tests
- ${BUILD_ROOT}/vboot_audio_tests
-
-ALLTESTS=runcgpttests runcryptotests runmisctests runfuzztests \
- runbmptests runsoundtests
-
-# Run a subset of tests
-runtests: genkeys ${ALLTESTS}
-
-# Run long tests, including all permutations of encryption keys (instead of
-# just the ones we use) and tests of currently-unused code (e.g. vboot_ec)
-runlongtests: genkeys genfuzztestcases
- ./run_vboot_common_tests.sh --all
- ./run_vbutil_tests.sh --all
- ./run_preamble_tests.sh --all
- ./run_vboot_ec_tests.sh
-
-# TODO: tests to run when ported to new API
-# ./run_image_verification_tests.sh
-# # Splicing tests
-# ${BUILD_ROOT}/firmware_splicing_tests
-# ${BUILD_ROOT}/kernel_splicing_tests
-# # Rollback Tests
-# ${BUILD_ROOT}/firmware_rollback_tests
-# ${BUILD_ROOT}/kernel_rollback_tests
-
-install-rbtest: $(BUILD_ROOT)/rollback_index_test
- mkdir -p $(DESTDIR)
- cp -f $(BUILD_ROOT)/rollback_index_test $(DESTDIR)
-
--include ${ALL_DEPS}
diff --git a/tests/bitmaps/Makefile b/tests/bitmaps/Makefile
deleted file mode 100644
index 0d200ad6..00000000
--- a/tests/bitmaps/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-export BMPBLK=${BUILD}/utility/bmpblk_utility
-
-runtests:
- ./TestBmpBlock.py -v
diff --git a/tests/tpm_lite/Makefile b/tests/tpm_lite/Makefile
deleted file mode 100644
index 69e67f39..00000000
--- a/tests/tpm_lite/Makefile
+++ /dev/null
@@ -1,45 +0,0 @@
-# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Always use VBOOT_DEBUG for tests. (Multiple -DVAR for the same VAR are OK.)
-CFLAGS += -DVBOOT_DEBUG
-
-INCLUDES += -I./include \
- -I$(FWDIR)/lib/include \
- -I$(FWDIR)/lib/cgptlib/include \
- -I$(FWDIR)/lib/cryptolib/include \
- -I$(FWDIR)/lib/tpm_lite/include \
- -I$(HOSTDIR)/include
-BUILD_ROOT = ${BUILD}/tests/tpm_lite
-
-TEST_NAMES = tpmtest_earlyextend \
- tpmtest_earlynvram \
- tpmtest_earlynvram2 \
- tpmtest_enable \
- tpmtest_fastenable \
- tpmtest_globallock \
- tpmtest_redefine_unowned \
- tpmtest_spaceperm \
- tpmtest_testsetup \
- tpmtest_timing \
- tpmtest_writelimit \
-
-TEST_BINS = $(addprefix ${BUILD_ROOT}/,$(TEST_NAMES))
-SHARED_TEST_OBJ = $(BUILD_ROOT)/tlcl_tests.o
-
-ALL_DEPS = $(addsuffix .d,${TEST_BINS})
-CFLAGS += -MMD -MF $@.d
-
-LIBS := ${TEST_LIB} $(HOSTLIB)
-
-all: $(TEST_BINS)
-
-${BUILD_ROOT}/%.o : %.c
- $(CC) $(CFLAGS) $(INCLUDES) -MMD -MF $@.d -c -o $@ $<
-
-${BUILD_ROOT}/tpmtest_%: %.c ${LIBS} ${SHARED_TEST_OBJ}
- $(CC) $(CFLAGS) $(INCLUDES) $< ${SHARED_TEST_OBJ} \
- ${LIBS} -o $@ -lcrypto -lrt $(LDFLAGS)
-
--include ${ALL_DEPS}
diff --git a/utility/Makefile b/utility/Makefile
deleted file mode 100644
index b874c36a..00000000
--- a/utility/Makefile
+++ /dev/null
@@ -1,216 +0,0 @@
-# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-INCLUDES += -I./include \
- -I$(FWDIR)/lib/include \
- -I$(FWDIR)/lib/cgptlib/include \
- -I$(FWDIR)/lib/cryptolib/include \
- -I$(FWDIR)/lib/tpm_lite/include \
- -I$(HOSTDIR)/include
-CFLAGS += $(INCLUDES)
-CFLAGS += -MMD -MF $@.d
-LIBS = $(HOSTLIB)
-HOSTCC = cc
-CRYPTO_LIBS := $(shell $(PKG_CONFIG) --libs libcrypto)
-
-BUILD_ROOT = ${BUILD}/utility
-
-DESTDIR ?= /usr/bin
-
-# Special flags for auto-update toolkits (must be statically linked).
-AU_LDFLAGS = $(LDFLAGS) -static
-AU_TARGETS = crossystem \
- dump_fmap \
- gbb_utility
-
-TARGET_NAMES = $(AU_TARGETS) \
- dumpRSAPublicKey \
- dump_kernel_config \
- load_kernel_test \
- pad_digest_utility \
- signature_digest_utility \
- tlcl_generator \
- tpm_init_temp_fix \
- tpmc \
- vbutil_ec \
- vbutil_firmware \
- vbutil_kernel \
- vbutil_key \
- vbutil_keyblock \
- verify_data \
- dev_make_keypair \
- dev_sign_file \
- dev_debug_vboot \
- enable_dev_usb_boot \
- vbutil_what_keys
-
-ifeq ($(MINIMAL),)
-TARGET_NAMES += bmpblk_font bmpblk_utility eficompress efidecompress
-else
-TARGET_NAMES += mount-encrypted
-endif
-
-TARGET_BINS = $(addprefix ${BUILD_ROOT}/,$(TARGET_NAMES))
-ALL_DEPS = $(addsuffix .d,${TARGET_BINS})
-
-all: $(TARGET_BINS) $(DUMPKERNELCONFIGLIB)
-
-${BUILD_ROOT}/crossystem: crossystem_main.c $(LIBS)
- $(CC) $(CFLAGS) $(AU_LDFLAGS) $< -o $@ $(LIBS)
-
-${BUILD_ROOT}/gbb_utility: gbb_utility.cc
- $(CXX) -DWITH_UTIL_MAIN $(CFLAGS) $(AU_LDFLAGS) $< -o $@
-
-${BUILD_ROOT}/dump_fmap: dump_fmap.c $(LIBS)
- $(CC) $(CFLAGS) $(AU_LDFLAGS) $< -o $@ $(LIBS)
-
-${BUILD_ROOT}/dumpRSAPublicKey: dumpRSAPublicKey.c
- $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(CRYPTO_LIBS)
-
-${BUILD_ROOT}/dump_kernel_config: dump_kernel_config_main.c \
- $(DUMPKERNELCONFIGLIB)
- $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ \
- $(LIBS) $(DUMPKERNELCONFIGLIB) $(CRYPTO_LIBS)
-
-${BUILD_ROOT}/dump_kernel_config.o: dump_kernel_config.c
- $(CC) $(CFLAGS) -c $< -o $@
-
-$(DUMPKERNELCONFIGLIB): ${BUILD_ROOT}/dump_kernel_config.o
- rm -f $@
- ar qc $@ $^
-
-${BUILD_ROOT}/bmpblk_utility.o: bmpblk_utility.cc
- $(CXX) -DWITH_UTIL_MAIN $(CFLAGS) -c $< -o $@
-
-${BUILD_ROOT}/bmpblk_util.o: bmpblk_util.c
- $(CC) $(CFLAGS) -c $< -o $@
-
-${BUILD_ROOT}/bmpblk_font.o: bmpblk_font.c
- $(CC) $(CFLAGS) -c $< -o $@
-
-${BUILD_ROOT}/image_types.o: image_types.c
- $(CC) $(CFLAGS) -c $< -o $@
-
-${BUILD_ROOT}/eficompress.o: eficompress.c
- $(CC) $(CFLAGS) -c $< -o $@
-
-${BUILD_ROOT}/eficompress: eficompress.c
- $(CC) $(CFLAGS) -DSTANDALONE $(LDFLAGS) $< -o $@
-
-${BUILD_ROOT}/efidecompress.o: efidecompress.c
- $(CC) $(CFLAGS) -c $< -o $@
-
-${BUILD_ROOT}/efidecompress: efidecompress.c
- $(CC) $(CFLAGS) -DSTANDALONE $(LDFLAGS) $< -o $@
-
-${BUILD_ROOT}/bmpblk_utility: ${BUILD_ROOT}/bmpblk_utility.o \
- ${BUILD_ROOT}/bmpblk_util.o \
- ${BUILD_ROOT}/image_types.o \
- ${BUILD_ROOT}/eficompress.o \
- ${BUILD_ROOT}/efidecompress.o
- $(CXX) $(CFLAGS) $^ -o $@ -llzma -lyaml
-
-${BUILD_ROOT}/bmpblk_font: ${BUILD_ROOT}/bmpblk_font.o \
- ${BUILD_ROOT}/image_types.o
- $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
-
-# TODO: rewrite load_firmware_test to support new wrapper API
-#${BUILD_ROOT}/load_firmware_test: load_firmware_test.c $(LIBS)
-# $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LIBS) $(CRYPTO_LIBS)
-
-${BUILD_ROOT}/load_kernel_test: load_kernel_test.c $(LIBS)
- $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LIBS) $(CRYPTO_LIBS)
-
-${BUILD_ROOT}/pad_digest_utility: pad_digest_utility.c $(LIBS)
- $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LIBS) $(CRYPTO_LIBS)
-
-${BUILD_ROOT}/signature_digest_utility: signature_digest_utility.c $(LIBS)
- $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LIBS) $(CRYPTO_LIBS)
-
-${BUILD_ROOT}/tlcl_generator: tlcl_generator.c
- $(HOSTCC) $(CFLAGS) -fpack-struct $(LDFLAGS) $< -o $@
-
-${BUILD_ROOT}/vbutil_ec: vbutil_ec.c $(LIBS)
- $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LIBS) $(CRYPTO_LIBS)
-
-${BUILD_ROOT}/vbutil_firmware: vbutil_firmware.c $(LIBS)
- $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LIBS) $(CRYPTO_LIBS)
-
-${BUILD_ROOT}/vbutil_kernel: vbutil_kernel.c $(LIBS)
- $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LIBS) $(CRYPTO_LIBS)
-
-${BUILD_ROOT}/vbutil_key: vbutil_key.c $(LIBS)
- $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LIBS) $(CRYPTO_LIBS)
-
-${BUILD_ROOT}/vbutil_keyblock: vbutil_keyblock.c $(LIBS)
- $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LIBS) $(CRYPTO_LIBS)
-
-${BUILD_ROOT}/verify_data: verify_data.c $(LIBS)
- $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LIBS) $(CRYPTO_LIBS)
-
-${BUILD_ROOT}/sign_image: sign_image.c $(LIBS)
- $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LIBS) $(CRYPTO_LIBS)
-
-${BUILD_ROOT}/tpm_init_temp_fix: tpm_init_temp_fix.c $(LIBS)
- $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LIBS)
-
-${BUILD_ROOT}/tpm_set_readsrkpub: tpm_set_readsrkpub.c
- $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ -ltspi
-
-${BUILD_ROOT}/dev_make_keypair: dev_make_keypair
- cp -f $< $@
- chmod +x $@
-
-${BUILD_ROOT}/dev_debug_vboot: dev_debug_vboot
- cp -f $< $@
- chmod +x $@
-
-${BUILD_ROOT}/enable_dev_usb_boot: enable_dev_usb_boot
- cp -f $< $@
- chmod +x $@
-
-${BUILD_ROOT}/vbutil_what_keys: vbutil_what_keys
- cp -f $< $@
- chmod +x $@
-
-${BUILD_ROOT}/tpmc: tpmc.c $(LIBS)
- $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LIBS)
-
-${BUILD_ROOT}/mount-helpers.o: mount-helpers.c mount-helpers.h mount-encrypted.h
- $(CC) -Wall -Werror -O2 -D_FORTIFY_SOURCE=2 -fstack-protector \
- $(shell $(PKG_CONFIG) --cflags glib-2.0 openssl) \
- -c $< -o $@
-
-# The embedded libcrypto includes conflict with the shipped openssl,
-# so this builds without the common CFLAGS (and those includes).
-${BUILD_ROOT}/mount-encrypted: mount-encrypted.c mount-encrypted.h \
- ${BUILD_ROOT}/mount-helpers.o $(LIBS)
- $(CC) -Wall -Werror -O2 -D_FORTIFY_SOURCE=2 -fstack-protector \
- $(shell $(PKG_CONFIG) --cflags glib-2.0 openssl) \
- -I$(FWDIR)/include \
- -I$(HOSTDIR)/include \
- $(LDFLAGS) \
- $< -o $@ \
- ${BUILD_ROOT}/mount-helpers.o $(LIBS) \
- $(shell $(PKG_CONFIG) --libs glib-2.0 openssl) \
- -lm
-
-${BUILD_ROOT}/dev_sign_file: dev_sign_file.c $(LIBS)
- $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LIBS) $(CRYPTO_LIBS)
-
-install: $(TARGET_BINS)
- mkdir -p $(DESTDIR)
- cp -f $(TARGET_BINS) $(DESTDIR)
- chmod a+rx $(patsubst %,$(DESTDIR)/%,$(TARGET_NAMES))
-
-STRUCTURES_TMP=${BUILD}/tlcl_structures.tmp
-STRUCTURES_SRC=${FWDIR}/lib/tpm_lite/include/tlcl_structures.h
-
-update_tlcl_structures: ${BUILD_ROOT}/tlcl_generator
- ${BUILD_ROOT}/tlcl_generator > $(STRUCTURES_TMP)
- cmp -s $(STRUCTURES_TMP) $(STRUCTURES_SRC) || \
- ( echo "%% Updating structures.h %%" && \
- cp $(STRUCTURES_TMP) $(STRUCTURES_SRC) )
-
--include ${ALL_DEPS}