Makefile revision c8c87b3264e02df2842e20866f717607a07c5ab4
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 47feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson 48cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson# Default values 49cfe83a827d40b310003fc6996b9978d8cf301444Bill RichardsonDEV_DEBUG_FORCE= 50cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson 51feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson# Where exactly do the pieces go? 526f3961507e73f90cec665896dece884e86be560aBill Richardson# UB_DIR = utility binary directory 53cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson# DF_DIR = utility defaults directory 546f3961507e73f90cec665896dece884e86be560aBill Richardson# VB_DIR = vboot binary directory for dev-mode-only scripts 55c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonifeq (${MINIMAL},) 566f3961507e73f90cec665896dece884e86be560aBill Richardson# Host install just puts everything where it's told 57efa8756c5e7068e57f5e98f0e7f2f42fb8d969d6Bill RichardsonUB_DIR=${DESTDIR}/bin 58cfe83a827d40b310003fc6996b9978d8cf301444Bill RichardsonDF_DIR=${DESTDIR}/default 59efa8756c5e7068e57f5e98f0e7f2f42fb8d969d6Bill RichardsonVB_DIR=${DESTDIR}/bin 60c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonelse 61efa8756c5e7068e57f5e98f0e7f2f42fb8d969d6Bill Richardson# Target install puts things into different places 626f3961507e73f90cec665896dece884e86be560aBill RichardsonUB_DIR=${DESTDIR}/usr/bin 63cfe83a827d40b310003fc6996b9978d8cf301444Bill RichardsonDF_DIR=${DESTDIR}/etc/default 64c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill RichardsonVB_DIR=${DESTDIR}/usr/share/vboot/bin 65c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonendif 666d696e532c6a0c93ad9b915c59dad4144e6f1b33Simon Glass 67eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Where to install the (exportable) executables for testing? 68eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTEST_INSTALL_DIR = ${BUILD}/install_for_test 69eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 70eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Verbose? Use V=1 71eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${V},) 72eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonQ := @ 73eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif 74eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 75661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass# Quiet? Use QUIET=1 76c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysingerifeq (${QUIET},) 77661ae9e9cbaad430b87b443712d2608f9ce59883Simon GlassPRINTF := printf 78661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glasselse 79661ae9e9cbaad430b87b443712d2608f9ce59883Simon GlassPRINTF := : 80661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glassendif 81661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass 8261a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# Architecture detection 8361a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler_machname := $(shell uname -m) 8461a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall SpanglerHOST_ARCH ?= ${_machname} 8561a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler 8661a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# ARCH and/or FIRMWARE_ARCH are defined by the Chromium OS ebuild. 8761a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# Pick a sane target architecture if none is defined. 8861a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerifeq (${ARCH},) 8961a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler ARCH := ${HOST_ARCH} 9061a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${ARCH},i386) 9161a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler override ARCH := x86 9261a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${ARCH},amd64) 9361a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler override ARCH := x86_64 9461a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerendif 9561a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler 9661a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# FIRMWARE_ARCH is only defined by the Chromium OS ebuild if compiling 9761a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# for a firmware target (such as u-boot or depthcharge). It must map 9861a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# to the same consistent set of architectures as the host. 9961a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerifeq (${FIRMWARE_ARCH},i386) 10061a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler override FIRMWARE_ARCH := x86 10161a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${FIRMWARE_ARCH},amd64) 10261a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler override FIRMWARE_ARCH := x86_64 103d96b25d0c0a739d351b8f09b128782ca12b7b0e1Stefan Reinauerelse ifeq (${FIRMWARE_ARCH},armv7) 104d96b25d0c0a739d351b8f09b128782ca12b7b0e1Stefan Reinauer override FIRMWARE_ARCH := arm 10561a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerendif 10661a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler 107b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# Provide default CC and CFLAGS for firmware builds; if you have any -D flags, 108b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# please add them after this point (e.g., -DVBOOT_DEBUG). 10974359b755c4a203df0fe3bf51fc53d5de87d1fbfChe-Liang Chiou# 1106b0003c6381a7e69818b0b34b358c2cfb1393043Che-Liang Chiou# TODO(crosbug.com/16808) We hard-code u-boot's compiler flags here just 1116b0003c6381a7e69818b0b34b358c2cfb1393043Che-Liang Chiou# temporarily. As we are still investigating which flags are necessary for 1126b0003c6381a7e69818b0b34b358c2cfb1393043Che-Liang Chiou# maintaining a compatible ABI, etc. between u-boot and vboot_reference. 11374359b755c4a203df0fe3bf51fc53d5de87d1fbfChe-Liang Chiou# 114b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# As a first step, this makes the setting of CC and CFLAGS here optional, to 115b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# permit a calling script or Makefile to set these. 11674359b755c4a203df0fe3bf51fc53d5de87d1fbfChe-Liang Chiou# 117b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# Flag ordering: arch, then -f, then -m, then -W 118b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassDEBUG_FLAGS := $(if ${DEBUG},-g -O0,-Os) 119b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCOMMON_FLAGS := -nostdinc -pipe \ 120b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass -ffreestanding -fno-builtin -fno-stack-protector \ 121eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson -Werror -Wall -Wstrict-prototypes ${DEBUG_FLAGS} 122b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass 123eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Note: FIRMWARE_ARCH is defined by the Chromium OS ebuild. 124eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH}, arm) 125b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCC ?= armv7a-cros-linux-gnueabi-gcc 126b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCFLAGS ?= -march=armv5 \ 127b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass -fno-common -ffixed-r8 \ 128d50b27d15de8cc9e37410fc52d3184f17e0db5bbDoug Anderson -mfloat-abi=hard -marm -mabi=aapcs-linux -mno-thumb-interwork \ 129eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${COMMON_FLAGS} 13061a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${FIRMWARE_ARCH}, x86) 131b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCC ?= i686-pc-linux-gnu-gcc 132b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# Drop -march=i386 to permit use of SSE instructions 133b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCFLAGS ?= \ 134b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass -ffunction-sections -fvisibility=hidden -fno-strict-aliasing \ 135b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass -fomit-frame-pointer -fno-toplevel-reorder -fno-dwarf2-cfi-asm \ 13646e00e63805f85c05449ce09cd843a18b76ca665Gabe Black -mpreferred-stack-boundary=2 \ 137eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${COMMON_FLAGS} 138eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonelse ifeq (${FIRMWARE_ARCH}, x86_64) 139eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCFLAGS ?= ${COMMON_FLAGS} \ 1408e85e987739281161ece1dbc9ff2b73f3e8e1e35Simon Glass -fvisibility=hidden -fno-strict-aliasing -fomit-frame-pointer 141844bce57471153664c78993dab453e87891bb969Randall Spanglerelse 142eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# FIRMWARE_ARCH not defined; assuming local compile. 143eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCC ?= gcc 144d462101f06e1bf817295a6cdd2b82e7e87eaeef3Bill RichardsonCFLAGS += -DCHROMEOS_ENVIRONMENT -Wall -Werror ${DEBUG_FLAGS} 1458e85e987739281161ece1dbc9ff2b73f3e8e1e35Simon Glassendif 14634be8273e0fb80a6654deab650e581b0dc9046a4Che-Liang Chiou 147eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifneq (${DEBUG},) 148eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCFLAGS += -DVBOOT_DEBUG 149eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif 150844bce57471153664c78993dab453e87891bb969Randall Spangler 151eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${DISABLE_NDEBUG},) 152eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCFLAGS += -DNDEBUG 153eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif 154eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 155feb2518166b1cd181e607c611cbb610f0c7300daBill Richardsonifneq (${FORCE_LOGGING_ON},) 156feb2518166b1cd181e607c611cbb610f0c7300daBill RichardsonCFLAGS += -DFORCE_LOGGING_ON=${FORCE_LOGGING_ON} 157feb2518166b1cd181e607c611cbb610f0c7300daBill Richardsonendif 158feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson 1596014c048131f7c3d055e97c0aaa44494edc4f813Randall Spanglerifneq (${PD_SYNC},) 1606014c048131f7c3d055e97c0aaa44494edc4f813Randall SpanglerCFLAGS += -DPD_SYNC 1616014c048131f7c3d055e97c0aaa44494edc4f813Randall Spanglerendif 1626014c048131f7c3d055e97c0aaa44494edc4f813Randall Spangler 163eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Create / use dependency files 164eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCFLAGS += -MMD -MF $@.d 165eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 166f8f807a5ef00e8d5360fc2c9093bd0b5da8c0507Bertrand SIMONNETifeq (${FIRMWARE_ARCH},) 167f8f807a5ef00e8d5360fc2c9093bd0b5da8c0507Bertrand SIMONNET# Creates position independent code for non firmware target. 168f8f807a5ef00e8d5360fc2c9093bd0b5da8c0507Bertrand SIMONNETCFLAGS += -fPIE 169f8f807a5ef00e8d5360fc2c9093bd0b5da8c0507Bertrand SIMONNETendif 170f8f807a5ef00e8d5360fc2c9093bd0b5da8c0507Bertrand SIMONNET 1710c3ba249abb1dc60f5ebabccf84ff13206440b83Bill Richardson# These are required to access large disks and files on 32-bit systems. 1720c3ba249abb1dc60f5ebabccf84ff13206440b83Bill RichardsonCFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 1730c3ba249abb1dc60f5ebabccf84ff13206440b83Bill Richardson 17459d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler# Code coverage 175eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifneq (${COV},) 176d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardson COV_FLAGS = -O0 --coverage -DCOVERAGE 17759d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler CFLAGS += ${COV_FLAGS} 17859d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler LDFLAGS += ${COV_FLAGS} 17959d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler COV_INFO = ${BUILD}/coverage.info 180eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif 181eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 182eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# And a few more default utilities 183eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonLD = ${CC} 1846df3e33912baf2633ed27fce6fe166d87e2f04a8Bill RichardsonCXX ?= g++ 185eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonPKG_CONFIG ?= pkg-config 186eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 1870b789c56fc5ff34309e935bab15f130a386a1140Mike Frysinger# Static? 1880b789c56fc5ff34309e935bab15f130a386a1140Mike Frysingerifneq (${STATIC},) 1890b789c56fc5ff34309e935bab15f130a386a1140Mike FrysingerLDFLAGS += -static 1900b789c56fc5ff34309e935bab15f130a386a1140Mike FrysingerPKG_CONFIG += --static 1910b789c56fc5ff34309e935bab15f130a386a1140Mike Frysingerendif 1920b789c56fc5ff34309e935bab15f130a386a1140Mike Frysinger 193844bce57471153664c78993dab453e87891bb969Randall Spangler# Determine QEMU architecture needed, if any 194eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${ARCH},${HOST_ARCH}) 195844bce57471153664c78993dab453e87891bb969Randall Spangler # Same architecture; no need for QEMU 196844bce57471153664c78993dab453e87891bb969Randall Spangler QEMU_ARCH := 19761a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${HOST_ARCH}-${ARCH},x86_64-x86) 198844bce57471153664c78993dab453e87891bb969Randall Spangler # 64-bit host can run 32-bit targets directly 199844bce57471153664c78993dab453e87891bb969Randall Spangler QEMU_ARCH := 200844bce57471153664c78993dab453e87891bb969Randall Spanglerelse 201eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson QEMU_ARCH := ${ARCH} 202844bce57471153664c78993dab453e87891bb969Randall Spanglerendif 203844bce57471153664c78993dab453e87891bb969Randall Spangler 204844bce57471153664c78993dab453e87891bb969Randall Spangler# The top of the chroot for qemu must be passed in via the SYSROOT environment 205844bce57471153664c78993dab453e87891bb969Randall Spangler# variable. In the Chromium OS chroot, this is done automatically by the 206844bce57471153664c78993dab453e87891bb969Randall Spangler# ebuild. 207844bce57471153664c78993dab453e87891bb969Randall Spangler 208eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${QEMU_ARCH},) 209844bce57471153664c78993dab453e87891bb969Randall Spangler # Path to build output for running tests is same as for building 210eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson BUILD_RUN = ${BUILD} 211e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler SRC_RUN = ${SRCDIR} 212844bce57471153664c78993dab453e87891bb969Randall Spanglerelse 213844bce57471153664c78993dab453e87891bb969Randall Spangler $(info Using qemu for testing.) 214844bce57471153664c78993dab453e87891bb969Randall Spangler # Path to build output for running tests is different in the chroot 215eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson BUILD_RUN = $(subst ${SYSROOT},,${BUILD}) 216e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler SRC_RUN = $(subst ${SYSROOT},,${SRCDIR}) 217844bce57471153664c78993dab453e87891bb969Randall Spangler 218eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson QEMU_BIN = qemu-${QEMU_ARCH} 219e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler QEMU_RUN = ${BUILD_RUN}/${QEMU_BIN} 220e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler export QEMU_RUN 221287beaed7f8ceff679c57664d4da008c6234edfdRandall Spangler 222e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler RUNTEST = tests/test_using_qemu.sh 223e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spanglerendif 2245d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 225e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spanglerexport BUILD_RUN 2265d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 227eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson############################################################################## 228eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Now we need to describe everything we might want or need to build 229b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass 230eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Everything wants these headers. 2315d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerINCLUDES += \ 2325d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler -Ifirmware/include \ 2335d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler -Ifirmware/lib/include \ 2345d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler -Ifirmware/lib/cgptlib/include \ 2355d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler -Ifirmware/lib/cryptolib/include \ 236786acdabcc15f023330d7c628aca9679e757a238Randall Spangler -Ifirmware/lib/tpm_lite/include \ 237786acdabcc15f023330d7c628aca9679e757a238Randall Spangler -Ifirmware/2lib/include 2380b8f35c6a56a0e645254dd7f07ca68e01c8ee629Bill Richardson 239eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# If we're not building for a specific target, just stub out things like the 240eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM commands and various external functions that are provided by the BIOS. 241eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH},) 2420e6ae29eec7a58eeeeba67356c3a3ee384ba6687Bill RichardsonINCLUDES += -Ihost/include -Ihost/lib/include 2435d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif 2445d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 245782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# Firmware library, used by the other firmware components (depthcharge, 246782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# coreboot, etc.). It doesn't need exporting to some other place; they'll build 247782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# this source tree locally and link to it directly. 248eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonFWLIB = ${BUILD}/vboot_fw.a 2495d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 2506f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler# Smaller firmware library 2516f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler# Stuff common to all vboot 2.x 2526f1b82ac14f341d9733d6e95d518b3ee352002efRandall SpanglerFWLIB2X = ${BUILD}/vboot_fw2x.a 2536f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler# Vboot 2.0 (stuck with this filename due to dependencies in coreboot) 254aaaff86467823e0d3d29c383402275eeae481256Randall SpanglerFWLIB20 = ${BUILD}/vboot_fw2.a 2556f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler# Vboot 2.1 256a5b69b02e039d7267390fea10266d45e14630559Randall SpanglerFWLIB21 = ${BUILD}/vboot_fw21.a 257786acdabcc15f023330d7c628aca9679e757a238Randall Spangler 25893943266c597ad66300445a04afa01270f2b5763Randall Spangler# Firmware library sources needed by VbInit() call 25993943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBINIT_SRCS = \ 2605d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/crc8.c \ 26193943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/utility.c \ 26293943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/vboot_api_init.c \ 26393943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/vboot_common_init.c \ 26493943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/vboot_nvstorage.c \ 265782990277ac7d6730db4c43c2b5632de93396921Bill Richardson firmware/lib/vboot_nvstorage_rollback.c \ 266527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass firmware/lib/region-init.c \ 26793943266c597ad66300445a04afa01270f2b5763Randall Spangler 26893943266c597ad66300445a04afa01270f2b5763Randall Spangler# Additional firmware library sources needed by VbSelectFirmware() call 26993943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_SRCS = \ 2705d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cryptolib/padding.c \ 2715d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cryptolib/rsa.c \ 2725d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cryptolib/rsa_utility.c \ 2735d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cryptolib/sha1.c \ 2745d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cryptolib/sha256.c \ 2755d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cryptolib/sha512.c \ 2765d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cryptolib/sha_utility.c \ 2775d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/stateful_util.c \ 2785d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/vboot_api_firmware.c \ 27993943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/vboot_common.c \ 280527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass firmware/lib/vboot_firmware.c \ 281527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass firmware/lib/region-fw.c \ 28293943266c597ad66300445a04afa01270f2b5763Randall Spangler 28393943266c597ad66300445a04afa01270f2b5763Randall Spangler# Additional firmware library sources needed by VbSelectAndLoadKernel() call 28493943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSLK_SRCS = \ 28593943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/cgptlib/cgptlib.c \ 28693943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/cgptlib/cgptlib_internal.c \ 28793943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/cgptlib/crc32.c \ 2887c2beb08380410ca6847abdac23e11ded2d1b625Dan Ehrenberg firmware/lib/gpt_misc.c \ 28993943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/utility_string.c \ 2905d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/vboot_api_kernel.c \ 2915d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/vboot_audio.c \ 2925d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/vboot_display.c \ 293527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass firmware/lib/vboot_kernel.c \ 294527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass firmware/lib/region-kernel.c \ 2955d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 296786acdabcc15f023330d7c628aca9679e757a238Randall Spangler# Firmware library source needed for smaller library 2 2976f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler# Code common to vboot 2.0 (old structs) and 2.1 (new structs) 298108d991c678f80c99967bd07035de7418c81a072Randall SpanglerFWLIB2_SRCS = \ 299a7ab8b50b8923afcfd7a9e6181892c4c8a2de250Randall Spangler firmware/2lib/2api.c \ 300786acdabcc15f023330d7c628aca9679e757a238Randall Spangler firmware/2lib/2common.c \ 3013333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler firmware/2lib/2crc8.c \ 3023333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler firmware/2lib/2misc.c \ 3033333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler firmware/2lib/2nvstorage.c \ 304e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler firmware/2lib/2rsa.c \ 3053333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler firmware/2lib/2secdata.c \ 306e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler firmware/2lib/2sha1.c \ 307e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler firmware/2lib/2sha256.c \ 308e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler firmware/2lib/2sha512.c \ 309a5b69b02e039d7267390fea10266d45e14630559Randall Spangler firmware/2lib/2sha_utility.c 310a5b69b02e039d7267390fea10266d45e14630559Randall Spangler 311108d991c678f80c99967bd07035de7418c81a072Randall SpanglerFWLIB20_SRCS = \ 3126f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler firmware/lib20/api.c \ 3136f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler firmware/lib20/common.c \ 3146f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler firmware/lib20/misc.c \ 3156f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler firmware/lib20/packed_key.c 316108d991c678f80c99967bd07035de7418c81a072Randall Spangler 317a5b69b02e039d7267390fea10266d45e14630559Randall SpanglerFWLIB21_SRCS = \ 318a5b69b02e039d7267390fea10266d45e14630559Randall Spangler firmware/lib21/api.c \ 319a5b69b02e039d7267390fea10266d45e14630559Randall Spangler firmware/lib21/common.c \ 320a5b69b02e039d7267390fea10266d45e14630559Randall Spangler firmware/lib21/misc.c \ 321a5b69b02e039d7267390fea10266d45e14630559Randall Spangler firmware/lib21/packed_key.c 322786acdabcc15f023330d7c628aca9679e757a238Randall Spangler 323eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Support real TPM unless BIOS sets MOCK_TPM 324eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${MOCK_TPM},) 32593943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBINIT_SRCS += \ 3265d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/rollback_index.c \ 3275d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/tpm_lite/tlcl.c 32893943266c597ad66300445a04afa01270f2b5763Randall Spangler 32993943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_SRCS += \ 33093943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/tpm_bootmode.c 3315d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerelse 33293943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBINIT_SRCS += \ 3335d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/mocked_rollback_index.c \ 3345d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/tpm_lite/mocked_tlcl.c 33593943266c597ad66300445a04afa01270f2b5763Randall Spangler 33693943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_SRCS += \ 33793943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/mocked_tpm_bootmode.c 3385d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif 3395d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 340eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH},) 341eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Include BIOS stubs in the firmware library when compiling for host 34293943266c597ad66300445a04afa01270f2b5763Randall Spangler# TODO: split out other stub funcs too 34393943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBINIT_SRCS += \ 3445d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/stub/tpm_lite_stub.c \ 3455d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/stub/utility_stub.c \ 346527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass firmware/stub/vboot_api_stub_init.c \ 347527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass firmware/stub/vboot_api_stub_region.c 34893943266c597ad66300445a04afa01270f2b5763Randall Spangler 34993943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_SRCS += \ 35093943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/stub/vboot_api_stub_sf.c 35193943266c597ad66300445a04afa01270f2b5763Randall Spangler 35293943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSLK_SRCS += \ 3535d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/stub/vboot_api_stub.c \ 3545dc75d16b6d5cb0ebc677e6572a2559c6157b8e4Dan Ehrenberg firmware/stub/vboot_api_stub_disk.c \ 3555dc75d16b6d5cb0ebc677e6572a2559c6157b8e4Dan Ehrenberg firmware/stub/vboot_api_stub_stream.c 356da2b49cf08a27551fd910626f669910a636378d4Randall Spangler 357108d991c678f80c99967bd07035de7418c81a072Randall SpanglerFWLIB2_SRCS += \ 358da2b49cf08a27551fd910626f669910a636378d4Randall Spangler firmware/2lib/2stub.c 359da2b49cf08a27551fd910626f669910a636378d4Randall Spangler 3605d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif 3615d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 36293943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_SRCS += ${VBINIT_SRCS} 36393943266c597ad66300445a04afa01270f2b5763Randall SpanglerFWLIB_SRCS += ${VBSF_SRCS} ${VBSLK_SRCS} 36493943266c597ad66300445a04afa01270f2b5763Randall Spangler 36593943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBINIT_OBJS = ${VBINIT_SRCS:%.c=${BUILD}/%.o} 36693943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_OBJS = ${VBSF_SRCS:%.c=${BUILD}/%.o} 367a5b69b02e039d7267390fea10266d45e14630559Randall SpanglerALL_OBJS += ${VBINIT_OBJS} ${VBSF_OBJS} 36893943266c597ad66300445a04afa01270f2b5763Randall Spangler 369eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonFWLIB_OBJS = ${FWLIB_SRCS:%.c=${BUILD}/%.o} 370108d991c678f80c99967bd07035de7418c81a072Randall SpanglerFWLIB2_OBJS = ${FWLIB2_SRCS:%.c=${BUILD}/%.o} 371aaaff86467823e0d3d29c383402275eeae481256Randall SpanglerFWLIB20_OBJS = ${FWLIB20_SRCS:%.c=${BUILD}/%.o} 372a5b69b02e039d7267390fea10266d45e14630559Randall SpanglerFWLIB21_OBJS = ${FWLIB21_SRCS:%.c=${BUILD}/%.o} 373108d991c678f80c99967bd07035de7418c81a072Randall SpanglerALL_OBJS += ${FWLIB_OBJS} ${FWLIB2_OBJS} ${FWLIB20_OBJS} ${FWLIB21_OBJS} 3745d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 375782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# Intermediate library for the vboot_reference utilities to link against. 376782990277ac7d6730db4c43c2b5632de93396921Bill RichardsonUTILLIB = ${BUILD}/libvboot_util.a 377108d991c678f80c99967bd07035de7418c81a072Randall SpanglerUTILLIB21 = ${BUILD}/libvboot_util21.a 3785d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 379782990277ac7d6730db4c43c2b5632de93396921Bill RichardsonUTILLIB_SRCS = \ 38081a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_create.c \ 38181a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_add.c \ 38281a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_boot.c \ 38381a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_show.c \ 38481a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_repair.c \ 38581a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_prioritize.c \ 38681a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_common.c \ 3876f3961507e73f90cec665896dece884e86be560aBill Richardson futility/dump_kernel_config_lib.c \ 388eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson host/arch/${ARCH}/lib/crossystem_arch.c \ 3895d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/crossystem.c \ 3905d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/file_keys.c \ 3915d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/fmap.c \ 3925d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/host_common.c \ 3935d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/host_key.c \ 3945d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/host_keyblock.c \ 3955d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/host_misc.c \ 396782990277ac7d6730db4c43c2b5632de93396921Bill Richardson host/lib/util_misc.c \ 3975d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/host_signature.c \ 3986f3961507e73f90cec665896dece884e86be560aBill Richardson host/lib/signature_digest.c 3995d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 400aaaff86467823e0d3d29c383402275eeae481256Randall SpanglerUTILLIB_OBJS = ${UTILLIB_SRCS:%.c=${BUILD}/%.o} 401aaaff86467823e0d3d29c383402275eeae481256Randall SpanglerALL_OBJS += ${UTILLIB_OBJS} 402aaaff86467823e0d3d29c383402275eeae481256Randall Spangler 403a5b69b02e039d7267390fea10266d45e14630559Randall SpanglerUTILLIB21_SRCS += \ 404a5b69b02e039d7267390fea10266d45e14630559Randall Spangler host/lib21/host_fw_preamble.c \ 405a5b69b02e039d7267390fea10266d45e14630559Randall Spangler host/lib21/host_key.c \ 406a5b69b02e039d7267390fea10266d45e14630559Randall Spangler host/lib21/host_keyblock.c \ 407a5b69b02e039d7267390fea10266d45e14630559Randall Spangler host/lib21/host_misc.c \ 408a5b69b02e039d7267390fea10266d45e14630559Randall Spangler host/lib21/host_signature.c 40902e11b323b819140590d99b6af440d36c12d161bRandall Spangler 410a5b69b02e039d7267390fea10266d45e14630559Randall SpanglerUTILLIB21_OBJS = ${UTILLIB21_SRCS:%.c=${BUILD}/%.o} 411a5b69b02e039d7267390fea10266d45e14630559Randall SpanglerALL_OBJS += ${UTILLIB21_OBJS} 412782990277ac7d6730db4c43c2b5632de93396921Bill Richardson 413782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# Externally exported library for some target userspace apps to link with 414782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# (cryptohome, updater, etc.) 415782990277ac7d6730db4c43c2b5632de93396921Bill RichardsonHOSTLIB = ${BUILD}/libvboot_host.a 416782990277ac7d6730db4c43c2b5632de93396921Bill Richardson 417782990277ac7d6730db4c43c2b5632de93396921Bill RichardsonHOSTLIB_SRCS = \ 418782990277ac7d6730db4c43c2b5632de93396921Bill Richardson cgpt/cgpt_add.c \ 419782990277ac7d6730db4c43c2b5632de93396921Bill Richardson cgpt/cgpt_boot.c \ 420782990277ac7d6730db4c43c2b5632de93396921Bill Richardson cgpt/cgpt_common.c \ 421782990277ac7d6730db4c43c2b5632de93396921Bill Richardson cgpt/cgpt_create.c \ 422782990277ac7d6730db4c43c2b5632de93396921Bill Richardson cgpt/cgpt_prioritize.c \ 423782990277ac7d6730db4c43c2b5632de93396921Bill Richardson firmware/lib/cgptlib/cgptlib_internal.c \ 424782990277ac7d6730db4c43c2b5632de93396921Bill Richardson firmware/lib/cgptlib/crc32.c \ 425782990277ac7d6730db4c43c2b5632de93396921Bill Richardson firmware/lib/crc8.c \ 42632a999d2c0e5bf8a1c0f6141d3db77a1dcc6f5afDan Ehrenberg firmware/lib/gpt_misc.c \ 427782990277ac7d6730db4c43c2b5632de93396921Bill Richardson firmware/lib/tpm_lite/tlcl.c \ 428782990277ac7d6730db4c43c2b5632de93396921Bill Richardson firmware/lib/utility_string.c \ 429782990277ac7d6730db4c43c2b5632de93396921Bill Richardson firmware/lib/vboot_nvstorage.c \ 430782990277ac7d6730db4c43c2b5632de93396921Bill Richardson firmware/stub/tpm_lite_stub.c \ 431782990277ac7d6730db4c43c2b5632de93396921Bill Richardson firmware/stub/utility_stub.c \ 43232a999d2c0e5bf8a1c0f6141d3db77a1dcc6f5afDan Ehrenberg firmware/stub/vboot_api_stub_disk.c \ 433782990277ac7d6730db4c43c2b5632de93396921Bill Richardson firmware/stub/vboot_api_stub_init.c \ 43432a999d2c0e5bf8a1c0f6141d3db77a1dcc6f5afDan Ehrenberg firmware/stub/vboot_api_stub_sf.c \ 4356f3961507e73f90cec665896dece884e86be560aBill Richardson futility/dump_kernel_config_lib.c \ 436782990277ac7d6730db4c43c2b5632de93396921Bill Richardson host/arch/${ARCH}/lib/crossystem_arch.c \ 437782990277ac7d6730db4c43c2b5632de93396921Bill Richardson host/lib/crossystem.c \ 4386ee52d9a929d00e871e7316240b54f381146fbc6Nam T. Nguyen host/lib/fmap.c \ 4396f3961507e73f90cec665896dece884e86be560aBill Richardson host/lib/host_misc.c 440782990277ac7d6730db4c43c2b5632de93396921Bill Richardson 441eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonHOSTLIB_OBJS = ${HOSTLIB_SRCS:%.c=${BUILD}/%.o} 4425d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerALL_OBJS += ${HOSTLIB_OBJS} 4435d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 44481a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson# Sigh. For historical reasons, the autoupdate installer must sometimes be a 44581a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson# 32-bit executable, even when everything else is 64-bit. But it only needs a 44681a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson# few functions, so let's just build those. 44781a0b3de707b4e00958faf36f41b8f3d7bac6808Bill RichardsonTINYHOSTLIB = ${BUILD}/libtinyvboot_host.a 44881a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson 44981a0b3de707b4e00958faf36f41b8f3d7bac6808Bill RichardsonTINYHOSTLIB_SRCS = \ 45081a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_add.c \ 45181a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_boot.c \ 45281a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_common.c \ 453782990277ac7d6730db4c43c2b5632de93396921Bill Richardson cgpt/cgpt_create.c \ 454782990277ac7d6730db4c43c2b5632de93396921Bill Richardson cgpt/cgpt_prioritize.c \ 455782990277ac7d6730db4c43c2b5632de93396921Bill Richardson firmware/lib/cgptlib/cgptlib_internal.c \ 456782990277ac7d6730db4c43c2b5632de93396921Bill Richardson firmware/lib/cgptlib/crc32.c \ 45732a999d2c0e5bf8a1c0f6141d3db77a1dcc6f5afDan Ehrenberg firmware/lib/gpt_misc.c \ 4585fed2a667096341160db8643a4a057e328953a1dBill Richardson firmware/lib/utility_string.c \ 45932a999d2c0e5bf8a1c0f6141d3db77a1dcc6f5afDan Ehrenberg firmware/stub/vboot_api_stub_disk.c \ 46032a999d2c0e5bf8a1c0f6141d3db77a1dcc6f5afDan Ehrenberg firmware/stub/vboot_api_stub_sf.c \ 461782990277ac7d6730db4c43c2b5632de93396921Bill Richardson firmware/stub/utility_stub.c \ 462ab899591808dd3e5f955ab7693b54a83389cd35fNam T. Nguyen futility/dump_kernel_config_lib.c 46381a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson 46481a0b3de707b4e00958faf36f41b8f3d7bac6808Bill RichardsonTINYHOSTLIB_OBJS = ${TINYHOSTLIB_SRCS:%.c=${BUILD}/%.o} 465eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 466eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ---------------------------------------------------------------------------- 467eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Now for the userspace binaries 4685d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 4695d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCGPT = ${BUILD}/cgpt/cgpt 4705d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 4715d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCGPT_SRCS = \ 4725d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt.c \ 4735d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_add.c \ 4745d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_boot.c \ 4755d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_common.c \ 4765d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_create.c \ 4775d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_find.c \ 4785d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_legacy.c \ 4795d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_prioritize.c \ 4805d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_repair.c \ 4815d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_show.c \ 4825d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cmd_add.c \ 4835d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cmd_boot.c \ 4845d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cmd_create.c \ 4855d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cmd_find.c \ 4865d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cmd_legacy.c \ 4875d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cmd_prioritize.c \ 4885d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cmd_repair.c \ 4898577b5360ca4c9514d9091ed9aded2bb3193f1f0Nam T. Nguyen cgpt/cmd_show.c 4905d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 491eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCGPT_OBJS = ${CGPT_SRCS:%.c=${BUILD}/%.o} 4925d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerALL_OBJS += ${CGPT_OBJS} 4935d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 494cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson# Utility defaults 495cfe83a827d40b310003fc6996b9978d8cf301444Bill RichardsonUTIL_DEFAULTS = ${BUILD}/default/vboot_reference 4965d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 497eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Scripts to install directly (not compiled) 4985d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerUTIL_SCRIPTS = \ 4995d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler utility/dev_debug_vboot \ 5004d49d34c4ba5aa64ca7aeb26c77e170b2cf2462fBill Richardson utility/enable_dev_usb_boot 5015d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 502c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonifeq (${MINIMAL},) 503c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill RichardsonUTIL_SCRIPTS += \ 5044d49d34c4ba5aa64ca7aeb26c77e170b2cf2462fBill Richardson utility/dev_make_keypair \ 5054d49d34c4ba5aa64ca7aeb26c77e170b2cf2462fBill Richardson utility/vbutil_what_keys 506c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonendif 507c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson 508eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# These utilities should be linked statically. 509eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonUTIL_NAMES_STATIC = \ 5106f3961507e73f90cec665896dece884e86be560aBill Richardson utility/crossystem 511eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 512eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonUTIL_NAMES = ${UTIL_NAMES_STATIC} \ 513339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/tpm_init_temp_fix \ 5140f07867e6fe186ea460afd557e830c1e49f1ff85Duncan Laurie utility/dumpRSAPublicKey \ 5156f3961507e73f90cec665896dece884e86be560aBill Richardson utility/tpmc 5165d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 5176f3961507e73f90cec665896dece884e86be560aBill Richardson# TODO: Do we still need eficompress and efidecompress for anything? 518eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${MINIMAL},) 5195d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerUTIL_NAMES += \ 520339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/bmpblk_font \ 521339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/bmpblk_utility \ 522339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/eficompress \ 523339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/efidecompress \ 524339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/load_kernel_test \ 525339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/pad_digest_utility \ 526339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/signature_digest_utility \ 527339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/verify_data 5285d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif 5295d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 530339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonUTIL_BINS_STATIC := $(addprefix ${BUILD}/,${UTIL_NAMES_STATIC}) 531339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonUTIL_BINS = $(addprefix ${BUILD}/,${UTIL_NAMES}) 5321912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += $(addsuffix .o,${UTIL_BINS} ${UTIL_BINS_STATIC}) 5335d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 534c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson 535c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# Scripts for signing stuff. 536c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill RichardsonSIGNING_SCRIPTS = \ 537c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson utility/tpm-nvsize \ 538c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson utility/chromeos-tpm-recovery 539c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson 540c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# These go in a different place. 541c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill RichardsonSIGNING_SCRIPTS_DEV = \ 542c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson scripts/image_signing/resign_firmwarefd.sh \ 543c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson scripts/image_signing/make_dev_firmware.sh \ 544c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson scripts/image_signing/make_dev_ssd.sh \ 545c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson scripts/image_signing/set_gbb_flags.sh 546c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson 547c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# Installed, but not made executable. 548c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill RichardsonSIGNING_COMMON = scripts/image_signing/common_minimal.sh 549eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 550eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 551eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# The unified firmware utility will eventually replace all the others 552eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonFUTIL_BIN = ${BUILD}/futility/futility 5536db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson# But we still need both static (tiny) and dynamic (with openssl) versions. 5546db8c75021e2edfa400ae707a8544d041e3c415fBill RichardsonFUTIL_STATIC_BIN = ${FUTIL_BIN}_s 555eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 5566f3961507e73f90cec665896dece884e86be560aBill Richardson# These are the executables that are now built in to futility. We'll create 5576f3961507e73f90cec665896dece884e86be560aBill Richardson# symlinks for these so the old names will still work. 5586f3961507e73f90cec665896dece884e86be560aBill Richardson# TODO: Do we still need dev_sign_file for anything? 559a1d9fe6eecf82540d31d34bba988e4838d295302Bill RichardsonFUTIL_SYMLINKS = \ 560e155044a7bbb9b8c6eb751af051726cfe1b411a4Bill Richardson dev_sign_file \ 561e155044a7bbb9b8c6eb751af051726cfe1b411a4Bill Richardson dump_fmap \ 562e155044a7bbb9b8c6eb751af051726cfe1b411a4Bill Richardson dump_kernel_config \ 563e155044a7bbb9b8c6eb751af051726cfe1b411a4Bill Richardson gbb_utility \ 564e155044a7bbb9b8c6eb751af051726cfe1b411a4Bill Richardson vbutil_firmware \ 565e155044a7bbb9b8c6eb751af051726cfe1b411a4Bill Richardson vbutil_kernel \ 566e155044a7bbb9b8c6eb751af051726cfe1b411a4Bill Richardson vbutil_key \ 5676f3961507e73f90cec665896dece884e86be560aBill Richardson vbutil_keyblock 568feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson 5696db8c75021e2edfa400ae707a8544d041e3c415fBill RichardsonFUTIL_STATIC_SRCS = \ 570feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson futility/futility.c \ 57120807b6158b6a43baf0974bc763890888ba1f841Bill Richardson futility/cmd_dump_fmap.c \ 572cf6e78dbd54684ebba0c3bfc2524426f61193416Bill Richardson futility/cmd_gbb_utility.c \ 573cf6e78dbd54684ebba0c3bfc2524426f61193416Bill Richardson futility/misc.c 574eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 5756db8c75021e2edfa400ae707a8544d041e3c415fBill RichardsonFUTIL_SRCS = \ 576c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger ${FUTIL_STATIC_SRCS} \ 5776f3961507e73f90cec665896dece884e86be560aBill Richardson futility/cmd_dev_sign_file.c \ 5786f3961507e73f90cec665896dece884e86be560aBill Richardson futility/cmd_dump_kernel_config.c \ 5792e25e813419f2cd437164929543e452b28b89260Bill Richardson futility/cmd_load_fmap.c \ 580f4f395e1ca724ef8795cfe86a9edbf15f14eacd1Bill Richardson futility/cmd_pcr.c \ 581f318ee205cc8d92def925c6158272da8a63bf1edBill Richardson futility/cmd_show.c \ 582f318ee205cc8d92def925c6158272da8a63bf1edBill Richardson futility/cmd_sign.c \ 5836f3961507e73f90cec665896dece884e86be560aBill Richardson futility/cmd_vbutil_firmware.c \ 5846f3961507e73f90cec665896dece884e86be560aBill Richardson futility/cmd_vbutil_kernel.c \ 585f1dba02034fba650c84cec52630755cd3c063e88Bill Richardson futility/cmd_vbutil_kernel0.c \ 586b84b81dc265a766a968bf126905447d442558218Bill Richardson futility/cmd_vbutil_key.c \ 587b8ff397674fb98c1d7eea864e7fa571369675131Randall Spangler futility/cmd_vbutil_keyblock.c \ 588cf6e78dbd54684ebba0c3bfc2524426f61193416Bill Richardson futility/cmd_verify_kernel.c \ 589f318ee205cc8d92def925c6158272da8a63bf1edBill Richardson futility/traversal.c \ 590f318ee205cc8d92def925c6158272da8a63bf1edBill Richardson futility/vb1_helper.c 5916db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson 592028f468aff976ef5e76f20133c64ec19cb9d1517Randall Spanglerifneq (${VBOOT2},) 593028f468aff976ef5e76f20133c64ec19cb9d1517Randall SpanglerFUTIL_SRCS += \ 594028f468aff976ef5e76f20133c64ec19cb9d1517Randall Spangler futility/cmd_vb2_verify_fw.c 595028f468aff976ef5e76f20133c64ec19cb9d1517Randall Spanglerendif 596028f468aff976ef5e76f20133c64ec19cb9d1517Randall Spangler 597e08ee28548934e933733babf0bc0c418142d095dAlex Deymo# List of commands built in futility and futility_s. 598e08ee28548934e933733babf0bc0c418142d095dAlex DeymoFUTIL_STATIC_CMD_LIST = ${BUILD}/gen/futility_static_cmds.c 599e08ee28548934e933733babf0bc0c418142d095dAlex DeymoFUTIL_CMD_LIST = ${BUILD}/gen/futility_cmds.c 600eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 60191852e7f58d50a031bcb5c02e68473cefb10ebb0Bill Richardson# Workaround for TODO(crbug.com/437107). 60291852e7f58d50a031bcb5c02e68473cefb10ebb0Bill RichardsonFUTIL_STATIC_WORKAROUND_SRCS = firmware/stub/vboot_api_stub_static_sf.c 60391852e7f58d50a031bcb5c02e68473cefb10ebb0Bill Richardson 604e08ee28548934e933733babf0bc0c418142d095dAlex DeymoFUTIL_STATIC_OBJS = ${FUTIL_STATIC_SRCS:%.c=${BUILD}/%.o} \ 60591852e7f58d50a031bcb5c02e68473cefb10ebb0Bill Richardson ${FUTIL_STATIC_WORKAROUND_SRCS:%.c=${BUILD}/%.o} \ 606e08ee28548934e933733babf0bc0c418142d095dAlex Deymo ${FUTIL_STATIC_CMD_LIST:%.c=%.o} 607e08ee28548934e933733babf0bc0c418142d095dAlex DeymoFUTIL_OBJS = ${FUTIL_SRCS:%.c=${BUILD}/%.o} ${FUTIL_CMD_LIST:%.c=%.o} 608eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 609eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonALL_OBJS += ${FUTIL_OBJS} 610eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 611eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 612eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Library of handy test functions. 613eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTESTLIB = ${BUILD}/tests/test.a 614eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 615eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTESTLIB_SRCS = \ 616eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson tests/test_common.c \ 617eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson tests/timer_utils.c \ 618eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson tests/crc32_test.c 619eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 620eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTESTLIB_OBJS = ${TESTLIB_SRCS:%.c=${BUILD}/%.o} 62180872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${TESTLIB_OBJS} 622eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 623eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 624eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# And some compiled tests. 625eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTEST_NAMES = \ 626339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/cgptlib_test \ 627339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/rollback_index2_tests \ 628339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/rollback_index3_tests \ 629339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/rsa_padding_test \ 630339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/rsa_utility_tests \ 631339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/rsa_verify_benchmark \ 632339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/sha_benchmark \ 633339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/sha_tests \ 634339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/stateful_util_tests \ 635339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tlcl_tests \ 636339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_bootmode_tests \ 637339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/utility_string_tests \ 638339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/utility_tests \ 639339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_api_init_tests \ 640339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_api_devmode_tests \ 641339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_api_firmware_tests \ 642339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_api_kernel_tests \ 643339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_api_kernel2_tests \ 644339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_api_kernel3_tests \ 645339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_api_kernel4_tests \ 646339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_audio_tests \ 647339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_common_tests \ 648339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_common2_tests \ 649339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_common3_tests \ 650339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_display_tests \ 651339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_firmware_tests \ 652339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_kernel_tests \ 653339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_nvstorage_test \ 6546f3961507e73f90cec665896dece884e86be560aBill Richardson tests/futility/binary_editor \ 655339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/futility/test_not_really 656eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 657527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glassifdef REGION_READ 658527ba810eff4006cf69579f6b96cb4350cb1e189Simon GlassTEST_NAMES += tests/vboot_region_tests 659527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glassendif 660527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass 6616f1b82ac14f341d9733d6e95d518b3ee352002efRandall SpanglerTEST2X_NAMES = \ 662a7ab8b50b8923afcfd7a9e6181892c4c8a2de250Randall Spangler tests/vb2_api_tests \ 663786acdabcc15f023330d7c628aca9679e757a238Randall Spangler tests/vb2_common_tests \ 6643333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler tests/vb2_misc_tests \ 6653333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler tests/vb2_nvstorage_tests \ 666e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler tests/vb2_rsa_utility_tests \ 6673333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler tests/vb2_secdata_tests \ 668108d991c678f80c99967bd07035de7418c81a072Randall Spangler tests/vb2_sha_tests 669108d991c678f80c99967bd07035de7418c81a072Randall Spangler 6706f1b82ac14f341d9733d6e95d518b3ee352002efRandall SpanglerTEST20_NAMES = \ 6716f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler tests/vb20_api_tests \ 6726f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler tests/vb20_common_tests \ 6736f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler tests/vb20_common2_tests \ 6746f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler tests/vb20_common3_tests \ 6756f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler tests/vb20_misc_tests \ 6766f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler tests/vb20_rsa_padding_tests 6776f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler 678108d991c678f80c99967bd07035de7418c81a072Randall SpanglerTEST21_NAMES = \ 679108d991c678f80c99967bd07035de7418c81a072Randall Spangler tests/vb21_api_tests \ 680108d991c678f80c99967bd07035de7418c81a072Randall Spangler tests/vb21_common_tests \ 681108d991c678f80c99967bd07035de7418c81a072Randall Spangler tests/vb21_common2_tests \ 682108d991c678f80c99967bd07035de7418c81a072Randall Spangler tests/vb21_misc_tests \ 683108d991c678f80c99967bd07035de7418c81a072Randall Spangler tests/vb21_host_fw_preamble_tests \ 684108d991c678f80c99967bd07035de7418c81a072Randall Spangler tests/vb21_host_key_tests \ 685108d991c678f80c99967bd07035de7418c81a072Randall Spangler tests/vb21_host_keyblock_tests \ 686108d991c678f80c99967bd07035de7418c81a072Randall Spangler tests/vb21_host_misc_tests \ 687108d991c678f80c99967bd07035de7418c81a072Randall Spangler tests/vb21_host_sig_tests 688786acdabcc15f023330d7c628aca9679e757a238Randall Spangler 689aaaff86467823e0d3d29c383402275eeae481256Randall Spanglerifneq (${VBOOT2},) 6906f1b82ac14f341d9733d6e95d518b3ee352002efRandall SpanglerTEST_NAMES += ${TEST2X_NAMES} ${TEST20_NAMES} ${TEST21_NAMES} 691786acdabcc15f023330d7c628aca9679e757a238Randall Spanglerendif 692786acdabcc15f023330d7c628aca9679e757a238Randall Spangler 693eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# And a few more... 694339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonTLCL_TEST_NAMES = \ 695339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_lite/tpmtest_earlyextend \ 696339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_lite/tpmtest_earlynvram \ 697339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_lite/tpmtest_earlynvram2 \ 698339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_lite/tpmtest_enable \ 699339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_lite/tpmtest_fastenable \ 700339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_lite/tpmtest_globallock \ 701339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_lite/tpmtest_redefine_unowned \ 702339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_lite/tpmtest_spaceperm \ 703339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_lite/tpmtest_testsetup \ 704339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_lite/tpmtest_timing \ 705339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_lite/tpmtest_writelimit 706eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 707eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTEST_NAMES += ${TLCL_TEST_NAMES} 708eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 709339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson# Finally 710339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonTEST_BINS = $(addprefix ${BUILD}/,${TEST_NAMES}) 71180872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += $(addsuffix .o,${TEST_BINS}) 712eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 7136f1b82ac14f341d9733d6e95d518b3ee352002efRandall SpanglerTEST2X_BINS = $(addprefix ${BUILD}/,${TEST2X_NAMES}) 714aaaff86467823e0d3d29c383402275eeae481256Randall SpanglerTEST20_BINS = $(addprefix ${BUILD}/,${TEST20_NAMES}) 715108d991c678f80c99967bd07035de7418c81a072Randall SpanglerTEST21_BINS = $(addprefix ${BUILD}/,${TEST21_NAMES}) 716aaaff86467823e0d3d29c383402275eeae481256Randall Spangler 717e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler# Directory containing test keys 718e061a256549607a56d771eb8ddae5d0dd90d519cRandall SpanglerTEST_KEYS = ${SRC_RUN}/tests/testkeys 719eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 720eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 721eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson############################################################################## 722eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Finally, some targets. High-level ones first. 723eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 724eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Create output directories if necessary. Do this via explicit shell commands 725eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# so it happens before trying to generate/include dependencies. 726eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonSUBDIRS := firmware host cgpt utility futility tests tests/tpm_lite 727eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson_dir_create := $(foreach d, \ 728eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson $(shell find ${SUBDIRS} -name '*.c' -exec dirname {} \; | sort -u), \ 729eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson $(shell [ -d ${BUILD}/${d} ] || mkdir -p ${BUILD}/${d})) 730eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 731eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 732eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Default target. 733eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: all 734aaaff86467823e0d3d29c383402275eeae481256Randall Spanglerall: fwlib \ 7356f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler $(if ${VBOOT2},fwlib2x fwlib2 fwlib21) \ 736aaaff86467823e0d3d29c383402275eeae481256Randall Spangler $(if ${FIRMWARE_ARCH},,host_stuff) \ 737786acdabcc15f023330d7c628aca9679e757a238Randall Spangler $(if ${COV},coverage) 738eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 739eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Host targets 740eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: host_stuff 741a5b69b02e039d7267390fea10266d45e14630559Randall Spanglerhost_stuff: utillib hostlib cgpt utils futil tests $(if ${VBOOT2},utillib21) 742eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 743eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: clean 744eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonclean: 745eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}/bin/rm -rf ${BUILD} 746eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 747eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: install 748c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsoninstall: cgpt_install utils_install signing_install futil_install 749eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 7503e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardson.PHONY: install_for_test 7513e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardsoninstall_for_test: override DESTDIR = ${TEST_INSTALL_DIR} 7523e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardsoninstall_for_test: install 7533e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardson 754eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Don't delete intermediate object files 755eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.SECONDARY: 756eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 757eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ---------------------------------------------------------------------------- 758eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Firmware library 759eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 760eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM-specific flags. These depend on the particular TPM we're targeting for. 761eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# They are needed here only for compiling parts of the firmware code into 762eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# user-level tests. 763eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 764eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM_BLOCKING_CONTINUESELFTEST is defined if TPM_ContinueSelfTest blocks until 765eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# the self test has completed. 766eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 76745cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DTPM_BLOCKING_CONTINUESELFTEST 768eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 769eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM_MANUAL_SELFTEST is defined if the self test must be started manually 770eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# (with a call to TPM_ContinueSelfTest) instead of starting automatically at 771eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# power on. 772eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# 773eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# We sincerely hope that TPM_BLOCKING_CONTINUESELFTEST and TPM_MANUAL_SELFTEST 774eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# are not both defined at the same time. (See comment in code.) 775eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 776eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# CFLAGS += -DTPM_MANUAL_SELFTEST 777eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 778eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH},i386) 779eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Unrolling loops in cryptolib makes it faster 78045cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DUNROLL_LOOPS 781108d991c678f80c99967bd07035de7418c81a072Randall Spangler${FWLIB2_OBJS}: CFLAGS += -DUNROLL_LOOPS 782aaaff86467823e0d3d29c383402275eeae481256Randall Spangler${FWLIB20_OBJS}: CFLAGS += -DUNROLL_LOOPS 783a5b69b02e039d7267390fea10266d45e14630559Randall Spangler${FWLIB21_OBJS}: CFLAGS += -DUNROLL_LOOPS 784eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 785eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Workaround for coreboot on x86, which will power off asynchronously 786eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# without giving us a chance to react. This is not an example of the Right 787eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Way to do things. See chrome-os-partner:7689, and the commit message 788eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# that made this change. 78945cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DSAVE_LOCALE_IMMEDIATELY 790eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 791eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# On x86 we don't actually read the GBB data into RAM until it is needed. 792eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Therefore it makes sense to cache it rather than reading it each time. 793eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Enable this feature. 79445cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DCOPY_BMP_DATA 795eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif 796eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 797527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glassifdef REGION_READ 798527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass${FWLIB_OBJS}: CFLAGS += -DREGION_READ 799527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glassendif 800527ba810eff4006cf69579f6b96cb4350cb1e189Simon Glass 801eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH},) 802eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Disable rollback TPM when compiling locally, since otherwise 803eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# load_kernel_test attempts to talk to the TPM. 80445cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DDISABLE_ROLLBACK_TPM 805eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif 806eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 8076f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler${FWLIB20_OBJS}: INCLUDES += -Ifirmware/lib20/include 808108d991c678f80c99967bd07035de7418c81a072Randall Spangler${FWLIB21_OBJS}: INCLUDES += -Ifirmware/lib21/include 809108d991c678f80c99967bd07035de7418c81a072Randall Spangler 810a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson# Linktest ensures firmware lib doesn't rely on outside libraries 811a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${BUILD}/firmware/linktest/main_vbinit: ${VBINIT_OBJS} 81293943266c597ad66300445a04afa01270f2b5763Randall Spangler${BUILD}/firmware/linktest/main_vbinit: OBJS = ${VBINIT_OBJS} 81380872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/firmware/linktest/main_vbinit.o 814a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${BUILD}/firmware/linktest/main_vbsf: ${VBSF_OBJS} 81593943266c597ad66300445a04afa01270f2b5763Randall Spangler${BUILD}/firmware/linktest/main_vbsf: OBJS = ${VBSF_OBJS} 81680872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/firmware/linktest/main_vbsf.o 817a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${BUILD}/firmware/linktest/main: ${FWLIB} 818a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${BUILD}/firmware/linktest/main: LIBS = ${FWLIB} 81980872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/firmware/linktest/main.o 82093943266c597ad66300445a04afa01270f2b5763Randall Spangler 821d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardson.PHONY: fwlinktest 822d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardsonfwlinktest: \ 82393943266c597ad66300445a04afa01270f2b5763Randall Spangler ${BUILD}/firmware/linktest/main_vbinit \ 82493943266c597ad66300445a04afa01270f2b5763Randall Spangler ${BUILD}/firmware/linktest/main_vbsf \ 82593943266c597ad66300445a04afa01270f2b5763Randall Spangler ${BUILD}/firmware/linktest/main 82693943266c597ad66300445a04afa01270f2b5763Randall Spangler 827eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: fwlib 828a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardsonfwlib: $(if ${FIRMWARE_ARCH},${FWLIB},fwlinktest) 829eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 830a5b69b02e039d7267390fea10266d45e14630559Randall Spangler${FWLIB}: ${FWLIB_OBJS} 831c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n" 832a5b69b02e039d7267390fea10266d45e14630559Randall Spangler ${Q}rm -f $@ 833c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n" 834a5b69b02e039d7267390fea10266d45e14630559Randall Spangler ${Q}ar qc $@ $^ 835a5b69b02e039d7267390fea10266d45e14630559Randall Spangler 8366f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler.PHONY: fwlib2x 8376f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spanglerfwlib2x: ${FWLIB2X} 8386f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler 8396f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler${FWLIB2X}: ${FWLIB2_OBJS} 840c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n" 8416f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler ${Q}rm -f $@ 842c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n" 8436f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler ${Q}ar qc $@ $^ 8446f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler 8456f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler# TODO: it'd be nice to call this fwlib20, but coreboot expects fwlib2 846786acdabcc15f023330d7c628aca9679e757a238Randall Spangler.PHONY: fwlib2 847aaaff86467823e0d3d29c383402275eeae481256Randall Spanglerfwlib2: ${FWLIB20} 848786acdabcc15f023330d7c628aca9679e757a238Randall Spangler 849108d991c678f80c99967bd07035de7418c81a072Randall Spangler${FWLIB20}: ${FWLIB2_OBJS} ${FWLIB20_OBJS} 850c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n" 851eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}rm -f $@ 852c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n" 853eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}ar qc $@ $^ 854eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 855a5b69b02e039d7267390fea10266d45e14630559Randall Spangler.PHONY: fwlib21 856a5b69b02e039d7267390fea10266d45e14630559Randall Spanglerfwlib21: ${FWLIB21} 857a5b69b02e039d7267390fea10266d45e14630559Randall Spangler 858108d991c678f80c99967bd07035de7418c81a072Randall Spangler${FWLIB21}: ${FWLIB2_OBJS} ${FWLIB21_OBJS} 859c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n" 860786acdabcc15f023330d7c628aca9679e757a238Randall Spangler ${Q}rm -f $@ 861c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n" 862786acdabcc15f023330d7c628aca9679e757a238Randall Spangler ${Q}ar qc $@ $^ 863786acdabcc15f023330d7c628aca9679e757a238Randall Spangler 864eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ---------------------------------------------------------------------------- 865782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# Host library(s) 866eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 867782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# Link tests for local utilities 868782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${BUILD}/host/linktest/main: ${UTILLIB} 869782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${BUILD}/host/linktest/main: LIBS = ${UTILLIB} 87080872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/host/linktest/main.o 871782990277ac7d6730db4c43c2b5632de93396921Bill Richardson 872782990277ac7d6730db4c43c2b5632de93396921Bill Richardson.PHONY: utillib 873782990277ac7d6730db4c43c2b5632de93396921Bill Richardsonutillib: ${UTILLIB} \ 874782990277ac7d6730db4c43c2b5632de93396921Bill Richardson ${BUILD}/host/linktest/main 875eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 876eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: better way to make .a than duplicating this recipe each time? 877aaaff86467823e0d3d29c383402275eeae481256Randall Spangler${UTILLIB}: ${UTILLIB_OBJS} ${FWLIB_OBJS} 878c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n" 879aaaff86467823e0d3d29c383402275eeae481256Randall Spangler ${Q}rm -f $@ 880c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n" 881aaaff86467823e0d3d29c383402275eeae481256Randall Spangler ${Q}ar qc $@ $^ 882aaaff86467823e0d3d29c383402275eeae481256Randall Spangler 883a5b69b02e039d7267390fea10266d45e14630559Randall Spangler.PHONY: utillib21 884a5b69b02e039d7267390fea10266d45e14630559Randall Spanglerutillib21: ${UTILLIB21} 885aaaff86467823e0d3d29c383402275eeae481256Randall Spangler 886108d991c678f80c99967bd07035de7418c81a072Randall Spangler${UTILLIB21}: INCLUDES += -Ihost/lib21/include -Ifirmware/lib21/include 8876f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler${UTILLIB21}: ${UTILLIB21_OBJS} ${FWLIB2_OBJS} ${FWLIB21_OBJS} 888c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n" 889782990277ac7d6730db4c43c2b5632de93396921Bill Richardson ${Q}rm -f $@ 890c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n" 891782990277ac7d6730db4c43c2b5632de93396921Bill Richardson ${Q}ar qc $@ $^ 892782990277ac7d6730db4c43c2b5632de93396921Bill Richardson 893782990277ac7d6730db4c43c2b5632de93396921Bill Richardson 894782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# Link tests for external repos 895782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${BUILD}/host/linktest/extern: ${HOSTLIB} 896782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${BUILD}/host/linktest/extern: LIBS = ${HOSTLIB} 897782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${BUILD}/host/linktest/extern: LDLIBS += -static 89880872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/host/linktest/extern.o 899782990277ac7d6730db4c43c2b5632de93396921Bill Richardson 900782990277ac7d6730db4c43c2b5632de93396921Bill Richardson.PHONY: hostlib 901782990277ac7d6730db4c43c2b5632de93396921Bill Richardsonhostlib: ${HOSTLIB} \ 902782990277ac7d6730db4c43c2b5632de93396921Bill Richardson ${BUILD}/host/linktest/extern 903782990277ac7d6730db4c43c2b5632de93396921Bill Richardson 904782990277ac7d6730db4c43c2b5632de93396921Bill Richardson# TODO: better way to make .a than duplicating this recipe each time? 905782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${HOSTLIB}: ${HOSTLIB_OBJS} 906c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n" 907eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}rm -f $@ 908c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n" 909eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}ar qc $@ $^ 910eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 91181a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson 91281a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson# Ugh. This is a very cut-down version of HOSTLIB just for the installer. 91381a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson.PHONY: tinyhostlib 91481a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardsontinyhostlib: ${TINYHOSTLIB} 91581a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson ${Q}cp -f ${TINYHOSTLIB} ${HOSTLIB} 91681a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson 91781a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson${TINYHOSTLIB}: ${TINYHOSTLIB_OBJS} 918c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n" 91981a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson ${Q}rm -f $@ 920c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n" 92181a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson ${Q}ar qc $@ $^ 92281a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson 923eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ---------------------------------------------------------------------------- 924eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# CGPT library and utility 925eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 926eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: cgpt 927eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsoncgpt: ${CGPT} 928eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 929eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${CGPT}: LDFLAGS += -static 930eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${CGPT}: LDLIBS += -luuid 931eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 932782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${CGPT}: ${CGPT_OBJS} ${UTILLIB} 933c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " LDcgpt $(subst ${BUILD}/,,$@)\n" 9346db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson ${Q}${LD} -o ${CGPT} ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS} 935eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 936eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: cgpt_install 937eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsoncgpt_install: ${CGPT} 938c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " INSTALL CGPT\n" 939c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson ${Q}mkdir -p ${UB_DIR} 940c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson ${Q}${INSTALL} -t ${UB_DIR} $^ 941eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 942eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ---------------------------------------------------------------------------- 943eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Utilities 944eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 945eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# These have their own headers too. 9460f6679e8582219b40e2ab5485992827a92c18bcdBill Richardson${BUILD}/utility/%: INCLUDES += -Iutility/include 9470f6679e8582219b40e2ab5485992827a92c18bcdBill Richardson 9480f6679e8582219b40e2ab5485992827a92c18bcdBill Richardson${UTIL_BINS} ${UTIL_BINS_STATIC}: ${UTILLIB} 9490f6679e8582219b40e2ab5485992827a92c18bcdBill Richardson${UTIL_BINS} ${UTIL_BINS_STATIC}: LIBS = ${UTILLIB} 950eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 951eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Utilities for auto-update toolkits must be statically linked. 952eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${UTIL_BINS_STATIC}: LDFLAGS += -static 953eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 954a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson 955acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: utils 956c7c6e5d2f7076fe512b692411f0d05d4bf76d91fBill Richardsonutils: ${UTIL_BINS} ${UTIL_SCRIPTS} 957eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}cp -f ${UTIL_SCRIPTS} ${BUILD}/utility 958eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}chmod a+rx $(patsubst %,${BUILD}/%,${UTIL_SCRIPTS}) 959826db09fcec194951e1dc71002d6a92620fbb46bBill Richardson 960acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: utils_install 961cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardsonutils_install: ${UTIL_BINS} ${UTIL_SCRIPTS} ${UTIL_DEFAULTS} 962c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " INSTALL UTILS\n" 963c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson ${Q}mkdir -p ${UB_DIR} 964c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson ${Q}${INSTALL} -t ${UB_DIR} ${UTIL_BINS} ${UTIL_SCRIPTS} 965cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson ${Q}mkdir -p ${DF_DIR} 966cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson ${Q}${INSTALL} -t ${DF_DIR} -m 'u=rw,go=r,a-s' ${UTIL_DEFAULTS} 967c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson 968c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# And some signing stuff for the target 969c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson.PHONY: signing_install 970c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonsigning_install: ${SIGNING_SCRIPTS} ${SIGNING_SCRIPTS_DEV} ${SIGNING_COMMON} 971c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " INSTALL SIGNING\n" 9726f3961507e73f90cec665896dece884e86be560aBill Richardson ${Q}mkdir -p ${UB_DIR} ${VB_DIR} 973c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson ${Q}${INSTALL} -t ${UB_DIR} ${SIGNING_SCRIPTS} 9746f3961507e73f90cec665896dece884e86be560aBill Richardson ${Q}${INSTALL} -t ${VB_DIR} ${SIGNING_SCRIPTS_DEV} 9756f3961507e73f90cec665896dece884e86be560aBill Richardson ${Q}${INSTALL} -t ${VB_DIR} -m 'u=rw,go=r,a-s' ${SIGNING_COMMON} 9765d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 977eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ---------------------------------------------------------------------------- 978eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# new Firmware Utility 9795d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 980eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: futil 9816db8c75021e2edfa400ae707a8544d041e3c415fBill Richardsonfutil: ${FUTIL_STATIC_BIN} ${FUTIL_BIN} 9826db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson 983aaaff86467823e0d3d29c383402275eeae481256Randall Spangler${FUTIL_STATIC_BIN}: ${FUTIL_STATIC_OBJS} ${UTILLIB} \ 9846f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler $(if ${VBOOT2},${FWLIB20}) 985c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " LD $(subst ${BUILD}/,,$@)\n" 9866db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} -static $^ ${LDLIBS} 9875d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 988b84b81dc265a766a968bf126905447d442558218Bill Richardson${FUTIL_BIN}: LDLIBS += ${CRYPTO_LIBS} 9896f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler${FUTIL_BIN}: ${FUTIL_OBJS} ${UTILLIB} $(if ${VBOOT2},${FWLIB20}) 990c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " LD $(subst ${BUILD}/,,$@)\n" 9916db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS} 9925d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 993eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: futil_install 994efa8756c5e7068e57f5e98f0e7f2f42fb8d969d6Bill Richardsonfutil_install: ${FUTIL_BIN} ${FUTIL_STATIC_BIN} 995c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " INSTALL futility\n" 9966f3961507e73f90cec665896dece884e86be560aBill Richardson ${Q}mkdir -p ${UB_DIR} 9976f3961507e73f90cec665896dece884e86be560aBill Richardson ${Q}${INSTALL} -t ${UB_DIR} ${FUTIL_BIN} ${FUTIL_STATIC_BIN} 998a1d9fe6eecf82540d31d34bba988e4838d295302Bill Richardson ${Q}for prog in ${FUTIL_SYMLINKS}; do \ 9996f3961507e73f90cec665896dece884e86be560aBill Richardson ln -sf futility "${UB_DIR}/$$prog"; done 10005d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1001eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ---------------------------------------------------------------------------- 10025d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Utility to generate TLCL structure definition header file. 10035d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1004acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/utility/tlcl_generator: CFLAGS += -fpack-struct 10055d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 10065d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerSTRUCTURES_TMP=${BUILD}/tlcl_structures.tmp 10075d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerSTRUCTURES_SRC=firmware/lib/tpm_lite/include/tlcl_structures.h 10085d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1009acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: update_tlcl_structures 10105d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerupdate_tlcl_structures: ${BUILD}/utility/tlcl_generator 1011c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " Rebuilding TLCL structures\n" 1012eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}${BUILD}/utility/tlcl_generator > ${STRUCTURES_TMP} 1013eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}cmp -s ${STRUCTURES_TMP} ${STRUCTURES_SRC} || \ 10145d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ( echo "%% Updating structures.h %%" && \ 1015eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson cp ${STRUCTURES_TMP} ${STRUCTURES_SRC} ) 10165d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1017eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ---------------------------------------------------------------------------- 10185d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Tests 10195d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1020eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: tests 1021eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontests: ${TEST_BINS} 10225d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1023782990277ac7d6730db4c43c2b5632de93396921Bill Richardson${TEST_BINS}: ${UTILLIB} ${TESTLIB} 1024339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson${TEST_BINS}: INCLUDES += -Itests 1025efa37b87f2b4cd4b4f515e96201502ae0408cec7Randall Spangler${TEST_BINS}: LIBS = ${TESTLIB} ${UTILLIB} 10265d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 10276f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler${TEST2X_BINS}: ${FWLIB2X} 10286f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler${TEST2X_BINS}: LIBS += ${FWLIB2X} 10296f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler 1030108d991c678f80c99967bd07035de7418c81a072Randall Spangler${TEST20_BINS}: ${FWLIB20} 10316f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler${TEST20_BINS}: INCLUDES += -Ifirmware/lib20/include 1032108d991c678f80c99967bd07035de7418c81a072Randall Spangler${TEST20_BINS}: LIBS += ${FWLIB20} 1033108d991c678f80c99967bd07035de7418c81a072Randall Spangler 1034108d991c678f80c99967bd07035de7418c81a072Randall Spangler${TEST21_BINS}: ${UTILLIB21} 1035108d991c678f80c99967bd07035de7418c81a072Randall Spangler${TEST21_BINS}: INCLUDES += -Ihost/lib21/include -Ifirmware/lib21/include 1036108d991c678f80c99967bd07035de7418c81a072Randall Spangler${TEST21_BINS}: LIBS += ${UTILLIB21} 1037aaaff86467823e0d3d29c383402275eeae481256Randall Spangler 1038eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${TESTLIB}: ${TESTLIB_OBJS} 1039c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n" 1040eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}rm -f $@ 1041c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n" 1042eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}ar qc $@ $^ 10435d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 10445d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1045eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ---------------------------------------------------------------------------- 1046eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Generic build rules. LIBS and OBJS can be overridden to tweak the generic 1047eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# rules for specific targets. 10485d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1049eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%: ${BUILD}/%.o ${OBJS} ${LIBS} 1050c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " LD $(subst ${BUILD}/,,$@)\n" 10516db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $< ${OBJS} ${LIBS} ${LDLIBS} 1052eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 1053eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%.o: %.c 1054c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " CC $(subst ${BUILD}/,,$@)\n" 1055eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $< 1056eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 1057e08ee28548934e933733babf0bc0c418142d095dAlex Deymo${BUILD}/%.o: ${BUILD}/%.c 1058c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " CC $(subst ${BUILD}/,,$@)\n" 1059e08ee28548934e933733babf0bc0c418142d095dAlex Deymo ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $< 1060e08ee28548934e933733babf0bc0c418142d095dAlex Deymo 1061eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Rules to recompile a single source file for library and test 1062eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: is there a tidier way to do this? 1063eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_lib.o: CFLAGS += -DFOR_LIBRARY 1064eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_lib.o: %.c 1065c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " CC-for-lib $(subst ${BUILD}/,,$@)\n" 1066eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $< 1067eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 1068eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_test.o: CFLAGS += -DFOR_TEST 1069eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_test.o: %.c 1070c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " CC-for-test $(subst ${BUILD}/,,$@)\n" 1071eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $< 1072eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 1073eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: C++ files don't belong in vboot reference at all. Convert to C. 1074eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%.o: %.cc 1075c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " CXX $(subst ${BUILD}/,,$@)\n" 1076eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}${CXX} ${CFLAGS} ${INCLUDES} -c -o $@ $< 1077eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 1078eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ---------------------------------------------------------------------------- 1079eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Here are the special tweaks to the generic rules. 1080eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 1081cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson# Always create the defaults file, since it depends on input variables 1082cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson.PHONY: ${UTIL_DEFAULTS} 1083cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson${UTIL_DEFAULTS}: 1084c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " CREATE $(subst ${BUILD}/,,$@)\n" 1085cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson ${Q}rm -f $@ 1086cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson ${Q}mkdir -p $(dir $@) 1087cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson ${Q}echo '# Generated file. Do not edit.' > $@.tmp 1088cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson ${Q}echo "DEV_DEBUG_FORCE=${DEV_DEBUG_FORCE}" >> $@.tmp 1089cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson ${Q}mv -f $@.tmp $@ 1090cfe83a827d40b310003fc6996b9978d8cf301444Bill Richardson 1091eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Some utilities need external crypto functions 1092782990277ac7d6730db4c43c2b5632de93396921Bill RichardsonCRYPTO_LIBS := $(shell ${PKG_CONFIG} --libs libcrypto) 1093782990277ac7d6730db4c43c2b5632de93396921Bill Richardson 1094eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/dumpRSAPublicKey: LDLIBS += ${CRYPTO_LIBS} 1095eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/pad_digest_utility: LDLIBS += ${CRYPTO_LIBS} 1096eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/signature_digest_utility: LDLIBS += ${CRYPTO_LIBS} 1097eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 1098eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/host/linktest/main: LDLIBS += ${CRYPTO_LIBS} 1099eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/vboot_common2_tests: LDLIBS += ${CRYPTO_LIBS} 1100eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/vboot_common3_tests: LDLIBS += ${CRYPTO_LIBS} 11016f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler${BUILD}/tests/vb20_common2_tests: LDLIBS += ${CRYPTO_LIBS} 11026f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler${BUILD}/tests/vb20_common3_tests: LDLIBS += ${CRYPTO_LIBS} 1103108d991c678f80c99967bd07035de7418c81a072Randall Spangler 1104108d991c678f80c99967bd07035de7418c81a072Randall Spangler${TEST21_BINS}: LDLIBS += ${CRYPTO_LIBS} 1105eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 11060b789c56fc5ff34309e935bab15f130a386a1140Mike FrysingerLZMA_LIBS := $(shell ${PKG_CONFIG} --libs liblzma) 11070b789c56fc5ff34309e935bab15f130a386a1140Mike FrysingerYAML_LIBS := $(shell ${PKG_CONFIG} --libs yaml-0.1) 11080b789c56fc5ff34309e935bab15f130a386a1140Mike Frysinger 1109eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_utility: LD = ${CXX} 11100b789c56fc5ff34309e935bab15f130a386a1140Mike Frysinger${BUILD}/utility/bmpblk_utility: LDLIBS = ${LZMA_LIBS} ${YAML_LIBS} 1111eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 1112eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonBMPBLK_UTILITY_DEPS = \ 1113eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${BUILD}/utility/bmpblk_util.o \ 1114eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${BUILD}/utility/image_types.o \ 1115eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${BUILD}/utility/eficompress_for_lib.o \ 1116eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${BUILD}/utility/efidecompress_for_lib.o 11171912bbae89b82c10819b01d039e140e39c668fc7Bill Richardson 1118eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_utility: OBJS = ${BMPBLK_UTILITY_DEPS} 1119eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_utility: ${BMPBLK_UTILITY_DEPS} 11201912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BMPBLK_UTILITY_DEPS} 1121eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 1122eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_font: OBJS += ${BUILD}/utility/image_types.o 1123eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_font: ${BUILD}/utility/image_types.o 11241912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BUILD}/utility/image_types.o 1125eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 1126eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Allow multiple definitions, so tests can mock functions from other libraries 1127eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/%: CFLAGS += -Xlinker --allow-multiple-definition 1128eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/%: LDLIBS += -lrt -luuid 1129eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/%: LIBS += ${TESTLIB} 11305d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 11315d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler${BUILD}/tests/rollback_index2_tests: OBJS += \ 113217f8d341099120da78a6ca71165834eefb0960edRandall Spangler ${BUILD}/firmware/lib/rollback_index_for_test.o 1133eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/rollback_index2_tests: \ 1134eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${BUILD}/firmware/lib/rollback_index_for_test.o 113580872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/firmware/lib/rollback_index_for_test.o 11365d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1137c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler${BUILD}/tests/tlcl_tests: OBJS += \ 1138c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o 1139c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler${BUILD}/tests/tlcl_tests: \ 1140c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o 114180872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o 1142c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler 11435d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler${BUILD}/tests/vboot_audio_tests: OBJS += \ 114417f8d341099120da78a6ca71165834eefb0960edRandall Spangler ${BUILD}/firmware/lib/vboot_audio_for_test.o 1145eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/vboot_audio_tests: \ 1146eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${BUILD}/firmware/lib/vboot_audio_for_test.o 114780872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/firmware/lib/vboot_audio_for_test.o 11485d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1149339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonTLCL_TEST_BINS = $(addprefix ${BUILD}/,${TLCL_TEST_NAMES}) 1150eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${TLCL_TEST_BINS}: OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o 1151eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${TLCL_TEST_BINS}: ${BUILD}/tests/tpm_lite/tlcl_tests.o 115280872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o 11535d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1154e08ee28548934e933733babf0bc0c418142d095dAlex Deymo# ---------------------------------------------------------------------------- 1155e08ee28548934e933733babf0bc0c418142d095dAlex Deymo# Here are the special rules that don't fit in the generic rules. 1156e08ee28548934e933733babf0bc0c418142d095dAlex Deymo 1157e08ee28548934e933733babf0bc0c418142d095dAlex Deymo# Generates the list of commands defined in futility by running grep in the 1158e08ee28548934e933733babf0bc0c418142d095dAlex Deymo# source files looking for the DECLARE_FUTIL_COMMAND() macro usage. 1159e08ee28548934e933733babf0bc0c418142d095dAlex Deymo${FUTIL_STATIC_CMD_LIST}: ${FUTIL_STATIC_SRCS} 1160e08ee28548934e933733babf0bc0c418142d095dAlex Deymo${FUTIL_CMD_LIST}: ${FUTIL_SRCS} 1161e08ee28548934e933733babf0bc0c418142d095dAlex Deymo${FUTIL_CMD_LIST} ${FUTIL_STATIC_CMD_LIST}: 1162c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " GEN $(subst ${BUILD}/,,$@)\n" 1163e08ee28548934e933733babf0bc0c418142d095dAlex Deymo ${Q}rm -f $@ $@_t $@_commands 1164e08ee28548934e933733babf0bc0c418142d095dAlex Deymo ${Q}mkdir -p ${BUILD}/gen 1165779796f57e1e0236ea502248ede2cbea986fca21Bill Richardson ${Q}grep -hoRE '^DECLARE_FUTIL_COMMAND\([^,]+' $^ \ 1166e08ee28548934e933733babf0bc0c418142d095dAlex Deymo | sed 's/DECLARE_FUTIL_COMMAND(\(.*\)/_CMD(\1)/' \ 1167e08ee28548934e933733babf0bc0c418142d095dAlex Deymo | sort >>$@_commands 1168e1486c3234b7dc6fc5b58681b271a65a09141e20Bill Richardson ${Q}./scripts/getversion.sh >> $@_t 1169e08ee28548934e933733babf0bc0c418142d095dAlex Deymo ${Q}echo '#define _CMD(NAME) extern const struct' \ 1170e08ee28548934e933733babf0bc0c418142d095dAlex Deymo 'futil_cmd_t __cmd_##NAME;' >> $@_t 1171e08ee28548934e933733babf0bc0c418142d095dAlex Deymo ${Q}cat $@_commands >> $@_t 1172e08ee28548934e933733babf0bc0c418142d095dAlex Deymo ${Q}echo '#undef _CMD' >> $@_t 1173e08ee28548934e933733babf0bc0c418142d095dAlex Deymo ${Q}echo '#define _CMD(NAME) &__cmd_##NAME,' >> $@_t 1174e08ee28548934e933733babf0bc0c418142d095dAlex Deymo ${Q}echo 'const struct futil_cmd_t *const futil_cmds[] = {' >> $@_t 1175e08ee28548934e933733babf0bc0c418142d095dAlex Deymo ${Q}cat $@_commands >> $@_t 1176e08ee28548934e933733babf0bc0c418142d095dAlex Deymo ${Q}echo '0}; /* null-terminated */' >> $@_t 1177e08ee28548934e933733babf0bc0c418142d095dAlex Deymo ${Q}echo '#undef _CMD' >> $@_t 1178e08ee28548934e933733babf0bc0c418142d095dAlex Deymo ${Q}mv $@_t $@ 1179e08ee28548934e933733babf0bc0c418142d095dAlex Deymo ${Q}rm -f $@_commands 1180e08ee28548934e933733babf0bc0c418142d095dAlex Deymo 1181eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson############################################################################## 1182eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Targets that exist just to run tests 11835d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 11845d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Frequently-run tests 1185eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: test_targets 1186786acdabcc15f023330d7c628aca9679e757a238Randall Spanglertest_targets:: runcgpttests runmisctests $(if ${VBOOT2},run2tests) 1187844bce57471153664c78993dab453e87891bb969Randall Spangler 1188eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${MINIMAL},) 1189844bce57471153664c78993dab453e87891bb969Randall Spangler# Bitmap utility isn't compiled for minimal variant 1190feb2518166b1cd181e607c611cbb610f0c7300daBill Richardsontest_targets:: runbmptests runfutiltests 1191844bce57471153664c78993dab453e87891bb969Randall Spangler# Scripts don't work under qemu testing 1192844bce57471153664c78993dab453e87891bb969Randall Spangler# TODO: convert scripts to makefile so they can be called directly 1193eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontest_targets:: runtestscripts 1194844bce57471153664c78993dab453e87891bb969Randall Spanglerendif 1195844bce57471153664c78993dab453e87891bb969Randall Spangler 1196eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: test_setup 11973e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardsontest_setup:: cgpt utils futil tests install_for_test 1198eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 1199844bce57471153664c78993dab453e87891bb969Randall Spangler# Qemu setup for cross-compiled tests. Need to copy qemu binary into the 1200844bce57471153664c78993dab453e87891bb969Randall Spangler# sysroot. 1201eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifneq (${QEMU_ARCH},) 1202eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontest_setup:: qemu_install 1203844bce57471153664c78993dab453e87891bb969Randall Spangler 1204844bce57471153664c78993dab453e87891bb969Randall Spangler.PHONY: qemu_install 1205844bce57471153664c78993dab453e87891bb969Randall Spanglerqemu_install: 1206eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${SYSROOT},) 1207eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson $(error SYSROOT must be set to the top of the target-specific root \ 1208eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonwhen cross-compiling for qemu-based tests to run properly.) 1209eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif 1210c8c87b3264e02df2842e20866f717607a07c5ab4Mike Frysinger @${PRINTF} " Copying qemu binary.\n" 1211eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}cp -fu /usr/bin/${QEMU_BIN} ${BUILD}/${QEMU_BIN} 1212eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}chmod a+rx ${BUILD}/${QEMU_BIN} 1213844bce57471153664c78993dab453e87891bb969Randall Spanglerendif 1214844bce57471153664c78993dab453e87891bb969Randall Spangler 1215acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runtests 1216a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardsonruntests: test_setup test_targets 12175d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 12185d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Generate test keys 1219acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: genkeys 1220844bce57471153664c78993dab453e87891bb969Randall Spanglergenkeys: utils 12215d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/gen_test_keys.sh 12225d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 12235d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Generate test cases for fuzzing 1224acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: genfuzztestcases 1225a808dc944284e6eba39a8f19ddb46bc61c34de8aRandall Spanglergenfuzztestcases: utils 12265d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/gen_fuzz_test_cases.sh 12275d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1228acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runbmptests 1229eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonrunbmptests: test_setup 1230eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson cd tests/bitmaps && BMPBLK=${BUILD_RUN}/utility/bmpblk_utility \ 12315d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ./TestBmpBlock.py -v 12325d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1233acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runcgpttests 1234eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonruncgpttests: test_setup 1235eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/cgptlib_test 12365d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1237844bce57471153664c78993dab453e87891bb969Randall Spangler.PHONY: runtestscripts 1238eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonruntestscripts: test_setup genfuzztestcases 1239b8ff397674fb98c1d7eea864e7fa571369675131Randall Spangler tests/load_kernel_tests.sh 1240eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt 1241ab899591808dd3e5f955ab7693b54a83389cd35fNam T. Nguyen tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt -D 358400 12425d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/run_preamble_tests.sh 12435d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/run_rsa_tests.sh 1244844bce57471153664c78993dab453e87891bb969Randall Spangler tests/run_vbutil_kernel_arg_tests.sh 12455d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/run_vbutil_tests.sh 1246e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spanglerifneq (${VBOOT2},) 1247e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler tests/vb2_rsa_tests.sh 1248539cbc27305b6aef9643adffc3297c7079fe7457Randall Spangler tests/vb2_firmware_tests.sh 1249e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spanglerendif 12505d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1251844bce57471153664c78993dab453e87891bb969Randall Spangler.PHONY: runmisctests 1252eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonrunmisctests: test_setup 1253eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/rollback_index2_tests 1254a3eac79f5070747e326da631c1eec155f0389919Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/rollback_index3_tests 1255eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/rsa_utility_tests 1256eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/sha_tests 1257eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/stateful_util_tests 1258c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/tlcl_tests 1259eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/tpm_bootmode_tests 1260eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/utility_string_tests 1261eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/utility_tests 1262eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_devmode_tests 1263eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_firmware_tests 12640714d9de56da3a5c686b26755d15aa6788c727d4Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_init_tests 12650714d9de56da3a5c686b26755d15aa6788c727d4Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel_tests 12667f43669630cb42e40ca6ddc1128eefea8fd339d9Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel2_tests 12677f43669630cb42e40ca6ddc1128eefea8fd339d9Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel3_tests 12687f43669630cb42e40ca6ddc1128eefea8fd339d9Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel4_tests 1269eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/vboot_audio_tests 1270e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_common_tests 1271e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS} 1272e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS} 1273786a5dca74387de5ffdc51ca5a099a4e90f406daRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_display_tests 1274eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/vboot_firmware_tests 127549cb0d3471e768da11fe76b65769bd57dca38bd7Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_kernel_tests 12766dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_nvstorage_test 1277eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 1278786acdabcc15f023330d7c628aca9679e757a238Randall Spangler.PHONY: run2tests 1279786acdabcc15f023330d7c628aca9679e757a238Randall Spanglerrun2tests: test_setup 1280a7ab8b50b8923afcfd7a9e6181892c4c8a2de250Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb2_api_tests 1281786acdabcc15f023330d7c628aca9679e757a238Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb2_common_tests 12823333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb2_misc_tests 12833333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb2_nvstorage_tests 1284e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb2_rsa_utility_tests 12853333e578497aafc4eb8c6e1e359f6e2b1dee633aRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb2_secdata_tests 1286e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb2_sha_tests 12876f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb20_api_tests 12886f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb20_common_tests 12896f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb20_common2_tests ${TEST_KEYS} 12906f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb20_common3_tests ${TEST_KEYS} 12916f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb20_misc_tests 1292108d991c678f80c99967bd07035de7418c81a072Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb21_api_tests 1293108d991c678f80c99967bd07035de7418c81a072Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb21_common_tests 1294108d991c678f80c99967bd07035de7418c81a072Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb21_common2_tests ${TEST_KEYS} 1295108d991c678f80c99967bd07035de7418c81a072Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb21_misc_tests 1296108d991c678f80c99967bd07035de7418c81a072Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb21_host_fw_preamble_tests ${TEST_KEYS} 1297108d991c678f80c99967bd07035de7418c81a072Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb21_host_key_tests ${TEST_KEYS} 1298108d991c678f80c99967bd07035de7418c81a072Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb21_host_keyblock_tests ${TEST_KEYS} 1299108d991c678f80c99967bd07035de7418c81a072Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb21_host_misc_tests 1300108d991c678f80c99967bd07035de7418c81a072Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb21_host_sig_tests ${TEST_KEYS} 1301786acdabcc15f023330d7c628aca9679e757a238Randall Spangler 1302eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: runfutiltests 13033e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardsonrunfutiltests: test_setup 1304efa8756c5e7068e57f5e98f0e7f2f42fb8d969d6Bill Richardson tests/futility/run_test_scripts.sh ${TEST_INSTALL_DIR}/bin 1305339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/futility/test_not_really 1306844bce57471153664c78993dab453e87891bb969Randall Spangler 13075d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Run long tests, including all permutations of encryption keys (instead of 1308786a5dca74387de5ffdc51ca5a099a4e90f406daRandall Spangler# just the ones we use) and tests of currently-unused code. 13095d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Not run by automated build. 1310acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runlongtests 1311eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonrunlongtests: test_setup genkeys genfuzztestcases 1312e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS} --all 1313e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS} --all 13147141d73c149ee203a192f0cb45ca9bfa10c0ff8cRandall Spanglerifneq (${VBOOT2},) 13156f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb20_common2_tests ${TEST_KEYS} --all 13166f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb20_common3_tests ${TEST_KEYS} --all 1317108d991c678f80c99967bd07035de7418c81a072Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vb21_common2_tests ${TEST_KEYS} --all 13187141d73c149ee203a192f0cb45ca9bfa10c0ff8cRandall Spanglerendif 13195d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/run_preamble_tests.sh --all 13205d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/run_vbutil_tests.sh --all 13215d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 132278d59bffec45da47b4e8a763186723192dd24f87Bill Richardson# TODO: There were a number of ancient tests that hadn't been run in years. 132378d59bffec45da47b4e8a763186723192dd24f87Bill Richardson# They were removed with https://chromium-review.googlesource.com/#/c/214610/ 132478d59bffec45da47b4e8a763186723192dd24f87Bill Richardson# Some day it might be nice to see what they were supposed to do. 13255d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1326782990277ac7d6730db4c43c2b5632de93396921Bill Richardson.PHONY: runalltests 1327782990277ac7d6730db4c43c2b5632de93396921Bill Richardsonrunalltests: runtests runfutiltests runlongtests 1328782990277ac7d6730db4c43c2b5632de93396921Bill Richardson 132959d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler# Code coverage 133059d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler.PHONY: coverage_init 133159d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage_init: test_setup 133259d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler rm -f ${COV_INFO}* 133359d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler lcov -c -i -d . -b . -o ${COV_INFO}.initial 133459d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler 133559d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler.PHONY: coverage_html 133659d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage_html: 133759d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler lcov -c -d . -b . -o ${COV_INFO}.tests 133859d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler lcov -a ${COV_INFO}.initial -a ${COV_INFO}.tests -o ${COV_INFO}.total 133959d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler lcov -r ${COV_INFO}.total '/usr/*' '*/linktest/*' -o ${COV_INFO}.local 134059d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler genhtml ${COV_INFO}.local -o ${BUILD}/coverage 1341d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardson# Generate addtional coverage stats just for firmware subdir, because the stats 1342d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardson# for the whole project don't include subdirectory summaries. This will print 1343d2d08b2cc68f720a485cdfa6f044ddb234e8c42bBill Richardson# the summary for just the firmware sources. 134449cb0d3471e768da11fe76b65769bd57dca38bd7Randall Spangler lcov -r ${COV_INFO}.local '*/stub/*' -o ${COV_INFO}.nostub 134549cb0d3471e768da11fe76b65769bd57dca38bd7Randall Spangler lcov -e ${COV_INFO}.nostub '${SRCDIR}/firmware/*' \ 134659d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler -o ${COV_INFO}.firmware 134759d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler 134859d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler.PHONY: coverage 134959d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglerifeq (${COV},) 135059d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage: 135159d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler $(error Build coverage like this: make clean && COV=1 make) 135259d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglerelse 135359d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage: coverage_init runtests coverage_html 135459d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglerendif 13551912bbae89b82c10819b01d039e140e39c668fc7Bill Richardson 13561912bbae89b82c10819b01d039e140e39c668fc7Bill Richardson# Include generated dependencies 13571912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_DEPS += ${ALL_OBJS:%.o=%.o.d} 135880872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonTEST_DEPS += ${TEST_OBJS:%.o=%.o.d} 135980872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson 136080872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson# We want to use only relative paths in cscope.files, especially since the 136180872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson# paths inside and outside the chroot are different. 136280872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill RichardsonSRCDIRPAT=$(subst /,\/,${SRCDIR}/) 136380872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson 136480872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson${BUILD}/cscope.files: test_setup 136580872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson ${Q}rm -f $@ 136680872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson ${Q}cat ${ALL_DEPS} | tr -d ':\\' | tr ' ' '\012' | \ 136780872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson sed -e "s/${SRCDIRPAT}//" | \ 136880872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson egrep '\.[chS]$$' | sort | uniq > $@ 136980872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson 137080872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardsoncmd_etags = etags -o ${BUILD}/TAGS $(shell cat ${BUILD}/cscope.files) 137180872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardsoncmd_ctags = ctags -o ${BUILD}/tags $(shell cat ${BUILD}/cscope.files) 137280872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardsonrun_if_prog = $(if $(shell which $(1) 2>/dev/null),$(2),) 137380872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson 137480872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson.PHONY: tags TAGS xrefs 137580872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardsontags TAGS xrefs: ${BUILD}/cscope.files 137680872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson ${Q}\rm -f ${BUILD}/tags ${BUILD}/TAGS 137780872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson ${Q}$(call run_if_prog,etags,${cmd_etags}) 137880872dbffcb2e0079bfe095d770ccc6c8bd5fd7aBill Richardson ${Q}$(call run_if_prog,ctags,${cmd_ctags}) 1379