Makefile revision 534723a6519267461855441279b321e6fc1e4e90
1e8cfa31d548c069d73c304fea522b527fe7c7dd6Randall Spangler# Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 2322536d2f9d30f42218cc9f2ab40574557da8a9Gaurav Shah# Use of this source code is governed by a BSD-style license that can be 3322536d2f9d30f42218cc9f2ab40574557da8a9Gaurav Shah# found in the LICENSE file. 4322536d2f9d30f42218cc9f2ab40574557da8a9Gaurav Shah 56d696e532c6a0c93ad9b915c59dad4144e6f1b33Simon Glass# This Makefile normally builds in a 'build' subdir, but use 66d696e532c6a0c93ad9b915c59dad4144e6f1b33Simon Glass# 76d696e532c6a0c93ad9b915c59dad4144e6f1b33Simon Glass# make BUILD=<dir> 86d696e532c6a0c93ad9b915c59dad4144e6f1b33Simon Glass# 9eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# to put the output somewhere else. 10eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 11eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson############################################################################## 12eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Make variables come in two flavors, immediate or deferred. 13eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# 14eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Variable definitions are parsed like this: 15eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# 16eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# IMMEDIATE = DEFERRED 17eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# or 18eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# IMMEDIATE := IMMEDIATE 19eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# 20eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Rules are parsed this way: 21eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# 22eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# IMMEDIATE : IMMEDIATE 23eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# DEFERRED 24eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# 25eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# So you can assign variables in any order if they're only to be used in 26eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# actions, but if you use a variable in either the target or prerequisite of a 27eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# rule, the rule will be constructed using only the top-down, immediate value. 28eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# 29eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# So we'll try to define all the variables first. Then the rules. 30eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# 31eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 32eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson############################################################################## 33eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Configuration variables come first. 34eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# 35eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Our convention is that we only use := for variables that will never be 36eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# changed or appended. They must be defined before being used anywhere. 37eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 38c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# We should only run pwd once, not every time we refer to ${BUILD}. 39e061a256549607a56d771eb8ddae5d0dd90d519cRandall SpanglerSRCDIR := $(shell pwd) 40feb2518166b1cd181e607c611cbb610f0c7300daBill RichardsonBUILD = $(SRCDIR)/build 41844bce57471153664c78993dab453e87891bb969Randall Spanglerexport BUILD 425d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 43c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# Stuff for 'make install' 44feb2518166b1cd181e607c611cbb610f0c7300daBill RichardsonINSTALL = install 45feb2518166b1cd181e607c611cbb610f0c7300daBill RichardsonDESTDIR = /usr/local/bin 46feb2518166b1cd181e607c611cbb610f0c7300daBill RichardsonOLDDIR = old_bins 47feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson 48feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson# Where exactly do the pieces go? 49feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson# FT_DIR = futility target directory - where it will be on the target 50feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson# F_DIR = futility install directory - where it gets put right now 51feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson# UB_DIR = userspace binary directory for futility's exec() targets 52feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson# VB_DIR = target vboot directory - for dev-mode-only helpers, keys, etc. 53c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonifeq (${MINIMAL},) 54c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# Host install just puts everything in one place 55feb2518166b1cd181e607c611cbb610f0c7300daBill RichardsonFT_DIR=${DESTDIR} 56feb2518166b1cd181e607c611cbb610f0c7300daBill RichardsonF_DIR=${DESTDIR} 57feb2518166b1cd181e607c611cbb610f0c7300daBill RichardsonUB_DIR=${DESTDIR}/${OLDDIR} 58c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonelse 59c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# Target install puts things into DESTDIR subdirectories 60feb2518166b1cd181e607c611cbb610f0c7300daBill RichardsonFT_DIR=/usr/bin 61feb2518166b1cd181e607c611cbb610f0c7300daBill RichardsonF_DIR=${DESTDIR}${FT_DIR} 62feb2518166b1cd181e607c611cbb610f0c7300daBill RichardsonUB_DIR=${F_DIR}/${OLDDIR} 63c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill RichardsonVB_DIR=${DESTDIR}/usr/share/vboot/bin 64c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonendif 656d696e532c6a0c93ad9b915c59dad4144e6f1b33Simon Glass 66eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Where to install the (exportable) executables for testing? 67eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTEST_INSTALL_DIR = ${BUILD}/install_for_test 68eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 69eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Verbose? Use V=1 70eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${V},) 71eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonQ := @ 72eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif 73eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 74661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass# Quiet? Use QUIET=1 75661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glassifeq ($(QUIET),) 76661ae9e9cbaad430b87b443712d2608f9ce59883Simon GlassPRINTF := printf 77661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glasselse 78661ae9e9cbaad430b87b443712d2608f9ce59883Simon GlassPRINTF := : 79661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glassendif 80661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass 8161a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# Architecture detection 8261a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler_machname := $(shell uname -m) 8361a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall SpanglerHOST_ARCH ?= ${_machname} 8461a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler 8561a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# ARCH and/or FIRMWARE_ARCH are defined by the Chromium OS ebuild. 8661a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# Pick a sane target architecture if none is defined. 8761a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerifeq (${ARCH},) 8861a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler ARCH := ${HOST_ARCH} 8961a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${ARCH},i386) 9061a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler override ARCH := x86 9161a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${ARCH},amd64) 9261a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler override ARCH := x86_64 9361a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerendif 9461a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler 9561a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# FIRMWARE_ARCH is only defined by the Chromium OS ebuild if compiling 9661a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# for a firmware target (such as u-boot or depthcharge). It must map 9761a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler# to the same consistent set of architectures as the host. 9861a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerifeq (${FIRMWARE_ARCH},i386) 9961a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler override FIRMWARE_ARCH := x86 10061a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${FIRMWARE_ARCH},amd64) 10161a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler override FIRMWARE_ARCH := x86_64 10261a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerendif 10361a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spangler 104b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# Provide default CC and CFLAGS for firmware builds; if you have any -D flags, 105b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# please add them after this point (e.g., -DVBOOT_DEBUG). 10674359b755c4a203df0fe3bf51fc53d5de87d1fbfChe-Liang Chiou# 1076b0003c6381a7e69818b0b34b358c2cfb1393043Che-Liang Chiou# TODO(crosbug.com/16808) We hard-code u-boot's compiler flags here just 1086b0003c6381a7e69818b0b34b358c2cfb1393043Che-Liang Chiou# temporarily. As we are still investigating which flags are necessary for 1096b0003c6381a7e69818b0b34b358c2cfb1393043Che-Liang Chiou# maintaining a compatible ABI, etc. between u-boot and vboot_reference. 11074359b755c4a203df0fe3bf51fc53d5de87d1fbfChe-Liang Chiou# 111b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# As a first step, this makes the setting of CC and CFLAGS here optional, to 112b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# permit a calling script or Makefile to set these. 11374359b755c4a203df0fe3bf51fc53d5de87d1fbfChe-Liang Chiou# 114b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# Flag ordering: arch, then -f, then -m, then -W 115b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassDEBUG_FLAGS := $(if ${DEBUG},-g -O0,-Os) 116b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCOMMON_FLAGS := -nostdinc -pipe \ 117b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass -ffreestanding -fno-builtin -fno-stack-protector \ 118eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson -Werror -Wall -Wstrict-prototypes ${DEBUG_FLAGS} 119b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass 120eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Note: FIRMWARE_ARCH is defined by the Chromium OS ebuild. 121eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH}, arm) 122b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCC ?= armv7a-cros-linux-gnueabi-gcc 123b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCFLAGS ?= -march=armv5 \ 124b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass -fno-common -ffixed-r8 \ 125d50b27d15de8cc9e37410fc52d3184f17e0db5bbDoug Anderson -mfloat-abi=hard -marm -mabi=aapcs-linux -mno-thumb-interwork \ 126eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${COMMON_FLAGS} 12761a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${FIRMWARE_ARCH}, x86) 128b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCC ?= i686-pc-linux-gnu-gcc 129b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass# Drop -march=i386 to permit use of SSE instructions 130b265c34321c01bd279f3a1df0a2fea3601f732eeSimon GlassCFLAGS ?= \ 131b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass -ffunction-sections -fvisibility=hidden -fno-strict-aliasing \ 132b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass -fomit-frame-pointer -fno-toplevel-reorder -fno-dwarf2-cfi-asm \ 133b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass -mpreferred-stack-boundary=2 -mregparm=3 \ 134eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${COMMON_FLAGS} 135eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonelse ifeq (${FIRMWARE_ARCH}, x86_64) 136eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCFLAGS ?= ${COMMON_FLAGS} \ 1378e85e987739281161ece1dbc9ff2b73f3e8e1e35Simon Glass -fvisibility=hidden -fno-strict-aliasing -fomit-frame-pointer 138844bce57471153664c78993dab453e87891bb969Randall Spanglerelse 139eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# FIRMWARE_ARCH not defined; assuming local compile. 140eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCC ?= gcc 141eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCFLAGS += -DCHROMEOS_ENVIRONMENT -Wall -Werror # HEY: always want last two? 1428e85e987739281161ece1dbc9ff2b73f3e8e1e35Simon Glassendif 14334be8273e0fb80a6654deab650e581b0dc9046a4Che-Liang Chiou 144feb2518166b1cd181e607c611cbb610f0c7300daBill Richardsonifneq (${OLDDIR},) 145feb2518166b1cd181e607c611cbb610f0c7300daBill RichardsonCFLAGS += -DOLDDIR=${OLDDIR} 146feb2518166b1cd181e607c611cbb610f0c7300daBill Richardsonendif 147feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson 148eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifneq (${DEBUG},) 149eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCFLAGS += -DVBOOT_DEBUG 150eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif 151844bce57471153664c78993dab453e87891bb969Randall Spangler 152eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${DISABLE_NDEBUG},) 153eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCFLAGS += -DNDEBUG 154eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif 155eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 156feb2518166b1cd181e607c611cbb610f0c7300daBill Richardsonifneq (${FORCE_LOGGING_ON},) 157feb2518166b1cd181e607c611cbb610f0c7300daBill RichardsonCFLAGS += -DFORCE_LOGGING_ON=${FORCE_LOGGING_ON} 158feb2518166b1cd181e607c611cbb610f0c7300daBill Richardsonendif 159feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson 160eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Create / use dependency files 161eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCFLAGS += -MMD -MF $@.d 162eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 1630c3ba249abb1dc60f5ebabccf84ff13206440b83Bill Richardson# These are required to access large disks and files on 32-bit systems. 1640c3ba249abb1dc60f5ebabccf84ff13206440b83Bill RichardsonCFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 1650c3ba249abb1dc60f5ebabccf84ff13206440b83Bill Richardson 16659d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler# Code coverage 167eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifneq (${COV},) 16859d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler COV_FLAGS = -O0 --coverage 16959d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler CFLAGS += ${COV_FLAGS} 17059d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler LDFLAGS += ${COV_FLAGS} 17159d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler COV_INFO = ${BUILD}/coverage.info 172eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif 173eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 174eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# And a few more default utilities 175eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonLD = ${CC} 176eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCXX ?= g++ # HEY: really? 177eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonPKG_CONFIG ?= pkg-config 178eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 179844bce57471153664c78993dab453e87891bb969Randall Spangler# Determine QEMU architecture needed, if any 180eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${ARCH},${HOST_ARCH}) 181844bce57471153664c78993dab453e87891bb969Randall Spangler # Same architecture; no need for QEMU 182844bce57471153664c78993dab453e87891bb969Randall Spangler QEMU_ARCH := 18361a2eb389d9903b1b5a88d3e11ad5d713b3a364aRandall Spanglerelse ifeq (${HOST_ARCH}-${ARCH},x86_64-x86) 184844bce57471153664c78993dab453e87891bb969Randall Spangler # 64-bit host can run 32-bit targets directly 185844bce57471153664c78993dab453e87891bb969Randall Spangler QEMU_ARCH := 186844bce57471153664c78993dab453e87891bb969Randall Spanglerelse 187eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson QEMU_ARCH := ${ARCH} 188844bce57471153664c78993dab453e87891bb969Randall Spanglerendif 189844bce57471153664c78993dab453e87891bb969Randall Spangler 190844bce57471153664c78993dab453e87891bb969Randall Spangler# The top of the chroot for qemu must be passed in via the SYSROOT environment 191844bce57471153664c78993dab453e87891bb969Randall Spangler# variable. In the Chromium OS chroot, this is done automatically by the 192844bce57471153664c78993dab453e87891bb969Randall Spangler# ebuild. 193844bce57471153664c78993dab453e87891bb969Randall Spangler 194eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${QEMU_ARCH},) 195844bce57471153664c78993dab453e87891bb969Randall Spangler # Path to build output for running tests is same as for building 196eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson BUILD_RUN = ${BUILD} 197e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler SRC_RUN = ${SRCDIR} 198844bce57471153664c78993dab453e87891bb969Randall Spanglerelse 199844bce57471153664c78993dab453e87891bb969Randall Spangler $(info Using qemu for testing.) 200844bce57471153664c78993dab453e87891bb969Randall Spangler # Path to build output for running tests is different in the chroot 201eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson BUILD_RUN = $(subst ${SYSROOT},,${BUILD}) 202e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler SRC_RUN = $(subst ${SYSROOT},,${SRCDIR}) 203844bce57471153664c78993dab453e87891bb969Randall Spangler 204eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson QEMU_BIN = qemu-${QEMU_ARCH} 205e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler QEMU_RUN = ${BUILD_RUN}/${QEMU_BIN} 206e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler export QEMU_RUN 207287beaed7f8ceff679c57664d4da008c6234edfdRandall Spangler 208e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler RUNTEST = tests/test_using_qemu.sh 209e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spanglerendif 2105d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 211e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spanglerexport BUILD_RUN 2125d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 213eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson############################################################################## 214eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Now we need to describe everything we might want or need to build 215b265c34321c01bd279f3a1df0a2fea3601f732eeSimon Glass 216eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Everything wants these headers. 2175d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerINCLUDES += \ 2185d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler -Ifirmware/include \ 2195d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler -Ifirmware/lib/include \ 2205d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler -Ifirmware/lib/cgptlib/include \ 2215d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler -Ifirmware/lib/cryptolib/include \ 2225d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler -Ifirmware/lib/tpm_lite/include 2230b8f35c6a56a0e645254dd7f07ca68e01c8ee629Bill Richardson 224eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# If we're not building for a specific target, just stub out things like the 225eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM commands and various external functions that are provided by the BIOS. 226eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH},) 2275d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerINCLUDES += -Ifirmware/stub/include 2280a0e8d0bb26c951a895c5034a4c1c12f3d4e8707Che-Liang Chiouelse 229eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonINCLUDES += -Ifirmware/arch/${FIRMWARE_ARCH}/include 2305d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif 2315d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 232eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Firmware library. TODO: Do we still need to export this? 233eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonFWLIB = ${BUILD}/vboot_fw.a 2345d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 23593943266c597ad66300445a04afa01270f2b5763Randall Spangler# Firmware library sources needed by VbInit() call 23693943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBINIT_SRCS = \ 2375d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/crc8.c \ 23893943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/utility.c \ 23993943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/vboot_api_init.c \ 24093943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/vboot_common_init.c \ 24193943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/vboot_nvstorage.c \ 24293943266c597ad66300445a04afa01270f2b5763Randall Spangler 24393943266c597ad66300445a04afa01270f2b5763Randall Spangler# Additional firmware library sources needed by VbSelectFirmware() call 24493943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_SRCS = \ 2455d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cryptolib/padding.c \ 2465d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cryptolib/rsa.c \ 2475d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cryptolib/rsa_utility.c \ 2485d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cryptolib/sha1.c \ 2495d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cryptolib/sha256.c \ 2505d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cryptolib/sha512.c \ 2515d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/cryptolib/sha_utility.c \ 2525d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/stateful_util.c \ 2535d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/vboot_api_firmware.c \ 25493943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/vboot_common.c \ 25593943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/vboot_firmware.c 25693943266c597ad66300445a04afa01270f2b5763Randall Spangler 25793943266c597ad66300445a04afa01270f2b5763Randall Spangler# Additional firmware library sources needed by VbSelectAndLoadKernel() call 25893943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSLK_SRCS = \ 25993943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/cgptlib/cgptlib.c \ 26093943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/cgptlib/cgptlib_internal.c \ 26193943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/cgptlib/crc32.c \ 2625c9e4532b9bc45cff22f37d3556da679809a60a7Albert Chaulk firmware/lib/cgptlib/mtdlib.c \ 26393943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/utility_string.c \ 2645d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/vboot_api_kernel.c \ 2655d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/vboot_audio.c \ 2665d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/vboot_display.c \ 26793943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/vboot_kernel.c 2685d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 269eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Support real TPM unless BIOS sets MOCK_TPM 270eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${MOCK_TPM},) 27193943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBINIT_SRCS += \ 2725d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/rollback_index.c \ 2735d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/tpm_lite/tlcl.c 27493943266c597ad66300445a04afa01270f2b5763Randall Spangler 27593943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_SRCS += \ 27693943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/tpm_bootmode.c 2775d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerelse 27893943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBINIT_SRCS += \ 2795d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/mocked_rollback_index.c \ 2805d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/lib/tpm_lite/mocked_tlcl.c 28193943266c597ad66300445a04afa01270f2b5763Randall Spangler 28293943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_SRCS += \ 28393943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/lib/mocked_tpm_bootmode.c 2845d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif 2855d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 286eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH},) 287eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Include BIOS stubs in the firmware library when compiling for host 28893943266c597ad66300445a04afa01270f2b5763Randall Spangler# TODO: split out other stub funcs too 28993943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBINIT_SRCS += \ 2905d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/stub/tpm_lite_stub.c \ 2915d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/stub/utility_stub.c \ 29293943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/stub/vboot_api_stub_init.c 29393943266c597ad66300445a04afa01270f2b5763Randall Spangler 29493943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_SRCS += \ 29593943266c597ad66300445a04afa01270f2b5763Randall Spangler firmware/stub/vboot_api_stub_sf.c 29693943266c597ad66300445a04afa01270f2b5763Randall Spangler 29793943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSLK_SRCS += \ 2985d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/stub/vboot_api_stub.c \ 2995d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler firmware/stub/vboot_api_stub_disk.c 3005d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif 3015d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 30293943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_SRCS += ${VBINIT_SRCS} 30393943266c597ad66300445a04afa01270f2b5763Randall SpanglerFWLIB_SRCS += ${VBSF_SRCS} ${VBSLK_SRCS} 30493943266c597ad66300445a04afa01270f2b5763Randall Spangler 30593943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBINIT_OBJS = ${VBINIT_SRCS:%.c=${BUILD}/%.o} 30693943266c597ad66300445a04afa01270f2b5763Randall SpanglerVBSF_OBJS = ${VBSF_SRCS:%.c=${BUILD}/%.o} 30793943266c597ad66300445a04afa01270f2b5763Randall Spangler 308eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonFWLIB_OBJS = ${FWLIB_SRCS:%.c=${BUILD}/%.o} 3091912bbae89b82c10819b01d039e140e39c668fc7Bill Richardson 3101912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${FWLIB_OBJS} ${VBINIT_OBJS} ${VBSF_OBJS} 3115d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 3125d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 313eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Library to build the utilities. "HOST" mostly means "userspace". 314c7c6e5d2f7076fe512b692411f0d05d4bf76d91fBill RichardsonHOSTLIB = ${BUILD}/libvboot_host.a 3155d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 3165d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerHOSTLIB_SRCS = \ 31781a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_create.c \ 31881a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_add.c \ 31981a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_boot.c \ 32081a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_show.c \ 32181a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_repair.c \ 32281a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_prioritize.c \ 32381a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_common.c \ 324534723a6519267461855441279b321e6fc1e4e90Albert Chaulk cgpt/flash_ts_drv.c \ 325534723a6519267461855441279b321e6fc1e4e90Albert Chaulk firmware/lib/flash_ts.c \ 326eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson host/arch/${ARCH}/lib/crossystem_arch.c \ 3275d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/crossystem.c \ 3285d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/file_keys.c \ 3295d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/fmap.c \ 3305d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/host_common.c \ 3315d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/host_key.c \ 3325d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/host_keyblock.c \ 3335d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/host_misc.c \ 3345d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler host/lib/host_signature.c \ 33581a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson host/lib/signature_digest.c \ 33681a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson utility/dump_kernel_config_lib.c 3375d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 338eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonHOSTLIB_OBJS = ${HOSTLIB_SRCS:%.c=${BUILD}/%.o} 3395d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerALL_OBJS += ${HOSTLIB_OBJS} 3405d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 341eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Might need this too. 342eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCRYPTO_LIBS := $(shell ${PKG_CONFIG} --libs libcrypto) 343eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 34481a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson# Sigh. For historical reasons, the autoupdate installer must sometimes be a 34581a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson# 32-bit executable, even when everything else is 64-bit. But it only needs a 34681a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson# few functions, so let's just build those. 34781a0b3de707b4e00958faf36f41b8f3d7bac6808Bill RichardsonTINYHOSTLIB = ${BUILD}/libtinyvboot_host.a 34881a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson 34981a0b3de707b4e00958faf36f41b8f3d7bac6808Bill RichardsonTINYHOSTLIB_SRCS = \ 35081a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_create.c \ 35181a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_add.c \ 35281a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_boot.c \ 35381a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_show.c \ 35481a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_repair.c \ 35581a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_prioritize.c \ 35681a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson cgpt/cgpt_common.c \ 357534723a6519267461855441279b321e6fc1e4e90Albert Chaulk cgpt/flash_ts_drv.c \ 358534723a6519267461855441279b321e6fc1e4e90Albert Chaulk firmware/lib/flash_ts.c \ 35981a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson utility/dump_kernel_config_lib.c \ 36081a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson firmware/lib/cgptlib/crc32.c \ 36181a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson firmware/lib/cgptlib/cgptlib_internal.c \ 3625fed2a667096341160db8643a4a057e328953a1dBill Richardson firmware/lib/utility_string.c \ 36381a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson firmware/stub/utility_stub.c 36481a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson 36581a0b3de707b4e00958faf36f41b8f3d7bac6808Bill RichardsonTINYHOSTLIB_OBJS = ${TINYHOSTLIB_SRCS:%.c=${BUILD}/%.o} 366eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 367eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ---------------------------------------------------------------------------- 368eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Now for the userspace binaries 3695d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 3705d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCGPT = ${BUILD}/cgpt/cgpt 3715d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 3725d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerCGPT_SRCS = \ 3735d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt.c \ 3745d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_add.c \ 3755d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_boot.c \ 3765d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_common.c \ 3775d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_create.c \ 3785d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_find.c \ 3795d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_legacy.c \ 3805d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_prioritize.c \ 3815d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_repair.c \ 3825d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cgpt_show.c \ 3835d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cmd_add.c \ 3845d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cmd_boot.c \ 3855d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cmd_create.c \ 3865d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cmd_find.c \ 3875d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cmd_legacy.c \ 3885d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cmd_prioritize.c \ 3895d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler cgpt/cmd_repair.c \ 390534723a6519267461855441279b321e6fc1e4e90Albert Chaulk cgpt/cmd_show.c \ 391534723a6519267461855441279b321e6fc1e4e90Albert Chaulk cgpt/flash_ts_drv.c \ 392534723a6519267461855441279b321e6fc1e4e90Albert Chaulk firmware/lib/flash_ts.c 3935d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 394eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonCGPT_OBJS = ${CGPT_SRCS:%.c=${BUILD}/%.o} 3955d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerALL_OBJS += ${CGPT_OBJS} 3965d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 3975d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 398eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Scripts to install directly (not compiled) 3995d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerUTIL_SCRIPTS = \ 4005d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler utility/dev_debug_vboot \ 4015d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler utility/enable_dev_usb_boot \ 4025d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler utility/vbutil_what_keys 4035d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 404c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonifeq (${MINIMAL},) 405c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill RichardsonUTIL_SCRIPTS += \ 406c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson utility/dev_make_keypair 407c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonendif 408c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson 409eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# These utilities should be linked statically. 410eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonUTIL_NAMES_STATIC = \ 411339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/crossystem \ 412339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/gbb_utility 413eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 414eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonUTIL_NAMES = ${UTIL_NAMES_STATIC} \ 415339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/dev_sign_file \ 416339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/dump_kernel_config \ 417339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/dumpRSAPublicKey \ 418339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/tpm_init_temp_fix \ 419339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/tpmc \ 420339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/vbutil_firmware \ 421339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/vbutil_kernel \ 422339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/vbutil_key \ 423339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/vbutil_keyblock \ 4245d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 425eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${MINIMAL},) 4265d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerUTIL_NAMES += \ 427339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/bmpblk_font \ 428339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/bmpblk_utility \ 429339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/eficompress \ 430339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/efidecompress \ 431339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/load_kernel_test \ 432339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/pad_digest_utility \ 433339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/signature_digest_utility \ 434339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson utility/verify_data 4355d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerendif 4365d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 437339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonUTIL_BINS_STATIC := $(addprefix ${BUILD}/,${UTIL_NAMES_STATIC}) 438339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonUTIL_BINS = $(addprefix ${BUILD}/,${UTIL_NAMES}) 4391912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += $(addsuffix .o,${UTIL_BINS} ${UTIL_BINS_STATIC}) 4405d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 441c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson 442c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# Scripts for signing stuff. 443c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill RichardsonSIGNING_SCRIPTS = \ 444c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson utility/tpm-nvsize \ 445c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson utility/chromeos-tpm-recovery 446c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson 447c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# These go in a different place. 448c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill RichardsonSIGNING_SCRIPTS_DEV = \ 449c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson scripts/image_signing/resign_firmwarefd.sh \ 450c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson scripts/image_signing/make_dev_firmware.sh \ 451c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson scripts/image_signing/make_dev_ssd.sh \ 452c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson scripts/image_signing/set_gbb_flags.sh 453c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson 454c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# Installed, but not made executable. 455c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill RichardsonSIGNING_COMMON = scripts/image_signing/common_minimal.sh 456eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 457eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 458eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# The unified firmware utility will eventually replace all the others 459eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonFUTIL_BIN = ${BUILD}/futility/futility 4606db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson# But we still need both static (tiny) and dynamic (with openssl) versions. 4616db8c75021e2edfa400ae707a8544d041e3c415fBill RichardsonFUTIL_STATIC_BIN = ${FUTIL_BIN}_s 462eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 463feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson# These are the others it will replace. 46420807b6158b6a43baf0974bc763890888ba1f841Bill RichardsonFUTIL_OLD = bmpblk_font bmpblk_utility cgpt chromeos-tpm-recovery crossystem \ 46520807b6158b6a43baf0974bc763890888ba1f841Bill Richardson dev_debug_vboot dev_make_keypair dev_sign_file dumpRSAPublicKey \ 46620807b6158b6a43baf0974bc763890888ba1f841Bill Richardson dump_fmap dump_kernel_config eficompress efidecompress \ 46720807b6158b6a43baf0974bc763890888ba1f841Bill Richardson enable_dev_usb_boot gbb_utility load_kernel_test \ 46820807b6158b6a43baf0974bc763890888ba1f841Bill Richardson make_dev_firmware.sh make_dev_ssd.sh pad_digest_utility \ 46920807b6158b6a43baf0974bc763890888ba1f841Bill Richardson resign_firmwarefd.sh set_gbb_flags.sh signature_digest_utility \ 47020807b6158b6a43baf0974bc763890888ba1f841Bill Richardson tpm-nvsize tpm_init_temp_fix tpmc vbutil_firmware vbutil_kernel \ 47120807b6158b6a43baf0974bc763890888ba1f841Bill Richardson vbutil_key vbutil_keyblock vbutil_what_keys verify_data 472feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson 4736db8c75021e2edfa400ae707a8544d041e3c415fBill RichardsonFUTIL_STATIC_SRCS = \ 474feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson futility/futility.c \ 47520807b6158b6a43baf0974bc763890888ba1f841Bill Richardson futility/cmd_dump_fmap.c \ 476feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson futility/cmd_foo.c 477eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 4786db8c75021e2edfa400ae707a8544d041e3c415fBill RichardsonFUTIL_SRCS = \ 4796db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson $(FUTIL_STATIC_SRCS) \ 4806db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson futility/cmd_hey.c 4816db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson 482eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonFUTIL_LDS = futility/futility.lds 483eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 4846db8c75021e2edfa400ae707a8544d041e3c415fBill RichardsonFUTIL_STATIC_OBJS = ${FUTIL_STATIC_SRCS:%.c=${BUILD}/%.o} 485eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonFUTIL_OBJS = ${FUTIL_SRCS:%.c=${BUILD}/%.o} 486eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 487eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonALL_OBJS += ${FUTIL_OBJS} 488eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 489eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 490eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Library of handy test functions. 491eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTESTLIB = ${BUILD}/tests/test.a 492eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 493eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTESTLIB_SRCS = \ 494eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson tests/test_common.c \ 495eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson tests/timer_utils.c \ 496eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson tests/crc32_test.c 497eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 498eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTESTLIB_OBJS = ${TESTLIB_SRCS:%.c=${BUILD}/%.o} 499eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonALL_OBJS += ${TESTLIB_OBJS} 500eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 501eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 502eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# And some compiled tests. 503eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTEST_NAMES = \ 504339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/cgptlib_test \ 505339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/rollback_index2_tests \ 506339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/rollback_index3_tests \ 507339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/rsa_padding_test \ 508339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/rsa_utility_tests \ 509339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/rsa_verify_benchmark \ 510339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/sha_benchmark \ 511339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/sha_tests \ 512339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/stateful_util_tests \ 513339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tlcl_tests \ 514339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_bootmode_tests \ 515339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/utility_string_tests \ 516339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/utility_tests \ 517339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_api_init_tests \ 518339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_api_devmode_tests \ 519339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_api_firmware_tests \ 520339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_api_kernel_tests \ 521339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_api_kernel2_tests \ 522339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_api_kernel3_tests \ 523339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_api_kernel4_tests \ 524339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_audio_tests \ 525339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_common_tests \ 526339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_common2_tests \ 527339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_common3_tests \ 528339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_display_tests \ 529339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_firmware_tests \ 530339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_kernel_tests \ 531339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/vboot_nvstorage_test \ 532339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/futility/test_not_really 533eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 534eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: port these tests to new API, if not already eqivalent 535eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# functionality in other tests. These don't even compile at present. 536eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# 537eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# big_firmware_tests 538eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# big_kernel_tests 539eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# firmware_image_tests 540eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# firmware_rollback_tests 541eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# firmware_splicing_tests 542eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# firmware_verify_benchmark 543eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# kernel_image_tests 544eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# kernel_rollback_tests 545eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# kernel_splicing_tests 546eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# kernel_verify_benchmark 547eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# rollback_index_test 548eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# verify_firmware_fuzz_driver 549eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# verify_kernel_fuzz_driver 550eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# utility/load_firmware_test 551eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 552eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# And a few more... 553339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonTLCL_TEST_NAMES = \ 554339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_lite/tpmtest_earlyextend \ 555339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_lite/tpmtest_earlynvram \ 556339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_lite/tpmtest_earlynvram2 \ 557339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_lite/tpmtest_enable \ 558339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_lite/tpmtest_fastenable \ 559339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_lite/tpmtest_globallock \ 560339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_lite/tpmtest_redefine_unowned \ 561339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_lite/tpmtest_spaceperm \ 562339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_lite/tpmtest_testsetup \ 563339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_lite/tpmtest_timing \ 564339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/tpm_lite/tpmtest_writelimit 565eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 566eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonTEST_NAMES += ${TLCL_TEST_NAMES} 567eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 568339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson# Finally 569339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonTEST_BINS = $(addprefix ${BUILD}/,${TEST_NAMES}) 5701912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += $(addsuffix .o,${TEST_BINS}) 571eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 572e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler# Directory containing test keys 573e061a256549607a56d771eb8ddae5d0dd90d519cRandall SpanglerTEST_KEYS = ${SRC_RUN}/tests/testkeys 574eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 575eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 576eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson############################################################################## 577eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Finally, some targets. High-level ones first. 578eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 579eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Create output directories if necessary. Do this via explicit shell commands 580eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# so it happens before trying to generate/include dependencies. 581eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonSUBDIRS := firmware host cgpt utility futility tests tests/tpm_lite 582eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson_dir_create := $(foreach d, \ 583eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson $(shell find ${SUBDIRS} -name '*.c' -exec dirname {} \; | sort -u), \ 584eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson $(shell [ -d ${BUILD}/${d} ] || mkdir -p ${BUILD}/${d})) 585eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 586eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 587eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Default target. 588eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: all 58959d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglerall: fwlib $(if ${FIRMWARE_ARCH},,host_stuff) $(if ${COV},coverage) 590eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 591eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Host targets 592eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: host_stuff 593eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonhost_stuff: hostlib cgpt utils futil tests 594eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 595eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: clean 596eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonclean: 597eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}/bin/rm -rf ${BUILD} 598eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 599eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: install 600c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsoninstall: cgpt_install utils_install signing_install futil_install 601eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 602eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Don't delete intermediate object files 603eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.SECONDARY: 604eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 605eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 606eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ---------------------------------------------------------------------------- 607eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Firmware library 608eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 609eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM-specific flags. These depend on the particular TPM we're targeting for. 610eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# They are needed here only for compiling parts of the firmware code into 611eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# user-level tests. 612eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 613eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM_BLOCKING_CONTINUESELFTEST is defined if TPM_ContinueSelfTest blocks until 614eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# the self test has completed. 615eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 61645cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DTPM_BLOCKING_CONTINUESELFTEST 617eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 618eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TPM_MANUAL_SELFTEST is defined if the self test must be started manually 619eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# (with a call to TPM_ContinueSelfTest) instead of starting automatically at 620eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# power on. 621eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# 622eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# We sincerely hope that TPM_BLOCKING_CONTINUESELFTEST and TPM_MANUAL_SELFTEST 623eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# are not both defined at the same time. (See comment in code.) 624eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 625eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# CFLAGS += -DTPM_MANUAL_SELFTEST 626eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 627eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH},i386) 628eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Unrolling loops in cryptolib makes it faster 62945cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DUNROLL_LOOPS 630eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 631eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Workaround for coreboot on x86, which will power off asynchronously 632eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# without giving us a chance to react. This is not an example of the Right 633eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Way to do things. See chrome-os-partner:7689, and the commit message 634eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# that made this change. 63545cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DSAVE_LOCALE_IMMEDIATELY 636eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 637eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# On x86 we don't actually read the GBB data into RAM until it is needed. 638eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Therefore it makes sense to cache it rather than reading it each time. 639eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Enable this feature. 64045cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DCOPY_BMP_DATA 641eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif 642eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 643eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${FIRMWARE_ARCH},) 644eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Disable rollback TPM when compiling locally, since otherwise 645eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# load_kernel_test attempts to talk to the TPM. 64645cc0f2c0a48b377520842597769a5813cf55902Randall Spangler${FWLIB_OBJS}: CFLAGS += -DDISABLE_ROLLBACK_TPM 647eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif 648eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 649a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson# Linktest ensures firmware lib doesn't rely on outside libraries 650a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${BUILD}/firmware/linktest/main_vbinit: ${VBINIT_OBJS} 65193943266c597ad66300445a04afa01270f2b5763Randall Spangler${BUILD}/firmware/linktest/main_vbinit: OBJS = ${VBINIT_OBJS} 6521912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BUILD}/firmware/linktest/main_vbinit.o 653a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${BUILD}/firmware/linktest/main_vbsf: ${VBSF_OBJS} 65493943266c597ad66300445a04afa01270f2b5763Randall Spangler${BUILD}/firmware/linktest/main_vbsf: OBJS = ${VBSF_OBJS} 6551912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BUILD}/firmware/linktest/main_vbsf.o 656a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${BUILD}/firmware/linktest/main: ${FWLIB} 657a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${BUILD}/firmware/linktest/main: LIBS = ${FWLIB} 6581912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BUILD}/firmware/linktest/main.o 65993943266c597ad66300445a04afa01270f2b5763Randall Spangler 66093943266c597ad66300445a04afa01270f2b5763Randall Spangler.phony: fwlinktest 66193943266c597ad66300445a04afa01270f2b5763Randall Spanglerfwlinktest: ${FWLIB} \ 66293943266c597ad66300445a04afa01270f2b5763Randall Spangler ${BUILD}/firmware/linktest/main_vbinit \ 66393943266c597ad66300445a04afa01270f2b5763Randall Spangler ${BUILD}/firmware/linktest/main_vbsf \ 66493943266c597ad66300445a04afa01270f2b5763Randall Spangler ${BUILD}/firmware/linktest/main 66593943266c597ad66300445a04afa01270f2b5763Randall Spangler 666eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: fwlib 667a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardsonfwlib: $(if ${FIRMWARE_ARCH},${FWLIB},fwlinktest) 668eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 669eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${FWLIB}: ${FWLIB_OBJS} 670661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass @$(PRINTF) " RM $(subst ${BUILD}/,,$@)\n" 671eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}rm -f $@ 672661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass @$(PRINTF) " AR $(subst ${BUILD}/,,$@)\n" 673eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}ar qc $@ $^ 674eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 675eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ---------------------------------------------------------------------------- 676eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Host library 677eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 678a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson 679a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson# Link tests 680a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${BUILD}/host/linktest/main: ${HOSTLIB} 681a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${BUILD}/host/linktest/main: LIBS = ${HOSTLIB} 6821912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BUILD}/host/linktest/main.o 683a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson 684eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: hostlib 685a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardsonhostlib: ${BUILD}/host/linktest/main 686eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 687eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/host/% ${HOSTLIB}: INCLUDES += \ 6880c3ba249abb1dc60f5ebabccf84ff13206440b83Bill Richardson -Ihost/include \ 6890c3ba249abb1dc60f5ebabccf84ff13206440b83Bill Richardson -Ihost/arch/${ARCH}/include \ 6900c3ba249abb1dc60f5ebabccf84ff13206440b83Bill Richardson -Ihost/lib/include 691eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 692eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: better way to make .a than duplicating this recipe each time? 693eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${HOSTLIB}: ${HOSTLIB_OBJS} ${FWLIB_OBJS} 694661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass @$(PRINTF) " RM $(subst ${BUILD}/,,$@)\n" 695eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}rm -f $@ 696661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass @$(PRINTF) " AR $(subst ${BUILD}/,,$@)\n" 697eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}ar qc $@ $^ 698eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 69981a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson 70081a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson# Ugh. This is a very cut-down version of HOSTLIB just for the installer. 70181a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson.PHONY: tinyhostlib 70281a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardsontinyhostlib: ${TINYHOSTLIB} 70381a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson ${Q}cp -f ${TINYHOSTLIB} ${HOSTLIB} 70481a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson 70581a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson${TINYHOSTLIB}: ${TINYHOSTLIB_OBJS} 706661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass @$(PRINTF) " RM $(subst ${BUILD}/,,$@)\n" 70781a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson ${Q}rm -f $@ 708661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass @$(PRINTF) " AR $(subst ${BUILD}/,,$@)\n" 70981a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson ${Q}ar qc $@ $^ 71081a0b3de707b4e00958faf36f41b8f3d7bac6808Bill Richardson 711eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ---------------------------------------------------------------------------- 712eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# CGPT library and utility 713eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 714eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: cgpt 715eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsoncgpt: ${CGPT} 716eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 7170c3ba249abb1dc60f5ebabccf84ff13206440b83Bill Richardson${CGPT_OBJS}: INCLUDES += -Ihost/include 7180c3ba249abb1dc60f5ebabccf84ff13206440b83Bill Richardson 719eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${CGPT}: LDFLAGS += -static 720eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${CGPT}: LDLIBS += -luuid 721eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 722a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${CGPT}: ${CGPT_OBJS} ${HOSTLIB} 723661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass @$(PRINTF) " LDcgpt $(subst ${BUILD}/,,$@)\n" 7246db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson ${Q}${LD} -o ${CGPT} ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS} 725eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 726eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: cgpt_install 727eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsoncgpt_install: ${CGPT} 728661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass @$(PRINTF) " INSTALL CGPT\n" 729c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson ${Q}mkdir -p ${UB_DIR} 730c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson ${Q}${INSTALL} -t ${UB_DIR} $^ 731eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 732eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ---------------------------------------------------------------------------- 733eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Utilities 734eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 735eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# These have their own headers too. 7360c3ba249abb1dc60f5ebabccf84ff13206440b83Bill Richardson${BUILD}/utility/%: INCLUDES += \ 7370c3ba249abb1dc60f5ebabccf84ff13206440b83Bill Richardson -Ihost/include \ 7380c3ba249abb1dc60f5ebabccf84ff13206440b83Bill Richardson -Ihost/lib/include \ 7390c3ba249abb1dc60f5ebabccf84ff13206440b83Bill Richardson -Iutility/include 740eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 741eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Utilities for auto-update toolkits must be statically linked. 742eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${UTIL_BINS_STATIC}: LDFLAGS += -static 743eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 744a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson 745acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: utils 746c7c6e5d2f7076fe512b692411f0d05d4bf76d91fBill Richardsonutils: ${UTIL_BINS} ${UTIL_SCRIPTS} 747eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}cp -f ${UTIL_SCRIPTS} ${BUILD}/utility 748eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}chmod a+rx $(patsubst %,${BUILD}/%,${UTIL_SCRIPTS}) 749826db09fcec194951e1dc71002d6a92620fbb46bBill Richardson 750a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${UTIL_BINS} ${UTIL_BINS_STATIC}: ${HOSTLIB} 751a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${UTIL_BINS} ${UTIL_BINS_STATIC}: LIBS = ${HOSTLIB} 752a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson 753acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: utils_install 754c7c6e5d2f7076fe512b692411f0d05d4bf76d91fBill Richardsonutils_install: ${UTIL_BINS} ${UTIL_SCRIPTS} 755661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass @$(PRINTF) " INSTALL UTILS\n" 756c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson ${Q}mkdir -p ${UB_DIR} 757c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson ${Q}${INSTALL} -t ${UB_DIR} ${UTIL_BINS} ${UTIL_SCRIPTS} 758c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson 759c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson# And some signing stuff for the target 760c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson.PHONY: signing_install 761c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonsigning_install: ${SIGNING_SCRIPTS} ${SIGNING_SCRIPTS_DEV} ${SIGNING_COMMON} 762661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass @$(PRINTF) " INSTALL SIGNING\n" 763c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson ${Q}mkdir -p ${UB_DIR} 764c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson ${Q}${INSTALL} -t ${UB_DIR} ${SIGNING_SCRIPTS} 765feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson ${Q}${INSTALL} -t ${UB_DIR} ${SIGNING_SCRIPTS_DEV} 766feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson ${Q}${INSTALL} -t ${UB_DIR} -m 'u=rw,go=r,a-s' ${SIGNING_COMMON} 767feb2518166b1cd181e607c611cbb610f0c7300daBill Richardsonifneq (${VB_DIR},) 768c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardson ${Q}mkdir -p ${VB_DIR} 769feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson ${Q}for prog in $(notdir ${SIGNING_SCRIPTS_DEV}); do \ 770feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson ln -sf "${FT_DIR}/futility" "${VB_DIR}/$$prog"; done 771c9bf348239af9bcf6c1e9eb6b83cd0ad9b3ea084Bill Richardsonendif 7725d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 773eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ---------------------------------------------------------------------------- 774eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# new Firmware Utility 7755d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 776eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: futil 7776db8c75021e2edfa400ae707a8544d041e3c415fBill Richardsonfutil: ${FUTIL_STATIC_BIN} ${FUTIL_BIN} 7786db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson 7796db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson${FUTIL_STATIC_BIN}: ${FUTIL_LDS} ${FUTIL_STATIC_OBJS} 7806db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson @$(PRINTF) " LD $(subst ${BUILD}/,,$@)\n" 7816db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} -static $^ ${LDLIBS} 7825d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 783eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${FUTIL_BIN}: ${FUTIL_LDS} ${FUTIL_OBJS} 784661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass @$(PRINTF) " LD $(subst ${BUILD}/,,$@)\n" 7856db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS} 7865d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 787eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: futil_install 788eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonfutil_install: ${FUTIL_BIN} 789661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass @$(PRINTF) " INSTALL futility\n" 790feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson ${Q}mkdir -p ${F_DIR} 7916db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson ${Q}${INSTALL} -t ${F_DIR} ${FUTIL_BIN} ${FUTIL_STATIC_BIN} 792feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson ${Q}for prog in ${FUTIL_OLD}; do \ 793feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson ln -sf futility "${F_DIR}/$$prog"; done 7945d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 79520807b6158b6a43baf0974bc763890888ba1f841Bill Richardson# TODO(wfrichar): This will need some refactoring (crbug.com/228932) 79620807b6158b6a43baf0974bc763890888ba1f841Bill Richardson${BUILD}/futility/% ${HOSTLIB}: INCLUDES += \ 79720807b6158b6a43baf0974bc763890888ba1f841Bill Richardson -Ihost/include \ 79820807b6158b6a43baf0974bc763890888ba1f841Bill Richardson -Ihost/arch/${ARCH}/include \ 79920807b6158b6a43baf0974bc763890888ba1f841Bill Richardson -Ihost/lib/include 80020807b6158b6a43baf0974bc763890888ba1f841Bill Richardson${FUTIL_STATIC_BIN} ${FUTIL_BIN}: ${HOSTLIB} 80120807b6158b6a43baf0974bc763890888ba1f841Bill Richardson${FUTIL_STATIC_BIN} ${FUTIL_BIN}: LIBS = ${HOSTLIB} 80220807b6158b6a43baf0974bc763890888ba1f841Bill Richardson 803eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ---------------------------------------------------------------------------- 8045d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Utility to generate TLCL structure definition header file. 8055d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 806acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/utility/tlcl_generator: CFLAGS += -fpack-struct 8075d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 8085d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerSTRUCTURES_TMP=${BUILD}/tlcl_structures.tmp 8095d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall SpanglerSTRUCTURES_SRC=firmware/lib/tpm_lite/include/tlcl_structures.h 8105d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 811acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: update_tlcl_structures 8125d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spanglerupdate_tlcl_structures: ${BUILD}/utility/tlcl_generator 813661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass @$(PRINTF) " Rebuilding TLCL structures\n" 814eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}${BUILD}/utility/tlcl_generator > ${STRUCTURES_TMP} 815eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}cmp -s ${STRUCTURES_TMP} ${STRUCTURES_SRC} || \ 8165d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ( echo "%% Updating structures.h %%" && \ 817eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson cp ${STRUCTURES_TMP} ${STRUCTURES_SRC} ) 8185d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 819eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ---------------------------------------------------------------------------- 8205d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Tests 8215d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 822eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: tests 823eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontests: ${TEST_BINS} 8245d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 825a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${TEST_BINS}: ${HOSTLIB} ${TESTLIB} 826339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson${TEST_BINS}: INCLUDES += -Itests 827a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardson${TEST_BINS}: LIBS = ${HOSTLIB} ${TESTLIB} 8285d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 829eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${TESTLIB}: ${TESTLIB_OBJS} 830661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass @$(PRINTF) " RM $(subst ${BUILD}/,,$@)\n" 831eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}rm -f $@ 832661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass @$(PRINTF) " AR $(subst ${BUILD}/,,$@)\n" 833eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}ar qc $@ $^ 8345d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 8355d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 836eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ---------------------------------------------------------------------------- 837eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Generic build rules. LIBS and OBJS can be overridden to tweak the generic 838eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# rules for specific targets. 8395d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 840eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%: ${BUILD}/%.o ${OBJS} ${LIBS} 841661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass @$(PRINTF) " LD $(subst ${BUILD}/,,$@)\n" 8426db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $< ${OBJS} ${LIBS} ${LDLIBS} 843eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 844eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%.o: %.c 845661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass @$(PRINTF) " CC $(subst ${BUILD}/,,$@)\n" 846eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $< 847eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 848eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Rules to recompile a single source file for library and test 849eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: is there a tidier way to do this? 850eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_lib.o: CFLAGS += -DFOR_LIBRARY 851eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_lib.o: %.c 852661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass @$(PRINTF) " CC-for-lib $(subst ${BUILD}/,,$@)\n" 853eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $< 854eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 855eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_test.o: CFLAGS += -DFOR_TEST 856eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%_for_test.o: %.c 857661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass @$(PRINTF) " CC-for-test $(subst ${BUILD}/,,$@)\n" 858eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $< 859eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 860eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# TODO: C++ files don't belong in vboot reference at all. Convert to C. 861eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/%.o: %.cc 862661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass @$(PRINTF) " CXX $(subst ${BUILD}/,,$@)\n" 863eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}${CXX} ${CFLAGS} ${INCLUDES} -c -o $@ $< 864eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 865eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# ---------------------------------------------------------------------------- 866eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Here are the special tweaks to the generic rules. 867eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 868eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# GBB utility needs C++ linker. TODO: It shouldn't. 869eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/gbb_utility: LD = ${CXX} 870eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 871feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson# Because we play some clever linker script games to add new commands without 872feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson# changing any header files, futility must be linked with ld.bfd, not gold. 873feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson${FUTIL_BIN}: LDFLAGS += -fuse-ld=bfd 8746db8c75021e2edfa400ae707a8544d041e3c415fBill Richardson${FUTIL_STATIC_BIN}: LDFLAGS += -fuse-ld=bfd 875feb2518166b1cd181e607c611cbb610f0c7300daBill Richardson 876eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Some utilities need external crypto functions 877eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/dumpRSAPublicKey: LDLIBS += ${CRYPTO_LIBS} 878eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/pad_digest_utility: LDLIBS += ${CRYPTO_LIBS} 879eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/signature_digest_utility: LDLIBS += ${CRYPTO_LIBS} 880eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/dev_sign_file: LDLIBS += ${CRYPTO_LIBS} 881eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/vbutil_firmware: LDLIBS += ${CRYPTO_LIBS} 882eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/vbutil_kernel: LDLIBS += ${CRYPTO_LIBS} 883eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/vbutil_key: LDLIBS += ${CRYPTO_LIBS} 884eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/vbutil_keyblock: LDLIBS += ${CRYPTO_LIBS} 885eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 886eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/host/linktest/main: LDLIBS += ${CRYPTO_LIBS} 887eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/vboot_common2_tests: LDLIBS += ${CRYPTO_LIBS} 888eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/vboot_common3_tests: LDLIBS += ${CRYPTO_LIBS} 889eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 890eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_utility: LD = ${CXX} 891eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_utility: LDLIBS = -llzma -lyaml 892eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 893eecc18fc953bd367d3cb5aa006df4b153d20a45eBill RichardsonBMPBLK_UTILITY_DEPS = \ 894eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${BUILD}/utility/bmpblk_util.o \ 895eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${BUILD}/utility/image_types.o \ 896eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${BUILD}/utility/eficompress_for_lib.o \ 897eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${BUILD}/utility/efidecompress_for_lib.o 8981912bbae89b82c10819b01d039e140e39c668fc7Bill Richardson 899eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_utility: OBJS = ${BMPBLK_UTILITY_DEPS} 900eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_utility: ${BMPBLK_UTILITY_DEPS} 9011912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BMPBLK_UTILITY_DEPS} 902eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 903eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_font: OBJS += ${BUILD}/utility/image_types.o 904eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/utility/bmpblk_font: ${BUILD}/utility/image_types.o 9051912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BUILD}/utility/image_types.o 906eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 907eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Allow multiple definitions, so tests can mock functions from other libraries 908eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/%: CFLAGS += -Xlinker --allow-multiple-definition 9090c3ba249abb1dc60f5ebabccf84ff13206440b83Bill Richardson${BUILD}/tests/%: INCLUDES += -Ihost/include -Ihost/lib/include 910eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/%: LDLIBS += -lrt -luuid 911eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/%: LIBS += ${TESTLIB} 9125d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 9135d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler${BUILD}/tests/rollback_index2_tests: OBJS += \ 91417f8d341099120da78a6ca71165834eefb0960edRandall Spangler ${BUILD}/firmware/lib/rollback_index_for_test.o 915eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/rollback_index2_tests: \ 916eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${BUILD}/firmware/lib/rollback_index_for_test.o 9171912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BUILD}/firmware/lib/rollback_index_for_test.o 9185d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 919c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler${BUILD}/tests/tlcl_tests: OBJS += \ 920c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o 921c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler${BUILD}/tests/tlcl_tests: \ 922c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o 9231912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o 924c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler 9255d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler${BUILD}/tests/vboot_audio_tests: OBJS += \ 92617f8d341099120da78a6ca71165834eefb0960edRandall Spangler ${BUILD}/firmware/lib/vboot_audio_for_test.o 927eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${BUILD}/tests/vboot_audio_tests: \ 928eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${BUILD}/firmware/lib/vboot_audio_for_test.o 9291912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BUILD}/firmware/lib/vboot_audio_for_test.o 9305d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 931acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/tests/rollback_index_test: INCLUDES += -I/usr/include 932acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson${BUILD}/tests/rollback_index_test: LIBS += -ltlcl 9335d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 934339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill RichardsonTLCL_TEST_BINS = $(addprefix ${BUILD}/,${TLCL_TEST_NAMES}) 935eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${TLCL_TEST_BINS}: OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o 936eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson${TLCL_TEST_BINS}: ${BUILD}/tests/tpm_lite/tlcl_tests.o 9371912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o 9385d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 939eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson############################################################################## 940eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson# Targets that exist just to run tests 9415d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 9425d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Frequently-run tests 943eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: test_targets 944eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontest_targets:: runcgpttests runmisctests 945844bce57471153664c78993dab453e87891bb969Randall Spangler 946eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${MINIMAL},) 947844bce57471153664c78993dab453e87891bb969Randall Spangler# Bitmap utility isn't compiled for minimal variant 948feb2518166b1cd181e607c611cbb610f0c7300daBill Richardsontest_targets:: runbmptests runfutiltests 949844bce57471153664c78993dab453e87891bb969Randall Spangler# Scripts don't work under qemu testing 950844bce57471153664c78993dab453e87891bb969Randall Spangler# TODO: convert scripts to makefile so they can be called directly 951eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontest_targets:: runtestscripts 952844bce57471153664c78993dab453e87891bb969Randall Spanglerendif 953844bce57471153664c78993dab453e87891bb969Randall Spangler 954eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: test_setup 955eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontest_setup:: cgpt utils futil tests 956eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 957844bce57471153664c78993dab453e87891bb969Randall Spangler# Qemu setup for cross-compiled tests. Need to copy qemu binary into the 958844bce57471153664c78993dab453e87891bb969Randall Spangler# sysroot. 959eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifneq (${QEMU_ARCH},) 960eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsontest_setup:: qemu_install 961844bce57471153664c78993dab453e87891bb969Randall Spangler 962844bce57471153664c78993dab453e87891bb969Randall Spangler.PHONY: qemu_install 963844bce57471153664c78993dab453e87891bb969Randall Spanglerqemu_install: 964eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonifeq (${SYSROOT},) 965eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson $(error SYSROOT must be set to the top of the target-specific root \ 966eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonwhen cross-compiling for qemu-based tests to run properly.) 967eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonendif 968661ae9e9cbaad430b87b443712d2608f9ce59883Simon Glass @$(PRINTF) " Copying qemu binary.\n" 969eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}cp -fu /usr/bin/${QEMU_BIN} ${BUILD}/${QEMU_BIN} 970eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${Q}chmod a+rx ${BUILD}/${QEMU_BIN} 971844bce57471153664c78993dab453e87891bb969Randall Spanglerendif 972844bce57471153664c78993dab453e87891bb969Randall Spangler 973acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runtests 974a130e0b0a38efa01195f5a7be635a66f0dd60c29Bill Richardsonruntests: test_setup test_targets 9755d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 9765d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Generate test keys 977acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: genkeys 978844bce57471153664c78993dab453e87891bb969Randall Spanglergenkeys: utils 9795d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/gen_test_keys.sh 9805d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 9815d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Generate test cases for fuzzing 982acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: genfuzztestcases 983a808dc944284e6eba39a8f19ddb46bc61c34de8aRandall Spanglergenfuzztestcases: utils 9845d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/gen_fuzz_test_cases.sh 9855d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 986acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runbmptests 987eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonrunbmptests: test_setup 988eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson cd tests/bitmaps && BMPBLK=${BUILD_RUN}/utility/bmpblk_utility \ 9895d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler ./TestBmpBlock.py -v 9905d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 991acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runcgpttests 992eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonruncgpttests: test_setup 993eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/cgptlib_test 9945d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 995844bce57471153664c78993dab453e87891bb969Randall Spangler.PHONY: runtestscripts 996eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonruntestscripts: test_setup genfuzztestcases 997eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt 9985d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/run_preamble_tests.sh 9995d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/run_rsa_tests.sh 1000844bce57471153664c78993dab453e87891bb969Randall Spangler tests/run_vbutil_kernel_arg_tests.sh 10015d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/run_vbutil_tests.sh 10025d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 1003844bce57471153664c78993dab453e87891bb969Randall Spangler.PHONY: runmisctests 1004eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonrunmisctests: test_setup 1005eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/rollback_index2_tests 1006a3eac79f5070747e326da631c1eec155f0389919Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/rollback_index3_tests 1007eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/rsa_utility_tests 1008eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/sha_tests 1009eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/stateful_util_tests 1010c3d488d155961d2849dfdaa4f0461df1aa95c2caRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/tlcl_tests 1011eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/tpm_bootmode_tests 1012eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/utility_string_tests 1013eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/utility_tests 1014eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_devmode_tests 1015eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_firmware_tests 10160714d9de56da3a5c686b26755d15aa6788c727d4Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_init_tests 10170714d9de56da3a5c686b26755d15aa6788c727d4Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel_tests 10187f43669630cb42e40ca6ddc1128eefea8fd339d9Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel2_tests 10197f43669630cb42e40ca6ddc1128eefea8fd339d9Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel3_tests 10207f43669630cb42e40ca6ddc1128eefea8fd339d9Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel4_tests 1021eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/vboot_audio_tests 1022e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_common_tests 1023e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS} 1024e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS} 1025786a5dca74387de5ffdc51ca5a099a4e90f406daRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_display_tests 1026eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/vboot_firmware_tests 102749cb0d3471e768da11fe76b65769bd57dca38bd7Randall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_kernel_tests 10286dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_nvstorage_test 1029eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson 1030eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardson.PHONY: runfutiltests 1031feb2518166b1cd181e607c611cbb610f0c7300daBill Richardsonrunfutiltests: override DESTDIR = ${TEST_INSTALL_DIR} 1032eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonrunfutiltests: test_setup install 1033339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson tests/futility/run_test_scripts.sh ${DESTDIR} 1034339f7e030cebe98a072d37acccbd1f0b4c1dea9bBill Richardson ${RUNTEST} ${BUILD_RUN}/tests/futility/test_not_really 1035844bce57471153664c78993dab453e87891bb969Randall Spangler 10365d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Run long tests, including all permutations of encryption keys (instead of 1037786a5dca74387de5ffdc51ca5a099a4e90f406daRandall Spangler# just the ones we use) and tests of currently-unused code. 10385d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# Not run by automated build. 1039acb2ee977b8dd139b01b68d0e269ea6bcc425c2bBill Richardson.PHONY: runlongtests 1040eecc18fc953bd367d3cb5aa006df4b153d20a45eBill Richardsonrunlongtests: test_setup genkeys genfuzztestcases 1041e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS} --all 1042e061a256549607a56d771eb8ddae5d0dd90d519cRandall Spangler ${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS} --all 10435d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/run_preamble_tests.sh --all 10445d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler tests/run_vbutil_tests.sh --all 10455d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 10465d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# TODO: tests to run when ported to new API 10475d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# ./run_image_verification_tests.sh 10485d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# # Splicing tests 10495d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# ${BUILD}/tests/firmware_splicing_tests 10505d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# ${BUILD}/tests/kernel_splicing_tests 10515d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# # Rollback Tests 10525d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# ${BUILD}/tests/firmware_rollback_tests 10535d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler# ${BUILD}/tests/kernel_rollback_tests 10545d9bbf2bbd7b8dfad45d8ddfea6512987736e523Randall Spangler 105559d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler# Code coverage 105659d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler.PHONY: coverage_init 105759d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage_init: test_setup 105859d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler rm -f ${COV_INFO}* 105959d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler lcov -c -i -d . -b . -o ${COV_INFO}.initial 106059d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler 106159d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler.PHONY: coverage_html 106259d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage_html: 106359d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler lcov -c -d . -b . -o ${COV_INFO}.tests 106459d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler lcov -a ${COV_INFO}.initial -a ${COV_INFO}.tests -o ${COV_INFO}.total 106559d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler lcov -r ${COV_INFO}.total '/usr/*' '*/linktest/*' -o ${COV_INFO}.local 106659d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler genhtml ${COV_INFO}.local -o ${BUILD}/coverage 106759d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler 106859d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler# Generate addtional coverage stats just for firmware subdir, because the 106959d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler# per-directory stats for the whole project don't include their own subdirs. 107049cb0d3471e768da11fe76b65769bd57dca38bd7Randall Spangler lcov -r ${COV_INFO}.local '*/stub/*' -o ${COV_INFO}.nostub 107149cb0d3471e768da11fe76b65769bd57dca38bd7Randall Spangler lcov -e ${COV_INFO}.nostub '${SRCDIR}/firmware/*' \ 107259d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler -o ${COV_INFO}.firmware 107359d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler 107459d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler.PHONY: coverage 107559d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglerifeq (${COV},) 107659d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage: 107759d7508c2261a8371715b28f663b8b2efbb5a895Randall Spangler $(error Build coverage like this: make clean && COV=1 make) 107859d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglerelse 107959d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglercoverage: coverage_init runtests coverage_html 108059d7508c2261a8371715b28f663b8b2efbb5a895Randall Spanglerendif 10811912bbae89b82c10819b01d039e140e39c668fc7Bill Richardson 10821912bbae89b82c10819b01d039e140e39c668fc7Bill Richardson# Include generated dependencies 10831912bbae89b82c10819b01d039e140e39c668fc7Bill RichardsonALL_DEPS += ${ALL_OBJS:%.o=%.o.d} 10841912bbae89b82c10819b01d039e140e39c668fc7Bill Richardson-include ${ALL_DEPS} 1085