blob: accc835c68c2de054f54c77265ff12d1646e2883 [file] [log] [blame]
Bill Richardson0b8f35c2010-05-26 09:18:38 -07001# 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 Richardson0b8f35c2010-05-26 09:18:38 -07005FWTOP := $(shell pwd)
6LIBDIR = $(FWTOP)/lib
7STUBDIR = $(FWTOP)/stub
8TESTDIR = $(FWTOP)/linktest
vbendeb70e95092010-06-14 15:41:27 -07009BUILD_ROOT := ${BUILD}/$(shell basename ${FWTOP})
Randall Spangler39f66112010-07-14 09:10:23 -070010LIBS = $(FWLIB) # Firmware library must be self-contained
11
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +080012# Disable rollback TPM when compiling locally, since otherwise
Randall Spangler39f66112010-07-14 09:10:23 -070013# load_kernel_test attempts to talk to the TPM.
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +080014ifeq ($(FIRMWARE_ARCH),)
Randall Spangler39f66112010-07-14 09:10:23 -070015CFLAGS += -DDISABLE_ROLLBACK_TPM
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +080016endif
Bill Richardson0b8f35c2010-05-26 09:18:38 -070017
Luigi Semenzato06fbb162011-03-16 17:33:23 -070018# 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
25CLAGS += -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
vbendeb70e95092010-06-14 15:41:27 -070036INCLUDES = \
Bill Richardson0b8f35c2010-05-26 09:18:38 -070037 -I$(FWTOP)/include \
38 -I$(LIBDIR)/include \
Randall Spangler3003c1d2010-05-27 09:20:11 -070039 -I$(LIBDIR)/cgptlib/include \
Randall Spanglerd0dae7a2010-06-21 18:25:31 -070040 -I$(LIBDIR)/cryptolib/include \
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +080041 -I$(LIBDIR)/tpm_lite/include
42
43ifeq ($(FIRMWARE_ARCH),)
44INCLUDES += -I$(STUBDIR)/include
45else
46INCLUDES += -I$(FWDIR)/arch/$(FIRMWARE_ARCH)/include
47endif
Bill Richardson0b8f35c2010-05-26 09:18:38 -070048
Bill Richardson96ee63b2010-06-03 12:47:38 -070049# find ./lib -iname '*.c' | sort
50LIB_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 Richardson96ee63b2010-06-03 12:47:38 -070060 ./lib/rollback_index.c \
Gaurav Shahb64faaa2011-03-15 16:36:29 -070061 ./lib/tpm_bootmode.c \
Randall Spanglerd1836442010-06-10 09:59:04 -070062 ./lib/stateful_util.c \
Randall Spangler39f66112010-07-14 09:10:23 -070063 ./lib/tpm_lite/tlcl.c \
Gaurav Shah37dff842010-08-20 14:30:03 -070064 ./lib/utility.c \
Randall Spanglerd1836442010-06-10 09:59:04 -070065 ./lib/vboot_common.c \
66 ./lib/vboot_firmware.c \
Randall Spanglerb9445342011-02-17 15:57:39 -080067 ./lib/vboot_kernel.c \
68 ./lib/vboot_nvstorage.c
Bill Richardson0b8f35c2010-05-26 09:18:38 -070069
Che-Liang Chiou89678602010-11-09 08:33:36 +080070LIB_OBJS = $(LIB_SRCS:%.c=${BUILD_ROOT}/%.o)
71
Bill Richardson96ee63b2010-06-03 12:47:38 -070072STUB_SRCS = \
73 ./stub/boot_device_stub.c \
Randall Spangler57c08f62010-06-08 12:53:11 -070074 ./stub/load_firmware_stub.c \
Randall Spangler39f66112010-07-14 09:10:23 -070075 ./stub/tpm_lite_stub.c \
Bill Richardson96ee63b2010-06-03 12:47:38 -070076 ./stub/utility_stub.c
77
Che-Liang Chiou89678602010-11-09 08:33:36 +080078STUB_OBJS = $(STUB_SRCS:%.c=${BUILD_ROOT}/%.o)
79
Randall Spanglerbce044d2011-02-07 12:36:51 -080080ALL_SRCS = ${LIB_SRCS} ${STUB_SRCS}
Bill Richardson0b8f35c2010-05-26 09:18:38 -070081
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +080082ifeq ($(FIRMWARE_ARCH),)
Randall Spanglerbce044d2011-02-07 12:36:51 -080083test : $(STUB_OBJS) $(FWLIB)
vbendeb70e95092010-06-14 15:41:27 -070084 $(CC) $(CFLAGS) $(INCLUDES) -o $(BUILD_ROOT)/a.out \
Che-Liang Chiou89678602010-11-09 08:33:36 +080085 $(TESTDIR)/main.c $(STUB_OBJS) $(LIBS)
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +080086else
87test : $(FWLIB)
88endif
Bill Richardson0b8f35c2010-05-26 09:18:38 -070089
vbendeb70e95092010-06-14 15:41:27 -070090include ../common.mk
Bill Richardson0b8f35c2010-05-26 09:18:38 -070091
Che-Liang Chiou89678602010-11-09 08:33:36 +080092$(FWLIB) : $(LIB_OBJS)
Bill Richardson0b8f35c2010-05-26 09:18:38 -070093 rm -f $@
94 ar qc $@ $^