blob: 1a712e1af2d7691586c504a0d4bbd729b760f080 [file] [log] [blame]
Bill Richardson6f396152014-07-15 12:52:19 -07001# Copyright 2013 The Chromium OS Authors. All rights reserved.
Gaurav Shah322536d2010-01-28 15:01:23 -08002# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
Simon Glass6d696e52011-11-14 13:46:33 -08005# This Makefile normally builds in a 'build' subdir, but use
6#
7# make BUILD=<dir>
8#
Bill Richardsoneecc18f2013-01-17 15:28:17 -08009# to put the output somewhere else.
10
11##############################################################################
12# Make variables come in two flavors, immediate or deferred.
13#
14# Variable definitions are parsed like this:
15#
16# IMMEDIATE = DEFERRED
17# or
18# IMMEDIATE := IMMEDIATE
19#
20# Rules are parsed this way:
21#
22# IMMEDIATE : IMMEDIATE
23# DEFERRED
24#
25# So you can assign variables in any order if they're only to be used in
26# actions, but if you use a variable in either the target or prerequisite of a
27# rule, the rule will be constructed using only the top-down, immediate value.
28#
29# So we'll try to define all the variables first. Then the rules.
30#
31
32##############################################################################
33# Configuration variables come first.
34#
35# Our convention is that we only use := for variables that will never be
36# changed or appended. They must be defined before being used anywhere.
37
Bill Richardsonc9bf3482013-02-13 14:38:29 -080038# We should only run pwd once, not every time we refer to ${BUILD}.
Randall Spanglere061a252013-01-22 15:34:07 -080039SRCDIR := $(shell pwd)
Bill Richardson64ddad72014-08-29 23:49:23 -070040export SRCDIR
Mike Frysingerc8c87b32015-01-15 17:04:40 -050041BUILD = ${SRCDIR}/build
Randall Spangler844bce52013-01-15 16:16:43 -080042export BUILD
Simon Glass6d696e52011-11-14 13:46:33 -080043
Bill Richardsonc9bf3482013-02-13 14:38:29 -080044# Stuff for 'make install'
Bill Richardsonfeb25182013-03-07 12:54:29 -080045INSTALL = install
Bill Richardsonefa87562014-09-11 10:41:51 -070046DESTDIR = /usr/local
Nam T. Nguyen07d90432015-02-17 13:26:44 -080047LIBDIR ?= lib
Bill Richardsonc9bf3482013-02-13 14:38:29 -080048
Bill Richardsoncfe83a82014-12-04 11:29:57 -080049# Default values
50DEV_DEBUG_FORCE=
51
Bill Richardsonfeb25182013-03-07 12:54:29 -080052# Where exactly do the pieces go?
Bill Richardson6f396152014-07-15 12:52:19 -070053# UB_DIR = utility binary directory
Nam T. Nguyen07d90432015-02-17 13:26:44 -080054# ULP_DIR = pkgconfig directory, usually /usr/lib/pkgconfig
Bill Richardsoncfe83a82014-12-04 11:29:57 -080055# DF_DIR = utility defaults directory
Bill Richardson6f396152014-07-15 12:52:19 -070056# VB_DIR = vboot binary directory for dev-mode-only scripts
Bill Richardsonc9bf3482013-02-13 14:38:29 -080057ifeq (${MINIMAL},)
Bill Richardson6f396152014-07-15 12:52:19 -070058# Host install just puts everything where it's told
Bill Richardsonefa87562014-09-11 10:41:51 -070059UB_DIR=${DESTDIR}/bin
Nam T. Nguyen07d90432015-02-17 13:26:44 -080060ULP_DIR=${DESTDIR}/${LIBDIR}/pkgconfig
Bill Richardsoncfe83a82014-12-04 11:29:57 -080061DF_DIR=${DESTDIR}/default
Bill Richardsonefa87562014-09-11 10:41:51 -070062VB_DIR=${DESTDIR}/bin
Bill Richardsonc9bf3482013-02-13 14:38:29 -080063else
Bill Richardsonefa87562014-09-11 10:41:51 -070064# Target install puts things into different places
Bill Richardson6f396152014-07-15 12:52:19 -070065UB_DIR=${DESTDIR}/usr/bin
Nam T. Nguyen07d90432015-02-17 13:26:44 -080066ULP_DIR=${DESTDIR}/usr/${LIBDIR}/pkgconfig
Bill Richardsoncfe83a82014-12-04 11:29:57 -080067DF_DIR=${DESTDIR}/etc/default
Bill Richardsonc9bf3482013-02-13 14:38:29 -080068VB_DIR=${DESTDIR}/usr/share/vboot/bin
69endif
Randall Spangler5d9bbf22013-01-08 10:44:23 -080070
Bill Richardsoneecc18f2013-01-17 15:28:17 -080071# Where to install the (exportable) executables for testing?
72TEST_INSTALL_DIR = ${BUILD}/install_for_test
73
74# Verbose? Use V=1
75ifeq (${V},)
76Q := @
77endif
78
Simon Glass661ae9e2013-03-26 11:39:21 -070079# Quiet? Use QUIET=1
Mike Frysingerc8c87b32015-01-15 17:04:40 -050080ifeq (${QUIET},)
Simon Glass661ae9e2013-03-26 11:39:21 -070081PRINTF := printf
82else
83PRINTF := :
84endif
85
Randall Spangler61a2eb32013-01-23 10:20:16 -080086# Architecture detection
87_machname := $(shell uname -m)
88HOST_ARCH ?= ${_machname}
89
90# ARCH and/or FIRMWARE_ARCH are defined by the Chromium OS ebuild.
91# Pick a sane target architecture if none is defined.
92ifeq (${ARCH},)
93 ARCH := ${HOST_ARCH}
94else ifeq (${ARCH},i386)
95 override ARCH := x86
96else ifeq (${ARCH},amd64)
97 override ARCH := x86_64
98endif
99
100# FIRMWARE_ARCH is only defined by the Chromium OS ebuild if compiling
101# for a firmware target (such as u-boot or depthcharge). It must map
102# to the same consistent set of architectures as the host.
103ifeq (${FIRMWARE_ARCH},i386)
104 override FIRMWARE_ARCH := x86
105else ifeq (${FIRMWARE_ARCH},amd64)
106 override FIRMWARE_ARCH := x86_64
Stefan Reinauerd96b25d2013-09-19 14:24:29 -0700107else ifeq (${FIRMWARE_ARCH},armv7)
108 override FIRMWARE_ARCH := arm
Randall Spangler61a2eb32013-01-23 10:20:16 -0800109endif
110
Simon Glassb265c342011-11-16 15:09:51 -0800111# Provide default CC and CFLAGS for firmware builds; if you have any -D flags,
112# please add them after this point (e.g., -DVBOOT_DEBUG).
Che-Liang Chiou74359b72011-06-21 15:25:51 -0700113#
Che-Liang Chiou6b0003c2011-10-14 11:11:28 +0800114# TODO(crosbug.com/16808) We hard-code u-boot's compiler flags here just
115# temporarily. As we are still investigating which flags are necessary for
116# maintaining a compatible ABI, etc. between u-boot and vboot_reference.
Che-Liang Chiou74359b72011-06-21 15:25:51 -0700117#
Simon Glassb265c342011-11-16 15:09:51 -0800118# As a first step, this makes the setting of CC and CFLAGS here optional, to
119# permit a calling script or Makefile to set these.
Che-Liang Chiou74359b72011-06-21 15:25:51 -0700120#
Simon Glassb265c342011-11-16 15:09:51 -0800121# Flag ordering: arch, then -f, then -m, then -W
122DEBUG_FLAGS := $(if ${DEBUG},-g -O0,-Os)
123COMMON_FLAGS := -nostdinc -pipe \
124 -ffreestanding -fno-builtin -fno-stack-protector \
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800125 -Werror -Wall -Wstrict-prototypes ${DEBUG_FLAGS}
Simon Glassb265c342011-11-16 15:09:51 -0800126
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800127# Note: FIRMWARE_ARCH is defined by the Chromium OS ebuild.
128ifeq (${FIRMWARE_ARCH}, arm)
Simon Glassb265c342011-11-16 15:09:51 -0800129CC ?= armv7a-cros-linux-gnueabi-gcc
130CFLAGS ?= -march=armv5 \
131 -fno-common -ffixed-r8 \
Doug Andersond50b27d2012-05-11 12:08:02 -0700132 -mfloat-abi=hard -marm -mabi=aapcs-linux -mno-thumb-interwork \
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800133 ${COMMON_FLAGS}
Randall Spangler61a2eb32013-01-23 10:20:16 -0800134else ifeq (${FIRMWARE_ARCH}, x86)
Simon Glassb265c342011-11-16 15:09:51 -0800135CC ?= i686-pc-linux-gnu-gcc
136# Drop -march=i386 to permit use of SSE instructions
137CFLAGS ?= \
138 -ffunction-sections -fvisibility=hidden -fno-strict-aliasing \
139 -fomit-frame-pointer -fno-toplevel-reorder -fno-dwarf2-cfi-asm \
Gabe Black46e00e62013-12-18 18:23:24 -0800140 -mpreferred-stack-boundary=2 \
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800141 ${COMMON_FLAGS}
142else ifeq (${FIRMWARE_ARCH}, x86_64)
143CFLAGS ?= ${COMMON_FLAGS} \
Simon Glass8e85e982011-11-22 13:54:50 -0800144 -fvisibility=hidden -fno-strict-aliasing -fomit-frame-pointer
Randall Spangler844bce52013-01-15 16:16:43 -0800145else
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800146# FIRMWARE_ARCH not defined; assuming local compile.
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800147CC ?= gcc
Bill Richardsond4621012014-07-09 23:31:13 -0700148CFLAGS += -DCHROMEOS_ENVIRONMENT -Wall -Werror ${DEBUG_FLAGS}
Che-Liang Chiou34be8272011-01-27 16:44:36 +0800149endif
150
151ifneq (${DEBUG},)
152CFLAGS += -DVBOOT_DEBUG
vbendebb2b0fcc2010-07-15 15:09:47 -0700153endif
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +0800154
vbendebb2b0fcc2010-07-15 15:09:47 -0700155ifeq (${DISABLE_NDEBUG},)
156CFLAGS += -DNDEBUG
157endif
158
Bill Richardsonfeb25182013-03-07 12:54:29 -0800159ifneq (${FORCE_LOGGING_ON},)
160CFLAGS += -DFORCE_LOGGING_ON=${FORCE_LOGGING_ON}
161endif
162
Randall Spangler6014c042014-07-22 14:42:58 -0700163ifneq (${PD_SYNC},)
164CFLAGS += -DPD_SYNC
165endif
166
Nam T. Nguyenf44ebbe2015-02-12 11:10:35 -0800167ifneq (${USE_MTD},)
168CFLAGS += -DUSE_MTD
169LDLIBS += -lmtdutils
170endif
171
Nam T. Nguyen07d90432015-02-17 13:26:44 -0800172# NOTE: We don't use these files but they are useful for other packages to
173# query about required compiling/linking flags.
174PC_IN_FILES = vboot_host.pc.in
175
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800176# Create / use dependency files
177CFLAGS += -MMD -MF $@.d
Simon Glassb265c342011-11-16 15:09:51 -0800178
Bertrand SIMONNETf8f807a2014-06-30 09:41:13 -0700179ifeq (${FIRMWARE_ARCH},)
180# Creates position independent code for non firmware target.
181CFLAGS += -fPIE
182endif
183
Bill Richardson0c3ba242013-03-29 11:09:30 -0700184# These are required to access large disks and files on 32-bit systems.
185CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
186
Randall Spangler59d75082013-01-23 09:29:54 -0800187# Code coverage
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800188ifneq (${COV},)
Bill Richardsond2d08b22014-07-08 16:31:40 -0700189 COV_FLAGS = -O0 --coverage -DCOVERAGE
Randall Spangler59d75082013-01-23 09:29:54 -0800190 CFLAGS += ${COV_FLAGS}
191 LDFLAGS += ${COV_FLAGS}
192 COV_INFO = ${BUILD}/coverage.info
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +0800193endif
Gaurav Shah322536d2010-01-28 15:01:23 -0800194
David Riley05987b12015-02-05 19:22:49 -0800195ifdef HAVE_MACOS
196 CFLAGS += -DHAVE_MACOS -Wno-deprecated-declarations
197endif
198
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800199# And a few more default utilities
200LD = ${CC}
Bill Richardson6df3e332014-10-02 18:50:33 -0700201CXX ?= g++
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800202PKG_CONFIG ?= pkg-config
203
Mike Frysinger0b789c52015-01-15 15:37:59 -0500204# Static?
205ifneq (${STATIC},)
206LDFLAGS += -static
207PKG_CONFIG += --static
208endif
209
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800210# Determine QEMU architecture needed, if any
211ifeq (${ARCH},${HOST_ARCH})
212 # Same architecture; no need for QEMU
213 QEMU_ARCH :=
Randall Spangler61a2eb32013-01-23 10:20:16 -0800214else ifeq (${HOST_ARCH}-${ARCH},x86_64-x86)
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800215 # 64-bit host can run 32-bit targets directly
216 QEMU_ARCH :=
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800217else
218 QEMU_ARCH := ${ARCH}
219endif
220
221# The top of the chroot for qemu must be passed in via the SYSROOT environment
222# variable. In the Chromium OS chroot, this is done automatically by the
223# ebuild.
224
225ifeq (${QEMU_ARCH},)
226 # Path to build output for running tests is same as for building
227 BUILD_RUN = ${BUILD}
Randall Spanglere061a252013-01-22 15:34:07 -0800228 SRC_RUN = ${SRCDIR}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800229else
230 $(info Using qemu for testing.)
231 # Path to build output for running tests is different in the chroot
232 BUILD_RUN = $(subst ${SYSROOT},,${BUILD})
Randall Spanglere061a252013-01-22 15:34:07 -0800233 SRC_RUN = $(subst ${SYSROOT},,${SRCDIR})
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800234
235 QEMU_BIN = qemu-${QEMU_ARCH}
Randall Spanglere061a252013-01-22 15:34:07 -0800236 QEMU_RUN = ${BUILD_RUN}/${QEMU_BIN}
237 export QEMU_RUN
238
239 RUNTEST = tests/test_using_qemu.sh
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800240endif
241
Randall Spanglere061a252013-01-22 15:34:07 -0800242export BUILD_RUN
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800243
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800244##############################################################################
245# Now we need to describe everything we might want or need to build
246
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800247# Everything wants these headers.
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800248INCLUDES += \
249 -Ifirmware/include \
250 -Ifirmware/lib/include \
251 -Ifirmware/lib/cgptlib/include \
252 -Ifirmware/lib/cryptolib/include \
Randall Spangler786acda2014-05-22 13:27:07 -0700253 -Ifirmware/lib/tpm_lite/include \
254 -Ifirmware/2lib/include
Bill Richardson0b8f35c2010-05-26 09:18:38 -0700255
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800256# If we're not building for a specific target, just stub out things like the
257# TPM commands and various external functions that are provided by the BIOS.
258ifeq (${FIRMWARE_ARCH},)
Bill Richardson0e6ae292014-08-26 10:34:40 -0700259INCLUDES += -Ihost/include -Ihost/lib/include
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +0800260endif
Gaurav Shah322536d2010-01-28 15:01:23 -0800261
Bill Richardson78299022014-06-20 14:33:00 -0700262# Firmware library, used by the other firmware components (depthcharge,
263# coreboot, etc.). It doesn't need exporting to some other place; they'll build
264# this source tree locally and link to it directly.
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800265FWLIB = ${BUILD}/vboot_fw.a
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800266
Bill Richardson06eb78c2015-01-27 15:01:51 -0800267# Smaller firmware library common to all vboot 2.x, used only for
268# 1) compile-time tests of the public API or
269# 2) linking with an actual 2.0 or 2.1 implementation
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800270FWLIB2X = ${BUILD}/vboot_fw2x.a
Bill Richardson06eb78c2015-01-27 15:01:51 -0800271
272# Vboot 2.0 (deprecated - see firmware/README)
273FWLIB20 = ${BUILD}/vboot_fw20.a
274# Vboot 2.1 (not yet ready - see firmware/README)
Randall Spanglera5b69b02014-12-02 13:41:29 -0800275FWLIB21 = ${BUILD}/vboot_fw21.a
Randall Spangler786acda2014-05-22 13:27:07 -0700276
Randall Spangler93943262013-02-26 11:03:57 -0800277# Firmware library sources needed by VbInit() call
278VBINIT_SRCS = \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800279 firmware/lib/crc8.c \
Randall Spangler93943262013-02-26 11:03:57 -0800280 firmware/lib/utility.c \
281 firmware/lib/vboot_api_init.c \
282 firmware/lib/vboot_common_init.c \
283 firmware/lib/vboot_nvstorage.c \
Bill Richardson78299022014-06-20 14:33:00 -0700284 firmware/lib/vboot_nvstorage_rollback.c \
Simon Glass527ba812013-07-25 08:48:47 -0600285 firmware/lib/region-init.c \
Randall Spangler93943262013-02-26 11:03:57 -0800286
287# Additional firmware library sources needed by VbSelectFirmware() call
288VBSF_SRCS = \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800289 firmware/lib/cryptolib/padding.c \
290 firmware/lib/cryptolib/rsa.c \
291 firmware/lib/cryptolib/rsa_utility.c \
292 firmware/lib/cryptolib/sha1.c \
293 firmware/lib/cryptolib/sha256.c \
294 firmware/lib/cryptolib/sha512.c \
295 firmware/lib/cryptolib/sha_utility.c \
296 firmware/lib/stateful_util.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800297 firmware/lib/vboot_api_firmware.c \
Randall Spangler93943262013-02-26 11:03:57 -0800298 firmware/lib/vboot_common.c \
Simon Glass527ba812013-07-25 08:48:47 -0600299 firmware/lib/vboot_firmware.c \
300 firmware/lib/region-fw.c \
Randall Spangler93943262013-02-26 11:03:57 -0800301
302# Additional firmware library sources needed by VbSelectAndLoadKernel() call
303VBSLK_SRCS = \
304 firmware/lib/cgptlib/cgptlib.c \
305 firmware/lib/cgptlib/cgptlib_internal.c \
306 firmware/lib/cgptlib/crc32.c \
Dan Ehrenberg7c2beb02014-10-21 16:15:54 -0700307 firmware/lib/gpt_misc.c \
Randall Spangler93943262013-02-26 11:03:57 -0800308 firmware/lib/utility_string.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800309 firmware/lib/vboot_api_kernel.c \
310 firmware/lib/vboot_audio.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800311 firmware/lib/vboot_display.c \
Simon Glass527ba812013-07-25 08:48:47 -0600312 firmware/lib/vboot_kernel.c \
313 firmware/lib/region-kernel.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800314
Bill Richardson06eb78c2015-01-27 15:01:51 -0800315# Code common to both vboot 2.0 (old structs) and 2.1 (new structs)
316FWLIB2X_SRCS = \
Randall Spanglera7ab8b52014-06-10 17:05:08 -0700317 firmware/2lib/2api.c \
Randall Spangler786acda2014-05-22 13:27:07 -0700318 firmware/2lib/2common.c \
Randall Spangler3333e572014-05-14 11:37:52 -0700319 firmware/2lib/2crc8.c \
320 firmware/2lib/2misc.c \
321 firmware/2lib/2nvstorage.c \
Randall Spanglere166d042014-05-13 09:24:52 -0700322 firmware/2lib/2rsa.c \
Randall Spangler3333e572014-05-14 11:37:52 -0700323 firmware/2lib/2secdata.c \
Randall Spanglere166d042014-05-13 09:24:52 -0700324 firmware/2lib/2sha1.c \
325 firmware/2lib/2sha256.c \
326 firmware/2lib/2sha512.c \
Daisuke Nojiri62d482e2015-01-29 14:37:25 -0800327 firmware/2lib/2sha_utility.c \
328 firmware/2lib/2tpm_bootmode.c
Randall Spanglera5b69b02014-12-02 13:41:29 -0800329
Randall Spangler108d9912014-12-02 15:55:56 -0800330FWLIB20_SRCS = \
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800331 firmware/lib20/api.c \
332 firmware/lib20/common.c \
333 firmware/lib20/misc.c \
334 firmware/lib20/packed_key.c
Randall Spangler108d9912014-12-02 15:55:56 -0800335
Randall Spanglera5b69b02014-12-02 13:41:29 -0800336FWLIB21_SRCS = \
337 firmware/lib21/api.c \
338 firmware/lib21/common.c \
339 firmware/lib21/misc.c \
340 firmware/lib21/packed_key.c
Randall Spangler786acda2014-05-22 13:27:07 -0700341
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800342# Support real TPM unless BIOS sets MOCK_TPM
343ifeq (${MOCK_TPM},)
Randall Spangler93943262013-02-26 11:03:57 -0800344VBINIT_SRCS += \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800345 firmware/lib/rollback_index.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800346 firmware/lib/tpm_lite/tlcl.c
Randall Spangler93943262013-02-26 11:03:57 -0800347
348VBSF_SRCS += \
349 firmware/lib/tpm_bootmode.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800350else
Randall Spangler93943262013-02-26 11:03:57 -0800351VBINIT_SRCS += \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800352 firmware/lib/mocked_rollback_index.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800353 firmware/lib/tpm_lite/mocked_tlcl.c
Randall Spangler93943262013-02-26 11:03:57 -0800354
355VBSF_SRCS += \
356 firmware/lib/mocked_tpm_bootmode.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800357endif
358
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800359ifeq (${FIRMWARE_ARCH},)
360# Include BIOS stubs in the firmware library when compiling for host
Randall Spangler93943262013-02-26 11:03:57 -0800361# TODO: split out other stub funcs too
362VBINIT_SRCS += \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800363 firmware/stub/tpm_lite_stub.c \
364 firmware/stub/utility_stub.c \
Simon Glass527ba812013-07-25 08:48:47 -0600365 firmware/stub/vboot_api_stub_init.c \
366 firmware/stub/vboot_api_stub_region.c
Randall Spangler93943262013-02-26 11:03:57 -0800367
368VBSF_SRCS += \
369 firmware/stub/vboot_api_stub_sf.c
370
371VBSLK_SRCS += \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800372 firmware/stub/vboot_api_stub.c \
Dan Ehrenberg5dc75d12014-10-07 14:55:37 -0700373 firmware/stub/vboot_api_stub_disk.c \
374 firmware/stub/vboot_api_stub_stream.c
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700375
Bill Richardson06eb78c2015-01-27 15:01:51 -0800376FWLIB2X_SRCS += \
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700377 firmware/2lib/2stub.c
378
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800379endif
380
Randall Spangler93943262013-02-26 11:03:57 -0800381VBSF_SRCS += ${VBINIT_SRCS}
382FWLIB_SRCS += ${VBSF_SRCS} ${VBSLK_SRCS}
383
384VBINIT_OBJS = ${VBINIT_SRCS:%.c=${BUILD}/%.o}
385VBSF_OBJS = ${VBSF_SRCS:%.c=${BUILD}/%.o}
Randall Spanglera5b69b02014-12-02 13:41:29 -0800386ALL_OBJS += ${VBINIT_OBJS} ${VBSF_OBJS}
Randall Spangler93943262013-02-26 11:03:57 -0800387
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800388FWLIB_OBJS = ${FWLIB_SRCS:%.c=${BUILD}/%.o}
Bill Richardson06eb78c2015-01-27 15:01:51 -0800389FWLIB2X_OBJS = ${FWLIB2X_SRCS:%.c=${BUILD}/%.o}
Randall Spangleraaaff862014-12-01 15:40:08 -0800390FWLIB20_OBJS = ${FWLIB20_SRCS:%.c=${BUILD}/%.o}
Randall Spanglera5b69b02014-12-02 13:41:29 -0800391FWLIB21_OBJS = ${FWLIB21_SRCS:%.c=${BUILD}/%.o}
Bill Richardson06eb78c2015-01-27 15:01:51 -0800392ALL_OBJS += ${FWLIB_OBJS} ${FWLIB2X_OBJS} ${FWLIB20_OBJS} ${FWLIB21_OBJS}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800393
Bill Richardson78299022014-06-20 14:33:00 -0700394# Intermediate library for the vboot_reference utilities to link against.
395UTILLIB = ${BUILD}/libvboot_util.a
Randall Spangler108d9912014-12-02 15:55:56 -0800396UTILLIB21 = ${BUILD}/libvboot_util21.a
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800397
Bill Richardson78299022014-06-20 14:33:00 -0700398UTILLIB_SRCS = \
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800399 cgpt/cgpt_create.c \
400 cgpt/cgpt_add.c \
401 cgpt/cgpt_boot.c \
402 cgpt/cgpt_show.c \
403 cgpt/cgpt_repair.c \
404 cgpt/cgpt_prioritize.c \
405 cgpt/cgpt_common.c \
Bill Richardson6f396152014-07-15 12:52:19 -0700406 futility/dump_kernel_config_lib.c \
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800407 host/arch/${ARCH}/lib/crossystem_arch.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800408 host/lib/crossystem.c \
409 host/lib/file_keys.c \
410 host/lib/fmap.c \
411 host/lib/host_common.c \
412 host/lib/host_key.c \
413 host/lib/host_keyblock.c \
414 host/lib/host_misc.c \
Bill Richardson78299022014-06-20 14:33:00 -0700415 host/lib/util_misc.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800416 host/lib/host_signature.c \
Bill Richardson6f396152014-07-15 12:52:19 -0700417 host/lib/signature_digest.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800418
Randall Spangleraaaff862014-12-01 15:40:08 -0800419UTILLIB_OBJS = ${UTILLIB_SRCS:%.c=${BUILD}/%.o}
420ALL_OBJS += ${UTILLIB_OBJS}
421
Randall Spanglera5b69b02014-12-02 13:41:29 -0800422UTILLIB21_SRCS += \
423 host/lib21/host_fw_preamble.c \
424 host/lib21/host_key.c \
425 host/lib21/host_keyblock.c \
426 host/lib21/host_misc.c \
427 host/lib21/host_signature.c
Randall Spangler02e11b32014-11-19 12:48:36 -0800428
Randall Spanglera5b69b02014-12-02 13:41:29 -0800429UTILLIB21_OBJS = ${UTILLIB21_SRCS:%.c=${BUILD}/%.o}
430ALL_OBJS += ${UTILLIB21_OBJS}
Bill Richardson78299022014-06-20 14:33:00 -0700431
432# Externally exported library for some target userspace apps to link with
433# (cryptohome, updater, etc.)
434HOSTLIB = ${BUILD}/libvboot_host.a
435
436HOSTLIB_SRCS = \
437 cgpt/cgpt_add.c \
438 cgpt/cgpt_boot.c \
439 cgpt/cgpt_common.c \
440 cgpt/cgpt_create.c \
441 cgpt/cgpt_prioritize.c \
Bill Richardson78299022014-06-20 14:33:00 -0700442 firmware/lib/cgptlib/cgptlib_internal.c \
443 firmware/lib/cgptlib/crc32.c \
Bill Richardson78299022014-06-20 14:33:00 -0700444 firmware/lib/crc8.c \
Dan Ehrenberg32a999d2014-11-21 15:44:05 -0800445 firmware/lib/gpt_misc.c \
Bill Richardson78299022014-06-20 14:33:00 -0700446 firmware/lib/tpm_lite/tlcl.c \
447 firmware/lib/utility_string.c \
448 firmware/lib/vboot_nvstorage.c \
449 firmware/stub/tpm_lite_stub.c \
450 firmware/stub/utility_stub.c \
Dan Ehrenberg32a999d2014-11-21 15:44:05 -0800451 firmware/stub/vboot_api_stub_disk.c \
Bill Richardson78299022014-06-20 14:33:00 -0700452 firmware/stub/vboot_api_stub_init.c \
Dan Ehrenberg32a999d2014-11-21 15:44:05 -0800453 firmware/stub/vboot_api_stub_sf.c \
Bill Richardson6f396152014-07-15 12:52:19 -0700454 futility/dump_kernel_config_lib.c \
Bill Richardson78299022014-06-20 14:33:00 -0700455 host/arch/${ARCH}/lib/crossystem_arch.c \
456 host/lib/crossystem.c \
Zach Reizner317bb492015-02-20 14:55:02 -0800457 host/lib/extract_vmlinuz.c \
Nam T. Nguyen6ee52d92014-10-24 13:20:39 -0700458 host/lib/fmap.c \
Bill Richardson6f396152014-07-15 12:52:19 -0700459 host/lib/host_misc.c
Bill Richardson78299022014-06-20 14:33:00 -0700460
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800461HOSTLIB_OBJS = ${HOSTLIB_SRCS:%.c=${BUILD}/%.o}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800462ALL_OBJS += ${HOSTLIB_OBJS}
463
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800464# Sigh. For historical reasons, the autoupdate installer must sometimes be a
465# 32-bit executable, even when everything else is 64-bit. But it only needs a
466# few functions, so let's just build those.
467TINYHOSTLIB = ${BUILD}/libtinyvboot_host.a
468
469TINYHOSTLIB_SRCS = \
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800470 cgpt/cgpt_add.c \
471 cgpt/cgpt_boot.c \
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800472 cgpt/cgpt_common.c \
Bill Richardson78299022014-06-20 14:33:00 -0700473 cgpt/cgpt_create.c \
474 cgpt/cgpt_prioritize.c \
Bill Richardson78299022014-06-20 14:33:00 -0700475 firmware/lib/cgptlib/cgptlib_internal.c \
476 firmware/lib/cgptlib/crc32.c \
Dan Ehrenberg32a999d2014-11-21 15:44:05 -0800477 firmware/lib/gpt_misc.c \
Bill Richardson5fed2a62013-03-04 15:11:38 -0800478 firmware/lib/utility_string.c \
Dan Ehrenberg32a999d2014-11-21 15:44:05 -0800479 firmware/stub/vboot_api_stub_disk.c \
480 firmware/stub/vboot_api_stub_sf.c \
Bill Richardson78299022014-06-20 14:33:00 -0700481 firmware/stub/utility_stub.c \
Zach Reizner317bb492015-02-20 14:55:02 -0800482 futility/dump_kernel_config_lib.c \
483 host/lib/extract_vmlinuz.c
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800484
485TINYHOSTLIB_OBJS = ${TINYHOSTLIB_SRCS:%.c=${BUILD}/%.o}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800486
487# ----------------------------------------------------------------------------
488# Now for the userspace binaries
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800489
490CGPT = ${BUILD}/cgpt/cgpt
491
492CGPT_SRCS = \
493 cgpt/cgpt.c \
494 cgpt/cgpt_add.c \
495 cgpt/cgpt_boot.c \
496 cgpt/cgpt_common.c \
497 cgpt/cgpt_create.c \
498 cgpt/cgpt_find.c \
499 cgpt/cgpt_legacy.c \
Nam T. Nguyend1236e42015-01-08 11:43:27 -0800500 cgpt/cgpt_nor.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800501 cgpt/cgpt_prioritize.c \
502 cgpt/cgpt_repair.c \
503 cgpt/cgpt_show.c \
504 cgpt/cmd_add.c \
505 cgpt/cmd_boot.c \
506 cgpt/cmd_create.c \
507 cgpt/cmd_find.c \
508 cgpt/cmd_legacy.c \
509 cgpt/cmd_prioritize.c \
510 cgpt/cmd_repair.c \
Nam T. Nguyen8577b532014-11-25 13:26:53 -0800511 cgpt/cmd_show.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800512
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800513CGPT_OBJS = ${CGPT_SRCS:%.c=${BUILD}/%.o}
Nam T. Nguyend1236e42015-01-08 11:43:27 -0800514
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800515ALL_OBJS += ${CGPT_OBJS}
516
Nam T. Nguyend1236e42015-01-08 11:43:27 -0800517CGPT_WRAPPER = ${BUILD}/cgpt/cgpt_wrapper
518
519CGPT_WRAPPER_SRCS = \
520 cgpt/cgpt_nor.c \
521 cgpt/cgpt_wrapper.c
522
523CGPT_WRAPPER_OBJS = ${CGPT_WRAPPER_SRCS:%.c=${BUILD}/%.o}
524
525ALL_OBJS += ${CGPT_WRAPPER_OBJS}
526
Bill Richardsoncfe83a82014-12-04 11:29:57 -0800527# Utility defaults
528UTIL_DEFAULTS = ${BUILD}/default/vboot_reference
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800529
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800530# Scripts to install directly (not compiled)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800531UTIL_SCRIPTS = \
532 utility/dev_debug_vboot \
Bill Richardson4d49d342014-10-02 10:52:41 -0700533 utility/enable_dev_usb_boot
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800534
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800535ifeq (${MINIMAL},)
536UTIL_SCRIPTS += \
Bill Richardson4d49d342014-10-02 10:52:41 -0700537 utility/dev_make_keypair \
538 utility/vbutil_what_keys
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800539endif
540
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800541# These utilities should be linked statically.
542UTIL_NAMES_STATIC = \
Bill Richardson6f396152014-07-15 12:52:19 -0700543 utility/crossystem
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800544
545UTIL_NAMES = ${UTIL_NAMES_STATIC} \
Bill Richardson339f7e02013-04-05 09:49:24 -0700546 utility/tpm_init_temp_fix \
Duncan Laurie0f078672014-09-19 14:39:09 -0700547 utility/dumpRSAPublicKey \
Bill Richardson6f396152014-07-15 12:52:19 -0700548 utility/tpmc
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800549
Bill Richardson6f396152014-07-15 12:52:19 -0700550# TODO: Do we still need eficompress and efidecompress for anything?
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800551ifeq (${MINIMAL},)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800552UTIL_NAMES += \
Bill Richardson339f7e02013-04-05 09:49:24 -0700553 utility/bmpblk_font \
554 utility/bmpblk_utility \
555 utility/eficompress \
556 utility/efidecompress \
557 utility/load_kernel_test \
558 utility/pad_digest_utility \
559 utility/signature_digest_utility \
560 utility/verify_data
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800561endif
562
Bill Richardson339f7e02013-04-05 09:49:24 -0700563UTIL_BINS_STATIC := $(addprefix ${BUILD}/,${UTIL_NAMES_STATIC})
564UTIL_BINS = $(addprefix ${BUILD}/,${UTIL_NAMES})
Bill Richardson1912bba2013-04-04 21:08:50 -0700565ALL_OBJS += $(addsuffix .o,${UTIL_BINS} ${UTIL_BINS_STATIC})
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800566
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800567
568# Scripts for signing stuff.
569SIGNING_SCRIPTS = \
570 utility/tpm-nvsize \
571 utility/chromeos-tpm-recovery
572
573# These go in a different place.
574SIGNING_SCRIPTS_DEV = \
575 scripts/image_signing/resign_firmwarefd.sh \
576 scripts/image_signing/make_dev_firmware.sh \
577 scripts/image_signing/make_dev_ssd.sh \
578 scripts/image_signing/set_gbb_flags.sh
579
580# Installed, but not made executable.
581SIGNING_COMMON = scripts/image_signing/common_minimal.sh
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800582
Bill Richardson826db092013-01-14 12:37:15 -0800583
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800584# The unified firmware utility will eventually replace all the others
585FUTIL_BIN = ${BUILD}/futility/futility
Bill Richardson6db8c752013-04-05 13:30:43 -0700586# But we still need both static (tiny) and dynamic (with openssl) versions.
587FUTIL_STATIC_BIN = ${FUTIL_BIN}_s
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800588
Bill Richardson6f396152014-07-15 12:52:19 -0700589# These are the executables that are now built in to futility. We'll create
590# symlinks for these so the old names will still work.
Bill Richardsona1d9fe62014-09-05 12:52:27 -0700591FUTIL_SYMLINKS = \
Bill Richardsone1550442014-07-17 11:32:17 -0700592 dump_fmap \
593 dump_kernel_config \
Bill Richardsone1550442014-07-17 11:32:17 -0700594 gbb_utility \
Bill Richardsone1550442014-07-17 11:32:17 -0700595 vbutil_firmware \
596 vbutil_kernel \
597 vbutil_key \
Bill Richardson6f396152014-07-15 12:52:19 -0700598 vbutil_keyblock
Bill Richardsonfeb25182013-03-07 12:54:29 -0800599
Bill Richardson6db8c752013-04-05 13:30:43 -0700600FUTIL_STATIC_SRCS = \
Bill Richardsonfeb25182013-03-07 12:54:29 -0800601 futility/futility.c \
Bill Richardson20807b62013-04-09 10:15:26 -0700602 futility/cmd_dump_fmap.c \
Bill Richardsoncf6e78d2014-08-27 15:50:25 -0700603 futility/cmd_gbb_utility.c \
604 futility/misc.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800605
Bill Richardson6db8c752013-04-05 13:30:43 -0700606FUTIL_SRCS = \
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500607 ${FUTIL_STATIC_SRCS} \
Bill Richardson4e4c1962015-02-03 17:07:15 -0800608 futility/cmd_create.c \
Bill Richardson6f396152014-07-15 12:52:19 -0700609 futility/cmd_dump_kernel_config.c \
Bill Richardson2e25e812014-09-03 11:34:27 -0700610 futility/cmd_load_fmap.c \
Bill Richardsonf4f395e2014-10-22 17:42:20 -0700611 futility/cmd_pcr.c \
Bill Richardsonf318ee22014-09-23 14:30:30 -0700612 futility/cmd_show.c \
613 futility/cmd_sign.c \
Bill Richardson6f396152014-07-15 12:52:19 -0700614 futility/cmd_vbutil_firmware.c \
615 futility/cmd_vbutil_kernel.c \
Bill Richardsonb84b81d2014-07-14 14:48:31 -0700616 futility/cmd_vbutil_key.c \
Randall Spanglerb8ff3972014-08-27 13:34:35 -0700617 futility/cmd_vbutil_keyblock.c \
Bill Richardson25593382015-01-30 12:22:28 -0800618 futility/file_type.c \
Bill Richardsonf318ee22014-09-23 14:30:30 -0700619 futility/traversal.c \
620 futility/vb1_helper.c
Bill Richardson6db8c752013-04-05 13:30:43 -0700621
Alex Deymoe08ee282014-08-29 01:07:48 -0700622# List of commands built in futility and futility_s.
623FUTIL_STATIC_CMD_LIST = ${BUILD}/gen/futility_static_cmds.c
624FUTIL_CMD_LIST = ${BUILD}/gen/futility_cmds.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800625
Bill Richardson91852e72014-11-28 12:28:04 -0800626# Workaround for TODO(crbug.com/437107).
627FUTIL_STATIC_WORKAROUND_SRCS = firmware/stub/vboot_api_stub_static_sf.c
628
Alex Deymoe08ee282014-08-29 01:07:48 -0700629FUTIL_STATIC_OBJS = ${FUTIL_STATIC_SRCS:%.c=${BUILD}/%.o} \
Bill Richardson91852e72014-11-28 12:28:04 -0800630 ${FUTIL_STATIC_WORKAROUND_SRCS:%.c=${BUILD}/%.o} \
Alex Deymoe08ee282014-08-29 01:07:48 -0700631 ${FUTIL_STATIC_CMD_LIST:%.c=%.o}
632FUTIL_OBJS = ${FUTIL_SRCS:%.c=${BUILD}/%.o} ${FUTIL_CMD_LIST:%.c=%.o}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800633
Bill Richardson4e4c1962015-02-03 17:07:15 -0800634${FUTIL_OBJS}: INCLUDES += -Ihost/lib21/include -Ifirmware/lib21/include
635${FUTIL_BIN}: ${UTILLIB21}
636${FUTIL_BIN}: LIBS += ${UTILLIB21}
637
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800638ALL_OBJS += ${FUTIL_OBJS}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800639
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800640
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800641# Library of handy test functions.
642TESTLIB = ${BUILD}/tests/test.a
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800643
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800644TESTLIB_SRCS = \
645 tests/test_common.c \
646 tests/timer_utils.c \
647 tests/crc32_test.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800648
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800649TESTLIB_OBJS = ${TESTLIB_SRCS:%.c=${BUILD}/%.o}
Bill Richardson80872db2014-10-03 10:26:11 -0700650TEST_OBJS += ${TESTLIB_OBJS}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800651
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800652
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800653# And some compiled tests.
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800654TEST_NAMES = \
Bill Richardson339f7e02013-04-05 09:49:24 -0700655 tests/cgptlib_test \
656 tests/rollback_index2_tests \
657 tests/rollback_index3_tests \
658 tests/rsa_padding_test \
659 tests/rsa_utility_tests \
660 tests/rsa_verify_benchmark \
661 tests/sha_benchmark \
662 tests/sha_tests \
663 tests/stateful_util_tests \
664 tests/tlcl_tests \
665 tests/tpm_bootmode_tests \
666 tests/utility_string_tests \
667 tests/utility_tests \
668 tests/vboot_api_init_tests \
669 tests/vboot_api_devmode_tests \
670 tests/vboot_api_firmware_tests \
671 tests/vboot_api_kernel_tests \
672 tests/vboot_api_kernel2_tests \
673 tests/vboot_api_kernel3_tests \
674 tests/vboot_api_kernel4_tests \
675 tests/vboot_audio_tests \
676 tests/vboot_common_tests \
677 tests/vboot_common2_tests \
678 tests/vboot_common3_tests \
679 tests/vboot_display_tests \
680 tests/vboot_firmware_tests \
681 tests/vboot_kernel_tests \
682 tests/vboot_nvstorage_test \
Bill Richardsona77541f2014-12-04 19:06:35 -0800683 tests/verify_kernel \
Bill Richardson6f396152014-07-15 12:52:19 -0700684 tests/futility/binary_editor \
Bill Richardson339f7e02013-04-05 09:49:24 -0700685 tests/futility/test_not_really
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800686
Simon Glass527ba812013-07-25 08:48:47 -0600687ifdef REGION_READ
688TEST_NAMES += tests/vboot_region_tests
689endif
690
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800691TEST2X_NAMES = \
Randall Spanglera7ab8b52014-06-10 17:05:08 -0700692 tests/vb2_api_tests \
Randall Spangler786acda2014-05-22 13:27:07 -0700693 tests/vb2_common_tests \
Randall Spangler3333e572014-05-14 11:37:52 -0700694 tests/vb2_misc_tests \
695 tests/vb2_nvstorage_tests \
Randall Spanglere166d042014-05-13 09:24:52 -0700696 tests/vb2_rsa_utility_tests \
Randall Spangler3333e572014-05-14 11:37:52 -0700697 tests/vb2_secdata_tests \
Randall Spangler108d9912014-12-02 15:55:56 -0800698 tests/vb2_sha_tests
699
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800700TEST20_NAMES = \
701 tests/vb20_api_tests \
702 tests/vb20_common_tests \
703 tests/vb20_common2_tests \
Bill Richardson5fb14632015-01-27 13:59:35 -0800704 tests/vb20_verify_fw.c \
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800705 tests/vb20_common3_tests \
706 tests/vb20_misc_tests \
Bill Richardson5fb14632015-01-27 13:59:35 -0800707 tests/vb20_rsa_padding_tests \
708 tests/vb20_verify_fw
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800709
Randall Spangler108d9912014-12-02 15:55:56 -0800710TEST21_NAMES = \
711 tests/vb21_api_tests \
712 tests/vb21_common_tests \
713 tests/vb21_common2_tests \
714 tests/vb21_misc_tests \
715 tests/vb21_host_fw_preamble_tests \
716 tests/vb21_host_key_tests \
717 tests/vb21_host_keyblock_tests \
718 tests/vb21_host_misc_tests \
719 tests/vb21_host_sig_tests
Randall Spangler786acda2014-05-22 13:27:07 -0700720
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800721TEST_NAMES += ${TEST2X_NAMES} ${TEST20_NAMES} ${TEST21_NAMES}
Randall Spangler786acda2014-05-22 13:27:07 -0700722
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800723# And a few more...
Bill Richardson339f7e02013-04-05 09:49:24 -0700724TLCL_TEST_NAMES = \
725 tests/tpm_lite/tpmtest_earlyextend \
726 tests/tpm_lite/tpmtest_earlynvram \
727 tests/tpm_lite/tpmtest_earlynvram2 \
728 tests/tpm_lite/tpmtest_enable \
729 tests/tpm_lite/tpmtest_fastenable \
730 tests/tpm_lite/tpmtest_globallock \
731 tests/tpm_lite/tpmtest_redefine_unowned \
732 tests/tpm_lite/tpmtest_spaceperm \
733 tests/tpm_lite/tpmtest_testsetup \
734 tests/tpm_lite/tpmtest_timing \
735 tests/tpm_lite/tpmtest_writelimit
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800736
737TEST_NAMES += ${TLCL_TEST_NAMES}
738
Bill Richardson339f7e02013-04-05 09:49:24 -0700739# Finally
740TEST_BINS = $(addprefix ${BUILD}/,${TEST_NAMES})
Bill Richardson80872db2014-10-03 10:26:11 -0700741TEST_OBJS += $(addsuffix .o,${TEST_BINS})
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800742
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800743TEST2X_BINS = $(addprefix ${BUILD}/,${TEST2X_NAMES})
Randall Spangleraaaff862014-12-01 15:40:08 -0800744TEST20_BINS = $(addprefix ${BUILD}/,${TEST20_NAMES})
Randall Spangler108d9912014-12-02 15:55:56 -0800745TEST21_BINS = $(addprefix ${BUILD}/,${TEST21_NAMES})
Randall Spangleraaaff862014-12-01 15:40:08 -0800746
Randall Spanglere061a252013-01-22 15:34:07 -0800747# Directory containing test keys
748TEST_KEYS = ${SRC_RUN}/tests/testkeys
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800749
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800750
751##############################################################################
752# Finally, some targets. High-level ones first.
753
754# Create output directories if necessary. Do this via explicit shell commands
755# so it happens before trying to generate/include dependencies.
756SUBDIRS := firmware host cgpt utility futility tests tests/tpm_lite
757_dir_create := $(foreach d, \
758 $(shell find ${SUBDIRS} -name '*.c' -exec dirname {} \; | sort -u), \
759 $(shell [ -d ${BUILD}/${d} ] || mkdir -p ${BUILD}/${d}))
760
761
762# Default target.
763.PHONY: all
Bill Richardson06eb78c2015-01-27 15:01:51 -0800764all: fwlib fwlib2x fwlib20 fwlib21 \
Randall Spangleraaaff862014-12-01 15:40:08 -0800765 $(if ${FIRMWARE_ARCH},,host_stuff) \
Randall Spangler786acda2014-05-22 13:27:07 -0700766 $(if ${COV},coverage)
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800767
768# Host targets
769.PHONY: host_stuff
Bill Richardson06eb78c2015-01-27 15:01:51 -0800770host_stuff: utillib hostlib cgpt utils futil tests utillib21
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800771
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800772.PHONY: clean
773clean:
774 ${Q}/bin/rm -rf ${BUILD}
775
776.PHONY: install
Nam T. Nguyen07d90432015-02-17 13:26:44 -0800777install: cgpt_install utils_install signing_install futil_install \
778 pc_files_install
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800779
Nam T. Nguyend1236e42015-01-08 11:43:27 -0800780.PHONY: install_mtd
781install_mtd: install cgpt_wrapper_install
782
Bill Richardson3e3790d2014-07-14 15:05:54 -0700783.PHONY: install_for_test
784install_for_test: override DESTDIR = ${TEST_INSTALL_DIR}
785install_for_test: install
786
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800787# Don't delete intermediate object files
788.SECONDARY:
789
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800790# ----------------------------------------------------------------------------
791# Firmware library
792
793# TPM-specific flags. These depend on the particular TPM we're targeting for.
794# They are needed here only for compiling parts of the firmware code into
795# user-level tests.
796
797# TPM_BLOCKING_CONTINUESELFTEST is defined if TPM_ContinueSelfTest blocks until
798# the self test has completed.
799
Randall Spangler45cc0f22013-01-25 09:34:26 -0800800${FWLIB_OBJS}: CFLAGS += -DTPM_BLOCKING_CONTINUESELFTEST
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800801
802# TPM_MANUAL_SELFTEST is defined if the self test must be started manually
803# (with a call to TPM_ContinueSelfTest) instead of starting automatically at
804# power on.
805#
806# We sincerely hope that TPM_BLOCKING_CONTINUESELFTEST and TPM_MANUAL_SELFTEST
807# are not both defined at the same time. (See comment in code.)
808
809# CFLAGS += -DTPM_MANUAL_SELFTEST
810
811ifeq (${FIRMWARE_ARCH},i386)
812# Unrolling loops in cryptolib makes it faster
Randall Spangler45cc0f22013-01-25 09:34:26 -0800813${FWLIB_OBJS}: CFLAGS += -DUNROLL_LOOPS
Bill Richardson06eb78c2015-01-27 15:01:51 -0800814${FWLIB2X_OBJS}: CFLAGS += -DUNROLL_LOOPS
Randall Spangleraaaff862014-12-01 15:40:08 -0800815${FWLIB20_OBJS}: CFLAGS += -DUNROLL_LOOPS
Randall Spanglera5b69b02014-12-02 13:41:29 -0800816${FWLIB21_OBJS}: CFLAGS += -DUNROLL_LOOPS
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800817
818# Workaround for coreboot on x86, which will power off asynchronously
819# without giving us a chance to react. This is not an example of the Right
820# Way to do things. See chrome-os-partner:7689, and the commit message
821# that made this change.
Randall Spangler45cc0f22013-01-25 09:34:26 -0800822${FWLIB_OBJS}: CFLAGS += -DSAVE_LOCALE_IMMEDIATELY
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800823
824# On x86 we don't actually read the GBB data into RAM until it is needed.
825# Therefore it makes sense to cache it rather than reading it each time.
826# Enable this feature.
Randall Spangler45cc0f22013-01-25 09:34:26 -0800827${FWLIB_OBJS}: CFLAGS += -DCOPY_BMP_DATA
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800828endif
829
Simon Glass527ba812013-07-25 08:48:47 -0600830ifdef REGION_READ
831${FWLIB_OBJS}: CFLAGS += -DREGION_READ
832endif
833
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800834ifeq (${FIRMWARE_ARCH},)
835# Disable rollback TPM when compiling locally, since otherwise
836# load_kernel_test attempts to talk to the TPM.
Randall Spangler45cc0f22013-01-25 09:34:26 -0800837${FWLIB_OBJS}: CFLAGS += -DDISABLE_ROLLBACK_TPM
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800838endif
839
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800840${FWLIB20_OBJS}: INCLUDES += -Ifirmware/lib20/include
Randall Spangler108d9912014-12-02 15:55:56 -0800841${FWLIB21_OBJS}: INCLUDES += -Ifirmware/lib21/include
842
Bill Richardsona130e0b2013-04-04 18:16:39 -0700843# Linktest ensures firmware lib doesn't rely on outside libraries
844${BUILD}/firmware/linktest/main_vbinit: ${VBINIT_OBJS}
Randall Spangler93943262013-02-26 11:03:57 -0800845${BUILD}/firmware/linktest/main_vbinit: OBJS = ${VBINIT_OBJS}
Bill Richardson80872db2014-10-03 10:26:11 -0700846TEST_OBJS += ${BUILD}/firmware/linktest/main_vbinit.o
Bill Richardsona130e0b2013-04-04 18:16:39 -0700847${BUILD}/firmware/linktest/main_vbsf: ${VBSF_OBJS}
Randall Spangler93943262013-02-26 11:03:57 -0800848${BUILD}/firmware/linktest/main_vbsf: OBJS = ${VBSF_OBJS}
Bill Richardson80872db2014-10-03 10:26:11 -0700849TEST_OBJS += ${BUILD}/firmware/linktest/main_vbsf.o
Bill Richardsona130e0b2013-04-04 18:16:39 -0700850${BUILD}/firmware/linktest/main: ${FWLIB}
851${BUILD}/firmware/linktest/main: LIBS = ${FWLIB}
Bill Richardson80872db2014-10-03 10:26:11 -0700852TEST_OBJS += ${BUILD}/firmware/linktest/main.o
Randall Spangler93943262013-02-26 11:03:57 -0800853
Bill Richardsond2d08b22014-07-08 16:31:40 -0700854.PHONY: fwlinktest
855fwlinktest: \
Randall Spangler93943262013-02-26 11:03:57 -0800856 ${BUILD}/firmware/linktest/main_vbinit \
857 ${BUILD}/firmware/linktest/main_vbsf \
858 ${BUILD}/firmware/linktest/main
859
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800860.PHONY: fwlib
Bill Richardsona130e0b2013-04-04 18:16:39 -0700861fwlib: $(if ${FIRMWARE_ARCH},${FWLIB},fwlinktest)
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800862
863${FWLIB}: ${FWLIB_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500864 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800865 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500866 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800867 ${Q}ar qc $@ $^
868
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800869.PHONY: fwlib2x
870fwlib2x: ${FWLIB2X}
871
Bill Richardson06eb78c2015-01-27 15:01:51 -0800872${FWLIB2X}: ${FWLIB2X_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500873 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800874 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500875 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800876 ${Q}ar qc $@ $^
877
Bill Richardson06eb78c2015-01-27 15:01:51 -0800878.PHONY: fwlib20
879fwlib20: ${FWLIB20}
Randall Spanglera5b69b02014-12-02 13:41:29 -0800880
Bill Richardson06eb78c2015-01-27 15:01:51 -0800881${FWLIB20}: ${FWLIB2X_OBJS} ${FWLIB20_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500882 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Randall Spangler786acda2014-05-22 13:27:07 -0700883 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500884 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Randall Spangler786acda2014-05-22 13:27:07 -0700885 ${Q}ar qc $@ $^
886
Randall Spanglera5b69b02014-12-02 13:41:29 -0800887.PHONY: fwlib21
888fwlib21: ${FWLIB21}
889
Bill Richardson06eb78c2015-01-27 15:01:51 -0800890${FWLIB21}: ${FWLIB2X_OBJS} ${FWLIB21_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500891 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Randall Spanglera5b69b02014-12-02 13:41:29 -0800892 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500893 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Randall Spanglera5b69b02014-12-02 13:41:29 -0800894 ${Q}ar qc $@ $^
895
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800896# ----------------------------------------------------------------------------
Bill Richardson78299022014-06-20 14:33:00 -0700897# Host library(s)
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800898
Bill Richardson78299022014-06-20 14:33:00 -0700899# Link tests for local utilities
900${BUILD}/host/linktest/main: ${UTILLIB}
Bill Richardson78299022014-06-20 14:33:00 -0700901${BUILD}/host/linktest/main: LIBS = ${UTILLIB}
Bill Richardson80872db2014-10-03 10:26:11 -0700902TEST_OBJS += ${BUILD}/host/linktest/main.o
Bill Richardson78299022014-06-20 14:33:00 -0700903
904.PHONY: utillib
905utillib: ${UTILLIB} \
906 ${BUILD}/host/linktest/main
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800907
908# TODO: better way to make .a than duplicating this recipe each time?
Randall Spangleraaaff862014-12-01 15:40:08 -0800909${UTILLIB}: ${UTILLIB_OBJS} ${FWLIB_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500910 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Randall Spangleraaaff862014-12-01 15:40:08 -0800911 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500912 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Randall Spangleraaaff862014-12-01 15:40:08 -0800913 ${Q}ar qc $@ $^
914
Randall Spanglera5b69b02014-12-02 13:41:29 -0800915.PHONY: utillib21
916utillib21: ${UTILLIB21}
Randall Spangleraaaff862014-12-01 15:40:08 -0800917
Randall Spangler108d9912014-12-02 15:55:56 -0800918${UTILLIB21}: INCLUDES += -Ihost/lib21/include -Ifirmware/lib21/include
Bill Richardson06eb78c2015-01-27 15:01:51 -0800919${UTILLIB21}: ${UTILLIB21_OBJS} ${FWLIB2X_OBJS} ${FWLIB21_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500920 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardson78299022014-06-20 14:33:00 -0700921 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500922 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardson78299022014-06-20 14:33:00 -0700923 ${Q}ar qc $@ $^
924
925
926# Link tests for external repos
927${BUILD}/host/linktest/extern: ${HOSTLIB}
Bill Richardson78299022014-06-20 14:33:00 -0700928${BUILD}/host/linktest/extern: LIBS = ${HOSTLIB}
929${BUILD}/host/linktest/extern: LDLIBS += -static
Bill Richardson80872db2014-10-03 10:26:11 -0700930TEST_OBJS += ${BUILD}/host/linktest/extern.o
Bill Richardson78299022014-06-20 14:33:00 -0700931
932.PHONY: hostlib
933hostlib: ${HOSTLIB} \
934 ${BUILD}/host/linktest/extern
935
936# TODO: better way to make .a than duplicating this recipe each time?
Bill Richardson78299022014-06-20 14:33:00 -0700937${HOSTLIB}: ${HOSTLIB_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500938 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800939 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500940 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800941 ${Q}ar qc $@ $^
942
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800943
944# Ugh. This is a very cut-down version of HOSTLIB just for the installer.
945.PHONY: tinyhostlib
946tinyhostlib: ${TINYHOSTLIB}
947 ${Q}cp -f ${TINYHOSTLIB} ${HOSTLIB}
948
949${TINYHOSTLIB}: ${TINYHOSTLIB_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500950 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800951 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500952 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800953 ${Q}ar qc $@ $^
954
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800955# ----------------------------------------------------------------------------
956# CGPT library and utility
957
Nam T. Nguyend1236e42015-01-08 11:43:27 -0800958.PHONY: cgpt_wrapper
959cgpt_wrapper: ${CGPT_WRAPPER}
960
961${CGPT_WRAPPER}: ${CGPT_WRAPPER_OBJS} ${UTILLIB}
962 @$(PRINTF) " LD $(subst ${BUILD}/,,$@)\n"
963 ${Q}${LD} -o ${CGPT_WRAPPER} ${CFLAGS} $^
964
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800965.PHONY: cgpt
Nam T. Nguyend1236e42015-01-08 11:43:27 -0800966cgpt: ${CGPT} ${CGPT_WRAPPER}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800967
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800968${CGPT}: LDLIBS += -luuid
969
Bill Richardson78299022014-06-20 14:33:00 -0700970${CGPT}: ${CGPT_OBJS} ${UTILLIB}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500971 @${PRINTF} " LDcgpt $(subst ${BUILD}/,,$@)\n"
Bill Richardson6db8c752013-04-05 13:30:43 -0700972 ${Q}${LD} -o ${CGPT} ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800973
974.PHONY: cgpt_install
975cgpt_install: ${CGPT}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500976 @${PRINTF} " INSTALL CGPT\n"
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800977 ${Q}mkdir -p ${UB_DIR}
978 ${Q}${INSTALL} -t ${UB_DIR} $^
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800979
Nam T. Nguyend1236e42015-01-08 11:43:27 -0800980.PHONY: cgpt_wrapper_install
981cgpt_wrapper_install: cgpt_install ${CGPT_WRAPPER}
982 @$(PRINTF) " INSTALL cgpt_wrapper\n"
983 ${Q}${INSTALL} -t ${UB_DIR} ${CGPT_WRAPPER}
984 ${Q}mv ${UB_DIR}/$(notdir ${CGPT}) \
985 ${UB_DIR}/$(notdir ${CGPT}).bin
986 ${Q}mv ${UB_DIR}/$(notdir ${CGPT_WRAPPER}) \
987 ${UB_DIR}/$(notdir ${CGPT})
988
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800989# ----------------------------------------------------------------------------
990# Utilities
991
992# These have their own headers too.
Bill Richardson0f6679e2014-07-10 15:49:52 -0700993${BUILD}/utility/%: INCLUDES += -Iutility/include
994
995${UTIL_BINS} ${UTIL_BINS_STATIC}: ${UTILLIB}
996${UTIL_BINS} ${UTIL_BINS_STATIC}: LIBS = ${UTILLIB}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800997
998# Utilities for auto-update toolkits must be statically linked.
999${UTIL_BINS_STATIC}: LDFLAGS += -static
1000
Bill Richardsona130e0b2013-04-04 18:16:39 -07001001
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001002.PHONY: utils
Bill Richardsonc7c6e5d2013-02-28 10:10:29 -08001003utils: ${UTIL_BINS} ${UTIL_SCRIPTS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001004 ${Q}cp -f ${UTIL_SCRIPTS} ${BUILD}/utility
1005 ${Q}chmod a+rx $(patsubst %,${BUILD}/%,${UTIL_SCRIPTS})
1006
1007.PHONY: utils_install
Bill Richardsoncfe83a82014-12-04 11:29:57 -08001008utils_install: ${UTIL_BINS} ${UTIL_SCRIPTS} ${UTIL_DEFAULTS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001009 @${PRINTF} " INSTALL UTILS\n"
Bill Richardsonc9bf3482013-02-13 14:38:29 -08001010 ${Q}mkdir -p ${UB_DIR}
1011 ${Q}${INSTALL} -t ${UB_DIR} ${UTIL_BINS} ${UTIL_SCRIPTS}
Bill Richardsoncfe83a82014-12-04 11:29:57 -08001012 ${Q}mkdir -p ${DF_DIR}
1013 ${Q}${INSTALL} -t ${DF_DIR} -m 'u=rw,go=r,a-s' ${UTIL_DEFAULTS}
Bill Richardsonc9bf3482013-02-13 14:38:29 -08001014
1015# And some signing stuff for the target
1016.PHONY: signing_install
1017signing_install: ${SIGNING_SCRIPTS} ${SIGNING_SCRIPTS_DEV} ${SIGNING_COMMON}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001018 @${PRINTF} " INSTALL SIGNING\n"
Bill Richardson6f396152014-07-15 12:52:19 -07001019 ${Q}mkdir -p ${UB_DIR} ${VB_DIR}
Bill Richardsonc9bf3482013-02-13 14:38:29 -08001020 ${Q}${INSTALL} -t ${UB_DIR} ${SIGNING_SCRIPTS}
Bill Richardson6f396152014-07-15 12:52:19 -07001021 ${Q}${INSTALL} -t ${VB_DIR} ${SIGNING_SCRIPTS_DEV}
1022 ${Q}${INSTALL} -t ${VB_DIR} -m 'u=rw,go=r,a-s' ${SIGNING_COMMON}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001023
1024# ----------------------------------------------------------------------------
1025# new Firmware Utility
1026
1027.PHONY: futil
Bill Richardson6db8c752013-04-05 13:30:43 -07001028futil: ${FUTIL_STATIC_BIN} ${FUTIL_BIN}
1029
Bill Richardson06eb78c2015-01-27 15:01:51 -08001030${FUTIL_STATIC_BIN}: ${FUTIL_STATIC_OBJS} ${UTILLIB}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001031 @${PRINTF} " LD $(subst ${BUILD}/,,$@)\n"
Bill Richardson6db8c752013-04-05 13:30:43 -07001032 ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} -static $^ ${LDLIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001033
Bill Richardsonb84b81d2014-07-14 14:48:31 -07001034${FUTIL_BIN}: LDLIBS += ${CRYPTO_LIBS}
Bill Richardson06eb78c2015-01-27 15:01:51 -08001035${FUTIL_BIN}: ${FUTIL_OBJS} ${UTILLIB}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001036 @${PRINTF} " LD $(subst ${BUILD}/,,$@)\n"
Bill Richardson6db8c752013-04-05 13:30:43 -07001037 ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001038
1039.PHONY: futil_install
Bill Richardsonefa87562014-09-11 10:41:51 -07001040futil_install: ${FUTIL_BIN} ${FUTIL_STATIC_BIN}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001041 @${PRINTF} " INSTALL futility\n"
Bill Richardson6f396152014-07-15 12:52:19 -07001042 ${Q}mkdir -p ${UB_DIR}
1043 ${Q}${INSTALL} -t ${UB_DIR} ${FUTIL_BIN} ${FUTIL_STATIC_BIN}
Bill Richardsona1d9fe62014-09-05 12:52:27 -07001044 ${Q}for prog in ${FUTIL_SYMLINKS}; do \
Bill Richardson6f396152014-07-15 12:52:19 -07001045 ln -sf futility "${UB_DIR}/$$prog"; done
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001046
1047# ----------------------------------------------------------------------------
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001048# Utility to generate TLCL structure definition header file.
1049
1050${BUILD}/utility/tlcl_generator: CFLAGS += -fpack-struct
1051
1052STRUCTURES_TMP=${BUILD}/tlcl_structures.tmp
1053STRUCTURES_SRC=firmware/lib/tpm_lite/include/tlcl_structures.h
1054
1055.PHONY: update_tlcl_structures
1056update_tlcl_structures: ${BUILD}/utility/tlcl_generator
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001057 @${PRINTF} " Rebuilding TLCL structures\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001058 ${Q}${BUILD}/utility/tlcl_generator > ${STRUCTURES_TMP}
1059 ${Q}cmp -s ${STRUCTURES_TMP} ${STRUCTURES_SRC} || \
1060 ( echo "%% Updating structures.h %%" && \
1061 cp ${STRUCTURES_TMP} ${STRUCTURES_SRC} )
1062
1063# ----------------------------------------------------------------------------
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001064# Tests
1065
1066.PHONY: tests
1067tests: ${TEST_BINS}
1068
Bill Richardson78299022014-06-20 14:33:00 -07001069${TEST_BINS}: ${UTILLIB} ${TESTLIB}
Bill Richardson339f7e02013-04-05 09:49:24 -07001070${TEST_BINS}: INCLUDES += -Itests
Randall Spanglerefa37b82014-11-12 16:20:50 -08001071${TEST_BINS}: LIBS = ${TESTLIB} ${UTILLIB}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001072
Randall Spangler6f1b82a2014-12-03 12:29:37 -08001073${TEST2X_BINS}: ${FWLIB2X}
1074${TEST2X_BINS}: LIBS += ${FWLIB2X}
1075
Randall Spangler108d9912014-12-02 15:55:56 -08001076${TEST20_BINS}: ${FWLIB20}
Randall Spangler6f1b82a2014-12-03 12:29:37 -08001077${TEST20_BINS}: INCLUDES += -Ifirmware/lib20/include
Randall Spangler108d9912014-12-02 15:55:56 -08001078${TEST20_BINS}: LIBS += ${FWLIB20}
1079
1080${TEST21_BINS}: ${UTILLIB21}
1081${TEST21_BINS}: INCLUDES += -Ihost/lib21/include -Ifirmware/lib21/include
1082${TEST21_BINS}: LIBS += ${UTILLIB21}
Randall Spangleraaaff862014-12-01 15:40:08 -08001083
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001084${TESTLIB}: ${TESTLIB_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001085 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001086 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001087 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001088 ${Q}ar qc $@ $^
1089
1090
1091# ----------------------------------------------------------------------------
1092# Generic build rules. LIBS and OBJS can be overridden to tweak the generic
1093# rules for specific targets.
1094
1095${BUILD}/%: ${BUILD}/%.o ${OBJS} ${LIBS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001096 @${PRINTF} " LD $(subst ${BUILD}/,,$@)\n"
Bill Richardson6db8c752013-04-05 13:30:43 -07001097 ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $< ${OBJS} ${LIBS} ${LDLIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001098
1099${BUILD}/%.o: %.c
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001100 @${PRINTF} " CC $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001101 ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1102
Alex Deymoe08ee282014-08-29 01:07:48 -07001103${BUILD}/%.o: ${BUILD}/%.c
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001104 @${PRINTF} " CC $(subst ${BUILD}/,,$@)\n"
Alex Deymoe08ee282014-08-29 01:07:48 -07001105 ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1106
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001107# Rules to recompile a single source file for library and test
1108# TODO: is there a tidier way to do this?
1109${BUILD}/%_for_lib.o: CFLAGS += -DFOR_LIBRARY
1110${BUILD}/%_for_lib.o: %.c
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001111 @${PRINTF} " CC-for-lib $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001112 ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1113
1114${BUILD}/%_for_test.o: CFLAGS += -DFOR_TEST
1115${BUILD}/%_for_test.o: %.c
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001116 @${PRINTF} " CC-for-test $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001117 ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1118
1119# TODO: C++ files don't belong in vboot reference at all. Convert to C.
1120${BUILD}/%.o: %.cc
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001121 @${PRINTF} " CXX $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001122 ${Q}${CXX} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1123
1124# ----------------------------------------------------------------------------
1125# Here are the special tweaks to the generic rules.
1126
Bill Richardsoncfe83a82014-12-04 11:29:57 -08001127# Always create the defaults file, since it depends on input variables
1128.PHONY: ${UTIL_DEFAULTS}
1129${UTIL_DEFAULTS}:
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001130 @${PRINTF} " CREATE $(subst ${BUILD}/,,$@)\n"
Bill Richardsoncfe83a82014-12-04 11:29:57 -08001131 ${Q}rm -f $@
1132 ${Q}mkdir -p $(dir $@)
1133 ${Q}echo '# Generated file. Do not edit.' > $@.tmp
1134 ${Q}echo "DEV_DEBUG_FORCE=${DEV_DEBUG_FORCE}" >> $@.tmp
1135 ${Q}mv -f $@.tmp $@
1136
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001137# Some utilities need external crypto functions
Bill Richardson78299022014-06-20 14:33:00 -07001138CRYPTO_LIBS := $(shell ${PKG_CONFIG} --libs libcrypto)
1139
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001140${BUILD}/utility/dumpRSAPublicKey: LDLIBS += ${CRYPTO_LIBS}
1141${BUILD}/utility/pad_digest_utility: LDLIBS += ${CRYPTO_LIBS}
1142${BUILD}/utility/signature_digest_utility: LDLIBS += ${CRYPTO_LIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001143
1144${BUILD}/host/linktest/main: LDLIBS += ${CRYPTO_LIBS}
1145${BUILD}/tests/vboot_common2_tests: LDLIBS += ${CRYPTO_LIBS}
1146${BUILD}/tests/vboot_common3_tests: LDLIBS += ${CRYPTO_LIBS}
Randall Spangler6f1b82a2014-12-03 12:29:37 -08001147${BUILD}/tests/vb20_common2_tests: LDLIBS += ${CRYPTO_LIBS}
1148${BUILD}/tests/vb20_common3_tests: LDLIBS += ${CRYPTO_LIBS}
Bill Richardsona77541f2014-12-04 19:06:35 -08001149${BUILD}/tests/verify_kernel: LDLIBS += ${CRYPTO_LIBS}
Randall Spangler108d9912014-12-02 15:55:56 -08001150
1151${TEST21_BINS}: LDLIBS += ${CRYPTO_LIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001152
Mike Frysinger0b789c52015-01-15 15:37:59 -05001153LZMA_LIBS := $(shell ${PKG_CONFIG} --libs liblzma)
1154YAML_LIBS := $(shell ${PKG_CONFIG} --libs yaml-0.1)
1155
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001156${BUILD}/utility/bmpblk_utility: LD = ${CXX}
Mike Frysinger0b789c52015-01-15 15:37:59 -05001157${BUILD}/utility/bmpblk_utility: LDLIBS = ${LZMA_LIBS} ${YAML_LIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001158
1159BMPBLK_UTILITY_DEPS = \
1160 ${BUILD}/utility/bmpblk_util.o \
1161 ${BUILD}/utility/image_types.o \
1162 ${BUILD}/utility/eficompress_for_lib.o \
1163 ${BUILD}/utility/efidecompress_for_lib.o
Bill Richardson1912bba2013-04-04 21:08:50 -07001164
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001165${BUILD}/utility/bmpblk_utility: OBJS = ${BMPBLK_UTILITY_DEPS}
1166${BUILD}/utility/bmpblk_utility: ${BMPBLK_UTILITY_DEPS}
Bill Richardson1912bba2013-04-04 21:08:50 -07001167ALL_OBJS += ${BMPBLK_UTILITY_DEPS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001168
1169${BUILD}/utility/bmpblk_font: OBJS += ${BUILD}/utility/image_types.o
1170${BUILD}/utility/bmpblk_font: ${BUILD}/utility/image_types.o
Bill Richardson1912bba2013-04-04 21:08:50 -07001171ALL_OBJS += ${BUILD}/utility/image_types.o
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001172
1173# Allow multiple definitions, so tests can mock functions from other libraries
1174${BUILD}/tests/%: CFLAGS += -Xlinker --allow-multiple-definition
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001175${BUILD}/tests/%: LDLIBS += -lrt -luuid
1176${BUILD}/tests/%: LIBS += ${TESTLIB}
1177
1178${BUILD}/tests/rollback_index2_tests: OBJS += \
1179 ${BUILD}/firmware/lib/rollback_index_for_test.o
1180${BUILD}/tests/rollback_index2_tests: \
1181 ${BUILD}/firmware/lib/rollback_index_for_test.o
Bill Richardson80872db2014-10-03 10:26:11 -07001182TEST_OBJS += ${BUILD}/firmware/lib/rollback_index_for_test.o
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001183
Randall Spanglerc3d488d2013-01-28 16:23:48 -08001184${BUILD}/tests/tlcl_tests: OBJS += \
1185 ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
1186${BUILD}/tests/tlcl_tests: \
1187 ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
Bill Richardson80872db2014-10-03 10:26:11 -07001188TEST_OBJS += ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
Randall Spanglerc3d488d2013-01-28 16:23:48 -08001189
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001190${BUILD}/tests/vboot_audio_tests: OBJS += \
1191 ${BUILD}/firmware/lib/vboot_audio_for_test.o
1192${BUILD}/tests/vboot_audio_tests: \
1193 ${BUILD}/firmware/lib/vboot_audio_for_test.o
Bill Richardson80872db2014-10-03 10:26:11 -07001194TEST_OBJS += ${BUILD}/firmware/lib/vboot_audio_for_test.o
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001195
Bill Richardson339f7e02013-04-05 09:49:24 -07001196TLCL_TEST_BINS = $(addprefix ${BUILD}/,${TLCL_TEST_NAMES})
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001197${TLCL_TEST_BINS}: OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o
1198${TLCL_TEST_BINS}: ${BUILD}/tests/tpm_lite/tlcl_tests.o
Bill Richardson80872db2014-10-03 10:26:11 -07001199TEST_OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001200
Alex Deymoe08ee282014-08-29 01:07:48 -07001201# ----------------------------------------------------------------------------
1202# Here are the special rules that don't fit in the generic rules.
1203
1204# Generates the list of commands defined in futility by running grep in the
1205# source files looking for the DECLARE_FUTIL_COMMAND() macro usage.
1206${FUTIL_STATIC_CMD_LIST}: ${FUTIL_STATIC_SRCS}
1207${FUTIL_CMD_LIST}: ${FUTIL_SRCS}
1208${FUTIL_CMD_LIST} ${FUTIL_STATIC_CMD_LIST}:
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001209 @${PRINTF} " GEN $(subst ${BUILD}/,,$@)\n"
Alex Deymoe08ee282014-08-29 01:07:48 -07001210 ${Q}rm -f $@ $@_t $@_commands
1211 ${Q}mkdir -p ${BUILD}/gen
Bill Richardson779796f2014-09-23 11:47:40 -07001212 ${Q}grep -hoRE '^DECLARE_FUTIL_COMMAND\([^,]+' $^ \
Alex Deymoe08ee282014-08-29 01:07:48 -07001213 | sed 's/DECLARE_FUTIL_COMMAND(\(.*\)/_CMD(\1)/' \
1214 | sort >>$@_commands
Bill Richardsone1486c32014-10-30 17:41:51 -07001215 ${Q}./scripts/getversion.sh >> $@_t
Alex Deymoe08ee282014-08-29 01:07:48 -07001216 ${Q}echo '#define _CMD(NAME) extern const struct' \
1217 'futil_cmd_t __cmd_##NAME;' >> $@_t
1218 ${Q}cat $@_commands >> $@_t
1219 ${Q}echo '#undef _CMD' >> $@_t
1220 ${Q}echo '#define _CMD(NAME) &__cmd_##NAME,' >> $@_t
1221 ${Q}echo 'const struct futil_cmd_t *const futil_cmds[] = {' >> $@_t
1222 ${Q}cat $@_commands >> $@_t
1223 ${Q}echo '0}; /* null-terminated */' >> $@_t
1224 ${Q}echo '#undef _CMD' >> $@_t
1225 ${Q}mv $@_t $@
1226 ${Q}rm -f $@_commands
1227
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001228##############################################################################
1229# Targets that exist just to run tests
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001230
1231# Frequently-run tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001232.PHONY: test_targets
Bill Richardson06eb78c2015-01-27 15:01:51 -08001233test_targets:: runcgpttests runmisctests run2tests
Randall Spangler844bce52013-01-15 16:16:43 -08001234
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001235ifeq (${MINIMAL},)
Randall Spangler844bce52013-01-15 16:16:43 -08001236# Bitmap utility isn't compiled for minimal variant
Bill Richardsonfeb25182013-03-07 12:54:29 -08001237test_targets:: runbmptests runfutiltests
Randall Spangler844bce52013-01-15 16:16:43 -08001238# Scripts don't work under qemu testing
1239# TODO: convert scripts to makefile so they can be called directly
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001240test_targets:: runtestscripts
Randall Spangler844bce52013-01-15 16:16:43 -08001241endif
1242
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001243.PHONY: test_setup
Bill Richardson3e3790d2014-07-14 15:05:54 -07001244test_setup:: cgpt utils futil tests install_for_test
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001245
Randall Spangler844bce52013-01-15 16:16:43 -08001246# Qemu setup for cross-compiled tests. Need to copy qemu binary into the
1247# sysroot.
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001248ifneq (${QEMU_ARCH},)
1249test_setup:: qemu_install
Randall Spangler844bce52013-01-15 16:16:43 -08001250
1251.PHONY: qemu_install
1252qemu_install:
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001253ifeq (${SYSROOT},)
1254 $(error SYSROOT must be set to the top of the target-specific root \
1255when cross-compiling for qemu-based tests to run properly.)
1256endif
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001257 @${PRINTF} " Copying qemu binary.\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001258 ${Q}cp -fu /usr/bin/${QEMU_BIN} ${BUILD}/${QEMU_BIN}
1259 ${Q}chmod a+rx ${BUILD}/${QEMU_BIN}
Randall Spangler844bce52013-01-15 16:16:43 -08001260endif
1261
Bill Richardsonacb2ee92013-01-11 22:53:00 -08001262.PHONY: runtests
Bill Richardsona130e0b2013-04-04 18:16:39 -07001263runtests: test_setup test_targets
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001264
1265# Generate test keys
Bill Richardsonacb2ee92013-01-11 22:53:00 -08001266.PHONY: genkeys
Bill Richardson0840b842015-02-05 12:39:02 -08001267genkeys: utils test_setup
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001268 tests/gen_test_keys.sh
1269
1270# Generate test cases for fuzzing
Bill Richardsonacb2ee92013-01-11 22:53:00 -08001271.PHONY: genfuzztestcases
Bill Richardson0840b842015-02-05 12:39:02 -08001272genfuzztestcases: utils test_setup
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001273 tests/gen_fuzz_test_cases.sh
1274
Bill Richardsonacb2ee92013-01-11 22:53:00 -08001275.PHONY: runbmptests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001276runbmptests: test_setup
1277 cd tests/bitmaps && BMPBLK=${BUILD_RUN}/utility/bmpblk_utility \
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001278 ./TestBmpBlock.py -v
1279
Bill Richardsonacb2ee92013-01-11 22:53:00 -08001280.PHONY: runcgpttests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001281runcgpttests: test_setup
1282 ${RUNTEST} ${BUILD_RUN}/tests/cgptlib_test
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001283
Randall Spangler844bce52013-01-15 16:16:43 -08001284.PHONY: runtestscripts
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001285runtestscripts: test_setup genfuzztestcases
Randall Spanglerb8ff3972014-08-27 13:34:35 -07001286 tests/load_kernel_tests.sh
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001287 tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt
Nam T. Nguyenab899592014-11-13 19:30:46 -08001288 tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt -D 358400
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001289 tests/run_preamble_tests.sh
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001290 tests/run_rsa_tests.sh
Randall Spangler844bce52013-01-15 16:16:43 -08001291 tests/run_vbutil_kernel_arg_tests.sh
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001292 tests/run_vbutil_tests.sh
Randall Spanglere166d042014-05-13 09:24:52 -07001293 tests/vb2_rsa_tests.sh
Randall Spangler539cbc22014-06-18 14:15:04 -07001294 tests/vb2_firmware_tests.sh
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001295
Randall Spangler844bce52013-01-15 16:16:43 -08001296.PHONY: runmisctests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001297runmisctests: test_setup
1298 ${RUNTEST} ${BUILD_RUN}/tests/rollback_index2_tests
Randall Spanglera3eac792013-01-23 13:04:05 -08001299 ${RUNTEST} ${BUILD_RUN}/tests/rollback_index3_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001300 ${RUNTEST} ${BUILD_RUN}/tests/rsa_utility_tests
1301 ${RUNTEST} ${BUILD_RUN}/tests/sha_tests
1302 ${RUNTEST} ${BUILD_RUN}/tests/stateful_util_tests
Randall Spanglerc3d488d2013-01-28 16:23:48 -08001303 ${RUNTEST} ${BUILD_RUN}/tests/tlcl_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001304 ${RUNTEST} ${BUILD_RUN}/tests/tpm_bootmode_tests
1305 ${RUNTEST} ${BUILD_RUN}/tests/utility_string_tests
1306 ${RUNTEST} ${BUILD_RUN}/tests/utility_tests
1307 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_devmode_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001308 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_firmware_tests
Randall Spangler0714d9d2013-02-05 10:23:38 -08001309 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_init_tests
1310 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel_tests
Randall Spangler7f436692013-02-05 12:42:36 -08001311 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel2_tests
1312 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel3_tests
1313 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel4_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001314 ${RUNTEST} ${BUILD_RUN}/tests/vboot_audio_tests
Randall Spanglere061a252013-01-22 15:34:07 -08001315 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common_tests
1316 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS}
1317 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS}
Randall Spangler786a5dc2013-01-24 14:19:56 -08001318 ${RUNTEST} ${BUILD_RUN}/tests/vboot_display_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001319 ${RUNTEST} ${BUILD_RUN}/tests/vboot_firmware_tests
Randall Spangler49cb0d32013-01-29 14:28:16 -08001320 ${RUNTEST} ${BUILD_RUN}/tests/vboot_kernel_tests
Randall Spangler6dbf9d92013-01-23 12:25:10 -08001321 ${RUNTEST} ${BUILD_RUN}/tests/vboot_nvstorage_test
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001322
Randall Spangler786acda2014-05-22 13:27:07 -07001323.PHONY: run2tests
1324run2tests: test_setup
Randall Spanglera7ab8b52014-06-10 17:05:08 -07001325 ${RUNTEST} ${BUILD_RUN}/tests/vb2_api_tests
Randall Spangler786acda2014-05-22 13:27:07 -07001326 ${RUNTEST} ${BUILD_RUN}/tests/vb2_common_tests
Randall Spangler3333e572014-05-14 11:37:52 -07001327 ${RUNTEST} ${BUILD_RUN}/tests/vb2_misc_tests
1328 ${RUNTEST} ${BUILD_RUN}/tests/vb2_nvstorage_tests
Randall Spanglere166d042014-05-13 09:24:52 -07001329 ${RUNTEST} ${BUILD_RUN}/tests/vb2_rsa_utility_tests
Randall Spangler3333e572014-05-14 11:37:52 -07001330 ${RUNTEST} ${BUILD_RUN}/tests/vb2_secdata_tests
Randall Spanglere166d042014-05-13 09:24:52 -07001331 ${RUNTEST} ${BUILD_RUN}/tests/vb2_sha_tests
Randall Spangler6f1b82a2014-12-03 12:29:37 -08001332 ${RUNTEST} ${BUILD_RUN}/tests/vb20_api_tests
1333 ${RUNTEST} ${BUILD_RUN}/tests/vb20_common_tests
1334 ${RUNTEST} ${BUILD_RUN}/tests/vb20_common2_tests ${TEST_KEYS}
1335 ${RUNTEST} ${BUILD_RUN}/tests/vb20_common3_tests ${TEST_KEYS}
1336 ${RUNTEST} ${BUILD_RUN}/tests/vb20_misc_tests
Randall Spangler108d9912014-12-02 15:55:56 -08001337 ${RUNTEST} ${BUILD_RUN}/tests/vb21_api_tests
1338 ${RUNTEST} ${BUILD_RUN}/tests/vb21_common_tests
1339 ${RUNTEST} ${BUILD_RUN}/tests/vb21_common2_tests ${TEST_KEYS}
1340 ${RUNTEST} ${BUILD_RUN}/tests/vb21_misc_tests
1341 ${RUNTEST} ${BUILD_RUN}/tests/vb21_host_fw_preamble_tests ${TEST_KEYS}
1342 ${RUNTEST} ${BUILD_RUN}/tests/vb21_host_key_tests ${TEST_KEYS}
1343 ${RUNTEST} ${BUILD_RUN}/tests/vb21_host_keyblock_tests ${TEST_KEYS}
1344 ${RUNTEST} ${BUILD_RUN}/tests/vb21_host_misc_tests
1345 ${RUNTEST} ${BUILD_RUN}/tests/vb21_host_sig_tests ${TEST_KEYS}
Randall Spangler786acda2014-05-22 13:27:07 -07001346
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001347.PHONY: runfutiltests
Bill Richardson3e3790d2014-07-14 15:05:54 -07001348runfutiltests: test_setup
Bill Richardsonefa87562014-09-11 10:41:51 -07001349 tests/futility/run_test_scripts.sh ${TEST_INSTALL_DIR}/bin
Bill Richardson339f7e02013-04-05 09:49:24 -07001350 ${RUNTEST} ${BUILD_RUN}/tests/futility/test_not_really
Randall Spangler844bce52013-01-15 16:16:43 -08001351
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001352# Run long tests, including all permutations of encryption keys (instead of
Randall Spangler786a5dc2013-01-24 14:19:56 -08001353# just the ones we use) and tests of currently-unused code.
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001354# Not run by automated build.
Bill Richardsonacb2ee92013-01-11 22:53:00 -08001355.PHONY: runlongtests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001356runlongtests: test_setup genkeys genfuzztestcases
Randall Spanglere061a252013-01-22 15:34:07 -08001357 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS} --all
1358 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS} --all
Randall Spangler6f1b82a2014-12-03 12:29:37 -08001359 ${RUNTEST} ${BUILD_RUN}/tests/vb20_common2_tests ${TEST_KEYS} --all
1360 ${RUNTEST} ${BUILD_RUN}/tests/vb20_common3_tests ${TEST_KEYS} --all
Randall Spangler108d9912014-12-02 15:55:56 -08001361 ${RUNTEST} ${BUILD_RUN}/tests/vb21_common2_tests ${TEST_KEYS} --all
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001362 tests/run_preamble_tests.sh --all
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001363 tests/run_vbutil_tests.sh --all
1364
Bill Richardson78d59bf2014-08-27 16:17:04 -07001365# TODO: There were a number of ancient tests that hadn't been run in years.
1366# They were removed with https://chromium-review.googlesource.com/#/c/214610/
1367# Some day it might be nice to see what they were supposed to do.
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001368
Bill Richardson78299022014-06-20 14:33:00 -07001369.PHONY: runalltests
1370runalltests: runtests runfutiltests runlongtests
1371
Randall Spangler59d75082013-01-23 09:29:54 -08001372# Code coverage
1373.PHONY: coverage_init
1374coverage_init: test_setup
1375 rm -f ${COV_INFO}*
1376 lcov -c -i -d . -b . -o ${COV_INFO}.initial
1377
1378.PHONY: coverage_html
1379coverage_html:
1380 lcov -c -d . -b . -o ${COV_INFO}.tests
1381 lcov -a ${COV_INFO}.initial -a ${COV_INFO}.tests -o ${COV_INFO}.total
1382 lcov -r ${COV_INFO}.total '/usr/*' '*/linktest/*' -o ${COV_INFO}.local
1383 genhtml ${COV_INFO}.local -o ${BUILD}/coverage
Bill Richardsond2d08b22014-07-08 16:31:40 -07001384# Generate addtional coverage stats just for firmware subdir, because the stats
1385# for the whole project don't include subdirectory summaries. This will print
1386# the summary for just the firmware sources.
Randall Spangler49cb0d32013-01-29 14:28:16 -08001387 lcov -r ${COV_INFO}.local '*/stub/*' -o ${COV_INFO}.nostub
1388 lcov -e ${COV_INFO}.nostub '${SRCDIR}/firmware/*' \
Randall Spangler59d75082013-01-23 09:29:54 -08001389 -o ${COV_INFO}.firmware
1390
1391.PHONY: coverage
1392ifeq (${COV},)
1393coverage:
1394 $(error Build coverage like this: make clean && COV=1 make)
1395else
1396coverage: coverage_init runtests coverage_html
1397endif
Bill Richardson1912bba2013-04-04 21:08:50 -07001398
1399# Include generated dependencies
1400ALL_DEPS += ${ALL_OBJS:%.o=%.o.d}
Bill Richardson80872db2014-10-03 10:26:11 -07001401TEST_DEPS += ${TEST_OBJS:%.o=%.o.d}
Bill Richardson04d98e32015-01-31 01:14:39 -08001402-include ${ALL_DEPS}
1403-include ${TEST_DEPS}
Bill Richardson80872db2014-10-03 10:26:11 -07001404
1405# We want to use only relative paths in cscope.files, especially since the
1406# paths inside and outside the chroot are different.
1407SRCDIRPAT=$(subst /,\/,${SRCDIR}/)
1408
Bill Richardson8db64da2015-01-29 21:46:58 -08001409# Note: vboot 2.0 is deprecated, so don't index those files
Bill Richardson80872db2014-10-03 10:26:11 -07001410${BUILD}/cscope.files: test_setup
1411 ${Q}rm -f $@
1412 ${Q}cat ${ALL_DEPS} | tr -d ':\\' | tr ' ' '\012' | \
Bill Richardson8db64da2015-01-29 21:46:58 -08001413 grep -v /lib20/ | \
Bill Richardson80872db2014-10-03 10:26:11 -07001414 sed -e "s/${SRCDIRPAT}//" | \
1415 egrep '\.[chS]$$' | sort | uniq > $@
1416
1417cmd_etags = etags -o ${BUILD}/TAGS $(shell cat ${BUILD}/cscope.files)
1418cmd_ctags = ctags -o ${BUILD}/tags $(shell cat ${BUILD}/cscope.files)
1419run_if_prog = $(if $(shell which $(1) 2>/dev/null),$(2),)
1420
1421.PHONY: tags TAGS xrefs
1422tags TAGS xrefs: ${BUILD}/cscope.files
1423 ${Q}\rm -f ${BUILD}/tags ${BUILD}/TAGS
1424 ${Q}$(call run_if_prog,etags,${cmd_etags})
1425 ${Q}$(call run_if_prog,ctags,${cmd_ctags})
Nam T. Nguyen07d90432015-02-17 13:26:44 -08001426
Bill Richardson82212012015-02-27 13:57:13 -08001427PC_FILES = ${PC_IN_FILES:%.pc.in=${BUILD}/%.pc}
Nam T. Nguyen07d90432015-02-17 13:26:44 -08001428${PC_FILES}: ${PC_IN_FILES}
1429 ${Q}sed \
1430 -e 's:@LDLIBS@:${LDLIBS}:' \
1431 -e 's:@LIBDIR@:${LIBDIR}:' \
1432 $< > $@
1433
1434.PHONY: pc_files_install
1435pc_files_install: ${PC_FILES}
1436 ${Q}mkdir -p ${ULP_DIR}
Bill Richardson82212012015-02-27 13:57:13 -08001437 ${Q}${INSTALL} -D -m 0644 $< ${ULP_DIR}/$(notdir $<)