blob: bccf0849b250c5951e9ed8e14132cd30091d8157 [file] [log] [blame]
David Riley623d6c42015-02-09 16:21:57 -08001# Copyright 2015 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
5# Minimal makefile capable of compiling futility to sign images
6
7LOCAL_PATH := $(call my-dir)
8include $(CLEAR_VARS)
9
10LOCAL_MODULE := libvboot_util-host
11
12ifeq ($(HOST_OS),darwin)
13LOCAL_CFLAGS += -DHAVE_MACOS
14endif
15
16# These are required to access large disks and files on 32-bit systems.
17LOCAL_CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
18
19LOCAL_C_INCLUDES += \
20 $(LOCAL_PATH)/firmware/include \
21 $(LOCAL_PATH)/firmware/lib/include \
22 $(LOCAL_PATH)/firmware/lib/cgptlib/include \
23 $(LOCAL_PATH)/firmware/lib/cryptolib/include \
24 $(LOCAL_PATH)/firmware/lib/tpm_lite/include \
25 $(LOCAL_PATH)/firmware/2lib/include \
26 $(LOCAL_PATH)/host/include \
Adam Langley9978e0a2015-04-01 11:29:03 -070027 $(LOCAL_PATH)/host/lib/include
David Riley623d6c42015-02-09 16:21:57 -080028
29# Firmware library sources needed by VbInit() call
30VBINIT_SRCS = \
31 firmware/lib/crc8.c \
32 firmware/lib/utility.c \
33 firmware/lib/vboot_api_init.c \
34 firmware/lib/vboot_common_init.c \
35 firmware/lib/vboot_nvstorage.c \
36 firmware/lib/vboot_nvstorage_rollback.c \
37 firmware/lib/region-init.c \
38
39# Additional firmware library sources needed by VbSelectFirmware() call
40VBSF_SRCS = \
41 firmware/lib/cryptolib/padding.c \
42 firmware/lib/cryptolib/rsa.c \
43 firmware/lib/cryptolib/rsa_utility.c \
44 firmware/lib/cryptolib/sha1.c \
45 firmware/lib/cryptolib/sha256.c \
46 firmware/lib/cryptolib/sha512.c \
47 firmware/lib/cryptolib/sha_utility.c \
48 firmware/lib/stateful_util.c \
David Riley623d6c42015-02-09 16:21:57 -080049 firmware/lib/vboot_common.c \
David Riley623d6c42015-02-09 16:21:57 -080050 firmware/lib/region-fw.c \
51
52# Additional firmware library sources needed by VbSelectAndLoadKernel() call
53VBSLK_SRCS = \
54 firmware/lib/cgptlib/cgptlib.c \
55 firmware/lib/cgptlib/cgptlib_internal.c \
56 firmware/lib/cgptlib/crc32.c \
57 firmware/lib/gpt_misc.c \
58 firmware/lib/utility_string.c \
59 firmware/lib/vboot_api_kernel.c \
60 firmware/lib/vboot_audio.c \
61 firmware/lib/vboot_display.c \
62 firmware/lib/vboot_kernel.c \
63 firmware/lib/region-kernel.c \
64
65VBINIT_SRCS += \
66 firmware/stub/tpm_lite_stub.c \
67 firmware/stub/utility_stub.c \
68 firmware/stub/vboot_api_stub_init.c \
69 firmware/stub/vboot_api_stub_region.c
70
71VBSF_SRCS += \
72 firmware/stub/vboot_api_stub_sf.c
73
74VBSLK_SRCS += \
75 firmware/stub/vboot_api_stub.c \
76 firmware/stub/vboot_api_stub_disk.c \
77 firmware/stub/vboot_api_stub_stream.c
78
79UTILLIB_SRCS = \
80 cgpt/cgpt_create.c \
81 cgpt/cgpt_add.c \
82 cgpt/cgpt_boot.c \
83 cgpt/cgpt_show.c \
84 cgpt/cgpt_repair.c \
85 cgpt/cgpt_prioritize.c \
86 cgpt/cgpt_common.c \
87 futility/dump_kernel_config_lib.c \
88 host/lib/crossystem.c \
89 host/lib/file_keys.c \
90 host/lib/fmap.c \
91 host/lib/host_common.c \
92 host/lib/host_key.c \
93 host/lib/host_keyblock.c \
94 host/lib/host_misc.c \
95 host/lib/util_misc.c \
96 host/lib/host_signature.c \
97 host/lib/signature_digest.c
98
99# host/arch/${HOST_ARCH}/lib/crossystem_arch.c \
100
101LOCAL_SRC_FILES := \
102 $(VBINIT_SRCS) \
103 $(VBSF_SRCS) \
104 $(VBSLK_SRCS) \
105 $(UTILLIB_SRCS)
106
107LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_C_INCLUDES)
Adam Langley9978e0a2015-04-01 11:29:03 -0700108LOCAL_STATIC_LIBRARIES := libcrypto_static
David Riley623d6c42015-02-09 16:21:57 -0800109
110include $(BUILD_HOST_STATIC_LIBRARY)
111
112include $(CLEAR_VARS)
113
114LOCAL_MODULE := futility-host
115LOCAL_IS_HOST_MODULE := true
116LOCAL_MODULE_CLASS := EXECUTABLES
117generated_sources := $(call local-generated-sources-dir)
118
119ifeq ($(HOST_OS),darwin)
120LOCAL_CFLAGS += -DHAVE_MACOS
121endif
122
123# These are required to access large disks and files on 32-bit systems.
124LOCAL_CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
125
126FUTIL_STATIC_SRCS = \
127 futility/futility.c \
128 futility/cmd_dump_fmap.c \
129 futility/cmd_gbb_utility.c \
130 futility/misc.c
131
132FUTIL_SRCS = \
133 ${FUTIL_STATIC_SRCS} \
134 futility/cmd_dump_kernel_config.c \
135 futility/cmd_load_fmap.c \
136 futility/cmd_pcr.c \
137 futility/cmd_show.c \
138 futility/cmd_sign.c \
139 futility/cmd_vbutil_firmware.c \
140 futility/cmd_vbutil_kernel.c \
141 futility/cmd_vbutil_key.c \
142 futility/cmd_vbutil_keyblock.c \
143 futility/file_type.c \
144 futility/traversal.c \
145 futility/vb1_helper.c
146
147# ${FUTIL_STATIC_WORKAROUND_SRCS:%.c=${BUILD}/%.o} \
148
149LOCAL_SRC_FILES := \
150 $(FUTIL_SRCS) \
151
152$(generated_sources)/futility_cmds.c: ${FUTIL_SRCS:%=${LOCAL_PATH}/%}
153 @echo making $< from ${FUTIL_SRCS}
154 @rm -f $@ $@_t $@_commands
155 @mkdir -p $(dir $@)
156 @grep -hoRE '^DECLARE_FUTIL_COMMAND\([^,]+' $^ \
157 | sed 's/DECLARE_FUTIL_COMMAND(\(.*\)/_CMD(\1)/' \
158 | sort >>$@_commands
159 @external/vboot_reference/scripts/getversion.sh >> $@_t
160 @echo '#define _CMD(NAME) extern const struct' \
161 'futil_cmd_t __cmd_##NAME;' >> $@_t
162 @cat $@_commands >> $@_t
163 @echo '#undef _CMD' >> $@_t
164 @echo '#define _CMD(NAME) &__cmd_##NAME,' >> $@_t
165 @echo 'const struct futil_cmd_t *const futil_cmds[] = {' >> $@_t
166 @cat $@_commands >> $@_t
167 @echo '0}; /* null-terminated */' >> $@_t
168 @echo '#undef _CMD' >> $@_t
169 @mv $@_t $@
170 @rm -f $@_commands
171
172LOCAL_GENERATED_SOURCES := $(generated_sources)/futility_cmds.c
173
174LOCAL_STATIC_LIBRARIES := libvboot_util-host
Adam Langley9978e0a2015-04-01 11:29:03 -0700175LOCAL_SHARED_LIBRARIES := libcrypto-host
David Riley623d6c42015-02-09 16:21:57 -0800176include $(BUILD_HOST_EXECUTABLE)
177