summaryrefslogtreecommitdiff
path: root/firmware/Makefile
blob: 99f33f216aa6129f98a0c8f1e1c300e41296f233 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

FWTOP := $(shell pwd)
LIBDIR = $(FWTOP)/lib
STUBDIR = $(FWTOP)/stub
TESTDIR = $(FWTOP)/linktest
BUILD_ROOT := ${BUILD}/$(shell basename ${FWTOP})
LIBS = $(FWLIB)  # Firmware library must be self-contained

# Disable rollback TPM when compiling locally, since otherwise 
# load_kernel_test attempts to talk to the TPM.
CFLAGS += -DDISABLE_ROLLBACK_TPM

INCLUDES = \
	-I$(FWTOP)/include \
	-I$(LIBDIR)/include \
	-I$(LIBDIR)/cgptlib/include \
	-I$(LIBDIR)/cryptolib/include \
	-I$(LIBDIR)/tpm_lite/include \
	-I$(STUBDIR)/include

# find ./lib -iname '*.c' | sort
LIB_SRCS = \
	./lib/cgptlib/cgptlib.c \
	./lib/cgptlib/cgptlib_internal.c \
	./lib/cgptlib/crc32.c \
	./lib/cryptolib/padding.c \
	./lib/cryptolib/rsa.c \
	./lib/cryptolib/rsa_utility.c \
	./lib/cryptolib/sha1.c \
	./lib/cryptolib/sha2.c \
	./lib/cryptolib/sha_utility.c \
	./lib/rollback_index.c \
	./lib/stateful_util.c \
	./lib/tpm_lite/tlcl.c \
	./lib/utility.c \
	./lib/vboot_common.c \
	./lib/vboot_firmware.c \
	./lib/vboot_kernel.c

STUB_SRCS = \
	./stub/boot_device_stub.c \
	./stub/load_firmware_stub.c \
	./stub/tpm_lite_stub.c \
	./stub/utility_stub.c

ALL_SRCS = ${LIB_SRCS} ${STUB_SRCS} version.c

test : $(FWLIB) update-version
	$(CC) $(CFLAGS) $(INCLUDES) -o $(BUILD_ROOT)/a.out \
		$(TESTDIR)/main.c $(LIBS)

# This is executed at every make, to see if anything has changed
update-version :
	find \( -name '*.[ch]' -o -name 'Makefile*' \) -a \! -name version.c \
		| sort | xargs cat | md5sum | cut -c 25-32 > \
	${BUILD_ROOT}/x.tmp && \
	echo "char* VbootVersion = \"VBOOv=$$(cat ${BUILD_ROOT}/x.tmp)\";" > \
		${BUILD_ROOT}/version.tmp && \
	(cmp -s ${BUILD_ROOT}/version.tmp version.c || \
		( echo "** Updating version.c **" &&  \
		  cp ${BUILD_ROOT}/version.tmp version.c))

include ../common.mk

$(FWLIB) : $(ALL_OBJS)
	rm -f $@
	ar qc $@ $^