Makefile revision 317bb498a697ae49f070e3ca46100b879f25aa1b
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} \
6086f3961507e73f90cec665896dece884e86be560aBill Richardson	futility/cmd_dump_kernel_config.c \
6092e25e813419f2cd437164929543e452b28b89260Bill Richardson	futility/cmd_load_fmap.c \
610f4f395e1ca724ef8795cfe86a9edbf15f14eacd1Bill Richardson	futility/cmd_pcr.c \
611f318ee205cc8d92def925c6158272da8a63bf1edBill Richardson	futility/cmd_show.c \
612f318ee205cc8d92def925c6158272da8a63bf1edBill Richardson	futility/cmd_sign.c \
6136f3961507e73f90cec665896dece884e86be560aBill Richardson	futility/cmd_vbutil_firmware.c \
6146f3961507e73f90cec665896dece884e86be560aBill Richardson	futility/cmd_vbutil_kernel.c \
615b84b81dc265a766a968bf126905447d442558218Bill Richardson	futility/cmd_vbutil_key.c \
616b8ff397674fb98c1d7eea864e7fa571369675131Randall Spangler	futility/cmd_vbutil_keyblock.c \
6172559338dbdacbcbd3ae426337403196135bbc7e8Bill Richardson	futility/file_type.c \
618f318ee205cc8d92def925c6158272da8a63bf1edBill Richardson	futility/traversal.c \
619f318ee205cc8d92def925c6158272da8a63bf1edBill Richardson	futility/vb1_helper.c
6206db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson
621e08ee28548934e933733babf0bc0c418142d095dAlex Deymo# List of commands built in futility and futility_s.
622e08ee28548934e933733babf0bc0c418142d095dAlex DeymoFUTIL_STATIC_CMD_LIST = ${BUILD}/gen/futility_static_cmds.c
623e08ee28548934e933733babf0bc0c418142d095dAlex DeymoFUTIL_CMD_LIST = ${BUILD}/gen/futility_cmds.c
624eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
62591852e7f58d50a031bcb5c02e68473cefb10ebb0Bill Richardson# Workaround for TODO(crbug.com/437107).
62691852e7f58d50a031bcb5c02e68473cefb10ebb0Bill RichardsonFUTIL_STATIC_WORKAROUND_SRCS = firmware/stub/vboot_api_stub_static_sf.c
62791852e7f58d50a031bcb5c02e68473cefb10ebb0Bill Richardson
628e08ee28548934e933733babf0bc0c418142d095dAlex DeymoFUTIL_STATIC_OBJS = ${FUTIL_STATIC_SRCS:%.c=${BUILD}/%.o} \
62991852e7f58d50a031bcb5c02e68473cefb10ebb0Bill Richardson	${FUTIL_STATIC_WORKAROUND_SRCS:%.c=${BUILD}/%.o} \
630e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${FUTIL_STATIC_CMD_LIST:%.c=%.o}
631e08ee28548934e933733babf0bc0c418142d095dAlex DeymoFUTIL_OBJS = ${FUTIL_SRCS:%.c=${BUILD}/%.o} ${FUTIL_CMD_LIST:%.c=%.o}
632eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
633eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonALL_OBJS += ${FUTIL_OBJS}
634eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
635eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
636eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Library of handy test functions.
637eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTESTLIB = ${BUILD}/tests/test.a
638eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
639eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTESTLIB_SRCS = \
640eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tests/test_common.c \
641eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tests/timer_utils.c \
642eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tests/crc32_test.c
643eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
644eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTESTLIB_OBJS = ${TESTLIB_SRCS:%.c=${BUILD}/%.o}
64580872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${TESTLIB_OBJS}
646eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
647eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
648eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# And some compiled tests.
649eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTEST_NAMES = \
650339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/cgptlib_test \
651339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/rollback_index2_tests \
652339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/rollback_index3_tests \
653339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/rsa_padding_test \
654339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/rsa_utility_tests \
655339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/rsa_verify_benchmark \
656339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/sha_benchmark \
657339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/sha_tests \
658339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/stateful_util_tests \
659339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tlcl_tests \
660339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_bootmode_tests \
661339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/utility_string_tests \
662339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/utility_tests \
663339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_api_init_tests \
664339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_api_devmode_tests \
665339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_api_firmware_tests \
666339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_api_kernel_tests \
667339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_api_kernel2_tests \
668339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_api_kernel3_tests \
669339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_api_kernel4_tests \
670339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_audio_tests \
671339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_common_tests \
672339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_common2_tests \
673339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_common3_tests \
674339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_display_tests \
675339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_firmware_tests \
676339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_kernel_tests \
677339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/vboot_nvstorage_test \
678a77541f94f731f5f7755264e9b49b7826aa48dfeBill Richardson	tests/verify_kernel \
6796f3961507e73f90cec665896dece884e86be560aBill Richardson	tests/futility/binary_editor \
680339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/futility/test_not_really
681eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
682527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glassifdef REGION_READ
683527ba810eff4006cf69579f6b96cb4350cb1e189Simon GlassTEST_NAMES += tests/vboot_region_tests
684527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glassendif
685527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass
6866f1b82ac14f341d9733d6e95d518b3ee352002efRandall SpanglerTEST2X_NAMES = \
687a7ab8b50b8923afcfd7a9e6181892c4c8a2de250Randall Spangler	tests/vb2_api_tests \
688786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	tests/vb2_common_tests \
6893333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	tests/vb2_misc_tests \
6903333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	tests/vb2_nvstorage_tests \
691e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	tests/vb2_rsa_utility_tests \
6923333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	tests/vb2_secdata_tests \
693108d991c678f80c99967bd07035de7418c81a072Randall Spangler	tests/vb2_sha_tests
694108d991c678f80c99967bd07035de7418c81a072Randall Spangler
6956f1b82ac14f341d9733d6e95d518b3ee352002efRandall SpanglerTEST20_NAMES = \
6966f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	tests/vb20_api_tests \
6976f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	tests/vb20_common_tests \
6986f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	tests/vb20_common2_tests \
6995fb14634b9f7618592b9e88d9aa74b2111f15ee1Bill Richardson	tests/vb20_verify_fw.c \
7006f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	tests/vb20_common3_tests \
7016f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	tests/vb20_misc_tests \
7025fb14634b9f7618592b9e88d9aa74b2111f15ee1Bill Richardson	tests/vb20_rsa_padding_tests \
7035fb14634b9f7618592b9e88d9aa74b2111f15ee1Bill Richardson	tests/vb20_verify_fw
7046f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler
705108d991c678f80c99967bd07035de7418c81a072Randall SpanglerTEST21_NAMES = \
706108d991c678f80c99967bd07035de7418c81a072Randall Spangler	tests/vb21_api_tests \
707108d991c678f80c99967bd07035de7418c81a072Randall Spangler	tests/vb21_common_tests \
708108d991c678f80c99967bd07035de7418c81a072Randall Spangler	tests/vb21_common2_tests \
709108d991c678f80c99967bd07035de7418c81a072Randall Spangler	tests/vb21_misc_tests \
710108d991c678f80c99967bd07035de7418c81a072Randall Spangler	tests/vb21_host_fw_preamble_tests \
711108d991c678f80c99967bd07035de7418c81a072Randall Spangler	tests/vb21_host_key_tests \
712108d991c678f80c99967bd07035de7418c81a072Randall Spangler	tests/vb21_host_keyblock_tests \
713108d991c678f80c99967bd07035de7418c81a072Randall Spangler	tests/vb21_host_misc_tests \
714108d991c678f80c99967bd07035de7418c81a072Randall Spangler	tests/vb21_host_sig_tests
715786acdabcc15f023330d7c628aca9679e757a238Randall Spangler
7166f1b82ac14f341d9733d6e95d518b3ee352002efRandall SpanglerTEST_NAMES += ${TEST2X_NAMES} ${TEST20_NAMES} ${TEST21_NAMES}
717786acdabcc15f023330d7c628aca9679e757a238Randall Spangler
718eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# And a few more...
719339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonTLCL_TEST_NAMES = \
720339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_lite/tpmtest_earlyextend \
721339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_lite/tpmtest_earlynvram \
722339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson        tests/tpm_lite/tpmtest_earlynvram2 \
723339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_lite/tpmtest_enable \
724339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_lite/tpmtest_fastenable \
725339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_lite/tpmtest_globallock \
726339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson        tests/tpm_lite/tpmtest_redefine_unowned \
727339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson        tests/tpm_lite/tpmtest_spaceperm \
728339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_lite/tpmtest_testsetup \
729339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	tests/tpm_lite/tpmtest_timing \
730339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson        tests/tpm_lite/tpmtest_writelimit
731eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
732eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTEST_NAMES += ${TLCL_TEST_NAMES}
733eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
734339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson# Finally
735339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonTEST_BINS = $(addprefix ${BUILD}/,${TEST_NAMES})
73680872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += $(addsuffix .o,${TEST_BINS})
737eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
7386f1b82ac14f341d9733d6e95d518b3ee352002efRandall SpanglerTEST2X_BINS = $(addprefix ${BUILD}/,${TEST2X_NAMES})
739aaaff86467823e0d3d29c383402275eeae481256Randall SpanglerTEST20_BINS = $(addprefix ${BUILD}/,${TEST20_NAMES})
740108d991c678f80c99967bd07035de7418c81a072Randall SpanglerTEST21_BINS = $(addprefix ${BUILD}/,${TEST21_NAMES})
741aaaff86467823e0d3d29c383402275eeae481256Randall Spangler
742e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler# Directory containing test keys
743e061a256549607a56d771eb8ddae5d0dd90d519cRandall SpanglerTEST_KEYS = ${SRC_RUN}/tests/testkeys
744eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
745eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
746eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson##############################################################################
747eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Finally, some targets. High-level ones first.
748eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
749eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Create output directories if necessary.  Do this via explicit shell commands
750eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# so it happens before trying to generate/include dependencies.
751eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonSUBDIRS := firmware host cgpt utility futility tests tests/tpm_lite
752eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson_dir_create := $(foreach d, \
753eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	$(shell find ${SUBDIRS} -name '*.c' -exec  dirname {} \; | sort -u), \
754eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	$(shell [ -d ${BUILD}/${d} ] || mkdir -p ${BUILD}/${d}))
755eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
756eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
757eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Default target.
758eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: all
75906eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardsonall: fwlib fwlib2x fwlib20 fwlib21 \
760aaaff86467823e0d3d29c383402275eeae481256Randall Spangler	$(if ${FIRMWARE_ARCH},,host_stuff) \
761786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	$(if ${COV},coverage)
762eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
763eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Host targets
764eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: host_stuff
76506eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardsonhost_stuff: utillib hostlib cgpt utils futil tests utillib21
766eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
767eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: clean
768eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonclean:
769eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}/bin/rm -rf ${BUILD}
770eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
771eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: install
77207d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyeninstall: cgpt_install utils_install signing_install futil_install \
77307d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen	pc_files_install
774eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
775d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen.PHONY: install_mtd
776d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyeninstall_mtd: install cgpt_wrapper_install
777d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen
7783e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardson.PHONY: install_for_test
7793e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardsoninstall_for_test: override DESTDIR = ${TEST_INSTALL_DIR}
7803e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardsoninstall_for_test: install
7813e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardson
782eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Don't delete intermediate object files
783eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.SECONDARY:
784eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
785eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
786eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Firmware library
787eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
788eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM-specific flags.  These depend on the particular TPM we're targeting for.
789eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# They are needed here only for compiling parts of the firmware code into
790eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# user-level tests.
791eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
792eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM_BLOCKING_CONTINUESELFTEST is defined if TPM_ContinueSelfTest blocks until
793eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# the self test has completed.
794eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
79545cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DTPM_BLOCKING_CONTINUESELFTEST
796eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
797eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM_MANUAL_SELFTEST is defined if the self test must be started manually
798eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# (with a call to TPM_ContinueSelfTest) instead of starting automatically at
799eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# power on.
800eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson#
801eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# We sincerely hope that TPM_BLOCKING_CONTINUESELFTEST and TPM_MANUAL_SELFTEST
802eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# are not both defined at the same time.  (See comment in code.)
803eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
804eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# CFLAGS += -DTPM_MANUAL_SELFTEST
805eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
806eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH},i386)
807eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Unrolling loops in cryptolib makes it faster
80845cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DUNROLL_LOOPS
80906eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson${FWLIB2X_OBJS}: CFLAGS += -DUNROLL_LOOPS
810aaaff86467823e0d3d29c383402275eeae481256Randall Spangler${FWLIB20_OBJS}: CFLAGS += -DUNROLL_LOOPS
811a5b69b02e039d7267390fea10266d45e14630559Randall Spangler${FWLIB21_OBJS}: CFLAGS += -DUNROLL_LOOPS
812eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
813eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Workaround for coreboot on x86, which will power off asynchronously
814eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# without giving us a chance to react. This is not an example of the Right
815eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Way to do things. See chrome-os-partner:7689, and the commit message
816eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# that made this change.
81745cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DSAVE_LOCALE_IMMEDIATELY
818eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
819eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# On x86 we don't actually read the GBB data into RAM until it is needed.
820eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Therefore it makes sense to cache it rather than reading it each time.
821eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Enable this feature.
82245cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DCOPY_BMP_DATA
823eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
824eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
825527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glassifdef REGION_READ
826527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass${FWLIB_OBJS}: CFLAGS += -DREGION_READ
827527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glassendif
828527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass
829eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH},)
830eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Disable rollback TPM when compiling locally, since otherwise
831eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# load_kernel_test attempts to talk to the TPM.
83245cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DDISABLE_ROLLBACK_TPM
833eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
834eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
8356f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler${FWLIB20_OBJS}: INCLUDES += -Ifirmware/lib20/include
836108d991c678f80c99967bd07035de7418c81a072Randall Spangler${FWLIB21_OBJS}: INCLUDES += -Ifirmware/lib21/include
837108d991c678f80c99967bd07035de7418c81a072Randall Spangler
838a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson# Linktest ensures firmware lib doesn't rely on outside libraries
839a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${BUILD}/firmware/linktest/main_vbinit: ${VBINIT_OBJS}
84093943266c597ad66300445a04afa01270f2b5763Randall Spangler${BUILD}/firmware/linktest/main_vbinit: OBJS = ${VBINIT_OBJS}
84180872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/firmware/linktest/main_vbinit.o
842a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${BUILD}/firmware/linktest/main_vbsf: ${VBSF_OBJS}
84393943266c597ad66300445a04afa01270f2b5763Randall Spangler${BUILD}/firmware/linktest/main_vbsf: OBJS = ${VBSF_OBJS}
84480872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/firmware/linktest/main_vbsf.o
845a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${BUILD}/firmware/linktest/main: ${FWLIB}
846a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${BUILD}/firmware/linktest/main: LIBS = ${FWLIB}
84780872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/firmware/linktest/main.o
84893943266c597ad66300445a04afa01270f2b5763Randall Spangler
849d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardson.PHONY: fwlinktest
850d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardsonfwlinktest: \
85193943266c597ad66300445a04afa01270f2b5763Randall Spangler	${BUILD}/firmware/linktest/main_vbinit \
85293943266c597ad66300445a04afa01270f2b5763Randall Spangler	${BUILD}/firmware/linktest/main_vbsf \
85393943266c597ad66300445a04afa01270f2b5763Randall Spangler	${BUILD}/firmware/linktest/main
85493943266c597ad66300445a04afa01270f2b5763Randall Spangler
855eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: fwlib
856a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardsonfwlib: $(if ${FIRMWARE_ARCH},${FWLIB},fwlinktest)
857eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
858a5b69b02e039d7267390fea10266d45e14630559Randall Spangler${FWLIB}: ${FWLIB_OBJS}
859c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    RM            $(subst ${BUILD}/,,$@)\n"
860a5b69b02e039d7267390fea10266d45e14630559Randall Spangler	${Q}rm -f $@
861c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    AR            $(subst ${BUILD}/,,$@)\n"
862a5b69b02e039d7267390fea10266d45e14630559Randall Spangler	${Q}ar qc $@ $^
863a5b69b02e039d7267390fea10266d45e14630559Randall Spangler
8646f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler.PHONY: fwlib2x
8656f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spanglerfwlib2x: ${FWLIB2X}
8666f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler
86706eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson${FWLIB2X}: ${FWLIB2X_OBJS}
868c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    RM            $(subst ${BUILD}/,,$@)\n"
8696f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	${Q}rm -f $@
870c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    AR            $(subst ${BUILD}/,,$@)\n"
8716f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	${Q}ar qc $@ $^
8726f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler
87306eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson.PHONY: fwlib20
87406eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardsonfwlib20: ${FWLIB20}
875786acdabcc15f023330d7c628aca9679e757a238Randall Spangler
87606eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson${FWLIB20}: ${FWLIB2X_OBJS} ${FWLIB20_OBJS}
877c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    RM            $(subst ${BUILD}/,,$@)\n"
878eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}rm -f $@
879c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    AR            $(subst ${BUILD}/,,$@)\n"
880eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}ar qc $@ $^
881eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
882a5b69b02e039d7267390fea10266d45e14630559Randall Spangler.PHONY: fwlib21
883a5b69b02e039d7267390fea10266d45e14630559Randall Spanglerfwlib21: ${FWLIB21}
884a5b69b02e039d7267390fea10266d45e14630559Randall Spangler
88506eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson${FWLIB21}: ${FWLIB2X_OBJS} ${FWLIB21_OBJS}
886c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    RM            $(subst ${BUILD}/,,$@)\n"
887786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	${Q}rm -f $@
888c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    AR            $(subst ${BUILD}/,,$@)\n"
889786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	${Q}ar qc $@ $^
890786acdabcc15f023330d7c628aca9679e757a238Randall Spangler
891eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
892782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# Host library(s)
893eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
894782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# Link tests for local utilities
895782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${BUILD}/host/linktest/main: ${UTILLIB}
896782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${BUILD}/host/linktest/main: LIBS = ${UTILLIB}
89780872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/host/linktest/main.o
898782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
899782990277ac7d6730db4c43c2b5632de93396921Bill Richardson.PHONY: utillib
900782990277ac7d6730db4c43c2b5632de93396921Bill Richardsonutillib: ${UTILLIB} \
901782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	${BUILD}/host/linktest/main
902eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
903eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: better way to make .a than duplicating this recipe each time?
904aaaff86467823e0d3d29c383402275eeae481256Randall Spangler${UTILLIB}: ${UTILLIB_OBJS} ${FWLIB_OBJS}
905c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    RM            $(subst ${BUILD}/,,$@)\n"
906aaaff86467823e0d3d29c383402275eeae481256Randall Spangler	${Q}rm -f $@
907c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    AR            $(subst ${BUILD}/,,$@)\n"
908aaaff86467823e0d3d29c383402275eeae481256Randall Spangler	${Q}ar qc $@ $^
909aaaff86467823e0d3d29c383402275eeae481256Randall Spangler
910a5b69b02e039d7267390fea10266d45e14630559Randall Spangler.PHONY: utillib21
911a5b69b02e039d7267390fea10266d45e14630559Randall Spanglerutillib21: ${UTILLIB21}
912aaaff86467823e0d3d29c383402275eeae481256Randall Spangler
913108d991c678f80c99967bd07035de7418c81a072Randall Spangler${UTILLIB21}: INCLUDES += -Ihost/lib21/include -Ifirmware/lib21/include
91406eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson${UTILLIB21}: ${UTILLIB21_OBJS} ${FWLIB2X_OBJS} ${FWLIB21_OBJS}
915c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    RM            $(subst ${BUILD}/,,$@)\n"
916782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	${Q}rm -f $@
917c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    AR            $(subst ${BUILD}/,,$@)\n"
918782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	${Q}ar qc $@ $^
919782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
920782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
921782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# Link tests for external repos
922782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${BUILD}/host/linktest/extern: ${HOSTLIB}
923782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${BUILD}/host/linktest/extern: LIBS = ${HOSTLIB}
924782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${BUILD}/host/linktest/extern: LDLIBS += -static
92580872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/host/linktest/extern.o
926782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
927782990277ac7d6730db4c43c2b5632de93396921Bill Richardson.PHONY: hostlib
928782990277ac7d6730db4c43c2b5632de93396921Bill Richardsonhostlib: ${HOSTLIB} \
929782990277ac7d6730db4c43c2b5632de93396921Bill Richardson	${BUILD}/host/linktest/extern
930782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
931782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# TODO: better way to make .a than duplicating this recipe each time?
932782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${HOSTLIB}: ${HOSTLIB_OBJS}
933c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    RM            $(subst ${BUILD}/,,$@)\n"
934eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}rm -f $@
935c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    AR            $(subst ${BUILD}/,,$@)\n"
936eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}ar qc $@ $^
937eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
93881a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson
93981a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson# Ugh. This is a very cut-down version of HOSTLIB just for the installer.
94081a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson.PHONY: tinyhostlib
94181a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardsontinyhostlib: ${TINYHOSTLIB}
94281a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	${Q}cp -f ${TINYHOSTLIB} ${HOSTLIB}
94381a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson
94481a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson${TINYHOSTLIB}: ${TINYHOSTLIB_OBJS}
945c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    RM            $(subst ${BUILD}/,,$@)\n"
94681a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	${Q}rm -f $@
947c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    AR            $(subst ${BUILD}/,,$@)\n"
94881a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson	${Q}ar qc $@ $^
94981a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson
950eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
951eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# CGPT library and utility
952eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
953d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen.PHONY: cgpt_wrapper
954d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyencgpt_wrapper: ${CGPT_WRAPPER}
955d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen
956d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen${CGPT_WRAPPER}: ${CGPT_WRAPPER_OBJS} ${UTILLIB}
957d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen	@$(PRINTF) "    LD            $(subst ${BUILD}/,,$@)\n"
958d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen	${Q}${LD} -o ${CGPT_WRAPPER} ${CFLAGS} $^
959d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen
960eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: cgpt
961d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyencgpt: ${CGPT} ${CGPT_WRAPPER}
962eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
963eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${CGPT}: LDFLAGS += -static
964eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${CGPT}: LDLIBS += -luuid
965eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
966782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${CGPT}: ${CGPT_OBJS} ${UTILLIB}
967c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    LDcgpt        $(subst ${BUILD}/,,$@)\n"
9686db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson	${Q}${LD} -o ${CGPT} ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS}
969eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
970eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: cgpt_install
971eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsoncgpt_install: ${CGPT}
972c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    INSTALL       CGPT\n"
973c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	${Q}mkdir -p ${UB_DIR}
974c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	${Q}${INSTALL} -t ${UB_DIR} $^
975eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
976d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen.PHONY: cgpt_wrapper_install
977d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyencgpt_wrapper_install: cgpt_install ${CGPT_WRAPPER}
978d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen	@$(PRINTF) "    INSTALL       cgpt_wrapper\n"
979d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen	${Q}${INSTALL} -t ${UB_DIR} ${CGPT_WRAPPER}
980d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen	${Q}mv ${UB_DIR}/$(notdir ${CGPT}) \
981d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen		${UB_DIR}/$(notdir ${CGPT}).bin
982d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen	${Q}mv ${UB_DIR}/$(notdir ${CGPT_WRAPPER}) \
983d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen		${UB_DIR}/$(notdir ${CGPT})
984d1236e4be6a7fe1c2b132ca8f63a513949d59775Nam T. Nguyen
985eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
986eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Utilities
987eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
988eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# These have their own headers too.
9890f6679e8582219b40e2ab5485992827a92c18bcdBill Richardson${BUILD}/utility/%: INCLUDES += -Iutility/include
9900f6679e8582219b40e2ab5485992827a92c18bcdBill Richardson
9910f6679e8582219b40e2ab5485992827a92c18bcdBill Richardson${UTIL_BINS} ${UTIL_BINS_STATIC}: ${UTILLIB}
9920f6679e8582219b40e2ab5485992827a92c18bcdBill Richardson${UTIL_BINS} ${UTIL_BINS_STATIC}: LIBS = ${UTILLIB}
993eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
994eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Utilities for auto-update toolkits must be statically linked.
995eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${UTIL_BINS_STATIC}: LDFLAGS += -static
996eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
997a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson
998acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: utils
999c7c6e5d2f7076fe512b692411f0d05d4bf76d91fBill Richardsonutils: ${UTIL_BINS} ${UTIL_SCRIPTS}
1000eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}cp -f ${UTIL_SCRIPTS} ${BUILD}/utility
1001eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}chmod a+rx $(patsubst %,${BUILD}/%,${UTIL_SCRIPTS})
1002826db09fcec194951e1dc71002d6a92620fbb46bBill Richardson
1003acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: utils_install
1004cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardsonutils_install: ${UTIL_BINS} ${UTIL_SCRIPTS} ${UTIL_DEFAULTS}
1005c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    INSTALL       UTILS\n"
1006c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	${Q}mkdir -p ${UB_DIR}
1007c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	${Q}${INSTALL} -t ${UB_DIR} ${UTIL_BINS} ${UTIL_SCRIPTS}
1008cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson	${Q}mkdir -p ${DF_DIR}
1009cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson	${Q}${INSTALL} -t ${DF_DIR} -m 'u=rw,go=r,a-s' ${UTIL_DEFAULTS}
1010c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson
1011c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# And some signing stuff for the target
1012c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson.PHONY: signing_install
1013c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonsigning_install: ${SIGNING_SCRIPTS} ${SIGNING_SCRIPTS_DEV} ${SIGNING_COMMON}
1014c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    INSTALL       SIGNING\n"
10156f3961507e73f90cec665896dece884e86be560aBill Richardson	${Q}mkdir -p ${UB_DIR} ${VB_DIR}
1016c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson	${Q}${INSTALL} -t ${UB_DIR} ${SIGNING_SCRIPTS}
10176f3961507e73f90cec665896dece884e86be560aBill Richardson	${Q}${INSTALL} -t ${VB_DIR} ${SIGNING_SCRIPTS_DEV}
10186f3961507e73f90cec665896dece884e86be560aBill Richardson	${Q}${INSTALL} -t ${VB_DIR} -m 'u=rw,go=r,a-s' ${SIGNING_COMMON}
10195d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1020eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
1021eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# new Firmware Utility
10225d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1023eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: futil
10246db8c75021e2edfa400ae707a8544d041e3c415fBill Richardsonfutil: ${FUTIL_STATIC_BIN} ${FUTIL_BIN}
10256db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson
102606eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson${FUTIL_STATIC_BIN}: ${FUTIL_STATIC_OBJS} ${UTILLIB}
1027c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    LD            $(subst ${BUILD}/,,$@)\n"
10286db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson	${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} -static $^ ${LDLIBS}
10295d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1030b84b81dc265a766a968bf126905447d442558218Bill Richardson${FUTIL_BIN}: LDLIBS += ${CRYPTO_LIBS}
103106eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardson${FUTIL_BIN}: ${FUTIL_OBJS} ${UTILLIB}
1032c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    LD            $(subst ${BUILD}/,,$@)\n"
10336db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson	${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS}
10345d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1035eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: futil_install
1036efa8756c5e7068e57f5e98f0e7f2f42fb8d969d6Bill Richardsonfutil_install: ${FUTIL_BIN} ${FUTIL_STATIC_BIN}
1037c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    INSTALL       futility\n"
10386f3961507e73f90cec665896dece884e86be560aBill Richardson	${Q}mkdir -p ${UB_DIR}
10396f3961507e73f90cec665896dece884e86be560aBill Richardson	${Q}${INSTALL} -t ${UB_DIR} ${FUTIL_BIN} ${FUTIL_STATIC_BIN}
1040a1d9fe6eecf82540d31d34bba988e4838d295302Bill Richardson	${Q}for prog in ${FUTIL_SYMLINKS}; do \
10416f3961507e73f90cec665896dece884e86be560aBill Richardson		ln -sf futility "${UB_DIR}/$$prog"; done
10425d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1043eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
10445d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Utility to generate TLCL structure definition header file.
10455d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1046acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/utility/tlcl_generator: CFLAGS += -fpack-struct
10475d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
10485d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerSTRUCTURES_TMP=${BUILD}/tlcl_structures.tmp
10495d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerSTRUCTURES_SRC=firmware/lib/tpm_lite/include/tlcl_structures.h
10505d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1051acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: update_tlcl_structures
10525d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerupdate_tlcl_structures: ${BUILD}/utility/tlcl_generator
1053c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    Rebuilding TLCL structures\n"
1054eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${BUILD}/utility/tlcl_generator > ${STRUCTURES_TMP}
1055eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}cmp -s ${STRUCTURES_TMP} ${STRUCTURES_SRC} || \
10565d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler		( echo "%% Updating structures.h %%" && \
1057eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson		  cp ${STRUCTURES_TMP} ${STRUCTURES_SRC} )
10585d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1059eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
10605d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Tests
10615d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1062eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: tests
1063eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontests: ${TEST_BINS}
10645d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1065782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${TEST_BINS}: ${UTILLIB} ${TESTLIB}
1066339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson${TEST_BINS}: INCLUDES += -Itests
1067efa37b87f2b4cd4b4f515e96201502ae0408cec7Randall Spangler${TEST_BINS}: LIBS = ${TESTLIB} ${UTILLIB}
10685d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
10696f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler${TEST2X_BINS}: ${FWLIB2X}
10706f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler${TEST2X_BINS}: LIBS += ${FWLIB2X}
10716f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler
1072108d991c678f80c99967bd07035de7418c81a072Randall Spangler${TEST20_BINS}: ${FWLIB20}
10736f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler${TEST20_BINS}: INCLUDES += -Ifirmware/lib20/include
1074108d991c678f80c99967bd07035de7418c81a072Randall Spangler${TEST20_BINS}: LIBS += ${FWLIB20}
1075108d991c678f80c99967bd07035de7418c81a072Randall Spangler
1076108d991c678f80c99967bd07035de7418c81a072Randall Spangler${TEST21_BINS}: ${UTILLIB21}
1077108d991c678f80c99967bd07035de7418c81a072Randall Spangler${TEST21_BINS}: INCLUDES += -Ihost/lib21/include -Ifirmware/lib21/include
1078108d991c678f80c99967bd07035de7418c81a072Randall Spangler${TEST21_BINS}: LIBS += ${UTILLIB21}
1079aaaff86467823e0d3d29c383402275eeae481256Randall Spangler
1080eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${TESTLIB}: ${TESTLIB_OBJS}
1081c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    RM            $(subst ${BUILD}/,,$@)\n"
1082eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}rm -f $@
1083c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    AR            $(subst ${BUILD}/,,$@)\n"
1084eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}ar qc $@ $^
10855d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
10865d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1087eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
1088eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Generic build rules. LIBS and OBJS can be overridden to tweak the generic
1089eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# rules for specific targets.
10905d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1091eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%: ${BUILD}/%.o ${OBJS} ${LIBS}
1092c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    LD            $(subst ${BUILD}/,,$@)\n"
10936db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson	${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $< ${OBJS} ${LIBS} ${LDLIBS}
1094eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1095eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%.o: %.c
1096c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    CC            $(subst ${BUILD}/,,$@)\n"
1097eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1098eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1099e08ee28548934e933733babf0bc0c418142d095dAlex Deymo${BUILD}/%.o: ${BUILD}/%.c
1100c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    CC            $(subst ${BUILD}/,,$@)\n"
1101e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1102e08ee28548934e933733babf0bc0c418142d095dAlex Deymo
1103eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Rules to recompile a single source file for library and test
1104eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: is there a tidier way to do this?
1105eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_lib.o: CFLAGS += -DFOR_LIBRARY
1106eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_lib.o: %.c
1107c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    CC-for-lib    $(subst ${BUILD}/,,$@)\n"
1108eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1109eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1110eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_test.o: CFLAGS += -DFOR_TEST
1111eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_test.o: %.c
1112c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    CC-for-test   $(subst ${BUILD}/,,$@)\n"
1113eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1114eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1115eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: C++ files don't belong in vboot reference at all.  Convert to C.
1116eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%.o: %.cc
1117c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    CXX           $(subst ${BUILD}/,,$@)\n"
1118eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}${CXX} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1119eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1120eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ----------------------------------------------------------------------------
1121eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Here are the special tweaks to the generic rules.
1122eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1123cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson# Always create the defaults file, since it depends on input variables
1124cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson.PHONY: ${UTIL_DEFAULTS}
1125cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson${UTIL_DEFAULTS}:
1126c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    CREATE        $(subst ${BUILD}/,,$@)\n"
1127cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson	${Q}rm -f $@
1128cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson	${Q}mkdir -p $(dir $@)
1129cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson	${Q}echo '# Generated file. Do not edit.' > $@.tmp
1130cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson	${Q}echo "DEV_DEBUG_FORCE=${DEV_DEBUG_FORCE}" >> $@.tmp
1131cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson	${Q}mv -f $@.tmp $@
1132cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson
1133eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Some utilities need external crypto functions
1134782990277ac7d6730db4c43c2b5632de93396921Bill RichardsonCRYPTO_LIBS := $(shell ${PKG_CONFIG} --libs libcrypto)
1135782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
1136eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/dumpRSAPublicKey: LDLIBS += ${CRYPTO_LIBS}
1137eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/pad_digest_utility: LDLIBS += ${CRYPTO_LIBS}
1138eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/signature_digest_utility: LDLIBS += ${CRYPTO_LIBS}
1139eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1140eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/host/linktest/main: LDLIBS += ${CRYPTO_LIBS}
1141eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/vboot_common2_tests: LDLIBS += ${CRYPTO_LIBS}
1142eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/vboot_common3_tests: LDLIBS += ${CRYPTO_LIBS}
11436f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler${BUILD}/tests/vb20_common2_tests: LDLIBS += ${CRYPTO_LIBS}
11446f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler${BUILD}/tests/vb20_common3_tests: LDLIBS += ${CRYPTO_LIBS}
1145a77541f94f731f5f7755264e9b49b7826aa48dfeBill Richardson${BUILD}/tests/verify_kernel: LDLIBS += ${CRYPTO_LIBS}
1146108d991c678f80c99967bd07035de7418c81a072Randall Spangler
1147108d991c678f80c99967bd07035de7418c81a072Randall Spangler${TEST21_BINS}: LDLIBS += ${CRYPTO_LIBS}
1148eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
11490b789c56fc5ff34309e935bab15f130a386a1140Mike FrysingerLZMA_LIBS := $(shell ${PKG_CONFIG} --libs liblzma)
11500b789c56fc5ff34309e935bab15f130a386a1140Mike FrysingerYAML_LIBS := $(shell ${PKG_CONFIG} --libs yaml-0.1)
11510b789c56fc5ff34309e935bab15f130a386a1140Mike Frysinger
1152eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_utility: LD = ${CXX}
11530b789c56fc5ff34309e935bab15f130a386a1140Mike Frysinger${BUILD}/utility/bmpblk_utility: LDLIBS = ${LZMA_LIBS} ${YAML_LIBS}
1154eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1155eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonBMPBLK_UTILITY_DEPS = \
1156eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/utility/bmpblk_util.o \
1157eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/utility/image_types.o \
1158eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/utility/eficompress_for_lib.o \
1159eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/utility/efidecompress_for_lib.o
11601912bbae89b82c10819b01d039e140e39c668fc7Bill Richardson
1161eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_utility: OBJS = ${BMPBLK_UTILITY_DEPS}
1162eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_utility: ${BMPBLK_UTILITY_DEPS}
11631912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BMPBLK_UTILITY_DEPS}
1164eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1165eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_font: OBJS += ${BUILD}/utility/image_types.o
1166eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_font: ${BUILD}/utility/image_types.o
11671912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BUILD}/utility/image_types.o
1168eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1169eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Allow multiple definitions, so tests can mock functions from other libraries
1170eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/%: CFLAGS += -Xlinker --allow-multiple-definition
1171eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/%: LDLIBS += -lrt -luuid
1172eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/%: LIBS += ${TESTLIB}
11735d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
11745d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler${BUILD}/tests/rollback_index2_tests: OBJS += \
117517f8d341099120da78a6ca71165834eefb0960edRandall Spangler	${BUILD}/firmware/lib/rollback_index_for_test.o
1176eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/rollback_index2_tests: \
1177eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/firmware/lib/rollback_index_for_test.o
117880872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/firmware/lib/rollback_index_for_test.o
11795d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1180c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler${BUILD}/tests/tlcl_tests: OBJS += \
1181c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler	${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
1182c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler${BUILD}/tests/tlcl_tests: \
1183c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler	${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
118480872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o
1185c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler
11865d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler${BUILD}/tests/vboot_audio_tests: OBJS += \
118717f8d341099120da78a6ca71165834eefb0960edRandall Spangler	${BUILD}/firmware/lib/vboot_audio_for_test.o
1188eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/vboot_audio_tests: \
1189eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${BUILD}/firmware/lib/vboot_audio_for_test.o
119080872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/firmware/lib/vboot_audio_for_test.o
11915d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1192339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonTLCL_TEST_BINS = $(addprefix ${BUILD}/,${TLCL_TEST_NAMES})
1193eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${TLCL_TEST_BINS}: OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o
1194eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${TLCL_TEST_BINS}: ${BUILD}/tests/tpm_lite/tlcl_tests.o
119580872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o
11965d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1197e08ee28548934e933733babf0bc0c418142d095dAlex Deymo# ----------------------------------------------------------------------------
1198e08ee28548934e933733babf0bc0c418142d095dAlex Deymo# Here are the special rules that don't fit in the generic rules.
1199e08ee28548934e933733babf0bc0c418142d095dAlex Deymo
1200e08ee28548934e933733babf0bc0c418142d095dAlex Deymo# Generates the list of commands defined in futility by running grep in the
1201e08ee28548934e933733babf0bc0c418142d095dAlex Deymo# source files looking for the DECLARE_FUTIL_COMMAND() macro usage.
1202e08ee28548934e933733babf0bc0c418142d095dAlex Deymo${FUTIL_STATIC_CMD_LIST}: ${FUTIL_STATIC_SRCS}
1203e08ee28548934e933733babf0bc0c418142d095dAlex Deymo${FUTIL_CMD_LIST}: ${FUTIL_SRCS}
1204e08ee28548934e933733babf0bc0c418142d095dAlex Deymo${FUTIL_CMD_LIST} ${FUTIL_STATIC_CMD_LIST}:
1205c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    GEN           $(subst ${BUILD}/,,$@)\n"
1206e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}rm -f $@ $@_t $@_commands
1207e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}mkdir -p ${BUILD}/gen
1208779796f57e1e0236ea502248ede2cbea986fca21Bill Richardson	${Q}grep -hoRE '^DECLARE_FUTIL_COMMAND\([^,]+' $^ \
1209e08ee28548934e933733babf0bc0c418142d095dAlex Deymo		| sed 's/DECLARE_FUTIL_COMMAND(\(.*\)/_CMD(\1)/' \
1210e08ee28548934e933733babf0bc0c418142d095dAlex Deymo		| sort >>$@_commands
1211e1486c3234b7dc6fc5b58681b271a65a09141e20Bill Richardson	${Q}./scripts/getversion.sh >> $@_t
1212e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}echo '#define _CMD(NAME) extern const struct' \
1213e08ee28548934e933733babf0bc0c418142d095dAlex Deymo		'futil_cmd_t __cmd_##NAME;' >> $@_t
1214e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}cat $@_commands >> $@_t
1215e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}echo '#undef _CMD' >> $@_t
1216e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}echo '#define _CMD(NAME) &__cmd_##NAME,' >> $@_t
1217e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}echo 'const struct futil_cmd_t *const futil_cmds[] = {' >> $@_t
1218e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}cat $@_commands >> $@_t
1219e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}echo '0};  /* null-terminated */' >> $@_t
1220e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}echo '#undef _CMD' >> $@_t
1221e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}mv $@_t $@
1222e08ee28548934e933733babf0bc0c418142d095dAlex Deymo	${Q}rm -f $@_commands
1223e08ee28548934e933733babf0bc0c418142d095dAlex Deymo
1224eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson##############################################################################
1225eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Targets that exist just to run tests
12265d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
12275d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Frequently-run tests
1228eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: test_targets
122906eb78c0f64c898c8d564b3efbffe349a8ae79b2Bill Richardsontest_targets:: runcgpttests runmisctests run2tests
1230844bce57471153664c78993dab453e87891bb969Randall Spangler
1231eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${MINIMAL},)
1232844bce57471153664c78993dab453e87891bb969Randall Spangler# Bitmap utility isn't compiled for minimal variant
1233feb2518166b1cd181e607c611cbb610f0c7300daBill Richardsontest_targets:: runbmptests runfutiltests
1234844bce57471153664c78993dab453e87891bb969Randall Spangler# Scripts don't work under qemu testing
1235844bce57471153664c78993dab453e87891bb969Randall Spangler# TODO: convert scripts to makefile so they can be called directly
1236eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontest_targets:: runtestscripts
1237844bce57471153664c78993dab453e87891bb969Randall Spanglerendif
1238844bce57471153664c78993dab453e87891bb969Randall Spangler
1239eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: test_setup
12403e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardsontest_setup:: cgpt utils futil tests install_for_test
1241eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1242844bce57471153664c78993dab453e87891bb969Randall Spangler# Qemu setup for cross-compiled tests.  Need to copy qemu binary into the
1243844bce57471153664c78993dab453e87891bb969Randall Spangler# sysroot.
1244eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifneq (${QEMU_ARCH},)
1245eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontest_setup:: qemu_install
1246844bce57471153664c78993dab453e87891bb969Randall Spangler
1247844bce57471153664c78993dab453e87891bb969Randall Spangler.PHONY: qemu_install
1248844bce57471153664c78993dab453e87891bb969Randall Spanglerqemu_install:
1249eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${SYSROOT},)
1250eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	$(error SYSROOT must be set to the top of the target-specific root \
1251eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonwhen cross-compiling for qemu-based tests to run properly.)
1252eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif
1253c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger	@${PRINTF} "    Copying qemu binary.\n"
1254eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}cp -fu /usr/bin/${QEMU_BIN} ${BUILD}/${QEMU_BIN}
1255eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${Q}chmod a+rx ${BUILD}/${QEMU_BIN}
1256844bce57471153664c78993dab453e87891bb969Randall Spanglerendif
1257844bce57471153664c78993dab453e87891bb969Randall Spangler
1258acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runtests
1259a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardsonruntests: test_setup test_targets
12605d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
12615d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Generate test keys
1262acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: genkeys
1263844bce57471153664c78993dab453e87891bb969Randall Spanglergenkeys: utils
12645d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/gen_test_keys.sh
12655d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
12665d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Generate test cases for fuzzing
1267acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: genfuzztestcases
1268a808dc944284e6eba39a8f19ddb46bc61c34de8aRandall Spanglergenfuzztestcases: utils
12695d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/gen_fuzz_test_cases.sh
12705d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1271acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runbmptests
1272eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonrunbmptests: test_setup
1273eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	cd tests/bitmaps && BMPBLK=${BUILD_RUN}/utility/bmpblk_utility \
12745d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler		./TestBmpBlock.py -v
12755d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1276acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runcgpttests
1277eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonruncgpttests: test_setup
1278eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/cgptlib_test
12795d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1280844bce57471153664c78993dab453e87891bb969Randall Spangler.PHONY: runtestscripts
1281eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonruntestscripts: test_setup genfuzztestcases
1282b8ff397674fb98c1d7eea864e7fa571369675131Randall Spangler	tests/load_kernel_tests.sh
1283eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt
1284ab899591808dd3e5f955ab7693b54a83389cd35fNam T. Nguyen	tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt -D 358400
12855d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/run_preamble_tests.sh
12865d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/run_rsa_tests.sh
1287844bce57471153664c78993dab453e87891bb969Randall Spangler	tests/run_vbutil_kernel_arg_tests.sh
12885d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/run_vbutil_tests.sh
1289e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	tests/vb2_rsa_tests.sh
1290539cbc27305b6aef9643adffc3297c7079fe7457Randall Spangler	tests/vb2_firmware_tests.sh
12915d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1292844bce57471153664c78993dab453e87891bb969Randall Spangler.PHONY: runmisctests
1293eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonrunmisctests: test_setup
1294eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/rollback_index2_tests
1295a3eac79f5070747e326da631c1eec155f0389919Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/rollback_index3_tests
1296eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/rsa_utility_tests
1297eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/sha_tests
1298eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/stateful_util_tests
1299c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/tlcl_tests
1300eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/tpm_bootmode_tests
1301eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/utility_string_tests
1302eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/utility_tests
1303eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_devmode_tests
1304eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_firmware_tests
13050714d9de56da3a5c686b26755d15aa6788c727d4Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_init_tests
13060714d9de56da3a5c686b26755d15aa6788c727d4Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel_tests
13077f43669630cb42e40ca6ddc1128eefea8fd339d9Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel2_tests
13087f43669630cb42e40ca6ddc1128eefea8fd339d9Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel3_tests
13097f43669630cb42e40ca6ddc1128eefea8fd339d9Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel4_tests
1310eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/vboot_audio_tests
1311e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_common_tests
1312e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS}
1313e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS}
1314786a5dca74387de5ffdc51ca5a099a4e90f406daRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_display_tests
1315eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/vboot_firmware_tests
131649cb0d3471e768da11fe76b65769bd57dca38bd7Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_kernel_tests
13176dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_nvstorage_test
1318eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson
1319786acdabcc15f023330d7c628aca9679e757a238Randall Spangler.PHONY: run2tests
1320786acdabcc15f023330d7c628aca9679e757a238Randall Spanglerrun2tests: test_setup
1321a7ab8b50b8923afcfd7a9e6181892c4c8a2de250Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_api_tests
1322786acdabcc15f023330d7c628aca9679e757a238Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_common_tests
13233333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_misc_tests
13243333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_nvstorage_tests
1325e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_rsa_utility_tests
13263333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_secdata_tests
1327e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb2_sha_tests
13286f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb20_api_tests
13296f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb20_common_tests
13306f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb20_common2_tests ${TEST_KEYS}
13316f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb20_common3_tests ${TEST_KEYS}
13326f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb20_misc_tests
1333108d991c678f80c99967bd07035de7418c81a072Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb21_api_tests
1334108d991c678f80c99967bd07035de7418c81a072Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb21_common_tests
1335108d991c678f80c99967bd07035de7418c81a072Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb21_common2_tests ${TEST_KEYS}
1336108d991c678f80c99967bd07035de7418c81a072Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb21_misc_tests
1337108d991c678f80c99967bd07035de7418c81a072Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb21_host_fw_preamble_tests ${TEST_KEYS}
1338108d991c678f80c99967bd07035de7418c81a072Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb21_host_key_tests ${TEST_KEYS}
1339108d991c678f80c99967bd07035de7418c81a072Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb21_host_keyblock_tests ${TEST_KEYS}
1340108d991c678f80c99967bd07035de7418c81a072Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb21_host_misc_tests
1341108d991c678f80c99967bd07035de7418c81a072Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb21_host_sig_tests ${TEST_KEYS}
1342786acdabcc15f023330d7c628aca9679e757a238Randall Spangler
1343eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: runfutiltests
13443e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardsonrunfutiltests: test_setup
1345efa8756c5e7068e57f5e98f0e7f2f42fb8d969d6Bill Richardson	tests/futility/run_test_scripts.sh ${TEST_INSTALL_DIR}/bin
1346339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson	${RUNTEST} ${BUILD_RUN}/tests/futility/test_not_really
1347844bce57471153664c78993dab453e87891bb969Randall Spangler
13485d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Run long tests, including all permutations of encryption keys (instead of
1349786a5dca74387de5ffdc51ca5a099a4e90f406daRandall Spangler# just the ones we use) and tests of currently-unused code.
13505d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Not run by automated build.
1351acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runlongtests
1352eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonrunlongtests: test_setup genkeys genfuzztestcases
1353e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS} --all
1354e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS} --all
13556f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb20_common2_tests ${TEST_KEYS} --all
13566f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb20_common3_tests ${TEST_KEYS} --all
1357108d991c678f80c99967bd07035de7418c81a072Randall Spangler	${RUNTEST} ${BUILD_RUN}/tests/vb21_common2_tests ${TEST_KEYS} --all
13585d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/run_preamble_tests.sh --all
13595d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler	tests/run_vbutil_tests.sh --all
13605d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
136178d59bffec45da47b4e8a763186723192dd24f87Bill Richardson# TODO: There were a number of ancient tests that hadn't been run in years.
136278d59bffec45da47b4e8a763186723192dd24f87Bill Richardson# They were removed with https://chromium-review.googlesource.com/#/c/214610/
136378d59bffec45da47b4e8a763186723192dd24f87Bill Richardson# Some day it might be nice to see what they were supposed to do.
13645d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler
1365782990277ac7d6730db4c43c2b5632de93396921Bill Richardson.PHONY: runalltests
1366782990277ac7d6730db4c43c2b5632de93396921Bill Richardsonrunalltests: runtests runfutiltests runlongtests
1367782990277ac7d6730db4c43c2b5632de93396921Bill Richardson
136859d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler# Code coverage
136959d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler.PHONY: coverage_init
137059d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage_init: test_setup
137159d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	rm -f ${COV_INFO}*
137259d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	lcov -c -i -d . -b . -o ${COV_INFO}.initial
137359d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler
137459d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler.PHONY: coverage_html
137559d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage_html:
137659d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	lcov -c -d . -b . -o ${COV_INFO}.tests
137759d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	lcov -a ${COV_INFO}.initial -a ${COV_INFO}.tests -o ${COV_INFO}.total
137859d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	lcov -r ${COV_INFO}.total '/usr/*' '*/linktest/*' -o ${COV_INFO}.local
137959d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	genhtml ${COV_INFO}.local -o ${BUILD}/coverage
1380d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardson# Generate addtional coverage stats just for firmware subdir, because the stats
1381d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardson# for the whole project don't include subdirectory summaries. This will print
1382d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardson# the summary for just the firmware sources.
138349cb0d3471e768da11fe76b65769bd57dca38bd7Randall Spangler	lcov -r ${COV_INFO}.local '*/stub/*' -o ${COV_INFO}.nostub
138449cb0d3471e768da11fe76b65769bd57dca38bd7Randall Spangler	lcov -e ${COV_INFO}.nostub '${SRCDIR}/firmware/*' \
138559d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler		-o ${COV_INFO}.firmware
138659d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler
138759d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler.PHONY: coverage
138859d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglerifeq (${COV},)
138959d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage:
139059d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler	$(error Build coverage like this: make clean && COV=1 make)
139159d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglerelse
139259d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage: coverage_init runtests coverage_html
139359d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglerendif
13941912bbae89b82c10819b01d039e140e39c668fc7Bill Richardson
13951912bbae89b82c10819b01d039e140e39c668fc7Bill Richardson# Include generated dependencies
13961912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_DEPS += ${ALL_OBJS:%.o=%.o.d}
139780872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_DEPS += ${TEST_OBJS:%.o=%.o.d}
139804d98e399d034656770e0049613d09ef3ea6d2d0Bill Richardson-include ${ALL_DEPS}
139904d98e399d034656770e0049613d09ef3ea6d2d0Bill Richardson-include ${TEST_DEPS}
140080872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson
140180872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson# We want to use only relative paths in cscope.files, especially since the
140280872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson# paths inside and outside the chroot are different.
140380872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonSRCDIRPAT=$(subst /,\/,${SRCDIR}/)
140480872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson
14058db64da0926e95c4cc19145e911aa270e06a83c0Bill Richardson# Note: vboot 2.0 is deprecated, so don't index those files
140680872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson${BUILD}/cscope.files: test_setup
140780872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson	${Q}rm -f $@
140880872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson	${Q}cat ${ALL_DEPS} | tr -d ':\\' | tr ' ' '\012' | \
14098db64da0926e95c4cc19145e911aa270e06a83c0Bill Richardson		grep -v /lib20/ | \
141080872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson		sed -e "s/${SRCDIRPAT}//" | \
141180872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson		egrep '\.[chS]$$' | sort | uniq > $@
141280872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson
141380872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardsoncmd_etags = etags -o ${BUILD}/TAGS $(shell cat ${BUILD}/cscope.files)
141480872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardsoncmd_ctags = ctags -o ${BUILD}/tags $(shell cat ${BUILD}/cscope.files)
141580872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardsonrun_if_prog = $(if $(shell which $(1) 2>/dev/null),$(2),)
141680872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson
141780872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson.PHONY: tags TAGS xrefs
141880872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardsontags TAGS xrefs: ${BUILD}/cscope.files
141980872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson	${Q}\rm -f ${BUILD}/tags ${BUILD}/TAGS
142080872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson	${Q}$(call run_if_prog,etags,${cmd_etags})
142180872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson	${Q}$(call run_if_prog,ctags,${cmd_ctags})
142207d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen
142307d9043da43ddce10406f56a040fb5a240747282Nam T. NguyenPC_FILES = ${PC_IN_FILES:%.pc.in=%.pc}
142407d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen${PC_FILES}: ${PC_IN_FILES}
142507d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen	${Q}sed \
142607d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen		-e 's:@LDLIBS@:${LDLIBS}:' \
142707d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen		-e 's:@LIBDIR@:${LIBDIR}:' \
142807d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen		$< > $@
142907d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen
143007d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen.PHONY: pc_files_install
143107d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyenpc_files_install: ${PC_FILES}
143207d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen	${Q}mkdir -p ${ULP_DIR}
143307d9043da43ddce10406f56a040fb5a240747282Nam T. Nguyen	${Q}${INSTALL} -D -m 0644 $< ${ULP_DIR}/$<
1434