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