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 | |
| 188 | # Some things only compile inside the Chromium OS chroot. |
| 189 | # TODO: Those things should be in their own repo, not part of vboot_reference |
| 190 | # TODO: Is there a better way to detect this? |
| 191 | ifneq (${CROS_WORKON_SRCROOT},) |
| 192 | IN_CHROOT := yes |
| 193 | endif |
| 194 | |
| 195 | # TODO: Move to separate repo. |
| 196 | ifneq (${IN_CHROOT},) |
| 197 | PC_BASE_VER ?= 125070 |
| 198 | PC_DEPS := libchrome-${PC_BASE_VER} |
| 199 | PC_CFLAGS := $(shell ${PKG_CONFIG} --cflags ${PC_DEPS}) |
| 200 | PC_LDLIBS := $(shell ${PKG_CONFIG} --libs ${PC_DEPS}) |
| 201 | endif |
| 202 | |
| 203 | |
| 204 | ############################################################################## |
| 205 | # Now we need to describe everything we might want or need to build |
| 206 | |
| 207 | # TODO: This should go in its own repo. |
| 208 | AU_CGPTLIB = ${BUILD}/cgpt/libcgpt-cc.a |
| 209 | # This is just ... Gah. There's no good place for it. |
| 210 | DUMPKERNELCONFIGLIB = ${BUILD}/libdump_kernel_config.a |
| 211 | |
| 212 | # Everything wants these headers. |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 213 | INCLUDES += \ |
| 214 | -Ifirmware/include \ |
| 215 | -Ifirmware/lib/include \ |
| 216 | -Ifirmware/lib/cgptlib/include \ |
| 217 | -Ifirmware/lib/cryptolib/include \ |
| 218 | -Ifirmware/lib/tpm_lite/include |
Bill Richardson | 0b8f35c | 2010-05-26 09:18:38 -0700 | [diff] [blame] | 219 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 220 | # If we're not building for a specific target, just stub out things like the |
| 221 | # TPM commands and various external functions that are provided by the BIOS. |
| 222 | ifeq (${FIRMWARE_ARCH},) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 223 | INCLUDES += -Ifirmware/stub/include |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 224 | else |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 225 | INCLUDES += -Ifirmware/arch/${FIRMWARE_ARCH}/include |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 226 | endif |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 227 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 228 | # Firmware library. TODO: Do we still need to export this? |
| 229 | FWLIB = ${BUILD}/vboot_fw.a |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 230 | |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame^] | 231 | # Firmware library sources needed by VbInit() call |
| 232 | VBINIT_SRCS = \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 233 | firmware/lib/crc8.c \ |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame^] | 234 | firmware/lib/utility.c \ |
| 235 | firmware/lib/vboot_api_init.c \ |
| 236 | firmware/lib/vboot_common_init.c \ |
| 237 | firmware/lib/vboot_nvstorage.c \ |
| 238 | |
| 239 | # Additional firmware library sources needed by VbSelectFirmware() call |
| 240 | VBSF_SRCS = \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 241 | firmware/lib/cryptolib/padding.c \ |
| 242 | firmware/lib/cryptolib/rsa.c \ |
| 243 | firmware/lib/cryptolib/rsa_utility.c \ |
| 244 | firmware/lib/cryptolib/sha1.c \ |
| 245 | firmware/lib/cryptolib/sha256.c \ |
| 246 | firmware/lib/cryptolib/sha512.c \ |
| 247 | firmware/lib/cryptolib/sha_utility.c \ |
| 248 | firmware/lib/stateful_util.c \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 249 | firmware/lib/vboot_api_firmware.c \ |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame^] | 250 | firmware/lib/vboot_common.c \ |
| 251 | firmware/lib/vboot_firmware.c |
| 252 | |
| 253 | # Additional firmware library sources needed by VbSelectAndLoadKernel() call |
| 254 | VBSLK_SRCS = \ |
| 255 | firmware/lib/cgptlib/cgptlib.c \ |
| 256 | firmware/lib/cgptlib/cgptlib_internal.c \ |
| 257 | firmware/lib/cgptlib/crc32.c \ |
| 258 | firmware/lib/utility_string.c \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 259 | firmware/lib/vboot_api_kernel.c \ |
| 260 | firmware/lib/vboot_audio.c \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 261 | firmware/lib/vboot_display.c \ |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame^] | 262 | firmware/lib/vboot_kernel.c |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 263 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 264 | # Support real TPM unless BIOS sets MOCK_TPM |
| 265 | ifeq (${MOCK_TPM},) |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame^] | 266 | VBINIT_SRCS += \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 267 | firmware/lib/rollback_index.c \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 268 | firmware/lib/tpm_lite/tlcl.c |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame^] | 269 | |
| 270 | VBSF_SRCS += \ |
| 271 | firmware/lib/tpm_bootmode.c |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 272 | else |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame^] | 273 | VBINIT_SRCS += \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 274 | firmware/lib/mocked_rollback_index.c \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 275 | firmware/lib/tpm_lite/mocked_tlcl.c |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame^] | 276 | |
| 277 | VBSF_SRCS += \ |
| 278 | firmware/lib/mocked_tpm_bootmode.c |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 279 | endif |
| 280 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 281 | ifeq (${FIRMWARE_ARCH},) |
| 282 | # Include BIOS stubs in the firmware library when compiling for host |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame^] | 283 | # TODO: split out other stub funcs too |
| 284 | VBINIT_SRCS += \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 285 | firmware/stub/tpm_lite_stub.c \ |
| 286 | firmware/stub/utility_stub.c \ |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame^] | 287 | firmware/stub/vboot_api_stub_init.c |
| 288 | |
| 289 | VBSF_SRCS += \ |
| 290 | firmware/stub/vboot_api_stub_sf.c |
| 291 | |
| 292 | VBSLK_SRCS += \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 293 | firmware/stub/vboot_api_stub.c \ |
| 294 | firmware/stub/vboot_api_stub_disk.c |
| 295 | endif |
| 296 | |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame^] | 297 | VBSF_SRCS += ${VBINIT_SRCS} |
| 298 | FWLIB_SRCS += ${VBSF_SRCS} ${VBSLK_SRCS} |
| 299 | |
| 300 | VBINIT_OBJS = ${VBINIT_SRCS:%.c=${BUILD}/%.o} |
| 301 | VBSF_OBJS = ${VBSF_SRCS:%.c=${BUILD}/%.o} |
| 302 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 303 | FWLIB_OBJS = ${FWLIB_SRCS:%.c=${BUILD}/%.o} |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 304 | ALL_OBJS += ${FWLIB_OBJS} |
| 305 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 306 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 307 | # Library to build the utilities. "HOST" mostly means "userspace". |
| 308 | HOSTLIB = ${BUILD}/vboot_host.a |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 309 | |
| 310 | HOSTLIB_SRCS = \ |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 311 | host/arch/${ARCH}/lib/crossystem_arch.c \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 312 | host/lib/crossystem.c \ |
| 313 | host/lib/file_keys.c \ |
| 314 | host/lib/fmap.c \ |
| 315 | host/lib/host_common.c \ |
| 316 | host/lib/host_key.c \ |
| 317 | host/lib/host_keyblock.c \ |
| 318 | host/lib/host_misc.c \ |
| 319 | host/lib/host_signature.c \ |
| 320 | host/lib/signature_digest.c |
| 321 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 322 | HOSTLIB_OBJS = ${HOSTLIB_SRCS:%.c=${BUILD}/%.o} |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 323 | ALL_OBJS += ${HOSTLIB_OBJS} |
| 324 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 325 | # Link with hostlib by default |
| 326 | LIBS = $(HOSTLIB) |
| 327 | |
| 328 | # Might need this too. |
| 329 | CRYPTO_LIBS := $(shell ${PKG_CONFIG} --libs libcrypto) |
| 330 | |
| 331 | |
| 332 | # ---------------------------------------------------------------------------- |
| 333 | # Now for the userspace binaries |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 334 | |
| 335 | CGPT = ${BUILD}/cgpt/cgpt |
| 336 | |
| 337 | CGPT_SRCS = \ |
| 338 | cgpt/cgpt.c \ |
| 339 | cgpt/cgpt_add.c \ |
| 340 | cgpt/cgpt_boot.c \ |
| 341 | cgpt/cgpt_common.c \ |
| 342 | cgpt/cgpt_create.c \ |
| 343 | cgpt/cgpt_find.c \ |
| 344 | cgpt/cgpt_legacy.c \ |
| 345 | cgpt/cgpt_prioritize.c \ |
| 346 | cgpt/cgpt_repair.c \ |
| 347 | cgpt/cgpt_show.c \ |
| 348 | cgpt/cmd_add.c \ |
| 349 | cgpt/cmd_boot.c \ |
| 350 | cgpt/cmd_create.c \ |
| 351 | cgpt/cmd_find.c \ |
| 352 | cgpt/cmd_legacy.c \ |
| 353 | cgpt/cmd_prioritize.c \ |
| 354 | cgpt/cmd_repair.c \ |
| 355 | cgpt/cmd_show.c |
| 356 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 357 | CGPT_OBJS = ${CGPT_SRCS:%.c=${BUILD}/%.o} |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 358 | ALL_OBJS += ${CGPT_OBJS} |
| 359 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 360 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 361 | # Scripts to install directly (not compiled) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 362 | UTIL_SCRIPTS = \ |
| 363 | utility/dev_debug_vboot \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 364 | utility/enable_dev_usb_boot \ |
| 365 | utility/vbutil_what_keys |
| 366 | |
Bill Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 367 | ifeq (${MINIMAL},) |
| 368 | UTIL_SCRIPTS += \ |
| 369 | utility/dev_make_keypair |
| 370 | endif |
| 371 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 372 | # These utilities should be linked statically. |
| 373 | UTIL_NAMES_STATIC = \ |
| 374 | crossystem \ |
| 375 | dump_fmap \ |
| 376 | gbb_utility |
| 377 | |
| 378 | UTIL_NAMES = ${UTIL_NAMES_STATIC} \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 379 | dev_sign_file \ |
| 380 | dump_kernel_config \ |
| 381 | dumpRSAPublicKey \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 382 | tpm_init_temp_fix \ |
| 383 | tpmc \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 384 | vbutil_firmware \ |
| 385 | vbutil_kernel \ |
| 386 | vbutil_key \ |
| 387 | vbutil_keyblock \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 388 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 389 | ifeq (${MINIMAL},) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 390 | UTIL_NAMES += \ |
| 391 | bmpblk_font \ |
| 392 | bmpblk_utility \ |
| 393 | eficompress \ |
Bill Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 394 | efidecompress \ |
| 395 | load_kernel_test \ |
| 396 | pad_digest_utility \ |
| 397 | signature_digest_utility \ |
| 398 | verify_data |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 399 | endif |
| 400 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 401 | UTIL_BINS_STATIC := $(addprefix ${BUILD}/utility/,${UTIL_NAMES_STATIC}) |
| 402 | UTIL_BINS = $(addprefix ${BUILD}/utility/,${UTIL_NAMES}) |
Bill Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 403 | ifneq (${IN_CHROOT},) |
| 404 | UTIL_SBINS = $(addprefix ${BUILD}/utility/,mount-encrypted) |
| 405 | endif |
| 406 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 407 | ALL_DEPS += $(addsuffix .d,${UTIL_BINS}) |
| 408 | |
Bill Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 409 | |
| 410 | # Scripts for signing stuff. |
| 411 | SIGNING_SCRIPTS = \ |
| 412 | utility/tpm-nvsize \ |
| 413 | utility/chromeos-tpm-recovery |
| 414 | |
| 415 | # These go in a different place. |
| 416 | SIGNING_SCRIPTS_DEV = \ |
| 417 | scripts/image_signing/resign_firmwarefd.sh \ |
| 418 | scripts/image_signing/make_dev_firmware.sh \ |
| 419 | scripts/image_signing/make_dev_ssd.sh \ |
| 420 | scripts/image_signing/set_gbb_flags.sh |
| 421 | |
| 422 | # Installed, but not made executable. |
| 423 | SIGNING_COMMON = scripts/image_signing/common_minimal.sh |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 424 | |
Bill Richardson | 826db09 | 2013-01-14 12:37:15 -0800 | [diff] [blame] | 425 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 426 | # The unified firmware utility will eventually replace all the others |
| 427 | FUTIL_BIN = ${BUILD}/futility/futility |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 428 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 429 | FUTIL_SRCS = \ |
| 430 | futility/IGNOREME.c |
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_LDS = futility/futility.lds |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 433 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 434 | FUTIL_OBJS = ${FUTIL_SRCS:%.c=${BUILD}/%.o} |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 435 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 436 | ALL_DEPS += $(addsuffix .d,${FUTIL_BIN}) |
| 437 | ALL_OBJS += ${FUTIL_OBJS} |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 438 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 439 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 440 | # Library of handy test functions. |
| 441 | TESTLIB = ${BUILD}/tests/test.a |
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 | TESTLIB_SRCS = \ |
| 444 | tests/test_common.c \ |
| 445 | tests/timer_utils.c \ |
| 446 | tests/crc32_test.c |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 447 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 448 | TESTLIB_OBJS = ${TESTLIB_SRCS:%.c=${BUILD}/%.o} |
| 449 | ALL_OBJS += ${TESTLIB_OBJS} |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 450 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 451 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 452 | # And some compiled tests. |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 453 | TEST_NAMES = \ |
| 454 | cgptlib_test \ |
| 455 | rollback_index2_tests \ |
Randall Spangler | a3eac79 | 2013-01-23 13:04:05 -0800 | [diff] [blame] | 456 | rollback_index3_tests \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 457 | rsa_padding_test \ |
| 458 | rsa_utility_tests \ |
| 459 | rsa_verify_benchmark \ |
| 460 | sha_benchmark \ |
| 461 | sha_tests \ |
| 462 | stateful_util_tests \ |
Randall Spangler | c3d488d | 2013-01-28 16:23:48 -0800 | [diff] [blame] | 463 | tlcl_tests \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 464 | tpm_bootmode_tests \ |
| 465 | utility_string_tests \ |
| 466 | utility_tests \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 467 | vboot_api_init_tests \ |
| 468 | vboot_api_devmode_tests \ |
| 469 | vboot_api_firmware_tests \ |
| 470 | vboot_api_kernel_tests \ |
Randall Spangler | 7f43669 | 2013-02-05 12:42:36 -0800 | [diff] [blame] | 471 | vboot_api_kernel2_tests \ |
| 472 | vboot_api_kernel3_tests \ |
| 473 | vboot_api_kernel4_tests \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 474 | vboot_audio_tests \ |
| 475 | vboot_common_tests \ |
| 476 | vboot_common2_tests \ |
| 477 | vboot_common3_tests \ |
Randall Spangler | 786a5dc | 2013-01-24 14:19:56 -0800 | [diff] [blame] | 478 | vboot_display_tests \ |
Randall Spangler | 6dbf9d9 | 2013-01-23 12:25:10 -0800 | [diff] [blame] | 479 | vboot_firmware_tests \ |
Randall Spangler | 49cb0d3 | 2013-01-29 14:28:16 -0800 | [diff] [blame] | 480 | vboot_kernel_tests \ |
Randall Spangler | 6dbf9d9 | 2013-01-23 12:25:10 -0800 | [diff] [blame] | 481 | vboot_nvstorage_test |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 482 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 483 | # Grrr |
| 484 | ifneq (${IN_CHROOT},) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 485 | TEST_NAMES += CgptManagerTests |
| 486 | endif |
| 487 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 488 | # TODO: port these tests to new API, if not already eqivalent |
| 489 | # functionality in other tests. These don't even compile at present. |
| 490 | # |
| 491 | # big_firmware_tests |
| 492 | # big_kernel_tests |
| 493 | # firmware_image_tests |
| 494 | # firmware_rollback_tests |
| 495 | # firmware_splicing_tests |
| 496 | # firmware_verify_benchmark |
| 497 | # kernel_image_tests |
| 498 | # kernel_rollback_tests |
| 499 | # kernel_splicing_tests |
| 500 | # kernel_verify_benchmark |
| 501 | # rollback_index_test |
| 502 | # verify_firmware_fuzz_driver |
| 503 | # verify_kernel_fuzz_driver |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 504 | # utility/load_firmware_test |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 505 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 506 | # And a few more... |
| 507 | TLCL_TESTS = \ |
| 508 | tpmtest_earlyextend \ |
| 509 | tpmtest_earlynvram \ |
| 510 | tpmtest_earlynvram2 \ |
| 511 | tpmtest_enable \ |
| 512 | tpmtest_fastenable \ |
| 513 | tpmtest_globallock \ |
| 514 | tpmtest_redefine_unowned \ |
| 515 | tpmtest_spaceperm \ |
| 516 | tpmtest_testsetup \ |
| 517 | tpmtest_timing \ |
| 518 | tpmtest_writelimit |
| 519 | TLCL_TEST_NAMES = $(addprefix tpm_lite/,${TLCL_TESTS}) |
| 520 | TLCL_TEST_BINS = $(addprefix ${BUILD}/tests/,${TLCL_TEST_NAMES}) |
| 521 | |
| 522 | TEST_NAMES += ${TLCL_TEST_NAMES} |
| 523 | |
| 524 | TEST_BINS = $(addprefix ${BUILD}/tests/,${TEST_NAMES}) |
| 525 | ALL_DEPS += $(addsuffix .d,${TEST_BINS}) |
| 526 | |
Randall Spangler | e061a25 | 2013-01-22 15:34:07 -0800 | [diff] [blame] | 527 | # Directory containing test keys |
| 528 | TEST_KEYS = ${SRC_RUN}/tests/testkeys |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 529 | |
| 530 | # ---------------------------------------------------------------------------- |
| 531 | # TODO: why not make this include *all* the cgpt files, and simply have |
| 532 | # cgpt link against it? |
| 533 | # TODO: CgptManager.cc should move to the installer project. Shouldn't be |
| 534 | # in libcgpt-cc.a. |
| 535 | AU_CGPTLIB_SRCS = \ |
| 536 | cgpt/CgptManager.cc \ |
| 537 | cgpt/cgpt_create.c \ |
| 538 | cgpt/cgpt_add.c \ |
| 539 | cgpt/cgpt_boot.c \ |
| 540 | cgpt/cgpt_show.c \ |
| 541 | cgpt/cgpt_repair.c \ |
| 542 | cgpt/cgpt_prioritize.c \ |
| 543 | cgpt/cgpt_common.c \ |
| 544 | firmware/lib/cgptlib/crc32.c \ |
| 545 | firmware/lib/cgptlib/cgptlib_internal.c \ |
| 546 | firmware/stub/utility_stub.c |
| 547 | |
| 548 | AU_CGPTLIB_OBJS = $(filter %.o, \ |
| 549 | ${AU_CGPTLIB_SRCS:%.c=${BUILD}/%.o} \ |
| 550 | ${AU_CGPTLIB_SRCS:%.cc=${BUILD}/%.o}) |
| 551 | ALL_OBJS += ${AU_CGPTLIB_OBJS} |
| 552 | |
| 553 | |
| 554 | ############################################################################## |
| 555 | # Finally, some targets. High-level ones first. |
| 556 | |
| 557 | # Create output directories if necessary. Do this via explicit shell commands |
| 558 | # so it happens before trying to generate/include dependencies. |
| 559 | SUBDIRS := firmware host cgpt utility futility tests tests/tpm_lite |
| 560 | _dir_create := $(foreach d, \ |
| 561 | $(shell find ${SUBDIRS} -name '*.c' -exec dirname {} \; | sort -u), \ |
| 562 | $(shell [ -d ${BUILD}/${d} ] || mkdir -p ${BUILD}/${d})) |
| 563 | |
| 564 | |
| 565 | # Default target. |
| 566 | .PHONY: all |
Randall Spangler | 59d7508 | 2013-01-23 09:29:54 -0800 | [diff] [blame] | 567 | all: fwlib $(if ${FIRMWARE_ARCH},,host_stuff) $(if ${COV},coverage) |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 568 | |
| 569 | # Host targets |
| 570 | .PHONY: host_stuff |
| 571 | host_stuff: hostlib cgpt utils futil tests |
| 572 | |
| 573 | # AU targets |
| 574 | .PHONY: au_stuff |
| 575 | au_stuff: libcgpt_cc libdump_kernel_config cgptmanager_tests |
| 576 | |
| 577 | .PHONY: clean |
| 578 | clean: |
| 579 | ${Q}/bin/rm -rf ${BUILD} |
| 580 | |
| 581 | .PHONY: install |
Bill Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 582 | install: cgpt_install utils_install signing_install futil_install |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 583 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 584 | # Don't delete intermediate object files |
| 585 | .SECONDARY: |
| 586 | |
| 587 | # TODO: I suspect this is missing some object files. Make a temp |
| 588 | # target which cleans all known obj/exe's and see what's left; those |
| 589 | # are the files which need deps. |
| 590 | ALL_DEPS += ${ALL_OBJS:%.o=%.o.d} |
| 591 | -include ${ALL_DEPS} |
| 592 | |
| 593 | # ---------------------------------------------------------------------------- |
| 594 | # Firmware library |
| 595 | |
| 596 | # TPM-specific flags. These depend on the particular TPM we're targeting for. |
| 597 | # They are needed here only for compiling parts of the firmware code into |
| 598 | # user-level tests. |
| 599 | |
| 600 | # TPM_BLOCKING_CONTINUESELFTEST is defined if TPM_ContinueSelfTest blocks until |
| 601 | # the self test has completed. |
| 602 | |
Randall Spangler | 45cc0f2 | 2013-01-25 09:34:26 -0800 | [diff] [blame] | 603 | ${FWLIB_OBJS}: CFLAGS += -DTPM_BLOCKING_CONTINUESELFTEST |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 604 | |
| 605 | # TPM_MANUAL_SELFTEST is defined if the self test must be started manually |
| 606 | # (with a call to TPM_ContinueSelfTest) instead of starting automatically at |
| 607 | # power on. |
| 608 | # |
| 609 | # We sincerely hope that TPM_BLOCKING_CONTINUESELFTEST and TPM_MANUAL_SELFTEST |
| 610 | # are not both defined at the same time. (See comment in code.) |
| 611 | |
| 612 | # CFLAGS += -DTPM_MANUAL_SELFTEST |
| 613 | |
| 614 | ifeq (${FIRMWARE_ARCH},i386) |
| 615 | # Unrolling loops in cryptolib makes it faster |
Randall Spangler | 45cc0f2 | 2013-01-25 09:34:26 -0800 | [diff] [blame] | 616 | ${FWLIB_OBJS}: CFLAGS += -DUNROLL_LOOPS |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 617 | |
| 618 | # Workaround for coreboot on x86, which will power off asynchronously |
| 619 | # without giving us a chance to react. This is not an example of the Right |
| 620 | # Way to do things. See chrome-os-partner:7689, and the commit message |
| 621 | # that made this change. |
Randall Spangler | 45cc0f2 | 2013-01-25 09:34:26 -0800 | [diff] [blame] | 622 | ${FWLIB_OBJS}: CFLAGS += -DSAVE_LOCALE_IMMEDIATELY |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 623 | |
| 624 | # On x86 we don't actually read the GBB data into RAM until it is needed. |
| 625 | # Therefore it makes sense to cache it rather than reading it each time. |
| 626 | # Enable this feature. |
Randall Spangler | 45cc0f2 | 2013-01-25 09:34:26 -0800 | [diff] [blame] | 627 | ${FWLIB_OBJS}: CFLAGS += -DCOPY_BMP_DATA |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 628 | endif |
| 629 | |
| 630 | ifeq (${FIRMWARE_ARCH},) |
| 631 | # Disable rollback TPM when compiling locally, since otherwise |
| 632 | # load_kernel_test attempts to talk to the TPM. |
Randall Spangler | 45cc0f2 | 2013-01-25 09:34:26 -0800 | [diff] [blame] | 633 | ${FWLIB_OBJS}: CFLAGS += -DDISABLE_ROLLBACK_TPM |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 634 | endif |
| 635 | |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame^] | 636 | # Link tests |
| 637 | ${BUILD}/firmware/linktest/main_vbinit: LIBS = |
| 638 | ${BUILD}/firmware/linktest/main_vbinit: OBJS = ${VBINIT_OBJS} |
| 639 | ${BUILD}/firmware/linktest/main_vbsf: LIBS = |
| 640 | ${BUILD}/firmware/linktest/main_vbsf: OBJS = ${VBSF_OBJS} |
| 641 | |
| 642 | .phony: fwlinktest |
| 643 | fwlinktest: ${FWLIB} \ |
| 644 | ${BUILD}/firmware/linktest/main_vbinit \ |
| 645 | ${BUILD}/firmware/linktest/main_vbsf \ |
| 646 | ${BUILD}/firmware/linktest/main |
| 647 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 648 | .PHONY: fwlib |
Randall Spangler | 9394326 | 2013-02-26 11:03:57 -0800 | [diff] [blame^] | 649 | fwlib: ${FWLIB} $(if ${FIRMWARE_ARCH},,fwlinktest) |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 650 | |
| 651 | ${FWLIB}: ${FWLIB_OBJS} |
| 652 | @printf " RM $(subst ${BUILD}/,,$@)\n" |
| 653 | ${Q}rm -f $@ |
| 654 | @printf " AR $(subst ${BUILD}/,,$@)\n" |
| 655 | ${Q}ar qc $@ $^ |
| 656 | |
| 657 | # ---------------------------------------------------------------------------- |
| 658 | # Host library |
| 659 | |
| 660 | .PHONY: hostlib |
| 661 | hostlib: ${HOSTLIB} ${BUILD}/host/linktest/main |
| 662 | |
| 663 | ${BUILD}/host/% ${HOSTLIB}: INCLUDES += \ |
| 664 | -Ihost/include\ |
| 665 | -Ihost/arch/${ARCH}/include |
| 666 | |
| 667 | # TODO: better way to make .a than duplicating this recipe each time? |
| 668 | ${HOSTLIB}: ${HOSTLIB_OBJS} ${FWLIB_OBJS} |
| 669 | @printf " RM $(subst ${BUILD}/,,$@)\n" |
| 670 | ${Q}rm -f $@ |
| 671 | @printf " AR $(subst ${BUILD}/,,$@)\n" |
| 672 | ${Q}ar qc $@ $^ |
| 673 | |
| 674 | # ---------------------------------------------------------------------------- |
| 675 | # CGPT library and utility |
| 676 | |
| 677 | .PHONY: cgpt |
| 678 | cgpt: ${CGPT} |
| 679 | |
| 680 | ${CGPT}: LDFLAGS += -static |
| 681 | ${CGPT}: LDLIBS += -luuid |
| 682 | |
| 683 | ${CGPT}: ${CGPT_OBJS} ${LIBS} |
| 684 | @printf " LDcgpt $(subst ${BUILD}/,,$@)\n" |
| 685 | ${Q}${LD} -o ${CGPT} ${CFLAGS} $^ ${LDFLAGS} ${LDLIBS} |
| 686 | |
| 687 | .PHONY: cgpt_install |
| 688 | cgpt_install: ${CGPT} |
| 689 | @printf " INSTALL CGPT\n" |
Bill Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 690 | ${Q}mkdir -p ${UB_DIR} |
| 691 | ${Q}${INSTALL} -t ${UB_DIR} $^ |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 692 | |
| 693 | # ---------------------------------------------------------------------------- |
| 694 | # Utilities |
| 695 | |
| 696 | # These have their own headers too. |
| 697 | ${BUILD}/utility/%: INCLUDES += -Ihost/include -Iutility/include |
| 698 | |
| 699 | # Utilities for auto-update toolkits must be statically linked. |
| 700 | ${UTIL_BINS_STATIC}: LDFLAGS += -static |
| 701 | |
| 702 | .PHONY: utils |
Bill Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 703 | utils: ${UTIL_BINS} ${UTIL_SCRIPTS} ${UTIL_SBINS} |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 704 | ${Q}cp -f ${UTIL_SCRIPTS} ${BUILD}/utility |
| 705 | ${Q}chmod a+rx $(patsubst %,${BUILD}/%,${UTIL_SCRIPTS}) |
| 706 | |
| 707 | .PHONY: utils_install |
Bill Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 708 | utils_install: ${UTIL_BINS} ${UTIL_SCRIPTS} ${UTIL_SBINS} |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 709 | @printf " INSTALL UTILS\n" |
Bill Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 710 | ${Q}mkdir -p ${UB_DIR} |
| 711 | ${Q}${INSTALL} -t ${UB_DIR} ${UTIL_BINS} ${UTIL_SCRIPTS} |
| 712 | ifneq (${UTIL_SBINS},) |
| 713 | ${Q}mkdir -p ${SB_DIR} |
| 714 | ${Q}${INSTALL} -t ${SB_DIR} ${UTIL_SBINS} |
| 715 | endif |
| 716 | |
| 717 | |
| 718 | # And some signing stuff for the target |
| 719 | .PHONY: signing_install |
| 720 | signing_install: ${SIGNING_SCRIPTS} ${SIGNING_SCRIPTS_DEV} ${SIGNING_COMMON} |
| 721 | ifneq (${MINIMAL},) |
| 722 | @printf " INSTALL SIGNING\n" |
| 723 | ${Q}mkdir -p ${UB_DIR} |
| 724 | ${Q}${INSTALL} -t ${UB_DIR} ${SIGNING_SCRIPTS} |
| 725 | ${Q}mkdir -p ${VB_DIR} |
| 726 | ${Q}${INSTALL} -t ${VB_DIR} ${SIGNING_SCRIPTS_DEV} |
| 727 | ${Q}${INSTALL} -t ${VB_DIR} -m 'u=rw,go=r,a-s' ${SIGNING_COMMON} |
| 728 | endif |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 729 | |
| 730 | # ---------------------------------------------------------------------------- |
| 731 | # new Firmware Utility |
| 732 | |
| 733 | .PHONY: futil |
| 734 | futil: ${FUTIL_BIN} |
| 735 | |
| 736 | ${FUTIL_BIN}: ${FUTIL_LDS} ${FUTIL_OBJS} |
| 737 | @printf " LD $(subst ${BUILD}/,,$@)\n" |
| 738 | ${Q}${LD} -o $@ ${CFLAGS} $^ ${LDFLAGS} ${LDLIBS} |
| 739 | |
| 740 | .PHONY: futil_install |
| 741 | futil_install: ${FUTIL_BIN} |
| 742 | @printf " INSTALL futility\n" |
Bill Richardson | c9bf348 | 2013-02-13 14:38:29 -0800 | [diff] [blame] | 743 | ${Q}mkdir -p ${UB_DIR} |
| 744 | ${Q}${INSTALL} -t ${UB_DIR} $^ |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 745 | |
| 746 | |
| 747 | # ---------------------------------------------------------------------------- |
| 748 | # Mount-encrypted utility for cryptohome |
| 749 | |
| 750 | # TODO: mount-encrypted should move to cryptohome and just link against |
| 751 | # vboot-host.a for tlcl and crossystem. |
| 752 | |
| 753 | # The embedded libcrypto conflicts with the shipped openssl, |
| 754 | # so mount-* builds without the common CFLAGS (and those includes). |
| 755 | |
| 756 | ${BUILD}/utility/mount-helpers.o: \ |
| 757 | utility/mount-helpers.c \ |
| 758 | utility/mount-helpers.h \ |
| 759 | utility/mount-encrypted.h |
| 760 | @printf " CCm-e $(subst ${BUILD}/,,$@)\n" |
| 761 | ${Q}${CC} -Wall -Werror -O2 -D_FORTIFY_SOURCE=2 -fstack-protector \ |
| 762 | ${COV_FLAGS} \ |
| 763 | $(shell ${PKG_CONFIG} --cflags glib-2.0 openssl) \ |
| 764 | -c $< -o $@ |
| 765 | |
| 766 | ${BUILD}/utility/mount-encrypted: \ |
| 767 | utility/mount-encrypted.c \ |
| 768 | utility/mount-encrypted.h \ |
| 769 | ${BUILD}/utility/mount-helpers.o ${LIBS} |
| 770 | @printf " CCm-exe $(subst ${BUILD}/,,$@)\n" |
| 771 | ${Q}${CC} -Wall -Werror -O2 -D_FORTIFY_SOURCE=2 -fstack-protector \ |
| 772 | $(shell ${PKG_CONFIG} --cflags glib-2.0 openssl) \ |
| 773 | -Ifirmware/include \ |
| 774 | -Ihost/include \ |
| 775 | ${COV_FLAGS} \ |
| 776 | ${LDFLAGS} \ |
| 777 | $< -o $@ \ |
| 778 | ${BUILD}/utility/mount-helpers.o ${LIBS} \ |
| 779 | $(shell ${PKG_CONFIG} --libs glib-2.0 openssl) \ |
| 780 | -lm |
| 781 | ifneq (${COV},) |
| 782 | ${Q}mv -f mount-encrypted.gcno ${BUILD}/utility |
| 783 | endif |
| 784 | |
| 785 | # ---------------------------------------------------------------------------- |
| 786 | # Utility to generate TLCL structure definition header file. |
| 787 | |
| 788 | ${BUILD}/utility/tlcl_generator: CFLAGS += -fpack-struct |
| 789 | |
| 790 | STRUCTURES_TMP=${BUILD}/tlcl_structures.tmp |
| 791 | STRUCTURES_SRC=firmware/lib/tpm_lite/include/tlcl_structures.h |
| 792 | |
| 793 | .PHONY: update_tlcl_structures |
| 794 | update_tlcl_structures: ${BUILD}/utility/tlcl_generator |
| 795 | @printf " Rebuilding TLCL structures\n" |
| 796 | ${Q}${BUILD}/utility/tlcl_generator > ${STRUCTURES_TMP} |
| 797 | ${Q}cmp -s ${STRUCTURES_TMP} ${STRUCTURES_SRC} || \ |
| 798 | ( echo "%% Updating structures.h %%" && \ |
| 799 | cp ${STRUCTURES_TMP} ${STRUCTURES_SRC} ) |
| 800 | |
| 801 | # ---------------------------------------------------------------------------- |
| 802 | # Library to dump kernel config |
| 803 | # Used by platform/installer, as well as standalone utility. |
| 804 | |
| 805 | .PHONY: libdump_kernel_config |
| 806 | libdump_kernel_config: ${DUMPKERNELCONFIGLIB} |
| 807 | |
| 808 | ${DUMPKERNELCONFIGLIB}: ${BUILD}/utility/dump_kernel_config_lib.o |
| 809 | @printf " RM $(subst ${BUILD}/,,$@)\n" |
| 810 | ${Q}rm -f $@ |
| 811 | @printf " AR $(subst ${BUILD}/,,$@)\n" |
| 812 | ${Q}ar qc $@ $^ |
| 813 | |
| 814 | # ---------------------------------------------------------------------------- |
| 815 | # And this thing. |
| 816 | |
| 817 | .PHONY: libcgpt_cc |
| 818 | libcgpt_cc: ${AU_CGPTLIB} |
| 819 | |
| 820 | ${AU_CGPTLIB}: INCLUDES += -Ifirmware/lib/cgptlib/include |
| 821 | ${AU_CGPTLIB}: ${AU_CGPTLIB_OBJS} |
| 822 | @printf " RM $(subst ${BUILD}/,,$@)\n" |
| 823 | ${Q}rm -f $@ |
| 824 | @printf " AR $(subst ${BUILD}/,,$@)\n" |
| 825 | ${Q}ar qc $@ $^ |
| 826 | |
| 827 | # ---------------------------------------------------------------------------- |
| 828 | # Tests |
| 829 | |
| 830 | .PHONY: tests |
| 831 | tests: ${TEST_BINS} |
| 832 | |
| 833 | ${TEST_BINS}: ${TESTLIB} |
| 834 | |
| 835 | ${TESTLIB}: ${TESTLIB_OBJS} |
| 836 | @printf " RM $(subst ${BUILD}/,,$@)\n" |
| 837 | ${Q}rm -f $@ |
| 838 | @printf " AR $(subst ${BUILD}/,,$@)\n" |
| 839 | ${Q}ar qc $@ $^ |
| 840 | |
| 841 | |
| 842 | # ---------------------------------------------------------------------------- |
| 843 | # Generic build rules. LIBS and OBJS can be overridden to tweak the generic |
| 844 | # rules for specific targets. |
| 845 | |
| 846 | ${BUILD}/%: ${BUILD}/%.o ${OBJS} ${LIBS} |
| 847 | @printf " LD $(subst ${BUILD}/,,$@)\n" |
| 848 | ${Q}${LD} -o $@ ${CFLAGS} $< ${OBJS} ${LIBS} ${LDFLAGS} ${LDLIBS} |
| 849 | |
| 850 | ${BUILD}/%.o: %.c |
| 851 | @printf " CC $(subst ${BUILD}/,,$@)\n" |
| 852 | ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $< |
| 853 | |
| 854 | # Rules to recompile a single source file for library and test |
| 855 | # TODO: is there a tidier way to do this? |
| 856 | ${BUILD}/%_for_lib.o: CFLAGS += -DFOR_LIBRARY |
| 857 | ${BUILD}/%_for_lib.o: %.c |
| 858 | @printf " CC-for-lib $(subst ${BUILD}/,,$@)\n" |
| 859 | ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $< |
| 860 | |
| 861 | ${BUILD}/%_for_test.o: CFLAGS += -DFOR_TEST |
| 862 | ${BUILD}/%_for_test.o: %.c |
| 863 | @printf " CC-for-test $(subst ${BUILD}/,,$@)\n" |
| 864 | ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $< |
| 865 | |
| 866 | # TODO: C++ files don't belong in vboot reference at all. Convert to C. |
| 867 | ${BUILD}/%.o: %.cc |
| 868 | @printf " CXX $(subst ${BUILD}/,,$@)\n" |
| 869 | ${Q}${CXX} ${CFLAGS} ${INCLUDES} -c -o $@ $< |
| 870 | |
| 871 | # ---------------------------------------------------------------------------- |
| 872 | # Here are the special tweaks to the generic rules. |
| 873 | |
| 874 | # Linktest ensures firmware lib doesn't rely on outside libraries |
| 875 | ${BUILD}/firmware/linktest/main: LIBS = ${FWLIB} |
| 876 | |
| 877 | # Specific dependency here. |
| 878 | ${BUILD}/utility/dump_kernel_config: LIBS += ${DUMPKERNELCONFIGLIB} |
| 879 | ${BUILD}/utility/dump_kernel_config: ${DUMPKERNELCONFIGLIB} |
| 880 | |
| 881 | # GBB utility needs C++ linker. TODO: It shouldn't. |
| 882 | ${BUILD}/utility/gbb_utility: LD = ${CXX} |
| 883 | |
| 884 | # Some utilities need external crypto functions |
| 885 | ${BUILD}/utility/dumpRSAPublicKey: LDLIBS += ${CRYPTO_LIBS} |
| 886 | ${BUILD}/utility/pad_digest_utility: LDLIBS += ${CRYPTO_LIBS} |
| 887 | ${BUILD}/utility/signature_digest_utility: LDLIBS += ${CRYPTO_LIBS} |
| 888 | ${BUILD}/utility/dev_sign_file: LDLIBS += ${CRYPTO_LIBS} |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 889 | ${BUILD}/utility/vbutil_firmware: LDLIBS += ${CRYPTO_LIBS} |
| 890 | ${BUILD}/utility/vbutil_kernel: LDLIBS += ${CRYPTO_LIBS} |
| 891 | ${BUILD}/utility/vbutil_key: LDLIBS += ${CRYPTO_LIBS} |
| 892 | ${BUILD}/utility/vbutil_keyblock: LDLIBS += ${CRYPTO_LIBS} |
| 893 | |
| 894 | ${BUILD}/host/linktest/main: LDLIBS += ${CRYPTO_LIBS} |
| 895 | ${BUILD}/tests/vboot_common2_tests: LDLIBS += ${CRYPTO_LIBS} |
| 896 | ${BUILD}/tests/vboot_common3_tests: LDLIBS += ${CRYPTO_LIBS} |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 897 | |
| 898 | ${BUILD}/utility/bmpblk_utility: LD = ${CXX} |
| 899 | ${BUILD}/utility/bmpblk_utility: LDLIBS = -llzma -lyaml |
| 900 | |
| 901 | BMPBLK_UTILITY_DEPS = \ |
| 902 | ${BUILD}/utility/bmpblk_util.o \ |
| 903 | ${BUILD}/utility/image_types.o \ |
| 904 | ${BUILD}/utility/eficompress_for_lib.o \ |
| 905 | ${BUILD}/utility/efidecompress_for_lib.o |
| 906 | ${BUILD}/utility/bmpblk_utility: OBJS = ${BMPBLK_UTILITY_DEPS} |
| 907 | ${BUILD}/utility/bmpblk_utility: ${BMPBLK_UTILITY_DEPS} |
| 908 | |
| 909 | ${BUILD}/utility/bmpblk_font: OBJS += ${BUILD}/utility/image_types.o |
| 910 | ${BUILD}/utility/bmpblk_font: ${BUILD}/utility/image_types.o |
| 911 | |
| 912 | # Allow multiple definitions, so tests can mock functions from other libraries |
| 913 | ${BUILD}/tests/%: CFLAGS += -Xlinker --allow-multiple-definition |
| 914 | ${BUILD}/tests/%: INCLUDES += -Ihost/include |
| 915 | ${BUILD}/tests/%: LDLIBS += -lrt -luuid |
| 916 | ${BUILD}/tests/%: LIBS += ${TESTLIB} |
| 917 | |
| 918 | ${BUILD}/tests/rollback_index2_tests: OBJS += \ |
| 919 | ${BUILD}/firmware/lib/rollback_index_for_test.o |
| 920 | ${BUILD}/tests/rollback_index2_tests: \ |
| 921 | ${BUILD}/firmware/lib/rollback_index_for_test.o |
| 922 | |
Randall Spangler | c3d488d | 2013-01-28 16:23:48 -0800 | [diff] [blame] | 923 | ${BUILD}/tests/tlcl_tests: OBJS += \ |
| 924 | ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o |
| 925 | ${BUILD}/tests/tlcl_tests: \ |
| 926 | ${BUILD}/firmware/lib/tpm_lite/tlcl_for_test.o |
| 927 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 928 | ${BUILD}/tests/vboot_audio_tests: OBJS += \ |
| 929 | ${BUILD}/firmware/lib/vboot_audio_for_test.o |
| 930 | ${BUILD}/tests/vboot_audio_tests: \ |
| 931 | ${BUILD}/firmware/lib/vboot_audio_for_test.o |
| 932 | |
| 933 | .PHONY: cgptmanager_tests |
| 934 | cgptmanager_tests: ${BUILD}/tests/CgptManagerTests |
| 935 | |
| 936 | ${BUILD}/tests/CgptManagerTests: CFLAGS += ${PC_CFLAGS} |
| 937 | ${BUILD}/tests/CgptManagerTests: LD = ${CXX} |
| 938 | ${BUILD}/tests/CgptManagerTests: LDLIBS += -lgtest -lgflags ${PC_LDLIBS} |
| 939 | ${BUILD}/tests/CgptManagerTests: LIBS = ${AU_CGPTLIB} |
| 940 | ${BUILD}/tests/CgptManagerTests: ${AU_CGPTLIB} |
| 941 | |
| 942 | ${BUILD}/tests/rollback_index_test: INCLUDES += -I/usr/include |
| 943 | ${BUILD}/tests/rollback_index_test: LIBS += -ltlcl |
| 944 | |
| 945 | ${TLCL_TEST_BINS}: OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o |
| 946 | ${TLCL_TEST_BINS}: ${BUILD}/tests/tpm_lite/tlcl_tests.o |
| 947 | |
| 948 | ############################################################################## |
| 949 | # Targets that exist just to run tests |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 950 | |
| 951 | # Frequently-run tests |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 952 | .PHONY: test_targets |
| 953 | test_targets:: runcgpttests runmisctests |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 954 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 955 | ifeq (${MINIMAL},) |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 956 | # Bitmap utility isn't compiled for minimal variant |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 957 | test_targets:: runbmptests |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 958 | # Scripts don't work under qemu testing |
| 959 | # TODO: convert scripts to makefile so they can be called directly |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 960 | test_targets:: runtestscripts |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 961 | endif |
| 962 | |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 963 | .PHONY: test_setup |
| 964 | test_setup:: cgpt utils futil tests |
| 965 | |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 966 | # Qemu setup for cross-compiled tests. Need to copy qemu binary into the |
| 967 | # sysroot. |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 968 | ifneq (${QEMU_ARCH},) |
| 969 | test_setup:: qemu_install |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 970 | |
| 971 | .PHONY: qemu_install |
| 972 | qemu_install: |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 973 | ifeq (${SYSROOT},) |
| 974 | $(error SYSROOT must be set to the top of the target-specific root \ |
| 975 | when cross-compiling for qemu-based tests to run properly.) |
| 976 | endif |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 977 | @printf " Copying qemu binary.\n" |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 978 | ${Q}cp -fu /usr/bin/${QEMU_BIN} ${BUILD}/${QEMU_BIN} |
| 979 | ${Q}chmod a+rx ${BUILD}/${QEMU_BIN} |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 980 | endif |
| 981 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 982 | .PHONY: runtests |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 983 | runtests: test_targets |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 984 | |
| 985 | # Generate test keys |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 986 | .PHONY: genkeys |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 987 | genkeys: utils |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 988 | tests/gen_test_keys.sh |
| 989 | |
| 990 | # Generate test cases for fuzzing |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 991 | .PHONY: genfuzztestcases |
Randall Spangler | a808dc9 | 2013-01-14 12:59:05 -0800 | [diff] [blame] | 992 | genfuzztestcases: utils |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 993 | tests/gen_fuzz_test_cases.sh |
| 994 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 995 | .PHONY: runbmptests |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 996 | runbmptests: test_setup |
| 997 | cd tests/bitmaps && BMPBLK=${BUILD_RUN}/utility/bmpblk_utility \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 998 | ./TestBmpBlock.py -v |
| 999 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 1000 | .PHONY: runcgpttests |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1001 | runcgpttests: test_setup |
| 1002 | ${RUNTEST} ${BUILD_RUN}/tests/cgptlib_test |
| 1003 | # HEY - elsewhere |
| 1004 | ifneq (${IN_CHROOT},) |
| 1005 | ${RUNTEST} ${BUILD_RUN}/tests/CgptManagerTests --v=1 |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1006 | endif |
| 1007 | |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 1008 | .PHONY: runtestscripts |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1009 | runtestscripts: test_setup genfuzztestcases |
| 1010 | tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1011 | tests/run_preamble_tests.sh |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1012 | tests/run_rsa_tests.sh |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 1013 | tests/run_vbutil_kernel_arg_tests.sh |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1014 | tests/run_vbutil_tests.sh |
| 1015 | |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 1016 | .PHONY: runmisctests |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1017 | runmisctests: test_setup |
| 1018 | ${RUNTEST} ${BUILD_RUN}/tests/rollback_index2_tests |
Randall Spangler | a3eac79 | 2013-01-23 13:04:05 -0800 | [diff] [blame] | 1019 | ${RUNTEST} ${BUILD_RUN}/tests/rollback_index3_tests |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1020 | ${RUNTEST} ${BUILD_RUN}/tests/rsa_utility_tests |
| 1021 | ${RUNTEST} ${BUILD_RUN}/tests/sha_tests |
| 1022 | ${RUNTEST} ${BUILD_RUN}/tests/stateful_util_tests |
Randall Spangler | c3d488d | 2013-01-28 16:23:48 -0800 | [diff] [blame] | 1023 | ${RUNTEST} ${BUILD_RUN}/tests/tlcl_tests |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1024 | ${RUNTEST} ${BUILD_RUN}/tests/tpm_bootmode_tests |
| 1025 | ${RUNTEST} ${BUILD_RUN}/tests/utility_string_tests |
| 1026 | ${RUNTEST} ${BUILD_RUN}/tests/utility_tests |
| 1027 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_devmode_tests |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1028 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_firmware_tests |
Randall Spangler | 0714d9d | 2013-02-05 10:23:38 -0800 | [diff] [blame] | 1029 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_init_tests |
| 1030 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel_tests |
Randall Spangler | 7f43669 | 2013-02-05 12:42:36 -0800 | [diff] [blame] | 1031 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel2_tests |
| 1032 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel3_tests |
| 1033 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_kernel4_tests |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1034 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_audio_tests |
Randall Spangler | e061a25 | 2013-01-22 15:34:07 -0800 | [diff] [blame] | 1035 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_common_tests |
| 1036 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS} |
| 1037 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS} |
Randall Spangler | 786a5dc | 2013-01-24 14:19:56 -0800 | [diff] [blame] | 1038 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_display_tests |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1039 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_firmware_tests |
Randall Spangler | 49cb0d3 | 2013-01-29 14:28:16 -0800 | [diff] [blame] | 1040 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_kernel_tests |
Randall Spangler | 6dbf9d9 | 2013-01-23 12:25:10 -0800 | [diff] [blame] | 1041 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_nvstorage_test |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1042 | |
| 1043 | .PHONY: runfutiltests |
| 1044 | runfutiltests: DESTDIR := ${TEST_INSTALL_DIR} |
| 1045 | runfutiltests: test_setup install |
| 1046 | @echo "$@ passed" |
Randall Spangler | 844bce5 | 2013-01-15 16:16:43 -0800 | [diff] [blame] | 1047 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1048 | # Run long tests, including all permutations of encryption keys (instead of |
Randall Spangler | 786a5dc | 2013-01-24 14:19:56 -0800 | [diff] [blame] | 1049 | # just the ones we use) and tests of currently-unused code. |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1050 | # Not run by automated build. |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 1051 | .PHONY: runlongtests |
Bill Richardson | eecc18f | 2013-01-17 15:28:17 -0800 | [diff] [blame] | 1052 | runlongtests: test_setup genkeys genfuzztestcases |
Randall Spangler | e061a25 | 2013-01-22 15:34:07 -0800 | [diff] [blame] | 1053 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS} --all |
| 1054 | ${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS} --all |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1055 | tests/run_preamble_tests.sh --all |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 1056 | tests/run_vbutil_tests.sh --all |
| 1057 | |
| 1058 | # TODO: tests to run when ported to new API |
| 1059 | # ./run_image_verification_tests.sh |
| 1060 | # # Splicing tests |
| 1061 | # ${BUILD}/tests/firmware_splicing_tests |
| 1062 | # ${BUILD}/tests/kernel_splicing_tests |
| 1063 | # # Rollback Tests |
| 1064 | # ${BUILD}/tests/firmware_rollback_tests |
| 1065 | # ${BUILD}/tests/kernel_rollback_tests |
| 1066 | |
Randall Spangler | 59d7508 | 2013-01-23 09:29:54 -0800 | [diff] [blame] | 1067 | # Code coverage |
| 1068 | .PHONY: coverage_init |
| 1069 | coverage_init: test_setup |
| 1070 | rm -f ${COV_INFO}* |
| 1071 | lcov -c -i -d . -b . -o ${COV_INFO}.initial |
| 1072 | |
| 1073 | .PHONY: coverage_html |
| 1074 | coverage_html: |
| 1075 | lcov -c -d . -b . -o ${COV_INFO}.tests |
| 1076 | lcov -a ${COV_INFO}.initial -a ${COV_INFO}.tests -o ${COV_INFO}.total |
| 1077 | lcov -r ${COV_INFO}.total '/usr/*' '*/linktest/*' -o ${COV_INFO}.local |
| 1078 | genhtml ${COV_INFO}.local -o ${BUILD}/coverage |
| 1079 | |
| 1080 | # Generate addtional coverage stats just for firmware subdir, because the |
| 1081 | # 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] | 1082 | lcov -r ${COV_INFO}.local '*/stub/*' -o ${COV_INFO}.nostub |
| 1083 | lcov -e ${COV_INFO}.nostub '${SRCDIR}/firmware/*' \ |
Randall Spangler | 59d7508 | 2013-01-23 09:29:54 -0800 | [diff] [blame] | 1084 | -o ${COV_INFO}.firmware |
| 1085 | |
| 1086 | .PHONY: coverage |
| 1087 | ifeq (${COV},) |
| 1088 | coverage: |
| 1089 | $(error Build coverage like this: make clean && COV=1 make) |
| 1090 | else |
| 1091 | coverage: coverage_init runtests coverage_html |
| 1092 | endif |
| 1093 | |