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