blob: 99f33f216aa6129f98a0c8f1e1c300e41296f233 [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
12# Disable rollback TPM when compiling locally, since otherwise
13# load_kernel_test attempts to talk to the TPM.
14CFLAGS += -DDISABLE_ROLLBACK_TPM
Bill Richardson0b8f35c2010-05-26 09:18:38 -070015
vbendeb70e95092010-06-14 15:41:27 -070016INCLUDES = \
Bill Richardson0b8f35c2010-05-26 09:18:38 -070017 -I$(FWTOP)/include \
18 -I$(LIBDIR)/include \
Randall Spangler3003c1d2010-05-27 09:20:11 -070019 -I$(LIBDIR)/cgptlib/include \
Randall Spanglerd0dae7a2010-06-21 18:25:31 -070020 -I$(LIBDIR)/cryptolib/include \
Randall Spangler39f66112010-07-14 09:10:23 -070021 -I$(LIBDIR)/tpm_lite/include \
Randall Spanglerd0dae7a2010-06-21 18:25:31 -070022 -I$(STUBDIR)/include
Bill Richardson0b8f35c2010-05-26 09:18:38 -070023
Bill Richardson96ee63b2010-06-03 12:47:38 -070024# find ./lib -iname '*.c' | sort
25LIB_SRCS = \
26 ./lib/cgptlib/cgptlib.c \
27 ./lib/cgptlib/cgptlib_internal.c \
28 ./lib/cgptlib/crc32.c \
29 ./lib/cryptolib/padding.c \
30 ./lib/cryptolib/rsa.c \
31 ./lib/cryptolib/rsa_utility.c \
32 ./lib/cryptolib/sha1.c \
33 ./lib/cryptolib/sha2.c \
34 ./lib/cryptolib/sha_utility.c \
Bill Richardson96ee63b2010-06-03 12:47:38 -070035 ./lib/rollback_index.c \
Randall Spanglerd1836442010-06-10 09:59:04 -070036 ./lib/stateful_util.c \
Randall Spangler39f66112010-07-14 09:10:23 -070037 ./lib/tpm_lite/tlcl.c \
Gaurav Shah37dff842010-08-20 14:30:03 -070038 ./lib/utility.c \
Randall Spanglerd1836442010-06-10 09:59:04 -070039 ./lib/vboot_common.c \
40 ./lib/vboot_firmware.c \
41 ./lib/vboot_kernel.c
Bill Richardson0b8f35c2010-05-26 09:18:38 -070042
Bill Richardson96ee63b2010-06-03 12:47:38 -070043STUB_SRCS = \
44 ./stub/boot_device_stub.c \
Randall Spangler57c08f62010-06-08 12:53:11 -070045 ./stub/load_firmware_stub.c \
Randall Spangler39f66112010-07-14 09:10:23 -070046 ./stub/tpm_lite_stub.c \
Bill Richardson96ee63b2010-06-03 12:47:38 -070047 ./stub/utility_stub.c
48
Luigi Semenzatof6ddd642010-06-24 08:11:24 -070049ALL_SRCS = ${LIB_SRCS} ${STUB_SRCS} version.c
Bill Richardson0b8f35c2010-05-26 09:18:38 -070050
Luigi Semenzatof6ddd642010-06-24 08:11:24 -070051test : $(FWLIB) update-version
vbendeb70e95092010-06-14 15:41:27 -070052 $(CC) $(CFLAGS) $(INCLUDES) -o $(BUILD_ROOT)/a.out \
Randall Spangler39f66112010-07-14 09:10:23 -070053 $(TESTDIR)/main.c $(LIBS)
Bill Richardson0b8f35c2010-05-26 09:18:38 -070054
Luigi Semenzatof6ddd642010-06-24 08:11:24 -070055# This is executed at every make, to see if anything has changed
56update-version :
57 find \( -name '*.[ch]' -o -name 'Makefile*' \) -a \! -name version.c \
vbendebe548e852010-06-24 17:24:01 -070058 | sort | xargs cat | md5sum | cut -c 25-32 > \
59 ${BUILD_ROOT}/x.tmp && \
60 echo "char* VbootVersion = \"VBOOv=$$(cat ${BUILD_ROOT}/x.tmp)\";" > \
Luigi Semenzato416f6812010-07-08 12:12:12 -070061 ${BUILD_ROOT}/version.tmp && \
62 (cmp -s ${BUILD_ROOT}/version.tmp version.c || \
vbendebe548e852010-06-24 17:24:01 -070063 ( echo "** Updating version.c **" && \
Luigi Semenzato416f6812010-07-08 12:12:12 -070064 cp ${BUILD_ROOT}/version.tmp version.c))
Luigi Semenzatof6ddd642010-06-24 08:11:24 -070065
vbendeb70e95092010-06-14 15:41:27 -070066include ../common.mk
Bill Richardson0b8f35c2010-05-26 09:18:38 -070067
vbendeb70e95092010-06-14 15:41:27 -070068$(FWLIB) : $(ALL_OBJS)
Bill Richardson0b8f35c2010-05-26 09:18:38 -070069 rm -f $@
70 ar qc $@ $^