Bill Richardson | 0b8f35c | 2010-05-26 09:18:38 -0700 | [diff] [blame] | 1 | # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
Bill Richardson | 0b8f35c | 2010-05-26 09:18:38 -0700 | [diff] [blame] | 5 | FWTOP := $(shell pwd) |
| 6 | LIBDIR = $(FWTOP)/lib |
| 7 | STUBDIR = $(FWTOP)/stub |
| 8 | TESTDIR = $(FWTOP)/linktest |
vbendeb | 70e9509 | 2010-06-14 15:41:27 -0700 | [diff] [blame] | 9 | BUILD_ROOT := ${BUILD}/$(shell basename ${FWTOP}) |
Randall Spangler | 39f6611 | 2010-07-14 09:10:23 -0700 | [diff] [blame] | 10 | LIBS = $(FWLIB) # Firmware library must be self-contained |
| 11 | |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 12 | # Disable rollback TPM when compiling locally, since otherwise |
Randall Spangler | 39f6611 | 2010-07-14 09:10:23 -0700 | [diff] [blame] | 13 | # load_kernel_test attempts to talk to the TPM. |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 14 | ifeq ($(FIRMWARE_ARCH),) |
Randall Spangler | 39f6611 | 2010-07-14 09:10:23 -0700 | [diff] [blame] | 15 | CFLAGS += -DDISABLE_ROLLBACK_TPM |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 16 | endif |
Bill Richardson | 0b8f35c | 2010-05-26 09:18:38 -0700 | [diff] [blame] | 17 | |
Luigi Semenzato | 06fbb16 | 2011-03-16 17:33:23 -0700 | [diff] [blame] | 18 | # TPM-specific flags. These depend on the particular TPM we're targeting for. |
| 19 | # They are needed here only for compiling parts of the firmware code into |
| 20 | # user-level tests. |
| 21 | |
| 22 | # TPM_BLOCKING_CONTINUESELFTEST is defined if TPM_ContinueSelfTest blocks until |
| 23 | # the self test has completed. |
| 24 | |
| 25 | CLAGS += -DTPM_BLOCKING_CONTINUESELFTEST |
| 26 | |
| 27 | # TPM_MANUAL_SELFTEST is defined if the self test must be started manually |
| 28 | # (with a call to TPM_ContinueSelfTest) instead of starting automatically at |
| 29 | # power on. |
| 30 | # |
| 31 | # We sincerely hope that TPM_BLOCKING_CONTINUESELFTEST and TPM_MANUAL_SELFTEST |
| 32 | # are not both defined at the same time. (See comment in code.) |
| 33 | |
| 34 | # CLAGS += -DTPM_MANUAL_SELFTEST |
| 35 | |
vbendeb | 70e9509 | 2010-06-14 15:41:27 -0700 | [diff] [blame] | 36 | INCLUDES = \ |
Bill Richardson | 0b8f35c | 2010-05-26 09:18:38 -0700 | [diff] [blame] | 37 | -I$(FWTOP)/include \ |
| 38 | -I$(LIBDIR)/include \ |
Randall Spangler | 3003c1d | 2010-05-27 09:20:11 -0700 | [diff] [blame] | 39 | -I$(LIBDIR)/cgptlib/include \ |
Randall Spangler | d0dae7a | 2010-06-21 18:25:31 -0700 | [diff] [blame] | 40 | -I$(LIBDIR)/cryptolib/include \ |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 41 | -I$(LIBDIR)/tpm_lite/include |
| 42 | |
| 43 | ifeq ($(FIRMWARE_ARCH),) |
| 44 | INCLUDES += -I$(STUBDIR)/include |
| 45 | else |
| 46 | INCLUDES += -I$(FWDIR)/arch/$(FIRMWARE_ARCH)/include |
| 47 | endif |
Bill Richardson | 0b8f35c | 2010-05-26 09:18:38 -0700 | [diff] [blame] | 48 | |
Bill Richardson | 96ee63b | 2010-06-03 12:47:38 -0700 | [diff] [blame] | 49 | # find ./lib -iname '*.c' | sort |
| 50 | LIB_SRCS = \ |
| 51 | ./lib/cgptlib/cgptlib.c \ |
| 52 | ./lib/cgptlib/cgptlib_internal.c \ |
| 53 | ./lib/cgptlib/crc32.c \ |
| 54 | ./lib/cryptolib/padding.c \ |
| 55 | ./lib/cryptolib/rsa.c \ |
| 56 | ./lib/cryptolib/rsa_utility.c \ |
| 57 | ./lib/cryptolib/sha1.c \ |
| 58 | ./lib/cryptolib/sha2.c \ |
| 59 | ./lib/cryptolib/sha_utility.c \ |
Bill Richardson | 96ee63b | 2010-06-03 12:47:38 -0700 | [diff] [blame] | 60 | ./lib/rollback_index.c \ |
Gaurav Shah | b64faaa | 2011-03-15 16:36:29 -0700 | [diff] [blame] | 61 | ./lib/tpm_bootmode.c \ |
Randall Spangler | d183644 | 2010-06-10 09:59:04 -0700 | [diff] [blame] | 62 | ./lib/stateful_util.c \ |
Randall Spangler | 39f6611 | 2010-07-14 09:10:23 -0700 | [diff] [blame] | 63 | ./lib/tpm_lite/tlcl.c \ |
Gaurav Shah | 37dff84 | 2010-08-20 14:30:03 -0700 | [diff] [blame] | 64 | ./lib/utility.c \ |
Randall Spangler | d183644 | 2010-06-10 09:59:04 -0700 | [diff] [blame] | 65 | ./lib/vboot_common.c \ |
| 66 | ./lib/vboot_firmware.c \ |
Randall Spangler | b944534 | 2011-02-17 15:57:39 -0800 | [diff] [blame] | 67 | ./lib/vboot_kernel.c \ |
| 68 | ./lib/vboot_nvstorage.c |
Bill Richardson | 0b8f35c | 2010-05-26 09:18:38 -0700 | [diff] [blame] | 69 | |
Che-Liang Chiou | 8967860 | 2010-11-09 08:33:36 +0800 | [diff] [blame] | 70 | LIB_OBJS = $(LIB_SRCS:%.c=${BUILD_ROOT}/%.o) |
| 71 | |
Bill Richardson | 96ee63b | 2010-06-03 12:47:38 -0700 | [diff] [blame] | 72 | STUB_SRCS = \ |
| 73 | ./stub/boot_device_stub.c \ |
Randall Spangler | 57c08f6 | 2010-06-08 12:53:11 -0700 | [diff] [blame] | 74 | ./stub/load_firmware_stub.c \ |
Randall Spangler | 39f6611 | 2010-07-14 09:10:23 -0700 | [diff] [blame] | 75 | ./stub/tpm_lite_stub.c \ |
Bill Richardson | 96ee63b | 2010-06-03 12:47:38 -0700 | [diff] [blame] | 76 | ./stub/utility_stub.c |
| 77 | |
Che-Liang Chiou | 8967860 | 2010-11-09 08:33:36 +0800 | [diff] [blame] | 78 | STUB_OBJS = $(STUB_SRCS:%.c=${BUILD_ROOT}/%.o) |
| 79 | |
Randall Spangler | bce044d | 2011-02-07 12:36:51 -0800 | [diff] [blame] | 80 | ALL_SRCS = ${LIB_SRCS} ${STUB_SRCS} |
Bill Richardson | 0b8f35c | 2010-05-26 09:18:38 -0700 | [diff] [blame] | 81 | |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 82 | ifeq ($(FIRMWARE_ARCH),) |
Randall Spangler | bce044d | 2011-02-07 12:36:51 -0800 | [diff] [blame] | 83 | test : $(STUB_OBJS) $(FWLIB) |
vbendeb | 70e9509 | 2010-06-14 15:41:27 -0700 | [diff] [blame] | 84 | $(CC) $(CFLAGS) $(INCLUDES) -o $(BUILD_ROOT)/a.out \ |
Che-Liang Chiou | 8967860 | 2010-11-09 08:33:36 +0800 | [diff] [blame] | 85 | $(TESTDIR)/main.c $(STUB_OBJS) $(LIBS) |
Che-Liang Chiou | 0a0e8d0 | 2010-11-30 09:30:45 +0800 | [diff] [blame] | 86 | else |
| 87 | test : $(FWLIB) |
| 88 | endif |
Bill Richardson | 0b8f35c | 2010-05-26 09:18:38 -0700 | [diff] [blame] | 89 | |
vbendeb | 70e9509 | 2010-06-14 15:41:27 -0700 | [diff] [blame] | 90 | include ../common.mk |
Bill Richardson | 0b8f35c | 2010-05-26 09:18:38 -0700 | [diff] [blame] | 91 | |
Che-Liang Chiou | 8967860 | 2010-11-09 08:33:36 +0800 | [diff] [blame] | 92 | $(FWLIB) : $(LIB_OBJS) |
Bill Richardson | 0b8f35c | 2010-05-26 09:18:38 -0700 | [diff] [blame] | 93 | rm -f $@ |
| 94 | ar qc $@ $^ |