Detect and report VM environment in crossystem
[vboot.git] / Android.mk
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
7 LOCAL_PATH := $(call my-dir)
8 include $(CLEAR_VARS)
9
10 LOCAL_MODULE := libvboot_util-host
11
12 ifeq ($(HOST_OS),darwin)
13 LOCAL_CFLAGS += -DHAVE_MACOS
14 endif
15
16 # These are required to access large disks and files on 32-bit systems.
17 LOCAL_CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
18
19 LOCAL_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 \
27         $(LOCAL_PATH)/host/lib/include
28
29 # Firmware library sources needed by VbInit() call
30 VBINIT_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
40 VBSF_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 \
49         firmware/lib/vboot_common.c \
50         firmware/lib/region-fw.c \
51
52 # Additional firmware library sources needed by VbSelectAndLoadKernel() call
53 VBSLK_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
65 VBINIT_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
71 VBSF_SRCS += \
72         firmware/stub/vboot_api_stub_sf.c
73
74 VBSLK_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
79 UTILLIB_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
101 LOCAL_SRC_FILES := \
102         $(VBINIT_SRCS) \
103         $(VBSF_SRCS) \
104         $(VBSLK_SRCS) \
105         $(UTILLIB_SRCS)
106
107 LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_C_INCLUDES)
108 LOCAL_STATIC_LIBRARIES := libcrypto_static
109
110 include $(BUILD_HOST_STATIC_LIBRARY)
111
112 include $(CLEAR_VARS)
113
114 LOCAL_MODULE := futility-host
115 LOCAL_IS_HOST_MODULE := true
116 LOCAL_MODULE_CLASS := EXECUTABLES
117 generated_sources := $(call local-generated-sources-dir)
118
119 ifeq ($(HOST_OS),darwin)
120 LOCAL_CFLAGS += -DHAVE_MACOS
121 endif
122
123 # These are required to access large disks and files on 32-bit systems.
124 LOCAL_CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
125
126 FUTIL_STATIC_SRCS = \
127         futility/futility.c \
128         futility/cmd_dump_fmap.c \
129         futility/cmd_gbb_utility.c \
130         futility/misc.c
131
132 FUTIL_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
149 LOCAL_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
172 LOCAL_GENERATED_SOURCES := $(generated_sources)/futility_cmds.c
173
174 LOCAL_STATIC_LIBRARIES := libvboot_util-host
175 LOCAL_SHARED_LIBRARIES := libcrypto-host
176 include $(BUILD_HOST_EXECUTABLE)
177