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 | |
Gabe Black | 0aedbe1 | 2012-12-20 00:26:59 -0800 | [diff] [blame] | 5 | ifneq ($(V),1) |
| 6 | Q := @ |
| 7 | endif |
| 8 | |
Simon Glass | 6d696e5 | 2011-11-14 13:46:33 -0800 | [diff] [blame] | 9 | # This Makefile normally builds in a 'build' subdir, but use |
| 10 | # |
| 11 | # make BUILD=<dir> |
| 12 | # |
| 13 | # to put the output somewhere else |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 14 | BUILD ?= $(shell pwd)/build |
Simon Glass | 6d696e5 | 2011-11-14 13:46:33 -0800 | [diff] [blame] | 15 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 16 | # Target for 'make install' |
| 17 | DESTDIR ?= /usr/bin |
Bill Richardson | 826db09 | 2013-01-14 12:37:15 -0800 | [diff] [blame] | 18 | INSTALL ?= install |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 19 | |
Simon Glass | b265c34 | 2011-11-16 15:09:51 -0800 | [diff] [blame] | 20 | # Provide default CC and CFLAGS for firmware builds; if you have any -D flags, |
| 21 | # please add them after this point (e.g., -DVBOOT_DEBUG). |
Che-Liang Chiou | 74359b7 | 2011-06-21 15:25:51 -0700 | [diff] [blame] | 22 | # |
Che-Liang Chiou | 6b0003c | 2011-10-14 11:11:28 +0800 | [diff] [blame] | 23 | # TODO(crosbug.com/16808) We hard-code u-boot's compiler flags here just |
| 24 | # temporarily. As we are still investigating which flags are necessary for |
| 25 | # maintaining a compatible ABI, etc. between u-boot and vboot_reference. |
Che-Liang Chiou | 74359b7 | 2011-06-21 15:25:51 -0700 | [diff] [blame] | 26 | # |
Simon Glass | b265c34 | 2011-11-16 15:09:51 -0800 | [diff] [blame] | 27 | # As a first step, this makes the setting of CC and CFLAGS here optional, to |
| 28 | # permit a calling script or Makefile to set these. |
Che-Liang Chiou | 74359b7 | 2011-06-21 15:25:51 -0700 | [diff] [blame] | 29 | # |
Simon Glass | b265c34 | 2011-11-16 15:09:51 -0800 | [diff] [blame] | 30 | # Flag ordering: arch, then -f, then -m, then -W |
| 31 | DEBUG_FLAGS := $(if ${DEBUG},-g -O0,-Os) |
| 32 | COMMON_FLAGS := -nostdinc -pipe \ |
| 33 | -ffreestanding -fno-builtin -fno-stack-protector \ |
| 34 | -Werror -Wall -Wstrict-prototypes $(DEBUG_FLAGS) |
| 35 | |
Che-Liang Chiou | 7604a7d | 2011-06-21 17:40:34 -0700 | [diff] [blame] | 36 | ifeq ($(FIRMWARE_ARCH), arm) |
Simon Glass | b265c34 | 2011-11-16 15:09:51 -0800 | [diff] [blame] | 37 | CC ?= armv7a-cros-linux-gnueabi-gcc |
| 38 | CFLAGS ?= -march=armv5 \ |
| 39 | -fno-common -ffixed-r8 \ |
Doug Anderson | d50b27d | 2012-05-11 12:08:02 -0700 | [diff] [blame] | 40 | -mfloat-abi=hard -marm -mabi=aapcs-linux -mno-thumb-interwork \ |
Simon Glass | b265c34 | 2011-11-16 15:09:51 -0800 | [diff] [blame] | 41 | $(COMMON_FLAGS) |
Che-Liang Chiou | 74359b7 | 2011-06-21 15:25:51 -0700 | [diff] [blame] | 42 | endif |
Che-Liang Chiou | 7604a7d | 2011-06-21 17:40:34 -0700 | [diff] [blame] | 43 | ifeq ($(FIRMWARE_ARCH), i386) |
Simon Glass | b265c34 | 2011-11-16 15:09:51 -0800 | [diff] [blame] | 44 | CC ?= i686-pc-linux-gnu-gcc |
| 45 | # Drop -march=i386 to permit use of SSE instructions |
| 46 | CFLAGS ?= \ |
| 47 | -ffunction-sections -fvisibility=hidden -fno-strict-aliasing \ |
| 48 | -fomit-frame-pointer -fno-toplevel-reorder -fno-dwarf2-cfi-asm \ |
| 49 | -mpreferred-stack-boundary=2 -mregparm=3 \ |
| 50 | $(COMMON_FLAGS) |
Che-Liang Chiou | 34be827 | 2011-01-27 16:44:36 +0800 | [diff] [blame] | 51 | endif |
Simon Glass | 8e85e98 | 2011-11-22 13:54:50 -0800 | [diff] [blame] | 52 | ifeq ($(FIRMWARE_ARCH), x86_64) |
| 53 | CFLAGS ?= $(COMMON_FLAGS) \ |
| 54 | -fvisibility=hidden -fno-strict-aliasing -fomit-frame-pointer |
| 55 | endif |
Che-Liang Chiou | 34be827 | 2011-01-27 16:44:36 +0800 | [diff] [blame] | 56 | |
Randall Spangler | 287beae | 2011-04-11 12:46:40 -0700 | [diff] [blame] | 57 | # Fix compiling directly on host (outside of emake) |
| 58 | ifeq ($(ARCH),) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 59 | ARCH = amd64 |
Randall Spangler | 287beae | 2011-04-11 12:46:40 -0700 | [diff] [blame] | 60 | endif |
| 61 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 62 | # Some things only compile inside the Chromium OS chroot |
| 63 | # TODO: is there a better way to detect this? |
| 64 | ifneq ($(CROS_WORKON_SRCROOT),) |
| 65 | IN_CHROOT = 1 |
| 66 | endif |
| 67 | |
| 68 | CC ?= gcc |
| 69 | CXX ?= g++ |
| 70 | LD = $(CC) |
| 71 | PKG_CONFIG ?= pkg-config |
| 72 | |
Che-Liang Chiou | 34be827 | 2011-01-27 16:44:36 +0800 | [diff] [blame] | 73 | ifeq ($(FIRMWARE_ARCH),) |
Bill Richardson | f472919 | 2012-05-02 23:30:16 -0700 | [diff] [blame] | 74 | CFLAGS += -DCHROMEOS_ENVIRONMENT -Wall -Werror |
Che-Liang Chiou | 34be827 | 2011-01-27 16:44:36 +0800 | [diff] [blame] | 75 | endif |
| 76 | |
| 77 | ifneq (${DEBUG},) |
| 78 | CFLAGS += -DVBOOT_DEBUG |
vbendeb | b2b0fcc | 2010-07-15 15:09:47 -0700 | [diff] [blame] | 79 | endif |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 80 | |
vbendeb | b2b0fcc | 2010-07-15 15:09:47 -0700 | [diff] [blame] | 81 | ifeq (${DISABLE_NDEBUG},) |
| 82 | CFLAGS += -DNDEBUG |
| 83 | endif |
| 84 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 85 | # Create / use dependency files |
| 86 | CFLAGS += -MMD -MF $@.d |
Simon Glass | b265c34 | 2011-11-16 15:09:51 -0800 | [diff] [blame] | 87 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 88 | # Code coverage |
| 89 | ifneq (${COV},) |
| 90 | #COV_FLAGS = -O0 -fprofile-arcs -ftest-coverage |
| 91 | COV_FLAGS = -O0 --coverage |
| 92 | CFLAGS += $(COV_FLAGS) |
| 93 | LDFLAGS += $(COV_FLAGS) |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 94 | endif |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 95 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 96 | INCLUDES += \ |
| 97 | -Ifirmware/include \ |
| 98 | -Ifirmware/lib/include \ |
| 99 | -Ifirmware/lib/cgptlib/include \ |
| 100 | -Ifirmware/lib/cryptolib/include \ |
| 101 | -Ifirmware/lib/tpm_lite/include |
Bill Richardson | 0b8f35c | 2010-05-26 09:18:38 -0700 | [diff] [blame] | 102 | |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 103 | ifeq ($(FIRMWARE_ARCH),) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 104 | INCLUDES += -Ifirmware/stub/include |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 105 | else |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 106 | INCLUDES += -Ifirmware/arch/$(FIRMWARE_ARCH)/include |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 107 | endif |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 108 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 109 | # Output libraries |
| 110 | CGPTLIB := ${BUILD}/cgpt/libcgpt-cc.a |
| 111 | DUMPKERNELCONFIGLIB := ${BUILD}/libdump_kernel_config.a |
| 112 | FWLIB := ${BUILD}/vboot_fw.a |
| 113 | HOSTLIB := ${BUILD}/vboot_host.a |
| 114 | TEST_LIB := ${BUILD}/tests/test.a |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 115 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 116 | CRYPTO_LIBS := $(shell $(PKG_CONFIG) --libs libcrypto) |
Jay Srinivasan | 5fac757 | 2012-02-23 10:59:01 -0800 | [diff] [blame] | 117 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 118 | ifneq ($(IN_CHROOT),) |
| 119 | PC_BASE_VER ?= 125070 |
| 120 | PC_DEPS = libchrome-$(PC_BASE_VER) |
| 121 | PC_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(PC_DEPS)) |
| 122 | PC_LDLIBS := $(shell $(PKG_CONFIG) --libs $(PC_DEPS)) |
| 123 | endif |
Jay Srinivasan | 5fac757 | 2012-02-23 10:59:01 -0800 | [diff] [blame] | 124 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 125 | # Link with hostlib and crypto libs by default |
| 126 | LIBS = $(HOSTLIB) |
| 127 | LDLIBS = $(CRYPTO_LIBS) |
| 128 | |
| 129 | # Create output directories if necessary. Do this via explicit shell commands |
| 130 | # so it happens before trying to generate/include dependencies. |
| 131 | SUBDIRS := firmware host utility cgpt tests tests/tpm_lite |
| 132 | _dir_create := $(foreach d, \ |
| 133 | $(shell find $(SUBDIRS) -name '*.c' -exec dirname {} \; | sort -u), \ |
| 134 | $(shell [ -d $(BUILD)/$(d) ] || mkdir -p $(BUILD)/$(d))) |
| 135 | |
| 136 | # First target |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 137 | .PHONY: all |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 138 | all: fwlib $(if $(FIRMWARE_ARCH),,host_stuff) |
| 139 | |
| 140 | # Host targets |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 141 | .PHONY: host_stuff |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 142 | host_stuff: fwlib hostlib cgpt utils tests |
Jay Srinivasan | 250549d | 2012-02-16 17:40:45 -0800 | [diff] [blame] | 143 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 144 | .PHONY: clean |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 145 | clean: |
Gabe Black | 0aedbe1 | 2012-12-20 00:26:59 -0800 | [diff] [blame] | 146 | $(Q)/bin/rm -rf ${BUILD} |
Bill Richardson | 371df8b | 2010-05-27 14:19:47 -0700 | [diff] [blame] | 147 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 148 | .PHONY: install |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 149 | install: cgpt_install utils_install |
Gaurav Shah | e642198 | 2010-06-03 07:49:32 -0700 | [diff] [blame] | 150 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 151 | # Coverage |
| 152 | COV_INFO = $(BUILD)/coverage.info |
| 153 | #coverage: runtests |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 154 | .PHONY: coverage |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 155 | coverage: |
| 156 | rm -f $(COV_INFO)* |
| 157 | lcov --capture --directory . --base-directory . -o $(COV_INFO).1 |
| 158 | lcov --remove $(COV_INFO).1 '/usr/*' -o $(COV_INFO) |
| 159 | genhtml $(COV_INFO) --output-directory $(BUILD)/coverage |
Luigi Semenzato | 18b814d | 2010-07-08 17:17:02 -0700 | [diff] [blame] | 160 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 161 | # Don't delete intermediate object files |
| 162 | .SECONDARY: |
Randall Spangler | e8cfa31 | 2013-01-02 16:49:38 -0800 | [diff] [blame] | 163 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 164 | # Use second expansion phase for $$(LIBS) so dependencies on libraries are |
| 165 | # properly evaluated for implicit rules. |
| 166 | .SECONDEXPANSION: |
Jay Srinivasan | 250549d | 2012-02-16 17:40:45 -0800 | [diff] [blame] | 167 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 168 | # ----------------------------------------------------------------------------- |
| 169 | # Firmware library |
Bill Richardson | 856e072 | 2011-02-07 15:39:45 -0800 | [diff] [blame] | 170 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 171 | # TPM-specific flags. These depend on the particular TPM we're targeting for. |
| 172 | # They are needed here only for compiling parts of the firmware code into |
| 173 | # user-level tests. |
| 174 | |
| 175 | # TPM_BLOCKING_CONTINUESELFTEST is defined if TPM_ContinueSelfTest blocks until |
| 176 | # the self test has completed. |
| 177 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 178 | $(FWLIB): CFLAGS += -DTPM_BLOCKING_CONTINUESELFTEST |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 179 | |
| 180 | # TPM_MANUAL_SELFTEST is defined if the self test must be started manually |
| 181 | # (with a call to TPM_ContinueSelfTest) instead of starting automatically at |
| 182 | # power on. |
| 183 | # |
| 184 | # We sincerely hope that TPM_BLOCKING_CONTINUESELFTEST and TPM_MANUAL_SELFTEST |
| 185 | # are not both defined at the same time. (See comment in code.) |
| 186 | |
| 187 | # CFLAGS += -DTPM_MANUAL_SELFTEST |
| 188 | |
| 189 | ifeq ($(FIRMWARE_ARCH),i386) |
| 190 | # Unrolling loops in cryptolib makes it faster |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 191 | $(FWLIB): CFLAGS += -DUNROLL_LOOPS |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 192 | |
| 193 | # Workaround for coreboot on x86, which will power off asynchronously |
| 194 | # without giving us a chance to react. This is not an example of the Right |
| 195 | # Way to do things. See chrome-os-partner:7689, and the commit message |
| 196 | # that made this change. |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 197 | $(FWLIB): CFLAGS += -DSAVE_LOCALE_IMMEDIATELY |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 198 | |
| 199 | # On x86 we don't actually read the GBB data into RAM until it is needed. |
| 200 | # Therefore it makes sense to cache it rather than reading it each time. |
| 201 | # Enable this feature. |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 202 | $(FWLIB): CFLAGS += -DCOPY_BMP_DATA |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 203 | endif |
| 204 | |
| 205 | ifeq ($(FIRMWARE_ARCH),) |
| 206 | $(warning FIRMWARE_ARCH not defined; assuming local compile) |
| 207 | |
| 208 | # Disable rollback TPM when compiling locally, since otherwise |
| 209 | # load_kernel_test attempts to talk to the TPM. |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 210 | $(FWLIB): CFLAGS += -DDISABLE_ROLLBACK_TPM |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 211 | endif |
| 212 | |
| 213 | # find lib -iname '*.c' | sort |
| 214 | FWLIB_SRCS = \ |
| 215 | firmware/lib/cgptlib/cgptlib.c \ |
| 216 | firmware/lib/cgptlib/cgptlib_internal.c \ |
| 217 | firmware/lib/cgptlib/crc32.c \ |
| 218 | firmware/lib/crc8.c \ |
| 219 | firmware/lib/cryptolib/padding.c \ |
| 220 | firmware/lib/cryptolib/rsa.c \ |
| 221 | firmware/lib/cryptolib/rsa_utility.c \ |
| 222 | firmware/lib/cryptolib/sha1.c \ |
| 223 | firmware/lib/cryptolib/sha256.c \ |
| 224 | firmware/lib/cryptolib/sha512.c \ |
| 225 | firmware/lib/cryptolib/sha_utility.c \ |
| 226 | firmware/lib/stateful_util.c \ |
| 227 | firmware/lib/utility.c \ |
| 228 | firmware/lib/utility_string.c \ |
| 229 | firmware/lib/vboot_api_init.c \ |
| 230 | firmware/lib/vboot_api_firmware.c \ |
| 231 | firmware/lib/vboot_api_kernel.c \ |
| 232 | firmware/lib/vboot_audio.c \ |
| 233 | firmware/lib/vboot_common.c \ |
| 234 | firmware/lib/vboot_display.c \ |
| 235 | firmware/lib/vboot_firmware.c \ |
| 236 | firmware/lib/vboot_kernel.c \ |
| 237 | firmware/lib/vboot_nvstorage.c |
| 238 | |
| 239 | ifeq ($(MOCK_TPM),) |
| 240 | FWLIB_SRCS += \ |
| 241 | firmware/lib/rollback_index.c \ |
| 242 | firmware/lib/tpm_bootmode.c \ |
| 243 | firmware/lib/tpm_lite/tlcl.c |
| 244 | else |
| 245 | FWLIB_SRCS += \ |
| 246 | firmware/lib/mocked_rollback_index.c \ |
| 247 | firmware/lib/mocked_tpm_bootmode.c \ |
| 248 | firmware/lib/tpm_lite/mocked_tlcl.c |
| 249 | endif |
| 250 | |
| 251 | ifeq ($(FIRMWARE_ARCH),) |
| 252 | # Include stub into firmware lib if compiling for host |
| 253 | FWLIB_SRCS += \ |
| 254 | firmware/stub/tpm_lite_stub.c \ |
| 255 | firmware/stub/utility_stub.c \ |
| 256 | firmware/stub/vboot_api_stub.c \ |
| 257 | firmware/stub/vboot_api_stub_disk.c |
| 258 | endif |
| 259 | |
| 260 | FWLIB_OBJS = $(FWLIB_SRCS:%.c=${BUILD}/%.o) |
| 261 | ALL_OBJS += ${FWLIB_OBJS} |
| 262 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 263 | .PHONY: fwlib |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 264 | ifeq ($(FIRMWARE_ARCH),) |
| 265 | # Link test ensures firmware lib doesn't rely on outside libraries |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 266 | ${BUILD}/firmware/linktest/main: LIBS = $(FWLIB) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 267 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 268 | fwlib: ${BUILD}/firmware/linktest/main |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 269 | else |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 270 | fwlib: $(FWLIB) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 271 | endif |
| 272 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 273 | $(FWLIB): $(FWLIB_OBJS) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 274 | @printf " RM $(subst $(BUILD)/,,$(@))\n" |
| 275 | $(Q)rm -f $@ |
| 276 | @printf " AR $(subst $(BUILD)/,,$(@))\n" |
| 277 | $(Q)ar qc $@ $^ |
| 278 | |
| 279 | # ----------------------------------------------------------------------------- |
| 280 | # Host library |
| 281 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 282 | .PHONY: hostlib |
| 283 | hostlib: $(HOSTLIB) ${BUILD}/host/linktest/main |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 284 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 285 | ${BUILD}/host/% ${HOSTLIB}: INCLUDES += \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 286 | -Ihost/include\ |
| 287 | -Ihost/arch/$(ARCH)/include |
| 288 | |
| 289 | HOSTLIB_SRCS = \ |
| 290 | host/arch/$(ARCH)/lib/crossystem_arch.c \ |
| 291 | host/lib/crossystem.c \ |
| 292 | host/lib/file_keys.c \ |
| 293 | host/lib/fmap.c \ |
| 294 | host/lib/host_common.c \ |
| 295 | host/lib/host_key.c \ |
| 296 | host/lib/host_keyblock.c \ |
| 297 | host/lib/host_misc.c \ |
| 298 | host/lib/host_signature.c \ |
| 299 | host/lib/signature_digest.c |
| 300 | |
| 301 | HOSTLIB_OBJS = $(HOSTLIB_SRCS:%.c=${BUILD}/%.o) |
| 302 | ALL_OBJS += ${HOSTLIB_OBJS} |
| 303 | |
| 304 | # TODO: better way to make .a than duplicating this recipe each time? |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 305 | $(HOSTLIB): $(HOSTLIB_OBJS) $(FWLIB_OBJS) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 306 | @printf " RM $(subst $(BUILD)/,,$(@))\n" |
| 307 | $(Q)rm -f $@ |
| 308 | @printf " AR $(subst $(BUILD)/,,$(@))\n" |
| 309 | $(Q)ar qc $@ $^ |
| 310 | |
| 311 | # ----------------------------------------------------------------------------- |
| 312 | # CGPT library and utility |
| 313 | |
| 314 | CGPT = ${BUILD}/cgpt/cgpt |
| 315 | |
| 316 | CGPT_SRCS = \ |
| 317 | cgpt/cgpt.c \ |
| 318 | cgpt/cgpt_add.c \ |
| 319 | cgpt/cgpt_boot.c \ |
| 320 | cgpt/cgpt_common.c \ |
| 321 | cgpt/cgpt_create.c \ |
| 322 | cgpt/cgpt_find.c \ |
| 323 | cgpt/cgpt_legacy.c \ |
| 324 | cgpt/cgpt_prioritize.c \ |
| 325 | cgpt/cgpt_repair.c \ |
| 326 | cgpt/cgpt_show.c \ |
| 327 | cgpt/cmd_add.c \ |
| 328 | cgpt/cmd_boot.c \ |
| 329 | cgpt/cmd_create.c \ |
| 330 | cgpt/cmd_find.c \ |
| 331 | cgpt/cmd_legacy.c \ |
| 332 | cgpt/cmd_prioritize.c \ |
| 333 | cgpt/cmd_repair.c \ |
| 334 | cgpt/cmd_show.c |
| 335 | |
| 336 | CGPT_OBJS = $(CGPT_SRCS:%.c=${BUILD}/%.o) |
| 337 | ALL_OBJS += ${CGPT_OBJS} |
| 338 | |
| 339 | # TODO: why not make this include *all* the cgpt files, and simply have |
| 340 | # cgpt link against it? |
| 341 | # TODO: CgptManager.cc should move to the installer project. Shouldn't be |
| 342 | # in libcgpt-cc.a. |
| 343 | CGPTLIB_SRCS = \ |
| 344 | cgpt/CgptManager.cc \ |
| 345 | cgpt/cgpt_create.c \ |
| 346 | cgpt/cgpt_add.c \ |
| 347 | cgpt/cgpt_boot.c \ |
| 348 | cgpt/cgpt_show.c \ |
| 349 | cgpt/cgpt_repair.c \ |
| 350 | cgpt/cgpt_prioritize.c \ |
| 351 | cgpt/cgpt_common.c \ |
| 352 | firmware/lib/cgptlib/crc32.c \ |
| 353 | firmware/lib/cgptlib/cgptlib_internal.c \ |
| 354 | firmware/stub/utility_stub.c |
| 355 | |
| 356 | CGPTLIB_OBJS = $(filter %.o, \ |
| 357 | $(CGPTLIB_SRCS:%.c=${BUILD}/%.o) \ |
| 358 | $(CGPTLIB_SRCS:%.cc=${BUILD}/%.o)) |
| 359 | ALL_OBJS += $(CGPTLIB_OBJS) |
| 360 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 361 | .PHONY: cgpt |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 362 | cgpt: $(CGPT) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 363 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 364 | .PHONY: libcgpt_cc |
| 365 | libcgpt_cc: $(CGPTLIB) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 366 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 367 | $(CGPTLIB): INCLUDES += -Ifirmware/lib/cgptlib/include |
| 368 | $(CGPTLIB): $(CGPTLIB_OBJS) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 369 | @printf " RM $(subst $(BUILD)/,,$(@))\n" |
| 370 | $(Q)rm -f $@ |
| 371 | @printf " AR $(subst $(BUILD)/,,$(@))\n" |
| 372 | $(Q)ar qc $@ $^ |
| 373 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 374 | $(CGPT): INCLUDES += -Ifirmware/lib/cgptlib/include |
| 375 | $(CGPT): LDLIBS = -luuid |
| 376 | $(CGPT): LDFLAGS += -static |
| 377 | $(CGPT): $(CGPT_OBJS) $$(LIBS) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 378 | @printf " LDcgpt $(subst $(BUILD)/,,$(@))\n" |
| 379 | $(Q)$(LD) -o $(CGPT) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) $(LDLIBS) |
| 380 | |
Bill Richardson | 826db09 | 2013-01-14 12:37:15 -0800 | [diff] [blame] | 381 | C_DESTDIR = $(DESTDIR) |
| 382 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 383 | .PHONY: cgpt_install |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 384 | cgpt_install: $(CGPT) |
Bill Richardson | 826db09 | 2013-01-14 12:37:15 -0800 | [diff] [blame] | 385 | @printf " INSTALL CGPT\n" |
| 386 | ${Q}mkdir -p $(C_DESTDIR) |
| 387 | ${Q}$(INSTALL) -t $(C_DESTDIR) $^ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 388 | |
| 389 | # ----------------------------------------------------------------------------- |
| 390 | # Utilities |
| 391 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 392 | ${BUILD}/utility/%: INCLUDES += -Ihost/include -Iutility/include |
| 393 | ${BUILD}/utility/%: CFLAGS += $(PC_CFLAGS) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 394 | |
| 395 | AU_NAMES = \ |
| 396 | crossystem \ |
| 397 | dump_fmap \ |
| 398 | gbb_utility |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 399 | AU_BINS:= $(addprefix ${BUILD}/utility/,$(AU_NAMES)) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 400 | |
| 401 | # Utilities for auto-update toolkits must be statically linked, and don't |
| 402 | # use the crypto libs. |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 403 | ${AU_BINS}: LDFLAGS += -static |
| 404 | ${AU_BINS}: CRYPTO_LIBS = |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 405 | |
| 406 | # Scripts to install |
| 407 | UTIL_SCRIPTS = \ |
| 408 | utility/dev_debug_vboot \ |
| 409 | utility/dev_make_keypair \ |
| 410 | utility/enable_dev_usb_boot \ |
| 411 | utility/vbutil_what_keys |
| 412 | |
| 413 | UTIL_NAMES = $(AU_NAMES) \ |
| 414 | dev_sign_file \ |
| 415 | dump_kernel_config \ |
| 416 | dumpRSAPublicKey \ |
| 417 | load_kernel_test \ |
| 418 | pad_digest_utility \ |
| 419 | signature_digest_utility \ |
| 420 | tpm_init_temp_fix \ |
| 421 | tpmc \ |
| 422 | vbutil_ec \ |
| 423 | vbutil_firmware \ |
| 424 | vbutil_kernel \ |
| 425 | vbutil_key \ |
| 426 | vbutil_keyblock \ |
| 427 | verify_data |
| 428 | |
| 429 | ifneq ($(IN_CHROOT),) |
| 430 | UTIL_NAMES += mount-encrypted |
| 431 | endif |
| 432 | |
| 433 | ifeq ($(MINIMAL),) |
| 434 | UTIL_NAMES += \ |
| 435 | bmpblk_font \ |
| 436 | bmpblk_utility \ |
| 437 | eficompress \ |
| 438 | efidecompress |
| 439 | endif |
| 440 | |
| 441 | UTIL_BINS = $(addprefix ${BUILD}/utility/,$(UTIL_NAMES)) |
| 442 | ALL_DEPS += $(addsuffix .d,${UTIL_BINS}) |
| 443 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 444 | .PHONY: utils |
| 445 | utils: $(UTIL_BINS) $(UTIL_SCRIPTS) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 446 | # TODO: change ebuild to pull scripts directly out of utility dir |
| 447 | $(Q)cp -f $(UTIL_SCRIPTS) $(BUILD)/utility |
| 448 | $(Q)chmod a+rx $(patsubst %,$(BUILD)/%,$(UTIL_SCRIPTS)) |
| 449 | |
Bill Richardson | 826db09 | 2013-01-14 12:37:15 -0800 | [diff] [blame] | 450 | U_DESTDIR = $(DESTDIR) |
| 451 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 452 | .PHONY: utils_install |
| 453 | utils_install: $(UTIL_BINS) $(UTIL_SCRIPTS) |
Bill Richardson | 826db09 | 2013-01-14 12:37:15 -0800 | [diff] [blame] | 454 | @printf " INSTALL UTILS\n" |
| 455 | ${Q}mkdir -p $(U_DESTDIR) |
| 456 | ${Q}$(INSTALL) -t $(U_DESTDIR) $^ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 457 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 458 | ${BUILD}/utility/dump_kernel_config: LIBS += $(DUMPKERNELCONFIGLIB) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 459 | |
| 460 | # GBB utility needs C++ linker |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 461 | ${BUILD}/utility/gbb_utility: LD = $(CXX) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 462 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 463 | ${BUILD}/utility/bmpblk_utility: LD = $(CXX) |
| 464 | ${BUILD}/utility/bmpblk_utility: LDLIBS = -llzma -lyaml |
| 465 | ${BUILD}/utility/bmpblk_utility: OBJS = \ |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 466 | ${BUILD}/utility/bmpblk_util.o \ |
| 467 | ${BUILD}/utility/image_types.o \ |
Randall Spangler | 17f8d34 | 2013-01-11 10:55:11 -0800 | [diff] [blame] | 468 | ${BUILD}/utility/eficompress_for_lib.o \ |
| 469 | ${BUILD}/utility/efidecompress_for_lib.o |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 470 | |
| 471 | ${BUILD}/utility/bmpblk_font: OBJS += ${BUILD}/utility/image_types.o |
| 472 | |
| 473 | # TODO: fix load_firmware_test util; it never got refactored for the new APIs |
| 474 | |
| 475 | # ----------------------------------------------------------------------------- |
| 476 | # Mount-encrypted utility for cryptohome |
| 477 | |
| 478 | # TODO: mount-encrypted should move to cryptohome and just link against |
| 479 | # vboot-host.a for tlcl and crossystem. |
| 480 | |
| 481 | # The embedded libcrypto conflicts with the shipped openssl, |
| 482 | # so mount-* builds without the common CFLAGS (and those includes). |
| 483 | |
| 484 | ${BUILD}/utility/mount-helpers.o: \ |
| 485 | utility/mount-helpers.c \ |
| 486 | utility/mount-helpers.h \ |
| 487 | utility/mount-encrypted.h |
| 488 | @printf " CCm-e $(subst $(BUILD)/,,$(@))\n" |
| 489 | $(Q)$(CC) -Wall -Werror -O2 -D_FORTIFY_SOURCE=2 -fstack-protector \ |
| 490 | $(COV_FLAGS) \ |
| 491 | $(shell $(PKG_CONFIG) --cflags glib-2.0 openssl) \ |
| 492 | -c $< -o $@ |
| 493 | |
| 494 | ${BUILD}/utility/mount-encrypted: \ |
| 495 | utility/mount-encrypted.c \ |
| 496 | utility/mount-encrypted.h \ |
| 497 | ${BUILD}/utility/mount-helpers.o $$(LIBS) |
| 498 | @printf " CCm-exe $(subst $(BUILD)/,,$(@))\n" |
| 499 | $(Q)$(CC) -Wall -Werror -O2 -D_FORTIFY_SOURCE=2 -fstack-protector \ |
| 500 | $(shell $(PKG_CONFIG) --cflags glib-2.0 openssl) \ |
| 501 | -Ifirmware/include \ |
| 502 | -Ihost/include \ |
| 503 | $(COV_FLAGS) \ |
| 504 | $(LDFLAGS) \ |
| 505 | $< -o $@ \ |
| 506 | ${BUILD}/utility/mount-helpers.o $(LIBS) \ |
| 507 | $(shell $(PKG_CONFIG) --libs glib-2.0 openssl) \ |
| 508 | -lm |
| 509 | ifneq (${COV},) |
| 510 | $(Q)mv -f mount-encrypted.gcno ${BUILD}/utility |
| 511 | endif |
| 512 | |
| 513 | # ----------------------------------------------------------------------------- |
| 514 | # Utility to generate TLCL structure definition header file. |
| 515 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 516 | ${BUILD}/utility/tlcl_generator: CFLAGS += -fpack-struct |
| 517 | ${BUILD}/utility/tlcl_generator: LIBS = |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 518 | |
| 519 | STRUCTURES_TMP=${BUILD}/tlcl_structures.tmp |
| 520 | STRUCTURES_SRC=firmware/lib/tpm_lite/include/tlcl_structures.h |
| 521 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 522 | .PHONY: update_tlcl_structures |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 523 | update_tlcl_structures: ${BUILD}/utility/tlcl_generator |
| 524 | @printf " Rebuilding TLCL structures\n" |
| 525 | $(Q)${BUILD}/utility/tlcl_generator > $(STRUCTURES_TMP) |
| 526 | $(Q)cmp -s $(STRUCTURES_TMP) $(STRUCTURES_SRC) || \ |
| 527 | ( echo "%% Updating structures.h %%" && \ |
| 528 | cp $(STRUCTURES_TMP) $(STRUCTURES_SRC) ) |
| 529 | |
| 530 | # ----------------------------------------------------------------------------- |
| 531 | # Library to dump kernel config |
Randall Spangler | 17f8d34 | 2013-01-11 10:55:11 -0800 | [diff] [blame] | 532 | # Used by platform/installer |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 533 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 534 | .PHONY: libdump_kernel_config |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 535 | libdump_kernel_config: $(DUMPKERNELCONFIGLIB) |
| 536 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 537 | $(DUMPKERNELCONFIGLIB): ${BUILD}/utility/dump_kernel_config_lib.o |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 538 | @printf " RM $(subst $(BUILD)/,,$(@))\n" |
| 539 | $(Q)rm -f $@ |
| 540 | @printf " AR $(subst $(BUILD)/,,$(@))\n" |
| 541 | $(Q)ar qc $@ $^ |
| 542 | |
| 543 | # ----------------------------------------------------------------------------- |
| 544 | # Tests |
| 545 | |
| 546 | # Allow multiple definitions, so tests can mock functions from other libraries |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 547 | ${BUILD}/tests/%: CFLAGS += -Xlinker --allow-multiple-definition |
| 548 | ${BUILD}/tests/%: INCLUDES += -Ihost/include |
| 549 | ${BUILD}/tests/%: LDLIBS += -lrt -luuid |
| 550 | ${BUILD}/tests/%: LIBS += $(TEST_LIB) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 551 | |
| 552 | TEST_NAMES = \ |
| 553 | cgptlib_test \ |
| 554 | rollback_index2_tests \ |
| 555 | rsa_padding_test \ |
| 556 | rsa_utility_tests \ |
| 557 | rsa_verify_benchmark \ |
| 558 | sha_benchmark \ |
| 559 | sha_tests \ |
| 560 | stateful_util_tests \ |
| 561 | tpm_bootmode_tests \ |
| 562 | utility_string_tests \ |
| 563 | utility_tests \ |
| 564 | vboot_nvstorage_test \ |
| 565 | vboot_api_init_tests \ |
| 566 | vboot_api_devmode_tests \ |
| 567 | vboot_api_firmware_tests \ |
| 568 | vboot_api_kernel_tests \ |
| 569 | vboot_audio_tests \ |
| 570 | vboot_common_tests \ |
| 571 | vboot_common2_tests \ |
| 572 | vboot_common3_tests \ |
| 573 | vboot_ec_tests \ |
| 574 | vboot_firmware_tests |
| 575 | |
| 576 | ifneq ($(IN_CHROOT),) |
| 577 | TEST_NAMES += CgptManagerTests |
| 578 | endif |
| 579 | |
| 580 | TLCL_TEST_NAMES = \ |
Randall Spangler | 17f8d34 | 2013-01-11 10:55:11 -0800 | [diff] [blame] | 581 | tpmtest_earlyextend \ |
| 582 | tpmtest_earlynvram \ |
| 583 | tpmtest_earlynvram2 \ |
| 584 | tpmtest_enable \ |
| 585 | tpmtest_fastenable \ |
| 586 | tpmtest_globallock \ |
| 587 | tpmtest_redefine_unowned \ |
| 588 | tpmtest_spaceperm \ |
| 589 | tpmtest_testsetup \ |
| 590 | tpmtest_timing \ |
| 591 | tpmtest_writelimit |
| 592 | TEST_NAMES += $(addprefix tpm_lite/,$(TLCL_TEST_NAMES)) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 593 | |
| 594 | TEST_BINS = $(addprefix ${BUILD}/tests/,$(TEST_NAMES)) |
| 595 | ALL_DEPS += $(addsuffix .d,${TEST_BINS}) |
| 596 | |
Randall Spangler | 17f8d34 | 2013-01-11 10:55:11 -0800 | [diff] [blame] | 597 | .PHONY: tests |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 598 | tests: $(TEST_BINS) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 599 | |
| 600 | ${TEST_LIB}: \ |
| 601 | ${BUILD}/tests/test_common.o \ |
| 602 | ${BUILD}/tests/timer_utils.o \ |
| 603 | ${BUILD}/tests/crc32_test.o |
| 604 | @printf " RM $(subst $(BUILD)/,,$(@))\n" |
| 605 | $(Q)rm -f $@ |
| 606 | @printf " AR $(subst $(BUILD)/,,$(@))\n" |
| 607 | $(Q)ar qc $@ $^ |
| 608 | |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 609 | ${BUILD}/tests/rollback_index2_tests: OBJS += \ |
Randall Spangler | 17f8d34 | 2013-01-11 10:55:11 -0800 | [diff] [blame] | 610 | ${BUILD}/firmware/lib/rollback_index_for_test.o |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 611 | |
| 612 | ${BUILD}/tests/vboot_audio_tests: OBJS += \ |
Randall Spangler | 17f8d34 | 2013-01-11 10:55:11 -0800 | [diff] [blame] | 613 | ${BUILD}/firmware/lib/vboot_audio_for_test.o |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 614 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 615 | .PHONY: cgptmanager_tests |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 616 | cgptmanager_tests: ${BUILD}/tests/CgptManagerTests |
| 617 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 618 | ${BUILD}/tests/CgptManagerTests: CFLAGS += $(PC_CFLAGS) |
| 619 | ${BUILD}/tests/CgptManagerTests: LD = $(CXX) |
| 620 | ${BUILD}/tests/CgptManagerTests: LDLIBS += -lgtest -lgflags $(PC_LDLIBS) |
| 621 | ${BUILD}/tests/CgptManagerTests: LIBS = $(CGPTLIB) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 622 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 623 | ${BUILD}/tests/rollback_index_test: INCLUDES += -I/usr/include |
| 624 | ${BUILD}/tests/rollback_index_test: LIBS += -ltlcl |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 625 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 626 | ${BUILD}/tests/tpm_lite/tpmtest_%: OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 627 | |
| 628 | # TODO: port these tests to new API, if not already eqivalent |
| 629 | # functionality in other tests. These don't even compile at present. |
| 630 | # |
| 631 | # big_firmware_tests |
| 632 | # big_kernel_tests |
| 633 | # firmware_image_tests |
| 634 | # firmware_rollback_tests |
| 635 | # firmware_splicing_tests |
| 636 | # firmware_verify_benchmark |
| 637 | # kernel_image_tests |
| 638 | # kernel_rollback_tests |
| 639 | # kernel_splicing_tests |
| 640 | # kernel_verify_benchmark |
| 641 | # rollback_index_test |
| 642 | # verify_firmware_fuzz_driver |
| 643 | # verify_kernel_fuzz_driver |
| 644 | |
| 645 | # ----------------------------------------------------------------------------- |
| 646 | # Targets to run tests |
| 647 | |
| 648 | # Frequently-run tests |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 649 | .PHONY: runtests |
| 650 | runtests: runbmptests runcgpttests runfuzztests runmisctests |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 651 | |
| 652 | # Generate test keys |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 653 | .PHONY: genkeys |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 654 | genkeys: |
| 655 | tests/gen_test_keys.sh |
| 656 | |
| 657 | # Generate test cases for fuzzing |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 658 | .PHONY: genfuzztestcases |
Randall Spangler | a808dc9 | 2013-01-14 12:59:05 -0800 | [diff] [blame^] | 659 | genfuzztestcases: utils |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 660 | tests/gen_fuzz_test_cases.sh |
| 661 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 662 | .PHONY: runbmptests |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 663 | runbmptests: utils |
| 664 | cd tests/bitmaps && BMPBLK=${BUILD}/utility/bmpblk_utility \ |
| 665 | ./TestBmpBlock.py -v |
| 666 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 667 | .PHONY: runcgpttests |
| 668 | runcgpttests: cgpt tests |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 669 | ${BUILD}/tests/cgptlib_test |
| 670 | tests/run_cgpt_tests.sh ${BUILD}/cgpt/cgpt |
| 671 | ifneq ($(IN_CHROOT),) |
| 672 | ${BUILD}/tests/CgptManagerTests --v=1 |
| 673 | endif |
| 674 | |
| 675 | # Exercise vbutil_kernel and vbutil_firmware |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 676 | .PHONY: runfuzztests |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 677 | runfuzztests: genfuzztestcases utils tests |
| 678 | tests/run_preamble_tests.sh |
| 679 | tests/run_vbutil_kernel_arg_tests.sh |
| 680 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 681 | .PHONY: runmisctests |
| 682 | runmisctests: tests utils |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 683 | ${BUILD}/tests/rollback_index2_tests |
| 684 | ${BUILD}/tests/rsa_utility_tests |
| 685 | ${BUILD}/tests/sha_tests |
| 686 | ${BUILD}/tests/stateful_util_tests |
| 687 | ${BUILD}/tests/tpm_bootmode_tests |
| 688 | ${BUILD}/tests/utility_string_tests |
| 689 | ${BUILD}/tests/utility_tests |
| 690 | ${BUILD}/tests/vboot_api_devmode_tests |
| 691 | ${BUILD}/tests/vboot_api_init_tests |
| 692 | ${BUILD}/tests/vboot_api_firmware_tests |
| 693 | ${BUILD}/tests/vboot_audio_tests |
| 694 | ${BUILD}/tests/vboot_firmware_tests |
| 695 | tests/run_rsa_tests.sh |
| 696 | tests/run_vboot_common_tests.sh |
| 697 | tests/run_vbutil_tests.sh |
| 698 | |
| 699 | # Run long tests, including all permutations of encryption keys (instead of |
| 700 | # just the ones we use) and tests of currently-unused code (e.g. vboot_ec). |
| 701 | # Not run by automated build. |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 702 | .PHONY: runlongtests |
| 703 | runlongtests: genkeys genfuzztestcases tests utils |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 704 | tests/run_preamble_tests.sh --all |
| 705 | tests/run_vboot_common_tests.sh --all |
| 706 | tests/run_vboot_ec_tests.sh |
| 707 | tests/run_vbutil_tests.sh --all |
| 708 | |
| 709 | # TODO: tests to run when ported to new API |
| 710 | # ./run_image_verification_tests.sh |
| 711 | # # Splicing tests |
| 712 | # ${BUILD}/tests/firmware_splicing_tests |
| 713 | # ${BUILD}/tests/kernel_splicing_tests |
| 714 | # # Rollback Tests |
| 715 | # ${BUILD}/tests/firmware_rollback_tests |
| 716 | # ${BUILD}/tests/kernel_rollback_tests |
| 717 | |
| 718 | # ----------------------------------------------------------------------------- |
| 719 | # Build rules |
| 720 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 721 | ${BUILD}/%: ${BUILD}/%.o $$(OBJS) $$(LIBS) |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 722 | @printf " LD $(subst $(BUILD)/,,$(@))\n" |
| 723 | $(Q)$(LD) $(CFLAGS) $(INCLUDES) $(LDFLAGS) $< $(OBJS) -o $@ \ |
| 724 | $(LIBS) $(LDLIBS) |
| 725 | |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 726 | ${BUILD}/%.o: %.c |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 727 | @printf " CC $(subst $(BUILD)/,,$(@))\n" |
| 728 | $(Q)$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $< |
| 729 | |
Randall Spangler | 17f8d34 | 2013-01-11 10:55:11 -0800 | [diff] [blame] | 730 | # Rules to recompile a single source file for library and test |
| 731 | # TODO: is there a tidier way to do this? |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 732 | ${BUILD}/%_for_lib.o: CFLAGS += -DFOR_LIBRARY |
| 733 | ${BUILD}/%_for_lib.o: %.c |
Randall Spangler | 17f8d34 | 2013-01-11 10:55:11 -0800 | [diff] [blame] | 734 | @printf " CC-for-lib $(subst $(BUILD)/,,$(@))\n" |
| 735 | $(Q)$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $< |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 736 | ${BUILD}/%_for_test.o: CFLAGS += -DFOR_TEST |
| 737 | ${BUILD}/%_for_test.o: %.c |
Randall Spangler | 17f8d34 | 2013-01-11 10:55:11 -0800 | [diff] [blame] | 738 | @printf " CC-for-test $(subst $(BUILD)/,,$(@))\n" |
| 739 | $(Q)$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $< |
| 740 | |
| 741 | # TODO: C++ files don't belong in vboot reference at all. Convert to C. |
Bill Richardson | acb2ee9 | 2013-01-11 22:53:00 -0800 | [diff] [blame] | 742 | ${BUILD}/%.o: %.cc |
Randall Spangler | 5d9bbf2 | 2013-01-08 10:44:23 -0800 | [diff] [blame] | 743 | @printf " CXX $(subst $(BUILD)/,,$(@))\n" |
| 744 | $(Q)$(CXX) $(CFLAGS) $(INCLUDES) -c -o $@ $< |
| 745 | |
| 746 | # ----------------------------------------------------------------------------- |
| 747 | # Dependencies must come last after ALL_OBJS has been accumulated |
| 748 | |
| 749 | # TODO: I suspect this is missing some object files. Make a temp |
| 750 | # target which cleans all known obj/exe's and see what's left; those |
| 751 | # are the files which need deps. |
| 752 | |
| 753 | ALL_DEPS += $(ALL_OBJS:%.o=%.o.d) |
| 754 | |
| 755 | -include ${ALL_DEPS} |