Makefile revision acb2ee977b8dd139b01b68d0e269ea6bcc425c2b
1e8cfa31d548c069d73c304fea522b527fe7c7dd6Randall Spangler# Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 2322536d2f9d30f42218cc9f2ab40574557da8a9Gaurav Shah# Use of this source code is governed by a BSD-style license that can be 3322536d2f9d30f42218cc9f2ab40574557da8a9Gaurav Shah# found in the LICENSE file. 4322536d2f9d30f42218cc9f2ab40574557da8a9Gaurav Shah 50aedbe1950225f8c8f3e535efa9575dc3a9c970dGabe Blackifneq ($(V),1) 60aedbe1950225f8c8f3e535efa9575dc3a9c970dGabe BlackQ := @ 70aedbe1950225f8c8f3e535efa9575dc3a9c970dGabe Blackendif 80aedbe1950225f8c8f3e535efa9575dc3a9c970dGabe Black 96d696e532c6a0c93ad9b915c59dad4144e6f1b33Simon Glass# This Makefile normally builds in a 'build' subdir, but use 106d696e532c6a0c93ad9b915c59dad4144e6f1b33Simon Glass# 116d696e532c6a0c93ad9b915c59dad4144e6f1b33Simon Glass# make BUILD=<dir> 126d696e532c6a0c93ad9b915c59dad4144e6f1b33Simon Glass# 136d696e532c6a0c93ad9b915c59dad4144e6f1b33Simon Glass# to put the output somewhere else 145d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerBUILD ?= $(shell pwd)/build 155d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 165d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Target for 'make install' 175d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerDESTDIR ?= /usr/bin 186d696e532c6a0c93ad9b915c59dad4144e6f1b33Simon Glass 19b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# Provide default CC and CFLAGS for firmware builds; if you have any -D flags, 20b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# please add them after this point (e.g., -DVBOOT_DEBUG). 2174359b755c4a203df0fe3bf51fc53d5de87d1fbfChe-Liang Chiou# 226b0003c6381a7e69818b0b34b358c2cfb1393043Che-Liang Chiou# TODO(crosbug.com/16808) We hard-code u-boot's compiler flags here just 236b0003c6381a7e69818b0b34b358c2cfb1393043Che-Liang Chiou# temporarily. As we are still investigating which flags are necessary for 246b0003c6381a7e69818b0b34b358c2cfb1393043Che-Liang Chiou# maintaining a compatible ABI, etc. between u-boot and vboot_reference. 2574359b755c4a203df0fe3bf51fc53d5de87d1fbfChe-Liang Chiou# 26b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# As a first step, this makes the setting of CC and CFLAGS here optional, to 27b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# permit a calling script or Makefile to set these. 2874359b755c4a203df0fe3bf51fc53d5de87d1fbfChe-Liang Chiou# 29b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# Flag ordering: arch, then -f, then -m, then -W 30b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassDEBUG_FLAGS := $(if ${DEBUG},-g -O0,-Os) 31b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCOMMON_FLAGS := -nostdinc -pipe \ 32b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass -ffreestanding -fno-builtin -fno-stack-protector \ 33b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass -Werror -Wall -Wstrict-prototypes $(DEBUG_FLAGS) 34b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass 357604a7dba239c1f4f1ce2561d3c5aa968dc53d8dChe-Liang Chiouifeq ($(FIRMWARE_ARCH), arm) 36b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCC ?= armv7a-cros-linux-gnueabi-gcc 37b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCFLAGS ?= -march=armv5 \ 38b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass -fno-common -ffixed-r8 \ 39d50b27d15de8cc9e37410fc52d3184f17e0db5bbDoug Anderson -mfloat-abi=hard -marm -mabi=aapcs-linux -mno-thumb-interwork \ 40b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass $(COMMON_FLAGS) 4174359b755c4a203df0fe3bf51fc53d5de87d1fbfChe-Liang Chiouendif 427604a7dba239c1f4f1ce2561d3c5aa968dc53d8dChe-Liang Chiouifeq ($(FIRMWARE_ARCH), i386) 43b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCC ?= i686-pc-linux-gnu-gcc 44b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# Drop -march=i386 to permit use of SSE instructions 45b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCFLAGS ?= \ 46b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass -ffunction-sections -fvisibility=hidden -fno-strict-aliasing \ 47b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass -fomit-frame-pointer -fno-toplevel-reorder -fno-dwarf2-cfi-asm \ 48b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass -mpreferred-stack-boundary=2 -mregparm=3 \ 49b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass $(COMMON_FLAGS) 5034be8273e0fb80a6654deab650e581b0dc9046a4Che-Liang Chiouendif 518e85e987739281161ece1dbc9ff2b73f3e8e1e35Simon Glassifeq ($(FIRMWARE_ARCH), x86_64) 528e85e987739281161ece1dbc9ff2b73f3e8e1e35Simon GlassCFLAGS ?= $(COMMON_FLAGS) \ 538e85e987739281161ece1dbc9ff2b73f3e8e1e35Simon Glass -fvisibility=hidden -fno-strict-aliasing -fomit-frame-pointer 548e85e987739281161ece1dbc9ff2b73f3e8e1e35Simon Glassendif 5534be8273e0fb80a6654deab650e581b0dc9046a4Che-Liang Chiou 56287beaed7f8ceff679c57664d4da008c6234edfdRandall Spangler# Fix compiling directly on host (outside of emake) 57287beaed7f8ceff679c57664d4da008c6234edfdRandall Spanglerifeq ($(ARCH),) 585d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerARCH = amd64 59287beaed7f8ceff679c57664d4da008c6234edfdRandall Spanglerendif 60287beaed7f8ceff679c57664d4da008c6234edfdRandall Spangler 615d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Some things only compile inside the Chromium OS chroot 625d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# TODO: is there a better way to detect this? 635d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerifneq ($(CROS_WORKON_SRCROOT),) 645d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerIN_CHROOT = 1 655d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif 665d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 675d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCC ?= gcc 685d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCXX ?= g++ 695d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerLD = $(CC) 705d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerPKG_CONFIG ?= pkg-config 715d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 7234be8273e0fb80a6654deab650e581b0dc9046a4Che-Liang Chiouifeq ($(FIRMWARE_ARCH),) 73f47291926afce3235421f73811a04324195f3e13Bill RichardsonCFLAGS += -DCHROMEOS_ENVIRONMENT -Wall -Werror 7434be8273e0fb80a6654deab650e581b0dc9046a4Che-Liang Chiouendif 7534be8273e0fb80a6654deab650e581b0dc9046a4Che-Liang Chiou 7634be8273e0fb80a6654deab650e581b0dc9046a4Che-Liang Chiouifneq (${DEBUG},) 7734be8273e0fb80a6654deab650e581b0dc9046a4Che-Liang ChiouCFLAGS += -DVBOOT_DEBUG 78b2b0fcc0f62fadce6f854bf14826a9778c0f7632vbendebendif 790a0e8d0bb26c951a895c5034a4c1c12f3d4e8707Che-Liang Chiou 80b2b0fcc0f62fadce6f854bf14826a9778c0f7632vbendebifeq (${DISABLE_NDEBUG},) 81b2b0fcc0f62fadce6f854bf14826a9778c0f7632vbendebCFLAGS += -DNDEBUG 82b2b0fcc0f62fadce6f854bf14826a9778c0f7632vbendebendif 83b2b0fcc0f62fadce6f854bf14826a9778c0f7632vbendeb 845d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Create / use dependency files 855d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCFLAGS += -MMD -MF $@.d 86b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass 875d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Code coverage 885d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerifneq (${COV},) 895d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler#COV_FLAGS = -O0 -fprofile-arcs -ftest-coverage 905d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCOV_FLAGS = -O0 --coverage 915d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCFLAGS += $(COV_FLAGS) 925d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerLDFLAGS += $(COV_FLAGS) 930a0e8d0bb26c951a895c5034a4c1c12f3d4e8707Che-Liang Chiouendif 94322536d2f9d30f42218cc9f2ab40574557da8a9Gaurav Shah 955d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerINCLUDES += \ 965d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler -Ifirmware/include \ 975d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler -Ifirmware/lib/include \ 985d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler -Ifirmware/lib/cgptlib/include \ 995d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler -Ifirmware/lib/cryptolib/include \ 1005d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler -Ifirmware/lib/tpm_lite/include 1010b8f35c6a56a0e645254dd7f07ca68e01c8ee629Bill Richardson 1020a0e8d0bb26c951a895c5034a4c1c12f3d4e8707Che-Liang Chiouifeq ($(FIRMWARE_ARCH),) 1035d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerINCLUDES += -Ifirmware/stub/include 1040a0e8d0bb26c951a895c5034a4c1c12f3d4e8707Che-Liang Chiouelse 1055d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerINCLUDES += -Ifirmware/arch/$(FIRMWARE_ARCH)/include 1065d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif 1075d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1085d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Output libraries 1095d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCGPTLIB := ${BUILD}/cgpt/libcgpt-cc.a 1105d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerDUMPKERNELCONFIGLIB := ${BUILD}/libdump_kernel_config.a 1115d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerFWLIB := ${BUILD}/vboot_fw.a 1125d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerHOSTLIB := ${BUILD}/vboot_host.a 1135d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerTEST_LIB := ${BUILD}/tests/test.a 1145d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1155d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCRYPTO_LIBS := $(shell $(PKG_CONFIG) --libs libcrypto) 1165d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1175d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerifneq ($(IN_CHROOT),) 1185d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerPC_BASE_VER ?= 125070 1195d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerPC_DEPS = libchrome-$(PC_BASE_VER) 1205d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerPC_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(PC_DEPS)) 1215d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerPC_LDLIBS := $(shell $(PKG_CONFIG) --libs $(PC_DEPS)) 1225d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif 1235d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1245d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Link with hostlib and crypto libs by default 1255d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerLIBS = $(HOSTLIB) 1265d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerLDLIBS = $(CRYPTO_LIBS) 1275d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1285d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Create output directories if necessary. Do this via explicit shell commands 1295d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# so it happens before trying to generate/include dependencies. 1305d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerSUBDIRS := firmware host utility cgpt tests tests/tpm_lite 1315d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler_dir_create := $(foreach d, \ 1325d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(shell find $(SUBDIRS) -name '*.c' -exec dirname {} \; | sort -u), \ 1335d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(shell [ -d $(BUILD)/$(d) ] || mkdir -p $(BUILD)/$(d))) 1345d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1355d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# First target 136acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: all 1375d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerall: fwlib $(if $(FIRMWARE_ARCH),,host_stuff) 1385d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1395d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Host targets 140acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: host_stuff 1415d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerhost_stuff: fwlib hostlib cgpt utils tests 142250549d3e742cddaf72b4f53d5739e54faf5db96Jay Srinivasan 143acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: clean 144322536d2f9d30f42218cc9f2ab40574557da8a9Gaurav Shahclean: 1450aedbe1950225f8c8f3e535efa9575dc3a9c970dGabe Black $(Q)/bin/rm -rf ${BUILD} 146371df8bbbf9088dc1206701bdc2294d9598bb339Bill Richardson 147acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: install 1485d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerinstall: cgpt_install utils_install 1495d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1505d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Coverage 1515d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCOV_INFO = $(BUILD)/coverage.info 1525d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler#coverage: runtests 153acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: coverage 1545d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglercoverage: 1555d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler rm -f $(COV_INFO)* 1565d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler lcov --capture --directory . --base-directory . -o $(COV_INFO).1 1575d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler lcov --remove $(COV_INFO).1 '/usr/*' -o $(COV_INFO) 1585d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler genhtml $(COV_INFO) --output-directory $(BUILD)/coverage 1595d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1605d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Don't delete intermediate object files 1615d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler.SECONDARY: 1625d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1635d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Use second expansion phase for $$(LIBS) so dependencies on libraries are 1645d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# properly evaluated for implicit rules. 1655d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler.SECONDEXPANSION: 1665d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1675d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# ----------------------------------------------------------------------------- 1685d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Firmware library 1695d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1705d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# TPM-specific flags. These depend on the particular TPM we're targeting for. 1715d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# They are needed here only for compiling parts of the firmware code into 1725d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# user-level tests. 1735d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1745d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# TPM_BLOCKING_CONTINUESELFTEST is defined if TPM_ContinueSelfTest blocks until 1755d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# the self test has completed. 1765d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 177acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson$(FWLIB): CFLAGS += -DTPM_BLOCKING_CONTINUESELFTEST 1785d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1795d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# TPM_MANUAL_SELFTEST is defined if the self test must be started manually 1805d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# (with a call to TPM_ContinueSelfTest) instead of starting automatically at 1815d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# power on. 1825d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# 1835d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# We sincerely hope that TPM_BLOCKING_CONTINUESELFTEST and TPM_MANUAL_SELFTEST 1845d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# are not both defined at the same time. (See comment in code.) 1855d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1865d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# CFLAGS += -DTPM_MANUAL_SELFTEST 1875d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1885d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerifeq ($(FIRMWARE_ARCH),i386) 1895d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Unrolling loops in cryptolib makes it faster 190acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson$(FWLIB): CFLAGS += -DUNROLL_LOOPS 1915d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1925d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Workaround for coreboot on x86, which will power off asynchronously 1935d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# without giving us a chance to react. This is not an example of the Right 1945d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Way to do things. See chrome-os-partner:7689, and the commit message 1955d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# that made this change. 196acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson$(FWLIB): CFLAGS += -DSAVE_LOCALE_IMMEDIATELY 1975d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1985d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# On x86 we don't actually read the GBB data into RAM until it is needed. 1995d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Therefore it makes sense to cache it rather than reading it each time. 2005d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Enable this feature. 201acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson$(FWLIB): CFLAGS += -DCOPY_BMP_DATA 2025d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif 2035d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 2045d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerifeq ($(FIRMWARE_ARCH),) 2055d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler$(warning FIRMWARE_ARCH not defined; assuming local compile) 2065d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 2075d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Disable rollback TPM when compiling locally, since otherwise 2085d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# load_kernel_test attempts to talk to the TPM. 209acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson$(FWLIB): CFLAGS += -DDISABLE_ROLLBACK_TPM 2105d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif 2115d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 2125d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# find lib -iname '*.c' | sort 2135d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerFWLIB_SRCS = \ 2145d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cgptlib/cgptlib.c \ 2155d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cgptlib/cgptlib_internal.c \ 2165d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cgptlib/crc32.c \ 2175d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/crc8.c \ 2185d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cryptolib/padding.c \ 2195d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cryptolib/rsa.c \ 2205d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cryptolib/rsa_utility.c \ 2215d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cryptolib/sha1.c \ 2225d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cryptolib/sha256.c \ 2235d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cryptolib/sha512.c \ 2245d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cryptolib/sha_utility.c \ 2255d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/stateful_util.c \ 2265d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/utility.c \ 2275d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/utility_string.c \ 2285d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/vboot_api_init.c \ 2295d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/vboot_api_firmware.c \ 2305d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/vboot_api_kernel.c \ 2315d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/vboot_audio.c \ 2325d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/vboot_common.c \ 2335d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/vboot_display.c \ 2345d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/vboot_firmware.c \ 2355d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/vboot_kernel.c \ 2365d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/vboot_nvstorage.c 2375d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 2385d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerifeq ($(MOCK_TPM),) 2395d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerFWLIB_SRCS += \ 2405d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/rollback_index.c \ 2415d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/tpm_bootmode.c \ 2425d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/tpm_lite/tlcl.c 2435d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerelse 2445d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerFWLIB_SRCS += \ 2455d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/mocked_rollback_index.c \ 2465d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/mocked_tpm_bootmode.c \ 2475d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/tpm_lite/mocked_tlcl.c 2485d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif 2495d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 2505d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerifeq ($(FIRMWARE_ARCH),) 2515d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Include stub into firmware lib if compiling for host 2525d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerFWLIB_SRCS += \ 2535d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/stub/tpm_lite_stub.c \ 2545d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/stub/utility_stub.c \ 2555d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/stub/vboot_api_stub.c \ 2565d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/stub/vboot_api_stub_disk.c 2575d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif 2585d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 2595d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerFWLIB_OBJS = $(FWLIB_SRCS:%.c=${BUILD}/%.o) 2605d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerALL_OBJS += ${FWLIB_OBJS} 2615d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 262acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: fwlib 2635d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerifeq ($(FIRMWARE_ARCH),) 2645d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Link test ensures firmware lib doesn't rely on outside libraries 265acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/firmware/linktest/main: LIBS = $(FWLIB) 2665d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 267acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardsonfwlib: ${BUILD}/firmware/linktest/main 2685d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerelse 269acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardsonfwlib: $(FWLIB) 2705d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif 2715d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 272acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson$(FWLIB): $(FWLIB_OBJS) 2735d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler @printf " RM $(subst $(BUILD)/,,$(@))\n" 2745d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(Q)rm -f $@ 2755d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler @printf " AR $(subst $(BUILD)/,,$(@))\n" 2765d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(Q)ar qc $@ $^ 2775d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 2785d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# ----------------------------------------------------------------------------- 2795d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Host library 2805d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 281acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: hostlib 282acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardsonhostlib: $(HOSTLIB) ${BUILD}/host/linktest/main 2835d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 284acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/host/% ${HOSTLIB}: INCLUDES += \ 2855d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler -Ihost/include\ 2865d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler -Ihost/arch/$(ARCH)/include 2875d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 2885d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerHOSTLIB_SRCS = \ 2895d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/arch/$(ARCH)/lib/crossystem_arch.c \ 2905d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/crossystem.c \ 2915d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/file_keys.c \ 2925d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/fmap.c \ 2935d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/host_common.c \ 2945d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/host_key.c \ 2955d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/host_keyblock.c \ 2965d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/host_misc.c \ 2975d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/host_signature.c \ 2985d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/signature_digest.c 2995d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 3005d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerHOSTLIB_OBJS = $(HOSTLIB_SRCS:%.c=${BUILD}/%.o) 3015d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerALL_OBJS += ${HOSTLIB_OBJS} 3025d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 3035d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# TODO: better way to make .a than duplicating this recipe each time? 304acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson$(HOSTLIB): $(HOSTLIB_OBJS) $(FWLIB_OBJS) 3055d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler @printf " RM $(subst $(BUILD)/,,$(@))\n" 3065d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(Q)rm -f $@ 3075d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler @printf " AR $(subst $(BUILD)/,,$(@))\n" 3085d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(Q)ar qc $@ $^ 3095d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 3105d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# ----------------------------------------------------------------------------- 3115d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# CGPT library and utility 3125d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 3135d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCGPT = ${BUILD}/cgpt/cgpt 3145d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 3155d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCGPT_SRCS = \ 3165d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt.c \ 3175d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_add.c \ 3185d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_boot.c \ 3195d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_common.c \ 3205d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_create.c \ 3215d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_find.c \ 3225d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_legacy.c \ 3235d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_prioritize.c \ 3245d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_repair.c \ 3255d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_show.c \ 3265d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cmd_add.c \ 3275d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cmd_boot.c \ 3285d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cmd_create.c \ 3295d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cmd_find.c \ 3305d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cmd_legacy.c \ 3315d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cmd_prioritize.c \ 3325d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cmd_repair.c \ 3335d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cmd_show.c 3345d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 3355d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCGPT_OBJS = $(CGPT_SRCS:%.c=${BUILD}/%.o) 3365d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerALL_OBJS += ${CGPT_OBJS} 3375d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 3385d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# TODO: why not make this include *all* the cgpt files, and simply have 3395d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# cgpt link against it? 3405d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# TODO: CgptManager.cc should move to the installer project. Shouldn't be 3415d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# in libcgpt-cc.a. 3425d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCGPTLIB_SRCS = \ 3435d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/CgptManager.cc \ 3445d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_create.c \ 3455d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_add.c \ 3465d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_boot.c \ 3475d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_show.c \ 3485d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_repair.c \ 3495d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_prioritize.c \ 3505d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_common.c \ 3515d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cgptlib/crc32.c \ 3525d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cgptlib/cgptlib_internal.c \ 3535d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/stub/utility_stub.c 3545d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 3555d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCGPTLIB_OBJS = $(filter %.o, \ 3565d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(CGPTLIB_SRCS:%.c=${BUILD}/%.o) \ 3575d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(CGPTLIB_SRCS:%.cc=${BUILD}/%.o)) 3585d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerALL_OBJS += $(CGPTLIB_OBJS) 3595d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 3605d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler.PHONY: cgpt 361acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardsoncgpt: $(CGPT) 3625d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 363acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: libcgpt_cc 364acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardsonlibcgpt_cc: $(CGPTLIB) 3655d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 366acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson$(CGPTLIB): INCLUDES += -Ifirmware/lib/cgptlib/include 367acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson$(CGPTLIB): $(CGPTLIB_OBJS) 3685d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler @printf " RM $(subst $(BUILD)/,,$(@))\n" 3695d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(Q)rm -f $@ 3705d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler @printf " AR $(subst $(BUILD)/,,$(@))\n" 3715d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(Q)ar qc $@ $^ 3725d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 373acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson$(CGPT): INCLUDES += -Ifirmware/lib/cgptlib/include 374acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson$(CGPT): LDLIBS = -luuid 375acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson$(CGPT): LDFLAGS += -static 376acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson$(CGPT): $(CGPT_OBJS) $$(LIBS) 3775d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler @printf " LDcgpt $(subst $(BUILD)/,,$(@))\n" 3785d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(Q)$(LD) -o $(CGPT) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) $(LDLIBS) 3795d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 380acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: cgpt_install 3815d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglercgpt_install: $(CGPT) 3825d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler mkdir -p $(DESTDIR) 3835d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cp -f $^ $(DESTDIR) 3845d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler chmod a+rx $(patsubst ${BUILD}/cgpt/%,$(DESTDIR)/%,$^) 3855d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 3865d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# ----------------------------------------------------------------------------- 3875d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Utilities 3885d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 389acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/utility/%: INCLUDES += -Ihost/include -Iutility/include 390acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/utility/%: CFLAGS += $(PC_CFLAGS) 3915d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 3925d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerAU_NAMES = \ 3935d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler crossystem \ 3945d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler dump_fmap \ 3955d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler gbb_utility 396acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill RichardsonAU_BINS:= $(addprefix ${BUILD}/utility/,$(AU_NAMES)) 3975d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 3985d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Utilities for auto-update toolkits must be statically linked, and don't 3995d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# use the crypto libs. 400acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${AU_BINS}: LDFLAGS += -static 401acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${AU_BINS}: CRYPTO_LIBS = 4025d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 4035d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Scripts to install 4045d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerUTIL_SCRIPTS = \ 4055d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler utility/dev_debug_vboot \ 4065d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler utility/dev_make_keypair \ 4075d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler utility/enable_dev_usb_boot \ 4085d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler utility/vbutil_what_keys 4095d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 4105d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerUTIL_NAMES = $(AU_NAMES) \ 4115d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler dev_sign_file \ 4125d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler dump_kernel_config \ 4135d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler dumpRSAPublicKey \ 4145d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler load_kernel_test \ 4155d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler pad_digest_utility \ 4165d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler signature_digest_utility \ 4175d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tpm_init_temp_fix \ 4185d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tpmc \ 4195d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler vbutil_ec \ 4205d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler vbutil_firmware \ 4215d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler vbutil_kernel \ 4225d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler vbutil_key \ 4235d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler vbutil_keyblock \ 4245d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler verify_data 4255d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 4265d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerifneq ($(IN_CHROOT),) 4275d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerUTIL_NAMES += mount-encrypted 4285d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif 4295d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 4305d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerifeq ($(MINIMAL),) 4315d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerUTIL_NAMES += \ 4325d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler bmpblk_font \ 4335d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler bmpblk_utility \ 4345d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler eficompress \ 4355d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler efidecompress 4365d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif 4375d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 4385d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerUTIL_BINS = $(addprefix ${BUILD}/utility/,$(UTIL_NAMES)) 4395d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerALL_DEPS += $(addsuffix .d,${UTIL_BINS}) 4405d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 441acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: utils 442acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardsonutils: $(UTIL_BINS) $(UTIL_SCRIPTS) 4435d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# TODO: change ebuild to pull scripts directly out of utility dir 4445d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(Q)cp -f $(UTIL_SCRIPTS) $(BUILD)/utility 4455d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(Q)chmod a+rx $(patsubst %,$(BUILD)/%,$(UTIL_SCRIPTS)) 4465d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 447acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: utils_install 448acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardsonutils_install: $(UTIL_BINS) $(UTIL_SCRIPTS) 4495d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler mkdir -p $(DESTDIR) 4505d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cp -f $(UTIL_BINS) $(DESTDIR) 4515d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler chmod a+rx $(patsubst %,$(DESTDIR)/%,$(UTIL_NAMES)) 4525d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cp -f $(UTIL_SCRIPTS) $(DESTDIR) 4535d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler chmod a+rx $(patsubst utility/%,$(DESTDIR)/%,$(UTIL_SCRIPTS)) 4545d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 455acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/utility/dump_kernel_config: LIBS += $(DUMPKERNELCONFIGLIB) 4565d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 4575d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# GBB utility needs C++ linker 458acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/utility/gbb_utility: LD = $(CXX) 4595d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 460acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/utility/bmpblk_utility: LD = $(CXX) 461acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/utility/bmpblk_utility: LDLIBS = -llzma -lyaml 462acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/utility/bmpblk_utility: OBJS = \ 4635d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ${BUILD}/utility/bmpblk_util.o \ 4645d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ${BUILD}/utility/image_types.o \ 46517f8d341099120da78a6ca71165834eefb0960edRandall Spangler ${BUILD}/utility/eficompress_for_lib.o \ 46617f8d341099120da78a6ca71165834eefb0960edRandall Spangler ${BUILD}/utility/efidecompress_for_lib.o 4675d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 4685d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler${BUILD}/utility/bmpblk_font: OBJS += ${BUILD}/utility/image_types.o 4695d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 4705d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# TODO: fix load_firmware_test util; it never got refactored for the new APIs 4715d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 4725d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# ----------------------------------------------------------------------------- 4735d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Mount-encrypted utility for cryptohome 4745d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 4755d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# TODO: mount-encrypted should move to cryptohome and just link against 4765d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# vboot-host.a for tlcl and crossystem. 4775d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 4785d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# The embedded libcrypto conflicts with the shipped openssl, 4795d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# so mount-* builds without the common CFLAGS (and those includes). 4805d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 4815d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler${BUILD}/utility/mount-helpers.o: \ 4825d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler utility/mount-helpers.c \ 4835d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler utility/mount-helpers.h \ 4845d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler utility/mount-encrypted.h 4855d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler @printf " CCm-e $(subst $(BUILD)/,,$(@))\n" 4865d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(Q)$(CC) -Wall -Werror -O2 -D_FORTIFY_SOURCE=2 -fstack-protector \ 4875d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(COV_FLAGS) \ 4885d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(shell $(PKG_CONFIG) --cflags glib-2.0 openssl) \ 4895d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler -c $< -o $@ 4905d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 4915d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler${BUILD}/utility/mount-encrypted: \ 4925d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler utility/mount-encrypted.c \ 4935d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler utility/mount-encrypted.h \ 4945d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ${BUILD}/utility/mount-helpers.o $$(LIBS) 4955d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler @printf " CCm-exe $(subst $(BUILD)/,,$(@))\n" 4965d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(Q)$(CC) -Wall -Werror -O2 -D_FORTIFY_SOURCE=2 -fstack-protector \ 4975d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(shell $(PKG_CONFIG) --cflags glib-2.0 openssl) \ 4985d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler -Ifirmware/include \ 4995d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler -Ihost/include \ 5005d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(COV_FLAGS) \ 5015d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(LDFLAGS) \ 5025d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $< -o $@ \ 5035d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ${BUILD}/utility/mount-helpers.o $(LIBS) \ 5045d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(shell $(PKG_CONFIG) --libs glib-2.0 openssl) \ 5055d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler -lm 5065d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerifneq (${COV},) 5075d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(Q)mv -f mount-encrypted.gcno ${BUILD}/utility 5085d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif 5095d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 5105d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# ----------------------------------------------------------------------------- 5115d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Utility to generate TLCL structure definition header file. 5125d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 513acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/utility/tlcl_generator: CFLAGS += -fpack-struct 514acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/utility/tlcl_generator: LIBS = 5155d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 5165d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerSTRUCTURES_TMP=${BUILD}/tlcl_structures.tmp 5175d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerSTRUCTURES_SRC=firmware/lib/tpm_lite/include/tlcl_structures.h 5185d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 519acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: update_tlcl_structures 5205d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerupdate_tlcl_structures: ${BUILD}/utility/tlcl_generator 5215d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler @printf " Rebuilding TLCL structures\n" 5225d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(Q)${BUILD}/utility/tlcl_generator > $(STRUCTURES_TMP) 5235d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(Q)cmp -s $(STRUCTURES_TMP) $(STRUCTURES_SRC) || \ 5245d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ( echo "%% Updating structures.h %%" && \ 5255d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cp $(STRUCTURES_TMP) $(STRUCTURES_SRC) ) 5265d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 5275d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# ----------------------------------------------------------------------------- 5285d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Library to dump kernel config 52917f8d341099120da78a6ca71165834eefb0960edRandall Spangler# Used by platform/installer 5305d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 531acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: libdump_kernel_config 5325d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerlibdump_kernel_config: $(DUMPKERNELCONFIGLIB) 5335d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 534acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson$(DUMPKERNELCONFIGLIB): ${BUILD}/utility/dump_kernel_config_lib.o 5355d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler @printf " RM $(subst $(BUILD)/,,$(@))\n" 5365d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(Q)rm -f $@ 5375d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler @printf " AR $(subst $(BUILD)/,,$(@))\n" 5385d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(Q)ar qc $@ $^ 5395d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 5405d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# ----------------------------------------------------------------------------- 5415d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Tests 5425d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 5435d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Allow multiple definitions, so tests can mock functions from other libraries 544acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/tests/%: CFLAGS += -Xlinker --allow-multiple-definition 545acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/tests/%: INCLUDES += -Ihost/include 546acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/tests/%: LDLIBS += -lrt -luuid 547acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/tests/%: LIBS += $(TEST_LIB) 5485d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 5495d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerTEST_NAMES = \ 5505d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgptlib_test \ 5515d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler rollback_index2_tests \ 5525d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler rsa_padding_test \ 5535d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler rsa_utility_tests \ 5545d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler rsa_verify_benchmark \ 5555d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler sha_benchmark \ 5565d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler sha_tests \ 5575d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler stateful_util_tests \ 5585d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tpm_bootmode_tests \ 5595d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler utility_string_tests \ 5605d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler utility_tests \ 5615d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler vboot_nvstorage_test \ 5625d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler vboot_api_init_tests \ 5635d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler vboot_api_devmode_tests \ 5645d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler vboot_api_firmware_tests \ 5655d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler vboot_api_kernel_tests \ 5665d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler vboot_audio_tests \ 5675d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler vboot_common_tests \ 5685d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler vboot_common2_tests \ 5695d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler vboot_common3_tests \ 5705d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler vboot_ec_tests \ 5715d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler vboot_firmware_tests 5725d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 5735d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerifneq ($(IN_CHROOT),) 5745d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerTEST_NAMES += CgptManagerTests 5755d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif 5765d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 5775d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerTLCL_TEST_NAMES = \ 57817f8d341099120da78a6ca71165834eefb0960edRandall Spangler tpmtest_earlyextend \ 57917f8d341099120da78a6ca71165834eefb0960edRandall Spangler tpmtest_earlynvram \ 58017f8d341099120da78a6ca71165834eefb0960edRandall Spangler tpmtest_earlynvram2 \ 58117f8d341099120da78a6ca71165834eefb0960edRandall Spangler tpmtest_enable \ 58217f8d341099120da78a6ca71165834eefb0960edRandall Spangler tpmtest_fastenable \ 58317f8d341099120da78a6ca71165834eefb0960edRandall Spangler tpmtest_globallock \ 58417f8d341099120da78a6ca71165834eefb0960edRandall Spangler tpmtest_redefine_unowned \ 58517f8d341099120da78a6ca71165834eefb0960edRandall Spangler tpmtest_spaceperm \ 58617f8d341099120da78a6ca71165834eefb0960edRandall Spangler tpmtest_testsetup \ 58717f8d341099120da78a6ca71165834eefb0960edRandall Spangler tpmtest_timing \ 58817f8d341099120da78a6ca71165834eefb0960edRandall Spangler tpmtest_writelimit 58917f8d341099120da78a6ca71165834eefb0960edRandall SpanglerTEST_NAMES += $(addprefix tpm_lite/,$(TLCL_TEST_NAMES)) 5905d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 5915d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerTEST_BINS = $(addprefix ${BUILD}/tests/,$(TEST_NAMES)) 5925d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerALL_DEPS += $(addsuffix .d,${TEST_BINS}) 5935d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 59417f8d341099120da78a6ca71165834eefb0960edRandall Spangler.PHONY: tests 595acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardsontests: $(TEST_BINS) 5965d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 5975d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler${TEST_LIB}: \ 5985d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ${BUILD}/tests/test_common.o \ 5995d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ${BUILD}/tests/timer_utils.o \ 6005d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ${BUILD}/tests/crc32_test.o 6015d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler @printf " RM $(subst $(BUILD)/,,$(@))\n" 6025d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(Q)rm -f $@ 6035d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler @printf " AR $(subst $(BUILD)/,,$(@))\n" 6045d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(Q)ar qc $@ $^ 6055d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 6065d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler${BUILD}/tests/rollback_index2_tests: OBJS += \ 60717f8d341099120da78a6ca71165834eefb0960edRandall Spangler ${BUILD}/firmware/lib/rollback_index_for_test.o 6085d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 6095d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler${BUILD}/tests/vboot_audio_tests: OBJS += \ 61017f8d341099120da78a6ca71165834eefb0960edRandall Spangler ${BUILD}/firmware/lib/vboot_audio_for_test.o 6115d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 612acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: cgptmanager_tests 6135d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglercgptmanager_tests: ${BUILD}/tests/CgptManagerTests 6145d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 615acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/tests/CgptManagerTests: CFLAGS += $(PC_CFLAGS) 616acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/tests/CgptManagerTests: LD = $(CXX) 617acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/tests/CgptManagerTests: LDLIBS += -lgtest -lgflags $(PC_LDLIBS) 618acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/tests/CgptManagerTests: LIBS = $(CGPTLIB) 6195d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 620acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/tests/rollback_index_test: INCLUDES += -I/usr/include 621acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/tests/rollback_index_test: LIBS += -ltlcl 6225d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 623acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/tests/tpm_lite/tpmtest_%: OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o 6245d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 6255d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# TODO: port these tests to new API, if not already eqivalent 6265d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# functionality in other tests. These don't even compile at present. 6275d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# 6285d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# big_firmware_tests 6295d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# big_kernel_tests 6305d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# firmware_image_tests 6315d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# firmware_rollback_tests 6325d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# firmware_splicing_tests 6335d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# firmware_verify_benchmark 6345d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# kernel_image_tests 6355d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# kernel_rollback_tests 6365d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# kernel_splicing_tests 6375d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# kernel_verify_benchmark 6385d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# rollback_index_test 6395d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# verify_firmware_fuzz_driver 6405d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# verify_kernel_fuzz_driver 6415d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 6425d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# ----------------------------------------------------------------------------- 6435d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Targets to run tests 6445d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 6455d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Frequently-run tests 646acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runtests 647acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardsonruntests: runbmptests runcgpttests runfuzztests runmisctests 6485d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 6495d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Generate test keys 650acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: genkeys 6515d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglergenkeys: 6525d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/gen_test_keys.sh 6535d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 6545d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Generate test cases for fuzzing 655acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: genfuzztestcases 6565d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglergenfuzztestcases: 6575d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/gen_fuzz_test_cases.sh 6585d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 659acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runbmptests 6605d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerrunbmptests: utils 6615d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cd tests/bitmaps && BMPBLK=${BUILD}/utility/bmpblk_utility \ 6625d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ./TestBmpBlock.py -v 6635d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 664acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runcgpttests 665acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardsonruncgpttests: cgpt tests 6665d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ${BUILD}/tests/cgptlib_test 6675d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/run_cgpt_tests.sh ${BUILD}/cgpt/cgpt 6685d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerifneq ($(IN_CHROOT),) 6695d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ${BUILD}/tests/CgptManagerTests --v=1 6705d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif 6715d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 6725d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Exercise vbutil_kernel and vbutil_firmware 673acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runfuzztests 6745d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerrunfuzztests: genfuzztestcases utils tests 6755d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/run_preamble_tests.sh 6765d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/run_vbutil_kernel_arg_tests.sh 6775d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 678acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runmisctests 679acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardsonrunmisctests: tests utils 6805d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ${BUILD}/tests/rollback_index2_tests 6815d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ${BUILD}/tests/rsa_utility_tests 6825d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ${BUILD}/tests/sha_tests 6835d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ${BUILD}/tests/stateful_util_tests 6845d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ${BUILD}/tests/tpm_bootmode_tests 6855d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ${BUILD}/tests/utility_string_tests 6865d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ${BUILD}/tests/utility_tests 6875d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ${BUILD}/tests/vboot_api_devmode_tests 6885d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ${BUILD}/tests/vboot_api_init_tests 6895d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ${BUILD}/tests/vboot_api_firmware_tests 6905d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ${BUILD}/tests/vboot_audio_tests 6915d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ${BUILD}/tests/vboot_firmware_tests 6925d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/run_rsa_tests.sh 6935d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/run_vboot_common_tests.sh 6945d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/run_vbutil_tests.sh 6955d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 6965d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Run long tests, including all permutations of encryption keys (instead of 6975d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# just the ones we use) and tests of currently-unused code (e.g. vboot_ec). 6985d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Not run by automated build. 699acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runlongtests 700acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardsonrunlongtests: genkeys genfuzztestcases tests utils 7015d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/run_preamble_tests.sh --all 7025d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/run_vboot_common_tests.sh --all 7035d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/run_vboot_ec_tests.sh 7045d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/run_vbutil_tests.sh --all 7055d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 7065d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# TODO: tests to run when ported to new API 7075d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# ./run_image_verification_tests.sh 7085d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# # Splicing tests 7095d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# ${BUILD}/tests/firmware_splicing_tests 7105d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# ${BUILD}/tests/kernel_splicing_tests 7115d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# # Rollback Tests 7125d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# ${BUILD}/tests/firmware_rollback_tests 7135d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# ${BUILD}/tests/kernel_rollback_tests 7145d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 7155d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# ----------------------------------------------------------------------------- 7165d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Build rules 7175d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 718acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/%: ${BUILD}/%.o $$(OBJS) $$(LIBS) 7195d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler @printf " LD $(subst $(BUILD)/,,$(@))\n" 7205d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(Q)$(LD) $(CFLAGS) $(INCLUDES) $(LDFLAGS) $< $(OBJS) -o $@ \ 7215d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(LIBS) $(LDLIBS) 7225d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 723acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/%.o: %.c 7245d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler @printf " CC $(subst $(BUILD)/,,$(@))\n" 7255d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(Q)$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $< 726e642198b93cf2c50e279a6598f21f69564b13c6fGaurav Shah 72717f8d341099120da78a6ca71165834eefb0960edRandall Spangler# Rules to recompile a single source file for library and test 72817f8d341099120da78a6ca71165834eefb0960edRandall Spangler# TODO: is there a tidier way to do this? 729acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/%_for_lib.o: CFLAGS += -DFOR_LIBRARY 730acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/%_for_lib.o: %.c 73117f8d341099120da78a6ca71165834eefb0960edRandall Spangler @printf " CC-for-lib $(subst $(BUILD)/,,$(@))\n" 73217f8d341099120da78a6ca71165834eefb0960edRandall Spangler $(Q)$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $< 733acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/%_for_test.o: CFLAGS += -DFOR_TEST 734acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/%_for_test.o: %.c 73517f8d341099120da78a6ca71165834eefb0960edRandall Spangler @printf " CC-for-test $(subst $(BUILD)/,,$(@))\n" 73617f8d341099120da78a6ca71165834eefb0960edRandall Spangler $(Q)$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $< 73717f8d341099120da78a6ca71165834eefb0960edRandall Spangler 73817f8d341099120da78a6ca71165834eefb0960edRandall Spangler# TODO: C++ files don't belong in vboot reference at all. Convert to C. 739acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/%.o: %.cc 7405d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler @printf " CXX $(subst $(BUILD)/,,$(@))\n" 7415d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler $(Q)$(CXX) $(CFLAGS) $(INCLUDES) -c -o $@ $< 74218b814d9bc7fcf0a7e5d7fca57eed8229f0e9aacLuigi Semenzato 7435d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# ----------------------------------------------------------------------------- 7445d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Dependencies must come last after ALL_OBJS has been accumulated 745e8cfa31d548c069d73c304fea522b527fe7c7dd6Randall Spangler 7465d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# TODO: I suspect this is missing some object files. Make a temp 7475d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# target which cleans all known obj/exe's and see what's left; those 7485d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# are the files which need deps. 749250549d3e742cddaf72b4f53d5739e54faf5db96Jay Srinivasan 7505d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerALL_DEPS += $(ALL_OBJS:%.o=%.o.d) 751856e072e8119cab07fd884e54853f1c3897452eeBill Richardson 7525d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler-include ${ALL_DEPS} 753