Makefile revision 028f468aff976ef5e76f20133c64ec19cb9d1517
16f3961507e73f90cec665896dece884e86be560aBill Richardson# Copyright 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
38c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# We should only run pwd once, not every time we refer to ${BUILD}.
39e061a256549607a56d771eb8ddae5d0dd90d519cRandall SpanglerSRCDIR := $(shell pwd)
40feb2518166b1cd181e607c611cbb610f0c7300daBill RichardsonBUILD = $(SRCDIR)/build
41844bce57471153664c78993dab453e87891bb969Randall Spanglerexport BUILD
425d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
43c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# Stuff for 'make install'
44feb2518166b1cd181e607c611cbb610f0c7300daBill RichardsonINSTALL = install
45feb2518166b1cd181e607c611cbb610f0c7300daBill RichardsonDESTDIR = /usr/local/bin
46feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson
47feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson# Where exactly do the pieces go?
486f3961507e73f90cec665896dece884e86be560aBill Richardson#  UB_DIR = utility binary directory
496f3961507e73f90cec665896dece884e86be560aBill Richardson#  VB_DIR = vboot binary directory for dev-mode-only scripts
50c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonifeq (${MINIMAL},)
516f3961507e73f90cec665896dece884e86be560aBill Richardson# Host install just puts everything where it's told
526f3961507e73f90cec665896dece884e86be560aBill RichardsonUB_DIR=${DESTDIR}
536f3961507e73f90cec665896dece884e86be560aBill RichardsonVB_DIR=${DESTDIR}
54c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonelse
556f3961507e73f90cec665896dece884e86be560aBill Richardson# Target install puts things into subdirectories under DESTDIR
566f3961507e73f90cec665896dece884e86be560aBill RichardsonUB_DIR=${DESTDIR}/usr/bin
57c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill RichardsonVB_DIR=${DESTDIR}/usr/share/vboot/bin
58c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonendif
596d696e532c6a0c93ad9b915c59dad4144e6f1b33Simon Glass
60eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Where to install the (exportable) executables for testing?
61eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTEST_INSTALL_DIR = ${BUILD}/install_for_test
62eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
63eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Verbose? Use V=1
64eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${V},)
65eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonQ := @
66eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
67eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
68661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass# Quiet? Use QUIET=1
69661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glassifeq ($(QUIET),)
70661ae9e9cbaad430b87b443712d2608f9ce59883Simon GlassPRINTF := printf
71661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glasselse
72661ae9e9cbaad430b87b443712d2608f9ce59883Simon GlassPRINTF := :
73661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glassendif
74661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass
7561a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# Architecture detection
7661a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler_machname := $(shell uname -m)
7761a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall SpanglerHOST_ARCH ?= ${_machname}
7861a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler
7961a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# ARCH and/or FIRMWARE_ARCH are defined by the Chromium OS ebuild.
8061a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# Pick a sane target architecture if none is defined.
8161a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerifeq (${ARCH},)
8261a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler  ARCH := ${HOST_ARCH}
8361a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${ARCH},i386)
8461a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler  override ARCH := x86
8561a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${ARCH},amd64)
8661a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler  override ARCH := x86_64
8761a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerendif
8861a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler
8961a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# FIRMWARE_ARCH is only defined by the Chromium OS ebuild if compiling
9061a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# for a firmware target (such as u-boot or depthcharge). It must map
9161a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# to the same consistent set of architectures as the host.
9261a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerifeq (${FIRMWARE_ARCH},i386)
9361a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler  override FIRMWARE_ARCH := x86
9461a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${FIRMWARE_ARCH},amd64)
9561a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler  override FIRMWARE_ARCH := x86_64
96d96b25d0c0a739d351b8f09b128782ca12b7b0e1Stefan Reinauerelse ifeq (${FIRMWARE_ARCH},armv7)
97d96b25d0c0a739d351b8f09b128782ca12b7b0e1Stefan Reinauer  override FIRMWARE_ARCH := arm
9861a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerendif
9961a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler
100b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# Provide default CC and CFLAGS for firmware builds; if you have any -D flags,
101b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# please add them after this point (e.g., -DVBOOT_DEBUG).
10274359b755c4a203df0fe3bf51fc53d5de87d1fbfChe-Liang Chiou#
1036b0003c6381a7e69818b0b34b358c2cfb1393043Che-Liang Chiou# TODO(crosbug.com/16808) We hard-code u-boot's compiler flags here just
1046b0003c6381a7e69818b0b34b358c2cfb1393043Che-Liang Chiou# temporarily. As we are still investigating which flags are necessary for
1056b0003c6381a7e69818b0b34b358c2cfb1393043Che-Liang Chiou# maintaining a compatible ABI, etc. between u-boot and vboot_reference.
10674359b755c4a203df0fe3bf51fc53d5de87d1fbfChe-Liang Chiou#
107b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# As a first step, this makes the setting of CC and CFLAGS here optional, to
108b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# permit a calling script or Makefile to set these.
10974359b755c4a203df0fe3bf51fc53d5de87d1fbfChe-Liang Chiou#
110b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# Flag ordering: arch, then -f, then -m, then -W
111b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassDEBUG_FLAGS := $(if ${DEBUG},-g -O0,-Os)
112b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCOMMON_FLAGS := -nostdinc -pipe \
113b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass	-ffreestanding -fno-builtin -fno-stack-protector \
114eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	-Werror -Wall -Wstrict-prototypes ${DEBUG_FLAGS}
115b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass
116eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Note: FIRMWARE_ARCH is defined by the Chromium OS ebuild.
117eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH}, arm)
118b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCC ?= armv7a-cros-linux-gnueabi-gcc
119b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCFLAGS ?= -march=armv5 \
120b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass	-fno-common -ffixed-r8 \
121d50b27d15de8cc9e37410fc52d3184f17e0db5bbDoug Anderson	-mfloat-abi=hard -marm -mabi=aapcs-linux -mno-thumb-interwork \
122eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${COMMON_FLAGS}
12361a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${FIRMWARE_ARCH}, x86)
124b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCC ?= i686-pc-linux-gnu-gcc
125b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# Drop -march=i386 to permit use of SSE instructions
126b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCFLAGS ?= \
127b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass	-ffunction-sections -fvisibility=hidden -fno-strict-aliasing \
128b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass	-fomit-frame-pointer -fno-toplevel-reorder -fno-dwarf2-cfi-asm \
12946e00e63805f85c05449ce09cd843a18b76ca665Gabe Black	-mpreferred-stack-boundary=2 \
130eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${COMMON_FLAGS}
131eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonelse ifeq (${FIRMWARE_ARCH}, x86_64)
132eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCFLAGS ?= ${COMMON_FLAGS} \
1338e85e987739281161ece1dbc9ff2b73f3e8e1e35Simon Glass	-fvisibility=hidden -fno-strict-aliasing -fomit-frame-pointer
134844bce57471153664c78993dab453e87891bb969Randall Spanglerelse
135eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# FIRMWARE_ARCH not defined; assuming local compile.
136eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCC ?= gcc
137d462101f06e1bf817295a6cdd2b82e7e87eaeef3Bill RichardsonCFLAGS += -DCHROMEOS_ENVIRONMENT -Wall -Werror ${DEBUG_FLAGS}
1388e85e987739281161ece1dbc9ff2b73f3e8e1e35Simon Glassendif
13934be8273e0fb80a6654deab650e581b0dc9046a4Che-Liang Chiou
140eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifneq (${DEBUG},)
141eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCFLAGS += -DVBOOT_DEBUG
142eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
143844bce57471153664c78993dab453e87891bb969Randall Spangler
144eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${DISABLE_NDEBUG},)
145eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCFLAGS += -DNDEBUG
146eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
147eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
148feb2518166b1cd181e607c611cbb610f0c7300daBill Richardsonifneq (${FORCE_LOGGING_ON},)
149feb2518166b1cd181e607c611cbb610f0c7300daBill RichardsonCFLAGS += -DFORCE_LOGGING_ON=${FORCE_LOGGING_ON}
150feb2518166b1cd181e607c611cbb610f0c7300daBill Richardsonendif
151feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson
1526014c048131f7c3d055e97c0aaa44494edc4f813Randall Spanglerifneq (${PD_SYNC},)
1536014c048131f7c3d055e97c0aaa44494edc4f813Randall SpanglerCFLAGS += -DPD_SYNC
1546014c048131f7c3d055e97c0aaa44494edc4f813Randall Spanglerendif
1556014c048131f7c3d055e97c0aaa44494edc4f813Randall Spangler
156eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Create / use dependency files
157eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCFLAGS += -MMD -MF $@.d
158eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
159f8f807a5ef00e8d5360fc2c9093bd0b5da8c0507Bertrand SIMONNETifeq (${FIRMWARE_ARCH},)
160f8f807a5ef00e8d5360fc2c9093bd0b5da8c0507Bertrand SIMONNET# Creates position independent code for non firmware target.
161f8f807a5ef00e8d5360fc2c9093bd0b5da8c0507Bertrand SIMONNETCFLAGS += -fPIE
162f8f807a5ef00e8d5360fc2c9093bd0b5da8c0507Bertrand SIMONNETendif
163f8f807a5ef00e8d5360fc2c9093bd0b5da8c0507Bertrand SIMONNET
1640c3ba249abb1dc60f5ebabccf84ff13206440b83Bill Richardson# These are required to access large disks and files on 32-bit systems.
1650c3ba249abb1dc60f5ebabccf84ff13206440b83Bill RichardsonCFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
1660c3ba249abb1dc60f5ebabccf84ff13206440b83Bill Richardson
16759d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler# Code coverage
168eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifneq (${COV},)
169d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardson  COV_FLAGS = -O0 --coverage -DCOVERAGE
17059d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler  CFLAGS += ${COV_FLAGS}
17159d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler  LDFLAGS += ${COV_FLAGS}
17259d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler  COV_INFO = ${BUILD}/coverage.info
173eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
174eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
175eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# And a few more default utilities
176eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonLD = ${CC}
177eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCXX ?= g++ # HEY: really?
178eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonPKG_CONFIG ?= pkg-config
179eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
180844bce57471153664c78993dab453e87891bb969Randall Spangler# Determine QEMU architecture needed, if any
181eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${ARCH},${HOST_ARCH})
182844bce57471153664c78993dab453e87891bb969Randall Spangler  # Same architecture; no need for QEMU
183844bce57471153664c78993dab453e87891bb969Randall Spangler  QEMU_ARCH :=
18461a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${HOST_ARCH}-${ARCH},x86_64-x86)
185844bce57471153664c78993dab453e87891bb969Randall Spangler  # 64-bit host can run 32-bit targets directly
186844bce57471153664c78993dab453e87891bb969Randall Spangler  QEMU_ARCH :=
187844bce57471153664c78993dab453e87891bb969Randall Spanglerelse
188eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson  QEMU_ARCH := ${ARCH}
189844bce57471153664c78993dab453e87891bb969Randall Spanglerendif
190844bce57471153664c78993dab453e87891bb969Randall Spangler
191844bce57471153664c78993dab453e87891bb969Randall Spangler# The top of the chroot for qemu must be passed in via the SYSROOT environment
192844bce57471153664c78993dab453e87891bb969Randall Spangler# variable.  In the Chromium OS chroot, this is done automatically by the
193844bce57471153664c78993dab453e87891bb969Randall Spangler# ebuild.
194844bce57471153664c78993dab453e87891bb969Randall Spangler
195eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${QEMU_ARCH},)
196844bce57471153664c78993dab453e87891bb969Randall Spangler  # Path to build output for running tests is same as for building
197eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson  BUILD_RUN = ${BUILD}
198e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler  SRC_RUN = ${SRCDIR}
199844bce57471153664c78993dab453e87891bb969Randall Spanglerelse
200844bce57471153664c78993dab453e87891bb969Randall Spangler  $(info Using qemu for testing.)
201844bce57471153664c78993dab453e87891bb969Randall Spangler  # Path to build output for running tests is different in the chroot
202eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson  BUILD_RUN = $(subst ${SYSROOT},,${BUILD})
203e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler  SRC_RUN = $(subst ${SYSROOT},,${SRCDIR})
204844bce57471153664c78993dab453e87891bb969Randall Spangler
205eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson  QEMU_BIN = qemu-${QEMU_ARCH}
206e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler  QEMU_RUN = ${BUILD_RUN}/${QEMU_BIN}
207e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler  export QEMU_RUN
208287beaed7f8ceff679c57664d4da008c6234edfdRandall Spangler
209e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler  RUNTEST = tests/test_using_qemu.sh
210e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spanglerendif
2115d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
212e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spanglerexport BUILD_RUN
2135d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
214eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson##############################################################################
215eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Now we need to describe everything we might want or need to build
216b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass
217eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Everything wants these headers.
2185d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerINCLUDES += \
2195d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	-Ifirmware/include \
2205d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	-Ifirmware/lib/include \
2215d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	-Ifirmware/lib/cgptlib/include \
2225d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	-Ifirmware/lib/cryptolib/include \
223786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	-Ifirmware/lib/tpm_lite/include \
224786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	-Ifirmware/2lib/include
2250b8f35c6a56a0e645254dd7f07ca68e01c8ee629Bill Richardson
226eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# If we're not building for a specific target, just stub out things like the
227eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM commands and various external functions that are provided by the BIOS.
228eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH},)
2290f6679e8582219b40e2ab5485992827a92c18bcdBill RichardsonINCLUDES += -Ifirmware/stub/include -Ihost/include -Ihost/lib/include
2300a0e8d0bb26c951a895c5034a4c1c12f3d4e8707Che-Liang Chiouelse
231eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonINCLUDES += -Ifirmware/arch/${FIRMWARE_ARCH}/include
2325d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif
2335d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
234782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# Firmware library, used by the other firmware components (depthcharge,
235782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# coreboot, etc.). It doesn't need exporting to some other place; they'll build
236782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# this source tree locally and link to it directly.
237eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonFWLIB = ${BUILD}/vboot_fw.a
2385d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
239786acdabcc15f023330d7c628aca9679e757a238Randall Spangler# Smaller firmware library. TODO: Do we still need to export this?
240786acdabcc15f023330d7c628aca9679e757a238Randall Spanglerifneq (${VBOOT2},)
241786acdabcc15f023330d7c628aca9679e757a238Randall SpanglerFWLIB2 = ${BUILD}/vboot_fw2.a
242786acdabcc15f023330d7c628aca9679e757a238Randall Spanglerendif
243786acdabcc15f023330d7c628aca9679e757a238Randall Spangler
24493943266c597ad66300445a04afa01270f2b5763Randall Spangler# Firmware library sources needed by VbInit() call
24593943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBINIT_SRCS = \
2465d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/crc8.c \
24793943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/lib/utility.c \
24893943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/lib/vboot_api_init.c \
24993943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/lib/vboot_common_init.c \
25093943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/lib/vboot_nvstorage.c \
251782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/lib/vboot_nvstorage_rollback.c \
252527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass	firmware/lib/region-init.c \
25393943266c597ad66300445a04afa01270f2b5763Randall Spangler
25493943266c597ad66300445a04afa01270f2b5763Randall Spangler# Additional firmware library sources needed by VbSelectFirmware() call
25593943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_SRCS = \
2565d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cryptolib/padding.c \
2575d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cryptolib/rsa.c \
2585d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cryptolib/rsa_utility.c \
2595d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cryptolib/sha1.c \
2605d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cryptolib/sha256.c \
2615d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cryptolib/sha512.c \
2625d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cryptolib/sha_utility.c \
2635d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/stateful_util.c \
2645d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/vboot_api_firmware.c \
26593943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/lib/vboot_common.c \
266527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass	firmware/lib/vboot_firmware.c \
267527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass	firmware/lib/region-fw.c \
26893943266c597ad66300445a04afa01270f2b5763Randall Spangler
26993943266c597ad66300445a04afa01270f2b5763Randall Spangler# Additional firmware library sources needed by VbSelectAndLoadKernel() call
27093943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSLK_SRCS = \
27193943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/lib/cgptlib/cgptlib.c \
27293943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/lib/cgptlib/cgptlib_internal.c \
27393943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/lib/cgptlib/crc32.c \
2745c9e4532b9bc45cff22f37d3556da679809a60a7Albert Chaulk	firmware/lib/cgptlib/mtdlib.c \
27593943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/lib/utility_string.c \
2765d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/vboot_api_kernel.c \
2775d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/vboot_audio.c \
2785d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/vboot_display.c \
279527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass	firmware/lib/vboot_kernel.c \
280527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass	firmware/lib/region-kernel.c \
2815d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
282786acdabcc15f023330d7c628aca9679e757a238Randall Spangler# Firmware library source needed for smaller library 2
283786acdabcc15f023330d7c628aca9679e757a238Randall SpanglerFWLIB2_SRCS = \
284a7ab8b50b8923afcfd7a9e6181892c4c8a2de250Randall Spangler	firmware/2lib/2api.c \
285786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	firmware/2lib/2common.c \
2863333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	firmware/2lib/2crc8.c \
2873333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	firmware/2lib/2misc.c \
2883333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	firmware/2lib/2nvstorage.c \
289e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	firmware/2lib/2rsa.c \
2903333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	firmware/2lib/2secdata.c \
291e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	firmware/2lib/2sha1.c \
292e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	firmware/2lib/2sha256.c \
293e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	firmware/2lib/2sha512.c \
294e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	firmware/2lib/2sha_utility.c \
295786acdabcc15f023330d7c628aca9679e757a238Randall Spangler
296eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Support real TPM unless BIOS sets MOCK_TPM
297eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${MOCK_TPM},)
29893943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBINIT_SRCS += \
2995d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/rollback_index.c \
3005d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/tpm_lite/tlcl.c
30193943266c597ad66300445a04afa01270f2b5763Randall Spangler
30293943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_SRCS += \
30393943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/lib/tpm_bootmode.c
3045d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerelse
30593943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBINIT_SRCS += \
3065d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/mocked_rollback_index.c \
3075d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/tpm_lite/mocked_tlcl.c
30893943266c597ad66300445a04afa01270f2b5763Randall Spangler
30993943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_SRCS += \
31093943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/lib/mocked_tpm_bootmode.c
3115d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif
3125d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
313eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH},)
314eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Include BIOS stubs in the firmware library when compiling for host
31593943266c597ad66300445a04afa01270f2b5763Randall Spangler# TODO: split out other stub funcs too
31693943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBINIT_SRCS += \
3175d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/stub/tpm_lite_stub.c \
3185d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/stub/utility_stub.c \
319527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass	firmware/stub/vboot_api_stub_init.c \
320527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass	firmware/stub/vboot_api_stub_region.c
32193943266c597ad66300445a04afa01270f2b5763Randall Spangler
32293943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_SRCS += \
32393943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/stub/vboot_api_stub_sf.c
32493943266c597ad66300445a04afa01270f2b5763Randall Spangler
32593943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSLK_SRCS += \
3265d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/stub/vboot_api_stub.c \
3275d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/stub/vboot_api_stub_disk.c
328da2b49cf08a27551fd910626f669910a636378d4Randall Spangler
329da2b49cf08a27551fd910626f669910a636378d4Randall SpanglerFWLIB2_SRCS += \
330da2b49cf08a27551fd910626f669910a636378d4Randall Spangler	firmware/2lib/2stub.c
331da2b49cf08a27551fd910626f669910a636378d4Randall Spangler
3325d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif
3335d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
33493943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_SRCS += ${VBINIT_SRCS}
33593943266c597ad66300445a04afa01270f2b5763Randall SpanglerFWLIB_SRCS += ${VBSF_SRCS} ${VBSLK_SRCS}
33693943266c597ad66300445a04afa01270f2b5763Randall Spangler
33793943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBINIT_OBJS = ${VBINIT_SRCS:%.c=${BUILD}/%.o}
33893943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_OBJS = ${VBSF_SRCS:%.c=${BUILD}/%.o}
33993943266c597ad66300445a04afa01270f2b5763Randall Spangler
340eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonFWLIB_OBJS = ${FWLIB_SRCS:%.c=${BUILD}/%.o}
3411912bbae89b82c10819b01d039e140e39c668fc7Bill Richardson
342786acdabcc15f023330d7c628aca9679e757a238Randall Spanglerifneq (${VBOOT2},)
343786acdabcc15f023330d7c628aca9679e757a238Randall SpanglerFWLIB2_OBJS = ${FWLIB2_SRCS:%.c=${BUILD}/%.o}
344786acdabcc15f023330d7c628aca9679e757a238Randall Spanglerendif
3455d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
346786acdabcc15f023330d7c628aca9679e757a238Randall SpanglerALL_OBJS += ${FWLIB_OBJS} ${FWLIB2_OBJS} ${VBINIT_OBJS} ${VBSF_OBJS}
3475d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
348782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# Intermediate library for the vboot_reference utilities to link against.
349782990277ac7d6730db4c43c2b5632de93396921Bill RichardsonUTILLIB = ${BUILD}/libvboot_util.a
3505d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
351782990277ac7d6730db4c43c2b5632de93396921Bill RichardsonUTILLIB_SRCS = \
35281a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	cgpt/cgpt_create.c \
35381a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	cgpt/cgpt_add.c \
35481a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	cgpt/cgpt_boot.c \
35581a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	cgpt/cgpt_show.c \
35681a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	cgpt/cgpt_repair.c \
35781a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	cgpt/cgpt_prioritize.c \
35881a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	cgpt/cgpt_common.c \
35918e03706df6ab4256a89f4e578ecf0f165641c8aBill Richardson	cgpt/flash_ts.c \
360534723a6519267461855441279b321e6fc1e4e90Albert Chaulk	cgpt/flash_ts_drv.c \
361b334e651a597a10d562bc882613f0b482b24e3caAlbert Chaulk	firmware/lib/cgptlib/mtdlib.c \
3626f3961507e73f90cec665896dece884e86be560aBill Richardson	futility/dump_kernel_config_lib.c \
363eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	host/arch/${ARCH}/lib/crossystem_arch.c \
3645d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/crossystem.c \
3655d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/file_keys.c \
3665d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/fmap.c \
3675d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/host_common.c \
3685d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/host_key.c \
3695d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/host_keyblock.c \
3705d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/host_misc.c \
371782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	host/lib/util_misc.c \
3725d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/host_signature.c \
3736f3961507e73f90cec665896dece884e86be560aBill Richardson	host/lib/signature_digest.c
3745d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
375782990277ac7d6730db4c43c2b5632de93396921Bill RichardsonUTILLIB_OBJS = ${UTILLIB_SRCS:%.c=${BUILD}/%.o}
376782990277ac7d6730db4c43c2b5632de93396921Bill RichardsonALL_OBJS += ${UTILLIB_OBJS}
377782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
378782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# Externally exported library for some target userspace apps to link with
379782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# (cryptohome, updater, etc.)
380782990277ac7d6730db4c43c2b5632de93396921Bill RichardsonHOSTLIB = ${BUILD}/libvboot_host.a
381782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
382782990277ac7d6730db4c43c2b5632de93396921Bill RichardsonHOSTLIB_SRCS = \
383782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	cgpt/cgpt_add.c \
384782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	cgpt/cgpt_boot.c \
385782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	cgpt/cgpt_common.c \
386782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	cgpt/cgpt_create.c \
387782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	cgpt/cgpt_prioritize.c \
38818e03706df6ab4256a89f4e578ecf0f165641c8aBill Richardson	cgpt/flash_ts.c \
389782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	cgpt/flash_ts_drv.c \
390782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/lib/cgptlib/cgptlib_internal.c \
391782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/lib/cgptlib/crc32.c \
392782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/lib/cgptlib/mtdlib.c \
393782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/lib/crc8.c \
394782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/lib/tpm_lite/tlcl.c \
395782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/lib/utility_string.c \
396782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/lib/vboot_nvstorage.c \
397782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/stub/tpm_lite_stub.c \
398782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/stub/utility_stub.c \
399782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/stub/vboot_api_stub_init.c \
4006f3961507e73f90cec665896dece884e86be560aBill Richardson	futility/dump_kernel_config_lib.c \
401782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	host/arch/${ARCH}/lib/crossystem_arch.c \
402782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	host/lib/crossystem.c \
4036f3961507e73f90cec665896dece884e86be560aBill Richardson	host/lib/host_misc.c
404782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
405eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonHOSTLIB_OBJS = ${HOSTLIB_SRCS:%.c=${BUILD}/%.o}
4065d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerALL_OBJS += ${HOSTLIB_OBJS}
4075d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
40881a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson# Sigh. For historical reasons, the autoupdate installer must sometimes be a
40981a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson# 32-bit executable, even when everything else is 64-bit. But it only needs a
41081a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson# few functions, so let's just build those.
41181a0b3de707b4e00958faf36f41b8f3d7bac6808Bill RichardsonTINYHOSTLIB = ${BUILD}/libtinyvboot_host.a
41281a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson
41381a0b3de707b4e00958faf36f41b8f3d7bac6808Bill RichardsonTINYHOSTLIB_SRCS = \
41481a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	cgpt/cgpt_add.c \
41581a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	cgpt/cgpt_boot.c \
41681a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	cgpt/cgpt_common.c \
417782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	cgpt/cgpt_create.c \
418782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	cgpt/cgpt_prioritize.c \
41918e03706df6ab4256a89f4e578ecf0f165641c8aBill Richardson	cgpt/flash_ts.c \
420534723a6519267461855441279b321e6fc1e4e90Albert Chaulk	cgpt/flash_ts_drv.c \
421782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/lib/cgptlib/cgptlib_internal.c \
422782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/lib/cgptlib/crc32.c \
423b334e651a597a10d562bc882613f0b482b24e3caAlbert Chaulk	firmware/lib/cgptlib/mtdlib.c \
4245fed2a667096341160db8643a4a057e328953a1dBill Richardson	firmware/lib/utility_string.c \
425782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/stub/utility_stub.c \
4266f3961507e73f90cec665896dece884e86be560aBill Richardson	futility/dump_kernel_config_lib.c
42781a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson
42881a0b3de707b4e00958faf36f41b8f3d7bac6808Bill RichardsonTINYHOSTLIB_OBJS = ${TINYHOSTLIB_SRCS:%.c=${BUILD}/%.o}
429eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
430eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
431eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Now for the userspace binaries
4325d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
4335d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCGPT = ${BUILD}/cgpt/cgpt
4345d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
4355d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCGPT_SRCS = \
4365d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt.c \
4375d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_add.c \
4385d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_boot.c \
4395d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_common.c \
4405d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_create.c \
4415d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_find.c \
4425d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_legacy.c \
4435d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_prioritize.c \
4445d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_repair.c \
4455d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_show.c \
4465d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cmd_add.c \
4475d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cmd_boot.c \
4485d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cmd_create.c \
4495d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cmd_find.c \
4505d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cmd_legacy.c \
4515d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cmd_prioritize.c \
4525d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cmd_repair.c \
453534723a6519267461855441279b321e6fc1e4e90Albert Chaulk	cgpt/cmd_show.c \
45418e03706df6ab4256a89f4e578ecf0f165641c8aBill Richardson	cgpt/flash_ts.c \
45518e03706df6ab4256a89f4e578ecf0f165641c8aBill Richardson	cgpt/flash_ts_drv.c
4565d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
457eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCGPT_OBJS = ${CGPT_SRCS:%.c=${BUILD}/%.o}
4585d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerALL_OBJS += ${CGPT_OBJS}
4595d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
4605d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
461eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Scripts to install directly (not compiled)
4625d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerUTIL_SCRIPTS = \
4635d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	utility/dev_debug_vboot \
4645d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	utility/enable_dev_usb_boot \
4655d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	utility/vbutil_what_keys
4665d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
467c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonifeq (${MINIMAL},)
468c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill RichardsonUTIL_SCRIPTS += \
469c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	utility/dev_make_keypair
470c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonendif
471c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson
472eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# These utilities should be linked statically.
473eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonUTIL_NAMES_STATIC = \
4746f3961507e73f90cec665896dece884e86be560aBill Richardson	utility/crossystem
475eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
476eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonUTIL_NAMES = ${UTIL_NAMES_STATIC} \
477339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	utility/tpm_init_temp_fix \
4786f3961507e73f90cec665896dece884e86be560aBill Richardson	utility/tpmc
4795d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
4806f3961507e73f90cec665896dece884e86be560aBill Richardson# TODO: Do we still need eficompress and efidecompress for anything?
481eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${MINIMAL},)
4825d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerUTIL_NAMES += \
483339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	utility/bmpblk_font \
484339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	utility/bmpblk_utility \
4856f3961507e73f90cec665896dece884e86be560aBill Richardson	utility/dumpRSAPublicKey \
486339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	utility/eficompress \
487339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	utility/efidecompress \
488339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	utility/load_kernel_test \
489339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	utility/pad_digest_utility \
490339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	utility/signature_digest_utility \
491339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	utility/verify_data
492a7ab8b50b8923afcfd7a9e6181892c4c8a2de250Randall Spangler
4935d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif
4945d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
495339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonUTIL_BINS_STATIC := $(addprefix ${BUILD}/,${UTIL_NAMES_STATIC})
496339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonUTIL_BINS = $(addprefix ${BUILD}/,${UTIL_NAMES})
4971912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += $(addsuffix .o,${UTIL_BINS} ${UTIL_BINS_STATIC})
4985d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
499c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson
500c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# Scripts for signing stuff.
501c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill RichardsonSIGNING_SCRIPTS = \
502c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	utility/tpm-nvsize \
503c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	utility/chromeos-tpm-recovery
504c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson
505c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# These go in a different place.
506c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill RichardsonSIGNING_SCRIPTS_DEV = \
507c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	scripts/image_signing/resign_firmwarefd.sh \
508c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	scripts/image_signing/make_dev_firmware.sh \
509c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	scripts/image_signing/make_dev_ssd.sh \
510c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	scripts/image_signing/set_gbb_flags.sh
511c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson
512c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# Installed, but not made executable.
513c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill RichardsonSIGNING_COMMON = scripts/image_signing/common_minimal.sh
514eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
515eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
516eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# The unified firmware utility will eventually replace all the others
517eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonFUTIL_BIN = ${BUILD}/futility/futility
5186db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson# But we still need both static (tiny) and dynamic (with openssl) versions.
5196db8c75021e2edfa400ae707a8544d041e3c415fBill RichardsonFUTIL_STATIC_BIN = ${FUTIL_BIN}_s
520eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
5216f3961507e73f90cec665896dece884e86be560aBill Richardson# These are the executables that are now built in to futility. We'll create
5226f3961507e73f90cec665896dece884e86be560aBill Richardson# symlinks for these so the old names will still work.
5236f3961507e73f90cec665896dece884e86be560aBill Richardson# TODO: Do we still need dev_sign_file for anything?
5246f3961507e73f90cec665896dece884e86be560aBill RichardsonFUTIL_BUILTIN = \
525e155044a7bbb9b8c6eb751af051726cfe1b411a4Bill Richardson	dev_sign_file \
526e155044a7bbb9b8c6eb751af051726cfe1b411a4Bill Richardson	dump_fmap \
527e155044a7bbb9b8c6eb751af051726cfe1b411a4Bill Richardson	dump_kernel_config \
528e155044a7bbb9b8c6eb751af051726cfe1b411a4Bill Richardson	gbb_utility \
529e155044a7bbb9b8c6eb751af051726cfe1b411a4Bill Richardson	vbutil_firmware \
530e155044a7bbb9b8c6eb751af051726cfe1b411a4Bill Richardson	vbutil_kernel \
531e155044a7bbb9b8c6eb751af051726cfe1b411a4Bill Richardson	vbutil_key \
5326f3961507e73f90cec665896dece884e86be560aBill Richardson	vbutil_keyblock
533feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson
5346db8c75021e2edfa400ae707a8544d041e3c415fBill RichardsonFUTIL_STATIC_SRCS = \
535feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson	futility/futility.c \
53620807b6158b6a43baf0974bc763890888ba1f841Bill Richardson	futility/cmd_dump_fmap.c \
5376f3961507e73f90cec665896dece884e86be560aBill Richardson	futility/cmd_gbb_utility.c
538eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
5396db8c75021e2edfa400ae707a8544d041e3c415fBill RichardsonFUTIL_SRCS = \
5406db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson	$(FUTIL_STATIC_SRCS) \
5416f3961507e73f90cec665896dece884e86be560aBill Richardson	futility/cmd_dev_sign_file.c \
5426f3961507e73f90cec665896dece884e86be560aBill Richardson	futility/cmd_dump_kernel_config.c \
5436f3961507e73f90cec665896dece884e86be560aBill Richardson	futility/cmd_vbutil_firmware.c \
5446f3961507e73f90cec665896dece884e86be560aBill Richardson	futility/cmd_vbutil_kernel.c \
545b84b81dc265a766a968bf126905447d442558218Bill Richardson	futility/cmd_vbutil_key.c \
5466f3961507e73f90cec665896dece884e86be560aBill Richardson	futility/cmd_vbutil_keyblock.c
5476db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson
548028f468aff976ef5e76f20133c64ec19cb9d1517Randall Spanglerifneq (${VBOOT2},)
549028f468aff976ef5e76f20133c64ec19cb9d1517Randall SpanglerFUTIL_SRCS += \
550028f468aff976ef5e76f20133c64ec19cb9d1517Randall Spangler	futility/cmd_vb2_verify_fw.c
551028f468aff976ef5e76f20133c64ec19cb9d1517Randall Spanglerendif
552028f468aff976ef5e76f20133c64ec19cb9d1517Randall Spangler
553eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonFUTIL_LDS = futility/futility.lds
554eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
5556db8c75021e2edfa400ae707a8544d041e3c415fBill RichardsonFUTIL_STATIC_OBJS = ${FUTIL_STATIC_SRCS:%.c=${BUILD}/%.o}
556eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonFUTIL_OBJS = ${FUTIL_SRCS:%.c=${BUILD}/%.o}
557eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
558eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonALL_OBJS += ${FUTIL_OBJS}
559eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
560eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
561eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Library of handy test functions.
562eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTESTLIB = ${BUILD}/tests/test.a
563eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
564eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTESTLIB_SRCS = \
565eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tests/test_common.c \
566eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tests/timer_utils.c \
567eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tests/crc32_test.c
568eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
569eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTESTLIB_OBJS = ${TESTLIB_SRCS:%.c=${BUILD}/%.o}
570eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonALL_OBJS += ${TESTLIB_OBJS}
571eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
572eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
573eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# And some compiled tests.
574eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTEST_NAMES = \
575339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/cgptlib_test \
576339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/rollback_index2_tests \
577339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/rollback_index3_tests \
578339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/rsa_padding_test \
579339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/rsa_utility_tests \
580339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/rsa_verify_benchmark \
581339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/sha_benchmark \
582339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/sha_tests \
583339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/stateful_util_tests \
584339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tlcl_tests \
585339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_bootmode_tests \
586339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/utility_string_tests \
587339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/utility_tests \
588339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_api_init_tests \
589339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_api_devmode_tests \
590339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_api_firmware_tests \
591339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_api_kernel_tests \
592339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_api_kernel2_tests \
593339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_api_kernel3_tests \
594339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_api_kernel4_tests \
595339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_audio_tests \
596339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_common_tests \
597339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_common2_tests \
598339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_common3_tests \
599339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_display_tests \
600339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_firmware_tests \
601339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_kernel_tests \
602339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_nvstorage_test \
6036f3961507e73f90cec665896dece884e86be560aBill Richardson	tests/futility/binary_editor \
604339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/futility/test_not_really
605eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
606527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glassifdef REGION_READ
607527ba810eff4006cf69579f6b96cb4350cb1e189Simon GlassTEST_NAMES += tests/vboot_region_tests
608527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glassendif
609527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass
610786acdabcc15f023330d7c628aca9679e757a238Randall Spanglerifneq (${VBOOT2},)
611786acdabcc15f023330d7c628aca9679e757a238Randall SpanglerTEST_NAMES += \
612a7ab8b50b8923afcfd7a9e6181892c4c8a2de250Randall Spangler	tests/vb2_api_tests \
613786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	tests/vb2_common_tests \
6147141d73c149ee203a192f0cb45ca9bfa10c0ff8cRandall Spangler	tests/vb2_common2_tests \
6157141d73c149ee203a192f0cb45ca9bfa10c0ff8cRandall Spangler	tests/vb2_common3_tests \
6163333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	tests/vb2_misc_tests \
6171803068173a625efd83d1cee8dd90843feb0d972Randall Spangler	tests/vb2_misc2_tests \
6183333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	tests/vb2_nvstorage_tests \
619e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	tests/vb2_rsa_padding_tests \
620e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	tests/vb2_rsa_utility_tests \
6213333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	tests/vb2_secdata_tests \
622e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	tests/vb2_sha_tests \
623786acdabcc15f023330d7c628aca9679e757a238Randall Spangler
624786acdabcc15f023330d7c628aca9679e757a238Randall Spanglerendif
625786acdabcc15f023330d7c628aca9679e757a238Randall Spangler
626eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: port these tests to new API, if not already eqivalent
627eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# functionality in other tests.  These don't even compile at present.
628eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#
629eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		big_firmware_tests
630eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		big_kernel_tests
631eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		firmware_image_tests
632eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		firmware_rollback_tests
633eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		firmware_splicing_tests
634eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		firmware_verify_benchmark
635eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		kernel_image_tests
636eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		kernel_rollback_tests
637eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		kernel_splicing_tests
638eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		kernel_verify_benchmark
639eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		rollback_index_test
640eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		verify_firmware_fuzz_driver
641eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#		verify_kernel_fuzz_driver
642eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#               utility/load_firmware_test
643eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
644eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# And a few more...
645339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonTLCL_TEST_NAMES = \
646339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_lite/tpmtest_earlyextend \
647339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_lite/tpmtest_earlynvram \
648339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson        tests/tpm_lite/tpmtest_earlynvram2 \
649339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_lite/tpmtest_enable \
650339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_lite/tpmtest_fastenable \
651339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_lite/tpmtest_globallock \
652339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson        tests/tpm_lite/tpmtest_redefine_unowned \
653339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson        tests/tpm_lite/tpmtest_spaceperm \
654339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_lite/tpmtest_testsetup \
655339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_lite/tpmtest_timing \
656339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson        tests/tpm_lite/tpmtest_writelimit
657eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
658eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTEST_NAMES += ${TLCL_TEST_NAMES}
659eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
660339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson# Finally
661339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonTEST_BINS = $(addprefix ${BUILD}/,${TEST_NAMES})
6621912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += $(addsuffix .o,${TEST_BINS})
663eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
664e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler# Directory containing test keys
665e061a256549607a56d771eb8ddae5d0dd90d519cRandall SpanglerTEST_KEYS = ${SRC_RUN}/tests/testkeys
666eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
667eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
668eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson##############################################################################
669eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Finally, some targets. High-level ones first.
670eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
671eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Create output directories if necessary.  Do this via explicit shell commands
672eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# so it happens before trying to generate/include dependencies.
673eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonSUBDIRS := firmware host cgpt utility futility tests tests/tpm_lite
674eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson_dir_create := $(foreach d, \
675eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	$(shell find ${SUBDIRS} -name '*.c' -exec  dirname {} \; | sort -u), \
676eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	$(shell [ -d ${BUILD}/${d} ] || mkdir -p ${BUILD}/${d}))
677eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
678eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
679eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Default target.
680eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: all
681786acdabcc15f023330d7c628aca9679e757a238Randall Spanglerall: fwlib $(if ${VBOOT2},fwlib2) $(if ${FIRMWARE_ARCH},,host_stuff) \
682786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	$(if ${COV},coverage)
683eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
684eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Host targets
685eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: host_stuff
686bc2d2b21d97d35f69dc083ad44fb08419fe32a08Bill Richardsonhost_stuff: utillib hostlib cgpt utils futil tests
687eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
688eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: clean
689eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonclean:
690eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}/bin/rm -rf ${BUILD}
691eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
692eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: install
693c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsoninstall: cgpt_install utils_install signing_install futil_install
694eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
6953e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardson.PHONY: install_for_test
6963e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardsoninstall_for_test: override DESTDIR = ${TEST_INSTALL_DIR}
6973e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardsoninstall_for_test: install
6983e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardson
699eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Don't delete intermediate object files
700eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.SECONDARY:
701eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
702eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
703eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
704eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Firmware library
705eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
706eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM-specific flags.  These depend on the particular TPM we're targeting for.
707eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# They are needed here only for compiling parts of the firmware code into
708eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# user-level tests.
709eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
710eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM_BLOCKING_CONTINUESELFTEST is defined if TPM_ContinueSelfTest blocks until
711eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# the self test has completed.
712eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
71345cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DTPM_BLOCKING_CONTINUESELFTEST
714eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
715eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM_MANUAL_SELFTEST is defined if the self test must be started manually
716eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# (with a call to TPM_ContinueSelfTest) instead of starting automatically at
717eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# power on.
718eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#
719eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# We sincerely hope that TPM_BLOCKING_CONTINUESELFTEST and TPM_MANUAL_SELFTEST
720eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# are not both defined at the same time.  (See comment in code.)
721eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
722eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# CFLAGS += -DTPM_MANUAL_SELFTEST
723eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
724eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH},i386)
725eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Unrolling loops in cryptolib makes it faster
72645cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DUNROLL_LOOPS
727786acdabcc15f023330d7c628aca9679e757a238Randall Spangler${FWLIB2_OBJS}: CFLAGS += -DUNROLL_LOOPS
728eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
729eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Workaround for coreboot on x86, which will power off asynchronously
730eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# without giving us a chance to react. This is not an example of the Right
731eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Way to do things. See chrome-os-partner:7689, and the commit message
732eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# that made this change.
73345cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DSAVE_LOCALE_IMMEDIATELY
734eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
735eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# On x86 we don't actually read the GBB data into RAM until it is needed.
736eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Therefore it makes sense to cache it rather than reading it each time.
737eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Enable this feature.
73845cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DCOPY_BMP_DATA
739eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
740eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
741527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glassifdef REGION_READ
742527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass${FWLIB_OBJS}: CFLAGS += -DREGION_READ
743527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glassendif
744527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass
745eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH},)
746eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Disable rollback TPM when compiling locally, since otherwise
747eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# load_kernel_test attempts to talk to the TPM.
74845cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DDISABLE_ROLLBACK_TPM
749eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
750eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
751a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson# Linktest ensures firmware lib doesn't rely on outside libraries
752a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${BUILD}/firmware/linktest/main_vbinit: ${VBINIT_OBJS}
75393943266c597ad66300445a04afa01270f2b5763Randall Spangler${BUILD}/firmware/linktest/main_vbinit: OBJS = ${VBINIT_OBJS}
7541912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BUILD}/firmware/linktest/main_vbinit.o
755a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${BUILD}/firmware/linktest/main_vbsf: ${VBSF_OBJS}
75693943266c597ad66300445a04afa01270f2b5763Randall Spangler${BUILD}/firmware/linktest/main_vbsf: OBJS = ${VBSF_OBJS}
7571912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BUILD}/firmware/linktest/main_vbsf.o
758a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${BUILD}/firmware/linktest/main: ${FWLIB}
759a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${BUILD}/firmware/linktest/main: LIBS = ${FWLIB}
7601912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BUILD}/firmware/linktest/main.o
76193943266c597ad66300445a04afa01270f2b5763Randall Spangler
762d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardson.PHONY: fwlinktest
763d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardsonfwlinktest: \
76493943266c597ad66300445a04afa01270f2b5763Randall Spangler	${BUILD}/firmware/linktest/main_vbinit \
76593943266c597ad66300445a04afa01270f2b5763Randall Spangler	${BUILD}/firmware/linktest/main_vbsf \
76693943266c597ad66300445a04afa01270f2b5763Randall Spangler	${BUILD}/firmware/linktest/main
76793943266c597ad66300445a04afa01270f2b5763Randall Spangler
768eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: fwlib
769a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardsonfwlib: $(if ${FIRMWARE_ARCH},${FWLIB},fwlinktest)
770eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
771786acdabcc15f023330d7c628aca9679e757a238Randall Spangler.PHONY: fwlib2
772786acdabcc15f023330d7c628aca9679e757a238Randall Spanglerfwlib2: ${FWLIB2}
773786acdabcc15f023330d7c628aca9679e757a238Randall Spangler
774eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${FWLIB}: ${FWLIB_OBJS}
775661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass	@$(PRINTF) "    RM            $(subst ${BUILD}/,,$@)\n"
776eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}rm -f $@
777661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass	@$(PRINTF) "    AR            $(subst ${BUILD}/,,$@)\n"
778eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}ar qc $@ $^
779eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
780786acdabcc15f023330d7c628aca9679e757a238Randall Spangler${FWLIB2}: ${FWLIB2_OBJS}
781786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	@$(PRINTF) "    RM            $(subst ${BUILD}/,,$@)\n"
782786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	${Q}rm -f $@
783786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	@$(PRINTF) "    AR            $(subst ${BUILD}/,,$@)\n"
784786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	${Q}ar qc $@ $^
785786acdabcc15f023330d7c628aca9679e757a238Randall Spangler
786eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
787782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# Host library(s)
788eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
789782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# Link tests for local utilities
790782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${BUILD}/host/linktest/main: ${UTILLIB}
791782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${BUILD}/host/linktest/main: LIBS = ${UTILLIB}
792782990277ac7d6730db4c43c2b5632de93396921Bill RichardsonALL_OBJS += ${BUILD}/host/linktest/main.o
793782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
794782990277ac7d6730db4c43c2b5632de93396921Bill Richardson.PHONY: utillib
795782990277ac7d6730db4c43c2b5632de93396921Bill Richardsonutillib: ${UTILLIB} \
796782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	${BUILD}/host/linktest/main
797eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
798eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: better way to make .a than duplicating this recipe each time?
799782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${UTILLIB}: ${UTILLIB_OBJS} ${FWLIB_OBJS} $(if ${VBOOT2},${FWLIB2_OBJS})
800782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	@$(PRINTF) "    RM            $(subst ${BUILD}/,,$@)\n"
801782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	${Q}rm -f $@
802782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	@$(PRINTF) "    AR            $(subst ${BUILD}/,,$@)\n"
803782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	${Q}ar qc $@ $^
804782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
805782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
806782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# Link tests for external repos
807782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${BUILD}/host/linktest/extern: ${HOSTLIB}
808782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${BUILD}/host/linktest/extern: LIBS = ${HOSTLIB}
809782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${BUILD}/host/linktest/extern: LDLIBS += -static
810782990277ac7d6730db4c43c2b5632de93396921Bill RichardsonALL_OBJS += ${BUILD}/host/linktest/extern.o
811782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
812782990277ac7d6730db4c43c2b5632de93396921Bill Richardson.PHONY: hostlib
813782990277ac7d6730db4c43c2b5632de93396921Bill Richardsonhostlib: ${HOSTLIB} \
814782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	${BUILD}/host/linktest/extern
815782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
816782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# TODO: better way to make .a than duplicating this recipe each time?
817782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${HOSTLIB}: ${HOSTLIB_OBJS}
818661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass	@$(PRINTF) "    RM            $(subst ${BUILD}/,,$@)\n"
819eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}rm -f $@
820661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass	@$(PRINTF) "    AR            $(subst ${BUILD}/,,$@)\n"
821eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}ar qc $@ $^
822eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
82381a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson
82481a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson# Ugh. This is a very cut-down version of HOSTLIB just for the installer.
82581a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson.PHONY: tinyhostlib
82681a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardsontinyhostlib: ${TINYHOSTLIB}
82781a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	${Q}cp -f ${TINYHOSTLIB} ${HOSTLIB}
82881a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson
82981a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson${TINYHOSTLIB}: ${TINYHOSTLIB_OBJS}
830661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass	@$(PRINTF) "    RM            $(subst ${BUILD}/,,$@)\n"
83181a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	${Q}rm -f $@
832661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass	@$(PRINTF) "    AR            $(subst ${BUILD}/,,$@)\n"
83381a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	${Q}ar qc $@ $^
83481a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson
835eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
836eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# CGPT library and utility
837eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
838eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: cgpt
839eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsoncgpt: ${CGPT}
840eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
841eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${CGPT}: LDFLAGS += -static
842eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${CGPT}: LDLIBS += -luuid
843eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
844782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${CGPT}: ${CGPT_OBJS} ${UTILLIB}
845661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass	@$(PRINTF) "    LDcgpt        $(subst ${BUILD}/,,$@)\n"
8466db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson	${Q}${LD} -o ${CGPT} ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS}
847eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
848eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: cgpt_install
849eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsoncgpt_install: ${CGPT}
850661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass	@$(PRINTF) "    INSTALL       CGPT\n"
851c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	${Q}mkdir -p ${UB_DIR}
852c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	${Q}${INSTALL} -t ${UB_DIR} $^
853eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
854eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
855eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Utilities
856eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
857eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# These have their own headers too.
8580f6679e8582219b40e2ab5485992827a92c18bcdBill Richardson${BUILD}/utility/%: INCLUDES += -Iutility/include
8590f6679e8582219b40e2ab5485992827a92c18bcdBill Richardson
8600f6679e8582219b40e2ab5485992827a92c18bcdBill Richardson${UTIL_BINS} ${UTIL_BINS_STATIC}: ${UTILLIB}
8610f6679e8582219b40e2ab5485992827a92c18bcdBill Richardson${UTIL_BINS} ${UTIL_BINS_STATIC}: LIBS = ${UTILLIB}
862eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
863eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Utilities for auto-update toolkits must be statically linked.
864eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${UTIL_BINS_STATIC}: LDFLAGS += -static
865eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
866a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson
867acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: utils
868c7c6e5d2f7076fe512b692411f0d05d4bf76d91fBill Richardsonutils: ${UTIL_BINS} ${UTIL_SCRIPTS}
869eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}cp -f ${UTIL_SCRIPTS} ${BUILD}/utility
870eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}chmod a+rx $(patsubst %,${BUILD}/%,${UTIL_SCRIPTS})
871826db09fcec194951e1dc71002d6a92620fbb46bBill Richardson
872acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: utils_install
873c7c6e5d2f7076fe512b692411f0d05d4bf76d91fBill Richardsonutils_install: ${UTIL_BINS} ${UTIL_SCRIPTS}
874661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass	@$(PRINTF) "    INSTALL       UTILS\n"
875c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	${Q}mkdir -p ${UB_DIR}
876c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	${Q}${INSTALL} -t ${UB_DIR} ${UTIL_BINS} ${UTIL_SCRIPTS}
877c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson
878c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# And some signing stuff for the target
879c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson.PHONY: signing_install
880c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonsigning_install: ${SIGNING_SCRIPTS} ${SIGNING_SCRIPTS_DEV} ${SIGNING_COMMON}
881661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass	@$(PRINTF) "    INSTALL       SIGNING\n"
8826f3961507e73f90cec665896dece884e86be560aBill Richardson	${Q}mkdir -p ${UB_DIR} ${VB_DIR}
883c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	${Q}${INSTALL} -t ${UB_DIR} ${SIGNING_SCRIPTS}
8846f3961507e73f90cec665896dece884e86be560aBill Richardson	${Q}${INSTALL} -t ${VB_DIR} ${SIGNING_SCRIPTS_DEV}
8856f3961507e73f90cec665896dece884e86be560aBill Richardson	${Q}${INSTALL} -t ${VB_DIR} -m 'u=rw,go=r,a-s' ${SIGNING_COMMON}
8865d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
887eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
888eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# new Firmware Utility
8895d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
890eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: futil
8916db8c75021e2edfa400ae707a8544d041e3c415fBill Richardsonfutil: ${FUTIL_STATIC_BIN} ${FUTIL_BIN}
8926db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson
8930f6679e8582219b40e2ab5485992827a92c18bcdBill Richardson${FUTIL_STATIC_BIN}: ${FUTIL_LDS} ${FUTIL_STATIC_OBJS} ${UTILLIB}
8946db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson	@$(PRINTF) "    LD            $(subst ${BUILD}/,,$@)\n"
8956db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson	${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} -static $^ ${LDLIBS}
8965d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
897b84b81dc265a766a968bf126905447d442558218Bill Richardson${FUTIL_BIN}: LDLIBS += ${CRYPTO_LIBS}
8980f6679e8582219b40e2ab5485992827a92c18bcdBill Richardson${FUTIL_BIN}: ${FUTIL_LDS} ${FUTIL_OBJS} ${UTILLIB}
899661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass	@$(PRINTF) "    LD            $(subst ${BUILD}/,,$@)\n"
9006db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson	${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS}
9015d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
902eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: futil_install
903eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonfutil_install: ${FUTIL_BIN}
904661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass	@$(PRINTF) "    INSTALL       futility\n"
9056f3961507e73f90cec665896dece884e86be560aBill Richardson	${Q}mkdir -p ${UB_DIR}
9066f3961507e73f90cec665896dece884e86be560aBill Richardson	${Q}${INSTALL} -t ${UB_DIR} ${FUTIL_BIN} ${FUTIL_STATIC_BIN}
9076f3961507e73f90cec665896dece884e86be560aBill Richardson	${Q}for prog in ${FUTIL_BUILTIN}; do \
9086f3961507e73f90cec665896dece884e86be560aBill Richardson		ln -sf futility "${UB_DIR}/$$prog"; done
9095d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
910eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
9115d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Utility to generate TLCL structure definition header file.
9125d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
913acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/utility/tlcl_generator: CFLAGS += -fpack-struct
9145d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
9155d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerSTRUCTURES_TMP=${BUILD}/tlcl_structures.tmp
9165d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerSTRUCTURES_SRC=firmware/lib/tpm_lite/include/tlcl_structures.h
9175d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
918acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: update_tlcl_structures
9195d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerupdate_tlcl_structures: ${BUILD}/utility/tlcl_generator
920661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass	@$(PRINTF) "    Rebuilding TLCL structures\n"
921eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${BUILD}/utility/tlcl_generator > ${STRUCTURES_TMP}
922eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}cmp -s ${STRUCTURES_TMP} ${STRUCTURES_SRC} || \
9235d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler		( echo "%% Updating structures.h %%" && \
924eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson		  cp ${STRUCTURES_TMP} ${STRUCTURES_SRC} )
9255d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
926eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
9275d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Tests
9285d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
929eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: tests
930eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontests: ${TEST_BINS}
9315d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
932782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${TEST_BINS}: ${UTILLIB} ${TESTLIB}
933339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson${TEST_BINS}: INCLUDES += -Itests
934782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${TEST_BINS}: LIBS = ${UTILLIB} ${TESTLIB}
9355d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
936eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${TESTLIB}: ${TESTLIB_OBJS}
937661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass	@$(PRINTF) "    RM            $(subst ${BUILD}/,,$@)\n"
938eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}rm -f $@
939661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass	@$(PRINTF) "    AR            $(subst ${BUILD}/,,$@)\n"
940eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}ar qc $@ $^
9415d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
9425d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
943eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
944eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Generic build rules. LIBS and OBJS can be overridden to tweak the generic
945eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# rules for specific targets.
9465d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
947eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%: ${BUILD}/%.o ${OBJS} ${LIBS}
948661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass	@$(PRINTF) "    LD            $(subst ${BUILD}/,,$@)\n"
9496db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson	${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $< ${OBJS} ${LIBS} ${LDLIBS}
950eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
951eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%.o: %.c
952661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass	@$(PRINTF) "    CC            $(subst ${BUILD}/,,$@)\n"
953eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
954eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
955eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Rules to recompile a single source file for library and test
956eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: is there a tidier way to do this?
957eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_lib.o: CFLAGS += -DFOR_LIBRARY
958eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_lib.o: %.c
959661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass	@$(PRINTF) "    CC-for-lib    $(subst ${BUILD}/,,$@)\n"
960eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
961eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
962eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_test.o: CFLAGS += -DFOR_TEST
963eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_test.o: %.c
964661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass	@$(PRINTF) "    CC-for-test   $(subst ${BUILD}/,,$@)\n"
965eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
966eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
967eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: C++ files don't belong in vboot reference at all.  Convert to C.
968eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%.o: %.cc
969661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass	@$(PRINTF) "    CXX           $(subst ${BUILD}/,,$@)\n"
970eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${CXX} ${CFLAGS} ${INCLUDES} -c -o $@ $<
971eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
972eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
973eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Here are the special tweaks to the generic rules.
974eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
975feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson# Because we play some clever linker script games to add new commands without
976feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson# changing any header files, futility must be linked with ld.bfd, not gold.
977feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson${FUTIL_BIN}: LDFLAGS += -fuse-ld=bfd
9786db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson${FUTIL_STATIC_BIN}: LDFLAGS += -fuse-ld=bfd
979feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson
980eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Some utilities need external crypto functions
981782990277ac7d6730db4c43c2b5632de93396921Bill RichardsonCRYPTO_LIBS := $(shell ${PKG_CONFIG} --libs libcrypto)
982782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
983eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/dumpRSAPublicKey: LDLIBS += ${CRYPTO_LIBS}
984eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/pad_digest_utility: LDLIBS += ${CRYPTO_LIBS}
985eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/signature_digest_utility: LDLIBS += ${CRYPTO_LIBS}
986eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
987eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/host/linktest/main: LDLIBS += ${CRYPTO_LIBS}
9887141d73c149ee203a192f0cb45ca9bfa10c0ff8cRandall Spangler${BUILD}/tests/vb2_common2_tests: LDLIBS += ${CRYPTO_LIBS}
9897141d73c149ee203a192f0cb45ca9bfa10c0ff8cRandall Spangler${BUILD}/tests/vb2_common3_tests: LDLIBS += ${CRYPTO_LIBS}
990eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/vboot_common2_tests: LDLIBS += ${CRYPTO_LIBS}
991eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/vboot_common3_tests: LDLIBS += ${CRYPTO_LIBS}
992eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
99318e03706df6ab4256a89f4e578ecf0f165641c8aBill Richardson${BUILD}/tests/cgptlib_test: OBJS += \
99418e03706df6ab4256a89f4e578ecf0f165641c8aBill Richardson	${BUILD}/firmware/lib/cgptlib/mtdlib_unused.o
99518e03706df6ab4256a89f4e578ecf0f165641c8aBill Richardson${BUILD}/tests/cgptlib_test: ${BUILD}/firmware/lib/cgptlib/mtdlib_unused.o
99618e03706df6ab4256a89f4e578ecf0f165641c8aBill Richardson
997eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_utility: LD = ${CXX}
998eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_utility: LDLIBS = -llzma -lyaml
999eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1000eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonBMPBLK_UTILITY_DEPS = \
1001eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/utility/bmpblk_util.o \
1002eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/utility/image_types.o \
1003eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/utility/eficompress_for_lib.o \
1004eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/utility/efidecompress_for_lib.o
10051912bbae89b82c10819b01d039e140e39c668fc7Bill Richardson
1006eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_utility: OBJS = ${BMPBLK_UTILITY_DEPS}
1007eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_utility: ${BMPBLK_UTILITY_DEPS}
10081912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BMPBLK_UTILITY_DEPS}
1009eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1010eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_font: OBJS += ${BUILD}/utility/image_types.o
1011eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_font: ${BUILD}/utility/image_types.o
10121912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BUILD}/utility/image_types.o
1013eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1014eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Allow multiple definitions, so tests can mock functions from other libraries
1015eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/%: CFLAGS += -Xlinker --allow-multiple-definition
1016eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/%: LDLIBS += -lrt -luuid
1017eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/%: LIBS += ${TESTLIB}
10185d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
10195d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler${BUILD}/tests/rollback_index2_tests: OBJS += \
102017f8d341099120da78a6ca71165834eefb0960edRandall Spangler	${BUILD}/firmware/lib/rollback_index_for_test.o
1021eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/rollback_index2_tests: \
1022eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/firmware/lib/rollback_index_for_test.o
10231912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BUILD}/firmware/lib/rollback_index_for_test.o
10245d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1025c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler${BUILD}/tests/tlcl_tests: OBJS += \
1026c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler	${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
1027c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler${BUILD}/tests/tlcl_tests: \
1028c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler	${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
10291912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
1030c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler
10315d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler${BUILD}/tests/vboot_audio_tests: OBJS += \
103217f8d341099120da78a6ca71165834eefb0960edRandall Spangler	${BUILD}/firmware/lib/vboot_audio_for_test.o
1033eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/vboot_audio_tests: \
1034eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/firmware/lib/vboot_audio_for_test.o
10351912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BUILD}/firmware/lib/vboot_audio_for_test.o
10365d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1037acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/tests/rollback_index_test: INCLUDES += -I/usr/include
1038acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/tests/rollback_index_test: LIBS += -ltlcl
10395d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1040339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonTLCL_TEST_BINS = $(addprefix ${BUILD}/,${TLCL_TEST_NAMES})
1041eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${TLCL_TEST_BINS}: OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o
1042eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${TLCL_TEST_BINS}: ${BUILD}/tests/tpm_lite/tlcl_tests.o
10431912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o
10445d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1045eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson##############################################################################
1046eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Targets that exist just to run tests
10475d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
10485d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Frequently-run tests
1049eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: test_targets
1050786acdabcc15f023330d7c628aca9679e757a238Randall Spanglertest_targets:: runcgpttests runmisctests $(if ${VBOOT2},run2tests)
1051844bce57471153664c78993dab453e87891bb969Randall Spangler
1052eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${MINIMAL},)
1053844bce57471153664c78993dab453e87891bb969Randall Spangler# Bitmap utility isn't compiled for minimal variant
1054feb2518166b1cd181e607c611cbb610f0c7300daBill Richardsontest_targets:: runbmptests runfutiltests
1055844bce57471153664c78993dab453e87891bb969Randall Spangler# Scripts don't work under qemu testing
1056844bce57471153664c78993dab453e87891bb969Randall Spangler# TODO: convert scripts to makefile so they can be called directly
1057eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontest_targets:: runtestscripts
1058844bce57471153664c78993dab453e87891bb969Randall Spanglerendif
1059844bce57471153664c78993dab453e87891bb969Randall Spangler
1060eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: test_setup
10613e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardsontest_setup:: cgpt utils futil tests install_for_test
1062eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1063844bce57471153664c78993dab453e87891bb969Randall Spangler# Qemu setup for cross-compiled tests.  Need to copy qemu binary into the
1064844bce57471153664c78993dab453e87891bb969Randall Spangler# sysroot.
1065eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifneq (${QEMU_ARCH},)
1066eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontest_setup:: qemu_install
1067844bce57471153664c78993dab453e87891bb969Randall Spangler
1068844bce57471153664c78993dab453e87891bb969Randall Spangler.PHONY: qemu_install
1069844bce57471153664c78993dab453e87891bb969Randall Spanglerqemu_install:
1070eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${SYSROOT},)
1071eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	$(error SYSROOT must be set to the top of the target-specific root \
1072eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonwhen cross-compiling for qemu-based tests to run properly.)
1073eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
1074661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass	@$(PRINTF) "    Copying qemu binary.\n"
1075eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}cp -fu /usr/bin/${QEMU_BIN} ${BUILD}/${QEMU_BIN}
1076eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}chmod a+rx ${BUILD}/${QEMU_BIN}
1077844bce57471153664c78993dab453e87891bb969Randall Spanglerendif
1078844bce57471153664c78993dab453e87891bb969Randall Spangler
1079acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runtests
1080a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardsonruntests: test_setup test_targets
10815d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
10825d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Generate test keys
1083acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: genkeys
1084844bce57471153664c78993dab453e87891bb969Randall Spanglergenkeys: utils
10855d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/gen_test_keys.sh
10865d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
10875d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Generate test cases for fuzzing
1088acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: genfuzztestcases
1089a808dc944284e6eba39a8f19ddb46bc61c34de8aRandall Spanglergenfuzztestcases: utils
10905d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/gen_fuzz_test_cases.sh
10915d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1092acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runbmptests
1093eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonrunbmptests: test_setup
1094eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	cd tests/bitmaps && BMPBLK=${BUILD_RUN}/utility/bmpblk_utility \
10955d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler		./TestBmpBlock.py -v
10965d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1097acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runcgpttests
1098eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonruncgpttests: test_setup
1099eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/cgptlib_test
11005d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1101844bce57471153664c78993dab453e87891bb969Randall Spangler.PHONY: runtestscripts
1102eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonruntestscripts: test_setup genfuzztestcases
1103eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt
110442c08cb2dac102509491810361e239fbde52b9e0Albert Chaulk	tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt -N=512,32,1,3
11055d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/run_preamble_tests.sh
11065d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/run_rsa_tests.sh
1107844bce57471153664c78993dab453e87891bb969Randall Spangler	tests/run_vbutil_kernel_arg_tests.sh
11085d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/run_vbutil_tests.sh
1109e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spanglerifneq (${VBOOT2},)
1110e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	tests/vb2_rsa_tests.sh
1111539cbc27305b6aef9643adffc3297c7079fe7457Randall Spangler	tests/vb2_firmware_tests.sh
1112e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spanglerendif
11135d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1114844bce57471153664c78993dab453e87891bb969Randall Spangler.PHONY: runmisctests
1115eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonrunmisctests: test_setup
1116eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/rollback_index2_tests
1117a3eac79f5070747e326da631c1eec155f0389919Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/rollback_index3_tests
1118eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/rsa_utility_tests
1119eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/sha_tests
1120eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/stateful_util_tests
1121c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/tlcl_tests
1122eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/tpm_bootmode_tests
1123eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/utility_string_tests
1124eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/utility_tests
1125eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_devmode_tests
1126eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_firmware_tests
11270714d9de56da3a5c686b26755d15aa6788c727d4Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_init_tests
11280714d9de56da3a5c686b26755d15aa6788c727d4Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel_tests
11297f43669630cb42e40ca6ddc1128eefea8fd339d9Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel2_tests
11307f43669630cb42e40ca6ddc1128eefea8fd339d9Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel3_tests
11317f43669630cb42e40ca6ddc1128eefea8fd339d9Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel4_tests
1132eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/vboot_audio_tests
1133e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_common_tests
1134e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS}
1135e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS}
1136786a5dca74387de5ffdc51ca5a099a4e90f406daRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_display_tests
1137eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/vboot_firmware_tests
113849cb0d3471e768da11fe76b65769bd57dca38bd7Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_kernel_tests
11396dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_nvstorage_test
1140eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1141786acdabcc15f023330d7c628aca9679e757a238Randall Spangler.PHONY: run2tests
1142786acdabcc15f023330d7c628aca9679e757a238Randall Spanglerrun2tests: test_setup
1143a7ab8b50b8923afcfd7a9e6181892c4c8a2de250Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_api_tests
1144786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_common_tests
11457141d73c149ee203a192f0cb45ca9bfa10c0ff8cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_common2_tests ${TEST_KEYS}
11467141d73c149ee203a192f0cb45ca9bfa10c0ff8cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_common3_tests ${TEST_KEYS}
11473333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_misc_tests
11481803068173a625efd83d1cee8dd90843feb0d972Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_misc2_tests
11493333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_nvstorage_tests
1150e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_rsa_utility_tests
11513333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_secdata_tests
1152e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_sha_tests
1153786acdabcc15f023330d7c628aca9679e757a238Randall Spangler
1154eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: runfutiltests
11553e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardsonrunfutiltests: test_setup
11563e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardson	tests/futility/run_test_scripts.sh ${TEST_INSTALL_DIR}
1157339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/futility/test_not_really
1158844bce57471153664c78993dab453e87891bb969Randall Spangler
11595d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Run long tests, including all permutations of encryption keys (instead of
1160786a5dca74387de5ffdc51ca5a099a4e90f406daRandall Spangler# just the ones we use) and tests of currently-unused code.
11615d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Not run by automated build.
1162acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runlongtests
1163eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonrunlongtests: test_setup genkeys genfuzztestcases
1164e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS} --all
1165e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS} --all
11667141d73c149ee203a192f0cb45ca9bfa10c0ff8cRandall Spanglerifneq (${VBOOT2},)
11677141d73c149ee203a192f0cb45ca9bfa10c0ff8cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_common2_tests ${TEST_KEYS} --all
11687141d73c149ee203a192f0cb45ca9bfa10c0ff8cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_common3_tests ${TEST_KEYS} --all
11697141d73c149ee203a192f0cb45ca9bfa10c0ff8cRandall Spanglerendif
11705d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/run_preamble_tests.sh --all
11715d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/run_vbutil_tests.sh --all
11725d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
11735d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# TODO: tests to run when ported to new API
11745d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler#	./run_image_verification_tests.sh
11755d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler#	# Splicing tests
11765d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler#	${BUILD}/tests/firmware_splicing_tests
11775d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler#	${BUILD}/tests/kernel_splicing_tests
11785d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler#	# Rollback Tests
11795d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler#	${BUILD}/tests/firmware_rollback_tests
11805d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler#	${BUILD}/tests/kernel_rollback_tests
11815d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1182782990277ac7d6730db4c43c2b5632de93396921Bill Richardson.PHONY: runalltests
1183782990277ac7d6730db4c43c2b5632de93396921Bill Richardsonrunalltests: runtests runfutiltests runlongtests
1184782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
118559d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler# Code coverage
118659d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler.PHONY: coverage_init
118759d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage_init: test_setup
118859d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	rm -f ${COV_INFO}*
118959d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	lcov -c -i -d . -b . -o ${COV_INFO}.initial
119059d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler
119159d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler.PHONY: coverage_html
119259d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage_html:
119359d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	lcov -c -d . -b . -o ${COV_INFO}.tests
119459d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	lcov -a ${COV_INFO}.initial -a ${COV_INFO}.tests -o ${COV_INFO}.total
119559d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	lcov -r ${COV_INFO}.total '/usr/*' '*/linktest/*' -o ${COV_INFO}.local
119659d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	genhtml ${COV_INFO}.local -o ${BUILD}/coverage
1197d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardson# Generate addtional coverage stats just for firmware subdir, because the stats
1198d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardson# for the whole project don't include subdirectory summaries. This will print
1199d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardson# the summary for just the firmware sources.
120049cb0d3471e768da11fe76b65769bd57dca38bd7Randall Spangler	lcov -r ${COV_INFO}.local '*/stub/*' -o ${COV_INFO}.nostub
120149cb0d3471e768da11fe76b65769bd57dca38bd7Randall Spangler	lcov -e ${COV_INFO}.nostub '${SRCDIR}/firmware/*' \
120259d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler		-o ${COV_INFO}.firmware
120359d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler
120459d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler.PHONY: coverage
120559d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglerifeq (${COV},)
120659d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage:
120759d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	$(error Build coverage like this: make clean && COV=1 make)
120859d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglerelse
120959d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage: coverage_init runtests coverage_html
121059d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglerendif
12111912bbae89b82c10819b01d039e140e39c668fc7Bill Richardson
12121912bbae89b82c10819b01d039e140e39c668fc7Bill Richardson# Include generated dependencies
12131912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_DEPS += ${ALL_OBJS:%.o=%.o.d}
12141912bbae89b82c10819b01d039e140e39c668fc7Bill Richardson-include ${ALL_DEPS}
1215