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