blob: ffe3946d40dac889dd8a6d093eb5fdd691e9da7b [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
Stefan Reinauerd96b25d2013-09-19 14:24:29 -0700102else ifeq (${FIRMWARE_ARCH},armv7)
103 override FIRMWARE_ARCH := arm
Randall Spangler61a2eb32013-01-23 10:20:16 -0800104endif
105
Simon Glassb265c342011-11-16 15:09:51 -0800106# Provide default CC and CFLAGS for firmware builds; if you have any -D flags,
107# please add them after this point (e.g., -DVBOOT_DEBUG).
Che-Liang Chiou74359b72011-06-21 15:25:51 -0700108#
Che-Liang Chiou6b0003c2011-10-14 11:11:28 +0800109# TODO(crosbug.com/16808) We hard-code u-boot's compiler flags here just
110# temporarily. As we are still investigating which flags are necessary for
111# maintaining a compatible ABI, etc. between u-boot and vboot_reference.
Che-Liang Chiou74359b72011-06-21 15:25:51 -0700112#
Simon Glassb265c342011-11-16 15:09:51 -0800113# As a first step, this makes the setting of CC and CFLAGS here optional, to
114# permit a calling script or Makefile to set these.
Che-Liang Chiou74359b72011-06-21 15:25:51 -0700115#
Simon Glassb265c342011-11-16 15:09:51 -0800116# Flag ordering: arch, then -f, then -m, then -W
117DEBUG_FLAGS := $(if ${DEBUG},-g -O0,-Os)
118COMMON_FLAGS := -nostdinc -pipe \
119 -ffreestanding -fno-builtin -fno-stack-protector \
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800120 -Werror -Wall -Wstrict-prototypes ${DEBUG_FLAGS}
Simon Glassb265c342011-11-16 15:09:51 -0800121
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800122# Note: FIRMWARE_ARCH is defined by the Chromium OS ebuild.
123ifeq (${FIRMWARE_ARCH}, arm)
Simon Glassb265c342011-11-16 15:09:51 -0800124CC ?= armv7a-cros-linux-gnueabi-gcc
125CFLAGS ?= -march=armv5 \
126 -fno-common -ffixed-r8 \
Doug Andersond50b27d2012-05-11 12:08:02 -0700127 -mfloat-abi=hard -marm -mabi=aapcs-linux -mno-thumb-interwork \
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800128 ${COMMON_FLAGS}
Randall Spangler61a2eb32013-01-23 10:20:16 -0800129else ifeq (${FIRMWARE_ARCH}, x86)
Simon Glassb265c342011-11-16 15:09:51 -0800130CC ?= i686-pc-linux-gnu-gcc
131# Drop -march=i386 to permit use of SSE instructions
132CFLAGS ?= \
133 -ffunction-sections -fvisibility=hidden -fno-strict-aliasing \
134 -fomit-frame-pointer -fno-toplevel-reorder -fno-dwarf2-cfi-asm \
Gabe Black46e00e62013-12-18 18:23:24 -0800135 -mpreferred-stack-boundary=2 \
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800136 ${COMMON_FLAGS}
137else ifeq (${FIRMWARE_ARCH}, x86_64)
138CFLAGS ?= ${COMMON_FLAGS} \
Simon Glass8e85e982011-11-22 13:54:50 -0800139 -fvisibility=hidden -fno-strict-aliasing -fomit-frame-pointer
Randall Spangler844bce52013-01-15 16:16:43 -0800140else
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800141# FIRMWARE_ARCH not defined; assuming local compile.
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800142CC ?= gcc
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800143CFLAGS += -DCHROMEOS_ENVIRONMENT -Wall -Werror # HEY: always want last two?
Che-Liang Chiou34be8272011-01-27 16:44:36 +0800144endif
145
Bill Richardsonfeb25182013-03-07 12:54:29 -0800146ifneq (${OLDDIR},)
147CFLAGS += -DOLDDIR=${OLDDIR}
148endif
149
Che-Liang Chiou34be8272011-01-27 16:44:36 +0800150ifneq (${DEBUG},)
151CFLAGS += -DVBOOT_DEBUG
vbendebb2b0fcc2010-07-15 15:09:47 -0700152endif
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +0800153
vbendebb2b0fcc2010-07-15 15:09:47 -0700154ifeq (${DISABLE_NDEBUG},)
155CFLAGS += -DNDEBUG
156endif
157
Bill Richardsonfeb25182013-03-07 12:54:29 -0800158ifneq (${FORCE_LOGGING_ON},)
159CFLAGS += -DFORCE_LOGGING_ON=${FORCE_LOGGING_ON}
160endif
161
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800162# Create / use dependency files
163CFLAGS += -MMD -MF $@.d
Simon Glassb265c342011-11-16 15:09:51 -0800164
Bill Richardson0c3ba242013-03-29 11:09:30 -0700165# These are required to access large disks and files on 32-bit systems.
166CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
167
Randall Spangler59d75082013-01-23 09:29:54 -0800168# Code coverage
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800169ifneq (${COV},)
Randall Spangler59d75082013-01-23 09:29:54 -0800170 COV_FLAGS = -O0 --coverage
171 CFLAGS += ${COV_FLAGS}
172 LDFLAGS += ${COV_FLAGS}
173 COV_INFO = ${BUILD}/coverage.info
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +0800174endif
Gaurav Shah322536d2010-01-28 15:01:23 -0800175
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800176# And a few more default utilities
177LD = ${CC}
178CXX ?= g++ # HEY: really?
179PKG_CONFIG ?= pkg-config
180
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800181# Determine QEMU architecture needed, if any
182ifeq (${ARCH},${HOST_ARCH})
183 # Same architecture; no need for QEMU
184 QEMU_ARCH :=
Randall Spangler61a2eb32013-01-23 10:20:16 -0800185else ifeq (${HOST_ARCH}-${ARCH},x86_64-x86)
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800186 # 64-bit host can run 32-bit targets directly
187 QEMU_ARCH :=
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800188else
189 QEMU_ARCH := ${ARCH}
190endif
191
192# The top of the chroot for qemu must be passed in via the SYSROOT environment
193# variable. In the Chromium OS chroot, this is done automatically by the
194# ebuild.
195
196ifeq (${QEMU_ARCH},)
197 # Path to build output for running tests is same as for building
198 BUILD_RUN = ${BUILD}
Randall Spanglere061a252013-01-22 15:34:07 -0800199 SRC_RUN = ${SRCDIR}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800200else
201 $(info Using qemu for testing.)
202 # Path to build output for running tests is different in the chroot
203 BUILD_RUN = $(subst ${SYSROOT},,${BUILD})
Randall Spanglere061a252013-01-22 15:34:07 -0800204 SRC_RUN = $(subst ${SYSROOT},,${SRCDIR})
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800205
206 QEMU_BIN = qemu-${QEMU_ARCH}
Randall Spanglere061a252013-01-22 15:34:07 -0800207 QEMU_RUN = ${BUILD_RUN}/${QEMU_BIN}
208 export QEMU_RUN
209
210 RUNTEST = tests/test_using_qemu.sh
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800211endif
212
Randall Spanglere061a252013-01-22 15:34:07 -0800213export BUILD_RUN
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800214
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800215##############################################################################
216# Now we need to describe everything we might want or need to build
217
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800218# Everything wants these headers.
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800219INCLUDES += \
220 -Ifirmware/include \
221 -Ifirmware/lib/include \
222 -Ifirmware/lib/cgptlib/include \
223 -Ifirmware/lib/cryptolib/include \
224 -Ifirmware/lib/tpm_lite/include
Bill Richardson0b8f35c2010-05-26 09:18:38 -0700225
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800226# If we're not building for a specific target, just stub out things like the
227# TPM commands and various external functions that are provided by the BIOS.
228ifeq (${FIRMWARE_ARCH},)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800229INCLUDES += -Ifirmware/stub/include
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +0800230else
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800231INCLUDES += -Ifirmware/arch/${FIRMWARE_ARCH}/include
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +0800232endif
Gaurav Shah322536d2010-01-28 15:01:23 -0800233
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800234# Firmware library. TODO: Do we still need to export this?
235FWLIB = ${BUILD}/vboot_fw.a
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800236
Randall Spangler93943262013-02-26 11:03:57 -0800237# Firmware library sources needed by VbInit() call
238VBINIT_SRCS = \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800239 firmware/lib/crc8.c \
Randall Spangler93943262013-02-26 11:03:57 -0800240 firmware/lib/utility.c \
241 firmware/lib/vboot_api_init.c \
242 firmware/lib/vboot_common_init.c \
243 firmware/lib/vboot_nvstorage.c \
Simon Glass527ba812013-07-25 08:48:47 -0600244 firmware/lib/region-init.c \
Randall Spangler93943262013-02-26 11:03:57 -0800245
246# Additional firmware library sources needed by VbSelectFirmware() call
247VBSF_SRCS = \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800248 firmware/lib/cryptolib/padding.c \
249 firmware/lib/cryptolib/rsa.c \
250 firmware/lib/cryptolib/rsa_utility.c \
251 firmware/lib/cryptolib/sha1.c \
252 firmware/lib/cryptolib/sha256.c \
253 firmware/lib/cryptolib/sha512.c \
254 firmware/lib/cryptolib/sha_utility.c \
255 firmware/lib/stateful_util.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800256 firmware/lib/vboot_api_firmware.c \
Randall Spangler93943262013-02-26 11:03:57 -0800257 firmware/lib/vboot_common.c \
Simon Glass527ba812013-07-25 08:48:47 -0600258 firmware/lib/vboot_firmware.c \
259 firmware/lib/region-fw.c \
Randall Spangler93943262013-02-26 11:03:57 -0800260
261# Additional firmware library sources needed by VbSelectAndLoadKernel() call
262VBSLK_SRCS = \
263 firmware/lib/cgptlib/cgptlib.c \
264 firmware/lib/cgptlib/cgptlib_internal.c \
265 firmware/lib/cgptlib/crc32.c \
Albert Chaulk5c9e4532013-03-20 16:03:49 -0700266 firmware/lib/cgptlib/mtdlib.c \
Randall Spangler93943262013-02-26 11:03:57 -0800267 firmware/lib/utility_string.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800268 firmware/lib/vboot_api_kernel.c \
269 firmware/lib/vboot_audio.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800270 firmware/lib/vboot_display.c \
Simon Glass527ba812013-07-25 08:48:47 -0600271 firmware/lib/vboot_kernel.c \
272 firmware/lib/region-kernel.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800273
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800274# Support real TPM unless BIOS sets MOCK_TPM
275ifeq (${MOCK_TPM},)
Randall Spangler93943262013-02-26 11:03:57 -0800276VBINIT_SRCS += \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800277 firmware/lib/rollback_index.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800278 firmware/lib/tpm_lite/tlcl.c
Randall Spangler93943262013-02-26 11:03:57 -0800279
280VBSF_SRCS += \
281 firmware/lib/tpm_bootmode.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800282else
Randall Spangler93943262013-02-26 11:03:57 -0800283VBINIT_SRCS += \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800284 firmware/lib/mocked_rollback_index.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800285 firmware/lib/tpm_lite/mocked_tlcl.c
Randall Spangler93943262013-02-26 11:03:57 -0800286
287VBSF_SRCS += \
288 firmware/lib/mocked_tpm_bootmode.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800289endif
290
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800291ifeq (${FIRMWARE_ARCH},)
292# Include BIOS stubs in the firmware library when compiling for host
Randall Spangler93943262013-02-26 11:03:57 -0800293# TODO: split out other stub funcs too
294VBINIT_SRCS += \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800295 firmware/stub/tpm_lite_stub.c \
296 firmware/stub/utility_stub.c \
Simon Glass527ba812013-07-25 08:48:47 -0600297 firmware/stub/vboot_api_stub_init.c \
298 firmware/stub/vboot_api_stub_region.c
Randall Spangler93943262013-02-26 11:03:57 -0800299
300VBSF_SRCS += \
301 firmware/stub/vboot_api_stub_sf.c
302
303VBSLK_SRCS += \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800304 firmware/stub/vboot_api_stub.c \
305 firmware/stub/vboot_api_stub_disk.c
306endif
307
Randall Spangler93943262013-02-26 11:03:57 -0800308VBSF_SRCS += ${VBINIT_SRCS}
309FWLIB_SRCS += ${VBSF_SRCS} ${VBSLK_SRCS}
310
311VBINIT_OBJS = ${VBINIT_SRCS:%.c=${BUILD}/%.o}
312VBSF_OBJS = ${VBSF_SRCS:%.c=${BUILD}/%.o}
313
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800314FWLIB_OBJS = ${FWLIB_SRCS:%.c=${BUILD}/%.o}
Bill Richardson1912bba2013-04-04 21:08:50 -0700315
316ALL_OBJS += ${FWLIB_OBJS} ${VBINIT_OBJS} ${VBSF_OBJS}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800317
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800318
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800319# Library to build the utilities. "HOST" mostly means "userspace".
Bill Richardsonc7c6e5d2013-02-28 10:10:29 -0800320HOSTLIB = ${BUILD}/libvboot_host.a
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800321
322HOSTLIB_SRCS = \
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800323 cgpt/cgpt_create.c \
324 cgpt/cgpt_add.c \
325 cgpt/cgpt_boot.c \
326 cgpt/cgpt_show.c \
327 cgpt/cgpt_repair.c \
328 cgpt/cgpt_prioritize.c \
329 cgpt/cgpt_common.c \
Albert Chaulk534723a2013-03-20 14:46:50 -0700330 cgpt/flash_ts_drv.c \
Albert Chaulkb334e652013-03-28 15:25:33 -0700331 firmware/lib/cgptlib/mtdlib.c \
Albert Chaulk534723a2013-03-20 14:46:50 -0700332 firmware/lib/flash_ts.c \
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800333 host/arch/${ARCH}/lib/crossystem_arch.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800334 host/lib/crossystem.c \
335 host/lib/file_keys.c \
336 host/lib/fmap.c \
337 host/lib/host_common.c \
338 host/lib/host_key.c \
339 host/lib/host_keyblock.c \
340 host/lib/host_misc.c \
341 host/lib/host_signature.c \
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800342 host/lib/signature_digest.c \
343 utility/dump_kernel_config_lib.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800344
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800345HOSTLIB_OBJS = ${HOSTLIB_SRCS:%.c=${BUILD}/%.o}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800346ALL_OBJS += ${HOSTLIB_OBJS}
347
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800348# Might need this too.
349CRYPTO_LIBS := $(shell ${PKG_CONFIG} --libs libcrypto)
350
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800351# Sigh. For historical reasons, the autoupdate installer must sometimes be a
352# 32-bit executable, even when everything else is 64-bit. But it only needs a
353# few functions, so let's just build those.
354TINYHOSTLIB = ${BUILD}/libtinyvboot_host.a
355
356TINYHOSTLIB_SRCS = \
357 cgpt/cgpt_create.c \
358 cgpt/cgpt_add.c \
359 cgpt/cgpt_boot.c \
360 cgpt/cgpt_show.c \
361 cgpt/cgpt_repair.c \
362 cgpt/cgpt_prioritize.c \
363 cgpt/cgpt_common.c \
Albert Chaulk534723a2013-03-20 14:46:50 -0700364 cgpt/flash_ts_drv.c \
Albert Chaulkb334e652013-03-28 15:25:33 -0700365 firmware/lib/cgptlib/mtdlib.c \
Albert Chaulk534723a2013-03-20 14:46:50 -0700366 firmware/lib/flash_ts.c \
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800367 utility/dump_kernel_config_lib.c \
368 firmware/lib/cgptlib/crc32.c \
369 firmware/lib/cgptlib/cgptlib_internal.c \
Bill Richardson5fed2a62013-03-04 15:11:38 -0800370 firmware/lib/utility_string.c \
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800371 firmware/stub/utility_stub.c
372
373TINYHOSTLIB_OBJS = ${TINYHOSTLIB_SRCS:%.c=${BUILD}/%.o}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800374
375# ----------------------------------------------------------------------------
376# Now for the userspace binaries
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800377
378CGPT = ${BUILD}/cgpt/cgpt
379
380CGPT_SRCS = \
381 cgpt/cgpt.c \
382 cgpt/cgpt_add.c \
383 cgpt/cgpt_boot.c \
384 cgpt/cgpt_common.c \
385 cgpt/cgpt_create.c \
386 cgpt/cgpt_find.c \
387 cgpt/cgpt_legacy.c \
388 cgpt/cgpt_prioritize.c \
389 cgpt/cgpt_repair.c \
390 cgpt/cgpt_show.c \
391 cgpt/cmd_add.c \
392 cgpt/cmd_boot.c \
393 cgpt/cmd_create.c \
394 cgpt/cmd_find.c \
395 cgpt/cmd_legacy.c \
396 cgpt/cmd_prioritize.c \
397 cgpt/cmd_repair.c \
Albert Chaulk534723a2013-03-20 14:46:50 -0700398 cgpt/cmd_show.c \
399 cgpt/flash_ts_drv.c \
400 firmware/lib/flash_ts.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800401
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800402CGPT_OBJS = ${CGPT_SRCS:%.c=${BUILD}/%.o}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800403ALL_OBJS += ${CGPT_OBJS}
404
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800405
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800406# Scripts to install directly (not compiled)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800407UTIL_SCRIPTS = \
408 utility/dev_debug_vboot \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800409 utility/enable_dev_usb_boot \
410 utility/vbutil_what_keys
411
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800412ifeq (${MINIMAL},)
413UTIL_SCRIPTS += \
414 utility/dev_make_keypair
415endif
416
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800417# These utilities should be linked statically.
418UTIL_NAMES_STATIC = \
Bill Richardson339f7e02013-04-05 09:49:24 -0700419 utility/crossystem \
Bill Richardson339f7e02013-04-05 09:49:24 -0700420 utility/gbb_utility
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800421
422UTIL_NAMES = ${UTIL_NAMES_STATIC} \
Bill Richardson339f7e02013-04-05 09:49:24 -0700423 utility/dev_sign_file \
424 utility/dump_kernel_config \
425 utility/dumpRSAPublicKey \
426 utility/tpm_init_temp_fix \
427 utility/tpmc \
428 utility/vbutil_firmware \
429 utility/vbutil_kernel \
430 utility/vbutil_key \
431 utility/vbutil_keyblock \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800432
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800433ifeq (${MINIMAL},)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800434UTIL_NAMES += \
Bill Richardson339f7e02013-04-05 09:49:24 -0700435 utility/bmpblk_font \
436 utility/bmpblk_utility \
437 utility/eficompress \
438 utility/efidecompress \
439 utility/load_kernel_test \
440 utility/pad_digest_utility \
441 utility/signature_digest_utility \
442 utility/verify_data
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800443endif
444
Bill Richardson339f7e02013-04-05 09:49:24 -0700445UTIL_BINS_STATIC := $(addprefix ${BUILD}/,${UTIL_NAMES_STATIC})
446UTIL_BINS = $(addprefix ${BUILD}/,${UTIL_NAMES})
Bill Richardson1912bba2013-04-04 21:08:50 -0700447ALL_OBJS += $(addsuffix .o,${UTIL_BINS} ${UTIL_BINS_STATIC})
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800448
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800449
450# Scripts for signing stuff.
451SIGNING_SCRIPTS = \
452 utility/tpm-nvsize \
453 utility/chromeos-tpm-recovery
454
455# These go in a different place.
456SIGNING_SCRIPTS_DEV = \
457 scripts/image_signing/resign_firmwarefd.sh \
458 scripts/image_signing/make_dev_firmware.sh \
459 scripts/image_signing/make_dev_ssd.sh \
460 scripts/image_signing/set_gbb_flags.sh
461
462# Installed, but not made executable.
463SIGNING_COMMON = scripts/image_signing/common_minimal.sh
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800464
Bill Richardson826db092013-01-14 12:37:15 -0800465
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800466# The unified firmware utility will eventually replace all the others
467FUTIL_BIN = ${BUILD}/futility/futility
Bill Richardson6db8c752013-04-05 13:30:43 -0700468# But we still need both static (tiny) and dynamic (with openssl) versions.
469FUTIL_STATIC_BIN = ${FUTIL_BIN}_s
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800470
Bill Richardsonfeb25182013-03-07 12:54:29 -0800471# These are the others it will replace.
Bill Richardson20807b62013-04-09 10:15:26 -0700472FUTIL_OLD = bmpblk_font bmpblk_utility cgpt chromeos-tpm-recovery crossystem \
473 dev_debug_vboot dev_make_keypair dev_sign_file dumpRSAPublicKey \
474 dump_fmap dump_kernel_config eficompress efidecompress \
475 enable_dev_usb_boot gbb_utility load_kernel_test \
476 make_dev_firmware.sh make_dev_ssd.sh pad_digest_utility \
477 resign_firmwarefd.sh set_gbb_flags.sh signature_digest_utility \
478 tpm-nvsize tpm_init_temp_fix tpmc vbutil_firmware vbutil_kernel \
479 vbutil_key vbutil_keyblock vbutil_what_keys verify_data
Bill Richardsonfeb25182013-03-07 12:54:29 -0800480
Bill Richardson6db8c752013-04-05 13:30:43 -0700481FUTIL_STATIC_SRCS = \
Bill Richardsonfeb25182013-03-07 12:54:29 -0800482 futility/futility.c \
Bill Richardson20807b62013-04-09 10:15:26 -0700483 futility/cmd_dump_fmap.c \
Bill Richardsonfeb25182013-03-07 12:54:29 -0800484 futility/cmd_foo.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800485
Bill Richardson6db8c752013-04-05 13:30:43 -0700486FUTIL_SRCS = \
487 $(FUTIL_STATIC_SRCS) \
488 futility/cmd_hey.c
489
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800490FUTIL_LDS = futility/futility.lds
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800491
Bill Richardson6db8c752013-04-05 13:30:43 -0700492FUTIL_STATIC_OBJS = ${FUTIL_STATIC_SRCS:%.c=${BUILD}/%.o}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800493FUTIL_OBJS = ${FUTIL_SRCS:%.c=${BUILD}/%.o}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800494
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800495ALL_OBJS += ${FUTIL_OBJS}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800496
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800497
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800498# Library of handy test functions.
499TESTLIB = ${BUILD}/tests/test.a
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800500
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800501TESTLIB_SRCS = \
502 tests/test_common.c \
503 tests/timer_utils.c \
504 tests/crc32_test.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800505
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800506TESTLIB_OBJS = ${TESTLIB_SRCS:%.c=${BUILD}/%.o}
507ALL_OBJS += ${TESTLIB_OBJS}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800508
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800509
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800510# And some compiled tests.
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800511TEST_NAMES = \
Bill Richardson339f7e02013-04-05 09:49:24 -0700512 tests/cgptlib_test \
513 tests/rollback_index2_tests \
514 tests/rollback_index3_tests \
515 tests/rsa_padding_test \
516 tests/rsa_utility_tests \
517 tests/rsa_verify_benchmark \
518 tests/sha_benchmark \
519 tests/sha_tests \
520 tests/stateful_util_tests \
521 tests/tlcl_tests \
522 tests/tpm_bootmode_tests \
523 tests/utility_string_tests \
524 tests/utility_tests \
525 tests/vboot_api_init_tests \
526 tests/vboot_api_devmode_tests \
527 tests/vboot_api_firmware_tests \
528 tests/vboot_api_kernel_tests \
529 tests/vboot_api_kernel2_tests \
530 tests/vboot_api_kernel3_tests \
531 tests/vboot_api_kernel4_tests \
532 tests/vboot_audio_tests \
533 tests/vboot_common_tests \
534 tests/vboot_common2_tests \
535 tests/vboot_common3_tests \
536 tests/vboot_display_tests \
537 tests/vboot_firmware_tests \
538 tests/vboot_kernel_tests \
539 tests/vboot_nvstorage_test \
540 tests/futility/test_not_really
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800541
Simon Glass527ba812013-07-25 08:48:47 -0600542ifdef REGION_READ
543TEST_NAMES += tests/vboot_region_tests
544endif
545
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800546# TODO: port these tests to new API, if not already eqivalent
547# functionality in other tests. These don't even compile at present.
548#
549# big_firmware_tests
550# big_kernel_tests
551# firmware_image_tests
552# firmware_rollback_tests
553# firmware_splicing_tests
554# firmware_verify_benchmark
555# kernel_image_tests
556# kernel_rollback_tests
557# kernel_splicing_tests
558# kernel_verify_benchmark
559# rollback_index_test
560# verify_firmware_fuzz_driver
561# verify_kernel_fuzz_driver
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800562# utility/load_firmware_test
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800563
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800564# And a few more...
Bill Richardson339f7e02013-04-05 09:49:24 -0700565TLCL_TEST_NAMES = \
566 tests/tpm_lite/tpmtest_earlyextend \
567 tests/tpm_lite/tpmtest_earlynvram \
568 tests/tpm_lite/tpmtest_earlynvram2 \
569 tests/tpm_lite/tpmtest_enable \
570 tests/tpm_lite/tpmtest_fastenable \
571 tests/tpm_lite/tpmtest_globallock \
572 tests/tpm_lite/tpmtest_redefine_unowned \
573 tests/tpm_lite/tpmtest_spaceperm \
574 tests/tpm_lite/tpmtest_testsetup \
575 tests/tpm_lite/tpmtest_timing \
576 tests/tpm_lite/tpmtest_writelimit
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800577
578TEST_NAMES += ${TLCL_TEST_NAMES}
579
Bill Richardson339f7e02013-04-05 09:49:24 -0700580# Finally
581TEST_BINS = $(addprefix ${BUILD}/,${TEST_NAMES})
Bill Richardson1912bba2013-04-04 21:08:50 -0700582ALL_OBJS += $(addsuffix .o,${TEST_BINS})
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800583
Randall Spanglere061a252013-01-22 15:34:07 -0800584# Directory containing test keys
585TEST_KEYS = ${SRC_RUN}/tests/testkeys
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800586
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800587
588##############################################################################
589# Finally, some targets. High-level ones first.
590
591# Create output directories if necessary. Do this via explicit shell commands
592# so it happens before trying to generate/include dependencies.
593SUBDIRS := firmware host cgpt utility futility tests tests/tpm_lite
594_dir_create := $(foreach d, \
595 $(shell find ${SUBDIRS} -name '*.c' -exec dirname {} \; | sort -u), \
596 $(shell [ -d ${BUILD}/${d} ] || mkdir -p ${BUILD}/${d}))
597
598
599# Default target.
600.PHONY: all
Randall Spangler59d75082013-01-23 09:29:54 -0800601all: fwlib $(if ${FIRMWARE_ARCH},,host_stuff) $(if ${COV},coverage)
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800602
603# Host targets
604.PHONY: host_stuff
605host_stuff: hostlib cgpt utils futil tests
606
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800607.PHONY: clean
608clean:
609 ${Q}/bin/rm -rf ${BUILD}
610
611.PHONY: install
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800612install: cgpt_install utils_install signing_install futil_install
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800613
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800614# Don't delete intermediate object files
615.SECONDARY:
616
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800617
618# ----------------------------------------------------------------------------
619# Firmware library
620
621# TPM-specific flags. These depend on the particular TPM we're targeting for.
622# They are needed here only for compiling parts of the firmware code into
623# user-level tests.
624
625# TPM_BLOCKING_CONTINUESELFTEST is defined if TPM_ContinueSelfTest blocks until
626# the self test has completed.
627
Randall Spangler45cc0f22013-01-25 09:34:26 -0800628${FWLIB_OBJS}: CFLAGS += -DTPM_BLOCKING_CONTINUESELFTEST
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800629
630# TPM_MANUAL_SELFTEST is defined if the self test must be started manually
631# (with a call to TPM_ContinueSelfTest) instead of starting automatically at
632# power on.
633#
634# We sincerely hope that TPM_BLOCKING_CONTINUESELFTEST and TPM_MANUAL_SELFTEST
635# are not both defined at the same time. (See comment in code.)
636
637# CFLAGS += -DTPM_MANUAL_SELFTEST
638
639ifeq (${FIRMWARE_ARCH},i386)
640# Unrolling loops in cryptolib makes it faster
Randall Spangler45cc0f22013-01-25 09:34:26 -0800641${FWLIB_OBJS}: CFLAGS += -DUNROLL_LOOPS
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800642
643# Workaround for coreboot on x86, which will power off asynchronously
644# without giving us a chance to react. This is not an example of the Right
645# Way to do things. See chrome-os-partner:7689, and the commit message
646# that made this change.
Randall Spangler45cc0f22013-01-25 09:34:26 -0800647${FWLIB_OBJS}: CFLAGS += -DSAVE_LOCALE_IMMEDIATELY
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800648
649# On x86 we don't actually read the GBB data into RAM until it is needed.
650# Therefore it makes sense to cache it rather than reading it each time.
651# Enable this feature.
Randall Spangler45cc0f22013-01-25 09:34:26 -0800652${FWLIB_OBJS}: CFLAGS += -DCOPY_BMP_DATA
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800653endif
654
Simon Glass527ba812013-07-25 08:48:47 -0600655ifdef REGION_READ
656${FWLIB_OBJS}: CFLAGS += -DREGION_READ
657endif
658
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800659ifeq (${FIRMWARE_ARCH},)
660# Disable rollback TPM when compiling locally, since otherwise
661# load_kernel_test attempts to talk to the TPM.
Randall Spangler45cc0f22013-01-25 09:34:26 -0800662${FWLIB_OBJS}: CFLAGS += -DDISABLE_ROLLBACK_TPM
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800663endif
664
Bill Richardsona130e0b2013-04-04 18:16:39 -0700665# Linktest ensures firmware lib doesn't rely on outside libraries
666${BUILD}/firmware/linktest/main_vbinit: ${VBINIT_OBJS}
Randall Spangler93943262013-02-26 11:03:57 -0800667${BUILD}/firmware/linktest/main_vbinit: OBJS = ${VBINIT_OBJS}
Bill Richardson1912bba2013-04-04 21:08:50 -0700668ALL_OBJS += ${BUILD}/firmware/linktest/main_vbinit.o
Bill Richardsona130e0b2013-04-04 18:16:39 -0700669${BUILD}/firmware/linktest/main_vbsf: ${VBSF_OBJS}
Randall Spangler93943262013-02-26 11:03:57 -0800670${BUILD}/firmware/linktest/main_vbsf: OBJS = ${VBSF_OBJS}
Bill Richardson1912bba2013-04-04 21:08:50 -0700671ALL_OBJS += ${BUILD}/firmware/linktest/main_vbsf.o
Bill Richardsona130e0b2013-04-04 18:16:39 -0700672${BUILD}/firmware/linktest/main: ${FWLIB}
673${BUILD}/firmware/linktest/main: LIBS = ${FWLIB}
Bill Richardson1912bba2013-04-04 21:08:50 -0700674ALL_OBJS += ${BUILD}/firmware/linktest/main.o
Randall Spangler93943262013-02-26 11:03:57 -0800675
676.phony: fwlinktest
677fwlinktest: ${FWLIB} \
678 ${BUILD}/firmware/linktest/main_vbinit \
679 ${BUILD}/firmware/linktest/main_vbsf \
680 ${BUILD}/firmware/linktest/main
681
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800682.PHONY: fwlib
Bill Richardsona130e0b2013-04-04 18:16:39 -0700683fwlib: $(if ${FIRMWARE_ARCH},${FWLIB},fwlinktest)
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800684
685${FWLIB}: ${FWLIB_OBJS}
Simon Glass661ae9e2013-03-26 11:39:21 -0700686 @$(PRINTF) " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800687 ${Q}rm -f $@
Simon Glass661ae9e2013-03-26 11:39:21 -0700688 @$(PRINTF) " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800689 ${Q}ar qc $@ $^
690
691# ----------------------------------------------------------------------------
692# Host library
693
Bill Richardsona130e0b2013-04-04 18:16:39 -0700694
695# Link tests
696${BUILD}/host/linktest/main: ${HOSTLIB}
697${BUILD}/host/linktest/main: LIBS = ${HOSTLIB}
Bill Richardson1912bba2013-04-04 21:08:50 -0700698ALL_OBJS += ${BUILD}/host/linktest/main.o
Bill Richardsona130e0b2013-04-04 18:16:39 -0700699
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800700.PHONY: hostlib
Bill Richardsona130e0b2013-04-04 18:16:39 -0700701hostlib: ${BUILD}/host/linktest/main
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800702
703${BUILD}/host/% ${HOSTLIB}: INCLUDES += \
Bill Richardson0c3ba242013-03-29 11:09:30 -0700704 -Ihost/include \
705 -Ihost/arch/${ARCH}/include \
706 -Ihost/lib/include
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800707
708# TODO: better way to make .a than duplicating this recipe each time?
709${HOSTLIB}: ${HOSTLIB_OBJS} ${FWLIB_OBJS}
Simon Glass661ae9e2013-03-26 11:39:21 -0700710 @$(PRINTF) " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800711 ${Q}rm -f $@
Simon Glass661ae9e2013-03-26 11:39:21 -0700712 @$(PRINTF) " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800713 ${Q}ar qc $@ $^
714
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800715
716# Ugh. This is a very cut-down version of HOSTLIB just for the installer.
717.PHONY: tinyhostlib
718tinyhostlib: ${TINYHOSTLIB}
719 ${Q}cp -f ${TINYHOSTLIB} ${HOSTLIB}
720
721${TINYHOSTLIB}: ${TINYHOSTLIB_OBJS}
Simon Glass661ae9e2013-03-26 11:39:21 -0700722 @$(PRINTF) " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800723 ${Q}rm -f $@
Simon Glass661ae9e2013-03-26 11:39:21 -0700724 @$(PRINTF) " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800725 ${Q}ar qc $@ $^
726
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800727# ----------------------------------------------------------------------------
728# CGPT library and utility
729
730.PHONY: cgpt
731cgpt: ${CGPT}
732
Bill Richardson0c3ba242013-03-29 11:09:30 -0700733${CGPT_OBJS}: INCLUDES += -Ihost/include
734
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800735${CGPT}: LDFLAGS += -static
736${CGPT}: LDLIBS += -luuid
737
Bill Richardsona130e0b2013-04-04 18:16:39 -0700738${CGPT}: ${CGPT_OBJS} ${HOSTLIB}
Simon Glass661ae9e2013-03-26 11:39:21 -0700739 @$(PRINTF) " LDcgpt $(subst ${BUILD}/,,$@)\n"
Bill Richardson6db8c752013-04-05 13:30:43 -0700740 ${Q}${LD} -o ${CGPT} ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800741
742.PHONY: cgpt_install
743cgpt_install: ${CGPT}
Simon Glass661ae9e2013-03-26 11:39:21 -0700744 @$(PRINTF) " INSTALL CGPT\n"
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800745 ${Q}mkdir -p ${UB_DIR}
746 ${Q}${INSTALL} -t ${UB_DIR} $^
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800747
748# ----------------------------------------------------------------------------
749# Utilities
750
751# These have their own headers too.
Bill Richardson0c3ba242013-03-29 11:09:30 -0700752${BUILD}/utility/%: INCLUDES += \
753 -Ihost/include \
754 -Ihost/lib/include \
755 -Iutility/include
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800756
757# Utilities for auto-update toolkits must be statically linked.
758${UTIL_BINS_STATIC}: LDFLAGS += -static
759
Bill Richardsona130e0b2013-04-04 18:16:39 -0700760
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800761.PHONY: utils
Bill Richardsonc7c6e5d2013-02-28 10:10:29 -0800762utils: ${UTIL_BINS} ${UTIL_SCRIPTS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800763 ${Q}cp -f ${UTIL_SCRIPTS} ${BUILD}/utility
764 ${Q}chmod a+rx $(patsubst %,${BUILD}/%,${UTIL_SCRIPTS})
765
Bill Richardsona130e0b2013-04-04 18:16:39 -0700766${UTIL_BINS} ${UTIL_BINS_STATIC}: ${HOSTLIB}
767${UTIL_BINS} ${UTIL_BINS_STATIC}: LIBS = ${HOSTLIB}
768
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800769.PHONY: utils_install
Bill Richardsonc7c6e5d2013-02-28 10:10:29 -0800770utils_install: ${UTIL_BINS} ${UTIL_SCRIPTS}
Simon Glass661ae9e2013-03-26 11:39:21 -0700771 @$(PRINTF) " INSTALL UTILS\n"
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800772 ${Q}mkdir -p ${UB_DIR}
773 ${Q}${INSTALL} -t ${UB_DIR} ${UTIL_BINS} ${UTIL_SCRIPTS}
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800774
775# And some signing stuff for the target
776.PHONY: signing_install
777signing_install: ${SIGNING_SCRIPTS} ${SIGNING_SCRIPTS_DEV} ${SIGNING_COMMON}
Simon Glass661ae9e2013-03-26 11:39:21 -0700778 @$(PRINTF) " INSTALL SIGNING\n"
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800779 ${Q}mkdir -p ${UB_DIR}
780 ${Q}${INSTALL} -t ${UB_DIR} ${SIGNING_SCRIPTS}
Bill Richardsonfeb25182013-03-07 12:54:29 -0800781 ${Q}${INSTALL} -t ${UB_DIR} ${SIGNING_SCRIPTS_DEV}
782 ${Q}${INSTALL} -t ${UB_DIR} -m 'u=rw,go=r,a-s' ${SIGNING_COMMON}
783ifneq (${VB_DIR},)
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800784 ${Q}mkdir -p ${VB_DIR}
Bill Richardsonfeb25182013-03-07 12:54:29 -0800785 ${Q}for prog in $(notdir ${SIGNING_SCRIPTS_DEV}); do \
786 ln -sf "${FT_DIR}/futility" "${VB_DIR}/$$prog"; done
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800787endif
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800788
789# ----------------------------------------------------------------------------
790# new Firmware Utility
791
792.PHONY: futil
Bill Richardson6db8c752013-04-05 13:30:43 -0700793futil: ${FUTIL_STATIC_BIN} ${FUTIL_BIN}
794
795${FUTIL_STATIC_BIN}: ${FUTIL_LDS} ${FUTIL_STATIC_OBJS}
796 @$(PRINTF) " LD $(subst ${BUILD}/,,$@)\n"
797 ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} -static $^ ${LDLIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800798
799${FUTIL_BIN}: ${FUTIL_LDS} ${FUTIL_OBJS}
Simon Glass661ae9e2013-03-26 11:39:21 -0700800 @$(PRINTF) " LD $(subst ${BUILD}/,,$@)\n"
Bill Richardson6db8c752013-04-05 13:30:43 -0700801 ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800802
803.PHONY: futil_install
804futil_install: ${FUTIL_BIN}
Simon Glass661ae9e2013-03-26 11:39:21 -0700805 @$(PRINTF) " INSTALL futility\n"
Bill Richardsonfeb25182013-03-07 12:54:29 -0800806 ${Q}mkdir -p ${F_DIR}
Bill Richardson6db8c752013-04-05 13:30:43 -0700807 ${Q}${INSTALL} -t ${F_DIR} ${FUTIL_BIN} ${FUTIL_STATIC_BIN}
Bill Richardsonfeb25182013-03-07 12:54:29 -0800808 ${Q}for prog in ${FUTIL_OLD}; do \
809 ln -sf futility "${F_DIR}/$$prog"; done
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800810
Bill Richardson20807b62013-04-09 10:15:26 -0700811# TODO(wfrichar): This will need some refactoring (crbug.com/228932)
812${BUILD}/futility/% ${HOSTLIB}: INCLUDES += \
813 -Ihost/include \
814 -Ihost/arch/${ARCH}/include \
815 -Ihost/lib/include
816${FUTIL_STATIC_BIN} ${FUTIL_BIN}: ${HOSTLIB}
817${FUTIL_STATIC_BIN} ${FUTIL_BIN}: LIBS = ${HOSTLIB}
818
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800819# ----------------------------------------------------------------------------
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800820# Utility to generate TLCL structure definition header file.
821
822${BUILD}/utility/tlcl_generator: CFLAGS += -fpack-struct
823
824STRUCTURES_TMP=${BUILD}/tlcl_structures.tmp
825STRUCTURES_SRC=firmware/lib/tpm_lite/include/tlcl_structures.h
826
827.PHONY: update_tlcl_structures
828update_tlcl_structures: ${BUILD}/utility/tlcl_generator
Simon Glass661ae9e2013-03-26 11:39:21 -0700829 @$(PRINTF) " Rebuilding TLCL structures\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800830 ${Q}${BUILD}/utility/tlcl_generator > ${STRUCTURES_TMP}
831 ${Q}cmp -s ${STRUCTURES_TMP} ${STRUCTURES_SRC} || \
832 ( echo "%% Updating structures.h %%" && \
833 cp ${STRUCTURES_TMP} ${STRUCTURES_SRC} )
834
835# ----------------------------------------------------------------------------
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800836# Tests
837
838.PHONY: tests
839tests: ${TEST_BINS}
840
Bill Richardsona130e0b2013-04-04 18:16:39 -0700841${TEST_BINS}: ${HOSTLIB} ${TESTLIB}
Bill Richardson339f7e02013-04-05 09:49:24 -0700842${TEST_BINS}: INCLUDES += -Itests
Bill Richardsona130e0b2013-04-04 18:16:39 -0700843${TEST_BINS}: LIBS = ${HOSTLIB} ${TESTLIB}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800844
845${TESTLIB}: ${TESTLIB_OBJS}
Simon Glass661ae9e2013-03-26 11:39:21 -0700846 @$(PRINTF) " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800847 ${Q}rm -f $@
Simon Glass661ae9e2013-03-26 11:39:21 -0700848 @$(PRINTF) " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800849 ${Q}ar qc $@ $^
850
851
852# ----------------------------------------------------------------------------
853# Generic build rules. LIBS and OBJS can be overridden to tweak the generic
854# rules for specific targets.
855
856${BUILD}/%: ${BUILD}/%.o ${OBJS} ${LIBS}
Simon Glass661ae9e2013-03-26 11:39:21 -0700857 @$(PRINTF) " LD $(subst ${BUILD}/,,$@)\n"
Bill Richardson6db8c752013-04-05 13:30:43 -0700858 ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $< ${OBJS} ${LIBS} ${LDLIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800859
860${BUILD}/%.o: %.c
Simon Glass661ae9e2013-03-26 11:39:21 -0700861 @$(PRINTF) " CC $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800862 ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
863
864# Rules to recompile a single source file for library and test
865# TODO: is there a tidier way to do this?
866${BUILD}/%_for_lib.o: CFLAGS += -DFOR_LIBRARY
867${BUILD}/%_for_lib.o: %.c
Simon Glass661ae9e2013-03-26 11:39:21 -0700868 @$(PRINTF) " CC-for-lib $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800869 ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
870
871${BUILD}/%_for_test.o: CFLAGS += -DFOR_TEST
872${BUILD}/%_for_test.o: %.c
Simon Glass661ae9e2013-03-26 11:39:21 -0700873 @$(PRINTF) " CC-for-test $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800874 ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
875
876# TODO: C++ files don't belong in vboot reference at all. Convert to C.
877${BUILD}/%.o: %.cc
Simon Glass661ae9e2013-03-26 11:39:21 -0700878 @$(PRINTF) " CXX $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800879 ${Q}${CXX} ${CFLAGS} ${INCLUDES} -c -o $@ $<
880
881# ----------------------------------------------------------------------------
882# Here are the special tweaks to the generic rules.
883
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800884# GBB utility needs C++ linker. TODO: It shouldn't.
885${BUILD}/utility/gbb_utility: LD = ${CXX}
886
Bill Richardsonfeb25182013-03-07 12:54:29 -0800887# Because we play some clever linker script games to add new commands without
888# changing any header files, futility must be linked with ld.bfd, not gold.
889${FUTIL_BIN}: LDFLAGS += -fuse-ld=bfd
Bill Richardson6db8c752013-04-05 13:30:43 -0700890${FUTIL_STATIC_BIN}: LDFLAGS += -fuse-ld=bfd
Bill Richardsonfeb25182013-03-07 12:54:29 -0800891
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800892# Some utilities need external crypto functions
893${BUILD}/utility/dumpRSAPublicKey: LDLIBS += ${CRYPTO_LIBS}
894${BUILD}/utility/pad_digest_utility: LDLIBS += ${CRYPTO_LIBS}
895${BUILD}/utility/signature_digest_utility: LDLIBS += ${CRYPTO_LIBS}
896${BUILD}/utility/dev_sign_file: LDLIBS += ${CRYPTO_LIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800897${BUILD}/utility/vbutil_firmware: LDLIBS += ${CRYPTO_LIBS}
898${BUILD}/utility/vbutil_kernel: LDLIBS += ${CRYPTO_LIBS}
899${BUILD}/utility/vbutil_key: LDLIBS += ${CRYPTO_LIBS}
900${BUILD}/utility/vbutil_keyblock: LDLIBS += ${CRYPTO_LIBS}
901
902${BUILD}/host/linktest/main: LDLIBS += ${CRYPTO_LIBS}
903${BUILD}/tests/vboot_common2_tests: LDLIBS += ${CRYPTO_LIBS}
904${BUILD}/tests/vboot_common3_tests: LDLIBS += ${CRYPTO_LIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800905
906${BUILD}/utility/bmpblk_utility: LD = ${CXX}
907${BUILD}/utility/bmpblk_utility: LDLIBS = -llzma -lyaml
908
909BMPBLK_UTILITY_DEPS = \
910 ${BUILD}/utility/bmpblk_util.o \
911 ${BUILD}/utility/image_types.o \
912 ${BUILD}/utility/eficompress_for_lib.o \
913 ${BUILD}/utility/efidecompress_for_lib.o
Bill Richardson1912bba2013-04-04 21:08:50 -0700914
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800915${BUILD}/utility/bmpblk_utility: OBJS = ${BMPBLK_UTILITY_DEPS}
916${BUILD}/utility/bmpblk_utility: ${BMPBLK_UTILITY_DEPS}
Bill Richardson1912bba2013-04-04 21:08:50 -0700917ALL_OBJS += ${BMPBLK_UTILITY_DEPS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800918
919${BUILD}/utility/bmpblk_font: OBJS += ${BUILD}/utility/image_types.o
920${BUILD}/utility/bmpblk_font: ${BUILD}/utility/image_types.o
Bill Richardson1912bba2013-04-04 21:08:50 -0700921ALL_OBJS += ${BUILD}/utility/image_types.o
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800922
923# Allow multiple definitions, so tests can mock functions from other libraries
924${BUILD}/tests/%: CFLAGS += -Xlinker --allow-multiple-definition
Bill Richardson0c3ba242013-03-29 11:09:30 -0700925${BUILD}/tests/%: INCLUDES += -Ihost/include -Ihost/lib/include
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800926${BUILD}/tests/%: LDLIBS += -lrt -luuid
927${BUILD}/tests/%: LIBS += ${TESTLIB}
928
929${BUILD}/tests/rollback_index2_tests: OBJS += \
930 ${BUILD}/firmware/lib/rollback_index_for_test.o
931${BUILD}/tests/rollback_index2_tests: \
932 ${BUILD}/firmware/lib/rollback_index_for_test.o
Bill Richardson1912bba2013-04-04 21:08:50 -0700933ALL_OBJS += ${BUILD}/firmware/lib/rollback_index_for_test.o
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800934
Randall Spanglerc3d488d2013-01-28 16:23:48 -0800935${BUILD}/tests/tlcl_tests: OBJS += \
936 ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
937${BUILD}/tests/tlcl_tests: \
938 ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
Bill Richardson1912bba2013-04-04 21:08:50 -0700939ALL_OBJS += ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
Randall Spanglerc3d488d2013-01-28 16:23:48 -0800940
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800941${BUILD}/tests/vboot_audio_tests: OBJS += \
942 ${BUILD}/firmware/lib/vboot_audio_for_test.o
943${BUILD}/tests/vboot_audio_tests: \
944 ${BUILD}/firmware/lib/vboot_audio_for_test.o
Bill Richardson1912bba2013-04-04 21:08:50 -0700945ALL_OBJS += ${BUILD}/firmware/lib/vboot_audio_for_test.o
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800946
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800947${BUILD}/tests/rollback_index_test: INCLUDES += -I/usr/include
948${BUILD}/tests/rollback_index_test: LIBS += -ltlcl
949
Bill Richardson339f7e02013-04-05 09:49:24 -0700950TLCL_TEST_BINS = $(addprefix ${BUILD}/,${TLCL_TEST_NAMES})
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800951${TLCL_TEST_BINS}: OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o
952${TLCL_TEST_BINS}: ${BUILD}/tests/tpm_lite/tlcl_tests.o
Bill Richardson1912bba2013-04-04 21:08:50 -0700953ALL_OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800954
955##############################################################################
956# Targets that exist just to run tests
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800957
958# Frequently-run tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800959.PHONY: test_targets
960test_targets:: runcgpttests runmisctests
Randall Spangler844bce52013-01-15 16:16:43 -0800961
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800962ifeq (${MINIMAL},)
Randall Spangler844bce52013-01-15 16:16:43 -0800963# Bitmap utility isn't compiled for minimal variant
Bill Richardsonfeb25182013-03-07 12:54:29 -0800964test_targets:: runbmptests runfutiltests
Randall Spangler844bce52013-01-15 16:16:43 -0800965# Scripts don't work under qemu testing
966# TODO: convert scripts to makefile so they can be called directly
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800967test_targets:: runtestscripts
Randall Spangler844bce52013-01-15 16:16:43 -0800968endif
969
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800970.PHONY: test_setup
971test_setup:: cgpt utils futil tests
972
Randall Spangler844bce52013-01-15 16:16:43 -0800973# Qemu setup for cross-compiled tests. Need to copy qemu binary into the
974# sysroot.
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800975ifneq (${QEMU_ARCH},)
976test_setup:: qemu_install
Randall Spangler844bce52013-01-15 16:16:43 -0800977
978.PHONY: qemu_install
979qemu_install:
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800980ifeq (${SYSROOT},)
981 $(error SYSROOT must be set to the top of the target-specific root \
982when cross-compiling for qemu-based tests to run properly.)
983endif
Simon Glass661ae9e2013-03-26 11:39:21 -0700984 @$(PRINTF) " Copying qemu binary.\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800985 ${Q}cp -fu /usr/bin/${QEMU_BIN} ${BUILD}/${QEMU_BIN}
986 ${Q}chmod a+rx ${BUILD}/${QEMU_BIN}
Randall Spangler844bce52013-01-15 16:16:43 -0800987endif
988
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800989.PHONY: runtests
Bill Richardsona130e0b2013-04-04 18:16:39 -0700990runtests: test_setup test_targets
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800991
992# Generate test keys
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800993.PHONY: genkeys
Randall Spangler844bce52013-01-15 16:16:43 -0800994genkeys: utils
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800995 tests/gen_test_keys.sh
996
997# Generate test cases for fuzzing
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800998.PHONY: genfuzztestcases
Randall Spanglera808dc92013-01-14 12:59:05 -0800999genfuzztestcases: utils
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001000 tests/gen_fuzz_test_cases.sh
1001
Bill Richardsonacb2ee92013-01-11 22:53:00 -08001002.PHONY: runbmptests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001003runbmptests: test_setup
1004 cd tests/bitmaps && BMPBLK=${BUILD_RUN}/utility/bmpblk_utility \
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001005 ./TestBmpBlock.py -v
1006
Bill Richardsonacb2ee92013-01-11 22:53:00 -08001007.PHONY: runcgpttests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001008runcgpttests: test_setup
1009 ${RUNTEST} ${BUILD_RUN}/tests/cgptlib_test
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001010
Randall Spangler844bce52013-01-15 16:16:43 -08001011.PHONY: runtestscripts
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001012runtestscripts: test_setup genfuzztestcases
1013 tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt
Albert Chaulk42c08cb2013-04-02 14:38:07 -07001014 tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt -N=512,32,1,3
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001015 tests/run_preamble_tests.sh
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001016 tests/run_rsa_tests.sh
Randall Spangler844bce52013-01-15 16:16:43 -08001017 tests/run_vbutil_kernel_arg_tests.sh
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001018 tests/run_vbutil_tests.sh
1019
Randall Spangler844bce52013-01-15 16:16:43 -08001020.PHONY: runmisctests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001021runmisctests: test_setup
1022 ${RUNTEST} ${BUILD_RUN}/tests/rollback_index2_tests
Randall Spanglera3eac792013-01-23 13:04:05 -08001023 ${RUNTEST} ${BUILD_RUN}/tests/rollback_index3_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001024 ${RUNTEST} ${BUILD_RUN}/tests/rsa_utility_tests
1025 ${RUNTEST} ${BUILD_RUN}/tests/sha_tests
1026 ${RUNTEST} ${BUILD_RUN}/tests/stateful_util_tests
Randall Spanglerc3d488d2013-01-28 16:23:48 -08001027 ${RUNTEST} ${BUILD_RUN}/tests/tlcl_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001028 ${RUNTEST} ${BUILD_RUN}/tests/tpm_bootmode_tests
1029 ${RUNTEST} ${BUILD_RUN}/tests/utility_string_tests
1030 ${RUNTEST} ${BUILD_RUN}/tests/utility_tests
1031 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_devmode_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001032 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_firmware_tests
Randall Spangler0714d9d2013-02-05 10:23:38 -08001033 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_init_tests
1034 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel_tests
Randall Spangler7f436692013-02-05 12:42:36 -08001035 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel2_tests
1036 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel3_tests
1037 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel4_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001038 ${RUNTEST} ${BUILD_RUN}/tests/vboot_audio_tests
Randall Spanglere061a252013-01-22 15:34:07 -08001039 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common_tests
1040 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS}
1041 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS}
Randall Spangler786a5dc2013-01-24 14:19:56 -08001042 ${RUNTEST} ${BUILD_RUN}/tests/vboot_display_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001043 ${RUNTEST} ${BUILD_RUN}/tests/vboot_firmware_tests
Randall Spangler49cb0d32013-01-29 14:28:16 -08001044 ${RUNTEST} ${BUILD_RUN}/tests/vboot_kernel_tests
Randall Spangler6dbf9d92013-01-23 12:25:10 -08001045 ${RUNTEST} ${BUILD_RUN}/tests/vboot_nvstorage_test
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001046
1047.PHONY: runfutiltests
Bill Richardsonfeb25182013-03-07 12:54:29 -08001048runfutiltests: override DESTDIR = ${TEST_INSTALL_DIR}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001049runfutiltests: test_setup install
Bill Richardson339f7e02013-04-05 09:49:24 -07001050 tests/futility/run_test_scripts.sh ${DESTDIR}
1051 ${RUNTEST} ${BUILD_RUN}/tests/futility/test_not_really
Randall Spangler844bce52013-01-15 16:16:43 -08001052
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001053# Run long tests, including all permutations of encryption keys (instead of
Randall Spangler786a5dc2013-01-24 14:19:56 -08001054# just the ones we use) and tests of currently-unused code.
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001055# Not run by automated build.
Bill Richardsonacb2ee92013-01-11 22:53:00 -08001056.PHONY: runlongtests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001057runlongtests: test_setup genkeys genfuzztestcases
Randall Spanglere061a252013-01-22 15:34:07 -08001058 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS} --all
1059 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS} --all
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001060 tests/run_preamble_tests.sh --all
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001061 tests/run_vbutil_tests.sh --all
1062
1063# TODO: tests to run when ported to new API
1064# ./run_image_verification_tests.sh
1065# # Splicing tests
1066# ${BUILD}/tests/firmware_splicing_tests
1067# ${BUILD}/tests/kernel_splicing_tests
1068# # Rollback Tests
1069# ${BUILD}/tests/firmware_rollback_tests
1070# ${BUILD}/tests/kernel_rollback_tests
1071
Randall Spangler59d75082013-01-23 09:29:54 -08001072# Code coverage
1073.PHONY: coverage_init
1074coverage_init: test_setup
1075 rm -f ${COV_INFO}*
1076 lcov -c -i -d . -b . -o ${COV_INFO}.initial
1077
1078.PHONY: coverage_html
1079coverage_html:
1080 lcov -c -d . -b . -o ${COV_INFO}.tests
1081 lcov -a ${COV_INFO}.initial -a ${COV_INFO}.tests -o ${COV_INFO}.total
1082 lcov -r ${COV_INFO}.total '/usr/*' '*/linktest/*' -o ${COV_INFO}.local
1083 genhtml ${COV_INFO}.local -o ${BUILD}/coverage
1084
1085# Generate addtional coverage stats just for firmware subdir, because the
1086# per-directory stats for the whole project don't include their own subdirs.
Randall Spangler49cb0d32013-01-29 14:28:16 -08001087 lcov -r ${COV_INFO}.local '*/stub/*' -o ${COV_INFO}.nostub
1088 lcov -e ${COV_INFO}.nostub '${SRCDIR}/firmware/*' \
Randall Spangler59d75082013-01-23 09:29:54 -08001089 -o ${COV_INFO}.firmware
1090
1091.PHONY: coverage
1092ifeq (${COV},)
1093coverage:
1094 $(error Build coverage like this: make clean && COV=1 make)
1095else
1096coverage: coverage_init runtests coverage_html
1097endif
Bill Richardson1912bba2013-04-04 21:08:50 -07001098
1099# Include generated dependencies
1100ALL_DEPS += ${ALL_OBJS:%.o=%.o.d}
1101-include ${ALL_DEPS}