Bill Richardson | 6f39615 | 2014-07-15 12:52:19 -0700 | [diff] [blame] | 1 | # Copyright 2013 The Chromium OS Authors. All rights reserved. |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
Simon Glass | 6d696e5 | 2011-11-14 13:46:33 -0800 | [diff] [blame] | 5 | # This Makefile normally builds in a 'build' subdir, but use |
| 6 | # |
| 7 | # make BUILD=<dir> |
| 8 | # |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 9 | # 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 Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 38 | # We should only run pwd once, not every time we refer to ${BUILD}. |
Randall Spangler | e061a25 | 2013-01-22 15:34:07 -0800 | [diff] [blame] | 39 | SRCDIR := $(shell pwd) |
Bill Richardson | feb2518 | 2013-03-07 12:54:29 -0800 | [diff] [blame] | 40 | BUILD = $(SRCDIR)/build |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 41 | export BUILD |
Simon Glass | 6d696e5 | 2011-11-14 13:46:33 -0800 | [diff] [blame] | 42 | |
Bill Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 43 | # Stuff for 'make install' |
Bill Richardson | feb2518 | 2013-03-07 12:54:29 -0800 | [diff] [blame] | 44 | INSTALL = install |
| 45 | DESTDIR = /usr/local/bin |
Bill Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 46 | |
Bill Richardson | feb2518 | 2013-03-07 12:54:29 -0800 | [diff] [blame] | 47 | # Where exactly do the pieces go? |
Bill Richardson | 6f39615 | 2014-07-15 12:52:19 -0700 | [diff] [blame] | 48 | # UB_DIR = utility binary directory |
| 49 | # VB_DIR = vboot binary directory for dev-mode-only scripts |
Bill Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 50 | ifeq (${MINIMAL},) |
Bill Richardson | 6f39615 | 2014-07-15 12:52:19 -0700 | [diff] [blame] | 51 | # Host install just puts everything where it's told |
| 52 | UB_DIR=${DESTDIR} |
| 53 | VB_DIR=${DESTDIR} |
Bill Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 54 | else |
Bill Richardson | 6f39615 | 2014-07-15 12:52:19 -0700 | [diff] [blame] | 55 | # Target install puts things into subdirectories under DESTDIR |
| 56 | UB_DIR=${DESTDIR}/usr/bin |
Bill Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 57 | VB_DIR=${DESTDIR}/usr/share/vboot/bin |
| 58 | endif |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 59 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 60 | # Where to install the (exportable) executables for testing? |
| 61 | TEST_INSTALL_DIR = ${BUILD}/install_for_test |
| 62 | |
| 63 | # Verbose? Use V=1 |
| 64 | ifeq (${V},) |
| 65 | Q := @ |
| 66 | endif |
| 67 | |
Simon Glass | 661ae9e | 2013-03-26 11:39:21 -0700 | [diff] [blame] | 68 | # Quiet? Use QUIET=1 |
| 69 | ifeq ($(QUIET),) |
| 70 | PRINTF := printf |
| 71 | else |
| 72 | PRINTF := : |
| 73 | endif |
| 74 | |
Randall Spangler | 61a2eb3 | 2013-01-23 10:20:16 -0800 | [diff] [blame] | 75 | # Architecture detection |
| 76 | _machname := $(shell uname -m) |
| 77 | HOST_ARCH ?= ${_machname} |
| 78 | |
| 79 | # ARCH and/or FIRMWARE_ARCH are defined by the Chromium OS ebuild. |
| 80 | # Pick a sane target architecture if none is defined. |
| 81 | ifeq (${ARCH},) |
| 82 | ARCH := ${HOST_ARCH} |
| 83 | else ifeq (${ARCH},i386) |
| 84 | override ARCH := x86 |
| 85 | else ifeq (${ARCH},amd64) |
| 86 | override ARCH := x86_64 |
| 87 | endif |
| 88 | |
| 89 | # FIRMWARE_ARCH is only defined by the Chromium OS ebuild if compiling |
| 90 | # for a firmware target (such as u-boot or depthcharge). It must map |
| 91 | # to the same consistent set of architectures as the host. |
| 92 | ifeq (${FIRMWARE_ARCH},i386) |
| 93 | override FIRMWARE_ARCH := x86 |
| 94 | else ifeq (${FIRMWARE_ARCH},amd64) |
| 95 | override FIRMWARE_ARCH := x86_64 |
Stefan Reinauer | d96b25d | 2013-09-19 14:24:29 -0700 | [diff] [blame] | 96 | else ifeq (${FIRMWARE_ARCH},armv7) |
| 97 | override FIRMWARE_ARCH := arm |
Randall Spangler | 61a2eb3 | 2013-01-23 10:20:16 -0800 | [diff] [blame] | 98 | endif |
| 99 | |
Simon Glass | b265c34 | 2011-11-16 15:09:51 -0800 | [diff] [blame] | 100 | # Provide default CC and CFLAGS for firmware builds; if you have any -D flags, |
| 101 | # please add them after this point (e.g., -DVBOOT_DEBUG). |
Che-Liang Chiou | 74359b7 | 2011-06-21 15:25:51 -0700 | [diff] [blame] | 102 | # |
Che-Liang Chiou | 6b0003c | 2011-10-14 11:11:28 +0800 | [diff] [blame] | 103 | # TODO(crosbug.com/16808) We hard-code u-boot's compiler flags here just |
| 104 | # temporarily. As we are still investigating which flags are necessary for |
| 105 | # maintaining a compatible ABI, etc. between u-boot and vboot_reference. |
Che-Liang Chiou | 74359b7 | 2011-06-21 15:25:51 -0700 | [diff] [blame] | 106 | # |
Simon Glass | b265c34 | 2011-11-16 15:09:51 -0800 | [diff] [blame] | 107 | # As a first step, this makes the setting of CC and CFLAGS here optional, to |
| 108 | # permit a calling script or Makefile to set these. |
Che-Liang Chiou | 74359b7 | 2011-06-21 15:25:51 -0700 | [diff] [blame] | 109 | # |
Simon Glass | b265c34 | 2011-11-16 15:09:51 -0800 | [diff] [blame] | 110 | # Flag ordering: arch, then -f, then -m, then -W |
| 111 | DEBUG_FLAGS := $(if ${DEBUG},-g -O0,-Os) |
| 112 | COMMON_FLAGS := -nostdinc -pipe \ |
| 113 | -ffreestanding -fno-builtin -fno-stack-protector \ |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 114 | -Werror -Wall -Wstrict-prototypes ${DEBUG_FLAGS} |
Simon Glass | b265c34 | 2011-11-16 15:09:51 -0800 | [diff] [blame] | 115 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 116 | # Note: FIRMWARE_ARCH is defined by the Chromium OS ebuild. |
| 117 | ifeq (${FIRMWARE_ARCH}, arm) |
Simon Glass | b265c34 | 2011-11-16 15:09:51 -0800 | [diff] [blame] | 118 | CC ?= armv7a-cros-linux-gnueabi-gcc |
| 119 | CFLAGS ?= -march=armv5 \ |
| 120 | -fno-common -ffixed-r8 \ |
Doug Anderson | d50b27d | 2012-05-11 12:08:02 -0700 | [diff] [blame] | 121 | -mfloat-abi=hard -marm -mabi=aapcs-linux -mno-thumb-interwork \ |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 122 | ${COMMON_FLAGS} |
Randall Spangler | 61a2eb3 | 2013-01-23 10:20:16 -0800 | [diff] [blame] | 123 | else ifeq (${FIRMWARE_ARCH}, x86) |
Simon Glass | b265c34 | 2011-11-16 15:09:51 -0800 | [diff] [blame] | 124 | CC ?= i686-pc-linux-gnu-gcc |
| 125 | # Drop -march=i386 to permit use of SSE instructions |
| 126 | CFLAGS ?= \ |
| 127 | -ffunction-sections -fvisibility=hidden -fno-strict-aliasing \ |
| 128 | -fomit-frame-pointer -fno-toplevel-reorder -fno-dwarf2-cfi-asm \ |
Gabe Black | 46e00e6 | 2013-12-18 18:23:24 -0800 | [diff] [blame] | 129 | -mpreferred-stack-boundary=2 \ |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 130 | ${COMMON_FLAGS} |
| 131 | else ifeq (${FIRMWARE_ARCH}, x86_64) |
| 132 | CFLAGS ?= ${COMMON_FLAGS} \ |
Simon Glass | 8e85e98 | 2011-11-22 13:54:50 -0800 | [diff] [blame] | 133 | -fvisibility=hidden -fno-strict-aliasing -fomit-frame-pointer |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 134 | else |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 135 | # FIRMWARE_ARCH not defined; assuming local compile. |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 136 | CC ?= gcc |
Bill Richardson | d462101 | 2014-07-09 23:31:13 -0700 | [diff] [blame] | 137 | CFLAGS += -DCHROMEOS_ENVIRONMENT -Wall -Werror ${DEBUG_FLAGS} |
Che-Liang Chiou | 34be827 | 2011-01-27 16:44:36 +0800 | [diff] [blame] | 138 | endif |
| 139 | |
| 140 | ifneq (${DEBUG},) |
| 141 | CFLAGS += -DVBOOT_DEBUG |
vbendeb | b2b0fcc | 2010-07-15 15:09:47 -0700 | [diff] [blame] | 142 | endif |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 143 | |
vbendeb | b2b0fcc | 2010-07-15 15:09:47 -0700 | [diff] [blame] | 144 | ifeq (${DISABLE_NDEBUG},) |
| 145 | CFLAGS += -DNDEBUG |
| 146 | endif |
| 147 | |
Bill Richardson | feb2518 | 2013-03-07 12:54:29 -0800 | [diff] [blame] | 148 | ifneq (${FORCE_LOGGING_ON},) |
| 149 | CFLAGS += -DFORCE_LOGGING_ON=${FORCE_LOGGING_ON} |
| 150 | endif |
| 151 | |
Randall Spangler | 6014c04 | 2014-07-22 14:42:58 -0700 | [diff] [blame] | 152 | ifneq (${PD_SYNC},) |
| 153 | CFLAGS += -DPD_SYNC |
| 154 | endif |
| 155 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 156 | # Create / use dependency files |
| 157 | CFLAGS += -MMD -MF $@.d |
Simon Glass | b265c34 | 2011-11-16 15:09:51 -0800 | [diff] [blame] | 158 | |
Bertrand SIMONNET | f8f807a | 2014-06-30 09:41:13 -0700 | [diff] [blame] | 159 | ifeq (${FIRMWARE_ARCH},) |
| 160 | # Creates position independent code for non firmware target. |
| 161 | CFLAGS += -fPIE |
| 162 | endif |
| 163 | |
Bill Richardson | 0c3ba24 | 2013-03-29 11:09:30 -0700 | [diff] [blame] | 164 | # These are required to access large disks and files on 32-bit systems. |
| 165 | CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 |
| 166 | |
Randall Spangler | 59d7508 | 2013-01-23 09:29:54 -0800 | [diff] [blame] | 167 | # Code coverage |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 168 | ifneq (${COV},) |
Bill Richardson | d2d08b2 | 2014-07-08 16:31:40 -0700 | [diff] [blame] | 169 | COV_FLAGS = -O0 --coverage -DCOVERAGE |
Randall Spangler | 59d7508 | 2013-01-23 09:29:54 -0800 | [diff] [blame] | 170 | CFLAGS += ${COV_FLAGS} |
| 171 | LDFLAGS += ${COV_FLAGS} |
| 172 | COV_INFO = ${BUILD}/coverage.info |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 173 | endif |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 174 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 175 | # And a few more default utilities |
| 176 | LD = ${CC} |
| 177 | CXX ?= g++ # HEY: really? |
| 178 | PKG_CONFIG ?= pkg-config |
| 179 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 180 | # Determine QEMU architecture needed, if any |
| 181 | ifeq (${ARCH},${HOST_ARCH}) |
| 182 | # Same architecture; no need for QEMU |
| 183 | QEMU_ARCH := |
Randall Spangler | 61a2eb3 | 2013-01-23 10:20:16 -0800 | [diff] [blame] | 184 | else ifeq (${HOST_ARCH}-${ARCH},x86_64-x86) |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 185 | # 64-bit host can run 32-bit targets directly |
| 186 | QEMU_ARCH := |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 187 | else |
| 188 | QEMU_ARCH := ${ARCH} |
| 189 | endif |
| 190 | |
| 191 | # The top of the chroot for qemu must be passed in via the SYSROOT environment |
| 192 | # variable. In the Chromium OS chroot, this is done automatically by the |
| 193 | # ebuild. |
| 194 | |
| 195 | ifeq (${QEMU_ARCH},) |
| 196 | # Path to build output for running tests is same as for building |
| 197 | BUILD_RUN = ${BUILD} |
Randall Spangler | e061a25 | 2013-01-22 15:34:07 -0800 | [diff] [blame] | 198 | SRC_RUN = ${SRCDIR} |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 199 | else |
| 200 | $(info Using qemu for testing.) |
| 201 | # Path to build output for running tests is different in the chroot |
| 202 | BUILD_RUN = $(subst ${SYSROOT},,${BUILD}) |
Randall Spangler | e061a25 | 2013-01-22 15:34:07 -0800 | [diff] [blame] | 203 | SRC_RUN = $(subst ${SYSROOT},,${SRCDIR}) |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 204 | |
| 205 | QEMU_BIN = qemu-${QEMU_ARCH} |
Randall Spangler | e061a25 | 2013-01-22 15:34:07 -0800 | [diff] [blame] | 206 | QEMU_RUN = ${BUILD_RUN}/${QEMU_BIN} |
| 207 | export QEMU_RUN |
| 208 | |
| 209 | RUNTEST = tests/test_using_qemu.sh |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 210 | endif |
| 211 | |
Randall Spangler | e061a25 | 2013-01-22 15:34:07 -0800 | [diff] [blame] | 212 | export BUILD_RUN |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 213 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 214 | ############################################################################## |
| 215 | # Now we need to describe everything we might want or need to build |
| 216 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 217 | # Everything wants these headers. |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 218 | INCLUDES += \ |
| 219 | -Ifirmware/include \ |
| 220 | -Ifirmware/lib/include \ |
| 221 | -Ifirmware/lib/cgptlib/include \ |
| 222 | -Ifirmware/lib/cryptolib/include \ |
Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 223 | -Ifirmware/lib/tpm_lite/include \ |
| 224 | -Ifirmware/2lib/include |
Bill Richardson | 0b8f35c | 2010-05-26 09:18:38 -0700 | [diff] [blame] | 225 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 226 | # If we're not building for a specific target, just stub out things like the |
| 227 | # TPM commands and various external functions that are provided by the BIOS. |
| 228 | ifeq (${FIRMWARE_ARCH},) |
Bill Richardson | 0e6ae29 | 2014-08-26 10:34:40 -0700 | [diff] [blame] | 229 | INCLUDES += -Ihost/include -Ihost/lib/include |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 230 | else |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 231 | INCLUDES += -Ifirmware/arch/${FIRMWARE_ARCH}/include |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 232 | endif |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 233 | |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 234 | # Firmware library, used by the other firmware components (depthcharge, |
| 235 | # coreboot, etc.). It doesn't need exporting to some other place; they'll build |
| 236 | # this source tree locally and link to it directly. |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 237 | FWLIB = ${BUILD}/vboot_fw.a |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 238 | |
Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 239 | # Smaller firmware library. TODO: Do we still need to export this? |
| 240 | ifneq (${VBOOT2},) |
| 241 | FWLIB2 = ${BUILD}/vboot_fw2.a |
| 242 | endif |
| 243 | |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame] | 244 | # Firmware library sources needed by VbInit() call |
| 245 | VBINIT_SRCS = \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 246 | firmware/lib/crc8.c \ |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame] | 247 | firmware/lib/utility.c \ |
| 248 | firmware/lib/vboot_api_init.c \ |
| 249 | firmware/lib/vboot_common_init.c \ |
| 250 | firmware/lib/vboot_nvstorage.c \ |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 251 | firmware/lib/vboot_nvstorage_rollback.c \ |
Simon Glass | 527ba81 | 2013-07-25 08:48:47 -0600 | [diff] [blame] | 252 | firmware/lib/region-init.c \ |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame] | 253 | |
| 254 | # Additional firmware library sources needed by VbSelectFirmware() call |
| 255 | VBSF_SRCS = \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 256 | firmware/lib/cryptolib/padding.c \ |
| 257 | firmware/lib/cryptolib/rsa.c \ |
| 258 | firmware/lib/cryptolib/rsa_utility.c \ |
| 259 | firmware/lib/cryptolib/sha1.c \ |
| 260 | firmware/lib/cryptolib/sha256.c \ |
| 261 | firmware/lib/cryptolib/sha512.c \ |
| 262 | firmware/lib/cryptolib/sha_utility.c \ |
| 263 | firmware/lib/stateful_util.c \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 264 | firmware/lib/vboot_api_firmware.c \ |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame] | 265 | firmware/lib/vboot_common.c \ |
Simon Glass | 527ba81 | 2013-07-25 08:48:47 -0600 | [diff] [blame] | 266 | firmware/lib/vboot_firmware.c \ |
| 267 | firmware/lib/region-fw.c \ |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame] | 268 | |
| 269 | # Additional firmware library sources needed by VbSelectAndLoadKernel() call |
| 270 | VBSLK_SRCS = \ |
| 271 | firmware/lib/cgptlib/cgptlib.c \ |
| 272 | firmware/lib/cgptlib/cgptlib_internal.c \ |
| 273 | firmware/lib/cgptlib/crc32.c \ |
Albert Chaulk | 5c9e453 | 2013-03-20 16:03:49 -0700 | [diff] [blame] | 274 | firmware/lib/cgptlib/mtdlib.c \ |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame] | 275 | firmware/lib/utility_string.c \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 276 | firmware/lib/vboot_api_kernel.c \ |
| 277 | firmware/lib/vboot_audio.c \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 278 | firmware/lib/vboot_display.c \ |
Simon Glass | 527ba81 | 2013-07-25 08:48:47 -0600 | [diff] [blame] | 279 | firmware/lib/vboot_kernel.c \ |
| 280 | firmware/lib/region-kernel.c \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 281 | |
Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 282 | # Firmware library source needed for smaller library 2 |
| 283 | FWLIB2_SRCS = \ |
Randall Spangler | a7ab8b5 | 2014-06-10 17:05:08 -0700 | [diff] [blame] | 284 | firmware/2lib/2api.c \ |
Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 285 | firmware/2lib/2common.c \ |
Randall Spangler | 3333e57 | 2014-05-14 11:37:52 -0700 | [diff] [blame] | 286 | firmware/2lib/2crc8.c \ |
| 287 | firmware/2lib/2misc.c \ |
| 288 | firmware/2lib/2nvstorage.c \ |
Randall Spangler | e166d04 | 2014-05-13 09:24:52 -0700 | [diff] [blame] | 289 | firmware/2lib/2rsa.c \ |
Randall Spangler | 3333e57 | 2014-05-14 11:37:52 -0700 | [diff] [blame] | 290 | firmware/2lib/2secdata.c \ |
Randall Spangler | e166d04 | 2014-05-13 09:24:52 -0700 | [diff] [blame] | 291 | firmware/2lib/2sha1.c \ |
| 292 | firmware/2lib/2sha256.c \ |
| 293 | firmware/2lib/2sha512.c \ |
| 294 | firmware/2lib/2sha_utility.c \ |
Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 295 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 296 | # Support real TPM unless BIOS sets MOCK_TPM |
| 297 | ifeq (${MOCK_TPM},) |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame] | 298 | VBINIT_SRCS += \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 299 | firmware/lib/rollback_index.c \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 300 | firmware/lib/tpm_lite/tlcl.c |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame] | 301 | |
| 302 | VBSF_SRCS += \ |
| 303 | firmware/lib/tpm_bootmode.c |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 304 | else |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame] | 305 | VBINIT_SRCS += \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 306 | firmware/lib/mocked_rollback_index.c \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 307 | firmware/lib/tpm_lite/mocked_tlcl.c |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame] | 308 | |
| 309 | VBSF_SRCS += \ |
| 310 | firmware/lib/mocked_tpm_bootmode.c |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 311 | endif |
| 312 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 313 | ifeq (${FIRMWARE_ARCH},) |
| 314 | # Include BIOS stubs in the firmware library when compiling for host |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame] | 315 | # TODO: split out other stub funcs too |
| 316 | VBINIT_SRCS += \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 317 | firmware/stub/tpm_lite_stub.c \ |
| 318 | firmware/stub/utility_stub.c \ |
Simon Glass | 527ba81 | 2013-07-25 08:48:47 -0600 | [diff] [blame] | 319 | firmware/stub/vboot_api_stub_init.c \ |
| 320 | firmware/stub/vboot_api_stub_region.c |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame] | 321 | |
| 322 | VBSF_SRCS += \ |
| 323 | firmware/stub/vboot_api_stub_sf.c |
| 324 | |
| 325 | VBSLK_SRCS += \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 326 | firmware/stub/vboot_api_stub.c \ |
| 327 | firmware/stub/vboot_api_stub_disk.c |
Randall Spangler | da2b49c | 2014-06-10 17:03:40 -0700 | [diff] [blame] | 328 | |
| 329 | FWLIB2_SRCS += \ |
| 330 | firmware/2lib/2stub.c |
| 331 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 332 | endif |
| 333 | |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame] | 334 | VBSF_SRCS += ${VBINIT_SRCS} |
| 335 | FWLIB_SRCS += ${VBSF_SRCS} ${VBSLK_SRCS} |
| 336 | |
| 337 | VBINIT_OBJS = ${VBINIT_SRCS:%.c=${BUILD}/%.o} |
| 338 | VBSF_OBJS = ${VBSF_SRCS:%.c=${BUILD}/%.o} |
| 339 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 340 | FWLIB_OBJS = ${FWLIB_SRCS:%.c=${BUILD}/%.o} |
Bill Richardson | 1912bba | 2013-04-04 21:08:50 -0700 | [diff] [blame] | 341 | |
Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 342 | ifneq (${VBOOT2},) |
| 343 | FWLIB2_OBJS = ${FWLIB2_SRCS:%.c=${BUILD}/%.o} |
| 344 | endif |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 345 | |
Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 346 | ALL_OBJS += ${FWLIB_OBJS} ${FWLIB2_OBJS} ${VBINIT_OBJS} ${VBSF_OBJS} |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 347 | |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 348 | # Intermediate library for the vboot_reference utilities to link against. |
| 349 | UTILLIB = ${BUILD}/libvboot_util.a |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 350 | |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 351 | UTILLIB_SRCS = \ |
Bill Richardson | 81a0b3d | 2013-02-28 13:53:09 -0800 | [diff] [blame] | 352 | cgpt/cgpt_create.c \ |
| 353 | cgpt/cgpt_add.c \ |
| 354 | cgpt/cgpt_boot.c \ |
| 355 | cgpt/cgpt_show.c \ |
| 356 | cgpt/cgpt_repair.c \ |
| 357 | cgpt/cgpt_prioritize.c \ |
| 358 | cgpt/cgpt_common.c \ |
Bill Richardson | 18e0370 | 2014-06-23 17:48:33 -0700 | [diff] [blame] | 359 | cgpt/flash_ts.c \ |
Albert Chaulk | 534723a | 2013-03-20 14:46:50 -0700 | [diff] [blame] | 360 | cgpt/flash_ts_drv.c \ |
Albert Chaulk | b334e65 | 2013-03-28 15:25:33 -0700 | [diff] [blame] | 361 | firmware/lib/cgptlib/mtdlib.c \ |
Bill Richardson | 6f39615 | 2014-07-15 12:52:19 -0700 | [diff] [blame] | 362 | futility/dump_kernel_config_lib.c \ |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 363 | host/arch/${ARCH}/lib/crossystem_arch.c \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 364 | host/lib/crossystem.c \ |
| 365 | host/lib/file_keys.c \ |
| 366 | host/lib/fmap.c \ |
| 367 | host/lib/host_common.c \ |
| 368 | host/lib/host_key.c \ |
| 369 | host/lib/host_keyblock.c \ |
| 370 | host/lib/host_misc.c \ |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 371 | host/lib/util_misc.c \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 372 | host/lib/host_signature.c \ |
Bill Richardson | 6f39615 | 2014-07-15 12:52:19 -0700 | [diff] [blame] | 373 | host/lib/signature_digest.c |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 374 | |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 375 | UTILLIB_OBJS = ${UTILLIB_SRCS:%.c=${BUILD}/%.o} |
| 376 | ALL_OBJS += ${UTILLIB_OBJS} |
| 377 | |
| 378 | # Externally exported library for some target userspace apps to link with |
| 379 | # (cryptohome, updater, etc.) |
| 380 | HOSTLIB = ${BUILD}/libvboot_host.a |
| 381 | |
| 382 | HOSTLIB_SRCS = \ |
| 383 | cgpt/cgpt_add.c \ |
| 384 | cgpt/cgpt_boot.c \ |
| 385 | cgpt/cgpt_common.c \ |
| 386 | cgpt/cgpt_create.c \ |
| 387 | cgpt/cgpt_prioritize.c \ |
Bill Richardson | 18e0370 | 2014-06-23 17:48:33 -0700 | [diff] [blame] | 388 | cgpt/flash_ts.c \ |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 389 | cgpt/flash_ts_drv.c \ |
| 390 | firmware/lib/cgptlib/cgptlib_internal.c \ |
| 391 | firmware/lib/cgptlib/crc32.c \ |
| 392 | firmware/lib/cgptlib/mtdlib.c \ |
| 393 | firmware/lib/crc8.c \ |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 394 | firmware/lib/tpm_lite/tlcl.c \ |
| 395 | firmware/lib/utility_string.c \ |
| 396 | firmware/lib/vboot_nvstorage.c \ |
| 397 | firmware/stub/tpm_lite_stub.c \ |
| 398 | firmware/stub/utility_stub.c \ |
| 399 | firmware/stub/vboot_api_stub_init.c \ |
Bill Richardson | 6f39615 | 2014-07-15 12:52:19 -0700 | [diff] [blame] | 400 | futility/dump_kernel_config_lib.c \ |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 401 | host/arch/${ARCH}/lib/crossystem_arch.c \ |
| 402 | host/lib/crossystem.c \ |
Bill Richardson | 6f39615 | 2014-07-15 12:52:19 -0700 | [diff] [blame] | 403 | host/lib/host_misc.c |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 404 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 405 | HOSTLIB_OBJS = ${HOSTLIB_SRCS:%.c=${BUILD}/%.o} |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 406 | ALL_OBJS += ${HOSTLIB_OBJS} |
| 407 | |
Bill Richardson | 81a0b3d | 2013-02-28 13:53:09 -0800 | [diff] [blame] | 408 | # Sigh. For historical reasons, the autoupdate installer must sometimes be a |
| 409 | # 32-bit executable, even when everything else is 64-bit. But it only needs a |
| 410 | # few functions, so let's just build those. |
| 411 | TINYHOSTLIB = ${BUILD}/libtinyvboot_host.a |
| 412 | |
| 413 | TINYHOSTLIB_SRCS = \ |
Bill Richardson | 81a0b3d | 2013-02-28 13:53:09 -0800 | [diff] [blame] | 414 | cgpt/cgpt_add.c \ |
| 415 | cgpt/cgpt_boot.c \ |
Bill Richardson | 81a0b3d | 2013-02-28 13:53:09 -0800 | [diff] [blame] | 416 | cgpt/cgpt_common.c \ |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 417 | cgpt/cgpt_create.c \ |
| 418 | cgpt/cgpt_prioritize.c \ |
Bill Richardson | 18e0370 | 2014-06-23 17:48:33 -0700 | [diff] [blame] | 419 | cgpt/flash_ts.c \ |
Albert Chaulk | 534723a | 2013-03-20 14:46:50 -0700 | [diff] [blame] | 420 | cgpt/flash_ts_drv.c \ |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 421 | firmware/lib/cgptlib/cgptlib_internal.c \ |
| 422 | firmware/lib/cgptlib/crc32.c \ |
Albert Chaulk | b334e65 | 2013-03-28 15:25:33 -0700 | [diff] [blame] | 423 | firmware/lib/cgptlib/mtdlib.c \ |
Bill Richardson | 5fed2a6 | 2013-03-04 15:11:38 -0800 | [diff] [blame] | 424 | firmware/lib/utility_string.c \ |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 425 | firmware/stub/utility_stub.c \ |
Bill Richardson | 6f39615 | 2014-07-15 12:52:19 -0700 | [diff] [blame] | 426 | futility/dump_kernel_config_lib.c |
Bill Richardson | 81a0b3d | 2013-02-28 13:53:09 -0800 | [diff] [blame] | 427 | |
| 428 | TINYHOSTLIB_OBJS = ${TINYHOSTLIB_SRCS:%.c=${BUILD}/%.o} |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 429 | |
| 430 | # ---------------------------------------------------------------------------- |
| 431 | # Now for the userspace binaries |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 432 | |
| 433 | CGPT = ${BUILD}/cgpt/cgpt |
| 434 | |
| 435 | CGPT_SRCS = \ |
| 436 | cgpt/cgpt.c \ |
| 437 | cgpt/cgpt_add.c \ |
| 438 | cgpt/cgpt_boot.c \ |
| 439 | cgpt/cgpt_common.c \ |
| 440 | cgpt/cgpt_create.c \ |
| 441 | cgpt/cgpt_find.c \ |
| 442 | cgpt/cgpt_legacy.c \ |
| 443 | cgpt/cgpt_prioritize.c \ |
| 444 | cgpt/cgpt_repair.c \ |
| 445 | cgpt/cgpt_show.c \ |
| 446 | cgpt/cmd_add.c \ |
| 447 | cgpt/cmd_boot.c \ |
| 448 | cgpt/cmd_create.c \ |
| 449 | cgpt/cmd_find.c \ |
| 450 | cgpt/cmd_legacy.c \ |
| 451 | cgpt/cmd_prioritize.c \ |
| 452 | cgpt/cmd_repair.c \ |
Albert Chaulk | 534723a | 2013-03-20 14:46:50 -0700 | [diff] [blame] | 453 | cgpt/cmd_show.c \ |
Bill Richardson | 18e0370 | 2014-06-23 17:48:33 -0700 | [diff] [blame] | 454 | cgpt/flash_ts.c \ |
| 455 | cgpt/flash_ts_drv.c |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 456 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 457 | CGPT_OBJS = ${CGPT_SRCS:%.c=${BUILD}/%.o} |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 458 | ALL_OBJS += ${CGPT_OBJS} |
| 459 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 460 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 461 | # Scripts to install directly (not compiled) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 462 | UTIL_SCRIPTS = \ |
| 463 | utility/dev_debug_vboot \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 464 | utility/enable_dev_usb_boot \ |
| 465 | utility/vbutil_what_keys |
| 466 | |
Bill Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 467 | ifeq (${MINIMAL},) |
| 468 | UTIL_SCRIPTS += \ |
| 469 | utility/dev_make_keypair |
| 470 | endif |
| 471 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 472 | # These utilities should be linked statically. |
| 473 | UTIL_NAMES_STATIC = \ |
Bill Richardson | 6f39615 | 2014-07-15 12:52:19 -0700 | [diff] [blame] | 474 | utility/crossystem |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 475 | |
| 476 | UTIL_NAMES = ${UTIL_NAMES_STATIC} \ |
Bill Richardson | 339f7e0 | 2013-04-05 09:49:24 -0700 | [diff] [blame] | 477 | utility/tpm_init_temp_fix \ |
Bill Richardson | 6f39615 | 2014-07-15 12:52:19 -0700 | [diff] [blame] | 478 | utility/tpmc |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 479 | |
Bill Richardson | 6f39615 | 2014-07-15 12:52:19 -0700 | [diff] [blame] | 480 | # TODO: Do we still need eficompress and efidecompress for anything? |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 481 | ifeq (${MINIMAL},) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 482 | UTIL_NAMES += \ |
Bill Richardson | 339f7e0 | 2013-04-05 09:49:24 -0700 | [diff] [blame] | 483 | utility/bmpblk_font \ |
| 484 | utility/bmpblk_utility \ |
Bill Richardson | 6f39615 | 2014-07-15 12:52:19 -0700 | [diff] [blame] | 485 | utility/dumpRSAPublicKey \ |
Bill Richardson | 339f7e0 | 2013-04-05 09:49:24 -0700 | [diff] [blame] | 486 | utility/eficompress \ |
| 487 | utility/efidecompress \ |
| 488 | utility/load_kernel_test \ |
| 489 | utility/pad_digest_utility \ |
| 490 | utility/signature_digest_utility \ |
| 491 | utility/verify_data |
Randall Spangler | a7ab8b5 | 2014-06-10 17:05:08 -0700 | [diff] [blame] | 492 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 493 | endif |
| 494 | |
Bill Richardson | 339f7e0 | 2013-04-05 09:49:24 -0700 | [diff] [blame] | 495 | UTIL_BINS_STATIC := $(addprefix ${BUILD}/,${UTIL_NAMES_STATIC}) |
| 496 | UTIL_BINS = $(addprefix ${BUILD}/,${UTIL_NAMES}) |
Bill Richardson | 1912bba | 2013-04-04 21:08:50 -0700 | [diff] [blame] | 497 | ALL_OBJS += $(addsuffix .o,${UTIL_BINS} ${UTIL_BINS_STATIC}) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 498 | |
Bill Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 499 | |
| 500 | # Scripts for signing stuff. |
| 501 | SIGNING_SCRIPTS = \ |
| 502 | utility/tpm-nvsize \ |
| 503 | utility/chromeos-tpm-recovery |
| 504 | |
| 505 | # These go in a different place. |
| 506 | SIGNING_SCRIPTS_DEV = \ |
| 507 | scripts/image_signing/resign_firmwarefd.sh \ |
| 508 | scripts/image_signing/make_dev_firmware.sh \ |
| 509 | scripts/image_signing/make_dev_ssd.sh \ |
| 510 | scripts/image_signing/set_gbb_flags.sh |
| 511 | |
| 512 | # Installed, but not made executable. |
| 513 | SIGNING_COMMON = scripts/image_signing/common_minimal.sh |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 514 | |
Bill Richardson | 826db09 | 2013-01-14 12:37:15 -0800 | [diff] [blame] | 515 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 516 | # The unified firmware utility will eventually replace all the others |
| 517 | FUTIL_BIN = ${BUILD}/futility/futility |
Bill Richardson | 6db8c75 | 2013-04-05 13:30:43 -0700 | [diff] [blame] | 518 | # But we still need both static (tiny) and dynamic (with openssl) versions. |
| 519 | FUTIL_STATIC_BIN = ${FUTIL_BIN}_s |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 520 | |
Bill Richardson | 6f39615 | 2014-07-15 12:52:19 -0700 | [diff] [blame] | 521 | # These are the executables that are now built in to futility. We'll create |
| 522 | # symlinks for these so the old names will still work. |
| 523 | # TODO: Do we still need dev_sign_file for anything? |
| 524 | FUTIL_BUILTIN = \ |
Bill Richardson | e155044 | 2014-07-17 11:32:17 -0700 | [diff] [blame] | 525 | dev_sign_file \ |
Bill Richardson | e155044 | 2014-07-17 11:32:17 -0700 | [diff] [blame] | 526 | dump_fmap \ |
| 527 | dump_kernel_config \ |
Bill Richardson | e155044 | 2014-07-17 11:32:17 -0700 | [diff] [blame] | 528 | gbb_utility \ |
Bill Richardson | e155044 | 2014-07-17 11:32:17 -0700 | [diff] [blame] | 529 | vbutil_firmware \ |
| 530 | vbutil_kernel \ |
| 531 | vbutil_key \ |
Bill Richardson | 6f39615 | 2014-07-15 12:52:19 -0700 | [diff] [blame] | 532 | vbutil_keyblock |
Bill Richardson | feb2518 | 2013-03-07 12:54:29 -0800 | [diff] [blame] | 533 | |
Bill Richardson | 6db8c75 | 2013-04-05 13:30:43 -0700 | [diff] [blame] | 534 | FUTIL_STATIC_SRCS = \ |
Bill Richardson | feb2518 | 2013-03-07 12:54:29 -0800 | [diff] [blame] | 535 | futility/futility.c \ |
Bill Richardson | 20807b6 | 2013-04-09 10:15:26 -0700 | [diff] [blame] | 536 | futility/cmd_dump_fmap.c \ |
Bill Richardson | 6f39615 | 2014-07-15 12:52:19 -0700 | [diff] [blame] | 537 | futility/cmd_gbb_utility.c |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 538 | |
Bill Richardson | 6db8c75 | 2013-04-05 13:30:43 -0700 | [diff] [blame] | 539 | FUTIL_SRCS = \ |
| 540 | $(FUTIL_STATIC_SRCS) \ |
Bill Richardson | 6f39615 | 2014-07-15 12:52:19 -0700 | [diff] [blame] | 541 | futility/cmd_dev_sign_file.c \ |
| 542 | futility/cmd_dump_kernel_config.c \ |
| 543 | futility/cmd_vbutil_firmware.c \ |
| 544 | futility/cmd_vbutil_kernel.c \ |
Bill Richardson | b84b81d | 2014-07-14 14:48:31 -0700 | [diff] [blame] | 545 | futility/cmd_vbutil_key.c \ |
Randall Spangler | b8ff397 | 2014-08-27 13:34:35 -0700 | [diff] [blame^] | 546 | futility/cmd_vbutil_keyblock.c \ |
| 547 | futility/cmd_verify_kernel.c |
Bill Richardson | 6db8c75 | 2013-04-05 13:30:43 -0700 | [diff] [blame] | 548 | |
Randall Spangler | 028f468 | 2014-08-19 14:42:08 -0700 | [diff] [blame] | 549 | ifneq (${VBOOT2},) |
| 550 | FUTIL_SRCS += \ |
| 551 | futility/cmd_vb2_verify_fw.c |
| 552 | endif |
| 553 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 554 | FUTIL_LDS = futility/futility.lds |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 555 | |
Bill Richardson | 6db8c75 | 2013-04-05 13:30:43 -0700 | [diff] [blame] | 556 | FUTIL_STATIC_OBJS = ${FUTIL_STATIC_SRCS:%.c=${BUILD}/%.o} |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 557 | FUTIL_OBJS = ${FUTIL_SRCS:%.c=${BUILD}/%.o} |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 558 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 559 | ALL_OBJS += ${FUTIL_OBJS} |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 560 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 561 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 562 | # Library of handy test functions. |
| 563 | TESTLIB = ${BUILD}/tests/test.a |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 564 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 565 | TESTLIB_SRCS = \ |
| 566 | tests/test_common.c \ |
| 567 | tests/timer_utils.c \ |
| 568 | tests/crc32_test.c |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 569 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 570 | TESTLIB_OBJS = ${TESTLIB_SRCS:%.c=${BUILD}/%.o} |
| 571 | ALL_OBJS += ${TESTLIB_OBJS} |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 572 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 573 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 574 | # And some compiled tests. |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 575 | TEST_NAMES = \ |
Bill Richardson | 339f7e0 | 2013-04-05 09:49:24 -0700 | [diff] [blame] | 576 | tests/cgptlib_test \ |
| 577 | tests/rollback_index2_tests \ |
| 578 | tests/rollback_index3_tests \ |
| 579 | tests/rsa_padding_test \ |
| 580 | tests/rsa_utility_tests \ |
| 581 | tests/rsa_verify_benchmark \ |
| 582 | tests/sha_benchmark \ |
| 583 | tests/sha_tests \ |
| 584 | tests/stateful_util_tests \ |
| 585 | tests/tlcl_tests \ |
| 586 | tests/tpm_bootmode_tests \ |
| 587 | tests/utility_string_tests \ |
| 588 | tests/utility_tests \ |
| 589 | tests/vboot_api_init_tests \ |
| 590 | tests/vboot_api_devmode_tests \ |
| 591 | tests/vboot_api_firmware_tests \ |
| 592 | tests/vboot_api_kernel_tests \ |
| 593 | tests/vboot_api_kernel2_tests \ |
| 594 | tests/vboot_api_kernel3_tests \ |
| 595 | tests/vboot_api_kernel4_tests \ |
| 596 | tests/vboot_audio_tests \ |
| 597 | tests/vboot_common_tests \ |
| 598 | tests/vboot_common2_tests \ |
| 599 | tests/vboot_common3_tests \ |
| 600 | tests/vboot_display_tests \ |
| 601 | tests/vboot_firmware_tests \ |
| 602 | tests/vboot_kernel_tests \ |
| 603 | tests/vboot_nvstorage_test \ |
Bill Richardson | 6f39615 | 2014-07-15 12:52:19 -0700 | [diff] [blame] | 604 | tests/futility/binary_editor \ |
Bill Richardson | 339f7e0 | 2013-04-05 09:49:24 -0700 | [diff] [blame] | 605 | tests/futility/test_not_really |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 606 | |
Simon Glass | 527ba81 | 2013-07-25 08:48:47 -0600 | [diff] [blame] | 607 | ifdef REGION_READ |
| 608 | TEST_NAMES += tests/vboot_region_tests |
| 609 | endif |
| 610 | |
Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 611 | ifneq (${VBOOT2},) |
| 612 | TEST_NAMES += \ |
Randall Spangler | a7ab8b5 | 2014-06-10 17:05:08 -0700 | [diff] [blame] | 613 | tests/vb2_api_tests \ |
Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 614 | tests/vb2_common_tests \ |
Randall Spangler | 7141d73 | 2014-05-15 15:34:54 -0700 | [diff] [blame] | 615 | tests/vb2_common2_tests \ |
| 616 | tests/vb2_common3_tests \ |
Randall Spangler | 3333e57 | 2014-05-14 11:37:52 -0700 | [diff] [blame] | 617 | tests/vb2_misc_tests \ |
Randall Spangler | 1803068 | 2014-06-11 16:01:08 -0700 | [diff] [blame] | 618 | tests/vb2_misc2_tests \ |
Randall Spangler | 3333e57 | 2014-05-14 11:37:52 -0700 | [diff] [blame] | 619 | tests/vb2_nvstorage_tests \ |
Randall Spangler | e166d04 | 2014-05-13 09:24:52 -0700 | [diff] [blame] | 620 | tests/vb2_rsa_padding_tests \ |
| 621 | tests/vb2_rsa_utility_tests \ |
Randall Spangler | 3333e57 | 2014-05-14 11:37:52 -0700 | [diff] [blame] | 622 | tests/vb2_secdata_tests \ |
Randall Spangler | e166d04 | 2014-05-13 09:24:52 -0700 | [diff] [blame] | 623 | tests/vb2_sha_tests \ |
Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 624 | |
| 625 | endif |
| 626 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 627 | # And a few more... |
Bill Richardson | 339f7e0 | 2013-04-05 09:49:24 -0700 | [diff] [blame] | 628 | TLCL_TEST_NAMES = \ |
| 629 | tests/tpm_lite/tpmtest_earlyextend \ |
| 630 | tests/tpm_lite/tpmtest_earlynvram \ |
| 631 | tests/tpm_lite/tpmtest_earlynvram2 \ |
| 632 | tests/tpm_lite/tpmtest_enable \ |
| 633 | tests/tpm_lite/tpmtest_fastenable \ |
| 634 | tests/tpm_lite/tpmtest_globallock \ |
| 635 | tests/tpm_lite/tpmtest_redefine_unowned \ |
| 636 | tests/tpm_lite/tpmtest_spaceperm \ |
| 637 | tests/tpm_lite/tpmtest_testsetup \ |
| 638 | tests/tpm_lite/tpmtest_timing \ |
| 639 | tests/tpm_lite/tpmtest_writelimit |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 640 | |
| 641 | TEST_NAMES += ${TLCL_TEST_NAMES} |
| 642 | |
Bill Richardson | 339f7e0 | 2013-04-05 09:49:24 -0700 | [diff] [blame] | 643 | # Finally |
| 644 | TEST_BINS = $(addprefix ${BUILD}/,${TEST_NAMES}) |
Bill Richardson | 1912bba | 2013-04-04 21:08:50 -0700 | [diff] [blame] | 645 | ALL_OBJS += $(addsuffix .o,${TEST_BINS}) |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 646 | |
Randall Spangler | e061a25 | 2013-01-22 15:34:07 -0800 | [diff] [blame] | 647 | # Directory containing test keys |
| 648 | TEST_KEYS = ${SRC_RUN}/tests/testkeys |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 649 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 650 | |
| 651 | ############################################################################## |
| 652 | # Finally, some targets. High-level ones first. |
| 653 | |
| 654 | # Create output directories if necessary. Do this via explicit shell commands |
| 655 | # so it happens before trying to generate/include dependencies. |
| 656 | SUBDIRS := firmware host cgpt utility futility tests tests/tpm_lite |
| 657 | _dir_create := $(foreach d, \ |
| 658 | $(shell find ${SUBDIRS} -name '*.c' -exec dirname {} \; | sort -u), \ |
| 659 | $(shell [ -d ${BUILD}/${d} ] || mkdir -p ${BUILD}/${d})) |
| 660 | |
| 661 | |
| 662 | # Default target. |
| 663 | .PHONY: all |
Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 664 | all: fwlib $(if ${VBOOT2},fwlib2) $(if ${FIRMWARE_ARCH},,host_stuff) \ |
| 665 | $(if ${COV},coverage) |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 666 | |
| 667 | # Host targets |
| 668 | .PHONY: host_stuff |
Bill Richardson | bc2d2b2 | 2014-07-09 21:11:12 -0700 | [diff] [blame] | 669 | host_stuff: utillib hostlib cgpt utils futil tests |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 670 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 671 | .PHONY: clean |
| 672 | clean: |
| 673 | ${Q}/bin/rm -rf ${BUILD} |
| 674 | |
| 675 | .PHONY: install |
Bill Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 676 | install: cgpt_install utils_install signing_install futil_install |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 677 | |
Bill Richardson | 3e3790d | 2014-07-14 15:05:54 -0700 | [diff] [blame] | 678 | .PHONY: install_for_test |
| 679 | install_for_test: override DESTDIR = ${TEST_INSTALL_DIR} |
| 680 | install_for_test: install |
| 681 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 682 | # Don't delete intermediate object files |
| 683 | .SECONDARY: |
| 684 | |
Bill Richardson | 0e6ae29 | 2014-08-26 10:34:40 -0700 | [diff] [blame] | 685 | .PHONY: tags TAGS |
| 686 | tags TAGS: ${CGPT_SRCS} ${FUTIL_SRCS} ${UTILLIB_SRCS} ${FWLIB_SRCS} \ |
| 687 | $(if ${VBOOT2},${FWLIB2_SRCS}) \ |
| 688 | $(wildcard $(patsubst -I%,%/*.h,${INCLUDES})) |
| 689 | ${Q}\rm -f cscope.* TAGS |
| 690 | ${Q}echo $^ | tr ' ' '\012' > cscope.files |
| 691 | ${Q}$(if $(shell which etags 2>/dev/null),etags $^,echo "no etags") |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 692 | |
| 693 | # ---------------------------------------------------------------------------- |
| 694 | # Firmware library |
| 695 | |
| 696 | # TPM-specific flags. These depend on the particular TPM we're targeting for. |
| 697 | # They are needed here only for compiling parts of the firmware code into |
| 698 | # user-level tests. |
| 699 | |
| 700 | # TPM_BLOCKING_CONTINUESELFTEST is defined if TPM_ContinueSelfTest blocks until |
| 701 | # the self test has completed. |
| 702 | |
Randall Spangler | 45cc0f2 | 2013-01-25 09:34:26 -0800 | [diff] [blame] | 703 | ${FWLIB_OBJS}: CFLAGS += -DTPM_BLOCKING_CONTINUESELFTEST |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 704 | |
| 705 | # TPM_MANUAL_SELFTEST is defined if the self test must be started manually |
| 706 | # (with a call to TPM_ContinueSelfTest) instead of starting automatically at |
| 707 | # power on. |
| 708 | # |
| 709 | # We sincerely hope that TPM_BLOCKING_CONTINUESELFTEST and TPM_MANUAL_SELFTEST |
| 710 | # are not both defined at the same time. (See comment in code.) |
| 711 | |
| 712 | # CFLAGS += -DTPM_MANUAL_SELFTEST |
| 713 | |
| 714 | ifeq (${FIRMWARE_ARCH},i386) |
| 715 | # Unrolling loops in cryptolib makes it faster |
Randall Spangler | 45cc0f2 | 2013-01-25 09:34:26 -0800 | [diff] [blame] | 716 | ${FWLIB_OBJS}: CFLAGS += -DUNROLL_LOOPS |
Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 717 | ${FWLIB2_OBJS}: CFLAGS += -DUNROLL_LOOPS |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 718 | |
| 719 | # Workaround for coreboot on x86, which will power off asynchronously |
| 720 | # without giving us a chance to react. This is not an example of the Right |
| 721 | # Way to do things. See chrome-os-partner:7689, and the commit message |
| 722 | # that made this change. |
Randall Spangler | 45cc0f2 | 2013-01-25 09:34:26 -0800 | [diff] [blame] | 723 | ${FWLIB_OBJS}: CFLAGS += -DSAVE_LOCALE_IMMEDIATELY |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 724 | |
| 725 | # On x86 we don't actually read the GBB data into RAM until it is needed. |
| 726 | # Therefore it makes sense to cache it rather than reading it each time. |
| 727 | # Enable this feature. |
Randall Spangler | 45cc0f2 | 2013-01-25 09:34:26 -0800 | [diff] [blame] | 728 | ${FWLIB_OBJS}: CFLAGS += -DCOPY_BMP_DATA |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 729 | endif |
| 730 | |
Simon Glass | 527ba81 | 2013-07-25 08:48:47 -0600 | [diff] [blame] | 731 | ifdef REGION_READ |
| 732 | ${FWLIB_OBJS}: CFLAGS += -DREGION_READ |
| 733 | endif |
| 734 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 735 | ifeq (${FIRMWARE_ARCH},) |
| 736 | # Disable rollback TPM when compiling locally, since otherwise |
| 737 | # load_kernel_test attempts to talk to the TPM. |
Randall Spangler | 45cc0f2 | 2013-01-25 09:34:26 -0800 | [diff] [blame] | 738 | ${FWLIB_OBJS}: CFLAGS += -DDISABLE_ROLLBACK_TPM |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 739 | endif |
| 740 | |
Bill Richardson | a130e0b | 2013-04-04 18:16:39 -0700 | [diff] [blame] | 741 | # Linktest ensures firmware lib doesn't rely on outside libraries |
| 742 | ${BUILD}/firmware/linktest/main_vbinit: ${VBINIT_OBJS} |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame] | 743 | ${BUILD}/firmware/linktest/main_vbinit: OBJS = ${VBINIT_OBJS} |
Bill Richardson | 1912bba | 2013-04-04 21:08:50 -0700 | [diff] [blame] | 744 | ALL_OBJS += ${BUILD}/firmware/linktest/main_vbinit.o |
Bill Richardson | a130e0b | 2013-04-04 18:16:39 -0700 | [diff] [blame] | 745 | ${BUILD}/firmware/linktest/main_vbsf: ${VBSF_OBJS} |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame] | 746 | ${BUILD}/firmware/linktest/main_vbsf: OBJS = ${VBSF_OBJS} |
Bill Richardson | 1912bba | 2013-04-04 21:08:50 -0700 | [diff] [blame] | 747 | ALL_OBJS += ${BUILD}/firmware/linktest/main_vbsf.o |
Bill Richardson | a130e0b | 2013-04-04 18:16:39 -0700 | [diff] [blame] | 748 | ${BUILD}/firmware/linktest/main: ${FWLIB} |
| 749 | ${BUILD}/firmware/linktest/main: LIBS = ${FWLIB} |
Bill Richardson | 1912bba | 2013-04-04 21:08:50 -0700 | [diff] [blame] | 750 | ALL_OBJS += ${BUILD}/firmware/linktest/main.o |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame] | 751 | |
Bill Richardson | d2d08b2 | 2014-07-08 16:31:40 -0700 | [diff] [blame] | 752 | .PHONY: fwlinktest |
| 753 | fwlinktest: \ |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame] | 754 | ${BUILD}/firmware/linktest/main_vbinit \ |
| 755 | ${BUILD}/firmware/linktest/main_vbsf \ |
| 756 | ${BUILD}/firmware/linktest/main |
| 757 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 758 | .PHONY: fwlib |
Bill Richardson | a130e0b | 2013-04-04 18:16:39 -0700 | [diff] [blame] | 759 | fwlib: $(if ${FIRMWARE_ARCH},${FWLIB},fwlinktest) |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 760 | |
Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 761 | .PHONY: fwlib2 |
| 762 | fwlib2: ${FWLIB2} |
| 763 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 764 | ${FWLIB}: ${FWLIB_OBJS} |
Simon Glass | 661ae9e | 2013-03-26 11:39:21 -0700 | [diff] [blame] | 765 | @$(PRINTF) " RM $(subst ${BUILD}/,,$@)\n" |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 766 | ${Q}rm -f $@ |
Simon Glass | 661ae9e | 2013-03-26 11:39:21 -0700 | [diff] [blame] | 767 | @$(PRINTF) " AR $(subst ${BUILD}/,,$@)\n" |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 768 | ${Q}ar qc $@ $^ |
| 769 | |
Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 770 | ${FWLIB2}: ${FWLIB2_OBJS} |
| 771 | @$(PRINTF) " RM $(subst ${BUILD}/,,$@)\n" |
| 772 | ${Q}rm -f $@ |
| 773 | @$(PRINTF) " AR $(subst ${BUILD}/,,$@)\n" |
| 774 | ${Q}ar qc $@ $^ |
| 775 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 776 | # ---------------------------------------------------------------------------- |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 777 | # Host library(s) |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 778 | |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 779 | # Link tests for local utilities |
| 780 | ${BUILD}/host/linktest/main: ${UTILLIB} |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 781 | ${BUILD}/host/linktest/main: LIBS = ${UTILLIB} |
| 782 | ALL_OBJS += ${BUILD}/host/linktest/main.o |
| 783 | |
| 784 | .PHONY: utillib |
| 785 | utillib: ${UTILLIB} \ |
| 786 | ${BUILD}/host/linktest/main |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 787 | |
| 788 | # TODO: better way to make .a than duplicating this recipe each time? |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 789 | ${UTILLIB}: ${UTILLIB_OBJS} ${FWLIB_OBJS} $(if ${VBOOT2},${FWLIB2_OBJS}) |
| 790 | @$(PRINTF) " RM $(subst ${BUILD}/,,$@)\n" |
| 791 | ${Q}rm -f $@ |
| 792 | @$(PRINTF) " AR $(subst ${BUILD}/,,$@)\n" |
| 793 | ${Q}ar qc $@ $^ |
| 794 | |
| 795 | |
| 796 | # Link tests for external repos |
| 797 | ${BUILD}/host/linktest/extern: ${HOSTLIB} |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 798 | ${BUILD}/host/linktest/extern: LIBS = ${HOSTLIB} |
| 799 | ${BUILD}/host/linktest/extern: LDLIBS += -static |
| 800 | ALL_OBJS += ${BUILD}/host/linktest/extern.o |
| 801 | |
| 802 | .PHONY: hostlib |
| 803 | hostlib: ${HOSTLIB} \ |
| 804 | ${BUILD}/host/linktest/extern |
| 805 | |
| 806 | # TODO: better way to make .a than duplicating this recipe each time? |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 807 | ${HOSTLIB}: ${HOSTLIB_OBJS} |
Simon Glass | 661ae9e | 2013-03-26 11:39:21 -0700 | [diff] [blame] | 808 | @$(PRINTF) " RM $(subst ${BUILD}/,,$@)\n" |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 809 | ${Q}rm -f $@ |
Simon Glass | 661ae9e | 2013-03-26 11:39:21 -0700 | [diff] [blame] | 810 | @$(PRINTF) " AR $(subst ${BUILD}/,,$@)\n" |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 811 | ${Q}ar qc $@ $^ |
| 812 | |
Bill Richardson | 81a0b3d | 2013-02-28 13:53:09 -0800 | [diff] [blame] | 813 | |
| 814 | # Ugh. This is a very cut-down version of HOSTLIB just for the installer. |
| 815 | .PHONY: tinyhostlib |
| 816 | tinyhostlib: ${TINYHOSTLIB} |
| 817 | ${Q}cp -f ${TINYHOSTLIB} ${HOSTLIB} |
| 818 | |
| 819 | ${TINYHOSTLIB}: ${TINYHOSTLIB_OBJS} |
Simon Glass | 661ae9e | 2013-03-26 11:39:21 -0700 | [diff] [blame] | 820 | @$(PRINTF) " RM $(subst ${BUILD}/,,$@)\n" |
Bill Richardson | 81a0b3d | 2013-02-28 13:53:09 -0800 | [diff] [blame] | 821 | ${Q}rm -f $@ |
Simon Glass | 661ae9e | 2013-03-26 11:39:21 -0700 | [diff] [blame] | 822 | @$(PRINTF) " AR $(subst ${BUILD}/,,$@)\n" |
Bill Richardson | 81a0b3d | 2013-02-28 13:53:09 -0800 | [diff] [blame] | 823 | ${Q}ar qc $@ $^ |
| 824 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 825 | # ---------------------------------------------------------------------------- |
| 826 | # CGPT library and utility |
| 827 | |
| 828 | .PHONY: cgpt |
| 829 | cgpt: ${CGPT} |
| 830 | |
| 831 | ${CGPT}: LDFLAGS += -static |
| 832 | ${CGPT}: LDLIBS += -luuid |
| 833 | |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 834 | ${CGPT}: ${CGPT_OBJS} ${UTILLIB} |
Simon Glass | 661ae9e | 2013-03-26 11:39:21 -0700 | [diff] [blame] | 835 | @$(PRINTF) " LDcgpt $(subst ${BUILD}/,,$@)\n" |
Bill Richardson | 6db8c75 | 2013-04-05 13:30:43 -0700 | [diff] [blame] | 836 | ${Q}${LD} -o ${CGPT} ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS} |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 837 | |
| 838 | .PHONY: cgpt_install |
| 839 | cgpt_install: ${CGPT} |
Simon Glass | 661ae9e | 2013-03-26 11:39:21 -0700 | [diff] [blame] | 840 | @$(PRINTF) " INSTALL CGPT\n" |
Bill Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 841 | ${Q}mkdir -p ${UB_DIR} |
| 842 | ${Q}${INSTALL} -t ${UB_DIR} $^ |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 843 | |
| 844 | # ---------------------------------------------------------------------------- |
| 845 | # Utilities |
| 846 | |
| 847 | # These have their own headers too. |
Bill Richardson | 0f6679e | 2014-07-10 15:49:52 -0700 | [diff] [blame] | 848 | ${BUILD}/utility/%: INCLUDES += -Iutility/include |
| 849 | |
| 850 | ${UTIL_BINS} ${UTIL_BINS_STATIC}: ${UTILLIB} |
| 851 | ${UTIL_BINS} ${UTIL_BINS_STATIC}: LIBS = ${UTILLIB} |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 852 | |
| 853 | # Utilities for auto-update toolkits must be statically linked. |
| 854 | ${UTIL_BINS_STATIC}: LDFLAGS += -static |
| 855 | |
Bill Richardson | a130e0b | 2013-04-04 18:16:39 -0700 | [diff] [blame] | 856 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 857 | .PHONY: utils |
Bill Richardson | c7c6e5d | 2013-02-28 10:10:29 -0800 | [diff] [blame] | 858 | utils: ${UTIL_BINS} ${UTIL_SCRIPTS} |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 859 | ${Q}cp -f ${UTIL_SCRIPTS} ${BUILD}/utility |
| 860 | ${Q}chmod a+rx $(patsubst %,${BUILD}/%,${UTIL_SCRIPTS}) |
| 861 | |
| 862 | .PHONY: utils_install |
Bill Richardson | c7c6e5d | 2013-02-28 10:10:29 -0800 | [diff] [blame] | 863 | utils_install: ${UTIL_BINS} ${UTIL_SCRIPTS} |
Simon Glass | 661ae9e | 2013-03-26 11:39:21 -0700 | [diff] [blame] | 864 | @$(PRINTF) " INSTALL UTILS\n" |
Bill Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 865 | ${Q}mkdir -p ${UB_DIR} |
| 866 | ${Q}${INSTALL} -t ${UB_DIR} ${UTIL_BINS} ${UTIL_SCRIPTS} |
Bill Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 867 | |
| 868 | # And some signing stuff for the target |
| 869 | .PHONY: signing_install |
| 870 | signing_install: ${SIGNING_SCRIPTS} ${SIGNING_SCRIPTS_DEV} ${SIGNING_COMMON} |
Simon Glass | 661ae9e | 2013-03-26 11:39:21 -0700 | [diff] [blame] | 871 | @$(PRINTF) " INSTALL SIGNING\n" |
Bill Richardson | 6f39615 | 2014-07-15 12:52:19 -0700 | [diff] [blame] | 872 | ${Q}mkdir -p ${UB_DIR} ${VB_DIR} |
Bill Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 873 | ${Q}${INSTALL} -t ${UB_DIR} ${SIGNING_SCRIPTS} |
Bill Richardson | 6f39615 | 2014-07-15 12:52:19 -0700 | [diff] [blame] | 874 | ${Q}${INSTALL} -t ${VB_DIR} ${SIGNING_SCRIPTS_DEV} |
| 875 | ${Q}${INSTALL} -t ${VB_DIR} -m 'u=rw,go=r,a-s' ${SIGNING_COMMON} |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 876 | |
| 877 | # ---------------------------------------------------------------------------- |
| 878 | # new Firmware Utility |
| 879 | |
| 880 | .PHONY: futil |
Bill Richardson | 6db8c75 | 2013-04-05 13:30:43 -0700 | [diff] [blame] | 881 | futil: ${FUTIL_STATIC_BIN} ${FUTIL_BIN} |
| 882 | |
Bill Richardson | 0f6679e | 2014-07-10 15:49:52 -0700 | [diff] [blame] | 883 | ${FUTIL_STATIC_BIN}: ${FUTIL_LDS} ${FUTIL_STATIC_OBJS} ${UTILLIB} |
Bill Richardson | 6db8c75 | 2013-04-05 13:30:43 -0700 | [diff] [blame] | 884 | @$(PRINTF) " LD $(subst ${BUILD}/,,$@)\n" |
| 885 | ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} -static $^ ${LDLIBS} |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 886 | |
Bill Richardson | b84b81d | 2014-07-14 14:48:31 -0700 | [diff] [blame] | 887 | ${FUTIL_BIN}: LDLIBS += ${CRYPTO_LIBS} |
Bill Richardson | 0f6679e | 2014-07-10 15:49:52 -0700 | [diff] [blame] | 888 | ${FUTIL_BIN}: ${FUTIL_LDS} ${FUTIL_OBJS} ${UTILLIB} |
Simon Glass | 661ae9e | 2013-03-26 11:39:21 -0700 | [diff] [blame] | 889 | @$(PRINTF) " LD $(subst ${BUILD}/,,$@)\n" |
Bill Richardson | 6db8c75 | 2013-04-05 13:30:43 -0700 | [diff] [blame] | 890 | ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS} |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 891 | |
| 892 | .PHONY: futil_install |
| 893 | futil_install: ${FUTIL_BIN} |
Simon Glass | 661ae9e | 2013-03-26 11:39:21 -0700 | [diff] [blame] | 894 | @$(PRINTF) " INSTALL futility\n" |
Bill Richardson | 6f39615 | 2014-07-15 12:52:19 -0700 | [diff] [blame] | 895 | ${Q}mkdir -p ${UB_DIR} |
| 896 | ${Q}${INSTALL} -t ${UB_DIR} ${FUTIL_BIN} ${FUTIL_STATIC_BIN} |
| 897 | ${Q}for prog in ${FUTIL_BUILTIN}; do \ |
| 898 | ln -sf futility "${UB_DIR}/$$prog"; done |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 899 | |
| 900 | # ---------------------------------------------------------------------------- |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 901 | # Utility to generate TLCL structure definition header file. |
| 902 | |
| 903 | ${BUILD}/utility/tlcl_generator: CFLAGS += -fpack-struct |
| 904 | |
| 905 | STRUCTURES_TMP=${BUILD}/tlcl_structures.tmp |
| 906 | STRUCTURES_SRC=firmware/lib/tpm_lite/include/tlcl_structures.h |
| 907 | |
| 908 | .PHONY: update_tlcl_structures |
| 909 | update_tlcl_structures: ${BUILD}/utility/tlcl_generator |
Simon Glass | 661ae9e | 2013-03-26 11:39:21 -0700 | [diff] [blame] | 910 | @$(PRINTF) " Rebuilding TLCL structures\n" |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 911 | ${Q}${BUILD}/utility/tlcl_generator > ${STRUCTURES_TMP} |
| 912 | ${Q}cmp -s ${STRUCTURES_TMP} ${STRUCTURES_SRC} || \ |
| 913 | ( echo "%% Updating structures.h %%" && \ |
| 914 | cp ${STRUCTURES_TMP} ${STRUCTURES_SRC} ) |
| 915 | |
| 916 | # ---------------------------------------------------------------------------- |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 917 | # Tests |
| 918 | |
| 919 | .PHONY: tests |
| 920 | tests: ${TEST_BINS} |
| 921 | |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 922 | ${TEST_BINS}: ${UTILLIB} ${TESTLIB} |
Bill Richardson | 339f7e0 | 2013-04-05 09:49:24 -0700 | [diff] [blame] | 923 | ${TEST_BINS}: INCLUDES += -Itests |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 924 | ${TEST_BINS}: LIBS = ${UTILLIB} ${TESTLIB} |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 925 | |
| 926 | ${TESTLIB}: ${TESTLIB_OBJS} |
Simon Glass | 661ae9e | 2013-03-26 11:39:21 -0700 | [diff] [blame] | 927 | @$(PRINTF) " RM $(subst ${BUILD}/,,$@)\n" |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 928 | ${Q}rm -f $@ |
Simon Glass | 661ae9e | 2013-03-26 11:39:21 -0700 | [diff] [blame] | 929 | @$(PRINTF) " AR $(subst ${BUILD}/,,$@)\n" |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 930 | ${Q}ar qc $@ $^ |
| 931 | |
| 932 | |
| 933 | # ---------------------------------------------------------------------------- |
| 934 | # Generic build rules. LIBS and OBJS can be overridden to tweak the generic |
| 935 | # rules for specific targets. |
| 936 | |
| 937 | ${BUILD}/%: ${BUILD}/%.o ${OBJS} ${LIBS} |
Simon Glass | 661ae9e | 2013-03-26 11:39:21 -0700 | [diff] [blame] | 938 | @$(PRINTF) " LD $(subst ${BUILD}/,,$@)\n" |
Bill Richardson | 6db8c75 | 2013-04-05 13:30:43 -0700 | [diff] [blame] | 939 | ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $< ${OBJS} ${LIBS} ${LDLIBS} |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 940 | |
| 941 | ${BUILD}/%.o: %.c |
Simon Glass | 661ae9e | 2013-03-26 11:39:21 -0700 | [diff] [blame] | 942 | @$(PRINTF) " CC $(subst ${BUILD}/,,$@)\n" |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 943 | ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $< |
| 944 | |
| 945 | # Rules to recompile a single source file for library and test |
| 946 | # TODO: is there a tidier way to do this? |
| 947 | ${BUILD}/%_for_lib.o: CFLAGS += -DFOR_LIBRARY |
| 948 | ${BUILD}/%_for_lib.o: %.c |
Simon Glass | 661ae9e | 2013-03-26 11:39:21 -0700 | [diff] [blame] | 949 | @$(PRINTF) " CC-for-lib $(subst ${BUILD}/,,$@)\n" |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 950 | ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $< |
| 951 | |
| 952 | ${BUILD}/%_for_test.o: CFLAGS += -DFOR_TEST |
| 953 | ${BUILD}/%_for_test.o: %.c |
Simon Glass | 661ae9e | 2013-03-26 11:39:21 -0700 | [diff] [blame] | 954 | @$(PRINTF) " CC-for-test $(subst ${BUILD}/,,$@)\n" |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 955 | ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $< |
| 956 | |
| 957 | # TODO: C++ files don't belong in vboot reference at all. Convert to C. |
| 958 | ${BUILD}/%.o: %.cc |
Simon Glass | 661ae9e | 2013-03-26 11:39:21 -0700 | [diff] [blame] | 959 | @$(PRINTF) " CXX $(subst ${BUILD}/,,$@)\n" |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 960 | ${Q}${CXX} ${CFLAGS} ${INCLUDES} -c -o $@ $< |
| 961 | |
| 962 | # ---------------------------------------------------------------------------- |
| 963 | # Here are the special tweaks to the generic rules. |
| 964 | |
Bill Richardson | feb2518 | 2013-03-07 12:54:29 -0800 | [diff] [blame] | 965 | # Because we play some clever linker script games to add new commands without |
| 966 | # changing any header files, futility must be linked with ld.bfd, not gold. |
| 967 | ${FUTIL_BIN}: LDFLAGS += -fuse-ld=bfd |
Bill Richardson | 6db8c75 | 2013-04-05 13:30:43 -0700 | [diff] [blame] | 968 | ${FUTIL_STATIC_BIN}: LDFLAGS += -fuse-ld=bfd |
Bill Richardson | feb2518 | 2013-03-07 12:54:29 -0800 | [diff] [blame] | 969 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 970 | # Some utilities need external crypto functions |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 971 | CRYPTO_LIBS := $(shell ${PKG_CONFIG} --libs libcrypto) |
| 972 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 973 | ${BUILD}/utility/dumpRSAPublicKey: LDLIBS += ${CRYPTO_LIBS} |
| 974 | ${BUILD}/utility/pad_digest_utility: LDLIBS += ${CRYPTO_LIBS} |
| 975 | ${BUILD}/utility/signature_digest_utility: LDLIBS += ${CRYPTO_LIBS} |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 976 | |
| 977 | ${BUILD}/host/linktest/main: LDLIBS += ${CRYPTO_LIBS} |
Randall Spangler | 7141d73 | 2014-05-15 15:34:54 -0700 | [diff] [blame] | 978 | ${BUILD}/tests/vb2_common2_tests: LDLIBS += ${CRYPTO_LIBS} |
| 979 | ${BUILD}/tests/vb2_common3_tests: LDLIBS += ${CRYPTO_LIBS} |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 980 | ${BUILD}/tests/vboot_common2_tests: LDLIBS += ${CRYPTO_LIBS} |
| 981 | ${BUILD}/tests/vboot_common3_tests: LDLIBS += ${CRYPTO_LIBS} |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 982 | |
Bill Richardson | 18e0370 | 2014-06-23 17:48:33 -0700 | [diff] [blame] | 983 | ${BUILD}/tests/cgptlib_test: OBJS += \ |
| 984 | ${BUILD}/firmware/lib/cgptlib/mtdlib_unused.o |
| 985 | ${BUILD}/tests/cgptlib_test: ${BUILD}/firmware/lib/cgptlib/mtdlib_unused.o |
| 986 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 987 | ${BUILD}/utility/bmpblk_utility: LD = ${CXX} |
| 988 | ${BUILD}/utility/bmpblk_utility: LDLIBS = -llzma -lyaml |
| 989 | |
| 990 | BMPBLK_UTILITY_DEPS = \ |
| 991 | ${BUILD}/utility/bmpblk_util.o \ |
| 992 | ${BUILD}/utility/image_types.o \ |
| 993 | ${BUILD}/utility/eficompress_for_lib.o \ |
| 994 | ${BUILD}/utility/efidecompress_for_lib.o |
Bill Richardson | 1912bba | 2013-04-04 21:08:50 -0700 | [diff] [blame] | 995 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 996 | ${BUILD}/utility/bmpblk_utility: OBJS = ${BMPBLK_UTILITY_DEPS} |
| 997 | ${BUILD}/utility/bmpblk_utility: ${BMPBLK_UTILITY_DEPS} |
Bill Richardson | 1912bba | 2013-04-04 21:08:50 -0700 | [diff] [blame] | 998 | ALL_OBJS += ${BMPBLK_UTILITY_DEPS} |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 999 | |
| 1000 | ${BUILD}/utility/bmpblk_font: OBJS += ${BUILD}/utility/image_types.o |
| 1001 | ${BUILD}/utility/bmpblk_font: ${BUILD}/utility/image_types.o |
Bill Richardson | 1912bba | 2013-04-04 21:08:50 -0700 | [diff] [blame] | 1002 | ALL_OBJS += ${BUILD}/utility/image_types.o |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1003 | |
| 1004 | # Allow multiple definitions, so tests can mock functions from other libraries |
| 1005 | ${BUILD}/tests/%: CFLAGS += -Xlinker --allow-multiple-definition |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1006 | ${BUILD}/tests/%: LDLIBS += -lrt -luuid |
| 1007 | ${BUILD}/tests/%: LIBS += ${TESTLIB} |
| 1008 | |
| 1009 | ${BUILD}/tests/rollback_index2_tests: OBJS += \ |
| 1010 | ${BUILD}/firmware/lib/rollback_index_for_test.o |
| 1011 | ${BUILD}/tests/rollback_index2_tests: \ |
| 1012 | ${BUILD}/firmware/lib/rollback_index_for_test.o |
Bill Richardson | 1912bba | 2013-04-04 21:08:50 -0700 | [diff] [blame] | 1013 | ALL_OBJS += ${BUILD}/firmware/lib/rollback_index_for_test.o |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1014 | |
Randall Spangler | c3d488d | 2013-01-28 16:23:48 -0800 | [diff] [blame] | 1015 | ${BUILD}/tests/tlcl_tests: OBJS += \ |
| 1016 | ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o |
| 1017 | ${BUILD}/tests/tlcl_tests: \ |
| 1018 | ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o |
Bill Richardson | 1912bba | 2013-04-04 21:08:50 -0700 | [diff] [blame] | 1019 | ALL_OBJS += ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o |
Randall Spangler | c3d488d | 2013-01-28 16:23:48 -0800 | [diff] [blame] | 1020 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1021 | ${BUILD}/tests/vboot_audio_tests: OBJS += \ |
| 1022 | ${BUILD}/firmware/lib/vboot_audio_for_test.o |
| 1023 | ${BUILD}/tests/vboot_audio_tests: \ |
| 1024 | ${BUILD}/firmware/lib/vboot_audio_for_test.o |
Bill Richardson | 1912bba | 2013-04-04 21:08:50 -0700 | [diff] [blame] | 1025 | ALL_OBJS += ${BUILD}/firmware/lib/vboot_audio_for_test.o |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1026 | |
Bill Richardson | 339f7e0 | 2013-04-05 09:49:24 -0700 | [diff] [blame] | 1027 | TLCL_TEST_BINS = $(addprefix ${BUILD}/,${TLCL_TEST_NAMES}) |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1028 | ${TLCL_TEST_BINS}: OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o |
| 1029 | ${TLCL_TEST_BINS}: ${BUILD}/tests/tpm_lite/tlcl_tests.o |
Bill Richardson | 1912bba | 2013-04-04 21:08:50 -0700 | [diff] [blame] | 1030 | ALL_OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1031 | |
| 1032 | ############################################################################## |
| 1033 | # Targets that exist just to run tests |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1034 | |
| 1035 | # Frequently-run tests |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1036 | .PHONY: test_targets |
Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 1037 | test_targets:: runcgpttests runmisctests $(if ${VBOOT2},run2tests) |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 1038 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1039 | ifeq (${MINIMAL},) |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 1040 | # Bitmap utility isn't compiled for minimal variant |
Bill Richardson | feb2518 | 2013-03-07 12:54:29 -0800 | [diff] [blame] | 1041 | test_targets:: runbmptests runfutiltests |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 1042 | # Scripts don't work under qemu testing |
| 1043 | # TODO: convert scripts to makefile so they can be called directly |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1044 | test_targets:: runtestscripts |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 1045 | endif |
| 1046 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1047 | .PHONY: test_setup |
Bill Richardson | 3e3790d | 2014-07-14 15:05:54 -0700 | [diff] [blame] | 1048 | test_setup:: cgpt utils futil tests install_for_test |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1049 | |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 1050 | # Qemu setup for cross-compiled tests. Need to copy qemu binary into the |
| 1051 | # sysroot. |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1052 | ifneq (${QEMU_ARCH},) |
| 1053 | test_setup:: qemu_install |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 1054 | |
| 1055 | .PHONY: qemu_install |
| 1056 | qemu_install: |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1057 | ifeq (${SYSROOT},) |
| 1058 | $(error SYSROOT must be set to the top of the target-specific root \ |
| 1059 | when cross-compiling for qemu-based tests to run properly.) |
| 1060 | endif |
Simon Glass | 661ae9e | 2013-03-26 11:39:21 -0700 | [diff] [blame] | 1061 | @$(PRINTF) " Copying qemu binary.\n" |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1062 | ${Q}cp -fu /usr/bin/${QEMU_BIN} ${BUILD}/${QEMU_BIN} |
| 1063 | ${Q}chmod a+rx ${BUILD}/${QEMU_BIN} |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 1064 | endif |
| 1065 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 1066 | .PHONY: runtests |
Bill Richardson | a130e0b | 2013-04-04 18:16:39 -0700 | [diff] [blame] | 1067 | runtests: test_setup test_targets |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1068 | |
| 1069 | # Generate test keys |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 1070 | .PHONY: genkeys |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 1071 | genkeys: utils |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1072 | tests/gen_test_keys.sh |
| 1073 | |
| 1074 | # Generate test cases for fuzzing |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 1075 | .PHONY: genfuzztestcases |
Randall Spangler | a808dc9 | 2013-01-14 12:59:05 -0800 | [diff] [blame] | 1076 | genfuzztestcases: utils |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1077 | tests/gen_fuzz_test_cases.sh |
| 1078 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 1079 | .PHONY: runbmptests |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1080 | runbmptests: test_setup |
| 1081 | cd tests/bitmaps && BMPBLK=${BUILD_RUN}/utility/bmpblk_utility \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1082 | ./TestBmpBlock.py -v |
| 1083 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 1084 | .PHONY: runcgpttests |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1085 | runcgpttests: test_setup |
| 1086 | ${RUNTEST} ${BUILD_RUN}/tests/cgptlib_test |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1087 | |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 1088 | .PHONY: runtestscripts |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1089 | runtestscripts: test_setup genfuzztestcases |
Randall Spangler | b8ff397 | 2014-08-27 13:34:35 -0700 | [diff] [blame^] | 1090 | tests/load_kernel_tests.sh |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1091 | tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt |
Albert Chaulk | 42c08cb | 2013-04-02 14:38:07 -0700 | [diff] [blame] | 1092 | tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt -N=512,32,1,3 |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1093 | tests/run_preamble_tests.sh |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1094 | tests/run_rsa_tests.sh |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 1095 | tests/run_vbutil_kernel_arg_tests.sh |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1096 | tests/run_vbutil_tests.sh |
Randall Spangler | e166d04 | 2014-05-13 09:24:52 -0700 | [diff] [blame] | 1097 | ifneq (${VBOOT2},) |
| 1098 | tests/vb2_rsa_tests.sh |
Randall Spangler | 539cbc2 | 2014-06-18 14:15:04 -0700 | [diff] [blame] | 1099 | tests/vb2_firmware_tests.sh |
Randall Spangler | e166d04 | 2014-05-13 09:24:52 -0700 | [diff] [blame] | 1100 | endif |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1101 | |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 1102 | .PHONY: runmisctests |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1103 | runmisctests: test_setup |
| 1104 | ${RUNTEST} ${BUILD_RUN}/tests/rollback_index2_tests |
Randall Spangler | a3eac79 | 2013-01-23 13:04:05 -0800 | [diff] [blame] | 1105 | ${RUNTEST} ${BUILD_RUN}/tests/rollback_index3_tests |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1106 | ${RUNTEST} ${BUILD_RUN}/tests/rsa_utility_tests |
| 1107 | ${RUNTEST} ${BUILD_RUN}/tests/sha_tests |
| 1108 | ${RUNTEST} ${BUILD_RUN}/tests/stateful_util_tests |
Randall Spangler | c3d488d | 2013-01-28 16:23:48 -0800 | [diff] [blame] | 1109 | ${RUNTEST} ${BUILD_RUN}/tests/tlcl_tests |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1110 | ${RUNTEST} ${BUILD_RUN}/tests/tpm_bootmode_tests |
| 1111 | ${RUNTEST} ${BUILD_RUN}/tests/utility_string_tests |
| 1112 | ${RUNTEST} ${BUILD_RUN}/tests/utility_tests |
| 1113 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_devmode_tests |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1114 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_firmware_tests |
Randall Spangler | 0714d9d | 2013-02-05 10:23:38 -0800 | [diff] [blame] | 1115 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_init_tests |
| 1116 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel_tests |
Randall Spangler | 7f43669 | 2013-02-05 12:42:36 -0800 | [diff] [blame] | 1117 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel2_tests |
| 1118 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel3_tests |
| 1119 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel4_tests |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1120 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_audio_tests |
Randall Spangler | e061a25 | 2013-01-22 15:34:07 -0800 | [diff] [blame] | 1121 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_common_tests |
| 1122 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS} |
| 1123 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS} |
Randall Spangler | 786a5dc | 2013-01-24 14:19:56 -0800 | [diff] [blame] | 1124 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_display_tests |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1125 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_firmware_tests |
Randall Spangler | 49cb0d3 | 2013-01-29 14:28:16 -0800 | [diff] [blame] | 1126 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_kernel_tests |
Randall Spangler | 6dbf9d9 | 2013-01-23 12:25:10 -0800 | [diff] [blame] | 1127 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_nvstorage_test |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1128 | |
Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 1129 | .PHONY: run2tests |
| 1130 | run2tests: test_setup |
Randall Spangler | a7ab8b5 | 2014-06-10 17:05:08 -0700 | [diff] [blame] | 1131 | ${RUNTEST} ${BUILD_RUN}/tests/vb2_api_tests |
Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 1132 | ${RUNTEST} ${BUILD_RUN}/tests/vb2_common_tests |
Randall Spangler | 7141d73 | 2014-05-15 15:34:54 -0700 | [diff] [blame] | 1133 | ${RUNTEST} ${BUILD_RUN}/tests/vb2_common2_tests ${TEST_KEYS} |
| 1134 | ${RUNTEST} ${BUILD_RUN}/tests/vb2_common3_tests ${TEST_KEYS} |
Randall Spangler | 3333e57 | 2014-05-14 11:37:52 -0700 | [diff] [blame] | 1135 | ${RUNTEST} ${BUILD_RUN}/tests/vb2_misc_tests |
Randall Spangler | 1803068 | 2014-06-11 16:01:08 -0700 | [diff] [blame] | 1136 | ${RUNTEST} ${BUILD_RUN}/tests/vb2_misc2_tests |
Randall Spangler | 3333e57 | 2014-05-14 11:37:52 -0700 | [diff] [blame] | 1137 | ${RUNTEST} ${BUILD_RUN}/tests/vb2_nvstorage_tests |
Randall Spangler | e166d04 | 2014-05-13 09:24:52 -0700 | [diff] [blame] | 1138 | ${RUNTEST} ${BUILD_RUN}/tests/vb2_rsa_utility_tests |
Randall Spangler | 3333e57 | 2014-05-14 11:37:52 -0700 | [diff] [blame] | 1139 | ${RUNTEST} ${BUILD_RUN}/tests/vb2_secdata_tests |
Randall Spangler | e166d04 | 2014-05-13 09:24:52 -0700 | [diff] [blame] | 1140 | ${RUNTEST} ${BUILD_RUN}/tests/vb2_sha_tests |
Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 1141 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1142 | .PHONY: runfutiltests |
Bill Richardson | 3e3790d | 2014-07-14 15:05:54 -0700 | [diff] [blame] | 1143 | runfutiltests: test_setup |
| 1144 | tests/futility/run_test_scripts.sh ${TEST_INSTALL_DIR} |
Bill Richardson | 339f7e0 | 2013-04-05 09:49:24 -0700 | [diff] [blame] | 1145 | ${RUNTEST} ${BUILD_RUN}/tests/futility/test_not_really |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 1146 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1147 | # Run long tests, including all permutations of encryption keys (instead of |
Randall Spangler | 786a5dc | 2013-01-24 14:19:56 -0800 | [diff] [blame] | 1148 | # just the ones we use) and tests of currently-unused code. |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1149 | # Not run by automated build. |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 1150 | .PHONY: runlongtests |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1151 | runlongtests: test_setup genkeys genfuzztestcases |
Randall Spangler | e061a25 | 2013-01-22 15:34:07 -0800 | [diff] [blame] | 1152 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS} --all |
| 1153 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS} --all |
Randall Spangler | 7141d73 | 2014-05-15 15:34:54 -0700 | [diff] [blame] | 1154 | ifneq (${VBOOT2},) |
| 1155 | ${RUNTEST} ${BUILD_RUN}/tests/vb2_common2_tests ${TEST_KEYS} --all |
| 1156 | ${RUNTEST} ${BUILD_RUN}/tests/vb2_common3_tests ${TEST_KEYS} --all |
| 1157 | endif |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1158 | tests/run_preamble_tests.sh --all |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1159 | tests/run_vbutil_tests.sh --all |
| 1160 | |
Bill Richardson | 78d59bf | 2014-08-27 16:17:04 -0700 | [diff] [blame] | 1161 | # TODO: There were a number of ancient tests that hadn't been run in years. |
| 1162 | # They were removed with https://chromium-review.googlesource.com/#/c/214610/ |
| 1163 | # Some day it might be nice to see what they were supposed to do. |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1164 | |
Bill Richardson | 7829902 | 2014-06-20 14:33:00 -0700 | [diff] [blame] | 1165 | .PHONY: runalltests |
| 1166 | runalltests: runtests runfutiltests runlongtests |
| 1167 | |
Randall Spangler | 59d7508 | 2013-01-23 09:29:54 -0800 | [diff] [blame] | 1168 | # Code coverage |
| 1169 | .PHONY: coverage_init |
| 1170 | coverage_init: test_setup |
| 1171 | rm -f ${COV_INFO}* |
| 1172 | lcov -c -i -d . -b . -o ${COV_INFO}.initial |
| 1173 | |
| 1174 | .PHONY: coverage_html |
| 1175 | coverage_html: |
| 1176 | lcov -c -d . -b . -o ${COV_INFO}.tests |
| 1177 | lcov -a ${COV_INFO}.initial -a ${COV_INFO}.tests -o ${COV_INFO}.total |
| 1178 | lcov -r ${COV_INFO}.total '/usr/*' '*/linktest/*' -o ${COV_INFO}.local |
| 1179 | genhtml ${COV_INFO}.local -o ${BUILD}/coverage |
Bill Richardson | d2d08b2 | 2014-07-08 16:31:40 -0700 | [diff] [blame] | 1180 | # Generate addtional coverage stats just for firmware subdir, because the stats |
| 1181 | # for the whole project don't include subdirectory summaries. This will print |
| 1182 | # the summary for just the firmware sources. |
Randall Spangler | 49cb0d3 | 2013-01-29 14:28:16 -0800 | [diff] [blame] | 1183 | lcov -r ${COV_INFO}.local '*/stub/*' -o ${COV_INFO}.nostub |
| 1184 | lcov -e ${COV_INFO}.nostub '${SRCDIR}/firmware/*' \ |
Randall Spangler | 59d7508 | 2013-01-23 09:29:54 -0800 | [diff] [blame] | 1185 | -o ${COV_INFO}.firmware |
| 1186 | |
| 1187 | .PHONY: coverage |
| 1188 | ifeq (${COV},) |
| 1189 | coverage: |
| 1190 | $(error Build coverage like this: make clean && COV=1 make) |
| 1191 | else |
| 1192 | coverage: coverage_init runtests coverage_html |
| 1193 | endif |
Bill Richardson | 1912bba | 2013-04-04 21:08:50 -0700 | [diff] [blame] | 1194 | |
| 1195 | # Include generated dependencies |
| 1196 | ALL_DEPS += ${ALL_OBJS:%.o=%.o.d} |
| 1197 | -include ${ALL_DEPS} |