Makefile revision 49cb0d3471e768da11fe76b65769bd57dca38bd7
1e8cfa31d548c069d73c304fea522b527fe7c7dd6Randall Spangler# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2322536d2f9d30f42218cc9f2ab40574557da8a9Gaurav Shah# Use of this source code is governed by a BSD-style license that can be
3322536d2f9d30f42218cc9f2ab40574557da8a9Gaurav Shah# found in the LICENSE file.
4322536d2f9d30f42218cc9f2ab40574557da8a9Gaurav Shah
56d696e532c6a0c93ad9b915c59dad4144e6f1b33Simon Glass# This Makefile normally builds in a 'build' subdir, but use
66d696e532c6a0c93ad9b915c59dad4144e6f1b33Simon Glass#
76d696e532c6a0c93ad9b915c59dad4144e6f1b33Simon Glass#    make BUILD=<dir>
86d696e532c6a0c93ad9b915c59dad4144e6f1b33Simon Glass#
9eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# to put the output somewhere else.
10eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
11eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson##############################################################################
12eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Make variables come in two flavors, immediate or deferred.
13eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#
14eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#   Variable definitions are parsed like this:
15eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#
16eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#        IMMEDIATE = DEFERRED
17eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#    or
18eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#        IMMEDIATE := IMMEDIATE
19eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#
20eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#   Rules are parsed this way:
21eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#
22eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#        IMMEDIATE : IMMEDIATE
23eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#           DEFERRED
24eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#
25eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# So you can assign variables in any order if they're only to be used in
26eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# actions, but if you use a variable in either the target or prerequisite of a
27eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# rule, the rule will be constructed using only the top-down, immediate value.
28eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#
29eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# So we'll try to define all the variables first. Then the rules.
30eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#
31eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
32eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson##############################################################################
33eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Configuration variables come first.
34eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#
35eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Our convention is that we only use := for variables that will never be
36eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# changed or appended. They must be defined before being used anywhere.
37eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
38eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# we should only run pwd once, not every time we refer to ${BUILD}.
39e061a256549607a56d771eb8ddae5d0dd90d519cRandall SpanglerSRCDIR := $(shell pwd)
40e061a256549607a56d771eb8ddae5d0dd90d519cRandall SpanglerBUILD ?= $(SRCDIR)/build
41844bce57471153664c78993dab453e87891bb969Randall Spanglerexport BUILD
425d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
435d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Target for 'make install'
445d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerDESTDIR ?= /usr/bin
45826db09fcec194951e1dc71002d6a92620fbb46bBill RichardsonINSTALL ?= install
466d696e532c6a0c93ad9b915c59dad4144e6f1b33Simon Glass
47eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Where to install the (exportable) executables for testing?
48eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTEST_INSTALL_DIR = ${BUILD}/install_for_test
49eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
50eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Verbose? Use V=1
51eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${V},)
52eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonQ := @
53eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
54eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
5561a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# Architecture detection
5661a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler_machname := $(shell uname -m)
5761a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall SpanglerHOST_ARCH ?= ${_machname}
5861a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler
5961a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# ARCH and/or FIRMWARE_ARCH are defined by the Chromium OS ebuild.
6061a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# Pick a sane target architecture if none is defined.
6161a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerifeq (${ARCH},)
6261a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler  ARCH := ${HOST_ARCH}
6361a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${ARCH},i386)
6461a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler  override ARCH := x86
6561a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${ARCH},amd64)
6661a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler  override ARCH := x86_64
6761a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerendif
6861a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler
6961a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# FIRMWARE_ARCH is only defined by the Chromium OS ebuild if compiling
7061a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# for a firmware target (such as u-boot or depthcharge). It must map
7161a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# to the same consistent set of architectures as the host.
7261a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerifeq (${FIRMWARE_ARCH},i386)
7361a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler  override FIRMWARE_ARCH := x86
7461a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${FIRMWARE_ARCH},amd64)
7561a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler  override FIRMWARE_ARCH := x86_64
7661a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerendif
7761a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler
78b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# Provide default CC and CFLAGS for firmware builds; if you have any -D flags,
79b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# please add them after this point (e.g., -DVBOOT_DEBUG).
8074359b755c4a203df0fe3bf51fc53d5de87d1fbfChe-Liang Chiou#
816b0003c6381a7e69818b0b34b358c2cfb1393043Che-Liang Chiou# TODO(crosbug.com/16808) We hard-code u-boot's compiler flags here just
826b0003c6381a7e69818b0b34b358c2cfb1393043Che-Liang Chiou# temporarily. As we are still investigating which flags are necessary for
836b0003c6381a7e69818b0b34b358c2cfb1393043Che-Liang Chiou# maintaining a compatible ABI, etc. between u-boot and vboot_reference.
8474359b755c4a203df0fe3bf51fc53d5de87d1fbfChe-Liang Chiou#
85b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# As a first step, this makes the setting of CC and CFLAGS here optional, to
86b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# permit a calling script or Makefile to set these.
8774359b755c4a203df0fe3bf51fc53d5de87d1fbfChe-Liang Chiou#
88b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# Flag ordering: arch, then -f, then -m, then -W
89b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassDEBUG_FLAGS := $(if ${DEBUG},-g -O0,-Os)
90b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCOMMON_FLAGS := -nostdinc -pipe \
91b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass	-ffreestanding -fno-builtin -fno-stack-protector \
92eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	-Werror -Wall -Wstrict-prototypes ${DEBUG_FLAGS}
93b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass
94eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Note: FIRMWARE_ARCH is defined by the Chromium OS ebuild.
95eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH}, arm)
96b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCC ?= armv7a-cros-linux-gnueabi-gcc
97b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCFLAGS ?= -march=armv5 \
98b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass	-fno-common -ffixed-r8 \
99d50b27d15de8cc9e37410fc52d3184f17e0db5bbDoug Anderson	-mfloat-abi=hard -marm -mabi=aapcs-linux -mno-thumb-interwork \
100eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${COMMON_FLAGS}
10161a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${FIRMWARE_ARCH}, x86)
102b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCC ?= i686-pc-linux-gnu-gcc
103b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# Drop -march=i386 to permit use of SSE instructions
104b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCFLAGS ?= \
105b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass	-ffunction-sections -fvisibility=hidden -fno-strict-aliasing \
106b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass	-fomit-frame-pointer -fno-toplevel-reorder -fno-dwarf2-cfi-asm \
107b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass	-mpreferred-stack-boundary=2 -mregparm=3 \
108eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${COMMON_FLAGS}
109eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonelse ifeq (${FIRMWARE_ARCH}, x86_64)
110eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCFLAGS ?= ${COMMON_FLAGS} \
1118e85e987739281161ece1dbc9ff2b73f3e8e1e35Simon Glass	-fvisibility=hidden -fno-strict-aliasing -fomit-frame-pointer
112844bce57471153664c78993dab453e87891bb969Randall Spanglerelse
113eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# FIRMWARE_ARCH not defined; assuming local compile.
114eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCC ?= gcc
115eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCFLAGS += -DCHROMEOS_ENVIRONMENT -Wall -Werror # HEY: always want last two?
1168e85e987739281161ece1dbc9ff2b73f3e8e1e35Simon Glassendif
11734be8273e0fb80a6654deab650e581b0dc9046a4Che-Liang Chiou
118eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifneq (${DEBUG},)
119eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCFLAGS += -DVBOOT_DEBUG
120eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
121844bce57471153664c78993dab453e87891bb969Randall Spangler
122eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${DISABLE_NDEBUG},)
123eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCFLAGS += -DNDEBUG
124eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
125eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
126eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Create / use dependency files
127eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCFLAGS += -MMD -MF $@.d
128eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
12959d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler# Code coverage
130eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifneq (${COV},)
13159d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler  COV_FLAGS = -O0 --coverage
13259d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler  CFLAGS += ${COV_FLAGS}
13359d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler  LDFLAGS += ${COV_FLAGS}
13459d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler  COV_INFO = ${BUILD}/coverage.info
135eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
136eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
137eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# And a few more default utilities
138eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonLD = ${CC}
139eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCXX ?= g++ # HEY: really?
140eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonPKG_CONFIG ?= pkg-config
141eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
142844bce57471153664c78993dab453e87891bb969Randall Spangler# Determine QEMU architecture needed, if any
143eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${ARCH},${HOST_ARCH})
144844bce57471153664c78993dab453e87891bb969Randall Spangler  # Same architecture; no need for QEMU
145844bce57471153664c78993dab453e87891bb969Randall Spangler  QEMU_ARCH :=
14661a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${HOST_ARCH}-${ARCH},x86_64-x86)
147844bce57471153664c78993dab453e87891bb969Randall Spangler  # 64-bit host can run 32-bit targets directly
148844bce57471153664c78993dab453e87891bb969Randall Spangler  QEMU_ARCH :=
149844bce57471153664c78993dab453e87891bb969Randall Spanglerelse
150eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson  QEMU_ARCH := ${ARCH}
151844bce57471153664c78993dab453e87891bb969Randall Spanglerendif
152844bce57471153664c78993dab453e87891bb969Randall Spangler
153844bce57471153664c78993dab453e87891bb969Randall Spangler# The top of the chroot for qemu must be passed in via the SYSROOT environment
154844bce57471153664c78993dab453e87891bb969Randall Spangler# variable.  In the Chromium OS chroot, this is done automatically by the
155844bce57471153664c78993dab453e87891bb969Randall Spangler# ebuild.
156844bce57471153664c78993dab453e87891bb969Randall Spangler
157eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${QEMU_ARCH},)
158844bce57471153664c78993dab453e87891bb969Randall Spangler  # Path to build output for running tests is same as for building
159eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson  BUILD_RUN = ${BUILD}
160e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler  SRC_RUN = ${SRCDIR}
161844bce57471153664c78993dab453e87891bb969Randall Spanglerelse
162844bce57471153664c78993dab453e87891bb969Randall Spangler  $(info Using qemu for testing.)
163844bce57471153664c78993dab453e87891bb969Randall Spangler  # Path to build output for running tests is different in the chroot
164eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson  BUILD_RUN = $(subst ${SYSROOT},,${BUILD})
165e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler  SRC_RUN = $(subst ${SYSROOT},,${SRCDIR})
166844bce57471153664c78993dab453e87891bb969Randall Spangler
167eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson  QEMU_BIN = qemu-${QEMU_ARCH}
168e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler  QEMU_RUN = ${BUILD_RUN}/${QEMU_BIN}
169e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler  export QEMU_RUN
170287beaed7f8ceff679c57664d4da008c6234edfdRandall Spangler
171e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler  RUNTEST = tests/test_using_qemu.sh
172e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spanglerendif
1735d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
174e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spanglerexport BUILD_RUN
1755d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
176eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Some things only compile inside the Chromium OS chroot.
177eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: Those things should be in their own repo, not part of vboot_reference
178eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: Is there a better way to detect this?
179eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifneq (${CROS_WORKON_SRCROOT},)
180eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonIN_CHROOT := yes
18134be8273e0fb80a6654deab650e581b0dc9046a4Che-Liang Chiouendif
18234be8273e0fb80a6654deab650e581b0dc9046a4Che-Liang Chiou
183eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: Move to separate repo.
184eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifneq (${IN_CHROOT},)
185eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonPC_BASE_VER ?= 125070
186eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonPC_DEPS := libchrome-${PC_BASE_VER}
187eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonPC_CFLAGS := $(shell ${PKG_CONFIG} --cflags ${PC_DEPS})
188eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonPC_LDLIBS := $(shell ${PKG_CONFIG} --libs ${PC_DEPS})
189b2b0fcc0f62fadce6f854bf14826a9778c0f7632vbendebendif
1900a0e8d0bb26c951a895c5034a4c1c12f3d4e8707Che-Liang Chiou
191b2b0fcc0f62fadce6f854bf14826a9778c0f7632vbendeb
192eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson##############################################################################
193eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Now we need to describe everything we might want or need to build
194b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass
195eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: This should go in its own repo.
196eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonAU_CGPTLIB = ${BUILD}/cgpt/libcgpt-cc.a
197eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# This is just ... Gah. There's no good place for it.
198eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonDUMPKERNELCONFIGLIB = ${BUILD}/libdump_kernel_config.a
199322536d2f9d30f42218cc9f2ab40574557da8a9Gaurav Shah
200eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Everything wants these headers.
2015d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerINCLUDES += \
2025d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	-Ifirmware/include \
2035d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	-Ifirmware/lib/include \
2045d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	-Ifirmware/lib/cgptlib/include \
2055d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	-Ifirmware/lib/cryptolib/include \
2065d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	-Ifirmware/lib/tpm_lite/include
2070b8f35c6a56a0e645254dd7f07ca68e01c8ee629Bill Richardson
208eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# If we're not building for a specific target, just stub out things like the
209eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM commands and various external functions that are provided by the BIOS.
210eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH},)
2115d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerINCLUDES += -Ifirmware/stub/include
2120a0e8d0bb26c951a895c5034a4c1c12f3d4e8707Che-Liang Chiouelse
213eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonINCLUDES += -Ifirmware/arch/${FIRMWARE_ARCH}/include
2145d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif
2155d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
216eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Firmware library. TODO: Do we still need to export this?
217eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonFWLIB = ${BUILD}/vboot_fw.a
2185d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
2195d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# find lib -iname '*.c' | sort
2205d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerFWLIB_SRCS = \
2215d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cgptlib/cgptlib.c \
2225d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cgptlib/cgptlib_internal.c \
2235d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cgptlib/crc32.c \
2245d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/crc8.c \
2255d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cryptolib/padding.c \
2265d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cryptolib/rsa.c \
2275d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cryptolib/rsa_utility.c \
2285d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cryptolib/sha1.c \
2295d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cryptolib/sha256.c \
2305d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cryptolib/sha512.c \
2315d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cryptolib/sha_utility.c \
2325d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/stateful_util.c \
2335d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/utility.c \
2345d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/utility_string.c \
2355d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/vboot_api_init.c \
2365d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/vboot_api_firmware.c \
2375d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/vboot_api_kernel.c \
2385d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/vboot_audio.c \
2395d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/vboot_common.c \
2405d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/vboot_display.c \
2415d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/vboot_firmware.c \
2425d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/vboot_kernel.c \
2435d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/vboot_nvstorage.c
2445d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
245eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Support real TPM unless BIOS sets MOCK_TPM
246eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${MOCK_TPM},)
2475d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerFWLIB_SRCS += \
2485d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/rollback_index.c \
2495d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/tpm_bootmode.c \
2505d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/tpm_lite/tlcl.c
2515d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerelse
2525d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerFWLIB_SRCS += \
2535d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/mocked_rollback_index.c \
2545d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/mocked_tpm_bootmode.c \
2555d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/tpm_lite/mocked_tlcl.c
2565d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif
2575d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
258eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH},)
259eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Include BIOS stubs in the firmware library when compiling for host
2605d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerFWLIB_SRCS += \
2615d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/stub/tpm_lite_stub.c \
2625d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/stub/utility_stub.c \
2635d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/stub/vboot_api_stub.c \
2645d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/stub/vboot_api_stub_disk.c
2655d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif
2665d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
267eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonFWLIB_OBJS = ${FWLIB_SRCS:%.c=${BUILD}/%.o}
2685d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerALL_OBJS += ${FWLIB_OBJS}
2695d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
2705d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
271eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Library to build the utilities. "HOST" mostly means "userspace".
272eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonHOSTLIB = ${BUILD}/vboot_host.a
2735d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
2745d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerHOSTLIB_SRCS = \
275eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	host/arch/${ARCH}/lib/crossystem_arch.c \
2765d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/crossystem.c \
2775d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/file_keys.c \
2785d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/fmap.c \
2795d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/host_common.c \
2805d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/host_key.c \
2815d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/host_keyblock.c \
2825d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/host_misc.c \
2835d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/host_signature.c \
2845d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/signature_digest.c
2855d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
286eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonHOSTLIB_OBJS = ${HOSTLIB_SRCS:%.c=${BUILD}/%.o}
2875d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerALL_OBJS += ${HOSTLIB_OBJS}
2885d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
2895d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
290eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Link with hostlib by default
291eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonLIBS = $(HOSTLIB)
292eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
293eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Might need this too.
294eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCRYPTO_LIBS := $(shell ${PKG_CONFIG} --libs libcrypto)
295eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
296eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
297eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
298eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Now for the userspace binaries
2995d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
3005d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCGPT = ${BUILD}/cgpt/cgpt
3015d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
3025d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCGPT_SRCS = \
3035d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt.c \
3045d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_add.c \
3055d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_boot.c \
3065d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_common.c \
3075d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_create.c \
3085d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_find.c \
3095d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_legacy.c \
3105d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_prioritize.c \
3115d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_repair.c \
3125d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_show.c \
3135d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cmd_add.c \
3145d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cmd_boot.c \
3155d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cmd_create.c \
3165d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cmd_find.c \
3175d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cmd_legacy.c \
3185d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cmd_prioritize.c \
3195d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cmd_repair.c \
3205d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cmd_show.c
3215d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
322eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCGPT_OBJS = ${CGPT_SRCS:%.c=${BUILD}/%.o}
3235d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerALL_OBJS += ${CGPT_OBJS}
3245d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
325eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonC_DESTDIR = ${DESTDIR}
3265d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
3275d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
328eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Scripts to install directly (not compiled)
3295d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerUTIL_SCRIPTS = \
3305d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	utility/dev_debug_vboot \
3315d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	utility/dev_make_keypair \
3325d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	utility/enable_dev_usb_boot \
3335d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	utility/vbutil_what_keys
3345d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
335eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# These utilities should be linked statically.
336eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonUTIL_NAMES_STATIC = \
337eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	crossystem \
338eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	dump_fmap \
339eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	gbb_utility
340eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
341eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonUTIL_NAMES = ${UTIL_NAMES_STATIC} \
3425d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	dev_sign_file \
3435d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	dump_kernel_config \
3445d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	dumpRSAPublicKey \
3455d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	load_kernel_test \
3465d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	pad_digest_utility \
3475d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	signature_digest_utility \
3485d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tpm_init_temp_fix \
3495d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tpmc \
3505d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	vbutil_firmware \
3515d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	vbutil_kernel \
3525d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	vbutil_key \
3535d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	vbutil_keyblock \
3545d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	verify_data
3555d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
356eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifneq (${IN_CHROOT},)
3575d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerUTIL_NAMES += mount-encrypted
3585d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif
3595d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
360eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${MINIMAL},)
3615d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerUTIL_NAMES += \
3625d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	bmpblk_font \
3635d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	bmpblk_utility \
3645d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	eficompress \
3655d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	efidecompress
3665d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif
3675d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
368eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonUTIL_BINS_STATIC := $(addprefix ${BUILD}/utility/,${UTIL_NAMES_STATIC})
369eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonUTIL_BINS = $(addprefix ${BUILD}/utility/,${UTIL_NAMES})
3705d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerALL_DEPS += $(addsuffix .d,${UTIL_BINS})
3715d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
372eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonU_DESTDIR = ${DESTDIR}
373eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
374eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
375eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# The unified firmware utility will eventually replace all the others
376eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonFUTIL_BIN = ${BUILD}/futility/futility
377eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
378eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonFUTIL_SRCS = \
379eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	futility/IGNOREME.c
380eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
381eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonFUTIL_LDS = futility/futility.lds
382eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
383eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonFUTIL_OBJS = ${FUTIL_SRCS:%.c=${BUILD}/%.o}
384eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
385eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonALL_DEPS += $(addsuffix .d,${FUTIL_BIN})
386eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonALL_OBJS += ${FUTIL_OBJS}
387eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
388eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonF_DESTDIR = ${DESTDIR}
389eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
390eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
391eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Library of handy test functions.
392eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTESTLIB = ${BUILD}/tests/test.a
393eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
394eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTESTLIB_SRCS = \
395eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tests/test_common.c \
396eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tests/timer_utils.c \
397eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tests/crc32_test.c
398eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
399eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTESTLIB_OBJS = ${TESTLIB_SRCS:%.c=${BUILD}/%.o}
400eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonALL_OBJS += ${TESTLIB_OBJS}
401eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
402eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
403eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# And some compiled tests.
404eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTEST_NAMES = \
405eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	cgptlib_test \
406eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	rollback_index2_tests \
407a3eac79f5070747e326da631c1eec155f0389919Randall Spangler	rollback_index3_tests \
408eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	rsa_padding_test \
409eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	rsa_utility_tests \
410eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	rsa_verify_benchmark \
411eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	sha_benchmark \
412eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	sha_tests \
413eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	stateful_util_tests \
414c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler	tlcl_tests \
415eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tpm_bootmode_tests \
416eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	utility_string_tests \
417eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	utility_tests \
418eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	vboot_api_init_tests \
419eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	vboot_api_devmode_tests \
420eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	vboot_api_firmware_tests \
421eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	vboot_api_kernel_tests \
422eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	vboot_audio_tests \
423eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	vboot_common_tests \
424eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	vboot_common2_tests \
425eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	vboot_common3_tests \
426786a5dca74387de5ffdc51ca5a099a4e90f406daRandall Spangler	vboot_display_tests \
4276dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler	vboot_firmware_tests \
42849cb0d3471e768da11fe76b65769bd57dca38bd7Randall Spangler	vboot_kernel_tests \
4296dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler	vboot_nvstorage_test
430eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
431eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Grrr
432eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifneq (${IN_CHROOT},)
433eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTEST_NAMES += CgptManagerTests
434eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
435eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
436eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: port these tests to new API, if not already eqivalent
437eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# functionality in other tests.  These don't even compile at present.
438eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#
439eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		big_firmware_tests
440eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		big_kernel_tests
441eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		firmware_image_tests
442eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		firmware_rollback_tests
443eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		firmware_splicing_tests
444eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		firmware_verify_benchmark
445eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		kernel_image_tests
446eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		kernel_rollback_tests
447eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		kernel_splicing_tests
448eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		kernel_verify_benchmark
449eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		rollback_index_test
450eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		verify_firmware_fuzz_driver
451eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		verify_kernel_fuzz_driver
452eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#               utility/load_firmware_test
453eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
454eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# And a few more...
455eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTLCL_TESTS = \
456eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tpmtest_earlyextend \
457eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tpmtest_earlynvram \
458eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson        tpmtest_earlynvram2 \
459eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tpmtest_enable \
460eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tpmtest_fastenable \
461eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tpmtest_globallock \
462eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson        tpmtest_redefine_unowned \
463eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson        tpmtest_spaceperm \
464eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tpmtest_testsetup \
465eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tpmtest_timing \
466eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson        tpmtest_writelimit
467eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTLCL_TEST_NAMES = $(addprefix tpm_lite/,${TLCL_TESTS})
468eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTLCL_TEST_BINS = $(addprefix ${BUILD}/tests/,${TLCL_TEST_NAMES})
469eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
470eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTEST_NAMES += ${TLCL_TEST_NAMES}
471eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
472eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTEST_BINS = $(addprefix ${BUILD}/tests/,${TEST_NAMES})
473eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonALL_DEPS += $(addsuffix .d,${TEST_BINS})
474eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
475e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler# Directory containing test keys
476e061a256549607a56d771eb8ddae5d0dd90d519cRandall SpanglerTEST_KEYS = ${SRC_RUN}/tests/testkeys
477eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
478eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
479eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: why not make this include *all* the cgpt files, and simply have
480eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# cgpt link against it?
481eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: CgptManager.cc should move to the installer project.  Shouldn't be
482eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# in libcgpt-cc.a.
483eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonAU_CGPTLIB_SRCS = \
484eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	cgpt/CgptManager.cc \
485eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	cgpt/cgpt_create.c \
486eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	cgpt/cgpt_add.c \
487eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	cgpt/cgpt_boot.c \
488eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	cgpt/cgpt_show.c \
489eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	cgpt/cgpt_repair.c \
490eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	cgpt/cgpt_prioritize.c \
491eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	cgpt/cgpt_common.c \
492eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	firmware/lib/cgptlib/crc32.c \
493eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	firmware/lib/cgptlib/cgptlib_internal.c \
494eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	firmware/stub/utility_stub.c
495eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
496eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonAU_CGPTLIB_OBJS = $(filter %.o, \
497eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${AU_CGPTLIB_SRCS:%.c=${BUILD}/%.o} \
498eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${AU_CGPTLIB_SRCS:%.cc=${BUILD}/%.o})
499eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonALL_OBJS += ${AU_CGPTLIB_OBJS}
500eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
501eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
502eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson##############################################################################
503eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Finally, some targets. High-level ones first.
504eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
505eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Create output directories if necessary.  Do this via explicit shell commands
506eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# so it happens before trying to generate/include dependencies.
507eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonSUBDIRS := firmware host cgpt utility futility tests tests/tpm_lite
508eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson_dir_create := $(foreach d, \
509eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	$(shell find ${SUBDIRS} -name '*.c' -exec  dirname {} \; | sort -u), \
510eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	$(shell [ -d ${BUILD}/${d} ] || mkdir -p ${BUILD}/${d}))
511eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
512eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
513eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Default target.
514eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: all
51559d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglerall: fwlib $(if ${FIRMWARE_ARCH},,host_stuff) $(if ${COV},coverage)
516eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
517eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Host targets
518eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: host_stuff
519eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonhost_stuff: hostlib cgpt utils futil tests
520eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
521eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# AU targets
522eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: au_stuff
523eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonau_stuff: libcgpt_cc libdump_kernel_config cgptmanager_tests
524eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
525eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: clean
526eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonclean:
527eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}/bin/rm -rf ${BUILD}
528eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
529eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: install
530eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsoninstall: cgpt_install utils_install futil_install
531eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
532eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Don't delete intermediate object files
533eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.SECONDARY:
534eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
535eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: I suspect this is missing some object files.  Make a temp
536eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# target which cleans all known obj/exe's and see what's left; those
537eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# are the files which need deps.
538eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonALL_DEPS += ${ALL_OBJS:%.o=%.o.d}
539eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson-include ${ALL_DEPS}
540eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
541eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
542eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Firmware library
543eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
544eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM-specific flags.  These depend on the particular TPM we're targeting for.
545eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# They are needed here only for compiling parts of the firmware code into
546eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# user-level tests.
547eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
548eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM_BLOCKING_CONTINUESELFTEST is defined if TPM_ContinueSelfTest blocks until
549eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# the self test has completed.
550eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
55145cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DTPM_BLOCKING_CONTINUESELFTEST
552eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
553eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM_MANUAL_SELFTEST is defined if the self test must be started manually
554eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# (with a call to TPM_ContinueSelfTest) instead of starting automatically at
555eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# power on.
556eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#
557eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# We sincerely hope that TPM_BLOCKING_CONTINUESELFTEST and TPM_MANUAL_SELFTEST
558eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# are not both defined at the same time.  (See comment in code.)
559eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
560eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# CFLAGS += -DTPM_MANUAL_SELFTEST
561eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
562eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH},i386)
563eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Unrolling loops in cryptolib makes it faster
56445cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DUNROLL_LOOPS
565eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
566eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Workaround for coreboot on x86, which will power off asynchronously
567eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# without giving us a chance to react. This is not an example of the Right
568eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Way to do things. See chrome-os-partner:7689, and the commit message
569eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# that made this change.
57045cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DSAVE_LOCALE_IMMEDIATELY
571eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
572eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# On x86 we don't actually read the GBB data into RAM until it is needed.
573eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Therefore it makes sense to cache it rather than reading it each time.
574eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Enable this feature.
57545cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DCOPY_BMP_DATA
576eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
577eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
578eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH},)
579eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Disable rollback TPM when compiling locally, since otherwise
580eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# load_kernel_test attempts to talk to the TPM.
58145cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DDISABLE_ROLLBACK_TPM
582eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
583eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
584eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: fwlib
585eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonfwlib: ${FWLIB} $(if ${FIRMWARE_ARCH},,${BUILD}/firmware/linktest/main)
586eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
587eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${FWLIB}: ${FWLIB_OBJS}
588eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	@printf "    RM            $(subst ${BUILD}/,,$@)\n"
589eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}rm -f $@
590eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	@printf "    AR            $(subst ${BUILD}/,,$@)\n"
591eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}ar qc $@ $^
592eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
593eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
594eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Host library
595eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
596eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: hostlib
597eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonhostlib: ${HOSTLIB} ${BUILD}/host/linktest/main
598eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
599eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/host/% ${HOSTLIB}: INCLUDES += \
600eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	-Ihost/include\
601eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	-Ihost/arch/${ARCH}/include
602eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
603eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: better way to make .a than duplicating this recipe each time?
604eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${HOSTLIB}: ${HOSTLIB_OBJS} ${FWLIB_OBJS}
605eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	@printf "    RM            $(subst ${BUILD}/,,$@)\n"
606eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}rm -f $@
607eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	@printf "    AR            $(subst ${BUILD}/,,$@)\n"
608eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}ar qc $@ $^
609eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
610eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
611eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# CGPT library and utility
612eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
613eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: cgpt
614eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsoncgpt: ${CGPT}
615eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
616eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${CGPT}: LDFLAGS += -static
617eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${CGPT}: LDLIBS += -luuid
618eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
619eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${CGPT}: ${CGPT_OBJS} ${LIBS}
620eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	@printf "    LDcgpt        $(subst ${BUILD}/,,$@)\n"
621eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${LD} -o ${CGPT} ${CFLAGS} $^ ${LDFLAGS} ${LDLIBS}
622eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
623eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: cgpt_install
624eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsoncgpt_install: ${CGPT}
625eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	@printf "    INSTALL       CGPT\n"
626eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}mkdir -p ${C_DESTDIR}
627eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${INSTALL} -t ${C_DESTDIR} $^
628eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
629eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
630eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Utilities
631eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
632eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# These have their own headers too.
633eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/%: INCLUDES += -Ihost/include -Iutility/include
634eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
635eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Utilities for auto-update toolkits must be statically linked.
636eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${UTIL_BINS_STATIC}: LDFLAGS += -static
637eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
638acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: utils
639eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonutils: ${UTIL_BINS} ${UTIL_SCRIPTS}
6405d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# TODO: change ebuild to pull scripts directly out of utility dir
641eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}cp -f ${UTIL_SCRIPTS} ${BUILD}/utility
642eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}chmod a+rx $(patsubst %,${BUILD}/%,${UTIL_SCRIPTS})
643826db09fcec194951e1dc71002d6a92620fbb46bBill Richardson
644acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: utils_install
645eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonutils_install: ${UTIL_BINS} ${UTIL_SCRIPTS}
646826db09fcec194951e1dc71002d6a92620fbb46bBill Richardson	@printf "    INSTALL       UTILS\n"
647eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}mkdir -p ${U_DESTDIR}
648eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${INSTALL} -t ${U_DESTDIR} $^
6495d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
650eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
651eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# new Firmware Utility
6525d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
653eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: futil
654eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonfutil: ${FUTIL_BIN}
6555d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
656eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${FUTIL_BIN}: ${FUTIL_LDS} ${FUTIL_OBJS}
657eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	@printf "    LD            $(subst ${BUILD}/,,$@)\n"
658eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${LD} -o $@ ${CFLAGS} $^ ${LDFLAGS} ${LDLIBS}
6595d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
660eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: futil_install
661eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonfutil_install: ${FUTIL_BIN}
662eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	@printf "    INSTALL       futility\n"
663eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}mkdir -p ${F_DESTDIR}
664eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${INSTALL} -t ${F_DESTDIR} $^
6655d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
6665d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
667eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
6685d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Mount-encrypted utility for cryptohome
6695d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
6705d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# TODO: mount-encrypted should move to cryptohome and just link against
6715d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# vboot-host.a for tlcl and crossystem.
6725d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
6735d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# The embedded libcrypto conflicts with the shipped openssl,
6745d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# so mount-* builds without the common CFLAGS (and those includes).
6755d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
6765d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler${BUILD}/utility/mount-helpers.o: \
6775d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler		utility/mount-helpers.c \
6785d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler		utility/mount-helpers.h \
6795d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler		utility/mount-encrypted.h
680eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	@printf "    CCm-e         $(subst ${BUILD}/,,$@)\n"
681eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${CC} -Wall -Werror -O2 -D_FORTIFY_SOURCE=2 -fstack-protector \
682eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson		${COV_FLAGS} \
683eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson		$(shell ${PKG_CONFIG} --cflags glib-2.0 openssl) \
6845d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler		-c $< -o $@
6855d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
6865d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler${BUILD}/utility/mount-encrypted: \
6875d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler		utility/mount-encrypted.c \
6885d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler		utility/mount-encrypted.h \
689eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson		${BUILD}/utility/mount-helpers.o ${LIBS}
690eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	@printf "    CCm-exe       $(subst ${BUILD}/,,$@)\n"
691eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${CC} -Wall -Werror -O2 -D_FORTIFY_SOURCE=2 -fstack-protector \
692eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson		$(shell ${PKG_CONFIG} --cflags glib-2.0 openssl) \
6935d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler		-Ifirmware/include \
6945d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler		-Ihost/include \
695eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson		${COV_FLAGS} \
696eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson		${LDFLAGS} \
6975d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler		$< -o $@ \
698eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson		${BUILD}/utility/mount-helpers.o ${LIBS} \
699eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson		$(shell ${PKG_CONFIG} --libs glib-2.0 openssl) \
7005d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler		-lm
7015d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerifneq (${COV},)
702eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}mv -f mount-encrypted.gcno ${BUILD}/utility
7035d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif
7045d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
705eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
7065d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Utility to generate TLCL structure definition header file.
7075d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
708acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/utility/tlcl_generator: CFLAGS += -fpack-struct
7095d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
7105d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerSTRUCTURES_TMP=${BUILD}/tlcl_structures.tmp
7115d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerSTRUCTURES_SRC=firmware/lib/tpm_lite/include/tlcl_structures.h
7125d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
713acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: update_tlcl_structures
7145d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerupdate_tlcl_structures: ${BUILD}/utility/tlcl_generator
7155d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	@printf "    Rebuilding TLCL structures\n"
716eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${BUILD}/utility/tlcl_generator > ${STRUCTURES_TMP}
717eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}cmp -s ${STRUCTURES_TMP} ${STRUCTURES_SRC} || \
7185d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler		( echo "%% Updating structures.h %%" && \
719eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson		  cp ${STRUCTURES_TMP} ${STRUCTURES_SRC} )
7205d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
721eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
7225d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Library to dump kernel config
723eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Used by platform/installer, as well as standalone utility.
7245d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
725acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: libdump_kernel_config
726eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonlibdump_kernel_config: ${DUMPKERNELCONFIGLIB}
727eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
728eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${DUMPKERNELCONFIGLIB}: ${BUILD}/utility/dump_kernel_config_lib.o
729eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	@printf "    RM            $(subst ${BUILD}/,,$@)\n"
730eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}rm -f $@
731eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	@printf "    AR            $(subst ${BUILD}/,,$@)\n"
732eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}ar qc $@ $^
733eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
734eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
735eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# And this thing.
7365d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
737eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: libcgpt_cc
738eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonlibcgpt_cc: ${AU_CGPTLIB}
739eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
740eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${AU_CGPTLIB}: INCLUDES += -Ifirmware/lib/cgptlib/include
741eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${AU_CGPTLIB}: ${AU_CGPTLIB_OBJS}
742eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	@printf "    RM            $(subst ${BUILD}/,,$@)\n"
743eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}rm -f $@
744eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	@printf "    AR            $(subst ${BUILD}/,,$@)\n"
745eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}ar qc $@ $^
7465d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
747eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
7485d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Tests
7495d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
750eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: tests
751eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontests: ${TEST_BINS}
7525d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
753eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${TEST_BINS}: ${TESTLIB}
7545d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
755eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${TESTLIB}: ${TESTLIB_OBJS}
756eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	@printf "    RM            $(subst ${BUILD}/,,$@)\n"
757eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}rm -f $@
758eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	@printf "    AR            $(subst ${BUILD}/,,$@)\n"
759eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}ar qc $@ $^
7605d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
7615d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
762eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
763eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Generic build rules. LIBS and OBJS can be overridden to tweak the generic
764eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# rules for specific targets.
7655d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
766eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%: ${BUILD}/%.o ${OBJS} ${LIBS}
767eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	@printf "    LD            $(subst ${BUILD}/,,$@)\n"
768eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${LD} -o $@ ${CFLAGS} $< ${OBJS} ${LIBS} ${LDFLAGS} ${LDLIBS}
769eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
770eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%.o: %.c
771eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	@printf "    CC            $(subst ${BUILD}/,,$@)\n"
772eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
773eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
774eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Rules to recompile a single source file for library and test
775eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: is there a tidier way to do this?
776eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_lib.o: CFLAGS += -DFOR_LIBRARY
777eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_lib.o: %.c
778eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	@printf "    CC-for-lib    $(subst ${BUILD}/,,$@)\n"
779eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
780eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
781eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_test.o: CFLAGS += -DFOR_TEST
782eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_test.o: %.c
783eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	@printf "    CC-for-test   $(subst ${BUILD}/,,$@)\n"
784eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
785eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
786eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: C++ files don't belong in vboot reference at all.  Convert to C.
787eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%.o: %.cc
788eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	@printf "    CXX           $(subst ${BUILD}/,,$@)\n"
789eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${CXX} ${CFLAGS} ${INCLUDES} -c -o $@ $<
790eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
791eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
792eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Here are the special tweaks to the generic rules.
793eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
794eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Linktest ensures firmware lib doesn't rely on outside libraries
795eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/firmware/linktest/main: LIBS = ${FWLIB}
796eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
797eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Specific dependency here.
798eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/dump_kernel_config: LIBS += ${DUMPKERNELCONFIGLIB}
799eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/dump_kernel_config: ${DUMPKERNELCONFIGLIB}
8005d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
801eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# GBB utility needs C++ linker. TODO: It shouldn't.
802eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/gbb_utility: LD = ${CXX}
803eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
804eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Some utilities need external crypto functions
805eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/dumpRSAPublicKey: LDLIBS += ${CRYPTO_LIBS}
806eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/pad_digest_utility: LDLIBS += ${CRYPTO_LIBS}
807eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/signature_digest_utility: LDLIBS += ${CRYPTO_LIBS}
808eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/dev_sign_file: LDLIBS += ${CRYPTO_LIBS}
809eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/vbutil_firmware: LDLIBS += ${CRYPTO_LIBS}
810eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/vbutil_kernel: LDLIBS += ${CRYPTO_LIBS}
811eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/vbutil_key: LDLIBS += ${CRYPTO_LIBS}
812eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/vbutil_keyblock: LDLIBS += ${CRYPTO_LIBS}
813eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
814eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/host/linktest/main: LDLIBS += ${CRYPTO_LIBS}
815eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/vboot_common2_tests: LDLIBS += ${CRYPTO_LIBS}
816eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/vboot_common3_tests: LDLIBS += ${CRYPTO_LIBS}
817eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
818eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_utility: LD = ${CXX}
819eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_utility: LDLIBS = -llzma -lyaml
820eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
821eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonBMPBLK_UTILITY_DEPS = \
822eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/utility/bmpblk_util.o \
823eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/utility/image_types.o \
824eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/utility/eficompress_for_lib.o \
825eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/utility/efidecompress_for_lib.o
826eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_utility: OBJS = ${BMPBLK_UTILITY_DEPS}
827eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_utility: ${BMPBLK_UTILITY_DEPS}
828eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
829eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_font: OBJS += ${BUILD}/utility/image_types.o
830eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_font: ${BUILD}/utility/image_types.o
831eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
832eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Allow multiple definitions, so tests can mock functions from other libraries
833eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/%: CFLAGS += -Xlinker --allow-multiple-definition
834eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/%: INCLUDES += -Ihost/include
835eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/%: LDLIBS += -lrt -luuid
836eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/%: LIBS += ${TESTLIB}
8375d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
8385d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler${BUILD}/tests/rollback_index2_tests: OBJS += \
83917f8d341099120da78a6ca71165834eefb0960edRandall Spangler	${BUILD}/firmware/lib/rollback_index_for_test.o
840eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/rollback_index2_tests: \
841eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/firmware/lib/rollback_index_for_test.o
8425d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
843c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler${BUILD}/tests/tlcl_tests: OBJS += \
844c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler	${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
845c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler${BUILD}/tests/tlcl_tests: \
846c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler	${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
847c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler
8485d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler${BUILD}/tests/vboot_audio_tests: OBJS += \
84917f8d341099120da78a6ca71165834eefb0960edRandall Spangler	${BUILD}/firmware/lib/vboot_audio_for_test.o
850eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/vboot_audio_tests: \
851eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/firmware/lib/vboot_audio_for_test.o
8525d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
853acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: cgptmanager_tests
8545d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglercgptmanager_tests: ${BUILD}/tests/CgptManagerTests
8555d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
856eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/CgptManagerTests: CFLAGS += ${PC_CFLAGS}
857eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/CgptManagerTests: LD = ${CXX}
858eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/CgptManagerTests: LDLIBS += -lgtest -lgflags ${PC_LDLIBS}
859eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/CgptManagerTests: LIBS = ${AU_CGPTLIB}
860eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/CgptManagerTests: ${AU_CGPTLIB}
8615d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
862acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/tests/rollback_index_test: INCLUDES += -I/usr/include
863acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/tests/rollback_index_test: LIBS += -ltlcl
8645d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
865eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${TLCL_TEST_BINS}: OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o
866eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${TLCL_TEST_BINS}: ${BUILD}/tests/tpm_lite/tlcl_tests.o
8675d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
868eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson##############################################################################
869eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Targets that exist just to run tests
8705d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
8715d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Frequently-run tests
872eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: test_targets
873eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontest_targets:: runcgpttests runmisctests
874844bce57471153664c78993dab453e87891bb969Randall Spangler
875eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${MINIMAL},)
876844bce57471153664c78993dab453e87891bb969Randall Spangler# Bitmap utility isn't compiled for minimal variant
877eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontest_targets:: runbmptests
878844bce57471153664c78993dab453e87891bb969Randall Spangler# Scripts don't work under qemu testing
879844bce57471153664c78993dab453e87891bb969Randall Spangler# TODO: convert scripts to makefile so they can be called directly
880eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontest_targets:: runtestscripts
881844bce57471153664c78993dab453e87891bb969Randall Spanglerendif
882844bce57471153664c78993dab453e87891bb969Randall Spangler
883eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: test_setup
884eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontest_setup:: cgpt utils futil tests
885eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
886844bce57471153664c78993dab453e87891bb969Randall Spangler# Qemu setup for cross-compiled tests.  Need to copy qemu binary into the
887844bce57471153664c78993dab453e87891bb969Randall Spangler# sysroot.
888eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifneq (${QEMU_ARCH},)
889eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontest_setup:: qemu_install
890844bce57471153664c78993dab453e87891bb969Randall Spangler
891844bce57471153664c78993dab453e87891bb969Randall Spangler.PHONY: qemu_install
892844bce57471153664c78993dab453e87891bb969Randall Spanglerqemu_install:
893eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${SYSROOT},)
894eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	$(error SYSROOT must be set to the top of the target-specific root \
895eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonwhen cross-compiling for qemu-based tests to run properly.)
896eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
897844bce57471153664c78993dab453e87891bb969Randall Spangler	@printf "    Copying qemu binary.\n"
898eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}cp -fu /usr/bin/${QEMU_BIN} ${BUILD}/${QEMU_BIN}
899eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}chmod a+rx ${BUILD}/${QEMU_BIN}
900844bce57471153664c78993dab453e87891bb969Randall Spanglerendif
901844bce57471153664c78993dab453e87891bb969Randall Spangler
902acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runtests
903eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonruntests: test_targets
9045d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
9055d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Generate test keys
906acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: genkeys
907844bce57471153664c78993dab453e87891bb969Randall Spanglergenkeys: utils
9085d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/gen_test_keys.sh
9095d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
9105d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Generate test cases for fuzzing
911acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: genfuzztestcases
912a808dc944284e6eba39a8f19ddb46bc61c34de8aRandall Spanglergenfuzztestcases: utils
9135d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/gen_fuzz_test_cases.sh
9145d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
915acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runbmptests
916eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonrunbmptests: test_setup
917eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	cd tests/bitmaps && BMPBLK=${BUILD_RUN}/utility/bmpblk_utility \
9185d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler		./TestBmpBlock.py -v
9195d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
920acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runcgpttests
921eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonruncgpttests: test_setup
922eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/cgptlib_test
923eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# HEY - elsewhere
924eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifneq (${IN_CHROOT},)
925eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/CgptManagerTests --v=1
9265d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif
9275d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
928844bce57471153664c78993dab453e87891bb969Randall Spangler.PHONY: runtestscripts
929eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonruntestscripts: test_setup genfuzztestcases
930eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt
9315d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/run_preamble_tests.sh
9325d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/run_rsa_tests.sh
933844bce57471153664c78993dab453e87891bb969Randall Spangler	tests/run_vbutil_kernel_arg_tests.sh
9345d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/run_vbutil_tests.sh
9355d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
936844bce57471153664c78993dab453e87891bb969Randall Spangler.PHONY: runmisctests
937eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonrunmisctests: test_setup
938eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/rollback_index2_tests
939a3eac79f5070747e326da631c1eec155f0389919Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/rollback_index3_tests
940eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/rsa_utility_tests
941eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/sha_tests
942eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/stateful_util_tests
943c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/tlcl_tests
944eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/tpm_bootmode_tests
945eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/utility_string_tests
946eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/utility_tests
947eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_devmode_tests
948eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_init_tests
949eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_firmware_tests
950eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/vboot_audio_tests
951e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_common_tests
952e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS}
953e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS}
954786a5dca74387de5ffdc51ca5a099a4e90f406daRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_display_tests
955eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/vboot_firmware_tests
95649cb0d3471e768da11fe76b65769bd57dca38bd7Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_kernel_tests
9576dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_nvstorage_test
958eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
959eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: runfutiltests
960eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonrunfutiltests: DESTDIR := ${TEST_INSTALL_DIR}
961eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonrunfutiltests: test_setup install
962eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	@echo "$@ passed"
963844bce57471153664c78993dab453e87891bb969Randall Spangler
9645d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Run long tests, including all permutations of encryption keys (instead of
965786a5dca74387de5ffdc51ca5a099a4e90f406daRandall Spangler# just the ones we use) and tests of currently-unused code.
9665d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Not run by automated build.
967acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runlongtests
968eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonrunlongtests: test_setup genkeys genfuzztestcases
969e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS} --all
970e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS} --all
9715d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/run_preamble_tests.sh --all
9725d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/run_vbutil_tests.sh --all
9735d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
9745d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# TODO: tests to run when ported to new API
9755d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler#	./run_image_verification_tests.sh
9765d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler#	# Splicing tests
9775d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler#	${BUILD}/tests/firmware_splicing_tests
9785d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler#	${BUILD}/tests/kernel_splicing_tests
9795d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler#	# Rollback Tests
9805d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler#	${BUILD}/tests/firmware_rollback_tests
9815d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler#	${BUILD}/tests/kernel_rollback_tests
9825d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
98359d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler# Code coverage
98459d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler.PHONY: coverage_init
98559d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage_init: test_setup
98659d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	rm -f ${COV_INFO}*
98759d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	lcov -c -i -d . -b . -o ${COV_INFO}.initial
98859d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler
98959d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler.PHONY: coverage_html
99059d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage_html:
99159d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	lcov -c -d . -b . -o ${COV_INFO}.tests
99259d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	lcov -a ${COV_INFO}.initial -a ${COV_INFO}.tests -o ${COV_INFO}.total
99359d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	lcov -r ${COV_INFO}.total '/usr/*' '*/linktest/*' -o ${COV_INFO}.local
99459d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	genhtml ${COV_INFO}.local -o ${BUILD}/coverage
99559d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler
99659d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler# Generate addtional coverage stats just for firmware subdir, because the
99759d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler# per-directory stats for the whole project don't include their own subdirs.
99849cb0d3471e768da11fe76b65769bd57dca38bd7Randall Spangler	lcov -r ${COV_INFO}.local '*/stub/*' -o ${COV_INFO}.nostub
99949cb0d3471e768da11fe76b65769bd57dca38bd7Randall Spangler	lcov -e ${COV_INFO}.nostub '${SRCDIR}/firmware/*' \
100059d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler		-o ${COV_INFO}.firmware
100159d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler
100259d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler.PHONY: coverage
100359d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglerifeq (${COV},)
100459d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage:
100559d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	$(error Build coverage like this: make clean && COV=1 make)
100659d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglerelse
100759d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage: coverage_init runtests coverage_html
100859d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglerendif
100959d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler
1010