blob: 53bc4f8ebc48094eac61352f5f7bd7fd1d79a7e9 [file] [log] [blame]
Bill Richardson6f396152014-07-15 12:52:19 -07001# Copyright 2013 The Chromium OS Authors. All rights reserved.
Gaurav Shah322536d2010-01-28 15:01:23 -08002# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
Simon Glass6d696e52011-11-14 13:46:33 -08005# This Makefile normally builds in a 'build' subdir, but use
6#
7# make BUILD=<dir>
8#
Bill Richardsoneecc18f2013-01-17 15:28:17 -08009# to put the output somewhere else.
10
11##############################################################################
12# Make variables come in two flavors, immediate or deferred.
13#
14# Variable definitions are parsed like this:
15#
16# IMMEDIATE = DEFERRED
17# or
18# IMMEDIATE := IMMEDIATE
19#
20# Rules are parsed this way:
21#
22# IMMEDIATE : IMMEDIATE
23# DEFERRED
24#
25# So you can assign variables in any order if they're only to be used in
26# actions, but if you use a variable in either the target or prerequisite of a
27# rule, the rule will be constructed using only the top-down, immediate value.
28#
29# So we'll try to define all the variables first. Then the rules.
30#
31
32##############################################################################
33# Configuration variables come first.
34#
35# Our convention is that we only use := for variables that will never be
36# changed or appended. They must be defined before being used anywhere.
37
Bill Richardsonc9bf3482013-02-13 14:38:29 -080038# We should only run pwd once, not every time we refer to ${BUILD}.
Randall Spanglere061a252013-01-22 15:34:07 -080039SRCDIR := $(shell pwd)
Bill Richardson64ddad72014-08-29 23:49:23 -070040export SRCDIR
Mike Frysingerc8c87b32015-01-15 17:04:40 -050041BUILD = ${SRCDIR}/build
Randall Spangler844bce52013-01-15 16:16:43 -080042export BUILD
Simon Glass6d696e52011-11-14 13:46:33 -080043
Bill Richardsonc9bf3482013-02-13 14:38:29 -080044# Stuff for 'make install'
Bill Richardsonfeb25182013-03-07 12:54:29 -080045INSTALL = install
Bill Richardsonefa87562014-09-11 10:41:51 -070046DESTDIR = /usr/local
Nam T. Nguyen07d90432015-02-17 13:26:44 -080047LIBDIR ?= lib
Bill Richardsonc9bf3482013-02-13 14:38:29 -080048
Bill Richardsoncfe83a82014-12-04 11:29:57 -080049# Default values
50DEV_DEBUG_FORCE=
51
Bill Richardsonfeb25182013-03-07 12:54:29 -080052# Where exactly do the pieces go?
Bill Richardson6f396152014-07-15 12:52:19 -070053# UB_DIR = utility binary directory
Nam T. Nguyen07d90432015-02-17 13:26:44 -080054# ULP_DIR = pkgconfig directory, usually /usr/lib/pkgconfig
Mike Frysinger9c57bd82015-03-12 03:52:40 -040055# UI_DIR = include directory for library headers
56# US_DIR = shared data directory (for static content like devkeys)
Bill Richardsoncfe83a82014-12-04 11:29:57 -080057# DF_DIR = utility defaults directory
Bill Richardson6f396152014-07-15 12:52:19 -070058# VB_DIR = vboot binary directory for dev-mode-only scripts
Bill Richardsonc9bf3482013-02-13 14:38:29 -080059ifeq (${MINIMAL},)
Bill Richardson6f396152014-07-15 12:52:19 -070060# Host install just puts everything where it's told
Bill Richardsonefa87562014-09-11 10:41:51 -070061UB_DIR=${DESTDIR}/bin
Mike Frysinger9c57bd82015-03-12 03:52:40 -040062UL_DIR=${DESTDIR}/${LIBDIR}
63ULP_DIR=${UL_DIR}/pkgconfig
64UI_DIR=${DESTDIR}/include/vboot
65US_DIR=${DESTDIR}/share/vboot
Bill Richardsoncfe83a82014-12-04 11:29:57 -080066DF_DIR=${DESTDIR}/default
Bill Richardsonefa87562014-09-11 10:41:51 -070067VB_DIR=${DESTDIR}/bin
Bill Richardsonc9bf3482013-02-13 14:38:29 -080068else
Bill Richardsonefa87562014-09-11 10:41:51 -070069# Target install puts things into different places
Bill Richardson6f396152014-07-15 12:52:19 -070070UB_DIR=${DESTDIR}/usr/bin
Mike Frysinger9c57bd82015-03-12 03:52:40 -040071UL_DIR=${DESTDIR}/usr/${LIBDIR}
72ULP_DIR=${UL_DIR}/pkgconfig
73UI_DIR=${DESTDIR}/usr/include/vboot
74US_DIR=${DESTDIR}/usr/share/vboot
Bill Richardsoncfe83a82014-12-04 11:29:57 -080075DF_DIR=${DESTDIR}/etc/default
Mike Frysinger9c57bd82015-03-12 03:52:40 -040076VB_DIR=${US_DIR}/bin
Bill Richardsonc9bf3482013-02-13 14:38:29 -080077endif
Randall Spangler5d9bbf22013-01-08 10:44:23 -080078
Bill Richardsoneecc18f2013-01-17 15:28:17 -080079# Where to install the (exportable) executables for testing?
80TEST_INSTALL_DIR = ${BUILD}/install_for_test
81
82# Verbose? Use V=1
83ifeq (${V},)
84Q := @
85endif
86
Simon Glass661ae9e2013-03-26 11:39:21 -070087# Quiet? Use QUIET=1
Mike Frysingerc8c87b32015-01-15 17:04:40 -050088ifeq (${QUIET},)
Simon Glass661ae9e2013-03-26 11:39:21 -070089PRINTF := printf
90else
91PRINTF := :
92endif
93
Randall Spangler61a2eb32013-01-23 10:20:16 -080094# Architecture detection
95_machname := $(shell uname -m)
96HOST_ARCH ?= ${_machname}
97
98# ARCH and/or FIRMWARE_ARCH are defined by the Chromium OS ebuild.
99# Pick a sane target architecture if none is defined.
100ifeq (${ARCH},)
101 ARCH := ${HOST_ARCH}
Paul Kocialkowski3467bd72016-07-12 22:24:16 +0200102endif
103
104ifeq (${ARCH},armv7l)
105 override ARCH := arm
Randall Spangler61a2eb32013-01-23 10:20:16 -0800106else ifeq (${ARCH},i386)
107 override ARCH := x86
108else ifeq (${ARCH},amd64)
109 override ARCH := x86_64
110endif
111
112# FIRMWARE_ARCH is only defined by the Chromium OS ebuild if compiling
113# for a firmware target (such as u-boot or depthcharge). It must map
114# to the same consistent set of architectures as the host.
115ifeq (${FIRMWARE_ARCH},i386)
116 override FIRMWARE_ARCH := x86
117else ifeq (${FIRMWARE_ARCH},amd64)
118 override FIRMWARE_ARCH := x86_64
Stefan Reinauerd96b25d2013-09-19 14:24:29 -0700119else ifeq (${FIRMWARE_ARCH},armv7)
120 override FIRMWARE_ARCH := arm
Randall Spangler61a2eb32013-01-23 10:20:16 -0800121endif
122
Simon Glassb265c342011-11-16 15:09:51 -0800123# Provide default CC and CFLAGS for firmware builds; if you have any -D flags,
124# please add them after this point (e.g., -DVBOOT_DEBUG).
Che-Liang Chiou74359b72011-06-21 15:25:51 -0700125#
Che-Liang Chiou6b0003c2011-10-14 11:11:28 +0800126# TODO(crosbug.com/16808) We hard-code u-boot's compiler flags here just
127# temporarily. As we are still investigating which flags are necessary for
128# maintaining a compatible ABI, etc. between u-boot and vboot_reference.
Che-Liang Chiou74359b72011-06-21 15:25:51 -0700129#
Simon Glassb265c342011-11-16 15:09:51 -0800130# As a first step, this makes the setting of CC and CFLAGS here optional, to
131# permit a calling script or Makefile to set these.
Che-Liang Chiou74359b72011-06-21 15:25:51 -0700132#
Simon Glassb265c342011-11-16 15:09:51 -0800133# Flag ordering: arch, then -f, then -m, then -W
134DEBUG_FLAGS := $(if ${DEBUG},-g -O0,-Os)
Mike Frysinger47c2aa02015-03-12 03:56:06 -0400135WERROR := -Werror
Simon Glassb265c342011-11-16 15:09:51 -0800136COMMON_FLAGS := -nostdinc -pipe \
137 -ffreestanding -fno-builtin -fno-stack-protector \
Mike Frysinger47c2aa02015-03-12 03:56:06 -0400138 ${WERROR} -Wall -Wstrict-prototypes ${DEBUG_FLAGS}
Simon Glassb265c342011-11-16 15:09:51 -0800139
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800140# Note: FIRMWARE_ARCH is defined by the Chromium OS ebuild.
141ifeq (${FIRMWARE_ARCH}, arm)
Simon Glassb265c342011-11-16 15:09:51 -0800142CC ?= armv7a-cros-linux-gnueabi-gcc
143CFLAGS ?= -march=armv5 \
144 -fno-common -ffixed-r8 \
Doug Andersond50b27d2012-05-11 12:08:02 -0700145 -mfloat-abi=hard -marm -mabi=aapcs-linux -mno-thumb-interwork \
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800146 ${COMMON_FLAGS}
Randall Spangler61a2eb32013-01-23 10:20:16 -0800147else ifeq (${FIRMWARE_ARCH}, x86)
Simon Glassb265c342011-11-16 15:09:51 -0800148CC ?= i686-pc-linux-gnu-gcc
149# Drop -march=i386 to permit use of SSE instructions
150CFLAGS ?= \
151 -ffunction-sections -fvisibility=hidden -fno-strict-aliasing \
152 -fomit-frame-pointer -fno-toplevel-reorder -fno-dwarf2-cfi-asm \
Gabe Black46e00e62013-12-18 18:23:24 -0800153 -mpreferred-stack-boundary=2 \
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800154 ${COMMON_FLAGS}
155else ifeq (${FIRMWARE_ARCH}, x86_64)
156CFLAGS ?= ${COMMON_FLAGS} \
Simon Glass8e85e982011-11-22 13:54:50 -0800157 -fvisibility=hidden -fno-strict-aliasing -fomit-frame-pointer
Randall Spangler844bce52013-01-15 16:16:43 -0800158else
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800159# FIRMWARE_ARCH not defined; assuming local compile.
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800160CC ?= gcc
Doug Evansaad73ca2015-11-19 14:58:25 -0800161CFLAGS += -DCHROMEOS_ENVIRONMENT -Wall ${WERROR} ${DEBUG_FLAGS}
Che-Liang Chiou34be8272011-01-27 16:44:36 +0800162endif
163
Alexandru M Stan65029352016-01-12 11:45:29 -0800164ifneq (${CUSTOM_MUSIC},)
165CFLAGS += -DCUSTOM_MUSIC
166endif
167
Che-Liang Chiou34be8272011-01-27 16:44:36 +0800168ifneq (${DEBUG},)
169CFLAGS += -DVBOOT_DEBUG
vbendebb2b0fcc2010-07-15 15:09:47 -0700170endif
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +0800171
vbendebb2b0fcc2010-07-15 15:09:47 -0700172ifeq (${DISABLE_NDEBUG},)
173CFLAGS += -DNDEBUG
174endif
175
Bill Richardsonfeb25182013-03-07 12:54:29 -0800176ifneq (${FORCE_LOGGING_ON},)
177CFLAGS += -DFORCE_LOGGING_ON=${FORCE_LOGGING_ON}
178endif
179
Randall Spangler6014c042014-07-22 14:42:58 -0700180ifneq (${PD_SYNC},)
181CFLAGS += -DPD_SYNC
182endif
183
Nam T. Nguyenf44ebbe2015-02-12 11:10:35 -0800184ifneq (${USE_MTD},)
185CFLAGS += -DUSE_MTD
186LDLIBS += -lmtdutils
187endif
188
Vadim Bendebury239aa212016-06-28 09:46:14 -0700189ifneq (${TPM2_MODE},)
190CFLAGS += -DTPM2_MODE
191endif
192
Nam T. Nguyen07d90432015-02-17 13:26:44 -0800193# NOTE: We don't use these files but they are useful for other packages to
194# query about required compiling/linking flags.
195PC_IN_FILES = vboot_host.pc.in
196
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800197# Create / use dependency files
198CFLAGS += -MMD -MF $@.d
Simon Glassb265c342011-11-16 15:09:51 -0800199
Bertrand SIMONNETf8f807a2014-06-30 09:41:13 -0700200ifeq (${FIRMWARE_ARCH},)
201# Creates position independent code for non firmware target.
202CFLAGS += -fPIE
203endif
204
Bill Richardson0c3ba242013-03-29 11:09:30 -0700205# These are required to access large disks and files on 32-bit systems.
206CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
207
Randall Spangler59d75082013-01-23 09:29:54 -0800208# Code coverage
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800209ifneq (${COV},)
Bill Richardsond2d08b22014-07-08 16:31:40 -0700210 COV_FLAGS = -O0 --coverage -DCOVERAGE
Randall Spangler59d75082013-01-23 09:29:54 -0800211 CFLAGS += ${COV_FLAGS}
212 LDFLAGS += ${COV_FLAGS}
213 COV_INFO = ${BUILD}/coverage.info
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +0800214endif
Gaurav Shah322536d2010-01-28 15:01:23 -0800215
David Riley05987b12015-02-05 19:22:49 -0800216ifdef HAVE_MACOS
217 CFLAGS += -DHAVE_MACOS -Wno-deprecated-declarations
218endif
219
Doug Evans58cb8c52015-11-19 15:57:23 -0800220# Musl doesn't have execinfo.h.
221ifndef HAVE_MUSL
222 CFLAGS += -DHAVE_EXECINFO_H
223endif
224
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800225# And a few more default utilities
226LD = ${CC}
Bill Richardson6df3e332014-10-02 18:50:33 -0700227CXX ?= g++
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800228PKG_CONFIG ?= pkg-config
229
Mike Frysinger0b789c52015-01-15 15:37:59 -0500230# Static?
231ifneq (${STATIC},)
232LDFLAGS += -static
233PKG_CONFIG += --static
234endif
235
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800236# Determine QEMU architecture needed, if any
237ifeq (${ARCH},${HOST_ARCH})
238 # Same architecture; no need for QEMU
239 QEMU_ARCH :=
Randall Spangler61a2eb32013-01-23 10:20:16 -0800240else ifeq (${HOST_ARCH}-${ARCH},x86_64-x86)
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800241 # 64-bit host can run 32-bit targets directly
242 QEMU_ARCH :=
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800243else
244 QEMU_ARCH := ${ARCH}
245endif
246
247# The top of the chroot for qemu must be passed in via the SYSROOT environment
248# variable. In the Chromium OS chroot, this is done automatically by the
249# ebuild.
250
251ifeq (${QEMU_ARCH},)
252 # Path to build output for running tests is same as for building
253 BUILD_RUN = ${BUILD}
Randall Spanglere061a252013-01-22 15:34:07 -0800254 SRC_RUN = ${SRCDIR}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800255else
256 $(info Using qemu for testing.)
257 # Path to build output for running tests is different in the chroot
258 BUILD_RUN = $(subst ${SYSROOT},,${BUILD})
Randall Spanglere061a252013-01-22 15:34:07 -0800259 SRC_RUN = $(subst ${SYSROOT},,${SRCDIR})
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800260
261 QEMU_BIN = qemu-${QEMU_ARCH}
Randall Spanglere061a252013-01-22 15:34:07 -0800262 QEMU_RUN = ${BUILD_RUN}/${QEMU_BIN}
263 export QEMU_RUN
264
265 RUNTEST = tests/test_using_qemu.sh
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800266endif
267
Randall Spanglere061a252013-01-22 15:34:07 -0800268export BUILD_RUN
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800269
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800270##############################################################################
Doug Evans0e5f54d2015-11-19 14:14:18 -0800271# The default target is here, to allow dependencies to be expressed below
272# without accidentally changing the default target.
273
274# Default target.
275.PHONY: all
276all: fwlib fwlib2x fwlib20 fwlib21 \
277 $(if ${FIRMWARE_ARCH},,host_stuff) \
278 $(if ${COV},coverage)
279
280##############################################################################
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800281# Now we need to describe everything we might want or need to build
282
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800283# Everything wants these headers.
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800284INCLUDES += \
285 -Ifirmware/include \
286 -Ifirmware/lib/include \
287 -Ifirmware/lib/cgptlib/include \
288 -Ifirmware/lib/cryptolib/include \
Randall Spangler786acda2014-05-22 13:27:07 -0700289 -Ifirmware/lib/tpm_lite/include \
Randall Spangler98263a12016-06-02 16:05:49 -0700290 -Ifirmware/2lib/include \
291 -Ifirmware/lib20/include
Bill Richardson0b8f35c2010-05-26 09:18:38 -0700292
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800293# If we're not building for a specific target, just stub out things like the
294# TPM commands and various external functions that are provided by the BIOS.
295ifeq (${FIRMWARE_ARCH},)
Randall Spangler31f04ad2016-06-17 10:57:53 -0700296INCLUDES += -Ihost/include -Ihost/lib/include
297INCLUDES += -Ihost/lib21/include -Ifirmware/lib21/include
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +0800298endif
Gaurav Shah322536d2010-01-28 15:01:23 -0800299
Bill Richardson78299022014-06-20 14:33:00 -0700300# Firmware library, used by the other firmware components (depthcharge,
301# coreboot, etc.). It doesn't need exporting to some other place; they'll build
302# this source tree locally and link to it directly.
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800303FWLIB = ${BUILD}/vboot_fw.a
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800304
Bill Richardson06eb78c2015-01-27 15:01:51 -0800305# Smaller firmware library common to all vboot 2.x, used only for
306# 1) compile-time tests of the public API or
307# 2) linking with an actual 2.0 or 2.1 implementation
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800308FWLIB2X = ${BUILD}/vboot_fw2x.a
Bill Richardson06eb78c2015-01-27 15:01:51 -0800309
310# Vboot 2.0 (deprecated - see firmware/README)
311FWLIB20 = ${BUILD}/vboot_fw20.a
312# Vboot 2.1 (not yet ready - see firmware/README)
Randall Spanglera5b69b02014-12-02 13:41:29 -0800313FWLIB21 = ${BUILD}/vboot_fw21.a
Randall Spangler786acda2014-05-22 13:27:07 -0700314
Daisuke Nojiri9928e2f2016-09-19 16:46:37 -0700315# Static library containing firmware APIs for common boot flow
Daisuke Nojiri825a2f82016-05-03 13:24:10 -0700316BDBLIB = ${BUILD}/bdb.a
317
Randall Spangler93943262013-02-26 11:03:57 -0800318# Firmware library sources needed by VbInit() call
319VBINIT_SRCS = \
Randall Spangler93943262013-02-26 11:03:57 -0800320 firmware/lib/utility.c \
Randall Spangler93943262013-02-26 11:03:57 -0800321 firmware/lib/vboot_common_init.c \
322 firmware/lib/vboot_nvstorage.c \
Simon Glass527ba812013-07-25 08:48:47 -0600323 firmware/lib/region-init.c \
Randall Spangler93943262013-02-26 11:03:57 -0800324
325# Additional firmware library sources needed by VbSelectFirmware() call
326VBSF_SRCS = \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800327 firmware/lib/cryptolib/padding.c \
328 firmware/lib/cryptolib/rsa.c \
329 firmware/lib/cryptolib/rsa_utility.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800330 firmware/lib/stateful_util.c \
Randall Spangler93943262013-02-26 11:03:57 -0800331 firmware/lib/vboot_common.c \
Simon Glass527ba812013-07-25 08:48:47 -0600332 firmware/lib/region-fw.c \
Randall Spangler93943262013-02-26 11:03:57 -0800333
334# Additional firmware library sources needed by VbSelectAndLoadKernel() call
335VBSLK_SRCS = \
336 firmware/lib/cgptlib/cgptlib.c \
337 firmware/lib/cgptlib/cgptlib_internal.c \
338 firmware/lib/cgptlib/crc32.c \
Dan Ehrenberg7c2beb02014-10-21 16:15:54 -0700339 firmware/lib/gpt_misc.c \
Randall Spangler93943262013-02-26 11:03:57 -0800340 firmware/lib/utility_string.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800341 firmware/lib/vboot_api_kernel.c \
342 firmware/lib/vboot_audio.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800343 firmware/lib/vboot_display.c \
Simon Glass527ba812013-07-25 08:48:47 -0600344 firmware/lib/vboot_kernel.c \
345 firmware/lib/region-kernel.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800346
Bill Richardson06eb78c2015-01-27 15:01:51 -0800347# Code common to both vboot 2.0 (old structs) and 2.1 (new structs)
348FWLIB2X_SRCS = \
Randall Spanglera7ab8b52014-06-10 17:05:08 -0700349 firmware/2lib/2api.c \
Randall Spangler786acda2014-05-22 13:27:07 -0700350 firmware/2lib/2common.c \
Randall Spangler3333e572014-05-14 11:37:52 -0700351 firmware/2lib/2crc8.c \
352 firmware/2lib/2misc.c \
353 firmware/2lib/2nvstorage.c \
Randall Spanglere166d042014-05-13 09:24:52 -0700354 firmware/2lib/2rsa.c \
Randall Spangler3333e572014-05-14 11:37:52 -0700355 firmware/2lib/2secdata.c \
Randall Spanglerbf9c2762015-05-12 13:44:30 -0700356 firmware/2lib/2secdatak.c \
Randall Spanglere166d042014-05-13 09:24:52 -0700357 firmware/2lib/2sha1.c \
358 firmware/2lib/2sha256.c \
359 firmware/2lib/2sha512.c \
Daisuke Nojiri62d482e2015-01-29 14:37:25 -0800360 firmware/2lib/2sha_utility.c \
Daisuke Nojirif3f9e002016-05-05 17:21:29 -0700361 firmware/2lib/2tpm_bootmode.c \
362 firmware/2lib/2hmac.c
Randall Spanglera5b69b02014-12-02 13:41:29 -0800363
Randall Spangler108d9912014-12-02 15:55:56 -0800364FWLIB20_SRCS = \
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800365 firmware/lib20/api.c \
Randall Spanglerd7f0f932015-05-19 13:41:09 -0700366 firmware/lib20/api_kernel.c \
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800367 firmware/lib20/common.c \
Randall Spangler2d25e832015-05-12 16:39:01 -0700368 firmware/lib20/kernel.c \
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800369 firmware/lib20/misc.c \
370 firmware/lib20/packed_key.c
Randall Spangler108d9912014-12-02 15:55:56 -0800371
Randall Spanglera5b69b02014-12-02 13:41:29 -0800372FWLIB21_SRCS = \
373 firmware/lib21/api.c \
374 firmware/lib21/common.c \
375 firmware/lib21/misc.c \
376 firmware/lib21/packed_key.c
Randall Spangler786acda2014-05-22 13:27:07 -0700377
Daisuke Nojiri825a2f82016-05-03 13:24:10 -0700378BDBLIB_SRCS = \
379 firmware/bdb/bdb.c \
Daisuke Nojiri10d5cfe2016-09-20 13:58:53 -0700380 firmware/bdb/ecdsa.c \
Daisuke Nojiri85dbb342016-05-04 14:55:57 -0700381 firmware/bdb/misc.c \
382 firmware/bdb/rsa.c \
Daisuke Nojiri7fbebd92016-05-06 12:32:38 -0700383 firmware/bdb/secrets.c \
Daisuke Nojiri8130e502016-09-14 12:55:20 -0700384 firmware/bdb/sha.c \
Daisuke Nojiri6b5c4e92016-05-06 12:32:38 -0700385 firmware/bdb/stub.c \
386 firmware/bdb/nvm.c
Daisuke Nojiri825a2f82016-05-03 13:24:10 -0700387
Andrey Pronin1becb0d2016-07-06 19:10:46 -0700388# TPM lightweight command library
Vadim Bendebury239aa212016-06-28 09:46:14 -0700389ifeq (${TPM2_MODE},)
Andrey Pronin1becb0d2016-07-06 19:10:46 -0700390TLCL_SRCS = \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800391 firmware/lib/tpm_lite/tlcl.c
Vadim Bendebury239aa212016-06-28 09:46:14 -0700392else
Andrey Pronin1becb0d2016-07-06 19:10:46 -0700393TLCL_SRCS = \
Vadim Bendebury239aa212016-06-28 09:46:14 -0700394 firmware/lib/tpm2_lite/tlcl.c \
395 firmware/lib/tpm2_lite/marshaling.c
396endif
Andrey Pronin1becb0d2016-07-06 19:10:46 -0700397TLCL_OBJS_FOR_TEST = $(TLCL_SRCS:%.c=${BUILD}/%_for_test.o)
398
399# Support real TPM unless BIOS sets MOCK_TPM
400ifeq (${MOCK_TPM},)
401VBINIT_SRCS += \
402 firmware/lib/rollback_index.c \
403 ${TLCL_SRCS}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800404else
Randall Spangler93943262013-02-26 11:03:57 -0800405VBINIT_SRCS += \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800406 firmware/lib/mocked_rollback_index.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800407 firmware/lib/tpm_lite/mocked_tlcl.c
408endif
409
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800410ifeq (${FIRMWARE_ARCH},)
411# Include BIOS stubs in the firmware library when compiling for host
Randall Spangler93943262013-02-26 11:03:57 -0800412# TODO: split out other stub funcs too
413VBINIT_SRCS += \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800414 firmware/stub/tpm_lite_stub.c \
Simon Glass527ba812013-07-25 08:48:47 -0600415 firmware/stub/vboot_api_stub_init.c \
416 firmware/stub/vboot_api_stub_region.c
Randall Spangler93943262013-02-26 11:03:57 -0800417
418VBSF_SRCS += \
419 firmware/stub/vboot_api_stub_sf.c
420
421VBSLK_SRCS += \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800422 firmware/stub/vboot_api_stub.c \
Dan Ehrenberg5dc75d12014-10-07 14:55:37 -0700423 firmware/stub/vboot_api_stub_disk.c \
424 firmware/stub/vboot_api_stub_stream.c
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700425
Bill Richardson06eb78c2015-01-27 15:01:51 -0800426FWLIB2X_SRCS += \
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700427 firmware/2lib/2stub.c
428
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800429endif
430
Randall Spangler93943262013-02-26 11:03:57 -0800431VBSF_SRCS += ${VBINIT_SRCS}
432FWLIB_SRCS += ${VBSF_SRCS} ${VBSLK_SRCS}
433
434VBINIT_OBJS = ${VBINIT_SRCS:%.c=${BUILD}/%.o}
435VBSF_OBJS = ${VBSF_SRCS:%.c=${BUILD}/%.o}
Randall Spanglera5b69b02014-12-02 13:41:29 -0800436ALL_OBJS += ${VBINIT_OBJS} ${VBSF_OBJS}
Randall Spangler93943262013-02-26 11:03:57 -0800437
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800438FWLIB_OBJS = ${FWLIB_SRCS:%.c=${BUILD}/%.o}
Bill Richardson06eb78c2015-01-27 15:01:51 -0800439FWLIB2X_OBJS = ${FWLIB2X_SRCS:%.c=${BUILD}/%.o}
Randall Spangleraaaff862014-12-01 15:40:08 -0800440FWLIB20_OBJS = ${FWLIB20_SRCS:%.c=${BUILD}/%.o}
Randall Spanglera5b69b02014-12-02 13:41:29 -0800441FWLIB21_OBJS = ${FWLIB21_SRCS:%.c=${BUILD}/%.o}
Daisuke Nojiri825a2f82016-05-03 13:24:10 -0700442BDBLIB_OBJS = ${BDBLIB_SRCS:%.c=${BUILD}/%.o}
443ALL_OBJS += ${FWLIB_OBJS} ${FWLIB2X_OBJS} ${FWLIB20_OBJS} ${FWLIB21_OBJS} \
444 $(BDBLIB_OBJS}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800445
Bill Richardson78299022014-06-20 14:33:00 -0700446# Intermediate library for the vboot_reference utilities to link against.
447UTILLIB = ${BUILD}/libvboot_util.a
Daisuke Nojiri9928e2f2016-09-19 16:46:37 -0700448
449# Static library containing both host and firmware APIs
Daisuke Nojiri825a2f82016-05-03 13:24:10 -0700450UTILBDB = ${BUILD}/libvboot_utilbdb.a
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800451
Bill Richardson78299022014-06-20 14:33:00 -0700452UTILLIB_SRCS = \
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800453 cgpt/cgpt_create.c \
454 cgpt/cgpt_add.c \
455 cgpt/cgpt_boot.c \
456 cgpt/cgpt_show.c \
457 cgpt/cgpt_repair.c \
458 cgpt/cgpt_prioritize.c \
459 cgpt/cgpt_common.c \
Bill Richardson6f396152014-07-15 12:52:19 -0700460 futility/dump_kernel_config_lib.c \
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800461 host/arch/${ARCH}/lib/crossystem_arch.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800462 host/lib/crossystem.c \
463 host/lib/file_keys.c \
464 host/lib/fmap.c \
465 host/lib/host_common.c \
466 host/lib/host_key.c \
Randall Spangler814aaf02016-06-17 10:48:16 -0700467 host/lib/host_key2.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800468 host/lib/host_keyblock.c \
469 host/lib/host_misc.c \
Bill Richardson78299022014-06-20 14:33:00 -0700470 host/lib/util_misc.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800471 host/lib/host_signature.c \
Randall Spangler814aaf02016-06-17 10:48:16 -0700472 host/lib/host_signature2.c \
Randall Spangler31f04ad2016-06-17 10:57:53 -0700473 host/lib/signature_digest.c \
Randall Spanglera5b69b02014-12-02 13:41:29 -0800474 host/lib21/host_fw_preamble.c \
475 host/lib21/host_key.c \
476 host/lib21/host_keyblock.c \
477 host/lib21/host_misc.c \
478 host/lib21/host_signature.c
Randall Spangler02e11b32014-11-19 12:48:36 -0800479
Randall Spangler31f04ad2016-06-17 10:57:53 -0700480UTILLIB_OBJS = ${UTILLIB_SRCS:%.c=${BUILD}/%.o}
481ALL_OBJS += ${UTILLIB_OBJS}
Bill Richardson78299022014-06-20 14:33:00 -0700482
Daisuke Nojiri9928e2f2016-09-19 16:46:37 -0700483# Source files containing host side APIs for common boot flow
Daisuke Nojiri825a2f82016-05-03 13:24:10 -0700484UTILBDB_SRCS += \
485 firmware/bdb/host.c
486
487UTILBDB_OBJS = ${UTILBDB_SRCS:%.c=${BUILD}/%.o}
488ALL_OBJS += ${UTILBDB_OBJS}
489
Bill Richardson78299022014-06-20 14:33:00 -0700490# Externally exported library for some target userspace apps to link with
491# (cryptohome, updater, etc.)
492HOSTLIB = ${BUILD}/libvboot_host.a
493
494HOSTLIB_SRCS = \
495 cgpt/cgpt_add.c \
496 cgpt/cgpt_boot.c \
497 cgpt/cgpt_common.c \
498 cgpt/cgpt_create.c \
499 cgpt/cgpt_prioritize.c \
Randall Spanglerbf6263d2016-10-13 16:27:45 -0700500 firmware/2lib/2crc8.c \
Bill Richardson78299022014-06-20 14:33:00 -0700501 firmware/lib/cgptlib/cgptlib_internal.c \
502 firmware/lib/cgptlib/crc32.c \
Dan Ehrenberg32a999d2014-11-21 15:44:05 -0800503 firmware/lib/gpt_misc.c \
Andrey Pronin1becb0d2016-07-06 19:10:46 -0700504 ${TLCL_SRCS} \
Bill Richardson78299022014-06-20 14:33:00 -0700505 firmware/lib/utility_string.c \
506 firmware/lib/vboot_nvstorage.c \
507 firmware/stub/tpm_lite_stub.c \
Furquan Shaikh7a1c0d12015-06-02 10:32:52 -0700508 firmware/stub/vboot_api_stub.c \
Dan Ehrenberg32a999d2014-11-21 15:44:05 -0800509 firmware/stub/vboot_api_stub_disk.c \
Bill Richardson78299022014-06-20 14:33:00 -0700510 firmware/stub/vboot_api_stub_init.c \
Dan Ehrenberg32a999d2014-11-21 15:44:05 -0800511 firmware/stub/vboot_api_stub_sf.c \
Bill Richardson6f396152014-07-15 12:52:19 -0700512 futility/dump_kernel_config_lib.c \
Bill Richardson78299022014-06-20 14:33:00 -0700513 host/arch/${ARCH}/lib/crossystem_arch.c \
514 host/lib/crossystem.c \
Zach Reizner317bb492015-02-20 14:55:02 -0800515 host/lib/extract_vmlinuz.c \
Nam T. Nguyen6ee52d92014-10-24 13:20:39 -0700516 host/lib/fmap.c \
Bill Richardson6f396152014-07-15 12:52:19 -0700517 host/lib/host_misc.c
Bill Richardson78299022014-06-20 14:33:00 -0700518
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800519HOSTLIB_OBJS = ${HOSTLIB_SRCS:%.c=${BUILD}/%.o}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800520ALL_OBJS += ${HOSTLIB_OBJS}
521
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800522# Sigh. For historical reasons, the autoupdate installer must sometimes be a
523# 32-bit executable, even when everything else is 64-bit. But it only needs a
524# few functions, so let's just build those.
525TINYHOSTLIB = ${BUILD}/libtinyvboot_host.a
526
527TINYHOSTLIB_SRCS = \
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800528 cgpt/cgpt_add.c \
529 cgpt/cgpt_boot.c \
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800530 cgpt/cgpt_common.c \
Bill Richardson78299022014-06-20 14:33:00 -0700531 cgpt/cgpt_create.c \
532 cgpt/cgpt_prioritize.c \
Randall Spanglerbf6263d2016-10-13 16:27:45 -0700533 firmware/2lib/2crc8.c \
Bill Richardson78299022014-06-20 14:33:00 -0700534 firmware/lib/cgptlib/cgptlib_internal.c \
535 firmware/lib/cgptlib/crc32.c \
Dan Ehrenberg32a999d2014-11-21 15:44:05 -0800536 firmware/lib/gpt_misc.c \
Bill Richardson5fed2a62013-03-04 15:11:38 -0800537 firmware/lib/utility_string.c \
Furquan Shaikh7a1c0d12015-06-02 10:32:52 -0700538 firmware/stub/vboot_api_stub.c \
Dan Ehrenberg32a999d2014-11-21 15:44:05 -0800539 firmware/stub/vboot_api_stub_disk.c \
540 firmware/stub/vboot_api_stub_sf.c \
Zach Reizner317bb492015-02-20 14:55:02 -0800541 futility/dump_kernel_config_lib.c \
542 host/lib/extract_vmlinuz.c
Bill Richardson81a0b3d2013-02-28 13:53:09 -0800543
544TINYHOSTLIB_OBJS = ${TINYHOSTLIB_SRCS:%.c=${BUILD}/%.o}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800545
546# ----------------------------------------------------------------------------
547# Now for the userspace binaries
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800548
549CGPT = ${BUILD}/cgpt/cgpt
550
551CGPT_SRCS = \
552 cgpt/cgpt.c \
553 cgpt/cgpt_add.c \
554 cgpt/cgpt_boot.c \
555 cgpt/cgpt_common.c \
556 cgpt/cgpt_create.c \
557 cgpt/cgpt_find.c \
558 cgpt/cgpt_legacy.c \
Nam T. Nguyend1236e42015-01-08 11:43:27 -0800559 cgpt/cgpt_nor.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800560 cgpt/cgpt_prioritize.c \
561 cgpt/cgpt_repair.c \
562 cgpt/cgpt_show.c \
563 cgpt/cmd_add.c \
564 cgpt/cmd_boot.c \
565 cgpt/cmd_create.c \
566 cgpt/cmd_find.c \
567 cgpt/cmd_legacy.c \
568 cgpt/cmd_prioritize.c \
569 cgpt/cmd_repair.c \
Nam T. Nguyen8577b532014-11-25 13:26:53 -0800570 cgpt/cmd_show.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800571
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800572CGPT_OBJS = ${CGPT_SRCS:%.c=${BUILD}/%.o}
Nam T. Nguyend1236e42015-01-08 11:43:27 -0800573
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800574ALL_OBJS += ${CGPT_OBJS}
575
Nam T. Nguyend1236e42015-01-08 11:43:27 -0800576CGPT_WRAPPER = ${BUILD}/cgpt/cgpt_wrapper
577
578CGPT_WRAPPER_SRCS = \
579 cgpt/cgpt_nor.c \
580 cgpt/cgpt_wrapper.c
581
582CGPT_WRAPPER_OBJS = ${CGPT_WRAPPER_SRCS:%.c=${BUILD}/%.o}
583
584ALL_OBJS += ${CGPT_WRAPPER_OBJS}
585
Bill Richardsoncfe83a82014-12-04 11:29:57 -0800586# Utility defaults
587UTIL_DEFAULTS = ${BUILD}/default/vboot_reference
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800588
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800589# Scripts to install directly (not compiled)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800590UTIL_SCRIPTS = \
591 utility/dev_debug_vboot \
Bill Richardson4d49d342014-10-02 10:52:41 -0700592 utility/enable_dev_usb_boot
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800593
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800594ifeq (${MINIMAL},)
595UTIL_SCRIPTS += \
Bill Richardson4d49d342014-10-02 10:52:41 -0700596 utility/dev_make_keypair \
597 utility/vbutil_what_keys
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800598endif
599
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800600# These utilities should be linked statically.
601UTIL_NAMES_STATIC = \
Bill Richardson6f396152014-07-15 12:52:19 -0700602 utility/crossystem
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800603
604UTIL_NAMES = ${UTIL_NAMES_STATIC} \
Duncan Laurie0f078672014-09-19 14:39:09 -0700605 utility/dumpRSAPublicKey \
Bill Richardson6f396152014-07-15 12:52:19 -0700606 utility/tpmc
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800607
Andrey Pronin1becb0d2016-07-06 19:10:46 -0700608ifeq (${TPM2_MODE},)
609UTIL_NAMES += utility/tpm_init_temp_fix
610endif
611
Bill Richardson6f396152014-07-15 12:52:19 -0700612# TODO: Do we still need eficompress and efidecompress for anything?
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800613ifeq (${MINIMAL},)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800614UTIL_NAMES += \
Daisuke Nojiri8130e502016-09-14 12:55:20 -0700615 utility/bdb_extend \
Bill Richardson339f7e02013-04-05 09:49:24 -0700616 utility/bmpblk_font \
617 utility/bmpblk_utility \
618 utility/eficompress \
619 utility/efidecompress \
620 utility/load_kernel_test \
621 utility/pad_digest_utility \
622 utility/signature_digest_utility \
623 utility/verify_data
Brian Norris1d4c49b2016-07-22 10:11:09 -0700624
625LZMA_LIBS := $(shell ${PKG_CONFIG} --libs liblzma)
626YAML_LIBS := $(shell ${PKG_CONFIG} --libs yaml-0.1)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800627endif
628
Bill Richardson339f7e02013-04-05 09:49:24 -0700629UTIL_BINS_STATIC := $(addprefix ${BUILD}/,${UTIL_NAMES_STATIC})
630UTIL_BINS = $(addprefix ${BUILD}/,${UTIL_NAMES})
Bill Richardson1912bba2013-04-04 21:08:50 -0700631ALL_OBJS += $(addsuffix .o,${UTIL_BINS} ${UTIL_BINS_STATIC})
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800632
Bill Richardsonc9bf3482013-02-13 14:38:29 -0800633
634# Scripts for signing stuff.
635SIGNING_SCRIPTS = \
636 utility/tpm-nvsize \
637 utility/chromeos-tpm-recovery
638
639# These go in a different place.
640SIGNING_SCRIPTS_DEV = \
641 scripts/image_signing/resign_firmwarefd.sh \
642 scripts/image_signing/make_dev_firmware.sh \
643 scripts/image_signing/make_dev_ssd.sh \
644 scripts/image_signing/set_gbb_flags.sh
645
646# Installed, but not made executable.
647SIGNING_COMMON = scripts/image_signing/common_minimal.sh
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800648
Bill Richardson826db092013-01-14 12:37:15 -0800649
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800650# The unified firmware utility will eventually replace all the others
651FUTIL_BIN = ${BUILD}/futility/futility
Bill Richardson6db8c752013-04-05 13:30:43 -0700652# But we still need both static (tiny) and dynamic (with openssl) versions.
653FUTIL_STATIC_BIN = ${FUTIL_BIN}_s
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800654
Bill Richardson6f396152014-07-15 12:52:19 -0700655# These are the executables that are now built in to futility. We'll create
656# symlinks for these so the old names will still work.
Bill Richardsona1d9fe62014-09-05 12:52:27 -0700657FUTIL_SYMLINKS = \
Bill Richardsone1550442014-07-17 11:32:17 -0700658 dump_fmap \
659 dump_kernel_config \
Bill Richardsone1550442014-07-17 11:32:17 -0700660 gbb_utility \
Bill Richardsone1550442014-07-17 11:32:17 -0700661 vbutil_firmware \
662 vbutil_kernel \
663 vbutil_key \
Bill Richardson6f396152014-07-15 12:52:19 -0700664 vbutil_keyblock
Bill Richardsonfeb25182013-03-07 12:54:29 -0800665
Bill Richardson6db8c752013-04-05 13:30:43 -0700666FUTIL_STATIC_SRCS = \
Bill Richardsonfeb25182013-03-07 12:54:29 -0800667 futility/futility.c \
Bill Richardson20807b62013-04-09 10:15:26 -0700668 futility/cmd_dump_fmap.c \
Bill Richardsoncf6e78d2014-08-27 15:50:25 -0700669 futility/cmd_gbb_utility.c \
Randall Spangler14f12262015-07-17 09:44:29 -0700670 futility/misc.c \
671 futility/ryu_root_header.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800672
Bill Richardson6db8c752013-04-05 13:30:43 -0700673FUTIL_SRCS = \
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500674 ${FUTIL_STATIC_SRCS} \
Daisuke Nojirie43574c2016-09-16 16:51:42 -0700675 futility/cmd_bdb.c \
Bill Richardson4e4c1962015-02-03 17:07:15 -0800676 futility/cmd_create.c \
Bill Richardson6f396152014-07-15 12:52:19 -0700677 futility/cmd_dump_kernel_config.c \
Bill Richardson2e25e812014-09-03 11:34:27 -0700678 futility/cmd_load_fmap.c \
Bill Richardsonf4f395e2014-10-22 17:42:20 -0700679 futility/cmd_pcr.c \
Bill Richardsonf318ee22014-09-23 14:30:30 -0700680 futility/cmd_show.c \
681 futility/cmd_sign.c \
Bill Richardson6f396152014-07-15 12:52:19 -0700682 futility/cmd_vbutil_firmware.c \
683 futility/cmd_vbutil_kernel.c \
Bill Richardsonb84b81d2014-07-14 14:48:31 -0700684 futility/cmd_vbutil_key.c \
Randall Spanglerb8ff3972014-08-27 13:34:35 -0700685 futility/cmd_vbutil_keyblock.c \
Bill Richardson25593382015-01-30 12:22:28 -0800686 futility/file_type.c \
Bill Richardson091c7b12015-03-26 16:58:49 -0700687 futility/file_type_bios.c \
Bill Richardson7ed26122015-10-12 13:58:12 -0700688 futility/file_type_rwsig.c \
Bill Richardsonb5a43922015-03-26 15:59:06 -0700689 futility/file_type_usbpd1.c \
Bill Richardsonadd997f2015-02-04 16:47:16 -0800690 futility/vb1_helper.c \
Daisuke Nojiric3daa952016-09-22 09:48:20 -0700691 futility/vb2_helper.c \
692 futility/bdb_helper.c
Bill Richardson6db8c752013-04-05 13:30:43 -0700693
Alex Deymoe08ee282014-08-29 01:07:48 -0700694# List of commands built in futility and futility_s.
695FUTIL_STATIC_CMD_LIST = ${BUILD}/gen/futility_static_cmds.c
696FUTIL_CMD_LIST = ${BUILD}/gen/futility_cmds.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800697
Bill Richardson91852e72014-11-28 12:28:04 -0800698# Workaround for TODO(crbug.com/437107).
699FUTIL_STATIC_WORKAROUND_SRCS = firmware/stub/vboot_api_stub_static_sf.c
700
Alex Deymoe08ee282014-08-29 01:07:48 -0700701FUTIL_STATIC_OBJS = ${FUTIL_STATIC_SRCS:%.c=${BUILD}/%.o} \
Bill Richardson91852e72014-11-28 12:28:04 -0800702 ${FUTIL_STATIC_WORKAROUND_SRCS:%.c=${BUILD}/%.o} \
Alex Deymoe08ee282014-08-29 01:07:48 -0700703 ${FUTIL_STATIC_CMD_LIST:%.c=%.o}
704FUTIL_OBJS = ${FUTIL_SRCS:%.c=${BUILD}/%.o} ${FUTIL_CMD_LIST:%.c=%.o}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800705
Daisuke Nojirie43574c2016-09-16 16:51:42 -0700706${FUTIL_OBJS}: INCLUDES += -Ihost/lib21/include -Ifirmware/lib21/include \
707 -Ifirmware/bdb
Bill Richardson4e4c1962015-02-03 17:07:15 -0800708
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800709ALL_OBJS += ${FUTIL_OBJS}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800710
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800711
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800712# Library of handy test functions.
713TESTLIB = ${BUILD}/tests/test.a
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800714
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800715TESTLIB_SRCS = \
716 tests/test_common.c \
717 tests/timer_utils.c \
718 tests/crc32_test.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800719
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800720TESTLIB_OBJS = ${TESTLIB_SRCS:%.c=${BUILD}/%.o}
Bill Richardson80872db2014-10-03 10:26:11 -0700721TEST_OBJS += ${TESTLIB_OBJS}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800722
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800723
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800724# And some compiled tests.
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800725TEST_NAMES = \
Bill Richardson339f7e02013-04-05 09:49:24 -0700726 tests/cgptlib_test \
Bill Richardson339f7e02013-04-05 09:49:24 -0700727 tests/rollback_index3_tests \
728 tests/rsa_padding_test \
729 tests/rsa_utility_tests \
730 tests/rsa_verify_benchmark \
731 tests/sha_benchmark \
Bill Richardson339f7e02013-04-05 09:49:24 -0700732 tests/stateful_util_tests \
Bill Richardson339f7e02013-04-05 09:49:24 -0700733 tests/utility_string_tests \
734 tests/utility_tests \
Bill Richardson339f7e02013-04-05 09:49:24 -0700735 tests/vboot_api_devmode_tests \
Bill Richardson339f7e02013-04-05 09:49:24 -0700736 tests/vboot_api_kernel_tests \
737 tests/vboot_api_kernel2_tests \
738 tests/vboot_api_kernel3_tests \
739 tests/vboot_api_kernel4_tests \
Furquan Shaikhf2743602015-05-21 14:39:11 -0700740 tests/vboot_api_kernel5_tests \
Furquan Shaikh773b5ac2015-05-25 21:49:11 -0700741 tests/vboot_api_kernel6_tests \
Bill Richardson339f7e02013-04-05 09:49:24 -0700742 tests/vboot_audio_tests \
743 tests/vboot_common_tests \
744 tests/vboot_common2_tests \
745 tests/vboot_common3_tests \
746 tests/vboot_display_tests \
Bill Richardson339f7e02013-04-05 09:49:24 -0700747 tests/vboot_kernel_tests \
748 tests/vboot_nvstorage_test \
Bill Richardson89901f02015-03-05 16:51:39 -0800749 tests/verify_kernel
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800750
Andrey Pronin1becb0d2016-07-06 19:10:46 -0700751ifeq (${TPM2_MODE},)
752# TODO(apronin): tests for TPM2 case?
753TEST_NAMES += \
754 tests/tlcl_tests \
755 tests/rollback_index2_tests
756endif
757
Simon Glass527ba812013-07-25 08:48:47 -0600758ifdef REGION_READ
759TEST_NAMES += tests/vboot_region_tests
760endif
761
Bill Richardson89901f02015-03-05 16:51:39 -0800762TEST_FUTIL_NAMES = \
763 tests/futility/binary_editor \
764 tests/futility/test_file_types \
765 tests/futility/test_not_really
766
767TEST_NAMES += ${TEST_FUTIL_NAMES}
768
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800769TEST2X_NAMES = \
Randall Spanglera7ab8b52014-06-10 17:05:08 -0700770 tests/vb2_api_tests \
Randall Spangler786acda2014-05-22 13:27:07 -0700771 tests/vb2_common_tests \
Randall Spangler3333e572014-05-14 11:37:52 -0700772 tests/vb2_misc_tests \
773 tests/vb2_nvstorage_tests \
Randall Spanglere166d042014-05-13 09:24:52 -0700774 tests/vb2_rsa_utility_tests \
Randall Spangler3333e572014-05-14 11:37:52 -0700775 tests/vb2_secdata_tests \
Randall Spanglerbf9c2762015-05-12 13:44:30 -0700776 tests/vb2_secdatak_tests \
Daisuke Nojirif3f9e002016-05-05 17:21:29 -0700777 tests/vb2_sha_tests \
778 tests/hmac_test
Randall Spangler108d9912014-12-02 15:55:56 -0800779
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800780TEST20_NAMES = \
781 tests/vb20_api_tests \
Randall Spanglerd7f0f932015-05-19 13:41:09 -0700782 tests/vb20_api_kernel_tests \
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800783 tests/vb20_common_tests \
784 tests/vb20_common2_tests \
Bill Richardson5fb14632015-01-27 13:59:35 -0800785 tests/vb20_verify_fw.c \
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800786 tests/vb20_common3_tests \
Randall Spangler3d5cd882015-05-20 17:22:17 -0700787 tests/vb20_kernel_tests \
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800788 tests/vb20_misc_tests \
Bill Richardson5fb14632015-01-27 13:59:35 -0800789 tests/vb20_rsa_padding_tests \
790 tests/vb20_verify_fw
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800791
Randall Spangler108d9912014-12-02 15:55:56 -0800792TEST21_NAMES = \
793 tests/vb21_api_tests \
794 tests/vb21_common_tests \
795 tests/vb21_common2_tests \
796 tests/vb21_misc_tests \
797 tests/vb21_host_fw_preamble_tests \
798 tests/vb21_host_key_tests \
799 tests/vb21_host_keyblock_tests \
800 tests/vb21_host_misc_tests \
801 tests/vb21_host_sig_tests
Randall Spangler786acda2014-05-22 13:27:07 -0700802
Daisuke Nojiri825a2f82016-05-03 13:24:10 -0700803TESTBDB_NAMES = \
Daisuke Nojiri85dbb342016-05-04 14:55:57 -0700804 tests/bdb_test \
Daisuke Nojirid5820a72016-06-28 14:50:16 -0700805 tests/bdb_nvm_test \
Daisuke Nojiri85dbb342016-05-04 14:55:57 -0700806 tests/bdb_sprw_test
Daisuke Nojiri825a2f82016-05-03 13:24:10 -0700807
808TEST_NAMES += ${TEST2X_NAMES} ${TEST20_NAMES} ${TEST21_NAMES} ${TESTBDB_NAMES}
Randall Spangler786acda2014-05-22 13:27:07 -0700809
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800810# And a few more...
Andrey Pronin1becb0d2016-07-06 19:10:46 -0700811ifeq (${TPM2_MODE},)
Bill Richardson339f7e02013-04-05 09:49:24 -0700812TLCL_TEST_NAMES = \
813 tests/tpm_lite/tpmtest_earlyextend \
814 tests/tpm_lite/tpmtest_earlynvram \
815 tests/tpm_lite/tpmtest_earlynvram2 \
816 tests/tpm_lite/tpmtest_enable \
817 tests/tpm_lite/tpmtest_fastenable \
818 tests/tpm_lite/tpmtest_globallock \
819 tests/tpm_lite/tpmtest_redefine_unowned \
820 tests/tpm_lite/tpmtest_spaceperm \
821 tests/tpm_lite/tpmtest_testsetup \
822 tests/tpm_lite/tpmtest_timing \
823 tests/tpm_lite/tpmtest_writelimit
Andrey Pronin1becb0d2016-07-06 19:10:46 -0700824else
825# TODO(apronin): tests for TPM2 case?
826TLCL_TEST_NAMES =
827endif
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800828
829TEST_NAMES += ${TLCL_TEST_NAMES}
830
Bill Richardson339f7e02013-04-05 09:49:24 -0700831# Finally
832TEST_BINS = $(addprefix ${BUILD}/,${TEST_NAMES})
Bill Richardson80872db2014-10-03 10:26:11 -0700833TEST_OBJS += $(addsuffix .o,${TEST_BINS})
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800834
Bill Richardson89901f02015-03-05 16:51:39 -0800835TEST_FUTIL_BINS = $(addprefix ${BUILD}/,${TEST_FUTIL_NAMES})
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800836TEST2X_BINS = $(addprefix ${BUILD}/,${TEST2X_NAMES})
Randall Spangleraaaff862014-12-01 15:40:08 -0800837TEST20_BINS = $(addprefix ${BUILD}/,${TEST20_NAMES})
Randall Spangler108d9912014-12-02 15:55:56 -0800838TEST21_BINS = $(addprefix ${BUILD}/,${TEST21_NAMES})
Daisuke Nojiri825a2f82016-05-03 13:24:10 -0700839TESTBDB_BINS = $(addprefix ${BUILD}/,${TESTBDB_NAMES})
Randall Spangleraaaff862014-12-01 15:40:08 -0800840
Randall Spanglere061a252013-01-22 15:34:07 -0800841# Directory containing test keys
842TEST_KEYS = ${SRC_RUN}/tests/testkeys
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800843
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800844
845##############################################################################
846# Finally, some targets. High-level ones first.
847
848# Create output directories if necessary. Do this via explicit shell commands
849# so it happens before trying to generate/include dependencies.
850SUBDIRS := firmware host cgpt utility futility tests tests/tpm_lite
851_dir_create := $(foreach d, \
852 $(shell find ${SUBDIRS} -name '*.c' -exec dirname {} \; | sort -u), \
853 $(shell [ -d ${BUILD}/${d} ] || mkdir -p ${BUILD}/${d}))
854
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800855# Host targets
856.PHONY: host_stuff
Randall Spangler31f04ad2016-06-17 10:57:53 -0700857host_stuff: utillib hostlib cgpt utils futil tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800858
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800859.PHONY: clean
860clean:
861 ${Q}/bin/rm -rf ${BUILD}
862
863.PHONY: install
Nam T. Nguyen07d90432015-02-17 13:26:44 -0800864install: cgpt_install utils_install signing_install futil_install \
865 pc_files_install
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800866
Mike Frysinger9c57bd82015-03-12 03:52:40 -0400867.PHONY: install_dev
868install_dev: headers_install lib_install
869
Nam T. Nguyend1236e42015-01-08 11:43:27 -0800870.PHONY: install_mtd
871install_mtd: install cgpt_wrapper_install
872
Bill Richardson3e3790d2014-07-14 15:05:54 -0700873.PHONY: install_for_test
874install_for_test: override DESTDIR = ${TEST_INSTALL_DIR}
875install_for_test: install
876
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800877# Don't delete intermediate object files
878.SECONDARY:
879
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800880# ----------------------------------------------------------------------------
881# Firmware library
882
883# TPM-specific flags. These depend on the particular TPM we're targeting for.
884# They are needed here only for compiling parts of the firmware code into
885# user-level tests.
886
887# TPM_BLOCKING_CONTINUESELFTEST is defined if TPM_ContinueSelfTest blocks until
888# the self test has completed.
889
Randall Spangler45cc0f22013-01-25 09:34:26 -0800890${FWLIB_OBJS}: CFLAGS += -DTPM_BLOCKING_CONTINUESELFTEST
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800891
892# TPM_MANUAL_SELFTEST is defined if the self test must be started manually
893# (with a call to TPM_ContinueSelfTest) instead of starting automatically at
894# power on.
895#
896# We sincerely hope that TPM_BLOCKING_CONTINUESELFTEST and TPM_MANUAL_SELFTEST
897# are not both defined at the same time. (See comment in code.)
898
899# CFLAGS += -DTPM_MANUAL_SELFTEST
900
901ifeq (${FIRMWARE_ARCH},i386)
902# Unrolling loops in cryptolib makes it faster
Randall Spangler45cc0f22013-01-25 09:34:26 -0800903${FWLIB_OBJS}: CFLAGS += -DUNROLL_LOOPS
Bill Richardson06eb78c2015-01-27 15:01:51 -0800904${FWLIB2X_OBJS}: CFLAGS += -DUNROLL_LOOPS
Randall Spangleraaaff862014-12-01 15:40:08 -0800905${FWLIB20_OBJS}: CFLAGS += -DUNROLL_LOOPS
Randall Spanglera5b69b02014-12-02 13:41:29 -0800906${FWLIB21_OBJS}: CFLAGS += -DUNROLL_LOOPS
Daisuke Nojiri825a2f82016-05-03 13:24:10 -0700907${BDBLIB_OBJS}: CFLAGS += -DUNROLL_LOOPS
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800908
909# Workaround for coreboot on x86, which will power off asynchronously
910# without giving us a chance to react. This is not an example of the Right
911# Way to do things. See chrome-os-partner:7689, and the commit message
912# that made this change.
Randall Spangler45cc0f22013-01-25 09:34:26 -0800913${FWLIB_OBJS}: CFLAGS += -DSAVE_LOCALE_IMMEDIATELY
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800914
915# On x86 we don't actually read the GBB data into RAM until it is needed.
916# Therefore it makes sense to cache it rather than reading it each time.
917# Enable this feature.
Randall Spangler45cc0f22013-01-25 09:34:26 -0800918${FWLIB_OBJS}: CFLAGS += -DCOPY_BMP_DATA
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800919endif
920
Simon Glass527ba812013-07-25 08:48:47 -0600921ifdef REGION_READ
922${FWLIB_OBJS}: CFLAGS += -DREGION_READ
923endif
924
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800925ifeq (${FIRMWARE_ARCH},)
926# Disable rollback TPM when compiling locally, since otherwise
927# load_kernel_test attempts to talk to the TPM.
Randall Spangler45cc0f22013-01-25 09:34:26 -0800928${FWLIB_OBJS}: CFLAGS += -DDISABLE_ROLLBACK_TPM
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800929endif
930
Randall Spangler108d9912014-12-02 15:55:56 -0800931${FWLIB21_OBJS}: INCLUDES += -Ifirmware/lib21/include
Daisuke Nojiri825a2f82016-05-03 13:24:10 -0700932${BDBLIB_OBJS}: INCLUDES += -Ifirmware/bdb
Randall Spangler108d9912014-12-02 15:55:56 -0800933
Bill Richardsona130e0b2013-04-04 18:16:39 -0700934# Linktest ensures firmware lib doesn't rely on outside libraries
Bill Richardsona130e0b2013-04-04 18:16:39 -0700935${BUILD}/firmware/linktest/main: ${FWLIB}
936${BUILD}/firmware/linktest/main: LIBS = ${FWLIB}
Bill Richardson80872db2014-10-03 10:26:11 -0700937TEST_OBJS += ${BUILD}/firmware/linktest/main.o
Randall Spangler93943262013-02-26 11:03:57 -0800938
Bill Richardsond2d08b22014-07-08 16:31:40 -0700939.PHONY: fwlinktest
Randall Spangler2afa8732016-05-19 09:36:46 -0700940fwlinktest: ${BUILD}/firmware/linktest/main
Randall Spangler93943262013-02-26 11:03:57 -0800941
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800942.PHONY: fwlib
Bill Richardsona130e0b2013-04-04 18:16:39 -0700943fwlib: $(if ${FIRMWARE_ARCH},${FWLIB},fwlinktest)
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800944
Randall Spangler7c3ae422016-05-11 13:50:18 -0700945${FWLIB}: ${FWLIB_OBJS} ${FWLIB2X_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500946 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800947 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500948 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800949 ${Q}ar qc $@ $^
950
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800951.PHONY: fwlib2x
952fwlib2x: ${FWLIB2X}
953
Bill Richardson06eb78c2015-01-27 15:01:51 -0800954${FWLIB2X}: ${FWLIB2X_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500955 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800956 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500957 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Randall Spangler6f1b82a2014-12-03 12:29:37 -0800958 ${Q}ar qc $@ $^
959
Bill Richardson06eb78c2015-01-27 15:01:51 -0800960.PHONY: fwlib20
961fwlib20: ${FWLIB20}
Randall Spanglera5b69b02014-12-02 13:41:29 -0800962
Bill Richardson06eb78c2015-01-27 15:01:51 -0800963${FWLIB20}: ${FWLIB2X_OBJS} ${FWLIB20_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500964 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Randall Spangler786acda2014-05-22 13:27:07 -0700965 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500966 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Randall Spangler786acda2014-05-22 13:27:07 -0700967 ${Q}ar qc $@ $^
968
Randall Spanglera5b69b02014-12-02 13:41:29 -0800969.PHONY: fwlib21
970fwlib21: ${FWLIB21}
971
Bill Richardson06eb78c2015-01-27 15:01:51 -0800972${FWLIB21}: ${FWLIB2X_OBJS} ${FWLIB21_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500973 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Randall Spanglera5b69b02014-12-02 13:41:29 -0800974 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -0500975 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Randall Spanglera5b69b02014-12-02 13:41:29 -0800976 ${Q}ar qc $@ $^
977
Daisuke Nojiri825a2f82016-05-03 13:24:10 -0700978.PHONY: bdblib
979bdblib: ${BDBLIB}
980
Daisuke Nojiriedc3c8e2016-05-03 16:23:53 -0700981${BDBLIB}: ${FWLIB2X_OBJS} ${BDBLIB_OBJS}
Daisuke Nojiri825a2f82016-05-03 13:24:10 -0700982 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
983 ${Q}rm -f $@
984 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
985 ${Q}ar qc $@ $^
986
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800987# ----------------------------------------------------------------------------
Bill Richardson78299022014-06-20 14:33:00 -0700988# Host library(s)
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800989
Bill Richardson78299022014-06-20 14:33:00 -0700990# Link tests for local utilities
991${BUILD}/host/linktest/main: ${UTILLIB}
Bill Richardson78299022014-06-20 14:33:00 -0700992${BUILD}/host/linktest/main: LIBS = ${UTILLIB}
Bill Richardson80872db2014-10-03 10:26:11 -0700993TEST_OBJS += ${BUILD}/host/linktest/main.o
Bill Richardson78299022014-06-20 14:33:00 -0700994
995.PHONY: utillib
996utillib: ${UTILLIB} \
997 ${BUILD}/host/linktest/main
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800998
999# TODO: better way to make .a than duplicating this recipe each time?
Randall Spangler31f04ad2016-06-17 10:57:53 -07001000${UTILLIB}: ${UTILLIB_OBJS} ${FWLIB_OBJS} ${FWLIB2X_OBJS} ${FWLIB20_OBJS} \
1001 ${FWLIB21_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001002 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardson78299022014-06-20 14:33:00 -07001003 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001004 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardson78299022014-06-20 14:33:00 -07001005 ${Q}ar qc $@ $^
1006
Daisuke Nojiri825a2f82016-05-03 13:24:10 -07001007${UTILBDB}: ${UTILBDB_OBJS} ${BDBLIB_OBJS}
1008 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
1009 ${Q}rm -f $@
1010 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
1011 ${Q}ar qc $@ $^
Bill Richardson78299022014-06-20 14:33:00 -07001012
1013# Link tests for external repos
1014${BUILD}/host/linktest/extern: ${HOSTLIB}
Bill Richardson78299022014-06-20 14:33:00 -07001015${BUILD}/host/linktest/extern: LIBS = ${HOSTLIB}
1016${BUILD}/host/linktest/extern: LDLIBS += -static
Bill Richardson80872db2014-10-03 10:26:11 -07001017TEST_OBJS += ${BUILD}/host/linktest/extern.o
Bill Richardson78299022014-06-20 14:33:00 -07001018
1019.PHONY: hostlib
1020hostlib: ${HOSTLIB} \
1021 ${BUILD}/host/linktest/extern
1022
1023# TODO: better way to make .a than duplicating this recipe each time?
Bill Richardson78299022014-06-20 14:33:00 -07001024${HOSTLIB}: ${HOSTLIB_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001025 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001026 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001027 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001028 ${Q}ar qc $@ $^
1029
Bill Richardson81a0b3d2013-02-28 13:53:09 -08001030
1031# Ugh. This is a very cut-down version of HOSTLIB just for the installer.
1032.PHONY: tinyhostlib
1033tinyhostlib: ${TINYHOSTLIB}
1034 ${Q}cp -f ${TINYHOSTLIB} ${HOSTLIB}
1035
1036${TINYHOSTLIB}: ${TINYHOSTLIB_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001037 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardson81a0b3d2013-02-28 13:53:09 -08001038 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001039 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardson81a0b3d2013-02-28 13:53:09 -08001040 ${Q}ar qc $@ $^
1041
Mike Frysinger9c57bd82015-03-12 03:52:40 -04001042.PHONY: headers_install
1043headers_install:
1044 @${PRINTF} " INSTALL HEADERS\n"
1045 ${Q}mkdir -p ${UI_DIR}
1046 ${Q}${INSTALL} -t ${UI_DIR} -m644 \
1047 host/include/* \
1048 firmware/include/gpt.h \
1049 firmware/include/tlcl.h \
1050 firmware/include/tss_constants.h
1051
1052.PHONY: lib_install
1053lib_install: ${HOSTLIB}
1054 @${PRINTF} " INSTALL HOSTLIB\n"
1055 ${Q}mkdir -p ${UL_DIR}
1056 ${Q}${INSTALL} -t ${UL_DIR} -m644 $^
1057
1058.PHONY: devkeys_install
1059devkeys_install:
1060 @${PRINTF} " INSTALL DEVKEYS\n"
1061 ${Q}mkdir -p ${US_DIR}/devkeys
1062 ${Q}${INSTALL} -t ${US_DIR}/devkeys -m644 tests/devkeys/*
1063
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001064# ----------------------------------------------------------------------------
1065# CGPT library and utility
1066
Nam T. Nguyend1236e42015-01-08 11:43:27 -08001067.PHONY: cgpt_wrapper
1068cgpt_wrapper: ${CGPT_WRAPPER}
1069
1070${CGPT_WRAPPER}: ${CGPT_WRAPPER_OBJS} ${UTILLIB}
1071 @$(PRINTF) " LD $(subst ${BUILD}/,,$@)\n"
1072 ${Q}${LD} -o ${CGPT_WRAPPER} ${CFLAGS} $^
1073
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001074.PHONY: cgpt
Nam T. Nguyend1236e42015-01-08 11:43:27 -08001075cgpt: ${CGPT} ${CGPT_WRAPPER}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001076
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001077${CGPT}: LDLIBS += -luuid
1078
Bill Richardson78299022014-06-20 14:33:00 -07001079${CGPT}: ${CGPT_OBJS} ${UTILLIB}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001080 @${PRINTF} " LDcgpt $(subst ${BUILD}/,,$@)\n"
Bill Richardson6db8c752013-04-05 13:30:43 -07001081 ${Q}${LD} -o ${CGPT} ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001082
1083.PHONY: cgpt_install
1084cgpt_install: ${CGPT}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001085 @${PRINTF} " INSTALL CGPT\n"
Bill Richardsonc9bf3482013-02-13 14:38:29 -08001086 ${Q}mkdir -p ${UB_DIR}
1087 ${Q}${INSTALL} -t ${UB_DIR} $^
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001088
Nam T. Nguyend1236e42015-01-08 11:43:27 -08001089.PHONY: cgpt_wrapper_install
1090cgpt_wrapper_install: cgpt_install ${CGPT_WRAPPER}
1091 @$(PRINTF) " INSTALL cgpt_wrapper\n"
1092 ${Q}${INSTALL} -t ${UB_DIR} ${CGPT_WRAPPER}
1093 ${Q}mv ${UB_DIR}/$(notdir ${CGPT}) \
1094 ${UB_DIR}/$(notdir ${CGPT}).bin
1095 ${Q}mv ${UB_DIR}/$(notdir ${CGPT_WRAPPER}) \
1096 ${UB_DIR}/$(notdir ${CGPT})
1097
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001098# ----------------------------------------------------------------------------
1099# Utilities
1100
1101# These have their own headers too.
Bill Richardson0f6679e2014-07-10 15:49:52 -07001102${BUILD}/utility/%: INCLUDES += -Iutility/include
1103
1104${UTIL_BINS} ${UTIL_BINS_STATIC}: ${UTILLIB}
1105${UTIL_BINS} ${UTIL_BINS_STATIC}: LIBS = ${UTILLIB}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001106
1107# Utilities for auto-update toolkits must be statically linked.
1108${UTIL_BINS_STATIC}: LDFLAGS += -static
1109
Bill Richardsona130e0b2013-04-04 18:16:39 -07001110
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001111.PHONY: utils
Bill Richardsonc7c6e5d2013-02-28 10:10:29 -08001112utils: ${UTIL_BINS} ${UTIL_SCRIPTS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001113 ${Q}cp -f ${UTIL_SCRIPTS} ${BUILD}/utility
1114 ${Q}chmod a+rx $(patsubst %,${BUILD}/%,${UTIL_SCRIPTS})
1115
1116.PHONY: utils_install
Bill Richardsoncfe83a82014-12-04 11:29:57 -08001117utils_install: ${UTIL_BINS} ${UTIL_SCRIPTS} ${UTIL_DEFAULTS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001118 @${PRINTF} " INSTALL UTILS\n"
Bill Richardsonc9bf3482013-02-13 14:38:29 -08001119 ${Q}mkdir -p ${UB_DIR}
1120 ${Q}${INSTALL} -t ${UB_DIR} ${UTIL_BINS} ${UTIL_SCRIPTS}
Bill Richardsoncfe83a82014-12-04 11:29:57 -08001121 ${Q}mkdir -p ${DF_DIR}
1122 ${Q}${INSTALL} -t ${DF_DIR} -m 'u=rw,go=r,a-s' ${UTIL_DEFAULTS}
Bill Richardsonc9bf3482013-02-13 14:38:29 -08001123
1124# And some signing stuff for the target
1125.PHONY: signing_install
1126signing_install: ${SIGNING_SCRIPTS} ${SIGNING_SCRIPTS_DEV} ${SIGNING_COMMON}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001127 @${PRINTF} " INSTALL SIGNING\n"
Bill Richardson6f396152014-07-15 12:52:19 -07001128 ${Q}mkdir -p ${UB_DIR} ${VB_DIR}
Bill Richardsonc9bf3482013-02-13 14:38:29 -08001129 ${Q}${INSTALL} -t ${UB_DIR} ${SIGNING_SCRIPTS}
Bill Richardson6f396152014-07-15 12:52:19 -07001130 ${Q}${INSTALL} -t ${VB_DIR} ${SIGNING_SCRIPTS_DEV}
1131 ${Q}${INSTALL} -t ${VB_DIR} -m 'u=rw,go=r,a-s' ${SIGNING_COMMON}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001132
1133# ----------------------------------------------------------------------------
1134# new Firmware Utility
1135
1136.PHONY: futil
Bill Richardson6db8c752013-04-05 13:30:43 -07001137futil: ${FUTIL_STATIC_BIN} ${FUTIL_BIN}
1138
Bill Richardson06eb78c2015-01-27 15:01:51 -08001139${FUTIL_STATIC_BIN}: ${FUTIL_STATIC_OBJS} ${UTILLIB}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001140 @${PRINTF} " LD $(subst ${BUILD}/,,$@)\n"
Bill Richardson6db8c752013-04-05 13:30:43 -07001141 ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} -static $^ ${LDLIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001142
Randall Spangler98263a12016-06-02 16:05:49 -07001143${FUTIL_BIN}: LDLIBS += ${CRYPTO_LIBS} ${FWLIB20}
Daisuke Nojirie43574c2016-09-16 16:51:42 -07001144${FUTIL_BIN}: ${FUTIL_OBJS} ${UTILLIB} ${FWLIB20} ${UTILBDB}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001145 @${PRINTF} " LD $(subst ${BUILD}/,,$@)\n"
Bill Richardson6db8c752013-04-05 13:30:43 -07001146 ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001147
1148.PHONY: futil_install
Bill Richardsonefa87562014-09-11 10:41:51 -07001149futil_install: ${FUTIL_BIN} ${FUTIL_STATIC_BIN}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001150 @${PRINTF} " INSTALL futility\n"
Bill Richardson6f396152014-07-15 12:52:19 -07001151 ${Q}mkdir -p ${UB_DIR}
1152 ${Q}${INSTALL} -t ${UB_DIR} ${FUTIL_BIN} ${FUTIL_STATIC_BIN}
Bill Richardsona1d9fe62014-09-05 12:52:27 -07001153 ${Q}for prog in ${FUTIL_SYMLINKS}; do \
Bill Richardson6f396152014-07-15 12:52:19 -07001154 ln -sf futility "${UB_DIR}/$$prog"; done
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001155
1156# ----------------------------------------------------------------------------
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001157# Utility to generate TLCL structure definition header file.
1158
1159${BUILD}/utility/tlcl_generator: CFLAGS += -fpack-struct
1160
1161STRUCTURES_TMP=${BUILD}/tlcl_structures.tmp
1162STRUCTURES_SRC=firmware/lib/tpm_lite/include/tlcl_structures.h
1163
1164.PHONY: update_tlcl_structures
1165update_tlcl_structures: ${BUILD}/utility/tlcl_generator
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001166 @${PRINTF} " Rebuilding TLCL structures\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001167 ${Q}${BUILD}/utility/tlcl_generator > ${STRUCTURES_TMP}
1168 ${Q}cmp -s ${STRUCTURES_TMP} ${STRUCTURES_SRC} || \
1169 ( echo "%% Updating structures.h %%" && \
1170 cp ${STRUCTURES_TMP} ${STRUCTURES_SRC} )
1171
1172# ----------------------------------------------------------------------------
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001173# Tests
1174
1175.PHONY: tests
1176tests: ${TEST_BINS}
1177
Bill Richardson78299022014-06-20 14:33:00 -07001178${TEST_BINS}: ${UTILLIB} ${TESTLIB}
Bill Richardson339f7e02013-04-05 09:49:24 -07001179${TEST_BINS}: INCLUDES += -Itests
Randall Spanglerefa37b82014-11-12 16:20:50 -08001180${TEST_BINS}: LIBS = ${TESTLIB} ${UTILLIB}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001181
Bill Richardson89901f02015-03-05 16:51:39 -08001182# Futility tests need almost everything that futility needs.
Daisuke Nojirie43574c2016-09-16 16:51:42 -07001183${TEST_FUTIL_BINS}: ${FUTIL_OBJS} ${UTILLIB} ${UTILBDB}
Bill Richardson89901f02015-03-05 16:51:39 -08001184${TEST_FUTIL_BINS}: INCLUDES += -Ifutility
Daisuke Nojirie43574c2016-09-16 16:51:42 -07001185${TEST_FUTIL_BINS}: OBJS += ${FUTIL_OBJS} ${UTILLIB} ${UTILBDB}
Bill Richardson89901f02015-03-05 16:51:39 -08001186${TEST_FUTIL_BINS}: LDLIBS += ${CRYPTO_LIBS}
1187
Randall Spangler6f1b82a2014-12-03 12:29:37 -08001188${TEST2X_BINS}: ${FWLIB2X}
1189${TEST2X_BINS}: LIBS += ${FWLIB2X}
1190
Randall Spangler108d9912014-12-02 15:55:56 -08001191${TEST20_BINS}: ${FWLIB20}
1192${TEST20_BINS}: LIBS += ${FWLIB20}
1193
Daisuke Nojiriedc3c8e2016-05-03 16:23:53 -07001194${TESTBDB_BINS}: ${FWLIB2X} ${UTILBDB}
Daisuke Nojiri825a2f82016-05-03 13:24:10 -07001195${TESTBDB_BINS}: INCLUDES += -Ifirmware/bdb
Daisuke Nojiri351bc292016-09-19 13:37:12 -07001196${TESTBDB_BINS}: LIBS += ${UTILBDB} ${FWLIB2X}
Daisuke Nojiri825a2f82016-05-03 13:24:10 -07001197
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001198${TESTLIB}: ${TESTLIB_OBJS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001199 @${PRINTF} " RM $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001200 ${Q}rm -f $@
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001201 @${PRINTF} " AR $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001202 ${Q}ar qc $@ $^
1203
1204
1205# ----------------------------------------------------------------------------
1206# Generic build rules. LIBS and OBJS can be overridden to tweak the generic
1207# rules for specific targets.
1208
1209${BUILD}/%: ${BUILD}/%.o ${OBJS} ${LIBS}
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001210 @${PRINTF} " LD $(subst ${BUILD}/,,$@)\n"
Bill Richardson6db8c752013-04-05 13:30:43 -07001211 ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $< ${OBJS} ${LIBS} ${LDLIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001212
1213${BUILD}/%.o: %.c
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001214 @${PRINTF} " CC $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001215 ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1216
Alex Deymoe08ee282014-08-29 01:07:48 -07001217${BUILD}/%.o: ${BUILD}/%.c
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001218 @${PRINTF} " CC $(subst ${BUILD}/,,$@)\n"
Alex Deymoe08ee282014-08-29 01:07:48 -07001219 ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1220
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001221# Rules to recompile a single source file for library and test
1222# TODO: is there a tidier way to do this?
1223${BUILD}/%_for_lib.o: CFLAGS += -DFOR_LIBRARY
1224${BUILD}/%_for_lib.o: %.c
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001225 @${PRINTF} " CC-for-lib $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001226 ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1227
1228${BUILD}/%_for_test.o: CFLAGS += -DFOR_TEST
1229${BUILD}/%_for_test.o: %.c
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001230 @${PRINTF} " CC-for-test $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001231 ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1232
1233# TODO: C++ files don't belong in vboot reference at all. Convert to C.
1234${BUILD}/%.o: %.cc
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001235 @${PRINTF} " CXX $(subst ${BUILD}/,,$@)\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001236 ${Q}${CXX} ${CFLAGS} ${INCLUDES} -c -o $@ $<
1237
1238# ----------------------------------------------------------------------------
1239# Here are the special tweaks to the generic rules.
1240
Bill Richardsoncfe83a82014-12-04 11:29:57 -08001241# Always create the defaults file, since it depends on input variables
1242.PHONY: ${UTIL_DEFAULTS}
1243${UTIL_DEFAULTS}:
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001244 @${PRINTF} " CREATE $(subst ${BUILD}/,,$@)\n"
Bill Richardsoncfe83a82014-12-04 11:29:57 -08001245 ${Q}rm -f $@
1246 ${Q}mkdir -p $(dir $@)
1247 ${Q}echo '# Generated file. Do not edit.' > $@.tmp
1248 ${Q}echo "DEV_DEBUG_FORCE=${DEV_DEBUG_FORCE}" >> $@.tmp
1249 ${Q}mv -f $@.tmp $@
1250
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001251# Some utilities need external crypto functions
Bill Richardson78299022014-06-20 14:33:00 -07001252CRYPTO_LIBS := $(shell ${PKG_CONFIG} --libs libcrypto)
1253
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001254${BUILD}/utility/dumpRSAPublicKey: LDLIBS += ${CRYPTO_LIBS}
1255${BUILD}/utility/pad_digest_utility: LDLIBS += ${CRYPTO_LIBS}
1256${BUILD}/utility/signature_digest_utility: LDLIBS += ${CRYPTO_LIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001257
Daisuke Nojiri8130e502016-09-14 12:55:20 -07001258${BUILD}/utility/bdb_extend: ${FWLIB2X} ${UTILBDB}
1259${BUILD}/utility/bdb_extend.o: INCLUDES += -Ifirmware/bdb
1260${BUILD}/utility/bdb_extend: LDLIBS += ${CRYPTO_LIBS}
1261${BUILD}/utility/bdb_extend: LIBS += ${UTILBDB} ${FWLIB2X}
1262
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001263${BUILD}/host/linktest/main: LDLIBS += ${CRYPTO_LIBS}
1264${BUILD}/tests/vboot_common2_tests: LDLIBS += ${CRYPTO_LIBS}
1265${BUILD}/tests/vboot_common3_tests: LDLIBS += ${CRYPTO_LIBS}
Randall Spangler6f1b82a2014-12-03 12:29:37 -08001266${BUILD}/tests/vb20_common2_tests: LDLIBS += ${CRYPTO_LIBS}
1267${BUILD}/tests/vb20_common3_tests: LDLIBS += ${CRYPTO_LIBS}
Bill Richardsona77541f2014-12-04 19:06:35 -08001268${BUILD}/tests/verify_kernel: LDLIBS += ${CRYPTO_LIBS}
Daisuke Nojiri825a2f82016-05-03 13:24:10 -07001269${BUILD}/tests/bdb_test: LDLIBS += ${CRYPTO_LIBS}
Daisuke Nojirid5820a72016-06-28 14:50:16 -07001270${BUILD}/tests/bdb_nvm_test: LDLIBS += ${CRYPTO_LIBS}
Daisuke Nojiri85dbb342016-05-04 14:55:57 -07001271${BUILD}/tests/bdb_sprw_test: LDLIBS += ${CRYPTO_LIBS}
Daisuke Nojirif3f9e002016-05-05 17:21:29 -07001272${BUILD}/tests/hmac_test: LDLIBS += ${CRYPTO_LIBS}
Randall Spangler108d9912014-12-02 15:55:56 -08001273
1274${TEST21_BINS}: LDLIBS += ${CRYPTO_LIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001275
1276${BUILD}/utility/bmpblk_utility: LD = ${CXX}
Mike Frysinger0b789c52015-01-15 15:37:59 -05001277${BUILD}/utility/bmpblk_utility: LDLIBS = ${LZMA_LIBS} ${YAML_LIBS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001278
1279BMPBLK_UTILITY_DEPS = \
1280 ${BUILD}/utility/bmpblk_util.o \
1281 ${BUILD}/utility/image_types.o \
1282 ${BUILD}/utility/eficompress_for_lib.o \
1283 ${BUILD}/utility/efidecompress_for_lib.o
Bill Richardson1912bba2013-04-04 21:08:50 -07001284
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001285${BUILD}/utility/bmpblk_utility: OBJS = ${BMPBLK_UTILITY_DEPS}
1286${BUILD}/utility/bmpblk_utility: ${BMPBLK_UTILITY_DEPS}
Bill Richardson1912bba2013-04-04 21:08:50 -07001287ALL_OBJS += ${BMPBLK_UTILITY_DEPS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001288
1289${BUILD}/utility/bmpblk_font: OBJS += ${BUILD}/utility/image_types.o
1290${BUILD}/utility/bmpblk_font: ${BUILD}/utility/image_types.o
Bill Richardson1912bba2013-04-04 21:08:50 -07001291ALL_OBJS += ${BUILD}/utility/image_types.o
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001292
1293# Allow multiple definitions, so tests can mock functions from other libraries
1294${BUILD}/tests/%: CFLAGS += -Xlinker --allow-multiple-definition
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001295${BUILD}/tests/%: LDLIBS += -lrt -luuid
1296${BUILD}/tests/%: LIBS += ${TESTLIB}
1297
Andrey Pronin1becb0d2016-07-06 19:10:46 -07001298ifeq (${TPM2_MODE},)
1299# TODO(apronin): tests for TPM2 case?
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001300${BUILD}/tests/rollback_index2_tests: OBJS += \
1301 ${BUILD}/firmware/lib/rollback_index_for_test.o
1302${BUILD}/tests/rollback_index2_tests: \
1303 ${BUILD}/firmware/lib/rollback_index_for_test.o
Bill Richardson80872db2014-10-03 10:26:11 -07001304TEST_OBJS += ${BUILD}/firmware/lib/rollback_index_for_test.o
Andrey Pronin1becb0d2016-07-06 19:10:46 -07001305endif
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001306
Randall Spanglerc3d488d2013-01-28 16:23:48 -08001307${BUILD}/tests/tlcl_tests: OBJS += \
Andrey Pronin1becb0d2016-07-06 19:10:46 -07001308 ${TLCL_OBJS_FOR_TEST}
Randall Spanglerc3d488d2013-01-28 16:23:48 -08001309${BUILD}/tests/tlcl_tests: \
Andrey Pronin1becb0d2016-07-06 19:10:46 -07001310 ${TLCL_OBJS_FOR_TEST}
1311TEST_OBJS += ${TLCL_OBJS_FOR_TEST}
Randall Spanglerc3d488d2013-01-28 16:23:48 -08001312
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001313${BUILD}/tests/vboot_audio_tests: OBJS += \
1314 ${BUILD}/firmware/lib/vboot_audio_for_test.o
1315${BUILD}/tests/vboot_audio_tests: \
1316 ${BUILD}/firmware/lib/vboot_audio_for_test.o
Bill Richardson80872db2014-10-03 10:26:11 -07001317TEST_OBJS += ${BUILD}/firmware/lib/vboot_audio_for_test.o
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001318
Andrey Pronin1becb0d2016-07-06 19:10:46 -07001319ifeq (${TPM2_MODE},)
1320# TODO(apronin): tests for TPM2 case?
Bill Richardson339f7e02013-04-05 09:49:24 -07001321TLCL_TEST_BINS = $(addprefix ${BUILD}/,${TLCL_TEST_NAMES})
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001322${TLCL_TEST_BINS}: OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o
1323${TLCL_TEST_BINS}: ${BUILD}/tests/tpm_lite/tlcl_tests.o
Bill Richardson80872db2014-10-03 10:26:11 -07001324TEST_OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o
Andrey Pronin1becb0d2016-07-06 19:10:46 -07001325endif
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001326
Alex Deymoe08ee282014-08-29 01:07:48 -07001327# ----------------------------------------------------------------------------
1328# Here are the special rules that don't fit in the generic rules.
1329
1330# Generates the list of commands defined in futility by running grep in the
1331# source files looking for the DECLARE_FUTIL_COMMAND() macro usage.
1332${FUTIL_STATIC_CMD_LIST}: ${FUTIL_STATIC_SRCS}
1333${FUTIL_CMD_LIST}: ${FUTIL_SRCS}
1334${FUTIL_CMD_LIST} ${FUTIL_STATIC_CMD_LIST}:
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001335 @${PRINTF} " GEN $(subst ${BUILD}/,,$@)\n"
Alex Deymoe08ee282014-08-29 01:07:48 -07001336 ${Q}rm -f $@ $@_t $@_commands
1337 ${Q}mkdir -p ${BUILD}/gen
Bill Richardson779796f2014-09-23 11:47:40 -07001338 ${Q}grep -hoRE '^DECLARE_FUTIL_COMMAND\([^,]+' $^ \
Alex Deymoe08ee282014-08-29 01:07:48 -07001339 | sed 's/DECLARE_FUTIL_COMMAND(\(.*\)/_CMD(\1)/' \
1340 | sort >>$@_commands
Bill Richardsone1486c32014-10-30 17:41:51 -07001341 ${Q}./scripts/getversion.sh >> $@_t
Alex Deymoe08ee282014-08-29 01:07:48 -07001342 ${Q}echo '#define _CMD(NAME) extern const struct' \
1343 'futil_cmd_t __cmd_##NAME;' >> $@_t
1344 ${Q}cat $@_commands >> $@_t
1345 ${Q}echo '#undef _CMD' >> $@_t
1346 ${Q}echo '#define _CMD(NAME) &__cmd_##NAME,' >> $@_t
1347 ${Q}echo 'const struct futil_cmd_t *const futil_cmds[] = {' >> $@_t
1348 ${Q}cat $@_commands >> $@_t
1349 ${Q}echo '0}; /* null-terminated */' >> $@_t
1350 ${Q}echo '#undef _CMD' >> $@_t
1351 ${Q}mv $@_t $@
1352 ${Q}rm -f $@_commands
1353
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001354##############################################################################
1355# Targets that exist just to run tests
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001356
1357# Frequently-run tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001358.PHONY: test_targets
Daisuke Nojiri825a2f82016-05-03 13:24:10 -07001359test_targets:: runcgpttests runmisctests run2tests runbdbtests
Randall Spangler844bce52013-01-15 16:16:43 -08001360
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001361ifeq (${MINIMAL},)
Randall Spangler844bce52013-01-15 16:16:43 -08001362# Bitmap utility isn't compiled for minimal variant
Bill Richardsonfeb25182013-03-07 12:54:29 -08001363test_targets:: runbmptests runfutiltests
Randall Spangler844bce52013-01-15 16:16:43 -08001364# Scripts don't work under qemu testing
1365# TODO: convert scripts to makefile so they can be called directly
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001366test_targets:: runtestscripts
Randall Spangler844bce52013-01-15 16:16:43 -08001367endif
1368
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001369.PHONY: test_setup
Bill Richardson3e3790d2014-07-14 15:05:54 -07001370test_setup:: cgpt utils futil tests install_for_test
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001371
Randall Spangler844bce52013-01-15 16:16:43 -08001372# Qemu setup for cross-compiled tests. Need to copy qemu binary into the
1373# sysroot.
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001374ifneq (${QEMU_ARCH},)
1375test_setup:: qemu_install
Randall Spangler844bce52013-01-15 16:16:43 -08001376
1377.PHONY: qemu_install
1378qemu_install:
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001379ifeq (${SYSROOT},)
1380 $(error SYSROOT must be set to the top of the target-specific root \
1381when cross-compiling for qemu-based tests to run properly.)
1382endif
Mike Frysingerc8c87b32015-01-15 17:04:40 -05001383 @${PRINTF} " Copying qemu binary.\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001384 ${Q}cp -fu /usr/bin/${QEMU_BIN} ${BUILD}/${QEMU_BIN}
1385 ${Q}chmod a+rx ${BUILD}/${QEMU_BIN}
Randall Spangler844bce52013-01-15 16:16:43 -08001386endif
1387
Bill Richardsonacb2ee92013-01-11 22:53:00 -08001388.PHONY: runtests
Bill Richardsona130e0b2013-04-04 18:16:39 -07001389runtests: test_setup test_targets
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001390
1391# Generate test keys
Bill Richardsonacb2ee92013-01-11 22:53:00 -08001392.PHONY: genkeys
Bill Richardson0840b842015-02-05 12:39:02 -08001393genkeys: utils test_setup
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001394 tests/gen_test_keys.sh
1395
1396# Generate test cases for fuzzing
Bill Richardsonacb2ee92013-01-11 22:53:00 -08001397.PHONY: genfuzztestcases
Bill Richardson0840b842015-02-05 12:39:02 -08001398genfuzztestcases: utils test_setup
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001399 tests/gen_fuzz_test_cases.sh
1400
Bill Richardsonacb2ee92013-01-11 22:53:00 -08001401.PHONY: runbmptests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001402runbmptests: test_setup
1403 cd tests/bitmaps && BMPBLK=${BUILD_RUN}/utility/bmpblk_utility \
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001404 ./TestBmpBlock.py -v
1405
Bill Richardsonacb2ee92013-01-11 22:53:00 -08001406.PHONY: runcgpttests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001407runcgpttests: test_setup
1408 ${RUNTEST} ${BUILD_RUN}/tests/cgptlib_test
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001409
Randall Spangler844bce52013-01-15 16:16:43 -08001410.PHONY: runtestscripts
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001411runtestscripts: test_setup genfuzztestcases
Randall Spanglerb8ff3972014-08-27 13:34:35 -07001412 tests/load_kernel_tests.sh
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001413 tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt
Nam T. Nguyenab899592014-11-13 19:30:46 -08001414 tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt -D 358400
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001415 tests/run_preamble_tests.sh
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001416 tests/run_rsa_tests.sh
Randall Spangler844bce52013-01-15 16:16:43 -08001417 tests/run_vbutil_kernel_arg_tests.sh
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001418 tests/run_vbutil_tests.sh
Randall Spanglere166d042014-05-13 09:24:52 -07001419 tests/vb2_rsa_tests.sh
Randall Spangler539cbc22014-06-18 14:15:04 -07001420 tests/vb2_firmware_tests.sh
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001421
Randall Spangler844bce52013-01-15 16:16:43 -08001422.PHONY: runmisctests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001423runmisctests: test_setup
Bill Richardson0ea5e1e2016-09-22 12:44:18 -07001424ifeq (${TPM2_MODE},)
1425 ${RUNTEST} ${BUILD_RUN}/tests/tlcl_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001426 ${RUNTEST} ${BUILD_RUN}/tests/rollback_index2_tests
Bill Richardson0ea5e1e2016-09-22 12:44:18 -07001427endif
Randall Spanglera3eac792013-01-23 13:04:05 -08001428 ${RUNTEST} ${BUILD_RUN}/tests/rollback_index3_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001429 ${RUNTEST} ${BUILD_RUN}/tests/rsa_utility_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001430 ${RUNTEST} ${BUILD_RUN}/tests/stateful_util_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001431 ${RUNTEST} ${BUILD_RUN}/tests/utility_string_tests
1432 ${RUNTEST} ${BUILD_RUN}/tests/utility_tests
1433 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_devmode_tests
Randall Spangler0714d9d2013-02-05 10:23:38 -08001434 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel_tests
Randall Spangler7f436692013-02-05 12:42:36 -08001435 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel2_tests
1436 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel3_tests
1437 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel4_tests
Furquan Shaikhf2743602015-05-21 14:39:11 -07001438 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel5_tests
Furquan Shaikh773b5ac2015-05-25 21:49:11 -07001439 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel6_tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001440 ${RUNTEST} ${BUILD_RUN}/tests/vboot_audio_tests
Randall Spanglere061a252013-01-22 15:34:07 -08001441 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common_tests
1442 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS}
1443 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS}
Randall Spangler786a5dc2013-01-24 14:19:56 -08001444 ${RUNTEST} ${BUILD_RUN}/tests/vboot_display_tests
Randall Spangler49cb0d32013-01-29 14:28:16 -08001445 ${RUNTEST} ${BUILD_RUN}/tests/vboot_kernel_tests
Randall Spangler6dbf9d92013-01-23 12:25:10 -08001446 ${RUNTEST} ${BUILD_RUN}/tests/vboot_nvstorage_test
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001447
Randall Spangler786acda2014-05-22 13:27:07 -07001448.PHONY: run2tests
1449run2tests: test_setup
Randall Spanglera7ab8b52014-06-10 17:05:08 -07001450 ${RUNTEST} ${BUILD_RUN}/tests/vb2_api_tests
Randall Spangler786acda2014-05-22 13:27:07 -07001451 ${RUNTEST} ${BUILD_RUN}/tests/vb2_common_tests
Randall Spangler3333e572014-05-14 11:37:52 -07001452 ${RUNTEST} ${BUILD_RUN}/tests/vb2_misc_tests
1453 ${RUNTEST} ${BUILD_RUN}/tests/vb2_nvstorage_tests
Randall Spanglere166d042014-05-13 09:24:52 -07001454 ${RUNTEST} ${BUILD_RUN}/tests/vb2_rsa_utility_tests
Randall Spangler3333e572014-05-14 11:37:52 -07001455 ${RUNTEST} ${BUILD_RUN}/tests/vb2_secdata_tests
Randall Spanglerbf9c2762015-05-12 13:44:30 -07001456 ${RUNTEST} ${BUILD_RUN}/tests/vb2_secdatak_tests
Randall Spanglere166d042014-05-13 09:24:52 -07001457 ${RUNTEST} ${BUILD_RUN}/tests/vb2_sha_tests
Randall Spangler6f1b82a2014-12-03 12:29:37 -08001458 ${RUNTEST} ${BUILD_RUN}/tests/vb20_api_tests
Randall Spanglerd7f0f932015-05-19 13:41:09 -07001459 ${RUNTEST} ${BUILD_RUN}/tests/vb20_api_kernel_tests
Randall Spangler6f1b82a2014-12-03 12:29:37 -08001460 ${RUNTEST} ${BUILD_RUN}/tests/vb20_common_tests
1461 ${RUNTEST} ${BUILD_RUN}/tests/vb20_common2_tests ${TEST_KEYS}
1462 ${RUNTEST} ${BUILD_RUN}/tests/vb20_common3_tests ${TEST_KEYS}
Randall Spangler3d5cd882015-05-20 17:22:17 -07001463 ${RUNTEST} ${BUILD_RUN}/tests/vb20_kernel_tests
Randall Spangler6f1b82a2014-12-03 12:29:37 -08001464 ${RUNTEST} ${BUILD_RUN}/tests/vb20_misc_tests
Randall Spangler108d9912014-12-02 15:55:56 -08001465 ${RUNTEST} ${BUILD_RUN}/tests/vb21_api_tests
1466 ${RUNTEST} ${BUILD_RUN}/tests/vb21_common_tests
1467 ${RUNTEST} ${BUILD_RUN}/tests/vb21_common2_tests ${TEST_KEYS}
1468 ${RUNTEST} ${BUILD_RUN}/tests/vb21_misc_tests
1469 ${RUNTEST} ${BUILD_RUN}/tests/vb21_host_fw_preamble_tests ${TEST_KEYS}
Mike Frysingercdf7dc92015-03-12 03:33:36 -04001470 ${RUNTEST} ${BUILD_RUN}/tests/vb21_host_key_tests ${TEST_KEYS} ${BUILD}
Randall Spangler108d9912014-12-02 15:55:56 -08001471 ${RUNTEST} ${BUILD_RUN}/tests/vb21_host_keyblock_tests ${TEST_KEYS}
Mike Frysingercdf7dc92015-03-12 03:33:36 -04001472 ${RUNTEST} ${BUILD_RUN}/tests/vb21_host_misc_tests ${BUILD}
Randall Spangler108d9912014-12-02 15:55:56 -08001473 ${RUNTEST} ${BUILD_RUN}/tests/vb21_host_sig_tests ${TEST_KEYS}
Daisuke Nojirif3f9e002016-05-05 17:21:29 -07001474 ${RUNTEST} ${BUILD_RUN}/tests/hmac_test
Randall Spangler786acda2014-05-22 13:27:07 -07001475
Daisuke Nojiri825a2f82016-05-03 13:24:10 -07001476.PHONY: runbdbtests
1477runbdbtests: test_setup
1478 ${RUNTEST} ${BUILD_RUN}/tests/bdb_test ${TEST_KEYS}
Daisuke Nojiri85dbb342016-05-04 14:55:57 -07001479 ${RUNTEST} ${BUILD_RUN}/tests/bdb_sprw_test ${TEST_KEYS}
Daisuke Nojiri825a2f82016-05-03 13:24:10 -07001480
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001481.PHONY: runfutiltests
Bill Richardson3e3790d2014-07-14 15:05:54 -07001482runfutiltests: test_setup
Bill Richardsonefa87562014-09-11 10:41:51 -07001483 tests/futility/run_test_scripts.sh ${TEST_INSTALL_DIR}/bin
Bill Richardson89901f02015-03-05 16:51:39 -08001484 ${RUNTEST} ${BUILD_RUN}/tests/futility/test_file_types
Bill Richardson339f7e02013-04-05 09:49:24 -07001485 ${RUNTEST} ${BUILD_RUN}/tests/futility/test_not_really
Randall Spangler844bce52013-01-15 16:16:43 -08001486
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001487# Run long tests, including all permutations of encryption keys (instead of
Randall Spangler786a5dc2013-01-24 14:19:56 -08001488# just the ones we use) and tests of currently-unused code.
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001489# Not run by automated build.
Bill Richardsonacb2ee92013-01-11 22:53:00 -08001490.PHONY: runlongtests
Bill Richardsoneecc18f2013-01-17 15:28:17 -08001491runlongtests: test_setup genkeys genfuzztestcases
Randall Spanglere061a252013-01-22 15:34:07 -08001492 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS} --all
1493 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS} --all
Randall Spangler6f1b82a2014-12-03 12:29:37 -08001494 ${RUNTEST} ${BUILD_RUN}/tests/vb20_common2_tests ${TEST_KEYS} --all
1495 ${RUNTEST} ${BUILD_RUN}/tests/vb20_common3_tests ${TEST_KEYS} --all
Randall Spangler108d9912014-12-02 15:55:56 -08001496 ${RUNTEST} ${BUILD_RUN}/tests/vb21_common2_tests ${TEST_KEYS} --all
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001497 tests/run_preamble_tests.sh --all
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001498 tests/run_vbutil_tests.sh --all
1499
Bill Richardson78d59bf2014-08-27 16:17:04 -07001500# TODO: There were a number of ancient tests that hadn't been run in years.
1501# They were removed with https://chromium-review.googlesource.com/#/c/214610/
1502# Some day it might be nice to see what they were supposed to do.
Randall Spangler5d9bbf22013-01-08 10:44:23 -08001503
Bill Richardson78299022014-06-20 14:33:00 -07001504.PHONY: runalltests
1505runalltests: runtests runfutiltests runlongtests
1506
Randall Spangler59d75082013-01-23 09:29:54 -08001507# Code coverage
1508.PHONY: coverage_init
1509coverage_init: test_setup
1510 rm -f ${COV_INFO}*
1511 lcov -c -i -d . -b . -o ${COV_INFO}.initial
1512
1513.PHONY: coverage_html
1514coverage_html:
1515 lcov -c -d . -b . -o ${COV_INFO}.tests
1516 lcov -a ${COV_INFO}.initial -a ${COV_INFO}.tests -o ${COV_INFO}.total
1517 lcov -r ${COV_INFO}.total '/usr/*' '*/linktest/*' -o ${COV_INFO}.local
1518 genhtml ${COV_INFO}.local -o ${BUILD}/coverage
Bill Richardsond2d08b22014-07-08 16:31:40 -07001519# Generate addtional coverage stats just for firmware subdir, because the stats
1520# for the whole project don't include subdirectory summaries. This will print
1521# the summary for just the firmware sources.
Randall Spangler49cb0d32013-01-29 14:28:16 -08001522 lcov -r ${COV_INFO}.local '*/stub/*' -o ${COV_INFO}.nostub
1523 lcov -e ${COV_INFO}.nostub '${SRCDIR}/firmware/*' \
Randall Spangler59d75082013-01-23 09:29:54 -08001524 -o ${COV_INFO}.firmware
1525
1526.PHONY: coverage
1527ifeq (${COV},)
1528coverage:
Randall Spanglerb87d1ec2015-05-19 12:45:20 -07001529 $(error Build coverage like this: make clean && COV=1 make coverage)
Randall Spangler59d75082013-01-23 09:29:54 -08001530else
1531coverage: coverage_init runtests coverage_html
1532endif
Bill Richardson1912bba2013-04-04 21:08:50 -07001533
1534# Include generated dependencies
1535ALL_DEPS += ${ALL_OBJS:%.o=%.o.d}
Bill Richardson80872db2014-10-03 10:26:11 -07001536TEST_DEPS += ${TEST_OBJS:%.o=%.o.d}
Bill Richardson04d98e32015-01-31 01:14:39 -08001537-include ${ALL_DEPS}
1538-include ${TEST_DEPS}
Bill Richardson80872db2014-10-03 10:26:11 -07001539
1540# We want to use only relative paths in cscope.files, especially since the
1541# paths inside and outside the chroot are different.
1542SRCDIRPAT=$(subst /,\/,${SRCDIR}/)
1543
Bill Richardson8db64da2015-01-29 21:46:58 -08001544# Note: vboot 2.0 is deprecated, so don't index those files
Bill Richardson01466d32015-03-11 11:21:47 -07001545${BUILD}/cscope.files: all test_setup
Bill Richardson80872db2014-10-03 10:26:11 -07001546 ${Q}rm -f $@
1547 ${Q}cat ${ALL_DEPS} | tr -d ':\\' | tr ' ' '\012' | \
Bill Richardson8db64da2015-01-29 21:46:58 -08001548 grep -v /lib20/ | \
Bill Richardson80872db2014-10-03 10:26:11 -07001549 sed -e "s/${SRCDIRPAT}//" | \
1550 egrep '\.[chS]$$' | sort | uniq > $@
1551
1552cmd_etags = etags -o ${BUILD}/TAGS $(shell cat ${BUILD}/cscope.files)
1553cmd_ctags = ctags -o ${BUILD}/tags $(shell cat ${BUILD}/cscope.files)
1554run_if_prog = $(if $(shell which $(1) 2>/dev/null),$(2),)
1555
1556.PHONY: tags TAGS xrefs
1557tags TAGS xrefs: ${BUILD}/cscope.files
1558 ${Q}\rm -f ${BUILD}/tags ${BUILD}/TAGS
1559 ${Q}$(call run_if_prog,etags,${cmd_etags})
1560 ${Q}$(call run_if_prog,ctags,${cmd_ctags})
Nam T. Nguyen07d90432015-02-17 13:26:44 -08001561
Bill Richardson82212012015-02-27 13:57:13 -08001562PC_FILES = ${PC_IN_FILES:%.pc.in=${BUILD}/%.pc}
Nam T. Nguyen07d90432015-02-17 13:26:44 -08001563${PC_FILES}: ${PC_IN_FILES}
1564 ${Q}sed \
1565 -e 's:@LDLIBS@:${LDLIBS}:' \
1566 -e 's:@LIBDIR@:${LIBDIR}:' \
1567 $< > $@
1568
1569.PHONY: pc_files_install
1570pc_files_install: ${PC_FILES}
1571 ${Q}mkdir -p ${ULP_DIR}
Bill Richardson82212012015-02-27 13:57:13 -08001572 ${Q}${INSTALL} -D -m 0644 $< ${ULP_DIR}/$(notdir $<)