blob: 08049720b7b8d46faa957aa0c2a69ed059ecf55e [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 \
Nam T. Nguyen6ee52d92014-10-24 13:20:39 -0700457 host/lib/fmap.c \
Bill Richardson6f396152014-07-15 12:52:19 -0700458 host/lib/host_misc.c
Bill Richardson78299022014-06-20 14:33:00 -0700459
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800460HOSTLIB_OBJS = ${HOSTLIB_SRCS:%.c=${BUILD}/%.o}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800461ALL_OBJS += ${HOSTLIB_OBJS}
462
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800463# Sigh. For historical reasons, the autoupdate installer must sometimes be a
464# 32-bit executable, even when everything else is 64-bit. But it only needs a
465# few functions, so let's just build those.
466TINYHOSTLIB = ${BUILD}/libtinyvboot_host.a
467
468TINYHOSTLIB_SRCS = \
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800469 cgpt/cgpt_add.c \
470 cgpt/cgpt_boot.c \
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800471 cgpt/cgpt_common.c \
Bill Richardson78299022014-06-20 14:33:00 -0700472 cgpt/cgpt_create.c \
473 cgpt/cgpt_prioritize.c \
Bill Richardson78299022014-06-20 14:33:00 -0700474 firmware/lib/cgptlib/cgptlib_internal.c \
475 firmware/lib/cgptlib/crc32.c \
Dan Ehrenberg32a999d2014-11-21 15:44:05 -0800476 firmware/lib/gpt_misc.c \
Bill Richardson5fed2a62013-03-04 15:11:38 -0800477 firmware/lib/utility_string.c \
Dan Ehrenberg32a999d2014-11-21 15:44:05 -0800478 firmware/stub/vboot_api_stub_disk.c \
479 firmware/stub/vboot_api_stub_sf.c \
Bill Richardson78299022014-06-20 14:33:00 -0700480 firmware/stub/utility_stub.c \
Nam T. Nguyenab899592014-11-13 19:30:46 -0800481 futility/dump_kernel_config_lib.c
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800482
483TINYHOSTLIB_OBJS = ${TINYHOSTLIB_SRCS:%.c=${BUILD}/%.o}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800484
485# ----------------------------------------------------------------------------
486# Now for the userspace binaries
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800487
488CGPT = ${BUILD}/cgpt/cgpt
489
490CGPT_SRCS = \
491 cgpt/cgpt.c \
492 cgpt/cgpt_add.c \
493 cgpt/cgpt_boot.c \
494 cgpt/cgpt_common.c \
495 cgpt/cgpt_create.c \
496 cgpt/cgpt_find.c \
497 cgpt/cgpt_legacy.c \
Nam T. Nguyend1236e42015-01-08 11:43:27 -0800498 cgpt/cgpt_nor.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800499 cgpt/cgpt_prioritize.c \
500 cgpt/cgpt_repair.c \
501 cgpt/cgpt_show.c \
502 cgpt/cmd_add.c \
503 cgpt/cmd_boot.c \
504 cgpt/cmd_create.c \
505 cgpt/cmd_find.c \
506 cgpt/cmd_legacy.c \
507 cgpt/cmd_prioritize.c \
508 cgpt/cmd_repair.c \
Nam T. Nguyen8577b532014-11-25 13:26:53 -0800509 cgpt/cmd_show.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800510
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800511CGPT_OBJS = ${CGPT_SRCS:%.c=${BUILD}/%.o}
Nam T. Nguyend1236e42015-01-08 11:43:27 -0800512
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800513ALL_OBJS += ${CGPT_OBJS}
514
Nam T. Nguyend1236e42015-01-08 11:43:27 -0800515CGPT_WRAPPER = ${BUILD}/cgpt/cgpt_wrapper
516
517CGPT_WRAPPER_SRCS = \
518 cgpt/cgpt_nor.c \
519 cgpt/cgpt_wrapper.c
520
521CGPT_WRAPPER_OBJS = ${CGPT_WRAPPER_SRCS:%.c=${BUILD}/%.o}
522
523ALL_OBJS += ${CGPT_WRAPPER_OBJS}
524
Bill Richardsoncfe83a82014-12-04 11:29:57 -0800525# Utility defaults
526UTIL_DEFAULTS = ${BUILD}/default/vboot_reference
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800527
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800528# Scripts to install directly (not compiled)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800529UTIL_SCRIPTS = \
530 utility/dev_debug_vboot \
Bill Richardson4d49d342014-10-02 10:52:41 -0700531 utility/enable_dev_usb_boot
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800532
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800533ifeq (${MINIMAL},)
534UTIL_SCRIPTS += \
Bill Richardson4d49d342014-10-02 10:52:41 -0700535 utility/dev_make_keypair \
536 utility/vbutil_what_keys
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800537endif
538
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800539# These utilities should be linked statically.
540UTIL_NAMES_STATIC = \
Bill Richardson6f396152014-07-15 12:52:19 -0700541 utility/crossystem
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800542
543UTIL_NAMES = ${UTIL_NAMES_STATIC} \
Bill Richardson339f7e02013-04-05 09:49:24 -0700544 utility/tpm_init_temp_fix \
Duncan Laurie0f078672014-09-19 14:39:09 -0700545 utility/dumpRSAPublicKey \
Bill Richardson6f396152014-07-15 12:52:19 -0700546 utility/tpmc
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800547
Bill Richardson6f396152014-07-15 12:52:19 -0700548# TODO: Do we still need eficompress and efidecompress for anything?
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800549ifeq (${MINIMAL},)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800550UTIL_NAMES += \
Bill Richardson339f7e02013-04-05 09:49:24 -0700551 utility/bmpblk_font \
552 utility/bmpblk_utility \
553 utility/eficompress \
554 utility/efidecompress \
555 utility/load_kernel_test \
556 utility/pad_digest_utility \
557 utility/signature_digest_utility \
558 utility/verify_data
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800559endif
560
Bill Richardson339f7e02013-04-05 09:49:24 -0700561UTIL_BINS_STATIC := $(addprefix ${BUILD}/,${UTIL_NAMES_STATIC})
562UTIL_BINS = $(addprefix ${BUILD}/,${UTIL_NAMES})
Bill Richardson1912bba2013-04-04 21:08:50 -0700563ALL_OBJS += $(addsuffix .o,${UTIL_BINS} ${UTIL_BINS_STATIC})
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800564
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800565
566# Scripts for signing stuff.
567SIGNING_SCRIPTS = \
568 utility/tpm-nvsize \
569 utility/chromeos-tpm-recovery
570
571# These go in a different place.
572SIGNING_SCRIPTS_DEV = \
573 scripts/image_signing/resign_firmwarefd.sh \
574 scripts/image_signing/make_dev_firmware.sh \
575 scripts/image_signing/make_dev_ssd.sh \
576 scripts/image_signing/set_gbb_flags.sh
577
578# Installed, but not made executable.
579SIGNING_COMMON = scripts/image_signing/common_minimal.sh
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800580
Bill Richardson826db092013-01-14 12:37:15 -0800581
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800582# The unified firmware utility will eventually replace all the others
583FUTIL_BIN = ${BUILD}/futility/futility
Bill Richardson6db8c752013-04-05 13:30:43 -0700584# But we still need both static (tiny) and dynamic (with openssl) versions.
585FUTIL_STATIC_BIN = ${FUTIL_BIN}_s
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800586
Bill Richardson6f396152014-07-15 12:52:19 -0700587# These are the executables that are now built in to futility. We'll create
588# symlinks for these so the old names will still work.
Bill Richardsona1d9fe62014-09-05 12:52:27 -0700589FUTIL_SYMLINKS = \
Bill Richardsone1550442014-07-17 11:32:17 -0700590 dump_fmap \
591 dump_kernel_config \
Bill Richardsone1550442014-07-17 11:32:17 -0700592 gbb_utility \
Bill Richardsone1550442014-07-17 11:32:17 -0700593 vbutil_firmware \
594 vbutil_kernel \
595 vbutil_key \
Bill Richardson6f396152014-07-15 12:52:19 -0700596 vbutil_keyblock
Bill Richardsonfeb25182013-03-07 12:54:29 -0800597
Bill Richardson6db8c752013-04-05 13:30:43 -0700598FUTIL_STATIC_SRCS = \
Bill Richardsonfeb25182013-03-07 12:54:29 -0800599 futility/futility.c \
Bill Richardson20807b62013-04-09 10:15:26 -0700600 futility/cmd_dump_fmap.c \
Bill Richardsoncf6e78d2014-08-27 15:50:25 -0700601 futility/cmd_gbb_utility.c \
602 futility/misc.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800603
Bill Richardson6db8c752013-04-05 13:30:43 -0700604FUTIL_SRCS = \
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500605 ${FUTIL_STATIC_SRCS} \
Bill Richardson6f396152014-07-15 12:52:19 -0700606 futility/cmd_dump_kernel_config.c \
Bill Richardson2e25e812014-09-03 11:34:27 -0700607 futility/cmd_load_fmap.c \
Bill Richardsonf4f395e2014-10-22 17:42:20 -0700608 futility/cmd_pcr.c \
Bill Richardsonf318ee22014-09-23 14:30:30 -0700609 futility/cmd_show.c \
610 futility/cmd_sign.c \
Bill Richardson6f396152014-07-15 12:52:19 -0700611 futility/cmd_vbutil_firmware.c \
612 futility/cmd_vbutil_kernel.c \
Bill Richardsonb84b81d2014-07-14 14:48:31 -0700613 futility/cmd_vbutil_key.c \
Randall Spanglerb8ff3972014-08-27 13:34:35 -0700614 futility/cmd_vbutil_keyblock.c \
Bill Richardson25593382015-01-30 12:22:28 -0800615 futility/file_type.c \
Bill Richardsonf318ee22014-09-23 14:30:30 -0700616 futility/traversal.c \
617 futility/vb1_helper.c
Bill Richardson6db8c752013-04-05 13:30:43 -0700618
Alex Deymoe08ee282014-08-29 01:07:48 -0700619# List of commands built in futility and futility_s.
620FUTIL_STATIC_CMD_LIST = ${BUILD}/gen/futility_static_cmds.c
621FUTIL_CMD_LIST = ${BUILD}/gen/futility_cmds.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800622
Bill Richardson91852e72014-11-28 12:28:04 -0800623# Workaround for TODO(crbug.com/437107).
624FUTIL_STATIC_WORKAROUND_SRCS = firmware/stub/vboot_api_stub_static_sf.c
625
Alex Deymoe08ee282014-08-29 01:07:48 -0700626FUTIL_STATIC_OBJS = ${FUTIL_STATIC_SRCS:%.c=${BUILD}/%.o} \
Bill Richardson91852e72014-11-28 12:28:04 -0800627 ${FUTIL_STATIC_WORKAROUND_SRCS:%.c=${BUILD}/%.o} \
Alex Deymoe08ee282014-08-29 01:07:48 -0700628 ${FUTIL_STATIC_CMD_LIST:%.c=%.o}
629FUTIL_OBJS = ${FUTIL_SRCS:%.c=${BUILD}/%.o} ${FUTIL_CMD_LIST:%.c=%.o}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800630
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800631ALL_OBJS += ${FUTIL_OBJS}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800632
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800633
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800634# Library of handy test functions.
635TESTLIB = ${BUILD}/tests/test.a
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800636
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800637TESTLIB_SRCS = \
638 tests/test_common.c \
639 tests/timer_utils.c \
640 tests/crc32_test.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800641
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800642TESTLIB_OBJS = ${TESTLIB_SRCS:%.c=${BUILD}/%.o}
Bill Richardson80872db2014-10-03 10:26:11 -0700643TEST_OBJS += ${TESTLIB_OBJS}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800644
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800645
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800646# And some compiled tests.
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800647TEST_NAMES = \
Bill Richardson339f7e02013-04-05 09:49:24 -0700648 tests/cgptlib_test \
649 tests/rollback_index2_tests \
650 tests/rollback_index3_tests \
651 tests/rsa_padding_test \
652 tests/rsa_utility_tests \
653 tests/rsa_verify_benchmark \
654 tests/sha_benchmark \
655 tests/sha_tests \
656 tests/stateful_util_tests \
657 tests/tlcl_tests \
658 tests/tpm_bootmode_tests \
659 tests/utility_string_tests \
660 tests/utility_tests \
661 tests/vboot_api_init_tests \
662 tests/vboot_api_devmode_tests \
663 tests/vboot_api_firmware_tests \
664 tests/vboot_api_kernel_tests \
665 tests/vboot_api_kernel2_tests \
666 tests/vboot_api_kernel3_tests \
667 tests/vboot_api_kernel4_tests \
668 tests/vboot_audio_tests \
669 tests/vboot_common_tests \
670 tests/vboot_common2_tests \
671 tests/vboot_common3_tests \
672 tests/vboot_display_tests \
673 tests/vboot_firmware_tests \
674 tests/vboot_kernel_tests \
675 tests/vboot_nvstorage_test \
Bill Richardsona77541f2014-12-04 19:06:35 -0800676 tests/verify_kernel \
Bill Richardson6f396152014-07-15 12:52:19 -0700677 tests/futility/binary_editor \
Bill Richardson339f7e02013-04-05 09:49:24 -0700678 tests/futility/test_not_really
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800679
Simon Glass527ba812013-07-25 08:48:47 -0600680ifdef REGION_READ
681TEST_NAMES += tests/vboot_region_tests
682endif
683
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800684TEST2X_NAMES = \
Randall Spanglera7ab8b52014-06-10 17:05:08 -0700685 tests/vb2_api_tests \
Randall Spangler786acda2014-05-22 13:27:07 -0700686 tests/vb2_common_tests \
Randall Spangler3333e572014-05-14 11:37:52 -0700687 tests/vb2_misc_tests \
688 tests/vb2_nvstorage_tests \
Randall Spanglere166d042014-05-13 09:24:52 -0700689 tests/vb2_rsa_utility_tests \
Randall Spangler3333e572014-05-14 11:37:52 -0700690 tests/vb2_secdata_tests \
Randall Spangler108d9912014-12-02 15:55:56 -0800691 tests/vb2_sha_tests
692
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800693TEST20_NAMES = \
694 tests/vb20_api_tests \
695 tests/vb20_common_tests \
696 tests/vb20_common2_tests \
Bill Richardson5fb14632015-01-27 13:59:35 -0800697 tests/vb20_verify_fw.c \
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800698 tests/vb20_common3_tests \
699 tests/vb20_misc_tests \
Bill Richardson5fb14632015-01-27 13:59:35 -0800700 tests/vb20_rsa_padding_tests \
701 tests/vb20_verify_fw
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800702
Randall Spangler108d9912014-12-02 15:55:56 -0800703TEST21_NAMES = \
704 tests/vb21_api_tests \
705 tests/vb21_common_tests \
706 tests/vb21_common2_tests \
707 tests/vb21_misc_tests \
708 tests/vb21_host_fw_preamble_tests \
709 tests/vb21_host_key_tests \
710 tests/vb21_host_keyblock_tests \
711 tests/vb21_host_misc_tests \
712 tests/vb21_host_sig_tests
Randall Spangler786acda2014-05-22 13:27:07 -0700713
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800714TEST_NAMES += ${TEST2X_NAMES} ${TEST20_NAMES} ${TEST21_NAMES}
Randall Spangler786acda2014-05-22 13:27:07 -0700715
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800716# And a few more...
Bill Richardson339f7e02013-04-05 09:49:24 -0700717TLCL_TEST_NAMES = \
718 tests/tpm_lite/tpmtest_earlyextend \
719 tests/tpm_lite/tpmtest_earlynvram \
720 tests/tpm_lite/tpmtest_earlynvram2 \
721 tests/tpm_lite/tpmtest_enable \
722 tests/tpm_lite/tpmtest_fastenable \
723 tests/tpm_lite/tpmtest_globallock \
724 tests/tpm_lite/tpmtest_redefine_unowned \
725 tests/tpm_lite/tpmtest_spaceperm \
726 tests/tpm_lite/tpmtest_testsetup \
727 tests/tpm_lite/tpmtest_timing \
728 tests/tpm_lite/tpmtest_writelimit
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800729
730TEST_NAMES += ${TLCL_TEST_NAMES}
731
Bill Richardson339f7e02013-04-05 09:49:24 -0700732# Finally
733TEST_BINS = $(addprefix ${BUILD}/,${TEST_NAMES})
Bill Richardson80872db2014-10-03 10:26:11 -0700734TEST_OBJS += $(addsuffix .o,${TEST_BINS})
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800735
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800736TEST2X_BINS = $(addprefix ${BUILD}/,${TEST2X_NAMES})
Randall Spangleraaaff862014-12-01 15:40:08 -0800737TEST20_BINS = $(addprefix ${BUILD}/,${TEST20_NAMES})
Randall Spangler108d9912014-12-02 15:55:56 -0800738TEST21_BINS = $(addprefix ${BUILD}/,${TEST21_NAMES})
Randall Spangleraaaff862014-12-01 15:40:08 -0800739
Randall Spanglere061a252013-01-22 15:34:07 -0800740# Directory containing test keys
741TEST_KEYS = ${SRC_RUN}/tests/testkeys
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800742
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800743
744##############################################################################
745# Finally, some targets. High-level ones first.
746
747# Create output directories if necessary. Do this via explicit shell commands
748# so it happens before trying to generate/include dependencies.
749SUBDIRS := firmware host cgpt utility futility tests tests/tpm_lite
750_dir_create := $(foreach d, \
751 $(shell find ${SUBDIRS} -name '*.c' -exec dirname {} \; | sort -u), \
752 $(shell [ -d ${BUILD}/${d} ] || mkdir -p ${BUILD}/${d}))
753
754
755# Default target.
756.PHONY: all
Bill Richardson06eb78c2015-01-27 15:01:51 -0800757all: fwlib fwlib2x fwlib20 fwlib21 \
Randall Spangleraaaff862014-12-01 15:40:08 -0800758 $(if ${FIRMWARE_ARCH},,host_stuff) \
Randall Spangler786acda2014-05-22 13:27:07 -0700759 $(if ${COV},coverage)
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800760
761# Host targets
762.PHONY: host_stuff
Bill Richardson06eb78c2015-01-27 15:01:51 -0800763host_stuff: utillib hostlib cgpt utils futil tests utillib21
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800764
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800765.PHONY: clean
766clean:
767 ${Q}/bin/rm -rf ${BUILD}
768
769.PHONY: install
Nam T. Nguyen07d90432015-02-17 13:26:44 -0800770install: cgpt_install utils_install signing_install futil_install \
771 pc_files_install
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800772
Nam T. Nguyend1236e42015-01-08 11:43:27 -0800773.PHONY: install_mtd
774install_mtd: install cgpt_wrapper_install
775
Bill Richardson3e3790d2014-07-14 15:05:54 -0700776.PHONY: install_for_test
777install_for_test: override DESTDIR = ${TEST_INSTALL_DIR}
778install_for_test: install
779
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800780# Don't delete intermediate object files
781.SECONDARY:
782
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800783# ----------------------------------------------------------------------------
784# Firmware library
785
786# TPM-specific flags. These depend on the particular TPM we're targeting for.
787# They are needed here only for compiling parts of the firmware code into
788# user-level tests.
789
790# TPM_BLOCKING_CONTINUESELFTEST is defined if TPM_ContinueSelfTest blocks until
791# the self test has completed.
792
Randall Spangler45cc0f22013-01-25 09:34:26 -0800793${FWLIB_OBJS}: CFLAGS += -DTPM_BLOCKING_CONTINUESELFTEST
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800794
795# TPM_MANUAL_SELFTEST is defined if the self test must be started manually
796# (with a call to TPM_ContinueSelfTest) instead of starting automatically at
797# power on.
798#
799# We sincerely hope that TPM_BLOCKING_CONTINUESELFTEST and TPM_MANUAL_SELFTEST
800# are not both defined at the same time. (See comment in code.)
801
802# CFLAGS += -DTPM_MANUAL_SELFTEST
803
804ifeq (${FIRMWARE_ARCH},i386)
805# Unrolling loops in cryptolib makes it faster
Randall Spangler45cc0f22013-01-25 09:34:26 -0800806${FWLIB_OBJS}: CFLAGS += -DUNROLL_LOOPS
Bill Richardson06eb78c2015-01-27 15:01:51 -0800807${FWLIB2X_OBJS}: CFLAGS += -DUNROLL_LOOPS
Randall Spangleraaaff862014-12-01 15:40:08 -0800808${FWLIB20_OBJS}: CFLAGS += -DUNROLL_LOOPS
Randall Spanglera5b69b02014-12-02 13:41:29 -0800809${FWLIB21_OBJS}: CFLAGS += -DUNROLL_LOOPS
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800810
811# Workaround for coreboot on x86, which will power off asynchronously
812# without giving us a chance to react. This is not an example of the Right
813# Way to do things. See chrome-os-partner:7689, and the commit message
814# that made this change.
Randall Spangler45cc0f22013-01-25 09:34:26 -0800815${FWLIB_OBJS}: CFLAGS += -DSAVE_LOCALE_IMMEDIATELY
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800816
817# On x86 we don't actually read the GBB data into RAM until it is needed.
818# Therefore it makes sense to cache it rather than reading it each time.
819# Enable this feature.
Randall Spangler45cc0f22013-01-25 09:34:26 -0800820${FWLIB_OBJS}: CFLAGS += -DCOPY_BMP_DATA
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800821endif
822
Simon Glass527ba812013-07-25 08:48:47 -0600823ifdef REGION_READ
824${FWLIB_OBJS}: CFLAGS += -DREGION_READ
825endif
826
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800827ifeq (${FIRMWARE_ARCH},)
828# Disable rollback TPM when compiling locally, since otherwise
829# load_kernel_test attempts to talk to the TPM.
Randall Spangler45cc0f22013-01-25 09:34:26 -0800830${FWLIB_OBJS}: CFLAGS += -DDISABLE_ROLLBACK_TPM
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800831endif
832
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800833${FWLIB20_OBJS}: INCLUDES += -Ifirmware/lib20/include
Randall Spangler108d9912014-12-02 15:55:56 -0800834${FWLIB21_OBJS}: INCLUDES += -Ifirmware/lib21/include
835
Bill Richardsona130e0b2013-04-04 18:16:39 -0700836# Linktest ensures firmware lib doesn't rely on outside libraries
837${BUILD}/firmware/linktest/main_vbinit: ${VBINIT_OBJS}
Randall Spangler93943262013-02-26 11:03:57 -0800838${BUILD}/firmware/linktest/main_vbinit: OBJS = ${VBINIT_OBJS}
Bill Richardson80872db2014-10-03 10:26:11 -0700839TEST_OBJS += ${BUILD}/firmware/linktest/main_vbinit.o
Bill Richardsona130e0b2013-04-04 18:16:39 -0700840${BUILD}/firmware/linktest/main_vbsf: ${VBSF_OBJS}
Randall Spangler93943262013-02-26 11:03:57 -0800841${BUILD}/firmware/linktest/main_vbsf: OBJS = ${VBSF_OBJS}
Bill Richardson80872db2014-10-03 10:26:11 -0700842TEST_OBJS += ${BUILD}/firmware/linktest/main_vbsf.o
Bill Richardsona130e0b2013-04-04 18:16:39 -0700843${BUILD}/firmware/linktest/main: ${FWLIB}
844${BUILD}/firmware/linktest/main: LIBS = ${FWLIB}
Bill Richardson80872db2014-10-03 10:26:11 -0700845TEST_OBJS += ${BUILD}/firmware/linktest/main.o
Randall Spangler93943262013-02-26 11:03:57 -0800846
Bill Richardsond2d08b22014-07-08 16:31:40 -0700847.PHONY: fwlinktest
848fwlinktest: \
Randall Spangler93943262013-02-26 11:03:57 -0800849 ${BUILD}/firmware/linktest/main_vbinit \
850 ${BUILD}/firmware/linktest/main_vbsf \
851 ${BUILD}/firmware/linktest/main
852
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800853.PHONY: fwlib
Bill Richardsona130e0b2013-04-04 18:16:39 -0700854fwlib: $(if ${FIRMWARE_ARCH},${FWLIB},fwlinktest)
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800855
856${FWLIB}: ${FWLIB_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500857 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800858 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500859 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800860 ${Q}ar qc $@ $^
861
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800862.PHONY: fwlib2x
863fwlib2x: ${FWLIB2X}
864
Bill Richardson06eb78c2015-01-27 15:01:51 -0800865${FWLIB2X}: ${FWLIB2X_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500866 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800867 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500868 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800869 ${Q}ar qc $@ $^
870
Bill Richardson06eb78c2015-01-27 15:01:51 -0800871.PHONY: fwlib20
872fwlib20: ${FWLIB20}
Randall Spanglera5b69b02014-12-02 13:41:29 -0800873
Bill Richardson06eb78c2015-01-27 15:01:51 -0800874${FWLIB20}: ${FWLIB2X_OBJS} ${FWLIB20_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500875 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Randall Spangler786acda2014-05-22 13:27:07 -0700876 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500877 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Randall Spangler786acda2014-05-22 13:27:07 -0700878 ${Q}ar qc $@ $^
879
Randall Spanglera5b69b02014-12-02 13:41:29 -0800880.PHONY: fwlib21
881fwlib21: ${FWLIB21}
882
Bill Richardson06eb78c2015-01-27 15:01:51 -0800883${FWLIB21}: ${FWLIB2X_OBJS} ${FWLIB21_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500884 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Randall Spanglera5b69b02014-12-02 13:41:29 -0800885 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500886 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Randall Spanglera5b69b02014-12-02 13:41:29 -0800887 ${Q}ar qc $@ $^
888
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800889# ----------------------------------------------------------------------------
Bill Richardson78299022014-06-20 14:33:00 -0700890# Host library(s)
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800891
Bill Richardson78299022014-06-20 14:33:00 -0700892# Link tests for local utilities
893${BUILD}/host/linktest/main: ${UTILLIB}
Bill Richardson78299022014-06-20 14:33:00 -0700894${BUILD}/host/linktest/main: LIBS = ${UTILLIB}
Bill Richardson80872db2014-10-03 10:26:11 -0700895TEST_OBJS += ${BUILD}/host/linktest/main.o
Bill Richardson78299022014-06-20 14:33:00 -0700896
897.PHONY: utillib
898utillib: ${UTILLIB} \
899 ${BUILD}/host/linktest/main
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800900
901# TODO: better way to make .a than duplicating this recipe each time?
Randall Spangleraaaff862014-12-01 15:40:08 -0800902${UTILLIB}: ${UTILLIB_OBJS} ${FWLIB_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500903 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Randall Spangleraaaff862014-12-01 15:40:08 -0800904 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500905 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Randall Spangleraaaff862014-12-01 15:40:08 -0800906 ${Q}ar qc $@ $^
907
Randall Spanglera5b69b02014-12-02 13:41:29 -0800908.PHONY: utillib21
909utillib21: ${UTILLIB21}
Randall Spangleraaaff862014-12-01 15:40:08 -0800910
Randall Spangler108d9912014-12-02 15:55:56 -0800911${UTILLIB21}: INCLUDES += -Ihost/lib21/include -Ifirmware/lib21/include
Bill Richardson06eb78c2015-01-27 15:01:51 -0800912${UTILLIB21}: ${UTILLIB21_OBJS} ${FWLIB2X_OBJS} ${FWLIB21_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500913 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardson78299022014-06-20 14:33:00 -0700914 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500915 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardson78299022014-06-20 14:33:00 -0700916 ${Q}ar qc $@ $^
917
918
919# Link tests for external repos
920${BUILD}/host/linktest/extern: ${HOSTLIB}
Bill Richardson78299022014-06-20 14:33:00 -0700921${BUILD}/host/linktest/extern: LIBS = ${HOSTLIB}
922${BUILD}/host/linktest/extern: LDLIBS += -static
Bill Richardson80872db2014-10-03 10:26:11 -0700923TEST_OBJS += ${BUILD}/host/linktest/extern.o
Bill Richardson78299022014-06-20 14:33:00 -0700924
925.PHONY: hostlib
926hostlib: ${HOSTLIB} \
927 ${BUILD}/host/linktest/extern
928
929# TODO: better way to make .a than duplicating this recipe each time?
Bill Richardson78299022014-06-20 14:33:00 -0700930${HOSTLIB}: ${HOSTLIB_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500931 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800932 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500933 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800934 ${Q}ar qc $@ $^
935
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800936
937# Ugh. This is a very cut-down version of HOSTLIB just for the installer.
938.PHONY: tinyhostlib
939tinyhostlib: ${TINYHOSTLIB}
940 ${Q}cp -f ${TINYHOSTLIB} ${HOSTLIB}
941
942${TINYHOSTLIB}: ${TINYHOSTLIB_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500943 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800944 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500945 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800946 ${Q}ar qc $@ $^
947
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800948# ----------------------------------------------------------------------------
949# CGPT library and utility
950
Nam T. Nguyend1236e42015-01-08 11:43:27 -0800951.PHONY: cgpt_wrapper
952cgpt_wrapper: ${CGPT_WRAPPER}
953
954${CGPT_WRAPPER}: ${CGPT_WRAPPER_OBJS} ${UTILLIB}
955 @$(PRINTF) " LD $(subst ${BUILD}/,,$@)\n"
956 ${Q}${LD} -o ${CGPT_WRAPPER} ${CFLAGS} $^
957
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800958.PHONY: cgpt
Nam T. Nguyend1236e42015-01-08 11:43:27 -0800959cgpt: ${CGPT} ${CGPT_WRAPPER}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800960
961${CGPT}: LDFLAGS += -static
962${CGPT}: LDLIBS += -luuid
963
Bill Richardson78299022014-06-20 14:33:00 -0700964${CGPT}: ${CGPT_OBJS} ${UTILLIB}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500965 @${PRINTF} " LDcgpt $(subst ${BUILD}/,,$@)\n"
Bill Richardson6db8c752013-04-05 13:30:43 -0700966 ${Q}${LD} -o ${CGPT} ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800967
968.PHONY: cgpt_install
969cgpt_install: ${CGPT}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500970 @${PRINTF} " INSTALL CGPT\n"
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800971 ${Q}mkdir -p ${UB_DIR}
972 ${Q}${INSTALL} -t ${UB_DIR} $^
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800973
Nam T. Nguyend1236e42015-01-08 11:43:27 -0800974.PHONY: cgpt_wrapper_install
975cgpt_wrapper_install: cgpt_install ${CGPT_WRAPPER}
976 @$(PRINTF) " INSTALL cgpt_wrapper\n"
977 ${Q}${INSTALL} -t ${UB_DIR} ${CGPT_WRAPPER}
978 ${Q}mv ${UB_DIR}/$(notdir ${CGPT}) \
979 ${UB_DIR}/$(notdir ${CGPT}).bin
980 ${Q}mv ${UB_DIR}/$(notdir ${CGPT_WRAPPER}) \
981 ${UB_DIR}/$(notdir ${CGPT})
982
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800983# ----------------------------------------------------------------------------
984# Utilities
985
986# These have their own headers too.
Bill Richardson0f6679e2014-07-10 15:49:52 -0700987${BUILD}/utility/%: INCLUDES += -Iutility/include
988
989${UTIL_BINS} ${UTIL_BINS_STATIC}: ${UTILLIB}
990${UTIL_BINS} ${UTIL_BINS_STATIC}: LIBS = ${UTILLIB}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800991
992# Utilities for auto-update toolkits must be statically linked.
993${UTIL_BINS_STATIC}: LDFLAGS += -static
994
Bill Richardsona130e0b2013-04-04 18:16:39 -0700995
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800996.PHONY: utils
Bill Richardsonc7c6e5d2013-02-28 10:10:29 -0800997utils: ${UTIL_BINS} ${UTIL_SCRIPTS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800998 ${Q}cp -f ${UTIL_SCRIPTS} ${BUILD}/utility
999 ${Q}chmod a+rx $(patsubst %,${BUILD}/%,${UTIL_SCRIPTS})
1000
1001.PHONY: utils_install
Bill Richardsoncfe83a82014-12-04 11:29:57 -08001002utils_install: ${UTIL_BINS} ${UTIL_SCRIPTS} ${UTIL_DEFAULTS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001003 @${PRINTF} " INSTALL UTILS\n"
Bill Richardsonc9bf3482013-02-13 14:38:29 -08001004 ${Q}mkdir -p ${UB_DIR}
1005 ${Q}${INSTALL} -t ${UB_DIR} ${UTIL_BINS} ${UTIL_SCRIPTS}
Bill Richardsoncfe83a82014-12-04 11:29:57 -08001006 ${Q}mkdir -p ${DF_DIR}
1007 ${Q}${INSTALL} -t ${DF_DIR} -m 'u=rw,go=r,a-s' ${UTIL_DEFAULTS}
Bill Richardsonc9bf3482013-02-13 14:38:29 -08001008
1009# And some signing stuff for the target
1010.PHONY: signing_install
1011signing_install: ${SIGNING_SCRIPTS} ${SIGNING_SCRIPTS_DEV} ${SIGNING_COMMON}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001012 @${PRINTF} " INSTALL SIGNING\n"
Bill Richardson6f396152014-07-15 12:52:19 -07001013 ${Q}mkdir -p ${UB_DIR} ${VB_DIR}
Bill Richardsonc9bf3482013-02-13 14:38:29 -08001014 ${Q}${INSTALL} -t ${UB_DIR} ${SIGNING_SCRIPTS}
Bill Richardson6f396152014-07-15 12:52:19 -07001015 ${Q}${INSTALL} -t ${VB_DIR} ${SIGNING_SCRIPTS_DEV}
1016 ${Q}${INSTALL} -t ${VB_DIR} -m 'u=rw,go=r,a-s' ${SIGNING_COMMON}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001017
1018# ----------------------------------------------------------------------------
1019# new Firmware Utility
1020
1021.PHONY: futil
Bill Richardson6db8c752013-04-05 13:30:43 -07001022futil: ${FUTIL_STATIC_BIN} ${FUTIL_BIN}
1023
Bill Richardson06eb78c2015-01-27 15:01:51 -08001024${FUTIL_STATIC_BIN}: ${FUTIL_STATIC_OBJS} ${UTILLIB}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001025 @${PRINTF} " LD $(subst ${BUILD}/,,$@)\n"
Bill Richardson6db8c752013-04-05 13:30:43 -07001026 ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} -static $^ ${LDLIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001027
Bill Richardsonb84b81d2014-07-14 14:48:31 -07001028${FUTIL_BIN}: LDLIBS += ${CRYPTO_LIBS}
Bill Richardson06eb78c2015-01-27 15:01:51 -08001029${FUTIL_BIN}: ${FUTIL_OBJS} ${UTILLIB}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001030 @${PRINTF} " LD $(subst ${BUILD}/,,$@)\n"
Bill Richardson6db8c752013-04-05 13:30:43 -07001031 ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001032
1033.PHONY: futil_install
Bill Richardsonefa87562014-09-11 10:41:51 -07001034futil_install: ${FUTIL_BIN} ${FUTIL_STATIC_BIN}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001035 @${PRINTF} " INSTALL futility\n"
Bill Richardson6f396152014-07-15 12:52:19 -07001036 ${Q}mkdir -p ${UB_DIR}
1037 ${Q}${INSTALL} -t ${UB_DIR} ${FUTIL_BIN} ${FUTIL_STATIC_BIN}
Bill Richardsona1d9fe62014-09-05 12:52:27 -07001038 ${Q}for prog in ${FUTIL_SYMLINKS}; do \
Bill Richardson6f396152014-07-15 12:52:19 -07001039 ln -sf futility "${UB_DIR}/$$prog"; done
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001040
1041# ----------------------------------------------------------------------------
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001042# Utility to generate TLCL structure definition header file.
1043
1044${BUILD}/utility/tlcl_generator: CFLAGS += -fpack-struct
1045
1046STRUCTURES_TMP=${BUILD}/tlcl_structures.tmp
1047STRUCTURES_SRC=firmware/lib/tpm_lite/include/tlcl_structures.h
1048
1049.PHONY: update_tlcl_structures
1050update_tlcl_structures: ${BUILD}/utility/tlcl_generator
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001051 @${PRINTF} " Rebuilding TLCL structures\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001052 ${Q}${BUILD}/utility/tlcl_generator > ${STRUCTURES_TMP}
1053 ${Q}cmp -s ${STRUCTURES_TMP} ${STRUCTURES_SRC} || \
1054 ( echo "%% Updating structures.h %%" && \
1055 cp ${STRUCTURES_TMP} ${STRUCTURES_SRC} )
1056
1057# ----------------------------------------------------------------------------
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001058# Tests
1059
1060.PHONY: tests
1061tests: ${TEST_BINS}
1062
Bill Richardson78299022014-06-20 14:33:00 -07001063${TEST_BINS}: ${UTILLIB} ${TESTLIB}
Bill Richardson339f7e02013-04-05 09:49:24 -07001064${TEST_BINS}: INCLUDES += -Itests
Randall Spanglerefa37b82014-11-12 16:20:50 -08001065${TEST_BINS}: LIBS = ${TESTLIB} ${UTILLIB}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001066
Randall Spangler6f1b82a2014-12-03 12:29:37 -08001067${TEST2X_BINS}: ${FWLIB2X}
1068${TEST2X_BINS}: LIBS += ${FWLIB2X}
1069
Randall Spangler108d9912014-12-02 15:55:56 -08001070${TEST20_BINS}: ${FWLIB20}
Randall Spangler6f1b82a2014-12-03 12:29:37 -08001071${TEST20_BINS}: INCLUDES += -Ifirmware/lib20/include
Randall Spangler108d9912014-12-02 15:55:56 -08001072${TEST20_BINS}: LIBS += ${FWLIB20}
1073
1074${TEST21_BINS}: ${UTILLIB21}
1075${TEST21_BINS}: INCLUDES += -Ihost/lib21/include -Ifirmware/lib21/include
1076${TEST21_BINS}: LIBS += ${UTILLIB21}
Randall Spangleraaaff862014-12-01 15:40:08 -08001077
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001078${TESTLIB}: ${TESTLIB_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001079 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001080 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001081 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001082 ${Q}ar qc $@ $^
1083
1084
1085# ----------------------------------------------------------------------------
1086# Generic build rules. LIBS and OBJS can be overridden to tweak the generic
1087# rules for specific targets.
1088
1089${BUILD}/%: ${BUILD}/%.o ${OBJS} ${LIBS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001090 @${PRINTF} " LD $(subst ${BUILD}/,,$@)\n"
Bill Richardson6db8c752013-04-05 13:30:43 -07001091 ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $< ${OBJS} ${LIBS} ${LDLIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001092
1093${BUILD}/%.o: %.c
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001094 @${PRINTF} " CC $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001095 ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1096
Alex Deymoe08ee282014-08-29 01:07:48 -07001097${BUILD}/%.o: ${BUILD}/%.c
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001098 @${PRINTF} " CC $(subst ${BUILD}/,,$@)\n"
Alex Deymoe08ee282014-08-29 01:07:48 -07001099 ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1100
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001101# Rules to recompile a single source file for library and test
1102# TODO: is there a tidier way to do this?
1103${BUILD}/%_for_lib.o: CFLAGS += -DFOR_LIBRARY
1104${BUILD}/%_for_lib.o: %.c
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001105 @${PRINTF} " CC-for-lib $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001106 ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1107
1108${BUILD}/%_for_test.o: CFLAGS += -DFOR_TEST
1109${BUILD}/%_for_test.o: %.c
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001110 @${PRINTF} " CC-for-test $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001111 ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1112
1113# TODO: C++ files don't belong in vboot reference at all. Convert to C.
1114${BUILD}/%.o: %.cc
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001115 @${PRINTF} " CXX $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001116 ${Q}${CXX} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1117
1118# ----------------------------------------------------------------------------
1119# Here are the special tweaks to the generic rules.
1120
Bill Richardsoncfe83a82014-12-04 11:29:57 -08001121# Always create the defaults file, since it depends on input variables
1122.PHONY: ${UTIL_DEFAULTS}
1123${UTIL_DEFAULTS}:
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001124 @${PRINTF} " CREATE $(subst ${BUILD}/,,$@)\n"
Bill Richardsoncfe83a82014-12-04 11:29:57 -08001125 ${Q}rm -f $@
1126 ${Q}mkdir -p $(dir $@)
1127 ${Q}echo '# Generated file. Do not edit.' > $@.tmp
1128 ${Q}echo "DEV_DEBUG_FORCE=${DEV_DEBUG_FORCE}" >> $@.tmp
1129 ${Q}mv -f $@.tmp $@
1130
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001131# Some utilities need external crypto functions
Bill Richardson78299022014-06-20 14:33:00 -07001132CRYPTO_LIBS := $(shell ${PKG_CONFIG} --libs libcrypto)
1133
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001134${BUILD}/utility/dumpRSAPublicKey: LDLIBS += ${CRYPTO_LIBS}
1135${BUILD}/utility/pad_digest_utility: LDLIBS += ${CRYPTO_LIBS}
1136${BUILD}/utility/signature_digest_utility: LDLIBS += ${CRYPTO_LIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001137
1138${BUILD}/host/linktest/main: LDLIBS += ${CRYPTO_LIBS}
1139${BUILD}/tests/vboot_common2_tests: LDLIBS += ${CRYPTO_LIBS}
1140${BUILD}/tests/vboot_common3_tests: LDLIBS += ${CRYPTO_LIBS}
Randall Spangler6f1b82a2014-12-03 12:29:37 -08001141${BUILD}/tests/vb20_common2_tests: LDLIBS += ${CRYPTO_LIBS}
1142${BUILD}/tests/vb20_common3_tests: LDLIBS += ${CRYPTO_LIBS}
Bill Richardsona77541f2014-12-04 19:06:35 -08001143${BUILD}/tests/verify_kernel: LDLIBS += ${CRYPTO_LIBS}
Randall Spangler108d9912014-12-02 15:55:56 -08001144
1145${TEST21_BINS}: LDLIBS += ${CRYPTO_LIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001146
Mike Frysinger0b789c52015-01-15 15:37:59 -05001147LZMA_LIBS := $(shell ${PKG_CONFIG} --libs liblzma)
1148YAML_LIBS := $(shell ${PKG_CONFIG} --libs yaml-0.1)
1149
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001150${BUILD}/utility/bmpblk_utility: LD = ${CXX}
Mike Frysinger0b789c52015-01-15 15:37:59 -05001151${BUILD}/utility/bmpblk_utility: LDLIBS = ${LZMA_LIBS} ${YAML_LIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001152
1153BMPBLK_UTILITY_DEPS = \
1154 ${BUILD}/utility/bmpblk_util.o \
1155 ${BUILD}/utility/image_types.o \
1156 ${BUILD}/utility/eficompress_for_lib.o \
1157 ${BUILD}/utility/efidecompress_for_lib.o
Bill Richardson1912bba2013-04-04 21:08:50 -07001158
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001159${BUILD}/utility/bmpblk_utility: OBJS = ${BMPBLK_UTILITY_DEPS}
1160${BUILD}/utility/bmpblk_utility: ${BMPBLK_UTILITY_DEPS}
Bill Richardson1912bba2013-04-04 21:08:50 -07001161ALL_OBJS += ${BMPBLK_UTILITY_DEPS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001162
1163${BUILD}/utility/bmpblk_font: OBJS += ${BUILD}/utility/image_types.o
1164${BUILD}/utility/bmpblk_font: ${BUILD}/utility/image_types.o
Bill Richardson1912bba2013-04-04 21:08:50 -07001165ALL_OBJS += ${BUILD}/utility/image_types.o
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001166
1167# Allow multiple definitions, so tests can mock functions from other libraries
1168${BUILD}/tests/%: CFLAGS += -Xlinker --allow-multiple-definition
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001169${BUILD}/tests/%: LDLIBS += -lrt -luuid
1170${BUILD}/tests/%: LIBS += ${TESTLIB}
1171
1172${BUILD}/tests/rollback_index2_tests: OBJS += \
1173 ${BUILD}/firmware/lib/rollback_index_for_test.o
1174${BUILD}/tests/rollback_index2_tests: \
1175 ${BUILD}/firmware/lib/rollback_index_for_test.o
Bill Richardson80872db2014-10-03 10:26:11 -07001176TEST_OBJS += ${BUILD}/firmware/lib/rollback_index_for_test.o
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001177
Randall Spanglerc3d488d2013-01-28 16:23:48 -08001178${BUILD}/tests/tlcl_tests: OBJS += \
1179 ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
1180${BUILD}/tests/tlcl_tests: \
1181 ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
Bill Richardson80872db2014-10-03 10:26:11 -07001182TEST_OBJS += ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
Randall Spanglerc3d488d2013-01-28 16:23:48 -08001183
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001184${BUILD}/tests/vboot_audio_tests: OBJS += \
1185 ${BUILD}/firmware/lib/vboot_audio_for_test.o
1186${BUILD}/tests/vboot_audio_tests: \
1187 ${BUILD}/firmware/lib/vboot_audio_for_test.o
Bill Richardson80872db2014-10-03 10:26:11 -07001188TEST_OBJS += ${BUILD}/firmware/lib/vboot_audio_for_test.o
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001189
Bill Richardson339f7e02013-04-05 09:49:24 -07001190TLCL_TEST_BINS = $(addprefix ${BUILD}/,${TLCL_TEST_NAMES})
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001191${TLCL_TEST_BINS}: OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o
1192${TLCL_TEST_BINS}: ${BUILD}/tests/tpm_lite/tlcl_tests.o
Bill Richardson80872db2014-10-03 10:26:11 -07001193TEST_OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001194
Alex Deymoe08ee282014-08-29 01:07:48 -07001195# ----------------------------------------------------------------------------
1196# Here are the special rules that don't fit in the generic rules.
1197
1198# Generates the list of commands defined in futility by running grep in the
1199# source files looking for the DECLARE_FUTIL_COMMAND() macro usage.
1200${FUTIL_STATIC_CMD_LIST}: ${FUTIL_STATIC_SRCS}
1201${FUTIL_CMD_LIST}: ${FUTIL_SRCS}
1202${FUTIL_CMD_LIST} ${FUTIL_STATIC_CMD_LIST}:
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001203 @${PRINTF} " GEN $(subst ${BUILD}/,,$@)\n"
Alex Deymoe08ee282014-08-29 01:07:48 -07001204 ${Q}rm -f $@ $@_t $@_commands
1205 ${Q}mkdir -p ${BUILD}/gen
Bill Richardson779796f2014-09-23 11:47:40 -07001206 ${Q}grep -hoRE '^DECLARE_FUTIL_COMMAND\([^,]+' $^ \
Alex Deymoe08ee282014-08-29 01:07:48 -07001207 | sed 's/DECLARE_FUTIL_COMMAND(\(.*\)/_CMD(\1)/' \
1208 | sort >>$@_commands
Bill Richardsone1486c32014-10-30 17:41:51 -07001209 ${Q}./scripts/getversion.sh >> $@_t
Alex Deymoe08ee282014-08-29 01:07:48 -07001210 ${Q}echo '#define _CMD(NAME) extern const struct' \
1211 'futil_cmd_t __cmd_##NAME;' >> $@_t
1212 ${Q}cat $@_commands >> $@_t
1213 ${Q}echo '#undef _CMD' >> $@_t
1214 ${Q}echo '#define _CMD(NAME) &__cmd_##NAME,' >> $@_t
1215 ${Q}echo 'const struct futil_cmd_t *const futil_cmds[] = {' >> $@_t
1216 ${Q}cat $@_commands >> $@_t
1217 ${Q}echo '0}; /* null-terminated */' >> $@_t
1218 ${Q}echo '#undef _CMD' >> $@_t
1219 ${Q}mv $@_t $@
1220 ${Q}rm -f $@_commands
1221
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001222##############################################################################
1223# Targets that exist just to run tests
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001224
1225# Frequently-run tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001226.PHONY: test_targets
Bill Richardson06eb78c2015-01-27 15:01:51 -08001227test_targets:: runcgpttests runmisctests run2tests
Randall Spangler844bce52013-01-15 16:16:43 -08001228
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001229ifeq (${MINIMAL},)
Randall Spangler844bce52013-01-15 16:16:43 -08001230# Bitmap utility isn't compiled for minimal variant
Bill Richardsonfeb25182013-03-07 12:54:29 -08001231test_targets:: runbmptests runfutiltests
Randall Spangler844bce52013-01-15 16:16:43 -08001232# Scripts don't work under qemu testing
1233# TODO: convert scripts to makefile so they can be called directly
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001234test_targets:: runtestscripts
Randall Spangler844bce52013-01-15 16:16:43 -08001235endif
1236
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001237.PHONY: test_setup
Bill Richardson3e3790d2014-07-14 15:05:54 -07001238test_setup:: cgpt utils futil tests install_for_test
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001239
Randall Spangler844bce52013-01-15 16:16:43 -08001240# Qemu setup for cross-compiled tests. Need to copy qemu binary into the
1241# sysroot.
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001242ifneq (${QEMU_ARCH},)
1243test_setup:: qemu_install
Randall Spangler844bce52013-01-15 16:16:43 -08001244
1245.PHONY: qemu_install
1246qemu_install:
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001247ifeq (${SYSROOT},)
1248 $(error SYSROOT must be set to the top of the target-specific root \
1249when cross-compiling for qemu-based tests to run properly.)
1250endif
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001251 @${PRINTF} " Copying qemu binary.\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001252 ${Q}cp -fu /usr/bin/${QEMU_BIN} ${BUILD}/${QEMU_BIN}
1253 ${Q}chmod a+rx ${BUILD}/${QEMU_BIN}
Randall Spangler844bce52013-01-15 16:16:43 -08001254endif
1255
Bill Richardsonacb2ee92013-01-11 22:53:00 -08001256.PHONY: runtests
Bill Richardsona130e0b2013-04-04 18:16:39 -07001257runtests: test_setup test_targets
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001258
1259# Generate test keys
Bill Richardsonacb2ee92013-01-11 22:53:00 -08001260.PHONY: genkeys
Randall Spangler844bce52013-01-15 16:16:43 -08001261genkeys: utils
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001262 tests/gen_test_keys.sh
1263
1264# Generate test cases for fuzzing
Bill Richardsonacb2ee92013-01-11 22:53:00 -08001265.PHONY: genfuzztestcases
Randall Spanglera808dc92013-01-14 12:59:05 -08001266genfuzztestcases: utils
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001267 tests/gen_fuzz_test_cases.sh
1268
Bill Richardsonacb2ee92013-01-11 22:53:00 -08001269.PHONY: runbmptests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001270runbmptests: test_setup
1271 cd tests/bitmaps && BMPBLK=${BUILD_RUN}/utility/bmpblk_utility \
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001272 ./TestBmpBlock.py -v
1273
Bill Richardsonacb2ee92013-01-11 22:53:00 -08001274.PHONY: runcgpttests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001275runcgpttests: test_setup
1276 ${RUNTEST} ${BUILD_RUN}/tests/cgptlib_test
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001277
Randall Spangler844bce52013-01-15 16:16:43 -08001278.PHONY: runtestscripts
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001279runtestscripts: test_setup genfuzztestcases
Randall Spanglerb8ff3972014-08-27 13:34:35 -07001280 tests/load_kernel_tests.sh
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001281 tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt
Nam T. Nguyenab899592014-11-13 19:30:46 -08001282 tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt -D 358400
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001283 tests/run_preamble_tests.sh
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001284 tests/run_rsa_tests.sh
Randall Spangler844bce52013-01-15 16:16:43 -08001285 tests/run_vbutil_kernel_arg_tests.sh
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001286 tests/run_vbutil_tests.sh
Randall Spanglere166d042014-05-13 09:24:52 -07001287 tests/vb2_rsa_tests.sh
Randall Spangler539cbc22014-06-18 14:15:04 -07001288 tests/vb2_firmware_tests.sh
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001289
Randall Spangler844bce52013-01-15 16:16:43 -08001290.PHONY: runmisctests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001291runmisctests: test_setup
1292 ${RUNTEST} ${BUILD_RUN}/tests/rollback_index2_tests
Randall Spanglera3eac792013-01-23 13:04:05 -08001293 ${RUNTEST} ${BUILD_RUN}/tests/rollback_index3_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001294 ${RUNTEST} ${BUILD_RUN}/tests/rsa_utility_tests
1295 ${RUNTEST} ${BUILD_RUN}/tests/sha_tests
1296 ${RUNTEST} ${BUILD_RUN}/tests/stateful_util_tests
Randall Spanglerc3d488d2013-01-28 16:23:48 -08001297 ${RUNTEST} ${BUILD_RUN}/tests/tlcl_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001298 ${RUNTEST} ${BUILD_RUN}/tests/tpm_bootmode_tests
1299 ${RUNTEST} ${BUILD_RUN}/tests/utility_string_tests
1300 ${RUNTEST} ${BUILD_RUN}/tests/utility_tests
1301 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_devmode_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001302 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_firmware_tests
Randall Spangler0714d9d2013-02-05 10:23:38 -08001303 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_init_tests
1304 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel_tests
Randall Spangler7f436692013-02-05 12:42:36 -08001305 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel2_tests
1306 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel3_tests
1307 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel4_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001308 ${RUNTEST} ${BUILD_RUN}/tests/vboot_audio_tests
Randall Spanglere061a252013-01-22 15:34:07 -08001309 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common_tests
1310 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS}
1311 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS}
Randall Spangler786a5dc2013-01-24 14:19:56 -08001312 ${RUNTEST} ${BUILD_RUN}/tests/vboot_display_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001313 ${RUNTEST} ${BUILD_RUN}/tests/vboot_firmware_tests
Randall Spangler49cb0d32013-01-29 14:28:16 -08001314 ${RUNTEST} ${BUILD_RUN}/tests/vboot_kernel_tests
Randall Spangler6dbf9d92013-01-23 12:25:10 -08001315 ${RUNTEST} ${BUILD_RUN}/tests/vboot_nvstorage_test
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001316
Randall Spangler786acda2014-05-22 13:27:07 -07001317.PHONY: run2tests
1318run2tests: test_setup
Randall Spanglera7ab8b52014-06-10 17:05:08 -07001319 ${RUNTEST} ${BUILD_RUN}/tests/vb2_api_tests
Randall Spangler786acda2014-05-22 13:27:07 -07001320 ${RUNTEST} ${BUILD_RUN}/tests/vb2_common_tests
Randall Spangler3333e572014-05-14 11:37:52 -07001321 ${RUNTEST} ${BUILD_RUN}/tests/vb2_misc_tests
1322 ${RUNTEST} ${BUILD_RUN}/tests/vb2_nvstorage_tests
Randall Spanglere166d042014-05-13 09:24:52 -07001323 ${RUNTEST} ${BUILD_RUN}/tests/vb2_rsa_utility_tests
Randall Spangler3333e572014-05-14 11:37:52 -07001324 ${RUNTEST} ${BUILD_RUN}/tests/vb2_secdata_tests
Randall Spanglere166d042014-05-13 09:24:52 -07001325 ${RUNTEST} ${BUILD_RUN}/tests/vb2_sha_tests
Randall Spangler6f1b82a2014-12-03 12:29:37 -08001326 ${RUNTEST} ${BUILD_RUN}/tests/vb20_api_tests
1327 ${RUNTEST} ${BUILD_RUN}/tests/vb20_common_tests
1328 ${RUNTEST} ${BUILD_RUN}/tests/vb20_common2_tests ${TEST_KEYS}
1329 ${RUNTEST} ${BUILD_RUN}/tests/vb20_common3_tests ${TEST_KEYS}
1330 ${RUNTEST} ${BUILD_RUN}/tests/vb20_misc_tests
Randall Spangler108d9912014-12-02 15:55:56 -08001331 ${RUNTEST} ${BUILD_RUN}/tests/vb21_api_tests
1332 ${RUNTEST} ${BUILD_RUN}/tests/vb21_common_tests
1333 ${RUNTEST} ${BUILD_RUN}/tests/vb21_common2_tests ${TEST_KEYS}
1334 ${RUNTEST} ${BUILD_RUN}/tests/vb21_misc_tests
1335 ${RUNTEST} ${BUILD_RUN}/tests/vb21_host_fw_preamble_tests ${TEST_KEYS}
1336 ${RUNTEST} ${BUILD_RUN}/tests/vb21_host_key_tests ${TEST_KEYS}
1337 ${RUNTEST} ${BUILD_RUN}/tests/vb21_host_keyblock_tests ${TEST_KEYS}
1338 ${RUNTEST} ${BUILD_RUN}/tests/vb21_host_misc_tests
1339 ${RUNTEST} ${BUILD_RUN}/tests/vb21_host_sig_tests ${TEST_KEYS}
Randall Spangler786acda2014-05-22 13:27:07 -07001340
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001341.PHONY: runfutiltests
Bill Richardson3e3790d2014-07-14 15:05:54 -07001342runfutiltests: test_setup
Bill Richardsonefa87562014-09-11 10:41:51 -07001343 tests/futility/run_test_scripts.sh ${TEST_INSTALL_DIR}/bin
Bill Richardson339f7e02013-04-05 09:49:24 -07001344 ${RUNTEST} ${BUILD_RUN}/tests/futility/test_not_really
Randall Spangler844bce52013-01-15 16:16:43 -08001345
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001346# Run long tests, including all permutations of encryption keys (instead of
Randall Spangler786a5dc2013-01-24 14:19:56 -08001347# just the ones we use) and tests of currently-unused code.
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001348# Not run by automated build.
Bill Richardsonacb2ee92013-01-11 22:53:00 -08001349.PHONY: runlongtests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001350runlongtests: test_setup genkeys genfuzztestcases
Randall Spanglere061a252013-01-22 15:34:07 -08001351 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS} --all
1352 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS} --all
Randall Spangler6f1b82a2014-12-03 12:29:37 -08001353 ${RUNTEST} ${BUILD_RUN}/tests/vb20_common2_tests ${TEST_KEYS} --all
1354 ${RUNTEST} ${BUILD_RUN}/tests/vb20_common3_tests ${TEST_KEYS} --all
Randall Spangler108d9912014-12-02 15:55:56 -08001355 ${RUNTEST} ${BUILD_RUN}/tests/vb21_common2_tests ${TEST_KEYS} --all
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001356 tests/run_preamble_tests.sh --all
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001357 tests/run_vbutil_tests.sh --all
1358
Bill Richardson78d59bf2014-08-27 16:17:04 -07001359# TODO: There were a number of ancient tests that hadn't been run in years.
1360# They were removed with https://chromium-review.googlesource.com/#/c/214610/
1361# Some day it might be nice to see what they were supposed to do.
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001362
Bill Richardson78299022014-06-20 14:33:00 -07001363.PHONY: runalltests
1364runalltests: runtests runfutiltests runlongtests
1365
Randall Spangler59d75082013-01-23 09:29:54 -08001366# Code coverage
1367.PHONY: coverage_init
1368coverage_init: test_setup
1369 rm -f ${COV_INFO}*
1370 lcov -c -i -d . -b . -o ${COV_INFO}.initial
1371
1372.PHONY: coverage_html
1373coverage_html:
1374 lcov -c -d . -b . -o ${COV_INFO}.tests
1375 lcov -a ${COV_INFO}.initial -a ${COV_INFO}.tests -o ${COV_INFO}.total
1376 lcov -r ${COV_INFO}.total '/usr/*' '*/linktest/*' -o ${COV_INFO}.local
1377 genhtml ${COV_INFO}.local -o ${BUILD}/coverage
Bill Richardsond2d08b22014-07-08 16:31:40 -07001378# Generate addtional coverage stats just for firmware subdir, because the stats
1379# for the whole project don't include subdirectory summaries. This will print
1380# the summary for just the firmware sources.
Randall Spangler49cb0d32013-01-29 14:28:16 -08001381 lcov -r ${COV_INFO}.local '*/stub/*' -o ${COV_INFO}.nostub
1382 lcov -e ${COV_INFO}.nostub '${SRCDIR}/firmware/*' \
Randall Spangler59d75082013-01-23 09:29:54 -08001383 -o ${COV_INFO}.firmware
1384
1385.PHONY: coverage
1386ifeq (${COV},)
1387coverage:
1388 $(error Build coverage like this: make clean && COV=1 make)
1389else
1390coverage: coverage_init runtests coverage_html
1391endif
Bill Richardson1912bba2013-04-04 21:08:50 -07001392
1393# Include generated dependencies
1394ALL_DEPS += ${ALL_OBJS:%.o=%.o.d}
Bill Richardson80872db2014-10-03 10:26:11 -07001395TEST_DEPS += ${TEST_OBJS:%.o=%.o.d}
Bill Richardson04d98e32015-01-31 01:14:39 -08001396-include ${ALL_DEPS}
1397-include ${TEST_DEPS}
Bill Richardson80872db2014-10-03 10:26:11 -07001398
1399# We want to use only relative paths in cscope.files, especially since the
1400# paths inside and outside the chroot are different.
1401SRCDIRPAT=$(subst /,\/,${SRCDIR}/)
1402
Bill Richardson8db64da2015-01-29 21:46:58 -08001403# Note: vboot 2.0 is deprecated, so don't index those files
Bill Richardson80872db2014-10-03 10:26:11 -07001404${BUILD}/cscope.files: test_setup
1405 ${Q}rm -f $@
1406 ${Q}cat ${ALL_DEPS} | tr -d ':\\' | tr ' ' '\012' | \
Bill Richardson8db64da2015-01-29 21:46:58 -08001407 grep -v /lib20/ | \
Bill Richardson80872db2014-10-03 10:26:11 -07001408 sed -e "s/${SRCDIRPAT}//" | \
1409 egrep '\.[chS]$$' | sort | uniq > $@
1410
1411cmd_etags = etags -o ${BUILD}/TAGS $(shell cat ${BUILD}/cscope.files)
1412cmd_ctags = ctags -o ${BUILD}/tags $(shell cat ${BUILD}/cscope.files)
1413run_if_prog = $(if $(shell which $(1) 2>/dev/null),$(2),)
1414
1415.PHONY: tags TAGS xrefs
1416tags TAGS xrefs: ${BUILD}/cscope.files
1417 ${Q}\rm -f ${BUILD}/tags ${BUILD}/TAGS
1418 ${Q}$(call run_if_prog,etags,${cmd_etags})
1419 ${Q}$(call run_if_prog,ctags,${cmd_ctags})
Nam T. Nguyen07d90432015-02-17 13:26:44 -08001420
1421PC_FILES = ${PC_IN_FILES:%.pc.in=%.pc}
1422${PC_FILES}: ${PC_IN_FILES}
1423 ${Q}sed \
1424 -e 's:@LDLIBS@:${LDLIBS}:' \
1425 -e 's:@LIBDIR@:${LIBDIR}:' \
1426 $< > $@
1427
1428.PHONY: pc_files_install
1429pc_files_install: ${PC_FILES}
1430 ${Q}mkdir -p ${ULP_DIR}
1431 ${Q}${INSTALL} -D -m 0644 $< ${ULP_DIR}/$<