blob: 13430167cad040b0ff67a755509724eb2676cf4d [file] [log] [blame]
Randall Spanglere8cfa312013-01-02 16:49:38 -08001# Copyright (c) 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 Richardsonfeb25182013-03-07 12:54:29 -080040BUILD = $(SRCDIR)/build
Randall Spangler844bce52013-01-15 16:16:43 -080041export BUILD
Simon Glass6d696e52011-11-14 13:46:33 -080042
Bill Richardsonc9bf3482013-02-13 14:38:29 -080043# Stuff for 'make install'
Bill Richardsonfeb25182013-03-07 12:54:29 -080044INSTALL = install
45DESTDIR = /usr/local/bin
46OLDDIR = old_bins
Bill Richardsonc9bf3482013-02-13 14:38:29 -080047
Bill Richardsonfeb25182013-03-07 12:54:29 -080048# Where exactly do the pieces go?
49# FT_DIR = futility target directory - where it will be on the target
50# F_DIR = futility install directory - where it gets put right now
51# UB_DIR = userspace binary directory for futility's exec() targets
52# VB_DIR = target vboot directory - for dev-mode-only helpers, keys, etc.
Bill Richardsonc9bf3482013-02-13 14:38:29 -080053ifeq (${MINIMAL},)
54# Host install just puts everything in one place
Bill Richardsonfeb25182013-03-07 12:54:29 -080055FT_DIR=${DESTDIR}
56F_DIR=${DESTDIR}
57UB_DIR=${DESTDIR}/${OLDDIR}
Bill Richardsonc9bf3482013-02-13 14:38:29 -080058else
59# Target install puts things into DESTDIR subdirectories
Bill Richardsonfeb25182013-03-07 12:54:29 -080060FT_DIR=/usr/bin
61F_DIR=${DESTDIR}${FT_DIR}
62UB_DIR=${F_DIR}/${OLDDIR}
Bill Richardsonc9bf3482013-02-13 14:38:29 -080063VB_DIR=${DESTDIR}/usr/share/vboot/bin
64endif
Randall Spangler5d9bbf22013-01-08 10:44:23 -080065
Bill Richardsoneecc18f2013-01-17 15:28:17 -080066# Where to install the (exportable) executables for testing?
67TEST_INSTALL_DIR = ${BUILD}/install_for_test
68
69# Verbose? Use V=1
70ifeq (${V},)
71Q := @
72endif
73
Simon Glass661ae9e2013-03-26 11:39:21 -070074# Quiet? Use QUIET=1
75ifeq ($(QUIET),)
76PRINTF := printf
77else
78PRINTF := :
79endif
80
Randall Spangler61a2eb32013-01-23 10:20:16 -080081# Architecture detection
82_machname := $(shell uname -m)
83HOST_ARCH ?= ${_machname}
84
85# ARCH and/or FIRMWARE_ARCH are defined by the Chromium OS ebuild.
86# Pick a sane target architecture if none is defined.
87ifeq (${ARCH},)
88 ARCH := ${HOST_ARCH}
89else ifeq (${ARCH},i386)
90 override ARCH := x86
91else ifeq (${ARCH},amd64)
92 override ARCH := x86_64
93endif
94
95# FIRMWARE_ARCH is only defined by the Chromium OS ebuild if compiling
96# for a firmware target (such as u-boot or depthcharge). It must map
97# to the same consistent set of architectures as the host.
98ifeq (${FIRMWARE_ARCH},i386)
99 override FIRMWARE_ARCH := x86
100else ifeq (${FIRMWARE_ARCH},amd64)
101 override FIRMWARE_ARCH := x86_64
102endif
103
Simon Glassb265c342011-11-16 15:09:51 -0800104# Provide default CC and CFLAGS for firmware builds; if you have any -D flags,
105# please add them after this point (e.g., -DVBOOT_DEBUG).
Che-Liang Chiou74359b72011-06-21 15:25:51 -0700106#
Che-Liang Chiou6b0003c2011-10-14 11:11:28 +0800107# TODO(crosbug.com/16808) We hard-code u-boot's compiler flags here just
108# temporarily. As we are still investigating which flags are necessary for
109# maintaining a compatible ABI, etc. between u-boot and vboot_reference.
Che-Liang Chiou74359b72011-06-21 15:25:51 -0700110#
Simon Glassb265c342011-11-16 15:09:51 -0800111# As a first step, this makes the setting of CC and CFLAGS here optional, to
112# permit a calling script or Makefile to set these.
Che-Liang Chiou74359b72011-06-21 15:25:51 -0700113#
Simon Glassb265c342011-11-16 15:09:51 -0800114# Flag ordering: arch, then -f, then -m, then -W
115DEBUG_FLAGS := $(if ${DEBUG},-g -O0,-Os)
116COMMON_FLAGS := -nostdinc -pipe \
117 -ffreestanding -fno-builtin -fno-stack-protector \
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800118 -Werror -Wall -Wstrict-prototypes ${DEBUG_FLAGS}
Simon Glassb265c342011-11-16 15:09:51 -0800119
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800120# Note: FIRMWARE_ARCH is defined by the Chromium OS ebuild.
121ifeq (${FIRMWARE_ARCH}, arm)
Simon Glassb265c342011-11-16 15:09:51 -0800122CC ?= armv7a-cros-linux-gnueabi-gcc
123CFLAGS ?= -march=armv5 \
124 -fno-common -ffixed-r8 \
Doug Andersond50b27d2012-05-11 12:08:02 -0700125 -mfloat-abi=hard -marm -mabi=aapcs-linux -mno-thumb-interwork \
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800126 ${COMMON_FLAGS}
Randall Spangler61a2eb32013-01-23 10:20:16 -0800127else ifeq (${FIRMWARE_ARCH}, x86)
Simon Glassb265c342011-11-16 15:09:51 -0800128CC ?= i686-pc-linux-gnu-gcc
129# Drop -march=i386 to permit use of SSE instructions
130CFLAGS ?= \
131 -ffunction-sections -fvisibility=hidden -fno-strict-aliasing \
132 -fomit-frame-pointer -fno-toplevel-reorder -fno-dwarf2-cfi-asm \
133 -mpreferred-stack-boundary=2 -mregparm=3 \
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800134 ${COMMON_FLAGS}
135else ifeq (${FIRMWARE_ARCH}, x86_64)
136CFLAGS ?= ${COMMON_FLAGS} \
Simon Glass8e85e982011-11-22 13:54:50 -0800137 -fvisibility=hidden -fno-strict-aliasing -fomit-frame-pointer
Randall Spangler844bce52013-01-15 16:16:43 -0800138else
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800139# FIRMWARE_ARCH not defined; assuming local compile.
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800140CC ?= gcc
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800141CFLAGS += -DCHROMEOS_ENVIRONMENT -Wall -Werror # HEY: always want last two?
Che-Liang Chiou34be8272011-01-27 16:44:36 +0800142endif
143
Bill Richardsonfeb25182013-03-07 12:54:29 -0800144ifneq (${OLDDIR},)
145CFLAGS += -DOLDDIR=${OLDDIR}
146endif
147
Che-Liang Chiou34be8272011-01-27 16:44:36 +0800148ifneq (${DEBUG},)
149CFLAGS += -DVBOOT_DEBUG
vbendebb2b0fcc2010-07-15 15:09:47 -0700150endif
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +0800151
vbendebb2b0fcc2010-07-15 15:09:47 -0700152ifeq (${DISABLE_NDEBUG},)
153CFLAGS += -DNDEBUG
154endif
155
Bill Richardsonfeb25182013-03-07 12:54:29 -0800156ifneq (${FORCE_LOGGING_ON},)
157CFLAGS += -DFORCE_LOGGING_ON=${FORCE_LOGGING_ON}
158endif
159
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800160# Create / use dependency files
161CFLAGS += -MMD -MF $@.d
Simon Glassb265c342011-11-16 15:09:51 -0800162
Bill Richardson0c3ba242013-03-29 11:09:30 -0700163# These are required to access large disks and files on 32-bit systems.
164CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
165
Randall Spangler59d75082013-01-23 09:29:54 -0800166# Code coverage
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800167ifneq (${COV},)
Randall Spangler59d75082013-01-23 09:29:54 -0800168 COV_FLAGS = -O0 --coverage
169 CFLAGS += ${COV_FLAGS}
170 LDFLAGS += ${COV_FLAGS}
171 COV_INFO = ${BUILD}/coverage.info
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +0800172endif
Gaurav Shah322536d2010-01-28 15:01:23 -0800173
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800174# And a few more default utilities
175LD = ${CC}
176CXX ?= g++ # HEY: really?
177PKG_CONFIG ?= pkg-config
178
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800179# Determine QEMU architecture needed, if any
180ifeq (${ARCH},${HOST_ARCH})
181 # Same architecture; no need for QEMU
182 QEMU_ARCH :=
Randall Spangler61a2eb32013-01-23 10:20:16 -0800183else ifeq (${HOST_ARCH}-${ARCH},x86_64-x86)
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800184 # 64-bit host can run 32-bit targets directly
185 QEMU_ARCH :=
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800186else
187 QEMU_ARCH := ${ARCH}
188endif
189
190# The top of the chroot for qemu must be passed in via the SYSROOT environment
191# variable. In the Chromium OS chroot, this is done automatically by the
192# ebuild.
193
194ifeq (${QEMU_ARCH},)
195 # Path to build output for running tests is same as for building
196 BUILD_RUN = ${BUILD}
Randall Spanglere061a252013-01-22 15:34:07 -0800197 SRC_RUN = ${SRCDIR}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800198else
199 $(info Using qemu for testing.)
200 # Path to build output for running tests is different in the chroot
201 BUILD_RUN = $(subst ${SYSROOT},,${BUILD})
Randall Spanglere061a252013-01-22 15:34:07 -0800202 SRC_RUN = $(subst ${SYSROOT},,${SRCDIR})
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800203
204 QEMU_BIN = qemu-${QEMU_ARCH}
Randall Spanglere061a252013-01-22 15:34:07 -0800205 QEMU_RUN = ${BUILD_RUN}/${QEMU_BIN}
206 export QEMU_RUN
207
208 RUNTEST = tests/test_using_qemu.sh
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800209endif
210
Randall Spanglere061a252013-01-22 15:34:07 -0800211export BUILD_RUN
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800212
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800213##############################################################################
214# Now we need to describe everything we might want or need to build
215
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800216# Everything wants these headers.
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800217INCLUDES += \
218 -Ifirmware/include \
219 -Ifirmware/lib/include \
220 -Ifirmware/lib/cgptlib/include \
221 -Ifirmware/lib/cryptolib/include \
222 -Ifirmware/lib/tpm_lite/include
Bill Richardson0b8f35c2010-05-26 09:18:38 -0700223
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800224# If we're not building for a specific target, just stub out things like the
225# TPM commands and various external functions that are provided by the BIOS.
226ifeq (${FIRMWARE_ARCH},)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800227INCLUDES += -Ifirmware/stub/include
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +0800228else
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800229INCLUDES += -Ifirmware/arch/${FIRMWARE_ARCH}/include
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +0800230endif
Gaurav Shah322536d2010-01-28 15:01:23 -0800231
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800232# Firmware library. TODO: Do we still need to export this?
233FWLIB = ${BUILD}/vboot_fw.a
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800234
Randall Spangler93943262013-02-26 11:03:57 -0800235# Firmware library sources needed by VbInit() call
236VBINIT_SRCS = \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800237 firmware/lib/crc8.c \
Randall Spangler93943262013-02-26 11:03:57 -0800238 firmware/lib/utility.c \
239 firmware/lib/vboot_api_init.c \
240 firmware/lib/vboot_common_init.c \
241 firmware/lib/vboot_nvstorage.c \
242
243# Additional firmware library sources needed by VbSelectFirmware() call
244VBSF_SRCS = \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800245 firmware/lib/cryptolib/padding.c \
246 firmware/lib/cryptolib/rsa.c \
247 firmware/lib/cryptolib/rsa_utility.c \
248 firmware/lib/cryptolib/sha1.c \
249 firmware/lib/cryptolib/sha256.c \
250 firmware/lib/cryptolib/sha512.c \
251 firmware/lib/cryptolib/sha_utility.c \
252 firmware/lib/stateful_util.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800253 firmware/lib/vboot_api_firmware.c \
Randall Spangler93943262013-02-26 11:03:57 -0800254 firmware/lib/vboot_common.c \
255 firmware/lib/vboot_firmware.c
256
257# Additional firmware library sources needed by VbSelectAndLoadKernel() call
258VBSLK_SRCS = \
259 firmware/lib/cgptlib/cgptlib.c \
260 firmware/lib/cgptlib/cgptlib_internal.c \
261 firmware/lib/cgptlib/crc32.c \
Albert Chaulk5c9e4532013-03-20 16:03:49 -0700262 firmware/lib/cgptlib/mtdlib.c \
Randall Spangler93943262013-02-26 11:03:57 -0800263 firmware/lib/utility_string.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800264 firmware/lib/vboot_api_kernel.c \
265 firmware/lib/vboot_audio.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800266 firmware/lib/vboot_display.c \
Randall Spangler93943262013-02-26 11:03:57 -0800267 firmware/lib/vboot_kernel.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800268
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800269# Support real TPM unless BIOS sets MOCK_TPM
270ifeq (${MOCK_TPM},)
Randall Spangler93943262013-02-26 11:03:57 -0800271VBINIT_SRCS += \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800272 firmware/lib/rollback_index.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800273 firmware/lib/tpm_lite/tlcl.c
Randall Spangler93943262013-02-26 11:03:57 -0800274
275VBSF_SRCS += \
276 firmware/lib/tpm_bootmode.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800277else
Randall Spangler93943262013-02-26 11:03:57 -0800278VBINIT_SRCS += \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800279 firmware/lib/mocked_rollback_index.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800280 firmware/lib/tpm_lite/mocked_tlcl.c
Randall Spangler93943262013-02-26 11:03:57 -0800281
282VBSF_SRCS += \
283 firmware/lib/mocked_tpm_bootmode.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800284endif
285
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800286ifeq (${FIRMWARE_ARCH},)
287# Include BIOS stubs in the firmware library when compiling for host
Randall Spangler93943262013-02-26 11:03:57 -0800288# TODO: split out other stub funcs too
289VBINIT_SRCS += \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800290 firmware/stub/tpm_lite_stub.c \
291 firmware/stub/utility_stub.c \
Randall Spangler93943262013-02-26 11:03:57 -0800292 firmware/stub/vboot_api_stub_init.c
293
294VBSF_SRCS += \
295 firmware/stub/vboot_api_stub_sf.c
296
297VBSLK_SRCS += \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800298 firmware/stub/vboot_api_stub.c \
299 firmware/stub/vboot_api_stub_disk.c
300endif
301
Randall Spangler93943262013-02-26 11:03:57 -0800302VBSF_SRCS += ${VBINIT_SRCS}
303FWLIB_SRCS += ${VBSF_SRCS} ${VBSLK_SRCS}
304
305VBINIT_OBJS = ${VBINIT_SRCS:%.c=${BUILD}/%.o}
306VBSF_OBJS = ${VBSF_SRCS:%.c=${BUILD}/%.o}
307
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800308FWLIB_OBJS = ${FWLIB_SRCS:%.c=${BUILD}/%.o}
Bill Richardson1912bba2013-04-04 21:08:50 -0700309
310ALL_OBJS += ${FWLIB_OBJS} ${VBINIT_OBJS} ${VBSF_OBJS}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800311
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800312
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800313# Library to build the utilities. "HOST" mostly means "userspace".
Bill Richardsonc7c6e5d2013-02-28 10:10:29 -0800314HOSTLIB = ${BUILD}/libvboot_host.a
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800315
316HOSTLIB_SRCS = \
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800317 cgpt/cgpt_create.c \
318 cgpt/cgpt_add.c \
319 cgpt/cgpt_boot.c \
320 cgpt/cgpt_show.c \
321 cgpt/cgpt_repair.c \
322 cgpt/cgpt_prioritize.c \
323 cgpt/cgpt_common.c \
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800324 host/arch/${ARCH}/lib/crossystem_arch.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800325 host/lib/crossystem.c \
326 host/lib/file_keys.c \
327 host/lib/fmap.c \
328 host/lib/host_common.c \
329 host/lib/host_key.c \
330 host/lib/host_keyblock.c \
331 host/lib/host_misc.c \
332 host/lib/host_signature.c \
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800333 host/lib/signature_digest.c \
334 utility/dump_kernel_config_lib.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800335
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800336HOSTLIB_OBJS = ${HOSTLIB_SRCS:%.c=${BUILD}/%.o}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800337ALL_OBJS += ${HOSTLIB_OBJS}
338
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800339# Might need this too.
340CRYPTO_LIBS := $(shell ${PKG_CONFIG} --libs libcrypto)
341
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800342# Sigh. For historical reasons, the autoupdate installer must sometimes be a
343# 32-bit executable, even when everything else is 64-bit. But it only needs a
344# few functions, so let's just build those.
345TINYHOSTLIB = ${BUILD}/libtinyvboot_host.a
346
347TINYHOSTLIB_SRCS = \
348 cgpt/cgpt_create.c \
349 cgpt/cgpt_add.c \
350 cgpt/cgpt_boot.c \
351 cgpt/cgpt_show.c \
352 cgpt/cgpt_repair.c \
353 cgpt/cgpt_prioritize.c \
354 cgpt/cgpt_common.c \
355 utility/dump_kernel_config_lib.c \
356 firmware/lib/cgptlib/crc32.c \
357 firmware/lib/cgptlib/cgptlib_internal.c \
Bill Richardson5fed2a62013-03-04 15:11:38 -0800358 firmware/lib/utility_string.c \
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800359 firmware/stub/utility_stub.c
360
361TINYHOSTLIB_OBJS = ${TINYHOSTLIB_SRCS:%.c=${BUILD}/%.o}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800362
363# ----------------------------------------------------------------------------
364# Now for the userspace binaries
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800365
366CGPT = ${BUILD}/cgpt/cgpt
367
368CGPT_SRCS = \
369 cgpt/cgpt.c \
370 cgpt/cgpt_add.c \
371 cgpt/cgpt_boot.c \
372 cgpt/cgpt_common.c \
373 cgpt/cgpt_create.c \
374 cgpt/cgpt_find.c \
375 cgpt/cgpt_legacy.c \
376 cgpt/cgpt_prioritize.c \
377 cgpt/cgpt_repair.c \
378 cgpt/cgpt_show.c \
379 cgpt/cmd_add.c \
380 cgpt/cmd_boot.c \
381 cgpt/cmd_create.c \
382 cgpt/cmd_find.c \
383 cgpt/cmd_legacy.c \
384 cgpt/cmd_prioritize.c \
385 cgpt/cmd_repair.c \
386 cgpt/cmd_show.c
387
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800388CGPT_OBJS = ${CGPT_SRCS:%.c=${BUILD}/%.o}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800389ALL_OBJS += ${CGPT_OBJS}
390
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800391
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800392# Scripts to install directly (not compiled)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800393UTIL_SCRIPTS = \
394 utility/dev_debug_vboot \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800395 utility/enable_dev_usb_boot \
396 utility/vbutil_what_keys
397
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800398ifeq (${MINIMAL},)
399UTIL_SCRIPTS += \
400 utility/dev_make_keypair
401endif
402
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800403# These utilities should be linked statically.
404UTIL_NAMES_STATIC = \
Bill Richardson339f7e02013-04-05 09:49:24 -0700405 utility/crossystem \
Bill Richardson339f7e02013-04-05 09:49:24 -0700406 utility/gbb_utility
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800407
408UTIL_NAMES = ${UTIL_NAMES_STATIC} \
Bill Richardson339f7e02013-04-05 09:49:24 -0700409 utility/dev_sign_file \
410 utility/dump_kernel_config \
411 utility/dumpRSAPublicKey \
412 utility/tpm_init_temp_fix \
413 utility/tpmc \
414 utility/vbutil_firmware \
415 utility/vbutil_kernel \
416 utility/vbutil_key \
417 utility/vbutil_keyblock \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800418
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800419ifeq (${MINIMAL},)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800420UTIL_NAMES += \
Bill Richardson339f7e02013-04-05 09:49:24 -0700421 utility/bmpblk_font \
422 utility/bmpblk_utility \
423 utility/eficompress \
424 utility/efidecompress \
425 utility/load_kernel_test \
426 utility/pad_digest_utility \
427 utility/signature_digest_utility \
428 utility/verify_data
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800429endif
430
Bill Richardson339f7e02013-04-05 09:49:24 -0700431UTIL_BINS_STATIC := $(addprefix ${BUILD}/,${UTIL_NAMES_STATIC})
432UTIL_BINS = $(addprefix ${BUILD}/,${UTIL_NAMES})
Bill Richardson1912bba2013-04-04 21:08:50 -0700433ALL_OBJS += $(addsuffix .o,${UTIL_BINS} ${UTIL_BINS_STATIC})
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800434
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800435
436# Scripts for signing stuff.
437SIGNING_SCRIPTS = \
438 utility/tpm-nvsize \
439 utility/chromeos-tpm-recovery
440
441# These go in a different place.
442SIGNING_SCRIPTS_DEV = \
443 scripts/image_signing/resign_firmwarefd.sh \
444 scripts/image_signing/make_dev_firmware.sh \
445 scripts/image_signing/make_dev_ssd.sh \
446 scripts/image_signing/set_gbb_flags.sh
447
448# Installed, but not made executable.
449SIGNING_COMMON = scripts/image_signing/common_minimal.sh
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800450
Bill Richardson826db092013-01-14 12:37:15 -0800451
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800452# The unified firmware utility will eventually replace all the others
453FUTIL_BIN = ${BUILD}/futility/futility
Bill Richardson6db8c752013-04-05 13:30:43 -0700454# But we still need both static (tiny) and dynamic (with openssl) versions.
455FUTIL_STATIC_BIN = ${FUTIL_BIN}_s
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800456
Bill Richardsonfeb25182013-03-07 12:54:29 -0800457# These are the others it will replace.
Bill Richardson20807b62013-04-09 10:15:26 -0700458FUTIL_OLD = bmpblk_font bmpblk_utility cgpt chromeos-tpm-recovery crossystem \
459 dev_debug_vboot dev_make_keypair dev_sign_file dumpRSAPublicKey \
460 dump_fmap dump_kernel_config eficompress efidecompress \
461 enable_dev_usb_boot gbb_utility load_kernel_test \
462 make_dev_firmware.sh make_dev_ssd.sh pad_digest_utility \
463 resign_firmwarefd.sh set_gbb_flags.sh signature_digest_utility \
464 tpm-nvsize tpm_init_temp_fix tpmc vbutil_firmware vbutil_kernel \
465 vbutil_key vbutil_keyblock vbutil_what_keys verify_data
Bill Richardsonfeb25182013-03-07 12:54:29 -0800466
Bill Richardson6db8c752013-04-05 13:30:43 -0700467FUTIL_STATIC_SRCS = \
Bill Richardsonfeb25182013-03-07 12:54:29 -0800468 futility/futility.c \
Bill Richardson20807b62013-04-09 10:15:26 -0700469 futility/cmd_dump_fmap.c \
Bill Richardsonfeb25182013-03-07 12:54:29 -0800470 futility/cmd_foo.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800471
Bill Richardson6db8c752013-04-05 13:30:43 -0700472FUTIL_SRCS = \
473 $(FUTIL_STATIC_SRCS) \
474 futility/cmd_hey.c
475
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800476FUTIL_LDS = futility/futility.lds
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800477
Bill Richardson6db8c752013-04-05 13:30:43 -0700478FUTIL_STATIC_OBJS = ${FUTIL_STATIC_SRCS:%.c=${BUILD}/%.o}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800479FUTIL_OBJS = ${FUTIL_SRCS:%.c=${BUILD}/%.o}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800480
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800481ALL_OBJS += ${FUTIL_OBJS}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800482
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800483
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800484# Library of handy test functions.
485TESTLIB = ${BUILD}/tests/test.a
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800486
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800487TESTLIB_SRCS = \
488 tests/test_common.c \
489 tests/timer_utils.c \
490 tests/crc32_test.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800491
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800492TESTLIB_OBJS = ${TESTLIB_SRCS:%.c=${BUILD}/%.o}
493ALL_OBJS += ${TESTLIB_OBJS}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800494
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800495
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800496# And some compiled tests.
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800497TEST_NAMES = \
Bill Richardson339f7e02013-04-05 09:49:24 -0700498 tests/cgptlib_test \
499 tests/rollback_index2_tests \
500 tests/rollback_index3_tests \
501 tests/rsa_padding_test \
502 tests/rsa_utility_tests \
503 tests/rsa_verify_benchmark \
504 tests/sha_benchmark \
505 tests/sha_tests \
506 tests/stateful_util_tests \
507 tests/tlcl_tests \
508 tests/tpm_bootmode_tests \
509 tests/utility_string_tests \
510 tests/utility_tests \
511 tests/vboot_api_init_tests \
512 tests/vboot_api_devmode_tests \
513 tests/vboot_api_firmware_tests \
514 tests/vboot_api_kernel_tests \
515 tests/vboot_api_kernel2_tests \
516 tests/vboot_api_kernel3_tests \
517 tests/vboot_api_kernel4_tests \
518 tests/vboot_audio_tests \
519 tests/vboot_common_tests \
520 tests/vboot_common2_tests \
521 tests/vboot_common3_tests \
522 tests/vboot_display_tests \
523 tests/vboot_firmware_tests \
524 tests/vboot_kernel_tests \
525 tests/vboot_nvstorage_test \
526 tests/futility/test_not_really
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800527
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800528# TODO: port these tests to new API, if not already eqivalent
529# functionality in other tests. These don't even compile at present.
530#
531# big_firmware_tests
532# big_kernel_tests
533# firmware_image_tests
534# firmware_rollback_tests
535# firmware_splicing_tests
536# firmware_verify_benchmark
537# kernel_image_tests
538# kernel_rollback_tests
539# kernel_splicing_tests
540# kernel_verify_benchmark
541# rollback_index_test
542# verify_firmware_fuzz_driver
543# verify_kernel_fuzz_driver
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800544# utility/load_firmware_test
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800545
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800546# And a few more...
Bill Richardson339f7e02013-04-05 09:49:24 -0700547TLCL_TEST_NAMES = \
548 tests/tpm_lite/tpmtest_earlyextend \
549 tests/tpm_lite/tpmtest_earlynvram \
550 tests/tpm_lite/tpmtest_earlynvram2 \
551 tests/tpm_lite/tpmtest_enable \
552 tests/tpm_lite/tpmtest_fastenable \
553 tests/tpm_lite/tpmtest_globallock \
554 tests/tpm_lite/tpmtest_redefine_unowned \
555 tests/tpm_lite/tpmtest_spaceperm \
556 tests/tpm_lite/tpmtest_testsetup \
557 tests/tpm_lite/tpmtest_timing \
558 tests/tpm_lite/tpmtest_writelimit
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800559
560TEST_NAMES += ${TLCL_TEST_NAMES}
561
Bill Richardson339f7e02013-04-05 09:49:24 -0700562# Finally
563TEST_BINS = $(addprefix ${BUILD}/,${TEST_NAMES})
Bill Richardson1912bba2013-04-04 21:08:50 -0700564ALL_OBJS += $(addsuffix .o,${TEST_BINS})
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800565
Randall Spanglere061a252013-01-22 15:34:07 -0800566# Directory containing test keys
567TEST_KEYS = ${SRC_RUN}/tests/testkeys
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800568
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800569
570##############################################################################
571# Finally, some targets. High-level ones first.
572
573# Create output directories if necessary. Do this via explicit shell commands
574# so it happens before trying to generate/include dependencies.
575SUBDIRS := firmware host cgpt utility futility tests tests/tpm_lite
576_dir_create := $(foreach d, \
577 $(shell find ${SUBDIRS} -name '*.c' -exec dirname {} \; | sort -u), \
578 $(shell [ -d ${BUILD}/${d} ] || mkdir -p ${BUILD}/${d}))
579
580
581# Default target.
582.PHONY: all
Randall Spangler59d75082013-01-23 09:29:54 -0800583all: fwlib $(if ${FIRMWARE_ARCH},,host_stuff) $(if ${COV},coverage)
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800584
585# Host targets
586.PHONY: host_stuff
587host_stuff: hostlib cgpt utils futil tests
588
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800589.PHONY: clean
590clean:
591 ${Q}/bin/rm -rf ${BUILD}
592
593.PHONY: install
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800594install: cgpt_install utils_install signing_install futil_install
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800595
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800596# Don't delete intermediate object files
597.SECONDARY:
598
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800599
600# ----------------------------------------------------------------------------
601# Firmware library
602
603# TPM-specific flags. These depend on the particular TPM we're targeting for.
604# They are needed here only for compiling parts of the firmware code into
605# user-level tests.
606
607# TPM_BLOCKING_CONTINUESELFTEST is defined if TPM_ContinueSelfTest blocks until
608# the self test has completed.
609
Randall Spangler45cc0f22013-01-25 09:34:26 -0800610${FWLIB_OBJS}: CFLAGS += -DTPM_BLOCKING_CONTINUESELFTEST
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800611
612# TPM_MANUAL_SELFTEST is defined if the self test must be started manually
613# (with a call to TPM_ContinueSelfTest) instead of starting automatically at
614# power on.
615#
616# We sincerely hope that TPM_BLOCKING_CONTINUESELFTEST and TPM_MANUAL_SELFTEST
617# are not both defined at the same time. (See comment in code.)
618
619# CFLAGS += -DTPM_MANUAL_SELFTEST
620
621ifeq (${FIRMWARE_ARCH},i386)
622# Unrolling loops in cryptolib makes it faster
Randall Spangler45cc0f22013-01-25 09:34:26 -0800623${FWLIB_OBJS}: CFLAGS += -DUNROLL_LOOPS
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800624
625# Workaround for coreboot on x86, which will power off asynchronously
626# without giving us a chance to react. This is not an example of the Right
627# Way to do things. See chrome-os-partner:7689, and the commit message
628# that made this change.
Randall Spangler45cc0f22013-01-25 09:34:26 -0800629${FWLIB_OBJS}: CFLAGS += -DSAVE_LOCALE_IMMEDIATELY
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800630
631# On x86 we don't actually read the GBB data into RAM until it is needed.
632# Therefore it makes sense to cache it rather than reading it each time.
633# Enable this feature.
Randall Spangler45cc0f22013-01-25 09:34:26 -0800634${FWLIB_OBJS}: CFLAGS += -DCOPY_BMP_DATA
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800635endif
636
637ifeq (${FIRMWARE_ARCH},)
638# Disable rollback TPM when compiling locally, since otherwise
639# load_kernel_test attempts to talk to the TPM.
Randall Spangler45cc0f22013-01-25 09:34:26 -0800640${FWLIB_OBJS}: CFLAGS += -DDISABLE_ROLLBACK_TPM
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800641endif
642
Bill Richardsona130e0b2013-04-04 18:16:39 -0700643# Linktest ensures firmware lib doesn't rely on outside libraries
644${BUILD}/firmware/linktest/main_vbinit: ${VBINIT_OBJS}
Randall Spangler93943262013-02-26 11:03:57 -0800645${BUILD}/firmware/linktest/main_vbinit: OBJS = ${VBINIT_OBJS}
Bill Richardson1912bba2013-04-04 21:08:50 -0700646ALL_OBJS += ${BUILD}/firmware/linktest/main_vbinit.o
Bill Richardsona130e0b2013-04-04 18:16:39 -0700647${BUILD}/firmware/linktest/main_vbsf: ${VBSF_OBJS}
Randall Spangler93943262013-02-26 11:03:57 -0800648${BUILD}/firmware/linktest/main_vbsf: OBJS = ${VBSF_OBJS}
Bill Richardson1912bba2013-04-04 21:08:50 -0700649ALL_OBJS += ${BUILD}/firmware/linktest/main_vbsf.o
Bill Richardsona130e0b2013-04-04 18:16:39 -0700650${BUILD}/firmware/linktest/main: ${FWLIB}
651${BUILD}/firmware/linktest/main: LIBS = ${FWLIB}
Bill Richardson1912bba2013-04-04 21:08:50 -0700652ALL_OBJS += ${BUILD}/firmware/linktest/main.o
Randall Spangler93943262013-02-26 11:03:57 -0800653
654.phony: fwlinktest
655fwlinktest: ${FWLIB} \
656 ${BUILD}/firmware/linktest/main_vbinit \
657 ${BUILD}/firmware/linktest/main_vbsf \
658 ${BUILD}/firmware/linktest/main
659
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800660.PHONY: fwlib
Bill Richardsona130e0b2013-04-04 18:16:39 -0700661fwlib: $(if ${FIRMWARE_ARCH},${FWLIB},fwlinktest)
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800662
663${FWLIB}: ${FWLIB_OBJS}
Simon Glass661ae9e2013-03-26 11:39:21 -0700664 @$(PRINTF) " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800665 ${Q}rm -f $@
Simon Glass661ae9e2013-03-26 11:39:21 -0700666 @$(PRINTF) " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800667 ${Q}ar qc $@ $^
668
669# ----------------------------------------------------------------------------
670# Host library
671
Bill Richardsona130e0b2013-04-04 18:16:39 -0700672
673# Link tests
674${BUILD}/host/linktest/main: ${HOSTLIB}
675${BUILD}/host/linktest/main: LIBS = ${HOSTLIB}
Bill Richardson1912bba2013-04-04 21:08:50 -0700676ALL_OBJS += ${BUILD}/host/linktest/main.o
Bill Richardsona130e0b2013-04-04 18:16:39 -0700677
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800678.PHONY: hostlib
Bill Richardsona130e0b2013-04-04 18:16:39 -0700679hostlib: ${BUILD}/host/linktest/main
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800680
681${BUILD}/host/% ${HOSTLIB}: INCLUDES += \
Bill Richardson0c3ba242013-03-29 11:09:30 -0700682 -Ihost/include \
683 -Ihost/arch/${ARCH}/include \
684 -Ihost/lib/include
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800685
686# TODO: better way to make .a than duplicating this recipe each time?
687${HOSTLIB}: ${HOSTLIB_OBJS} ${FWLIB_OBJS}
Simon Glass661ae9e2013-03-26 11:39:21 -0700688 @$(PRINTF) " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800689 ${Q}rm -f $@
Simon Glass661ae9e2013-03-26 11:39:21 -0700690 @$(PRINTF) " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800691 ${Q}ar qc $@ $^
692
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800693
694# Ugh. This is a very cut-down version of HOSTLIB just for the installer.
695.PHONY: tinyhostlib
696tinyhostlib: ${TINYHOSTLIB}
697 ${Q}cp -f ${TINYHOSTLIB} ${HOSTLIB}
698
699${TINYHOSTLIB}: ${TINYHOSTLIB_OBJS}
Simon Glass661ae9e2013-03-26 11:39:21 -0700700 @$(PRINTF) " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800701 ${Q}rm -f $@
Simon Glass661ae9e2013-03-26 11:39:21 -0700702 @$(PRINTF) " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800703 ${Q}ar qc $@ $^
704
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800705# ----------------------------------------------------------------------------
706# CGPT library and utility
707
708.PHONY: cgpt
709cgpt: ${CGPT}
710
Bill Richardson0c3ba242013-03-29 11:09:30 -0700711${CGPT_OBJS}: INCLUDES += -Ihost/include
712
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800713${CGPT}: LDFLAGS += -static
714${CGPT}: LDLIBS += -luuid
715
Bill Richardsona130e0b2013-04-04 18:16:39 -0700716${CGPT}: ${CGPT_OBJS} ${HOSTLIB}
Simon Glass661ae9e2013-03-26 11:39:21 -0700717 @$(PRINTF) " LDcgpt $(subst ${BUILD}/,,$@)\n"
Bill Richardson6db8c752013-04-05 13:30:43 -0700718 ${Q}${LD} -o ${CGPT} ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800719
720.PHONY: cgpt_install
721cgpt_install: ${CGPT}
Simon Glass661ae9e2013-03-26 11:39:21 -0700722 @$(PRINTF) " INSTALL CGPT\n"
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800723 ${Q}mkdir -p ${UB_DIR}
724 ${Q}${INSTALL} -t ${UB_DIR} $^
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800725
726# ----------------------------------------------------------------------------
727# Utilities
728
729# These have their own headers too.
Bill Richardson0c3ba242013-03-29 11:09:30 -0700730${BUILD}/utility/%: INCLUDES += \
731 -Ihost/include \
732 -Ihost/lib/include \
733 -Iutility/include
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800734
735# Utilities for auto-update toolkits must be statically linked.
736${UTIL_BINS_STATIC}: LDFLAGS += -static
737
Bill Richardsona130e0b2013-04-04 18:16:39 -0700738
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800739.PHONY: utils
Bill Richardsonc7c6e5d2013-02-28 10:10:29 -0800740utils: ${UTIL_BINS} ${UTIL_SCRIPTS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800741 ${Q}cp -f ${UTIL_SCRIPTS} ${BUILD}/utility
742 ${Q}chmod a+rx $(patsubst %,${BUILD}/%,${UTIL_SCRIPTS})
743
Bill Richardsona130e0b2013-04-04 18:16:39 -0700744${UTIL_BINS} ${UTIL_BINS_STATIC}: ${HOSTLIB}
745${UTIL_BINS} ${UTIL_BINS_STATIC}: LIBS = ${HOSTLIB}
746
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800747.PHONY: utils_install
Bill Richardsonc7c6e5d2013-02-28 10:10:29 -0800748utils_install: ${UTIL_BINS} ${UTIL_SCRIPTS}
Simon Glass661ae9e2013-03-26 11:39:21 -0700749 @$(PRINTF) " INSTALL UTILS\n"
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800750 ${Q}mkdir -p ${UB_DIR}
751 ${Q}${INSTALL} -t ${UB_DIR} ${UTIL_BINS} ${UTIL_SCRIPTS}
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800752
753# And some signing stuff for the target
754.PHONY: signing_install
755signing_install: ${SIGNING_SCRIPTS} ${SIGNING_SCRIPTS_DEV} ${SIGNING_COMMON}
Simon Glass661ae9e2013-03-26 11:39:21 -0700756 @$(PRINTF) " INSTALL SIGNING\n"
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800757 ${Q}mkdir -p ${UB_DIR}
758 ${Q}${INSTALL} -t ${UB_DIR} ${SIGNING_SCRIPTS}
Bill Richardsonfeb25182013-03-07 12:54:29 -0800759 ${Q}${INSTALL} -t ${UB_DIR} ${SIGNING_SCRIPTS_DEV}
760 ${Q}${INSTALL} -t ${UB_DIR} -m 'u=rw,go=r,a-s' ${SIGNING_COMMON}
761ifneq (${VB_DIR},)
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800762 ${Q}mkdir -p ${VB_DIR}
Bill Richardsonfeb25182013-03-07 12:54:29 -0800763 ${Q}for prog in $(notdir ${SIGNING_SCRIPTS_DEV}); do \
764 ln -sf "${FT_DIR}/futility" "${VB_DIR}/$$prog"; done
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800765endif
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800766
767# ----------------------------------------------------------------------------
768# new Firmware Utility
769
770.PHONY: futil
Bill Richardson6db8c752013-04-05 13:30:43 -0700771futil: ${FUTIL_STATIC_BIN} ${FUTIL_BIN}
772
773${FUTIL_STATIC_BIN}: ${FUTIL_LDS} ${FUTIL_STATIC_OBJS}
774 @$(PRINTF) " LD $(subst ${BUILD}/,,$@)\n"
775 ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} -static $^ ${LDLIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800776
777${FUTIL_BIN}: ${FUTIL_LDS} ${FUTIL_OBJS}
Simon Glass661ae9e2013-03-26 11:39:21 -0700778 @$(PRINTF) " LD $(subst ${BUILD}/,,$@)\n"
Bill Richardson6db8c752013-04-05 13:30:43 -0700779 ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800780
781.PHONY: futil_install
782futil_install: ${FUTIL_BIN}
Simon Glass661ae9e2013-03-26 11:39:21 -0700783 @$(PRINTF) " INSTALL futility\n"
Bill Richardsonfeb25182013-03-07 12:54:29 -0800784 ${Q}mkdir -p ${F_DIR}
Bill Richardson6db8c752013-04-05 13:30:43 -0700785 ${Q}${INSTALL} -t ${F_DIR} ${FUTIL_BIN} ${FUTIL_STATIC_BIN}
Bill Richardsonfeb25182013-03-07 12:54:29 -0800786 ${Q}for prog in ${FUTIL_OLD}; do \
787 ln -sf futility "${F_DIR}/$$prog"; done
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800788
Bill Richardson20807b62013-04-09 10:15:26 -0700789# TODO(wfrichar): This will need some refactoring (crbug.com/228932)
790${BUILD}/futility/% ${HOSTLIB}: INCLUDES += \
791 -Ihost/include \
792 -Ihost/arch/${ARCH}/include \
793 -Ihost/lib/include
794${FUTIL_STATIC_BIN} ${FUTIL_BIN}: ${HOSTLIB}
795${FUTIL_STATIC_BIN} ${FUTIL_BIN}: LIBS = ${HOSTLIB}
796
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800797# ----------------------------------------------------------------------------
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800798# Utility to generate TLCL structure definition header file.
799
800${BUILD}/utility/tlcl_generator: CFLAGS += -fpack-struct
801
802STRUCTURES_TMP=${BUILD}/tlcl_structures.tmp
803STRUCTURES_SRC=firmware/lib/tpm_lite/include/tlcl_structures.h
804
805.PHONY: update_tlcl_structures
806update_tlcl_structures: ${BUILD}/utility/tlcl_generator
Simon Glass661ae9e2013-03-26 11:39:21 -0700807 @$(PRINTF) " Rebuilding TLCL structures\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800808 ${Q}${BUILD}/utility/tlcl_generator > ${STRUCTURES_TMP}
809 ${Q}cmp -s ${STRUCTURES_TMP} ${STRUCTURES_SRC} || \
810 ( echo "%% Updating structures.h %%" && \
811 cp ${STRUCTURES_TMP} ${STRUCTURES_SRC} )
812
813# ----------------------------------------------------------------------------
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800814# Tests
815
816.PHONY: tests
817tests: ${TEST_BINS}
818
Bill Richardsona130e0b2013-04-04 18:16:39 -0700819${TEST_BINS}: ${HOSTLIB} ${TESTLIB}
Bill Richardson339f7e02013-04-05 09:49:24 -0700820${TEST_BINS}: INCLUDES += -Itests
Bill Richardsona130e0b2013-04-04 18:16:39 -0700821${TEST_BINS}: LIBS = ${HOSTLIB} ${TESTLIB}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800822
823${TESTLIB}: ${TESTLIB_OBJS}
Simon Glass661ae9e2013-03-26 11:39:21 -0700824 @$(PRINTF) " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800825 ${Q}rm -f $@
Simon Glass661ae9e2013-03-26 11:39:21 -0700826 @$(PRINTF) " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800827 ${Q}ar qc $@ $^
828
829
830# ----------------------------------------------------------------------------
831# Generic build rules. LIBS and OBJS can be overridden to tweak the generic
832# rules for specific targets.
833
834${BUILD}/%: ${BUILD}/%.o ${OBJS} ${LIBS}
Simon Glass661ae9e2013-03-26 11:39:21 -0700835 @$(PRINTF) " LD $(subst ${BUILD}/,,$@)\n"
Bill Richardson6db8c752013-04-05 13:30:43 -0700836 ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $< ${OBJS} ${LIBS} ${LDLIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800837
838${BUILD}/%.o: %.c
Simon Glass661ae9e2013-03-26 11:39:21 -0700839 @$(PRINTF) " CC $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800840 ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
841
842# Rules to recompile a single source file for library and test
843# TODO: is there a tidier way to do this?
844${BUILD}/%_for_lib.o: CFLAGS += -DFOR_LIBRARY
845${BUILD}/%_for_lib.o: %.c
Simon Glass661ae9e2013-03-26 11:39:21 -0700846 @$(PRINTF) " CC-for-lib $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800847 ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
848
849${BUILD}/%_for_test.o: CFLAGS += -DFOR_TEST
850${BUILD}/%_for_test.o: %.c
Simon Glass661ae9e2013-03-26 11:39:21 -0700851 @$(PRINTF) " CC-for-test $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800852 ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
853
854# TODO: C++ files don't belong in vboot reference at all. Convert to C.
855${BUILD}/%.o: %.cc
Simon Glass661ae9e2013-03-26 11:39:21 -0700856 @$(PRINTF) " CXX $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800857 ${Q}${CXX} ${CFLAGS} ${INCLUDES} -c -o $@ $<
858
859# ----------------------------------------------------------------------------
860# Here are the special tweaks to the generic rules.
861
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800862# GBB utility needs C++ linker. TODO: It shouldn't.
863${BUILD}/utility/gbb_utility: LD = ${CXX}
864
Bill Richardsonfeb25182013-03-07 12:54:29 -0800865# Because we play some clever linker script games to add new commands without
866# changing any header files, futility must be linked with ld.bfd, not gold.
867${FUTIL_BIN}: LDFLAGS += -fuse-ld=bfd
Bill Richardson6db8c752013-04-05 13:30:43 -0700868${FUTIL_STATIC_BIN}: LDFLAGS += -fuse-ld=bfd
Bill Richardsonfeb25182013-03-07 12:54:29 -0800869
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800870# Some utilities need external crypto functions
871${BUILD}/utility/dumpRSAPublicKey: LDLIBS += ${CRYPTO_LIBS}
872${BUILD}/utility/pad_digest_utility: LDLIBS += ${CRYPTO_LIBS}
873${BUILD}/utility/signature_digest_utility: LDLIBS += ${CRYPTO_LIBS}
874${BUILD}/utility/dev_sign_file: LDLIBS += ${CRYPTO_LIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800875${BUILD}/utility/vbutil_firmware: LDLIBS += ${CRYPTO_LIBS}
876${BUILD}/utility/vbutil_kernel: LDLIBS += ${CRYPTO_LIBS}
877${BUILD}/utility/vbutil_key: LDLIBS += ${CRYPTO_LIBS}
878${BUILD}/utility/vbutil_keyblock: LDLIBS += ${CRYPTO_LIBS}
879
880${BUILD}/host/linktest/main: LDLIBS += ${CRYPTO_LIBS}
881${BUILD}/tests/vboot_common2_tests: LDLIBS += ${CRYPTO_LIBS}
882${BUILD}/tests/vboot_common3_tests: LDLIBS += ${CRYPTO_LIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800883
884${BUILD}/utility/bmpblk_utility: LD = ${CXX}
885${BUILD}/utility/bmpblk_utility: LDLIBS = -llzma -lyaml
886
887BMPBLK_UTILITY_DEPS = \
888 ${BUILD}/utility/bmpblk_util.o \
889 ${BUILD}/utility/image_types.o \
890 ${BUILD}/utility/eficompress_for_lib.o \
891 ${BUILD}/utility/efidecompress_for_lib.o
Bill Richardson1912bba2013-04-04 21:08:50 -0700892
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800893${BUILD}/utility/bmpblk_utility: OBJS = ${BMPBLK_UTILITY_DEPS}
894${BUILD}/utility/bmpblk_utility: ${BMPBLK_UTILITY_DEPS}
Bill Richardson1912bba2013-04-04 21:08:50 -0700895ALL_OBJS += ${BMPBLK_UTILITY_DEPS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800896
897${BUILD}/utility/bmpblk_font: OBJS += ${BUILD}/utility/image_types.o
898${BUILD}/utility/bmpblk_font: ${BUILD}/utility/image_types.o
Bill Richardson1912bba2013-04-04 21:08:50 -0700899ALL_OBJS += ${BUILD}/utility/image_types.o
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800900
901# Allow multiple definitions, so tests can mock functions from other libraries
902${BUILD}/tests/%: CFLAGS += -Xlinker --allow-multiple-definition
Bill Richardson0c3ba242013-03-29 11:09:30 -0700903${BUILD}/tests/%: INCLUDES += -Ihost/include -Ihost/lib/include
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800904${BUILD}/tests/%: LDLIBS += -lrt -luuid
905${BUILD}/tests/%: LIBS += ${TESTLIB}
906
907${BUILD}/tests/rollback_index2_tests: OBJS += \
908 ${BUILD}/firmware/lib/rollback_index_for_test.o
909${BUILD}/tests/rollback_index2_tests: \
910 ${BUILD}/firmware/lib/rollback_index_for_test.o
Bill Richardson1912bba2013-04-04 21:08:50 -0700911ALL_OBJS += ${BUILD}/firmware/lib/rollback_index_for_test.o
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800912
Randall Spanglerc3d488d2013-01-28 16:23:48 -0800913${BUILD}/tests/tlcl_tests: OBJS += \
914 ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
915${BUILD}/tests/tlcl_tests: \
916 ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
Bill Richardson1912bba2013-04-04 21:08:50 -0700917ALL_OBJS += ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
Randall Spanglerc3d488d2013-01-28 16:23:48 -0800918
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800919${BUILD}/tests/vboot_audio_tests: OBJS += \
920 ${BUILD}/firmware/lib/vboot_audio_for_test.o
921${BUILD}/tests/vboot_audio_tests: \
922 ${BUILD}/firmware/lib/vboot_audio_for_test.o
Bill Richardson1912bba2013-04-04 21:08:50 -0700923ALL_OBJS += ${BUILD}/firmware/lib/vboot_audio_for_test.o
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800924
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800925${BUILD}/tests/rollback_index_test: INCLUDES += -I/usr/include
926${BUILD}/tests/rollback_index_test: LIBS += -ltlcl
927
Bill Richardson339f7e02013-04-05 09:49:24 -0700928TLCL_TEST_BINS = $(addprefix ${BUILD}/,${TLCL_TEST_NAMES})
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800929${TLCL_TEST_BINS}: OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o
930${TLCL_TEST_BINS}: ${BUILD}/tests/tpm_lite/tlcl_tests.o
Bill Richardson1912bba2013-04-04 21:08:50 -0700931ALL_OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800932
933##############################################################################
934# Targets that exist just to run tests
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800935
936# Frequently-run tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800937.PHONY: test_targets
938test_targets:: runcgpttests runmisctests
Randall Spangler844bce52013-01-15 16:16:43 -0800939
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800940ifeq (${MINIMAL},)
Randall Spangler844bce52013-01-15 16:16:43 -0800941# Bitmap utility isn't compiled for minimal variant
Bill Richardsonfeb25182013-03-07 12:54:29 -0800942test_targets:: runbmptests runfutiltests
Randall Spangler844bce52013-01-15 16:16:43 -0800943# Scripts don't work under qemu testing
944# TODO: convert scripts to makefile so they can be called directly
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800945test_targets:: runtestscripts
Randall Spangler844bce52013-01-15 16:16:43 -0800946endif
947
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800948.PHONY: test_setup
949test_setup:: cgpt utils futil tests
950
Randall Spangler844bce52013-01-15 16:16:43 -0800951# Qemu setup for cross-compiled tests. Need to copy qemu binary into the
952# sysroot.
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800953ifneq (${QEMU_ARCH},)
954test_setup:: qemu_install
Randall Spangler844bce52013-01-15 16:16:43 -0800955
956.PHONY: qemu_install
957qemu_install:
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800958ifeq (${SYSROOT},)
959 $(error SYSROOT must be set to the top of the target-specific root \
960when cross-compiling for qemu-based tests to run properly.)
961endif
Simon Glass661ae9e2013-03-26 11:39:21 -0700962 @$(PRINTF) " Copying qemu binary.\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800963 ${Q}cp -fu /usr/bin/${QEMU_BIN} ${BUILD}/${QEMU_BIN}
964 ${Q}chmod a+rx ${BUILD}/${QEMU_BIN}
Randall Spangler844bce52013-01-15 16:16:43 -0800965endif
966
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800967.PHONY: runtests
Bill Richardsona130e0b2013-04-04 18:16:39 -0700968runtests: test_setup test_targets
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800969
970# Generate test keys
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800971.PHONY: genkeys
Randall Spangler844bce52013-01-15 16:16:43 -0800972genkeys: utils
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800973 tests/gen_test_keys.sh
974
975# Generate test cases for fuzzing
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800976.PHONY: genfuzztestcases
Randall Spanglera808dc92013-01-14 12:59:05 -0800977genfuzztestcases: utils
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800978 tests/gen_fuzz_test_cases.sh
979
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800980.PHONY: runbmptests
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800981runbmptests: test_setup
982 cd tests/bitmaps && BMPBLK=${BUILD_RUN}/utility/bmpblk_utility \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800983 ./TestBmpBlock.py -v
984
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800985.PHONY: runcgpttests
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800986runcgpttests: test_setup
987 ${RUNTEST} ${BUILD_RUN}/tests/cgptlib_test
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800988
Randall Spangler844bce52013-01-15 16:16:43 -0800989.PHONY: runtestscripts
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800990runtestscripts: test_setup genfuzztestcases
991 tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800992 tests/run_preamble_tests.sh
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800993 tests/run_rsa_tests.sh
Randall Spangler844bce52013-01-15 16:16:43 -0800994 tests/run_vbutil_kernel_arg_tests.sh
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800995 tests/run_vbutil_tests.sh
996
Randall Spangler844bce52013-01-15 16:16:43 -0800997.PHONY: runmisctests
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800998runmisctests: test_setup
999 ${RUNTEST} ${BUILD_RUN}/tests/rollback_index2_tests
Randall Spanglera3eac792013-01-23 13:04:05 -08001000 ${RUNTEST} ${BUILD_RUN}/tests/rollback_index3_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001001 ${RUNTEST} ${BUILD_RUN}/tests/rsa_utility_tests
1002 ${RUNTEST} ${BUILD_RUN}/tests/sha_tests
1003 ${RUNTEST} ${BUILD_RUN}/tests/stateful_util_tests
Randall Spanglerc3d488d2013-01-28 16:23:48 -08001004 ${RUNTEST} ${BUILD_RUN}/tests/tlcl_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001005 ${RUNTEST} ${BUILD_RUN}/tests/tpm_bootmode_tests
1006 ${RUNTEST} ${BUILD_RUN}/tests/utility_string_tests
1007 ${RUNTEST} ${BUILD_RUN}/tests/utility_tests
1008 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_devmode_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001009 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_firmware_tests
Randall Spangler0714d9d2013-02-05 10:23:38 -08001010 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_init_tests
1011 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel_tests
Randall Spangler7f436692013-02-05 12:42:36 -08001012 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel2_tests
1013 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel3_tests
1014 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel4_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001015 ${RUNTEST} ${BUILD_RUN}/tests/vboot_audio_tests
Randall Spanglere061a252013-01-22 15:34:07 -08001016 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common_tests
1017 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS}
1018 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS}
Randall Spangler786a5dc2013-01-24 14:19:56 -08001019 ${RUNTEST} ${BUILD_RUN}/tests/vboot_display_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001020 ${RUNTEST} ${BUILD_RUN}/tests/vboot_firmware_tests
Randall Spangler49cb0d32013-01-29 14:28:16 -08001021 ${RUNTEST} ${BUILD_RUN}/tests/vboot_kernel_tests
Randall Spangler6dbf9d92013-01-23 12:25:10 -08001022 ${RUNTEST} ${BUILD_RUN}/tests/vboot_nvstorage_test
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001023
1024.PHONY: runfutiltests
Bill Richardsonfeb25182013-03-07 12:54:29 -08001025runfutiltests: override DESTDIR = ${TEST_INSTALL_DIR}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001026runfutiltests: test_setup install
Bill Richardson339f7e02013-04-05 09:49:24 -07001027 tests/futility/run_test_scripts.sh ${DESTDIR}
1028 ${RUNTEST} ${BUILD_RUN}/tests/futility/test_not_really
Randall Spangler844bce52013-01-15 16:16:43 -08001029
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001030# Run long tests, including all permutations of encryption keys (instead of
Randall Spangler786a5dc2013-01-24 14:19:56 -08001031# just the ones we use) and tests of currently-unused code.
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001032# Not run by automated build.
Bill Richardsonacb2ee92013-01-11 22:53:00 -08001033.PHONY: runlongtests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001034runlongtests: test_setup genkeys genfuzztestcases
Randall Spanglere061a252013-01-22 15:34:07 -08001035 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS} --all
1036 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS} --all
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001037 tests/run_preamble_tests.sh --all
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001038 tests/run_vbutil_tests.sh --all
1039
1040# TODO: tests to run when ported to new API
1041# ./run_image_verification_tests.sh
1042# # Splicing tests
1043# ${BUILD}/tests/firmware_splicing_tests
1044# ${BUILD}/tests/kernel_splicing_tests
1045# # Rollback Tests
1046# ${BUILD}/tests/firmware_rollback_tests
1047# ${BUILD}/tests/kernel_rollback_tests
1048
Randall Spangler59d75082013-01-23 09:29:54 -08001049# Code coverage
1050.PHONY: coverage_init
1051coverage_init: test_setup
1052 rm -f ${COV_INFO}*
1053 lcov -c -i -d . -b . -o ${COV_INFO}.initial
1054
1055.PHONY: coverage_html
1056coverage_html:
1057 lcov -c -d . -b . -o ${COV_INFO}.tests
1058 lcov -a ${COV_INFO}.initial -a ${COV_INFO}.tests -o ${COV_INFO}.total
1059 lcov -r ${COV_INFO}.total '/usr/*' '*/linktest/*' -o ${COV_INFO}.local
1060 genhtml ${COV_INFO}.local -o ${BUILD}/coverage
1061
1062# Generate addtional coverage stats just for firmware subdir, because the
1063# per-directory stats for the whole project don't include their own subdirs.
Randall Spangler49cb0d32013-01-29 14:28:16 -08001064 lcov -r ${COV_INFO}.local '*/stub/*' -o ${COV_INFO}.nostub
1065 lcov -e ${COV_INFO}.nostub '${SRCDIR}/firmware/*' \
Randall Spangler59d75082013-01-23 09:29:54 -08001066 -o ${COV_INFO}.firmware
1067
1068.PHONY: coverage
1069ifeq (${COV},)
1070coverage:
1071 $(error Build coverage like this: make clean && COV=1 make)
1072else
1073coverage: coverage_init runtests coverage_html
1074endif
Bill Richardson1912bba2013-04-04 21:08:50 -07001075
1076# Include generated dependencies
1077ALL_DEPS += ${ALL_OBJS:%.o=%.o.d}
1078-include ${ALL_DEPS}