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)
4064ddad77e58b9892c72f49977f479a585dce095cBill Richardsonexport SRCDIR
41c8c87b3264e02df2842e20866f717607a07c5ab4Mike FrysingerBUILD = ${SRCDIR}/build
42844bce57471153664c78993dab453e87891bb969Randall Spanglerexport BUILD
435d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
44c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# Stuff for 'make install'
45feb2518166b1cd181e607c611cbb610f0c7300daBill RichardsonINSTALL = install
46efa8756c5e7068e57f5e98f0e7f2f42fb8d969d6Bill RichardsonDESTDIR = /usr/local
4707d9043da43ddce10406f56a040fb5a240747282Nam T. NguyenLIBDIR ?= lib
48feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson
49cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson# Default values
50cfe83a827d40b310003fc6996b9978d8cf301444Bill RichardsonDEV_DEBUG_FORCE=
51cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson
52feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson# Where exactly do the pieces go?
536f3961507e73f90cec665896dece884e86be560aBill Richardson#  UB_DIR = utility binary directory
5407d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen#  ULP_DIR = pkgconfig directory, usually /usr/lib/pkgconfig
55cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson#  DF_DIR = utility defaults directory
566f3961507e73f90cec665896dece884e86be560aBill Richardson#  VB_DIR = vboot binary directory for dev-mode-only scripts
57c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonifeq (${MINIMAL},)
586f3961507e73f90cec665896dece884e86be560aBill Richardson# Host install just puts everything where it's told
59efa8756c5e7068e57f5e98f0e7f2f42fb8d969d6Bill RichardsonUB_DIR=${DESTDIR}/bin
6007d9043da43ddce10406f56a040fb5a240747282Nam T. NguyenULP_DIR=${DESTDIR}/${LIBDIR}/pkgconfig
61cfe83a827d40b310003fc6996b9978d8cf301444Bill RichardsonDF_DIR=${DESTDIR}/default
62efa8756c5e7068e57f5e98f0e7f2f42fb8d969d6Bill RichardsonVB_DIR=${DESTDIR}/bin
63c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonelse
64efa8756c5e7068e57f5e98f0e7f2f42fb8d969d6Bill Richardson# Target install puts things into different places
656f3961507e73f90cec665896dece884e86be560aBill RichardsonUB_DIR=${DESTDIR}/usr/bin
6607d9043da43ddce10406f56a040fb5a240747282Nam T. NguyenULP_DIR=${DESTDIR}/usr/${LIBDIR}/pkgconfig
67cfe83a827d40b310003fc6996b9978d8cf301444Bill RichardsonDF_DIR=${DESTDIR}/etc/default
68c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill RichardsonVB_DIR=${DESTDIR}/usr/share/vboot/bin
69c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonendif
706d696e532c6a0c93ad9b915c59dad4144e6f1b33Simon Glass
71eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Where to install the (exportable) executables for testing?
72eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTEST_INSTALL_DIR = ${BUILD}/install_for_test
73eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
74eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Verbose? Use V=1
75eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${V},)
76eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonQ := @
77eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
78eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
79661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass# Quiet? Use QUIET=1
80c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysingerifeq (${QUIET},)
81661ae9e9cbaad430b87b443712d2608f9ce59883Simon GlassPRINTF := printf
82661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glasselse
83661ae9e9cbaad430b87b443712d2608f9ce59883Simon GlassPRINTF := :
84661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glassendif
85661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass
8661a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# Architecture detection
8761a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler_machname := $(shell uname -m)
8861a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall SpanglerHOST_ARCH ?= ${_machname}
8961a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler
9061a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# ARCH and/or FIRMWARE_ARCH are defined by the Chromium OS ebuild.
9161a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# Pick a sane target architecture if none is defined.
9261a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerifeq (${ARCH},)
9361a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler  ARCH := ${HOST_ARCH}
9461a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${ARCH},i386)
9561a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler  override ARCH := x86
9661a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${ARCH},amd64)
9761a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler  override ARCH := x86_64
9861a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerendif
9961a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler
10061a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# FIRMWARE_ARCH is only defined by the Chromium OS ebuild if compiling
10161a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# for a firmware target (such as u-boot or depthcharge). It must map
10261a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# to the same consistent set of architectures as the host.
10361a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerifeq (${FIRMWARE_ARCH},i386)
10461a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler  override FIRMWARE_ARCH := x86
10561a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${FIRMWARE_ARCH},amd64)
10661a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler  override FIRMWARE_ARCH := x86_64
107d96b25d0c0a739d351b8f09b128782ca12b7b0e1Stefan Reinauerelse ifeq (${FIRMWARE_ARCH},armv7)
108d96b25d0c0a739d351b8f09b128782ca12b7b0e1Stefan Reinauer  override FIRMWARE_ARCH := arm
10961a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerendif
11061a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler
111b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# Provide default CC and CFLAGS for firmware builds; if you have any -D flags,
112b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# please add them after this point (e.g., -DVBOOT_DEBUG).
11374359b755c4a203df0fe3bf51fc53d5de87d1fbfChe-Liang Chiou#
1146b0003c6381a7e69818b0b34b358c2cfb1393043Che-Liang Chiou# TODO(crosbug.com/16808) We hard-code u-boot's compiler flags here just
1156b0003c6381a7e69818b0b34b358c2cfb1393043Che-Liang Chiou# temporarily. As we are still investigating which flags are necessary for
1166b0003c6381a7e69818b0b34b358c2cfb1393043Che-Liang Chiou# maintaining a compatible ABI, etc. between u-boot and vboot_reference.
11774359b755c4a203df0fe3bf51fc53d5de87d1fbfChe-Liang Chiou#
118b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# As a first step, this makes the setting of CC and CFLAGS here optional, to
119b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# permit a calling script or Makefile to set these.
12074359b755c4a203df0fe3bf51fc53d5de87d1fbfChe-Liang Chiou#
121b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# Flag ordering: arch, then -f, then -m, then -W
122b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassDEBUG_FLAGS := $(if ${DEBUG},-g -O0,-Os)
123b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCOMMON_FLAGS := -nostdinc -pipe \
124b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass	-ffreestanding -fno-builtin -fno-stack-protector \
125eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	-Werror -Wall -Wstrict-prototypes ${DEBUG_FLAGS}
126b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass
127eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Note: FIRMWARE_ARCH is defined by the Chromium OS ebuild.
128eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH}, arm)
129b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCC ?= armv7a-cros-linux-gnueabi-gcc
130b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCFLAGS ?= -march=armv5 \
131b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass	-fno-common -ffixed-r8 \
132d50b27d15de8cc9e37410fc52d3184f17e0db5bbDoug Anderson	-mfloat-abi=hard -marm -mabi=aapcs-linux -mno-thumb-interwork \
133eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${COMMON_FLAGS}
13461a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${FIRMWARE_ARCH}, x86)
135b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCC ?= i686-pc-linux-gnu-gcc
136b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# Drop -march=i386 to permit use of SSE instructions
137b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCFLAGS ?= \
138b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass	-ffunction-sections -fvisibility=hidden -fno-strict-aliasing \
139b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass	-fomit-frame-pointer -fno-toplevel-reorder -fno-dwarf2-cfi-asm \
14046e00e63805f85c05449ce09cd843a18b76ca665Gabe Black	-mpreferred-stack-boundary=2 \
141eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${COMMON_FLAGS}
142eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonelse ifeq (${FIRMWARE_ARCH}, x86_64)
143eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCFLAGS ?= ${COMMON_FLAGS} \
1448e85e987739281161ece1dbc9ff2b73f3e8e1e35Simon Glass	-fvisibility=hidden -fno-strict-aliasing -fomit-frame-pointer
145844bce57471153664c78993dab453e87891bb969Randall Spanglerelse
146eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# FIRMWARE_ARCH not defined; assuming local compile.
147eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCC ?= gcc
148d462101f06e1bf817295a6cdd2b82e7e87eaeef3Bill RichardsonCFLAGS += -DCHROMEOS_ENVIRONMENT -Wall -Werror ${DEBUG_FLAGS}
1498e85e987739281161ece1dbc9ff2b73f3e8e1e35Simon Glassendif
15034be8273e0fb80a6654deab650e581b0dc9046a4Che-Liang Chiou
151eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifneq (${DEBUG},)
152eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCFLAGS += -DVBOOT_DEBUG
153eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
154844bce57471153664c78993dab453e87891bb969Randall Spangler
155eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${DISABLE_NDEBUG},)
156eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCFLAGS += -DNDEBUG
157eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
158eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
159feb2518166b1cd181e607c611cbb610f0c7300daBill Richardsonifneq (${FORCE_LOGGING_ON},)
160feb2518166b1cd181e607c611cbb610f0c7300daBill RichardsonCFLAGS += -DFORCE_LOGGING_ON=${FORCE_LOGGING_ON}
161feb2518166b1cd181e607c611cbb610f0c7300daBill Richardsonendif
162feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson
1636014c048131f7c3d055e97c0aaa44494edc4f813Randall Spanglerifneq (${PD_SYNC},)
1646014c048131f7c3d055e97c0aaa44494edc4f813Randall SpanglerCFLAGS += -DPD_SYNC
1656014c048131f7c3d055e97c0aaa44494edc4f813Randall Spanglerendif
1666014c048131f7c3d055e97c0aaa44494edc4f813Randall Spangler
167f44ebbe36b2c1603437edc57b534244e89bfcd9cNam T. Nguyenifneq (${USE_MTD},)
168f44ebbe36b2c1603437edc57b534244e89bfcd9cNam T. NguyenCFLAGS += -DUSE_MTD
169f44ebbe36b2c1603437edc57b534244e89bfcd9cNam T. NguyenLDLIBS += -lmtdutils
170f44ebbe36b2c1603437edc57b534244e89bfcd9cNam T. Nguyenendif
171f44ebbe36b2c1603437edc57b534244e89bfcd9cNam T. Nguyen
17207d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen# NOTE: We don't use these files but they are useful for other packages to
17307d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen# query about required compiling/linking flags.
17407d9043da43ddce10406f56a040fb5a240747282Nam T. NguyenPC_IN_FILES = vboot_host.pc.in
17507d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen
176eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Create / use dependency files
177eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCFLAGS += -MMD -MF $@.d
178eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
179f8f807a5ef00e8d5360fc2c9093bd0b5da8c0507Bertrand SIMONNETifeq (${FIRMWARE_ARCH},)
180f8f807a5ef00e8d5360fc2c9093bd0b5da8c0507Bertrand SIMONNET# Creates position independent code for non firmware target.
181f8f807a5ef00e8d5360fc2c9093bd0b5da8c0507Bertrand SIMONNETCFLAGS += -fPIE
182f8f807a5ef00e8d5360fc2c9093bd0b5da8c0507Bertrand SIMONNETendif
183f8f807a5ef00e8d5360fc2c9093bd0b5da8c0507Bertrand SIMONNET
1840c3ba249abb1dc60f5ebabccf84ff13206440b83Bill Richardson# These are required to access large disks and files on 32-bit systems.
1850c3ba249abb1dc60f5ebabccf84ff13206440b83Bill RichardsonCFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
1860c3ba249abb1dc60f5ebabccf84ff13206440b83Bill Richardson
18759d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler# Code coverage
188eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifneq (${COV},)
189d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardson  COV_FLAGS = -O0 --coverage -DCOVERAGE
19059d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler  CFLAGS += ${COV_FLAGS}
19159d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler  LDFLAGS += ${COV_FLAGS}
19259d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler  COV_INFO = ${BUILD}/coverage.info
193eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
194eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
19505987b159acb9737707b9ef92b818ac434ef8c3dDavid Rileyifdef HAVE_MACOS
19605987b159acb9737707b9ef92b818ac434ef8c3dDavid Riley  CFLAGS += -DHAVE_MACOS -Wno-deprecated-declarations
19705987b159acb9737707b9ef92b818ac434ef8c3dDavid Rileyendif
19805987b159acb9737707b9ef92b818ac434ef8c3dDavid Riley
199eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# And a few more default utilities
200eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonLD = ${CC}
2016df3e33912baf2633ed27fce6fe166d87e2f04a8Bill RichardsonCXX ?= g++
202eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonPKG_CONFIG ?= pkg-config
203eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
2040b789c56fc5ff34309e935bab15f130a386a1140Mike Frysinger# Static?
2050b789c56fc5ff34309e935bab15f130a386a1140Mike Frysingerifneq (${STATIC},)
2060b789c56fc5ff34309e935bab15f130a386a1140Mike FrysingerLDFLAGS += -static
2070b789c56fc5ff34309e935bab15f130a386a1140Mike FrysingerPKG_CONFIG += --static
2080b789c56fc5ff34309e935bab15f130a386a1140Mike Frysingerendif
2090b789c56fc5ff34309e935bab15f130a386a1140Mike Frysinger
210844bce57471153664c78993dab453e87891bb969Randall Spangler# Determine QEMU architecture needed, if any
211eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${ARCH},${HOST_ARCH})
212844bce57471153664c78993dab453e87891bb969Randall Spangler  # Same architecture; no need for QEMU
213844bce57471153664c78993dab453e87891bb969Randall Spangler  QEMU_ARCH :=
21461a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${HOST_ARCH}-${ARCH},x86_64-x86)
215844bce57471153664c78993dab453e87891bb969Randall Spangler  # 64-bit host can run 32-bit targets directly
216844bce57471153664c78993dab453e87891bb969Randall Spangler  QEMU_ARCH :=
217844bce57471153664c78993dab453e87891bb969Randall Spanglerelse
218eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson  QEMU_ARCH := ${ARCH}
219844bce57471153664c78993dab453e87891bb969Randall Spanglerendif
220844bce57471153664c78993dab453e87891bb969Randall Spangler
221844bce57471153664c78993dab453e87891bb969Randall Spangler# The top of the chroot for qemu must be passed in via the SYSROOT environment
222844bce57471153664c78993dab453e87891bb969Randall Spangler# variable.  In the Chromium OS chroot, this is done automatically by the
223844bce57471153664c78993dab453e87891bb969Randall Spangler# ebuild.
224844bce57471153664c78993dab453e87891bb969Randall Spangler
225eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${QEMU_ARCH},)
226844bce57471153664c78993dab453e87891bb969Randall Spangler  # Path to build output for running tests is same as for building
227eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson  BUILD_RUN = ${BUILD}
228e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler  SRC_RUN = ${SRCDIR}
229844bce57471153664c78993dab453e87891bb969Randall Spanglerelse
230844bce57471153664c78993dab453e87891bb969Randall Spangler  $(info Using qemu for testing.)
231844bce57471153664c78993dab453e87891bb969Randall Spangler  # Path to build output for running tests is different in the chroot
232eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson  BUILD_RUN = $(subst ${SYSROOT},,${BUILD})
233e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler  SRC_RUN = $(subst ${SYSROOT},,${SRCDIR})
234844bce57471153664c78993dab453e87891bb969Randall Spangler
235eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson  QEMU_BIN = qemu-${QEMU_ARCH}
236e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler  QEMU_RUN = ${BUILD_RUN}/${QEMU_BIN}
237e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler  export QEMU_RUN
238287beaed7f8ceff679c57664d4da008c6234edfdRandall Spangler
239e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler  RUNTEST = tests/test_using_qemu.sh
240e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spanglerendif
2415d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
242e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spanglerexport BUILD_RUN
2435d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
244eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson##############################################################################
245eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Now we need to describe everything we might want or need to build
246b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass
247eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Everything wants these headers.
2485d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerINCLUDES += \
2495d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	-Ifirmware/include \
2505d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	-Ifirmware/lib/include \
2515d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	-Ifirmware/lib/cgptlib/include \
2525d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	-Ifirmware/lib/cryptolib/include \
253786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	-Ifirmware/lib/tpm_lite/include \
254786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	-Ifirmware/2lib/include
2550b8f35c6a56a0e645254dd7f07ca68e01c8ee629Bill Richardson
256eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# If we're not building for a specific target, just stub out things like the
257eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM commands and various external functions that are provided by the BIOS.
258eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH},)
2590e6ae29eec7a58eeeeba67356c3a3ee384ba6687Bill RichardsonINCLUDES += -Ihost/include -Ihost/lib/include
2605d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif
2615d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
262782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# Firmware library, used by the other firmware components (depthcharge,
263782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# coreboot, etc.). It doesn't need exporting to some other place; they'll build
264782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# this source tree locally and link to it directly.
265eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonFWLIB = ${BUILD}/vboot_fw.a
2665d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
26706eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson# Smaller firmware library common to all vboot 2.x, used only for
26806eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson# 1) compile-time tests of the public API or
26906eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson# 2) linking with an actual 2.0 or 2.1 implementation
2706f1b82ac14f341d9733d6e95d518b3ee352002efRandall SpanglerFWLIB2X = ${BUILD}/vboot_fw2x.a
27106eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson
27206eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson# Vboot 2.0 (deprecated - see firmware/README)
27306eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill RichardsonFWLIB20 = ${BUILD}/vboot_fw20.a
27406eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson# Vboot 2.1 (not yet ready - see firmware/README)
275a5b69b02e039d7267390fea10266d45e14630559Randall SpanglerFWLIB21 = ${BUILD}/vboot_fw21.a
276786acdabcc15f023330d7c628aca9679e757a238Randall Spangler
27793943266c597ad66300445a04afa01270f2b5763Randall Spangler# Firmware library sources needed by VbInit() call
27893943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBINIT_SRCS = \
2795d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/crc8.c \
28093943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/lib/utility.c \
28193943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/lib/vboot_api_init.c \
28293943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/lib/vboot_common_init.c \
28393943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/lib/vboot_nvstorage.c \
284782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/lib/vboot_nvstorage_rollback.c \
285527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass	firmware/lib/region-init.c \
28693943266c597ad66300445a04afa01270f2b5763Randall Spangler
28793943266c597ad66300445a04afa01270f2b5763Randall Spangler# Additional firmware library sources needed by VbSelectFirmware() call
28893943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_SRCS = \
2895d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cryptolib/padding.c \
2905d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cryptolib/rsa.c \
2915d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cryptolib/rsa_utility.c \
2925d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cryptolib/sha1.c \
2935d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cryptolib/sha256.c \
2945d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cryptolib/sha512.c \
2955d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/cryptolib/sha_utility.c \
2965d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/stateful_util.c \
2975d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/vboot_api_firmware.c \
29893943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/lib/vboot_common.c \
299527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass	firmware/lib/vboot_firmware.c \
300527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass	firmware/lib/region-fw.c \
30193943266c597ad66300445a04afa01270f2b5763Randall Spangler
30293943266c597ad66300445a04afa01270f2b5763Randall Spangler# Additional firmware library sources needed by VbSelectAndLoadKernel() call
30393943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSLK_SRCS = \
30493943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/lib/cgptlib/cgptlib.c \
30593943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/lib/cgptlib/cgptlib_internal.c \
30693943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/lib/cgptlib/crc32.c \
3077c2beb08380410ca6847abdac23e11ded2d1b625Dan Ehrenberg	firmware/lib/gpt_misc.c \
30893943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/lib/utility_string.c \
3095d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/vboot_api_kernel.c \
3105d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/vboot_audio.c \
3115d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/vboot_display.c \
312527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass	firmware/lib/vboot_kernel.c \
313527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass	firmware/lib/region-kernel.c \
3145d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
31506eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson# Code common to both vboot 2.0 (old structs) and 2.1 (new structs)
31606eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill RichardsonFWLIB2X_SRCS = \
317a7ab8b50b8923afcfd7a9e6181892c4c8a2de250Randall Spangler	firmware/2lib/2api.c \
318786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	firmware/2lib/2common.c \
3193333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	firmware/2lib/2crc8.c \
3203333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	firmware/2lib/2misc.c \
3213333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	firmware/2lib/2nvstorage.c \
322e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	firmware/2lib/2rsa.c \
3233333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	firmware/2lib/2secdata.c \
324e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	firmware/2lib/2sha1.c \
325e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	firmware/2lib/2sha256.c \
326e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	firmware/2lib/2sha512.c \
32762d482ecddf5735076a085859cf40fcfa24671eeDaisuke Nojiri	firmware/2lib/2sha_utility.c \
32862d482ecddf5735076a085859cf40fcfa24671eeDaisuke Nojiri	firmware/2lib/2tpm_bootmode.c
329a5b69b02e039d7267390fea10266d45e14630559Randall Spangler
330108d991c678f80c99967bd07035de7418c81a072Randall SpanglerFWLIB20_SRCS = \
3316f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	firmware/lib20/api.c \
3326f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	firmware/lib20/common.c \
3336f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	firmware/lib20/misc.c \
3346f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	firmware/lib20/packed_key.c
335108d991c678f80c99967bd07035de7418c81a072Randall Spangler
336a5b69b02e039d7267390fea10266d45e14630559Randall SpanglerFWLIB21_SRCS = \
337a5b69b02e039d7267390fea10266d45e14630559Randall Spangler	firmware/lib21/api.c \
338a5b69b02e039d7267390fea10266d45e14630559Randall Spangler	firmware/lib21/common.c \
339a5b69b02e039d7267390fea10266d45e14630559Randall Spangler	firmware/lib21/misc.c \
340a5b69b02e039d7267390fea10266d45e14630559Randall Spangler	firmware/lib21/packed_key.c
341786acdabcc15f023330d7c628aca9679e757a238Randall Spangler
342eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Support real TPM unless BIOS sets MOCK_TPM
343eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${MOCK_TPM},)
34493943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBINIT_SRCS += \
3455d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/rollback_index.c \
3465d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/tpm_lite/tlcl.c
34793943266c597ad66300445a04afa01270f2b5763Randall Spangler
34893943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_SRCS += \
34993943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/lib/tpm_bootmode.c
3505d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerelse
35193943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBINIT_SRCS += \
3525d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/mocked_rollback_index.c \
3535d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/lib/tpm_lite/mocked_tlcl.c
35493943266c597ad66300445a04afa01270f2b5763Randall Spangler
35593943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_SRCS += \
35693943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/lib/mocked_tpm_bootmode.c
3575d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif
3585d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
359eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH},)
360eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Include BIOS stubs in the firmware library when compiling for host
36193943266c597ad66300445a04afa01270f2b5763Randall Spangler# TODO: split out other stub funcs too
36293943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBINIT_SRCS += \
3635d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/stub/tpm_lite_stub.c \
3645d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/stub/utility_stub.c \
365527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass	firmware/stub/vboot_api_stub_init.c \
366527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass	firmware/stub/vboot_api_stub_region.c
36793943266c597ad66300445a04afa01270f2b5763Randall Spangler
36893943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_SRCS += \
36993943266c597ad66300445a04afa01270f2b5763Randall Spangler	firmware/stub/vboot_api_stub_sf.c
37093943266c597ad66300445a04afa01270f2b5763Randall Spangler
37193943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSLK_SRCS += \
3725d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	firmware/stub/vboot_api_stub.c \
3735dc75d16b6d5cb0ebc677e6572a2559c6157b8e4Dan Ehrenberg	firmware/stub/vboot_api_stub_disk.c \
3745dc75d16b6d5cb0ebc677e6572a2559c6157b8e4Dan Ehrenberg	firmware/stub/vboot_api_stub_stream.c
375da2b49cf08a27551fd910626f669910a636378d4Randall Spangler
37606eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill RichardsonFWLIB2X_SRCS += \
377da2b49cf08a27551fd910626f669910a636378d4Randall Spangler	firmware/2lib/2stub.c
378da2b49cf08a27551fd910626f669910a636378d4Randall Spangler
3795d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif
3805d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
38193943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_SRCS += ${VBINIT_SRCS}
38293943266c597ad66300445a04afa01270f2b5763Randall SpanglerFWLIB_SRCS += ${VBSF_SRCS} ${VBSLK_SRCS}
38393943266c597ad66300445a04afa01270f2b5763Randall Spangler
38493943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBINIT_OBJS = ${VBINIT_SRCS:%.c=${BUILD}/%.o}
38593943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_OBJS = ${VBSF_SRCS:%.c=${BUILD}/%.o}
386a5b69b02e039d7267390fea10266d45e14630559Randall SpanglerALL_OBJS +=  ${VBINIT_OBJS} ${VBSF_OBJS}
38793943266c597ad66300445a04afa01270f2b5763Randall Spangler
388eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonFWLIB_OBJS = ${FWLIB_SRCS:%.c=${BUILD}/%.o}
38906eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill RichardsonFWLIB2X_OBJS = ${FWLIB2X_SRCS:%.c=${BUILD}/%.o}
390aaaff86467823e0d3d29c383402275eeae481256Randall SpanglerFWLIB20_OBJS = ${FWLIB20_SRCS:%.c=${BUILD}/%.o}
391a5b69b02e039d7267390fea10266d45e14630559Randall SpanglerFWLIB21_OBJS = ${FWLIB21_SRCS:%.c=${BUILD}/%.o}
39206eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill RichardsonALL_OBJS += ${FWLIB_OBJS} ${FWLIB2X_OBJS} ${FWLIB20_OBJS} ${FWLIB21_OBJS}
3935d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
394782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# Intermediate library for the vboot_reference utilities to link against.
395782990277ac7d6730db4c43c2b5632de93396921Bill RichardsonUTILLIB = ${BUILD}/libvboot_util.a
396108d991c678f80c99967bd07035de7418c81a072Randall SpanglerUTILLIB21 = ${BUILD}/libvboot_util21.a
3975d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
398782990277ac7d6730db4c43c2b5632de93396921Bill RichardsonUTILLIB_SRCS = \
39981a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	cgpt/cgpt_create.c \
40081a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	cgpt/cgpt_add.c \
40181a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	cgpt/cgpt_boot.c \
40281a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	cgpt/cgpt_show.c \
40381a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	cgpt/cgpt_repair.c \
40481a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	cgpt/cgpt_prioritize.c \
40581a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	cgpt/cgpt_common.c \
4066f3961507e73f90cec665896dece884e86be560aBill Richardson	futility/dump_kernel_config_lib.c \
407eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	host/arch/${ARCH}/lib/crossystem_arch.c \
4085d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/crossystem.c \
4095d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/file_keys.c \
4105d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/fmap.c \
4115d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/host_common.c \
4125d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/host_key.c \
4135d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/host_keyblock.c \
4145d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/host_misc.c \
415782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	host/lib/util_misc.c \
4165d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	host/lib/host_signature.c \
4176f3961507e73f90cec665896dece884e86be560aBill Richardson	host/lib/signature_digest.c
4185d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
419aaaff86467823e0d3d29c383402275eeae481256Randall SpanglerUTILLIB_OBJS = ${UTILLIB_SRCS:%.c=${BUILD}/%.o}
420aaaff86467823e0d3d29c383402275eeae481256Randall SpanglerALL_OBJS += ${UTILLIB_OBJS}
421aaaff86467823e0d3d29c383402275eeae481256Randall Spangler
422a5b69b02e039d7267390fea10266d45e14630559Randall SpanglerUTILLIB21_SRCS += \
423a5b69b02e039d7267390fea10266d45e14630559Randall Spangler	host/lib21/host_fw_preamble.c \
424a5b69b02e039d7267390fea10266d45e14630559Randall Spangler	host/lib21/host_key.c \
425a5b69b02e039d7267390fea10266d45e14630559Randall Spangler	host/lib21/host_keyblock.c \
426a5b69b02e039d7267390fea10266d45e14630559Randall Spangler	host/lib21/host_misc.c \
427a5b69b02e039d7267390fea10266d45e14630559Randall Spangler	host/lib21/host_signature.c
42802e11b323b819140590d99b6af440d36c12d161bRandall Spangler
429a5b69b02e039d7267390fea10266d45e14630559Randall SpanglerUTILLIB21_OBJS = ${UTILLIB21_SRCS:%.c=${BUILD}/%.o}
430a5b69b02e039d7267390fea10266d45e14630559Randall SpanglerALL_OBJS += ${UTILLIB21_OBJS}
431782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
432782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# Externally exported library for some target userspace apps to link with
433782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# (cryptohome, updater, etc.)
434782990277ac7d6730db4c43c2b5632de93396921Bill RichardsonHOSTLIB = ${BUILD}/libvboot_host.a
435782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
436782990277ac7d6730db4c43c2b5632de93396921Bill RichardsonHOSTLIB_SRCS = \
437782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	cgpt/cgpt_add.c \
438782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	cgpt/cgpt_boot.c \
439782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	cgpt/cgpt_common.c \
440782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	cgpt/cgpt_create.c \
441782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	cgpt/cgpt_prioritize.c \
442782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/lib/cgptlib/cgptlib_internal.c \
443782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/lib/cgptlib/crc32.c \
444782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/lib/crc8.c \
44532a999d2c0e5bf8a1c0f6141d3db77a1dcc6f5afDan Ehrenberg	firmware/lib/gpt_misc.c \
446782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/lib/tpm_lite/tlcl.c \
447782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/lib/utility_string.c \
448782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/lib/vboot_nvstorage.c \
449782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/stub/tpm_lite_stub.c \
450782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/stub/utility_stub.c \
45132a999d2c0e5bf8a1c0f6141d3db77a1dcc6f5afDan Ehrenberg	firmware/stub/vboot_api_stub_disk.c \
452782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/stub/vboot_api_stub_init.c \
45332a999d2c0e5bf8a1c0f6141d3db77a1dcc6f5afDan Ehrenberg	firmware/stub/vboot_api_stub_sf.c \
4546f3961507e73f90cec665896dece884e86be560aBill Richardson	futility/dump_kernel_config_lib.c \
455782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	host/arch/${ARCH}/lib/crossystem_arch.c \
456782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	host/lib/crossystem.c \
457317bb498a697ae49f070e3ca46100b879f25aa1bZach Reizner	host/lib/extract_vmlinuz.c \
4586ee52d9a929d00e871e7316240b54f381146fbc6Nam T. Nguyen	host/lib/fmap.c \
4596f3961507e73f90cec665896dece884e86be560aBill Richardson	host/lib/host_misc.c
460782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
461eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonHOSTLIB_OBJS = ${HOSTLIB_SRCS:%.c=${BUILD}/%.o}
4625d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerALL_OBJS += ${HOSTLIB_OBJS}
4635d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
46481a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson# Sigh. For historical reasons, the autoupdate installer must sometimes be a
46581a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson# 32-bit executable, even when everything else is 64-bit. But it only needs a
46681a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson# few functions, so let's just build those.
46781a0b3de707b4e00958faf36f41b8f3d7bac6808Bill RichardsonTINYHOSTLIB = ${BUILD}/libtinyvboot_host.a
46881a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson
46981a0b3de707b4e00958faf36f41b8f3d7bac6808Bill RichardsonTINYHOSTLIB_SRCS = \
47081a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	cgpt/cgpt_add.c \
47181a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	cgpt/cgpt_boot.c \
47281a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	cgpt/cgpt_common.c \
473782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	cgpt/cgpt_create.c \
474782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	cgpt/cgpt_prioritize.c \
475782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/lib/cgptlib/cgptlib_internal.c \
476782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/lib/cgptlib/crc32.c \
47732a999d2c0e5bf8a1c0f6141d3db77a1dcc6f5afDan Ehrenberg	firmware/lib/gpt_misc.c \
4785fed2a667096341160db8643a4a057e328953a1dBill Richardson	firmware/lib/utility_string.c \
47932a999d2c0e5bf8a1c0f6141d3db77a1dcc6f5afDan Ehrenberg	firmware/stub/vboot_api_stub_disk.c \
48032a999d2c0e5bf8a1c0f6141d3db77a1dcc6f5afDan Ehrenberg	firmware/stub/vboot_api_stub_sf.c \
481782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	firmware/stub/utility_stub.c \
482317bb498a697ae49f070e3ca46100b879f25aa1bZach Reizner	futility/dump_kernel_config_lib.c \
483317bb498a697ae49f070e3ca46100b879f25aa1bZach Reizner	host/lib/extract_vmlinuz.c
48481a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson
48581a0b3de707b4e00958faf36f41b8f3d7bac6808Bill RichardsonTINYHOSTLIB_OBJS = ${TINYHOSTLIB_SRCS:%.c=${BUILD}/%.o}
486eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
487eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
488eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Now for the userspace binaries
4895d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
4905d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCGPT = ${BUILD}/cgpt/cgpt
4915d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
4925d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCGPT_SRCS = \
4935d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt.c \
4945d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_add.c \
4955d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_boot.c \
4965d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_common.c \
4975d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_create.c \
4985d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_find.c \
4995d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_legacy.c \
500d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen	cgpt/cgpt_nor.c \
5015d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_prioritize.c \
5025d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_repair.c \
5035d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cgpt_show.c \
5045d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cmd_add.c \
5055d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cmd_boot.c \
5065d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cmd_create.c \
5075d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cmd_find.c \
5085d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cmd_legacy.c \
5095d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cmd_prioritize.c \
5105d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	cgpt/cmd_repair.c \
5118577b5360ca4c9514d9091ed9aded2bb3193f1f0Nam T. Nguyen	cgpt/cmd_show.c
5125d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
513eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCGPT_OBJS = ${CGPT_SRCS:%.c=${BUILD}/%.o}
514d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen
5155d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerALL_OBJS += ${CGPT_OBJS}
5165d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
517d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. NguyenCGPT_WRAPPER = ${BUILD}/cgpt/cgpt_wrapper
518d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen
519d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. NguyenCGPT_WRAPPER_SRCS = \
520d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen	cgpt/cgpt_nor.c \
521d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen	cgpt/cgpt_wrapper.c
522d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen
523d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. NguyenCGPT_WRAPPER_OBJS = ${CGPT_WRAPPER_SRCS:%.c=${BUILD}/%.o}
524d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen
525d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. NguyenALL_OBJS += ${CGPT_WRAPPER_OBJS}
526d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen
527cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson# Utility defaults
528cfe83a827d40b310003fc6996b9978d8cf301444Bill RichardsonUTIL_DEFAULTS = ${BUILD}/default/vboot_reference
5295d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
530eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Scripts to install directly (not compiled)
5315d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerUTIL_SCRIPTS = \
5325d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	utility/dev_debug_vboot \
5334d49d34c4ba5aa64ca7aeb26c77e170b2cf2462fBill Richardson	utility/enable_dev_usb_boot
5345d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
535c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonifeq (${MINIMAL},)
536c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill RichardsonUTIL_SCRIPTS += \
5374d49d34c4ba5aa64ca7aeb26c77e170b2cf2462fBill Richardson	utility/dev_make_keypair \
5384d49d34c4ba5aa64ca7aeb26c77e170b2cf2462fBill Richardson	utility/vbutil_what_keys
539c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonendif
540c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson
541eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# These utilities should be linked statically.
542eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonUTIL_NAMES_STATIC = \
5436f3961507e73f90cec665896dece884e86be560aBill Richardson	utility/crossystem
544eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
545eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonUTIL_NAMES = ${UTIL_NAMES_STATIC} \
546339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	utility/tpm_init_temp_fix \
5470f07867e6fe186ea460afd557e830c1e49f1ff85Duncan Laurie	utility/dumpRSAPublicKey \
5486f3961507e73f90cec665896dece884e86be560aBill Richardson	utility/tpmc
5495d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
5506f3961507e73f90cec665896dece884e86be560aBill Richardson# TODO: Do we still need eficompress and efidecompress for anything?
551eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${MINIMAL},)
5525d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerUTIL_NAMES += \
553339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	utility/bmpblk_font \
554339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	utility/bmpblk_utility \
555339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	utility/eficompress \
556339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	utility/efidecompress \
557339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	utility/load_kernel_test \
558339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	utility/pad_digest_utility \
559339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	utility/signature_digest_utility \
560339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	utility/verify_data
5615d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif
5625d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
563339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonUTIL_BINS_STATIC := $(addprefix ${BUILD}/,${UTIL_NAMES_STATIC})
564339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonUTIL_BINS = $(addprefix ${BUILD}/,${UTIL_NAMES})
5651912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += $(addsuffix .o,${UTIL_BINS} ${UTIL_BINS_STATIC})
5665d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
567c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson
568c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# Scripts for signing stuff.
569c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill RichardsonSIGNING_SCRIPTS = \
570c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	utility/tpm-nvsize \
571c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	utility/chromeos-tpm-recovery
572c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson
573c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# These go in a different place.
574c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill RichardsonSIGNING_SCRIPTS_DEV = \
575c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	scripts/image_signing/resign_firmwarefd.sh \
576c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	scripts/image_signing/make_dev_firmware.sh \
577c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	scripts/image_signing/make_dev_ssd.sh \
578c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	scripts/image_signing/set_gbb_flags.sh
579c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson
580c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# Installed, but not made executable.
581c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill RichardsonSIGNING_COMMON = scripts/image_signing/common_minimal.sh
582eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
583eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
584eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# The unified firmware utility will eventually replace all the others
585eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonFUTIL_BIN = ${BUILD}/futility/futility
5866db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson# But we still need both static (tiny) and dynamic (with openssl) versions.
5876db8c75021e2edfa400ae707a8544d041e3c415fBill RichardsonFUTIL_STATIC_BIN = ${FUTIL_BIN}_s
588eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
5896f3961507e73f90cec665896dece884e86be560aBill Richardson# These are the executables that are now built in to futility. We'll create
5906f3961507e73f90cec665896dece884e86be560aBill Richardson# symlinks for these so the old names will still work.
591a1d9fe6eecf82540d31d34bba988e4838d295302Bill RichardsonFUTIL_SYMLINKS = \
592e155044a7bbb9b8c6eb751af051726cfe1b411a4Bill Richardson	dump_fmap \
593e155044a7bbb9b8c6eb751af051726cfe1b411a4Bill Richardson	dump_kernel_config \
594e155044a7bbb9b8c6eb751af051726cfe1b411a4Bill Richardson	gbb_utility \
595e155044a7bbb9b8c6eb751af051726cfe1b411a4Bill Richardson	vbutil_firmware \
596e155044a7bbb9b8c6eb751af051726cfe1b411a4Bill Richardson	vbutil_kernel \
597e155044a7bbb9b8c6eb751af051726cfe1b411a4Bill Richardson	vbutil_key \
5986f3961507e73f90cec665896dece884e86be560aBill Richardson	vbutil_keyblock
599feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson
6006db8c75021e2edfa400ae707a8544d041e3c415fBill RichardsonFUTIL_STATIC_SRCS = \
601feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson	futility/futility.c \
60220807b6158b6a43baf0974bc763890888ba1f841Bill Richardson	futility/cmd_dump_fmap.c \
603cf6e78dbd54684ebba0c3bfc2524426f61193416Bill Richardson	futility/cmd_gbb_utility.c \
604cf6e78dbd54684ebba0c3bfc2524426f61193416Bill Richardson	futility/misc.c
605eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
6066db8c75021e2edfa400ae707a8544d041e3c415fBill RichardsonFUTIL_SRCS = \
607c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	${FUTIL_STATIC_SRCS} \
6084e4c19602edf3834b50d66d3ba067e895aca6fa0Bill Richardson	futility/cmd_create.c \
6096f3961507e73f90cec665896dece884e86be560aBill Richardson	futility/cmd_dump_kernel_config.c \
6102e25e813419f2cd437164929543e452b28b89260Bill Richardson	futility/cmd_load_fmap.c \
611f4f395e1ca724ef8795cfe86a9edbf15f14eacd1Bill Richardson	futility/cmd_pcr.c \
612f318ee205cc8d92def925c6158272da8a63bf1edBill Richardson	futility/cmd_show.c \
613f318ee205cc8d92def925c6158272da8a63bf1edBill Richardson	futility/cmd_sign.c \
6146f3961507e73f90cec665896dece884e86be560aBill Richardson	futility/cmd_vbutil_firmware.c \
6156f3961507e73f90cec665896dece884e86be560aBill Richardson	futility/cmd_vbutil_kernel.c \
616b84b81dc265a766a968bf126905447d442558218Bill Richardson	futility/cmd_vbutil_key.c \
617b8ff397674fb98c1d7eea864e7fa571369675131Randall Spangler	futility/cmd_vbutil_keyblock.c \
6182559338dbdacbcbd3ae426337403196135bbc7e8Bill Richardson	futility/file_type.c \
619f318ee205cc8d92def925c6158272da8a63bf1edBill Richardson	futility/traversal.c \
620f318ee205cc8d92def925c6158272da8a63bf1edBill Richardson	futility/vb1_helper.c
6216db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson
622e08ee28548934e933733babf0bc0c418142d095dAlex Deymo# List of commands built in futility and futility_s.
623e08ee28548934e933733babf0bc0c418142d095dAlex DeymoFUTIL_STATIC_CMD_LIST = ${BUILD}/gen/futility_static_cmds.c
624e08ee28548934e933733babf0bc0c418142d095dAlex DeymoFUTIL_CMD_LIST = ${BUILD}/gen/futility_cmds.c
625eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
62691852e7f58d50a031bcb5c02e68473cefb10ebb0Bill Richardson# Workaround for TODO(crbug.com/437107).
62791852e7f58d50a031bcb5c02e68473cefb10ebb0Bill RichardsonFUTIL_STATIC_WORKAROUND_SRCS = firmware/stub/vboot_api_stub_static_sf.c
62891852e7f58d50a031bcb5c02e68473cefb10ebb0Bill Richardson
629e08ee28548934e933733babf0bc0c418142d095dAlex DeymoFUTIL_STATIC_OBJS = ${FUTIL_STATIC_SRCS:%.c=${BUILD}/%.o} \
63091852e7f58d50a031bcb5c02e68473cefb10ebb0Bill Richardson	${FUTIL_STATIC_WORKAROUND_SRCS:%.c=${BUILD}/%.o} \
631e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${FUTIL_STATIC_CMD_LIST:%.c=%.o}
632e08ee28548934e933733babf0bc0c418142d095dAlex DeymoFUTIL_OBJS = ${FUTIL_SRCS:%.c=${BUILD}/%.o} ${FUTIL_CMD_LIST:%.c=%.o}
633eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
6344e4c19602edf3834b50d66d3ba067e895aca6fa0Bill Richardson${FUTIL_OBJS}: INCLUDES += -Ihost/lib21/include -Ifirmware/lib21/include
6354e4c19602edf3834b50d66d3ba067e895aca6fa0Bill Richardson${FUTIL_BIN}: ${UTILLIB21}
6364e4c19602edf3834b50d66d3ba067e895aca6fa0Bill Richardson${FUTIL_BIN}: LIBS += ${UTILLIB21}
6374e4c19602edf3834b50d66d3ba067e895aca6fa0Bill Richardson
638eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonALL_OBJS += ${FUTIL_OBJS}
639eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
640eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
641eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Library of handy test functions.
642eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTESTLIB = ${BUILD}/tests/test.a
643eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
644eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTESTLIB_SRCS = \
645eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tests/test_common.c \
646eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tests/timer_utils.c \
647eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tests/crc32_test.c
648eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
649eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTESTLIB_OBJS = ${TESTLIB_SRCS:%.c=${BUILD}/%.o}
65080872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${TESTLIB_OBJS}
651eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
652eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
653eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# And some compiled tests.
654eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTEST_NAMES = \
655339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/cgptlib_test \
656339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/rollback_index2_tests \
657339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/rollback_index3_tests \
658339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/rsa_padding_test \
659339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/rsa_utility_tests \
660339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/rsa_verify_benchmark \
661339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/sha_benchmark \
662339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/sha_tests \
663339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/stateful_util_tests \
664339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tlcl_tests \
665339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_bootmode_tests \
666339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/utility_string_tests \
667339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/utility_tests \
668339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_api_init_tests \
669339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_api_devmode_tests \
670339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_api_firmware_tests \
671339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_api_kernel_tests \
672339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_api_kernel2_tests \
673339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_api_kernel3_tests \
674339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_api_kernel4_tests \
675339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_audio_tests \
676339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_common_tests \
677339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_common2_tests \
678339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_common3_tests \
679339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_display_tests \
680339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_firmware_tests \
681339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_kernel_tests \
682339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_nvstorage_test \
683a77541f94f731f5f7755264e9b49b7826aa48dfeBill Richardson	tests/verify_kernel \
6846f3961507e73f90cec665896dece884e86be560aBill Richardson	tests/futility/binary_editor \
685339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/futility/test_not_really
686eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
687527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glassifdef REGION_READ
688527ba810eff4006cf69579f6b96cb4350cb1e189Simon GlassTEST_NAMES += tests/vboot_region_tests
689527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glassendif
690527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass
6916f1b82ac14f341d9733d6e95d518b3ee352002efRandall SpanglerTEST2X_NAMES = \
692a7ab8b50b8923afcfd7a9e6181892c4c8a2de250Randall Spangler	tests/vb2_api_tests \
693786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	tests/vb2_common_tests \
6943333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	tests/vb2_misc_tests \
6953333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	tests/vb2_nvstorage_tests \
696e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	tests/vb2_rsa_utility_tests \
6973333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	tests/vb2_secdata_tests \
698108d991c678f80c99967bd07035de7418c81a072Randall Spangler	tests/vb2_sha_tests
699108d991c678f80c99967bd07035de7418c81a072Randall Spangler
7006f1b82ac14f341d9733d6e95d518b3ee352002efRandall SpanglerTEST20_NAMES = \
7016f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	tests/vb20_api_tests \
7026f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	tests/vb20_common_tests \
7036f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	tests/vb20_common2_tests \
7045fb14634b9f7618592b9e88d9aa74b2111f15ee1Bill Richardson	tests/vb20_verify_fw.c \
7056f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	tests/vb20_common3_tests \
7066f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	tests/vb20_misc_tests \
7075fb14634b9f7618592b9e88d9aa74b2111f15ee1Bill Richardson	tests/vb20_rsa_padding_tests \
7085fb14634b9f7618592b9e88d9aa74b2111f15ee1Bill Richardson	tests/vb20_verify_fw
7096f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler
710108d991c678f80c99967bd07035de7418c81a072Randall SpanglerTEST21_NAMES = \
711108d991c678f80c99967bd07035de7418c81a072Randall Spangler	tests/vb21_api_tests \
712108d991c678f80c99967bd07035de7418c81a072Randall Spangler	tests/vb21_common_tests \
713108d991c678f80c99967bd07035de7418c81a072Randall Spangler	tests/vb21_common2_tests \
714108d991c678f80c99967bd07035de7418c81a072Randall Spangler	tests/vb21_misc_tests \
715108d991c678f80c99967bd07035de7418c81a072Randall Spangler	tests/vb21_host_fw_preamble_tests \
716108d991c678f80c99967bd07035de7418c81a072Randall Spangler	tests/vb21_host_key_tests \
717108d991c678f80c99967bd07035de7418c81a072Randall Spangler	tests/vb21_host_keyblock_tests \
718108d991c678f80c99967bd07035de7418c81a072Randall Spangler	tests/vb21_host_misc_tests \
719108d991c678f80c99967bd07035de7418c81a072Randall Spangler	tests/vb21_host_sig_tests
720786acdabcc15f023330d7c628aca9679e757a238Randall Spangler
7216f1b82ac14f341d9733d6e95d518b3ee352002efRandall SpanglerTEST_NAMES += ${TEST2X_NAMES} ${TEST20_NAMES} ${TEST21_NAMES}
722786acdabcc15f023330d7c628aca9679e757a238Randall Spangler
723eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# And a few more...
724339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonTLCL_TEST_NAMES = \
725339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_lite/tpmtest_earlyextend \
726339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_lite/tpmtest_earlynvram \
727339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson        tests/tpm_lite/tpmtest_earlynvram2 \
728339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_lite/tpmtest_enable \
729339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_lite/tpmtest_fastenable \
730339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_lite/tpmtest_globallock \
731339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson        tests/tpm_lite/tpmtest_redefine_unowned \
732339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson        tests/tpm_lite/tpmtest_spaceperm \
733339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_lite/tpmtest_testsetup \
734339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_lite/tpmtest_timing \
735339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson        tests/tpm_lite/tpmtest_writelimit
736eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
737eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTEST_NAMES += ${TLCL_TEST_NAMES}
738eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
739339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson# Finally
740339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonTEST_BINS = $(addprefix ${BUILD}/,${TEST_NAMES})
74180872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += $(addsuffix .o,${TEST_BINS})
742eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
7436f1b82ac14f341d9733d6e95d518b3ee352002efRandall SpanglerTEST2X_BINS = $(addprefix ${BUILD}/,${TEST2X_NAMES})
744aaaff86467823e0d3d29c383402275eeae481256Randall SpanglerTEST20_BINS = $(addprefix ${BUILD}/,${TEST20_NAMES})
745108d991c678f80c99967bd07035de7418c81a072Randall SpanglerTEST21_BINS = $(addprefix ${BUILD}/,${TEST21_NAMES})
746aaaff86467823e0d3d29c383402275eeae481256Randall Spangler
747e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler# Directory containing test keys
748e061a256549607a56d771eb8ddae5d0dd90d519cRandall SpanglerTEST_KEYS = ${SRC_RUN}/tests/testkeys
749eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
750eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
751eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson##############################################################################
752eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Finally, some targets. High-level ones first.
753eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
754eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Create output directories if necessary.  Do this via explicit shell commands
755eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# so it happens before trying to generate/include dependencies.
756eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonSUBDIRS := firmware host cgpt utility futility tests tests/tpm_lite
757eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson_dir_create := $(foreach d, \
758eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	$(shell find ${SUBDIRS} -name '*.c' -exec  dirname {} \; | sort -u), \
759eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	$(shell [ -d ${BUILD}/${d} ] || mkdir -p ${BUILD}/${d}))
760eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
761eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
762eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Default target.
763eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: all
76406eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardsonall: fwlib fwlib2x fwlib20 fwlib21 \
765aaaff86467823e0d3d29c383402275eeae481256Randall Spangler	$(if ${FIRMWARE_ARCH},,host_stuff) \
766786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	$(if ${COV},coverage)
767eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
768eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Host targets
769eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: host_stuff
77006eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardsonhost_stuff: utillib hostlib cgpt utils futil tests utillib21
771eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
772eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: clean
773eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonclean:
774eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}/bin/rm -rf ${BUILD}
775eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
776eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: install
77707d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyeninstall: cgpt_install utils_install signing_install futil_install \
77807d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen	pc_files_install
779eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
780d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen.PHONY: install_mtd
781d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyeninstall_mtd: install cgpt_wrapper_install
782d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen
7833e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardson.PHONY: install_for_test
7843e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardsoninstall_for_test: override DESTDIR = ${TEST_INSTALL_DIR}
7853e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardsoninstall_for_test: install
7863e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardson
787eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Don't delete intermediate object files
788eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.SECONDARY:
789eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
790eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
791eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Firmware library
792eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
793eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM-specific flags.  These depend on the particular TPM we're targeting for.
794eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# They are needed here only for compiling parts of the firmware code into
795eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# user-level tests.
796eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
797eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM_BLOCKING_CONTINUESELFTEST is defined if TPM_ContinueSelfTest blocks until
798eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# the self test has completed.
799eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
80045cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DTPM_BLOCKING_CONTINUESELFTEST
801eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
802eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM_MANUAL_SELFTEST is defined if the self test must be started manually
803eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# (with a call to TPM_ContinueSelfTest) instead of starting automatically at
804eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# power on.
805eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#
806eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# We sincerely hope that TPM_BLOCKING_CONTINUESELFTEST and TPM_MANUAL_SELFTEST
807eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# are not both defined at the same time.  (See comment in code.)
808eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
809eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# CFLAGS += -DTPM_MANUAL_SELFTEST
810eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
811eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH},i386)
812eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Unrolling loops in cryptolib makes it faster
81345cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DUNROLL_LOOPS
81406eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson${FWLIB2X_OBJS}: CFLAGS += -DUNROLL_LOOPS
815aaaff86467823e0d3d29c383402275eeae481256Randall Spangler${FWLIB20_OBJS}: CFLAGS += -DUNROLL_LOOPS
816a5b69b02e039d7267390fea10266d45e14630559Randall Spangler${FWLIB21_OBJS}: CFLAGS += -DUNROLL_LOOPS
817eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
818eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Workaround for coreboot on x86, which will power off asynchronously
819eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# without giving us a chance to react. This is not an example of the Right
820eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Way to do things. See chrome-os-partner:7689, and the commit message
821eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# that made this change.
82245cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DSAVE_LOCALE_IMMEDIATELY
823eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
824eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# On x86 we don't actually read the GBB data into RAM until it is needed.
825eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Therefore it makes sense to cache it rather than reading it each time.
826eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Enable this feature.
82745cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DCOPY_BMP_DATA
828eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
829eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
830527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glassifdef REGION_READ
831527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass${FWLIB_OBJS}: CFLAGS += -DREGION_READ
832527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glassendif
833527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass
834eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH},)
835eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Disable rollback TPM when compiling locally, since otherwise
836eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# load_kernel_test attempts to talk to the TPM.
83745cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DDISABLE_ROLLBACK_TPM
838eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
839eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
8406f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler${FWLIB20_OBJS}: INCLUDES += -Ifirmware/lib20/include
841108d991c678f80c99967bd07035de7418c81a072Randall Spangler${FWLIB21_OBJS}: INCLUDES += -Ifirmware/lib21/include
842108d991c678f80c99967bd07035de7418c81a072Randall Spangler
843a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson# Linktest ensures firmware lib doesn't rely on outside libraries
844a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${BUILD}/firmware/linktest/main_vbinit: ${VBINIT_OBJS}
84593943266c597ad66300445a04afa01270f2b5763Randall Spangler${BUILD}/firmware/linktest/main_vbinit: OBJS = ${VBINIT_OBJS}
84680872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/firmware/linktest/main_vbinit.o
847a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${BUILD}/firmware/linktest/main_vbsf: ${VBSF_OBJS}
84893943266c597ad66300445a04afa01270f2b5763Randall Spangler${BUILD}/firmware/linktest/main_vbsf: OBJS = ${VBSF_OBJS}
84980872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/firmware/linktest/main_vbsf.o
850a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${BUILD}/firmware/linktest/main: ${FWLIB}
851a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${BUILD}/firmware/linktest/main: LIBS = ${FWLIB}
85280872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/firmware/linktest/main.o
85393943266c597ad66300445a04afa01270f2b5763Randall Spangler
854d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardson.PHONY: fwlinktest
855d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardsonfwlinktest: \
85693943266c597ad66300445a04afa01270f2b5763Randall Spangler	${BUILD}/firmware/linktest/main_vbinit \
85793943266c597ad66300445a04afa01270f2b5763Randall Spangler	${BUILD}/firmware/linktest/main_vbsf \
85893943266c597ad66300445a04afa01270f2b5763Randall Spangler	${BUILD}/firmware/linktest/main
85993943266c597ad66300445a04afa01270f2b5763Randall Spangler
860eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: fwlib
861a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardsonfwlib: $(if ${FIRMWARE_ARCH},${FWLIB},fwlinktest)
862eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
863a5b69b02e039d7267390fea10266d45e14630559Randall Spangler${FWLIB}: ${FWLIB_OBJS}
864c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    RM            $(subst ${BUILD}/,,$@)\n"
865a5b69b02e039d7267390fea10266d45e14630559Randall Spangler	${Q}rm -f $@
866c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    AR            $(subst ${BUILD}/,,$@)\n"
867a5b69b02e039d7267390fea10266d45e14630559Randall Spangler	${Q}ar qc $@ $^
868a5b69b02e039d7267390fea10266d45e14630559Randall Spangler
8696f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler.PHONY: fwlib2x
8706f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spanglerfwlib2x: ${FWLIB2X}
8716f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler
87206eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson${FWLIB2X}: ${FWLIB2X_OBJS}
873c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    RM            $(subst ${BUILD}/,,$@)\n"
8746f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	${Q}rm -f $@
875c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    AR            $(subst ${BUILD}/,,$@)\n"
8766f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	${Q}ar qc $@ $^
8776f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler
87806eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson.PHONY: fwlib20
87906eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardsonfwlib20: ${FWLIB20}
880786acdabcc15f023330d7c628aca9679e757a238Randall Spangler
88106eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson${FWLIB20}: ${FWLIB2X_OBJS} ${FWLIB20_OBJS}
882c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    RM            $(subst ${BUILD}/,,$@)\n"
883eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}rm -f $@
884c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    AR            $(subst ${BUILD}/,,$@)\n"
885eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}ar qc $@ $^
886eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
887a5b69b02e039d7267390fea10266d45e14630559Randall Spangler.PHONY: fwlib21
888a5b69b02e039d7267390fea10266d45e14630559Randall Spanglerfwlib21: ${FWLIB21}
889a5b69b02e039d7267390fea10266d45e14630559Randall Spangler
89006eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson${FWLIB21}: ${FWLIB2X_OBJS} ${FWLIB21_OBJS}
891c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    RM            $(subst ${BUILD}/,,$@)\n"
892786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	${Q}rm -f $@
893c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    AR            $(subst ${BUILD}/,,$@)\n"
894786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	${Q}ar qc $@ $^
895786acdabcc15f023330d7c628aca9679e757a238Randall Spangler
896eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
897782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# Host library(s)
898eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
899782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# Link tests for local utilities
900782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${BUILD}/host/linktest/main: ${UTILLIB}
901782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${BUILD}/host/linktest/main: LIBS = ${UTILLIB}
90280872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/host/linktest/main.o
903782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
904782990277ac7d6730db4c43c2b5632de93396921Bill Richardson.PHONY: utillib
905782990277ac7d6730db4c43c2b5632de93396921Bill Richardsonutillib: ${UTILLIB} \
906782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	${BUILD}/host/linktest/main
907eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
908eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: better way to make .a than duplicating this recipe each time?
909aaaff86467823e0d3d29c383402275eeae481256Randall Spangler${UTILLIB}: ${UTILLIB_OBJS} ${FWLIB_OBJS}
910c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    RM            $(subst ${BUILD}/,,$@)\n"
911aaaff86467823e0d3d29c383402275eeae481256Randall Spangler	${Q}rm -f $@
912c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    AR            $(subst ${BUILD}/,,$@)\n"
913aaaff86467823e0d3d29c383402275eeae481256Randall Spangler	${Q}ar qc $@ $^
914aaaff86467823e0d3d29c383402275eeae481256Randall Spangler
915a5b69b02e039d7267390fea10266d45e14630559Randall Spangler.PHONY: utillib21
916a5b69b02e039d7267390fea10266d45e14630559Randall Spanglerutillib21: ${UTILLIB21}
917aaaff86467823e0d3d29c383402275eeae481256Randall Spangler
918108d991c678f80c99967bd07035de7418c81a072Randall Spangler${UTILLIB21}: INCLUDES += -Ihost/lib21/include -Ifirmware/lib21/include
91906eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson${UTILLIB21}: ${UTILLIB21_OBJS} ${FWLIB2X_OBJS} ${FWLIB21_OBJS}
920c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    RM            $(subst ${BUILD}/,,$@)\n"
921782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	${Q}rm -f $@
922c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    AR            $(subst ${BUILD}/,,$@)\n"
923782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	${Q}ar qc $@ $^
924782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
925782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
926782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# Link tests for external repos
927782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${BUILD}/host/linktest/extern: ${HOSTLIB}
928782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${BUILD}/host/linktest/extern: LIBS = ${HOSTLIB}
929782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${BUILD}/host/linktest/extern: LDLIBS += -static
93080872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/host/linktest/extern.o
931782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
932782990277ac7d6730db4c43c2b5632de93396921Bill Richardson.PHONY: hostlib
933782990277ac7d6730db4c43c2b5632de93396921Bill Richardsonhostlib: ${HOSTLIB} \
934782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	${BUILD}/host/linktest/extern
935782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
936782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# TODO: better way to make .a than duplicating this recipe each time?
937782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${HOSTLIB}: ${HOSTLIB_OBJS}
938c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    RM            $(subst ${BUILD}/,,$@)\n"
939eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}rm -f $@
940c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    AR            $(subst ${BUILD}/,,$@)\n"
941eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}ar qc $@ $^
942eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
94381a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson
94481a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson# Ugh. This is a very cut-down version of HOSTLIB just for the installer.
94581a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson.PHONY: tinyhostlib
94681a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardsontinyhostlib: ${TINYHOSTLIB}
94781a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	${Q}cp -f ${TINYHOSTLIB} ${HOSTLIB}
94881a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson
94981a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson${TINYHOSTLIB}: ${TINYHOSTLIB_OBJS}
950c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    RM            $(subst ${BUILD}/,,$@)\n"
95181a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	${Q}rm -f $@
952c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    AR            $(subst ${BUILD}/,,$@)\n"
95381a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	${Q}ar qc $@ $^
95481a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson
955eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
956eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# CGPT library and utility
957eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
958d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen.PHONY: cgpt_wrapper
959d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyencgpt_wrapper: ${CGPT_WRAPPER}
960d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen
961d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen${CGPT_WRAPPER}: ${CGPT_WRAPPER_OBJS} ${UTILLIB}
962d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen	@$(PRINTF) "    LD            $(subst ${BUILD}/,,$@)\n"
963d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen	${Q}${LD} -o ${CGPT_WRAPPER} ${CFLAGS} $^
964d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen
965eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: cgpt
966d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyencgpt: ${CGPT} ${CGPT_WRAPPER}
967eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
968eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${CGPT}: LDLIBS += -luuid
969eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
970782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${CGPT}: ${CGPT_OBJS} ${UTILLIB}
971c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    LDcgpt        $(subst ${BUILD}/,,$@)\n"
9726db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson	${Q}${LD} -o ${CGPT} ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS}
973eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
974eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: cgpt_install
975eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsoncgpt_install: ${CGPT}
976c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    INSTALL       CGPT\n"
977c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	${Q}mkdir -p ${UB_DIR}
978c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	${Q}${INSTALL} -t ${UB_DIR} $^
979eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
980d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen.PHONY: cgpt_wrapper_install
981d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyencgpt_wrapper_install: cgpt_install ${CGPT_WRAPPER}
982d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen	@$(PRINTF) "    INSTALL       cgpt_wrapper\n"
983d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen	${Q}${INSTALL} -t ${UB_DIR} ${CGPT_WRAPPER}
984d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen	${Q}mv ${UB_DIR}/$(notdir ${CGPT}) \
985d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen		${UB_DIR}/$(notdir ${CGPT}).bin
986d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen	${Q}mv ${UB_DIR}/$(notdir ${CGPT_WRAPPER}) \
987d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen		${UB_DIR}/$(notdir ${CGPT})
988d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen
989eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
990eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Utilities
991eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
992eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# These have their own headers too.
9930f6679e8582219b40e2ab5485992827a92c18bcdBill Richardson${BUILD}/utility/%: INCLUDES += -Iutility/include
9940f6679e8582219b40e2ab5485992827a92c18bcdBill Richardson
9950f6679e8582219b40e2ab5485992827a92c18bcdBill Richardson${UTIL_BINS} ${UTIL_BINS_STATIC}: ${UTILLIB}
9960f6679e8582219b40e2ab5485992827a92c18bcdBill Richardson${UTIL_BINS} ${UTIL_BINS_STATIC}: LIBS = ${UTILLIB}
997eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
998eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Utilities for auto-update toolkits must be statically linked.
999eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${UTIL_BINS_STATIC}: LDFLAGS += -static
1000eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1001a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson
1002acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: utils
1003c7c6e5d2f7076fe512b692411f0d05d4bf76d91fBill Richardsonutils: ${UTIL_BINS} ${UTIL_SCRIPTS}
1004eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}cp -f ${UTIL_SCRIPTS} ${BUILD}/utility
1005eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}chmod a+rx $(patsubst %,${BUILD}/%,${UTIL_SCRIPTS})
1006826db09fcec194951e1dc71002d6a92620fbb46bBill Richardson
1007acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: utils_install
1008cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardsonutils_install: ${UTIL_BINS} ${UTIL_SCRIPTS} ${UTIL_DEFAULTS}
1009c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    INSTALL       UTILS\n"
1010c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	${Q}mkdir -p ${UB_DIR}
1011c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	${Q}${INSTALL} -t ${UB_DIR} ${UTIL_BINS} ${UTIL_SCRIPTS}
1012cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson	${Q}mkdir -p ${DF_DIR}
1013cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson	${Q}${INSTALL} -t ${DF_DIR} -m 'u=rw,go=r,a-s' ${UTIL_DEFAULTS}
1014c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson
1015c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# And some signing stuff for the target
1016c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson.PHONY: signing_install
1017c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonsigning_install: ${SIGNING_SCRIPTS} ${SIGNING_SCRIPTS_DEV} ${SIGNING_COMMON}
1018c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    INSTALL       SIGNING\n"
10196f3961507e73f90cec665896dece884e86be560aBill Richardson	${Q}mkdir -p ${UB_DIR} ${VB_DIR}
1020c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	${Q}${INSTALL} -t ${UB_DIR} ${SIGNING_SCRIPTS}
10216f3961507e73f90cec665896dece884e86be560aBill Richardson	${Q}${INSTALL} -t ${VB_DIR} ${SIGNING_SCRIPTS_DEV}
10226f3961507e73f90cec665896dece884e86be560aBill Richardson	${Q}${INSTALL} -t ${VB_DIR} -m 'u=rw,go=r,a-s' ${SIGNING_COMMON}
10235d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1024eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
1025eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# new Firmware Utility
10265d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1027eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: futil
10286db8c75021e2edfa400ae707a8544d041e3c415fBill Richardsonfutil: ${FUTIL_STATIC_BIN} ${FUTIL_BIN}
10296db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson
103006eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson${FUTIL_STATIC_BIN}: ${FUTIL_STATIC_OBJS} ${UTILLIB}
1031c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    LD            $(subst ${BUILD}/,,$@)\n"
10326db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson	${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} -static $^ ${LDLIBS}
10335d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1034b84b81dc265a766a968bf126905447d442558218Bill Richardson${FUTIL_BIN}: LDLIBS += ${CRYPTO_LIBS}
103506eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson${FUTIL_BIN}: ${FUTIL_OBJS} ${UTILLIB}
1036c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    LD            $(subst ${BUILD}/,,$@)\n"
10376db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson	${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS}
10385d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1039eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: futil_install
1040efa8756c5e7068e57f5e98f0e7f2f42fb8d969d6Bill Richardsonfutil_install: ${FUTIL_BIN} ${FUTIL_STATIC_BIN}
1041c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    INSTALL       futility\n"
10426f3961507e73f90cec665896dece884e86be560aBill Richardson	${Q}mkdir -p ${UB_DIR}
10436f3961507e73f90cec665896dece884e86be560aBill Richardson	${Q}${INSTALL} -t ${UB_DIR} ${FUTIL_BIN} ${FUTIL_STATIC_BIN}
1044a1d9fe6eecf82540d31d34bba988e4838d295302Bill Richardson	${Q}for prog in ${FUTIL_SYMLINKS}; do \
10456f3961507e73f90cec665896dece884e86be560aBill Richardson		ln -sf futility "${UB_DIR}/$$prog"; done
10465d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1047eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
10485d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Utility to generate TLCL structure definition header file.
10495d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1050acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/utility/tlcl_generator: CFLAGS += -fpack-struct
10515d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
10525d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerSTRUCTURES_TMP=${BUILD}/tlcl_structures.tmp
10535d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerSTRUCTURES_SRC=firmware/lib/tpm_lite/include/tlcl_structures.h
10545d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1055acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: update_tlcl_structures
10565d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerupdate_tlcl_structures: ${BUILD}/utility/tlcl_generator
1057c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    Rebuilding TLCL structures\n"
1058eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${BUILD}/utility/tlcl_generator > ${STRUCTURES_TMP}
1059eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}cmp -s ${STRUCTURES_TMP} ${STRUCTURES_SRC} || \
10605d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler		( echo "%% Updating structures.h %%" && \
1061eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson		  cp ${STRUCTURES_TMP} ${STRUCTURES_SRC} )
10625d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1063eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
10645d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Tests
10655d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1066eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: tests
1067eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontests: ${TEST_BINS}
10685d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1069782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${TEST_BINS}: ${UTILLIB} ${TESTLIB}
1070339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson${TEST_BINS}: INCLUDES += -Itests
1071efa37b87f2b4cd4b4f515e96201502ae0408cec7Randall Spangler${TEST_BINS}: LIBS = ${TESTLIB} ${UTILLIB}
10725d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
10736f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler${TEST2X_BINS}: ${FWLIB2X}
10746f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler${TEST2X_BINS}: LIBS += ${FWLIB2X}
10756f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler
1076108d991c678f80c99967bd07035de7418c81a072Randall Spangler${TEST20_BINS}: ${FWLIB20}
10776f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler${TEST20_BINS}: INCLUDES += -Ifirmware/lib20/include
1078108d991c678f80c99967bd07035de7418c81a072Randall Spangler${TEST20_BINS}: LIBS += ${FWLIB20}
1079108d991c678f80c99967bd07035de7418c81a072Randall Spangler
1080108d991c678f80c99967bd07035de7418c81a072Randall Spangler${TEST21_BINS}: ${UTILLIB21}
1081108d991c678f80c99967bd07035de7418c81a072Randall Spangler${TEST21_BINS}: INCLUDES += -Ihost/lib21/include -Ifirmware/lib21/include
1082108d991c678f80c99967bd07035de7418c81a072Randall Spangler${TEST21_BINS}: LIBS += ${UTILLIB21}
1083aaaff86467823e0d3d29c383402275eeae481256Randall Spangler
1084eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${TESTLIB}: ${TESTLIB_OBJS}
1085c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    RM            $(subst ${BUILD}/,,$@)\n"
1086eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}rm -f $@
1087c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    AR            $(subst ${BUILD}/,,$@)\n"
1088eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}ar qc $@ $^
10895d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
10905d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1091eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
1092eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Generic build rules. LIBS and OBJS can be overridden to tweak the generic
1093eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# rules for specific targets.
10945d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1095eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%: ${BUILD}/%.o ${OBJS} ${LIBS}
1096c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    LD            $(subst ${BUILD}/,,$@)\n"
10976db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson	${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $< ${OBJS} ${LIBS} ${LDLIBS}
1098eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1099eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%.o: %.c
1100c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    CC            $(subst ${BUILD}/,,$@)\n"
1101eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1102eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1103e08ee28548934e933733babf0bc0c418142d095dAlex Deymo${BUILD}/%.o: ${BUILD}/%.c
1104c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    CC            $(subst ${BUILD}/,,$@)\n"
1105e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1106e08ee28548934e933733babf0bc0c418142d095dAlex Deymo
1107eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Rules to recompile a single source file for library and test
1108eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: is there a tidier way to do this?
1109eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_lib.o: CFLAGS += -DFOR_LIBRARY
1110eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_lib.o: %.c
1111c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    CC-for-lib    $(subst ${BUILD}/,,$@)\n"
1112eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1113eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1114eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_test.o: CFLAGS += -DFOR_TEST
1115eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_test.o: %.c
1116c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    CC-for-test   $(subst ${BUILD}/,,$@)\n"
1117eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1118eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1119eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: C++ files don't belong in vboot reference at all.  Convert to C.
1120eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%.o: %.cc
1121c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    CXX           $(subst ${BUILD}/,,$@)\n"
1122eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${CXX} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1123eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1124eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
1125eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Here are the special tweaks to the generic rules.
1126eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1127cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson# Always create the defaults file, since it depends on input variables
1128cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson.PHONY: ${UTIL_DEFAULTS}
1129cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson${UTIL_DEFAULTS}:
1130c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    CREATE        $(subst ${BUILD}/,,$@)\n"
1131cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson	${Q}rm -f $@
1132cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson	${Q}mkdir -p $(dir $@)
1133cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson	${Q}echo '# Generated file. Do not edit.' > $@.tmp
1134cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson	${Q}echo "DEV_DEBUG_FORCE=${DEV_DEBUG_FORCE}" >> $@.tmp
1135cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson	${Q}mv -f $@.tmp $@
1136cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson
1137eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Some utilities need external crypto functions
1138782990277ac7d6730db4c43c2b5632de93396921Bill RichardsonCRYPTO_LIBS := $(shell ${PKG_CONFIG} --libs libcrypto)
1139782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
1140eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/dumpRSAPublicKey: LDLIBS += ${CRYPTO_LIBS}
1141eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/pad_digest_utility: LDLIBS += ${CRYPTO_LIBS}
1142eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/signature_digest_utility: LDLIBS += ${CRYPTO_LIBS}
1143eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1144eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/host/linktest/main: LDLIBS += ${CRYPTO_LIBS}
1145eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/vboot_common2_tests: LDLIBS += ${CRYPTO_LIBS}
1146eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/vboot_common3_tests: LDLIBS += ${CRYPTO_LIBS}
11476f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler${BUILD}/tests/vb20_common2_tests: LDLIBS += ${CRYPTO_LIBS}
11486f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler${BUILD}/tests/vb20_common3_tests: LDLIBS += ${CRYPTO_LIBS}
1149a77541f94f731f5f7755264e9b49b7826aa48dfeBill Richardson${BUILD}/tests/verify_kernel: LDLIBS += ${CRYPTO_LIBS}
1150108d991c678f80c99967bd07035de7418c81a072Randall Spangler
1151108d991c678f80c99967bd07035de7418c81a072Randall Spangler${TEST21_BINS}: LDLIBS += ${CRYPTO_LIBS}
1152eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
11530b789c56fc5ff34309e935bab15f130a386a1140Mike FrysingerLZMA_LIBS := $(shell ${PKG_CONFIG} --libs liblzma)
11540b789c56fc5ff34309e935bab15f130a386a1140Mike FrysingerYAML_LIBS := $(shell ${PKG_CONFIG} --libs yaml-0.1)
11550b789c56fc5ff34309e935bab15f130a386a1140Mike Frysinger
1156eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_utility: LD = ${CXX}
11570b789c56fc5ff34309e935bab15f130a386a1140Mike Frysinger${BUILD}/utility/bmpblk_utility: LDLIBS = ${LZMA_LIBS} ${YAML_LIBS}
1158eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1159eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonBMPBLK_UTILITY_DEPS = \
1160eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/utility/bmpblk_util.o \
1161eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/utility/image_types.o \
1162eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/utility/eficompress_for_lib.o \
1163eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/utility/efidecompress_for_lib.o
11641912bbae89b82c10819b01d039e140e39c668fc7Bill Richardson
1165eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_utility: OBJS = ${BMPBLK_UTILITY_DEPS}
1166eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_utility: ${BMPBLK_UTILITY_DEPS}
11671912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BMPBLK_UTILITY_DEPS}
1168eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1169eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_font: OBJS += ${BUILD}/utility/image_types.o
1170eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_font: ${BUILD}/utility/image_types.o
11711912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BUILD}/utility/image_types.o
1172eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1173eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Allow multiple definitions, so tests can mock functions from other libraries
1174eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/%: CFLAGS += -Xlinker --allow-multiple-definition
1175eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/%: LDLIBS += -lrt -luuid
1176eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/%: LIBS += ${TESTLIB}
11775d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
11785d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler${BUILD}/tests/rollback_index2_tests: OBJS += \
117917f8d341099120da78a6ca71165834eefb0960edRandall Spangler	${BUILD}/firmware/lib/rollback_index_for_test.o
1180eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/rollback_index2_tests: \
1181eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/firmware/lib/rollback_index_for_test.o
118280872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/firmware/lib/rollback_index_for_test.o
11835d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1184c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler${BUILD}/tests/tlcl_tests: OBJS += \
1185c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler	${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
1186c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler${BUILD}/tests/tlcl_tests: \
1187c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler	${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
118880872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
1189c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler
11905d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler${BUILD}/tests/vboot_audio_tests: OBJS += \
119117f8d341099120da78a6ca71165834eefb0960edRandall Spangler	${BUILD}/firmware/lib/vboot_audio_for_test.o
1192eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/vboot_audio_tests: \
1193eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/firmware/lib/vboot_audio_for_test.o
119480872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/firmware/lib/vboot_audio_for_test.o
11955d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1196339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonTLCL_TEST_BINS = $(addprefix ${BUILD}/,${TLCL_TEST_NAMES})
1197eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${TLCL_TEST_BINS}: OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o
1198eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${TLCL_TEST_BINS}: ${BUILD}/tests/tpm_lite/tlcl_tests.o
119980872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o
12005d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1201e08ee28548934e933733babf0bc0c418142d095dAlex Deymo# ----------------------------------------------------------------------------
1202e08ee28548934e933733babf0bc0c418142d095dAlex Deymo# Here are the special rules that don't fit in the generic rules.
1203e08ee28548934e933733babf0bc0c418142d095dAlex Deymo
1204e08ee28548934e933733babf0bc0c418142d095dAlex Deymo# Generates the list of commands defined in futility by running grep in the
1205e08ee28548934e933733babf0bc0c418142d095dAlex Deymo# source files looking for the DECLARE_FUTIL_COMMAND() macro usage.
1206e08ee28548934e933733babf0bc0c418142d095dAlex Deymo${FUTIL_STATIC_CMD_LIST}: ${FUTIL_STATIC_SRCS}
1207e08ee28548934e933733babf0bc0c418142d095dAlex Deymo${FUTIL_CMD_LIST}: ${FUTIL_SRCS}
1208e08ee28548934e933733babf0bc0c418142d095dAlex Deymo${FUTIL_CMD_LIST} ${FUTIL_STATIC_CMD_LIST}:
1209c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    GEN           $(subst ${BUILD}/,,$@)\n"
1210e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}rm -f $@ $@_t $@_commands
1211e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}mkdir -p ${BUILD}/gen
1212779796f57e1e0236ea502248ede2cbea986fca21Bill Richardson	${Q}grep -hoRE '^DECLARE_FUTIL_COMMAND\([^,]+' $^ \
1213e08ee28548934e933733babf0bc0c418142d095dAlex Deymo		| sed 's/DECLARE_FUTIL_COMMAND(\(.*\)/_CMD(\1)/' \
1214e08ee28548934e933733babf0bc0c418142d095dAlex Deymo		| sort >>$@_commands
1215e1486c3234b7dc6fc5b58681b271a65a09141e20Bill Richardson	${Q}./scripts/getversion.sh >> $@_t
1216e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}echo '#define _CMD(NAME) extern const struct' \
1217e08ee28548934e933733babf0bc0c418142d095dAlex Deymo		'futil_cmd_t __cmd_##NAME;' >> $@_t
1218e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}cat $@_commands >> $@_t
1219e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}echo '#undef _CMD' >> $@_t
1220e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}echo '#define _CMD(NAME) &__cmd_##NAME,' >> $@_t
1221e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}echo 'const struct futil_cmd_t *const futil_cmds[] = {' >> $@_t
1222e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}cat $@_commands >> $@_t
1223e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}echo '0};  /* null-terminated */' >> $@_t
1224e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}echo '#undef _CMD' >> $@_t
1225e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}mv $@_t $@
1226e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}rm -f $@_commands
1227e08ee28548934e933733babf0bc0c418142d095dAlex Deymo
1228eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson##############################################################################
1229eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Targets that exist just to run tests
12305d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
12315d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Frequently-run tests
1232eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: test_targets
123306eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardsontest_targets:: runcgpttests runmisctests run2tests
1234844bce57471153664c78993dab453e87891bb969Randall Spangler
1235eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${MINIMAL},)
1236844bce57471153664c78993dab453e87891bb969Randall Spangler# Bitmap utility isn't compiled for minimal variant
1237feb2518166b1cd181e607c611cbb610f0c7300daBill Richardsontest_targets:: runbmptests runfutiltests
1238844bce57471153664c78993dab453e87891bb969Randall Spangler# Scripts don't work under qemu testing
1239844bce57471153664c78993dab453e87891bb969Randall Spangler# TODO: convert scripts to makefile so they can be called directly
1240eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontest_targets:: runtestscripts
1241844bce57471153664c78993dab453e87891bb969Randall Spanglerendif
1242844bce57471153664c78993dab453e87891bb969Randall Spangler
1243eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: test_setup
12443e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardsontest_setup:: cgpt utils futil tests install_for_test
1245eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1246844bce57471153664c78993dab453e87891bb969Randall Spangler# Qemu setup for cross-compiled tests.  Need to copy qemu binary into the
1247844bce57471153664c78993dab453e87891bb969Randall Spangler# sysroot.
1248eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifneq (${QEMU_ARCH},)
1249eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontest_setup:: qemu_install
1250844bce57471153664c78993dab453e87891bb969Randall Spangler
1251844bce57471153664c78993dab453e87891bb969Randall Spangler.PHONY: qemu_install
1252844bce57471153664c78993dab453e87891bb969Randall Spanglerqemu_install:
1253eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${SYSROOT},)
1254eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	$(error SYSROOT must be set to the top of the target-specific root \
1255eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonwhen cross-compiling for qemu-based tests to run properly.)
1256eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
1257c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    Copying qemu binary.\n"
1258eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}cp -fu /usr/bin/${QEMU_BIN} ${BUILD}/${QEMU_BIN}
1259eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}chmod a+rx ${BUILD}/${QEMU_BIN}
1260844bce57471153664c78993dab453e87891bb969Randall Spanglerendif
1261844bce57471153664c78993dab453e87891bb969Randall Spangler
1262acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runtests
1263a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardsonruntests: test_setup test_targets
12645d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
12655d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Generate test keys
1266acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: genkeys
12670840b842c1609accee80b148bc26f5e84f42e309Bill Richardsongenkeys: utils test_setup
12685d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/gen_test_keys.sh
12695d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
12705d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Generate test cases for fuzzing
1271acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: genfuzztestcases
12720840b842c1609accee80b148bc26f5e84f42e309Bill Richardsongenfuzztestcases: utils test_setup
12735d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/gen_fuzz_test_cases.sh
12745d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1275acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runbmptests
1276eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonrunbmptests: test_setup
1277eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	cd tests/bitmaps && BMPBLK=${BUILD_RUN}/utility/bmpblk_utility \
12785d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler		./TestBmpBlock.py -v
12795d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1280acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runcgpttests
1281eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonruncgpttests: test_setup
1282eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/cgptlib_test
12835d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1284844bce57471153664c78993dab453e87891bb969Randall Spangler.PHONY: runtestscripts
1285eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonruntestscripts: test_setup genfuzztestcases
1286b8ff397674fb98c1d7eea864e7fa571369675131Randall Spangler	tests/load_kernel_tests.sh
1287eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt
1288ab899591808dd3e5f955ab7693b54a83389cd35fNam T. Nguyen	tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt -D 358400
12895d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/run_preamble_tests.sh
12905d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/run_rsa_tests.sh
1291844bce57471153664c78993dab453e87891bb969Randall Spangler	tests/run_vbutil_kernel_arg_tests.sh
12925d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/run_vbutil_tests.sh
1293e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	tests/vb2_rsa_tests.sh
1294539cbc27305b6aef9643adffc3297c7079fe7457Randall Spangler	tests/vb2_firmware_tests.sh
12955d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1296844bce57471153664c78993dab453e87891bb969Randall Spangler.PHONY: runmisctests
1297eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonrunmisctests: test_setup
1298eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/rollback_index2_tests
1299a3eac79f5070747e326da631c1eec155f0389919Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/rollback_index3_tests
1300eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/rsa_utility_tests
1301eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/sha_tests
1302eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/stateful_util_tests
1303c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/tlcl_tests
1304eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/tpm_bootmode_tests
1305eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/utility_string_tests
1306eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/utility_tests
1307eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_devmode_tests
1308eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_firmware_tests
13090714d9de56da3a5c686b26755d15aa6788c727d4Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_init_tests
13100714d9de56da3a5c686b26755d15aa6788c727d4Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel_tests
13117f43669630cb42e40ca6ddc1128eefea8fd339d9Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel2_tests
13127f43669630cb42e40ca6ddc1128eefea8fd339d9Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel3_tests
13137f43669630cb42e40ca6ddc1128eefea8fd339d9Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel4_tests
1314eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/vboot_audio_tests
1315e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_common_tests
1316e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS}
1317e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS}
1318786a5dca74387de5ffdc51ca5a099a4e90f406daRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_display_tests
1319eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/vboot_firmware_tests
132049cb0d3471e768da11fe76b65769bd57dca38bd7Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_kernel_tests
13216dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_nvstorage_test
1322eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1323786acdabcc15f023330d7c628aca9679e757a238Randall Spangler.PHONY: run2tests
1324786acdabcc15f023330d7c628aca9679e757a238Randall Spanglerrun2tests: test_setup
1325a7ab8b50b8923afcfd7a9e6181892c4c8a2de250Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_api_tests
1326786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_common_tests
13273333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_misc_tests
13283333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_nvstorage_tests
1329e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_rsa_utility_tests
13303333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_secdata_tests
1331e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_sha_tests
13326f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb20_api_tests
13336f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb20_common_tests
13346f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb20_common2_tests ${TEST_KEYS}
13356f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb20_common3_tests ${TEST_KEYS}
13366f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb20_misc_tests
1337108d991c678f80c99967bd07035de7418c81a072Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb21_api_tests
1338108d991c678f80c99967bd07035de7418c81a072Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb21_common_tests
1339108d991c678f80c99967bd07035de7418c81a072Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb21_common2_tests ${TEST_KEYS}
1340108d991c678f80c99967bd07035de7418c81a072Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb21_misc_tests
1341108d991c678f80c99967bd07035de7418c81a072Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb21_host_fw_preamble_tests ${TEST_KEYS}
1342108d991c678f80c99967bd07035de7418c81a072Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb21_host_key_tests ${TEST_KEYS}
1343108d991c678f80c99967bd07035de7418c81a072Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb21_host_keyblock_tests ${TEST_KEYS}
1344108d991c678f80c99967bd07035de7418c81a072Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb21_host_misc_tests
1345108d991c678f80c99967bd07035de7418c81a072Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb21_host_sig_tests ${TEST_KEYS}
1346786acdabcc15f023330d7c628aca9679e757a238Randall Spangler
1347eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: runfutiltests
13483e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardsonrunfutiltests: test_setup
1349efa8756c5e7068e57f5e98f0e7f2f42fb8d969d6Bill Richardson	tests/futility/run_test_scripts.sh ${TEST_INSTALL_DIR}/bin
1350339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/futility/test_not_really
1351844bce57471153664c78993dab453e87891bb969Randall Spangler
13525d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Run long tests, including all permutations of encryption keys (instead of
1353786a5dca74387de5ffdc51ca5a099a4e90f406daRandall Spangler# just the ones we use) and tests of currently-unused code.
13545d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Not run by automated build.
1355acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runlongtests
1356eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonrunlongtests: test_setup genkeys genfuzztestcases
1357e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS} --all
1358e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS} --all
13596f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb20_common2_tests ${TEST_KEYS} --all
13606f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb20_common3_tests ${TEST_KEYS} --all
1361108d991c678f80c99967bd07035de7418c81a072Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb21_common2_tests ${TEST_KEYS} --all
13625d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/run_preamble_tests.sh --all
13635d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/run_vbutil_tests.sh --all
13645d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
136578d59bffec45da47b4e8a763186723192dd24f87Bill Richardson# TODO: There were a number of ancient tests that hadn't been run in years.
136678d59bffec45da47b4e8a763186723192dd24f87Bill Richardson# They were removed with https://chromium-review.googlesource.com/#/c/214610/
136778d59bffec45da47b4e8a763186723192dd24f87Bill Richardson# Some day it might be nice to see what they were supposed to do.
13685d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1369782990277ac7d6730db4c43c2b5632de93396921Bill Richardson.PHONY: runalltests
1370782990277ac7d6730db4c43c2b5632de93396921Bill Richardsonrunalltests: runtests runfutiltests runlongtests
1371782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
137259d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler# Code coverage
137359d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler.PHONY: coverage_init
137459d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage_init: test_setup
137559d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	rm -f ${COV_INFO}*
137659d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	lcov -c -i -d . -b . -o ${COV_INFO}.initial
137759d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler
137859d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler.PHONY: coverage_html
137959d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage_html:
138059d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	lcov -c -d . -b . -o ${COV_INFO}.tests
138159d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	lcov -a ${COV_INFO}.initial -a ${COV_INFO}.tests -o ${COV_INFO}.total
138259d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	lcov -r ${COV_INFO}.total '/usr/*' '*/linktest/*' -o ${COV_INFO}.local
138359d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	genhtml ${COV_INFO}.local -o ${BUILD}/coverage
1384d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardson# Generate addtional coverage stats just for firmware subdir, because the stats
1385d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardson# for the whole project don't include subdirectory summaries. This will print
1386d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardson# the summary for just the firmware sources.
138749cb0d3471e768da11fe76b65769bd57dca38bd7Randall Spangler	lcov -r ${COV_INFO}.local '*/stub/*' -o ${COV_INFO}.nostub
138849cb0d3471e768da11fe76b65769bd57dca38bd7Randall Spangler	lcov -e ${COV_INFO}.nostub '${SRCDIR}/firmware/*' \
138959d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler		-o ${COV_INFO}.firmware
139059d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler
139159d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler.PHONY: coverage
139259d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglerifeq (${COV},)
139359d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage:
139459d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	$(error Build coverage like this: make clean && COV=1 make)
139559d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglerelse
139659d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage: coverage_init runtests coverage_html
139759d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglerendif
13981912bbae89b82c10819b01d039e140e39c668fc7Bill Richardson
13991912bbae89b82c10819b01d039e140e39c668fc7Bill Richardson# Include generated dependencies
14001912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_DEPS += ${ALL_OBJS:%.o=%.o.d}
140180872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_DEPS += ${TEST_OBJS:%.o=%.o.d}
140204d98e399d034656770e0049613d09ef3ea6d2d0Bill Richardson-include ${ALL_DEPS}
140304d98e399d034656770e0049613d09ef3ea6d2d0Bill Richardson-include ${TEST_DEPS}
140480872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson
140580872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson# We want to use only relative paths in cscope.files, especially since the
140680872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson# paths inside and outside the chroot are different.
140780872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonSRCDIRPAT=$(subst /,\/,${SRCDIR}/)
140880872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson
14098db64da0926e95c4cc19145e911aa270e06a83c0Bill Richardson# Note: vboot 2.0 is deprecated, so don't index those files
141080872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson${BUILD}/cscope.files: test_setup
141180872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson	${Q}rm -f $@
141280872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson	${Q}cat ${ALL_DEPS} | tr -d ':\\' | tr ' ' '\012' | \
14138db64da0926e95c4cc19145e911aa270e06a83c0Bill Richardson		grep -v /lib20/ | \
141480872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson		sed -e "s/${SRCDIRPAT}//" | \
141580872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson		egrep '\.[chS]$$' | sort | uniq > $@
141680872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson
141780872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardsoncmd_etags = etags -o ${BUILD}/TAGS $(shell cat ${BUILD}/cscope.files)
141880872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardsoncmd_ctags = ctags -o ${BUILD}/tags $(shell cat ${BUILD}/cscope.files)
141980872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardsonrun_if_prog = $(if $(shell which $(1) 2>/dev/null),$(2),)
142080872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson
142180872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson.PHONY: tags TAGS xrefs
142280872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardsontags TAGS xrefs: ${BUILD}/cscope.files
142380872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson	${Q}\rm -f ${BUILD}/tags ${BUILD}/TAGS
142480872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson	${Q}$(call run_if_prog,etags,${cmd_etags})
142580872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson	${Q}$(call run_if_prog,ctags,${cmd_ctags})
142607d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen
1427822120106c963b43c3d303a791f8dd8731d0888eBill RichardsonPC_FILES = ${PC_IN_FILES:%.pc.in=${BUILD}/%.pc}
142807d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen${PC_FILES}: ${PC_IN_FILES}
142907d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen	${Q}sed \
143007d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen		-e 's:@LDLIBS@:${LDLIBS}:' \
143107d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen		-e 's:@LIBDIR@:${LIBDIR}:' \
143207d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen		$< > $@
143307d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen
143407d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen.PHONY: pc_files_install
143507d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyenpc_files_install: ${PC_FILES}
143607d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen	${Q}mkdir -p ${ULP_DIR}
1437822120106c963b43c3d303a791f8dd8731d0888eBill Richardson	${Q}${INSTALL} -D -m 0644 $< ${ULP_DIR}/$(notdir $<)
1438