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