blob: 6752f55a2f8dd2538f81e5f5f9917e59ac327a0b [file] [log] [blame]
Randall Spanglere8cfa312013-01-02 16:49:38 -08001# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
Gaurav Shah322536d2010-01-28 15:01:23 -08002# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
Gabe Black0aedbe12012-12-20 00:26:59 -08005ifneq ($(V),1)
6Q := @
7endif
8
Simon Glass6d696e52011-11-14 13:46:33 -08009# This Makefile normally builds in a 'build' subdir, but use
10#
11# make BUILD=<dir>
12#
13# to put the output somewhere else
Randall Spangler5d9bbf22013-01-08 10:44:23 -080014BUILD ?= $(shell pwd)/build
Randall Spangler844bce52013-01-15 16:16:43 -080015export BUILD
Simon Glass6d696e52011-11-14 13:46:33 -080016
Randall Spangler5d9bbf22013-01-08 10:44:23 -080017# Target for 'make install'
18DESTDIR ?= /usr/bin
Bill Richardson826db092013-01-14 12:37:15 -080019INSTALL ?= install
Randall Spangler5d9bbf22013-01-08 10:44:23 -080020
Simon Glassb265c342011-11-16 15:09:51 -080021# Provide default CC and CFLAGS for firmware builds; if you have any -D flags,
22# please add them after this point (e.g., -DVBOOT_DEBUG).
Che-Liang Chiou74359b72011-06-21 15:25:51 -070023#
Che-Liang Chiou6b0003c2011-10-14 11:11:28 +080024# TODO(crosbug.com/16808) We hard-code u-boot's compiler flags here just
25# temporarily. As we are still investigating which flags are necessary for
26# maintaining a compatible ABI, etc. between u-boot and vboot_reference.
Che-Liang Chiou74359b72011-06-21 15:25:51 -070027#
Simon Glassb265c342011-11-16 15:09:51 -080028# As a first step, this makes the setting of CC and CFLAGS here optional, to
29# permit a calling script or Makefile to set these.
Che-Liang Chiou74359b72011-06-21 15:25:51 -070030#
Simon Glassb265c342011-11-16 15:09:51 -080031# Flag ordering: arch, then -f, then -m, then -W
32DEBUG_FLAGS := $(if ${DEBUG},-g -O0,-Os)
33COMMON_FLAGS := -nostdinc -pipe \
34 -ffreestanding -fno-builtin -fno-stack-protector \
35 -Werror -Wall -Wstrict-prototypes $(DEBUG_FLAGS)
36
Che-Liang Chiou7604a7d2011-06-21 17:40:34 -070037ifeq ($(FIRMWARE_ARCH), arm)
Simon Glassb265c342011-11-16 15:09:51 -080038CC ?= armv7a-cros-linux-gnueabi-gcc
39CFLAGS ?= -march=armv5 \
40 -fno-common -ffixed-r8 \
Doug Andersond50b27d2012-05-11 12:08:02 -070041 -mfloat-abi=hard -marm -mabi=aapcs-linux -mno-thumb-interwork \
Simon Glassb265c342011-11-16 15:09:51 -080042 $(COMMON_FLAGS)
Randall Spangler844bce52013-01-15 16:16:43 -080043else ifeq ($(FIRMWARE_ARCH), i386)
Simon Glassb265c342011-11-16 15:09:51 -080044CC ?= i686-pc-linux-gnu-gcc
45# Drop -march=i386 to permit use of SSE instructions
46CFLAGS ?= \
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)
Randall Spangler844bce52013-01-15 16:16:43 -080051else ifeq ($(FIRMWARE_ARCH), x86_64)
Simon Glass8e85e982011-11-22 13:54:50 -080052CFLAGS ?= $(COMMON_FLAGS) \
53 -fvisibility=hidden -fno-strict-aliasing -fomit-frame-pointer
Randall Spangler844bce52013-01-15 16:16:43 -080054else
55$(info FIRMWARE_ARCH not defined; assuming local compile.)
Simon Glass8e85e982011-11-22 13:54:50 -080056endif
Che-Liang Chiou34be8272011-01-27 16:44:36 +080057
Randall Spangler844bce52013-01-15 16:16:43 -080058# Architecture detection
59HOST_ARCH ?= $(shell uname -m)
60
61# Pick a sane target architecture if none defined (building outside emake)
Randall Spangler287beae2011-04-11 12:46:40 -070062ifeq ($(ARCH),)
Randall Spangler844bce52013-01-15 16:16:43 -080063 ARCH := $(HOST_ARCH)
64 ifeq ($(ARCH), x86_64)
65 ARCH := amd64
66 endif
67endif
68
69# Determine QEMU architecture needed, if any
70ifeq ($(ARCH),$(HOST_ARCH))
71 # Same architecture; no need for QEMU
72 QEMU_ARCH :=
73else ifeq ($(HOST_ARCH)-$(ARCH),x86_64-i386)
74 # 64-bit host can run 32-bit targets directly
75 QEMU_ARCH :=
76else ifeq ($(HOST_ARCH)-$(ARCH),x86_64-amd64)
77 # 64-bit host can run 64-bit directly
78 QEMU_ARCH :=
79else ifeq ($(ARCH),amd64)
80 QEMU_ARCH := x86_64
81else
82 QEMU_ARCH := $(ARCH)
83endif
84
85# The top of the chroot for qemu must be passed in via the SYSROOT environment
86# variable. In the Chromium OS chroot, this is done automatically by the
87# ebuild.
88
89# If SYSROOT is not defined, disable QEMU testing
90# TODO: which probably means attempting to test should simply fail
91ifneq ($(QEMU_ARCH),)
92 ifeq ($(SYSROOT),)
93 $(warning SYSROOT must be set to the top of the target-specific root \
94when cross-compiling for qemu-based tests to run properly.)
95 QEMU_ARCH :=
96 endif
97endif
98
99ifeq ($(QEMU_ARCH),)
100 # Path to build output for running tests is same as for building
101 BUILD_RUN = $(BUILD)
102else
103 $(info Using qemu for testing.)
104 # Path to build output for running tests is different in the chroot
105 BUILD_RUN = $(subst $(SYSROOT),,$(BUILD))
106
107 QEMU_BIN = qemu-$(QEMU_ARCH)
108 QEMU_OPTS = -drop-ld-preload \
109 -E LD_LIBRARY_PATH=/lib64:/lib:/usr/lib64:/usr/lib \
110 -E HOME=$(HOME) \
111 -E BUILD=$(BUILD_RUN)
112 QEMU_CMD = sudo chroot $(SYSROOT) $(BUILD_RUN)/$(QEMU_BIN) $(QEMU_OPTS) --
113 RUNTEST = $(QEMU_CMD)
Randall Spangler287beae2011-04-11 12:46:40 -0700114endif
115
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800116# Some things only compile inside the Chromium OS chroot
117# TODO: is there a better way to detect this?
118ifneq ($(CROS_WORKON_SRCROOT),)
119IN_CHROOT = 1
120endif
121
122CC ?= gcc
123CXX ?= g++
124LD = $(CC)
125PKG_CONFIG ?= pkg-config
126
Che-Liang Chiou34be8272011-01-27 16:44:36 +0800127ifeq ($(FIRMWARE_ARCH),)
Bill Richardsonf4729192012-05-02 23:30:16 -0700128CFLAGS += -DCHROMEOS_ENVIRONMENT -Wall -Werror
Che-Liang Chiou34be8272011-01-27 16:44:36 +0800129endif
130
131ifneq (${DEBUG},)
132CFLAGS += -DVBOOT_DEBUG
vbendebb2b0fcc2010-07-15 15:09:47 -0700133endif
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +0800134
vbendebb2b0fcc2010-07-15 15:09:47 -0700135ifeq (${DISABLE_NDEBUG},)
136CFLAGS += -DNDEBUG
137endif
138
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800139# Create / use dependency files
140CFLAGS += -MMD -MF $@.d
Simon Glassb265c342011-11-16 15:09:51 -0800141
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800142# Code coverage
Randall Spangler844bce52013-01-15 16:16:43 -0800143# Run like this: COV=1 make runtests coverage
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800144ifneq (${COV},)
145#COV_FLAGS = -O0 -fprofile-arcs -ftest-coverage
146COV_FLAGS = -O0 --coverage
147CFLAGS += $(COV_FLAGS)
148LDFLAGS += $(COV_FLAGS)
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +0800149endif
Gaurav Shah322536d2010-01-28 15:01:23 -0800150
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800151INCLUDES += \
152 -Ifirmware/include \
153 -Ifirmware/lib/include \
154 -Ifirmware/lib/cgptlib/include \
155 -Ifirmware/lib/cryptolib/include \
156 -Ifirmware/lib/tpm_lite/include
Bill Richardson0b8f35c2010-05-26 09:18:38 -0700157
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +0800158ifeq ($(FIRMWARE_ARCH),)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800159INCLUDES += -Ifirmware/stub/include
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +0800160else
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800161INCLUDES += -Ifirmware/arch/$(FIRMWARE_ARCH)/include
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +0800162endif
Gaurav Shah322536d2010-01-28 15:01:23 -0800163
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800164# Output libraries
165CGPTLIB := ${BUILD}/cgpt/libcgpt-cc.a
166DUMPKERNELCONFIGLIB := ${BUILD}/libdump_kernel_config.a
167FWLIB := ${BUILD}/vboot_fw.a
168HOSTLIB := ${BUILD}/vboot_host.a
169TEST_LIB := ${BUILD}/tests/test.a
Gaurav Shah322536d2010-01-28 15:01:23 -0800170
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800171CRYPTO_LIBS := $(shell $(PKG_CONFIG) --libs libcrypto)
Jay Srinivasan5fac7572012-02-23 10:59:01 -0800172
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800173ifneq ($(IN_CHROOT),)
174PC_BASE_VER ?= 125070
175PC_DEPS = libchrome-$(PC_BASE_VER)
176PC_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(PC_DEPS))
177PC_LDLIBS := $(shell $(PKG_CONFIG) --libs $(PC_DEPS))
178endif
Jay Srinivasan5fac7572012-02-23 10:59:01 -0800179
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800180# Link with hostlib and crypto libs by default
181LIBS = $(HOSTLIB)
182LDLIBS = $(CRYPTO_LIBS)
183
184# Create output directories if necessary. Do this via explicit shell commands
185# so it happens before trying to generate/include dependencies.
186SUBDIRS := firmware host utility cgpt tests tests/tpm_lite
187_dir_create := $(foreach d, \
188 $(shell find $(SUBDIRS) -name '*.c' -exec dirname {} \; | sort -u), \
189 $(shell [ -d $(BUILD)/$(d) ] || mkdir -p $(BUILD)/$(d)))
190
191# First target
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800192.PHONY: all
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800193all: fwlib $(if $(FIRMWARE_ARCH),,host_stuff)
194
195# Host targets
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800196.PHONY: host_stuff
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800197host_stuff: fwlib hostlib cgpt utils tests
Jay Srinivasan250549d2012-02-16 17:40:45 -0800198
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800199.PHONY: clean
Gaurav Shah322536d2010-01-28 15:01:23 -0800200clean:
Gabe Black0aedbe12012-12-20 00:26:59 -0800201 $(Q)/bin/rm -rf ${BUILD}
Bill Richardson371df8b2010-05-27 14:19:47 -0700202
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800203.PHONY: install
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800204install: cgpt_install utils_install
Gaurav Shahe6421982010-06-03 07:49:32 -0700205
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800206# Coverage
Randall Spangler844bce52013-01-15 16:16:43 -0800207# TODO: only if COV=1
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800208COV_INFO = $(BUILD)/coverage.info
209#coverage: runtests
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800210.PHONY: coverage
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800211coverage:
212 rm -f $(COV_INFO)*
213 lcov --capture --directory . --base-directory . -o $(COV_INFO).1
214 lcov --remove $(COV_INFO).1 '/usr/*' -o $(COV_INFO)
215 genhtml $(COV_INFO) --output-directory $(BUILD)/coverage
Luigi Semenzato18b814d2010-07-08 17:17:02 -0700216
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800217# Don't delete intermediate object files
218.SECONDARY:
Randall Spanglere8cfa312013-01-02 16:49:38 -0800219
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800220# Use second expansion phase for $$(LIBS) so dependencies on libraries are
221# properly evaluated for implicit rules.
222.SECONDEXPANSION:
Jay Srinivasan250549d2012-02-16 17:40:45 -0800223
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800224# -----------------------------------------------------------------------------
225# Firmware library
Bill Richardson856e0722011-02-07 15:39:45 -0800226
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800227# TPM-specific flags. These depend on the particular TPM we're targeting for.
228# They are needed here only for compiling parts of the firmware code into
229# user-level tests.
230
231# TPM_BLOCKING_CONTINUESELFTEST is defined if TPM_ContinueSelfTest blocks until
232# the self test has completed.
233
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800234$(FWLIB): CFLAGS += -DTPM_BLOCKING_CONTINUESELFTEST
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800235
236# TPM_MANUAL_SELFTEST is defined if the self test must be started manually
237# (with a call to TPM_ContinueSelfTest) instead of starting automatically at
238# power on.
239#
240# We sincerely hope that TPM_BLOCKING_CONTINUESELFTEST and TPM_MANUAL_SELFTEST
241# are not both defined at the same time. (See comment in code.)
242
243# CFLAGS += -DTPM_MANUAL_SELFTEST
244
245ifeq ($(FIRMWARE_ARCH),i386)
246# Unrolling loops in cryptolib makes it faster
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800247$(FWLIB): CFLAGS += -DUNROLL_LOOPS
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800248
249# Workaround for coreboot on x86, which will power off asynchronously
250# without giving us a chance to react. This is not an example of the Right
251# Way to do things. See chrome-os-partner:7689, and the commit message
252# that made this change.
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800253$(FWLIB): CFLAGS += -DSAVE_LOCALE_IMMEDIATELY
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800254
255# On x86 we don't actually read the GBB data into RAM until it is needed.
256# Therefore it makes sense to cache it rather than reading it each time.
257# Enable this feature.
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800258$(FWLIB): CFLAGS += -DCOPY_BMP_DATA
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800259endif
260
261ifeq ($(FIRMWARE_ARCH),)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800262# Disable rollback TPM when compiling locally, since otherwise
263# load_kernel_test attempts to talk to the TPM.
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800264$(FWLIB): CFLAGS += -DDISABLE_ROLLBACK_TPM
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800265endif
266
267# find lib -iname '*.c' | sort
268FWLIB_SRCS = \
269 firmware/lib/cgptlib/cgptlib.c \
270 firmware/lib/cgptlib/cgptlib_internal.c \
271 firmware/lib/cgptlib/crc32.c \
272 firmware/lib/crc8.c \
273 firmware/lib/cryptolib/padding.c \
274 firmware/lib/cryptolib/rsa.c \
275 firmware/lib/cryptolib/rsa_utility.c \
276 firmware/lib/cryptolib/sha1.c \
277 firmware/lib/cryptolib/sha256.c \
278 firmware/lib/cryptolib/sha512.c \
279 firmware/lib/cryptolib/sha_utility.c \
280 firmware/lib/stateful_util.c \
281 firmware/lib/utility.c \
282 firmware/lib/utility_string.c \
283 firmware/lib/vboot_api_init.c \
284 firmware/lib/vboot_api_firmware.c \
285 firmware/lib/vboot_api_kernel.c \
286 firmware/lib/vboot_audio.c \
287 firmware/lib/vboot_common.c \
288 firmware/lib/vboot_display.c \
289 firmware/lib/vboot_firmware.c \
290 firmware/lib/vboot_kernel.c \
291 firmware/lib/vboot_nvstorage.c
292
293ifeq ($(MOCK_TPM),)
294FWLIB_SRCS += \
295 firmware/lib/rollback_index.c \
296 firmware/lib/tpm_bootmode.c \
297 firmware/lib/tpm_lite/tlcl.c
298else
299FWLIB_SRCS += \
300 firmware/lib/mocked_rollback_index.c \
301 firmware/lib/mocked_tpm_bootmode.c \
302 firmware/lib/tpm_lite/mocked_tlcl.c
303endif
304
305ifeq ($(FIRMWARE_ARCH),)
306# Include stub into firmware lib if compiling for host
307FWLIB_SRCS += \
308 firmware/stub/tpm_lite_stub.c \
309 firmware/stub/utility_stub.c \
310 firmware/stub/vboot_api_stub.c \
311 firmware/stub/vboot_api_stub_disk.c
312endif
313
314FWLIB_OBJS = $(FWLIB_SRCS:%.c=${BUILD}/%.o)
315ALL_OBJS += ${FWLIB_OBJS}
316
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800317.PHONY: fwlib
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800318ifeq ($(FIRMWARE_ARCH),)
319# Link test ensures firmware lib doesn't rely on outside libraries
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800320${BUILD}/firmware/linktest/main: LIBS = $(FWLIB)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800321
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800322fwlib: ${BUILD}/firmware/linktest/main
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800323else
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800324fwlib: $(FWLIB)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800325endif
326
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800327$(FWLIB): $(FWLIB_OBJS)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800328 @printf " RM $(subst $(BUILD)/,,$(@))\n"
329 $(Q)rm -f $@
330 @printf " AR $(subst $(BUILD)/,,$(@))\n"
331 $(Q)ar qc $@ $^
332
333# -----------------------------------------------------------------------------
334# Host library
335
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800336.PHONY: hostlib
337hostlib: $(HOSTLIB) ${BUILD}/host/linktest/main
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800338
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800339${BUILD}/host/% ${HOSTLIB}: INCLUDES += \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800340 -Ihost/include\
341 -Ihost/arch/$(ARCH)/include
342
343HOSTLIB_SRCS = \
344 host/arch/$(ARCH)/lib/crossystem_arch.c \
345 host/lib/crossystem.c \
346 host/lib/file_keys.c \
347 host/lib/fmap.c \
348 host/lib/host_common.c \
349 host/lib/host_key.c \
350 host/lib/host_keyblock.c \
351 host/lib/host_misc.c \
352 host/lib/host_signature.c \
353 host/lib/signature_digest.c
354
355HOSTLIB_OBJS = $(HOSTLIB_SRCS:%.c=${BUILD}/%.o)
356ALL_OBJS += ${HOSTLIB_OBJS}
357
358# TODO: better way to make .a than duplicating this recipe each time?
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800359$(HOSTLIB): $(HOSTLIB_OBJS) $(FWLIB_OBJS)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800360 @printf " RM $(subst $(BUILD)/,,$(@))\n"
361 $(Q)rm -f $@
362 @printf " AR $(subst $(BUILD)/,,$(@))\n"
363 $(Q)ar qc $@ $^
364
365# -----------------------------------------------------------------------------
366# CGPT library and utility
367
368CGPT = ${BUILD}/cgpt/cgpt
369
370CGPT_SRCS = \
371 cgpt/cgpt.c \
372 cgpt/cgpt_add.c \
373 cgpt/cgpt_boot.c \
374 cgpt/cgpt_common.c \
375 cgpt/cgpt_create.c \
376 cgpt/cgpt_find.c \
377 cgpt/cgpt_legacy.c \
378 cgpt/cgpt_prioritize.c \
379 cgpt/cgpt_repair.c \
380 cgpt/cgpt_show.c \
381 cgpt/cmd_add.c \
382 cgpt/cmd_boot.c \
383 cgpt/cmd_create.c \
384 cgpt/cmd_find.c \
385 cgpt/cmd_legacy.c \
386 cgpt/cmd_prioritize.c \
387 cgpt/cmd_repair.c \
388 cgpt/cmd_show.c
389
390CGPT_OBJS = $(CGPT_SRCS:%.c=${BUILD}/%.o)
391ALL_OBJS += ${CGPT_OBJS}
392
393# TODO: why not make this include *all* the cgpt files, and simply have
394# cgpt link against it?
395# TODO: CgptManager.cc should move to the installer project. Shouldn't be
396# in libcgpt-cc.a.
397CGPTLIB_SRCS = \
398 cgpt/CgptManager.cc \
399 cgpt/cgpt_create.c \
400 cgpt/cgpt_add.c \
401 cgpt/cgpt_boot.c \
402 cgpt/cgpt_show.c \
403 cgpt/cgpt_repair.c \
404 cgpt/cgpt_prioritize.c \
405 cgpt/cgpt_common.c \
406 firmware/lib/cgptlib/crc32.c \
407 firmware/lib/cgptlib/cgptlib_internal.c \
408 firmware/stub/utility_stub.c
409
410CGPTLIB_OBJS = $(filter %.o, \
411 $(CGPTLIB_SRCS:%.c=${BUILD}/%.o) \
412 $(CGPTLIB_SRCS:%.cc=${BUILD}/%.o))
413ALL_OBJS += $(CGPTLIB_OBJS)
414
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800415.PHONY: cgpt
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800416cgpt: $(CGPT)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800417
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800418.PHONY: libcgpt_cc
419libcgpt_cc: $(CGPTLIB)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800420
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800421$(CGPTLIB): INCLUDES += -Ifirmware/lib/cgptlib/include
422$(CGPTLIB): $(CGPTLIB_OBJS)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800423 @printf " RM $(subst $(BUILD)/,,$(@))\n"
424 $(Q)rm -f $@
425 @printf " AR $(subst $(BUILD)/,,$(@))\n"
426 $(Q)ar qc $@ $^
427
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800428$(CGPT): INCLUDES += -Ifirmware/lib/cgptlib/include
429$(CGPT): LDLIBS = -luuid
430$(CGPT): LDFLAGS += -static
431$(CGPT): $(CGPT_OBJS) $$(LIBS)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800432 @printf " LDcgpt $(subst $(BUILD)/,,$(@))\n"
433 $(Q)$(LD) -o $(CGPT) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) $(LDLIBS)
434
Bill Richardson826db092013-01-14 12:37:15 -0800435C_DESTDIR = $(DESTDIR)
436
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800437.PHONY: cgpt_install
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800438cgpt_install: $(CGPT)
Bill Richardson826db092013-01-14 12:37:15 -0800439 @printf " INSTALL CGPT\n"
440 ${Q}mkdir -p $(C_DESTDIR)
441 ${Q}$(INSTALL) -t $(C_DESTDIR) $^
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800442
443# -----------------------------------------------------------------------------
444# Utilities
445
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800446${BUILD}/utility/%: INCLUDES += -Ihost/include -Iutility/include
447${BUILD}/utility/%: CFLAGS += $(PC_CFLAGS)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800448
449AU_NAMES = \
450 crossystem \
451 dump_fmap \
452 gbb_utility
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800453AU_BINS:= $(addprefix ${BUILD}/utility/,$(AU_NAMES))
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800454
455# Utilities for auto-update toolkits must be statically linked, and don't
456# use the crypto libs.
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800457${AU_BINS}: LDFLAGS += -static
458${AU_BINS}: CRYPTO_LIBS =
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800459
460# Scripts to install
461UTIL_SCRIPTS = \
462 utility/dev_debug_vboot \
463 utility/dev_make_keypair \
464 utility/enable_dev_usb_boot \
465 utility/vbutil_what_keys
466
467UTIL_NAMES = $(AU_NAMES) \
468 dev_sign_file \
469 dump_kernel_config \
470 dumpRSAPublicKey \
471 load_kernel_test \
472 pad_digest_utility \
473 signature_digest_utility \
474 tpm_init_temp_fix \
475 tpmc \
476 vbutil_ec \
477 vbutil_firmware \
478 vbutil_kernel \
479 vbutil_key \
480 vbutil_keyblock \
481 verify_data
482
483ifneq ($(IN_CHROOT),)
484UTIL_NAMES += mount-encrypted
485endif
486
487ifeq ($(MINIMAL),)
488UTIL_NAMES += \
489 bmpblk_font \
490 bmpblk_utility \
491 eficompress \
492 efidecompress
493endif
494
495UTIL_BINS = $(addprefix ${BUILD}/utility/,$(UTIL_NAMES))
496ALL_DEPS += $(addsuffix .d,${UTIL_BINS})
497
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800498.PHONY: utils
499utils: $(UTIL_BINS) $(UTIL_SCRIPTS)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800500# TODO: change ebuild to pull scripts directly out of utility dir
501 $(Q)cp -f $(UTIL_SCRIPTS) $(BUILD)/utility
502 $(Q)chmod a+rx $(patsubst %,$(BUILD)/%,$(UTIL_SCRIPTS))
503
Bill Richardson826db092013-01-14 12:37:15 -0800504U_DESTDIR = $(DESTDIR)
505
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800506.PHONY: utils_install
507utils_install: $(UTIL_BINS) $(UTIL_SCRIPTS)
Bill Richardson826db092013-01-14 12:37:15 -0800508 @printf " INSTALL UTILS\n"
509 ${Q}mkdir -p $(U_DESTDIR)
510 ${Q}$(INSTALL) -t $(U_DESTDIR) $^
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800511
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800512${BUILD}/utility/dump_kernel_config: LIBS += $(DUMPKERNELCONFIGLIB)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800513
514# GBB utility needs C++ linker
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800515${BUILD}/utility/gbb_utility: LD = $(CXX)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800516
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800517${BUILD}/utility/bmpblk_utility: LD = $(CXX)
518${BUILD}/utility/bmpblk_utility: LDLIBS = -llzma -lyaml
519${BUILD}/utility/bmpblk_utility: OBJS = \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800520 ${BUILD}/utility/bmpblk_util.o \
521 ${BUILD}/utility/image_types.o \
Randall Spangler17f8d342013-01-11 10:55:11 -0800522 ${BUILD}/utility/eficompress_for_lib.o \
523 ${BUILD}/utility/efidecompress_for_lib.o
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800524
525${BUILD}/utility/bmpblk_font: OBJS += ${BUILD}/utility/image_types.o
526
527# TODO: fix load_firmware_test util; it never got refactored for the new APIs
528
529# -----------------------------------------------------------------------------
530# Mount-encrypted utility for cryptohome
531
532# TODO: mount-encrypted should move to cryptohome and just link against
533# vboot-host.a for tlcl and crossystem.
534
535# The embedded libcrypto conflicts with the shipped openssl,
536# so mount-* builds without the common CFLAGS (and those includes).
537
538${BUILD}/utility/mount-helpers.o: \
539 utility/mount-helpers.c \
540 utility/mount-helpers.h \
541 utility/mount-encrypted.h
542 @printf " CCm-e $(subst $(BUILD)/,,$(@))\n"
543 $(Q)$(CC) -Wall -Werror -O2 -D_FORTIFY_SOURCE=2 -fstack-protector \
544 $(COV_FLAGS) \
545 $(shell $(PKG_CONFIG) --cflags glib-2.0 openssl) \
546 -c $< -o $@
547
548${BUILD}/utility/mount-encrypted: \
549 utility/mount-encrypted.c \
550 utility/mount-encrypted.h \
551 ${BUILD}/utility/mount-helpers.o $$(LIBS)
552 @printf " CCm-exe $(subst $(BUILD)/,,$(@))\n"
553 $(Q)$(CC) -Wall -Werror -O2 -D_FORTIFY_SOURCE=2 -fstack-protector \
554 $(shell $(PKG_CONFIG) --cflags glib-2.0 openssl) \
555 -Ifirmware/include \
556 -Ihost/include \
557 $(COV_FLAGS) \
558 $(LDFLAGS) \
559 $< -o $@ \
560 ${BUILD}/utility/mount-helpers.o $(LIBS) \
561 $(shell $(PKG_CONFIG) --libs glib-2.0 openssl) \
562 -lm
563ifneq (${COV},)
564 $(Q)mv -f mount-encrypted.gcno ${BUILD}/utility
565endif
566
567# -----------------------------------------------------------------------------
568# Utility to generate TLCL structure definition header file.
569
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800570${BUILD}/utility/tlcl_generator: CFLAGS += -fpack-struct
571${BUILD}/utility/tlcl_generator: LIBS =
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800572
573STRUCTURES_TMP=${BUILD}/tlcl_structures.tmp
574STRUCTURES_SRC=firmware/lib/tpm_lite/include/tlcl_structures.h
575
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800576.PHONY: update_tlcl_structures
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800577update_tlcl_structures: ${BUILD}/utility/tlcl_generator
578 @printf " Rebuilding TLCL structures\n"
579 $(Q)${BUILD}/utility/tlcl_generator > $(STRUCTURES_TMP)
580 $(Q)cmp -s $(STRUCTURES_TMP) $(STRUCTURES_SRC) || \
581 ( echo "%% Updating structures.h %%" && \
582 cp $(STRUCTURES_TMP) $(STRUCTURES_SRC) )
583
584# -----------------------------------------------------------------------------
585# Library to dump kernel config
Randall Spangler17f8d342013-01-11 10:55:11 -0800586# Used by platform/installer
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800587
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800588.PHONY: libdump_kernel_config
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800589libdump_kernel_config: $(DUMPKERNELCONFIGLIB)
590
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800591$(DUMPKERNELCONFIGLIB): ${BUILD}/utility/dump_kernel_config_lib.o
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800592 @printf " RM $(subst $(BUILD)/,,$(@))\n"
593 $(Q)rm -f $@
594 @printf " AR $(subst $(BUILD)/,,$(@))\n"
595 $(Q)ar qc $@ $^
596
597# -----------------------------------------------------------------------------
598# Tests
599
600# Allow multiple definitions, so tests can mock functions from other libraries
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800601${BUILD}/tests/%: CFLAGS += -Xlinker --allow-multiple-definition
602${BUILD}/tests/%: INCLUDES += -Ihost/include
603${BUILD}/tests/%: LDLIBS += -lrt -luuid
604${BUILD}/tests/%: LIBS += $(TEST_LIB)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800605
606TEST_NAMES = \
607 cgptlib_test \
608 rollback_index2_tests \
609 rsa_padding_test \
610 rsa_utility_tests \
611 rsa_verify_benchmark \
612 sha_benchmark \
613 sha_tests \
614 stateful_util_tests \
615 tpm_bootmode_tests \
616 utility_string_tests \
617 utility_tests \
618 vboot_nvstorage_test \
619 vboot_api_init_tests \
620 vboot_api_devmode_tests \
621 vboot_api_firmware_tests \
622 vboot_api_kernel_tests \
623 vboot_audio_tests \
624 vboot_common_tests \
625 vboot_common2_tests \
626 vboot_common3_tests \
627 vboot_ec_tests \
628 vboot_firmware_tests
629
630ifneq ($(IN_CHROOT),)
631TEST_NAMES += CgptManagerTests
632endif
633
634TLCL_TEST_NAMES = \
Randall Spangler17f8d342013-01-11 10:55:11 -0800635 tpmtest_earlyextend \
636 tpmtest_earlynvram \
637 tpmtest_earlynvram2 \
638 tpmtest_enable \
639 tpmtest_fastenable \
640 tpmtest_globallock \
641 tpmtest_redefine_unowned \
642 tpmtest_spaceperm \
643 tpmtest_testsetup \
644 tpmtest_timing \
645 tpmtest_writelimit
646TEST_NAMES += $(addprefix tpm_lite/,$(TLCL_TEST_NAMES))
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800647
648TEST_BINS = $(addprefix ${BUILD}/tests/,$(TEST_NAMES))
649ALL_DEPS += $(addsuffix .d,${TEST_BINS})
650
Randall Spangler17f8d342013-01-11 10:55:11 -0800651.PHONY: tests
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800652tests: $(TEST_BINS)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800653
654${TEST_LIB}: \
655 ${BUILD}/tests/test_common.o \
656 ${BUILD}/tests/timer_utils.o \
657 ${BUILD}/tests/crc32_test.o
658 @printf " RM $(subst $(BUILD)/,,$(@))\n"
659 $(Q)rm -f $@
660 @printf " AR $(subst $(BUILD)/,,$(@))\n"
661 $(Q)ar qc $@ $^
662
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800663${BUILD}/tests/rollback_index2_tests: OBJS += \
Randall Spangler17f8d342013-01-11 10:55:11 -0800664 ${BUILD}/firmware/lib/rollback_index_for_test.o
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800665
666${BUILD}/tests/vboot_audio_tests: OBJS += \
Randall Spangler17f8d342013-01-11 10:55:11 -0800667 ${BUILD}/firmware/lib/vboot_audio_for_test.o
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800668
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800669.PHONY: cgptmanager_tests
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800670cgptmanager_tests: ${BUILD}/tests/CgptManagerTests
671
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800672${BUILD}/tests/CgptManagerTests: CFLAGS += $(PC_CFLAGS)
673${BUILD}/tests/CgptManagerTests: LD = $(CXX)
674${BUILD}/tests/CgptManagerTests: LDLIBS += -lgtest -lgflags $(PC_LDLIBS)
675${BUILD}/tests/CgptManagerTests: LIBS = $(CGPTLIB)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800676
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800677${BUILD}/tests/rollback_index_test: INCLUDES += -I/usr/include
678${BUILD}/tests/rollback_index_test: LIBS += -ltlcl
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800679
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800680${BUILD}/tests/tpm_lite/tpmtest_%: OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800681
682# TODO: port these tests to new API, if not already eqivalent
683# functionality in other tests. These don't even compile at present.
684#
685# big_firmware_tests
686# big_kernel_tests
687# firmware_image_tests
688# firmware_rollback_tests
689# firmware_splicing_tests
690# firmware_verify_benchmark
691# kernel_image_tests
692# kernel_rollback_tests
693# kernel_splicing_tests
694# kernel_verify_benchmark
695# rollback_index_test
696# verify_firmware_fuzz_driver
697# verify_kernel_fuzz_driver
698
699# -----------------------------------------------------------------------------
700# Targets to run tests
701
702# Frequently-run tests
Randall Spangler844bce52013-01-15 16:16:43 -0800703TEST_TARGETS = runcgpttests runmisctests
704
705ifeq ($(MINIMAL),)
706# Bitmap utility isn't compiled for minimal variant
707TEST_TARGETS += runbmptests
708# Scripts don't work under qemu testing
709# TODO: convert scripts to makefile so they can be called directly
710TEST_TARGETS += runtestscripts
711endif
712
713# Qemu setup for cross-compiled tests. Need to copy qemu binary into the
714# sysroot.
715ifneq ($(QEMU_ARCH),)
716TEST_SETUP += qemu_install
717
718.PHONY: qemu_install
719qemu_install:
720 @printf " Copying qemu binary.\n"
721 $(Q)cp -fu /usr/bin/$(QEMU_BIN) $(BUILD)/$(QEMU_BIN)
722 $(Q)chmod a+rx $(BUILD)/$(QEMU_BIN)
723endif
724
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800725.PHONY: runtests
Randall Spangler844bce52013-01-15 16:16:43 -0800726runtests: $(TEST_TARGETS)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800727
728# Generate test keys
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800729.PHONY: genkeys
Randall Spangler844bce52013-01-15 16:16:43 -0800730genkeys: utils
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800731 tests/gen_test_keys.sh
732
733# Generate test cases for fuzzing
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800734.PHONY: genfuzztestcases
Randall Spanglera808dc92013-01-14 12:59:05 -0800735genfuzztestcases: utils
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800736 tests/gen_fuzz_test_cases.sh
737
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800738.PHONY: runbmptests
Randall Spangler844bce52013-01-15 16:16:43 -0800739runbmptests: $(TEST_SETUP) utils
740 cd tests/bitmaps && BMPBLK=$(BUILD_RUN)/utility/bmpblk_utility \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800741 ./TestBmpBlock.py -v
742
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800743.PHONY: runcgpttests
Randall Spangler844bce52013-01-15 16:16:43 -0800744runcgpttests: $(TEST_SETUP) cgpt tests
745 $(RUNTEST) $(BUILD_RUN)/tests/cgptlib_test
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800746ifneq ($(IN_CHROOT),)
Randall Spangler844bce52013-01-15 16:16:43 -0800747 $(RUNTEST) $(BUILD_RUN)/tests/CgptManagerTests --v=1
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800748endif
749
Randall Spangler844bce52013-01-15 16:16:43 -0800750.PHONY: runtestscripts
751runtestscripts: $(TEST_SETUP) genfuzztestcases utils tests
752 tests/run_cgpt_tests.sh $(BUILD_RUN)/cgpt/cgpt
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800753 tests/run_preamble_tests.sh
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800754 tests/run_rsa_tests.sh
755 tests/run_vboot_common_tests.sh
Randall Spangler844bce52013-01-15 16:16:43 -0800756 tests/run_vbutil_kernel_arg_tests.sh
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800757 tests/run_vbutil_tests.sh
758
Randall Spangler844bce52013-01-15 16:16:43 -0800759.PHONY: runmisctests
760runmisctests: $(TEST_SETUP) tests utils
761 $(RUNTEST) $(BUILD_RUN)/tests/rollback_index2_tests
762 $(RUNTEST) $(BUILD_RUN)/tests/rsa_utility_tests
763 $(RUNTEST) $(BUILD_RUN)/tests/sha_tests
764 $(RUNTEST) $(BUILD_RUN)/tests/stateful_util_tests
765 $(RUNTEST) $(BUILD_RUN)/tests/tpm_bootmode_tests
766 $(RUNTEST) $(BUILD_RUN)/tests/utility_string_tests
767 $(RUNTEST) $(BUILD_RUN)/tests/utility_tests
768 $(RUNTEST) $(BUILD_RUN)/tests/vboot_api_devmode_tests
769 $(RUNTEST) $(BUILD_RUN)/tests/vboot_api_init_tests
770 $(RUNTEST) $(BUILD_RUN)/tests/vboot_api_firmware_tests
771 $(RUNTEST) $(BUILD_RUN)/tests/vboot_audio_tests
772 $(RUNTEST) $(BUILD_RUN)/tests/vboot_firmware_tests
773
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800774# Run long tests, including all permutations of encryption keys (instead of
775# just the ones we use) and tests of currently-unused code (e.g. vboot_ec).
776# Not run by automated build.
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800777.PHONY: runlongtests
Randall Spangler844bce52013-01-15 16:16:43 -0800778runlongtests: $(TEST_SETUP) genkeys genfuzztestcases tests utils
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800779 tests/run_preamble_tests.sh --all
780 tests/run_vboot_common_tests.sh --all
781 tests/run_vboot_ec_tests.sh
782 tests/run_vbutil_tests.sh --all
783
784# TODO: tests to run when ported to new API
785# ./run_image_verification_tests.sh
786# # Splicing tests
787# ${BUILD}/tests/firmware_splicing_tests
788# ${BUILD}/tests/kernel_splicing_tests
789# # Rollback Tests
790# ${BUILD}/tests/firmware_rollback_tests
791# ${BUILD}/tests/kernel_rollback_tests
792
793# -----------------------------------------------------------------------------
794# Build rules
795
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800796${BUILD}/%: ${BUILD}/%.o $$(OBJS) $$(LIBS)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800797 @printf " LD $(subst $(BUILD)/,,$(@))\n"
798 $(Q)$(LD) $(CFLAGS) $(INCLUDES) $(LDFLAGS) $< $(OBJS) -o $@ \
799 $(LIBS) $(LDLIBS)
800
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800801${BUILD}/%.o: %.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800802 @printf " CC $(subst $(BUILD)/,,$(@))\n"
803 $(Q)$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
804
Randall Spangler17f8d342013-01-11 10:55:11 -0800805# Rules to recompile a single source file for library and test
806# TODO: is there a tidier way to do this?
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800807${BUILD}/%_for_lib.o: CFLAGS += -DFOR_LIBRARY
808${BUILD}/%_for_lib.o: %.c
Randall Spangler17f8d342013-01-11 10:55:11 -0800809 @printf " CC-for-lib $(subst $(BUILD)/,,$(@))\n"
810 $(Q)$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800811${BUILD}/%_for_test.o: CFLAGS += -DFOR_TEST
812${BUILD}/%_for_test.o: %.c
Randall Spangler17f8d342013-01-11 10:55:11 -0800813 @printf " CC-for-test $(subst $(BUILD)/,,$(@))\n"
814 $(Q)$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
815
816# TODO: C++ files don't belong in vboot reference at all. Convert to C.
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800817${BUILD}/%.o: %.cc
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800818 @printf " CXX $(subst $(BUILD)/,,$(@))\n"
819 $(Q)$(CXX) $(CFLAGS) $(INCLUDES) -c -o $@ $<
820
821# -----------------------------------------------------------------------------
822# Dependencies must come last after ALL_OBJS has been accumulated
823
824# TODO: I suspect this is missing some object files. Make a temp
825# target which cleans all known obj/exe's and see what's left; those
826# are the files which need deps.
827
828ALL_DEPS += $(ALL_OBJS:%.o=%.o.d)
829
830-include ${ALL_DEPS}