David Riley | 623d6c4 | 2015-02-09 16:21:57 -0800 | [diff] [blame] | 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 | |
Chih-Hung Hsieh | 1392bc8 | 2017-10-11 14:40:47 -0700 | [diff] [blame] | 7 | libvboot_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 | |
David Riley | 623d6c4 | 2015-02-09 16:21:57 -0800 | [diff] [blame] | 17 | LOCAL_PATH := $(call my-dir) |
| 18 | include $(CLEAR_VARS) |
| 19 | |
| 20 | LOCAL_MODULE := libvboot_util-host |
| 21 | |
Chih-Hung Hsieh | 1392bc8 | 2017-10-11 14:40:47 -0700 | [diff] [blame] | 22 | LOCAL_CFLAGS := $(libvboot_common_warning_flags) |
| 23 | |
David Riley | 623d6c4 | 2015-02-09 16:21:57 -0800 | [diff] [blame] | 24 | ifeq ($(HOST_OS),darwin) |
Ying Wang | 10ebdb2 | 2015-06-05 19:18:05 -0700 | [diff] [blame] | 25 | LOCAL_CFLAGS += -DHAVE_MACOS -DO_LARGEFILE=0 |
David Riley | 623d6c4 | 2015-02-09 16:21:57 -0800 | [diff] [blame] | 26 | endif |
| 27 | |
| 28 | # These are required to access large disks and files on 32-bit systems. |
| 29 | LOCAL_CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 |
| 30 | |
| 31 | LOCAL_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 \ |
Adam Langley | d6759e4 | 2015-04-01 11:29:03 -0700 | [diff] [blame] | 39 | $(LOCAL_PATH)/host/lib/include |
David Riley | 623d6c4 | 2015-02-09 16:21:57 -0800 | [diff] [blame] | 40 | |
| 41 | # Firmware library sources needed by VbInit() call |
| 42 | VBINIT_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 |
| 52 | VBSF_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 |
| 67 | VBSLK_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 | |
| 79 | VBINIT_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 | |
| 85 | VBSF_SRCS += \ |
| 86 | firmware/stub/vboot_api_stub_sf.c |
| 87 | |
| 88 | VBSLK_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 | |
| 93 | UTILLIB_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 | |
| 115 | LOCAL_SRC_FILES := \ |
| 116 | $(VBINIT_SRCS) \ |
| 117 | $(VBSF_SRCS) \ |
| 118 | $(VBSLK_SRCS) \ |
| 119 | $(UTILLIB_SRCS) |
| 120 | |
| 121 | LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_C_INCLUDES) |
Alex Klyubin | 0ad090f | 2017-05-08 14:11:48 -0700 | [diff] [blame] | 122 | LOCAL_STATIC_LIBRARIES := libcrypto |
David Riley | 623d6c4 | 2015-02-09 16:21:57 -0800 | [diff] [blame] | 123 | |
| 124 | include $(BUILD_HOST_STATIC_LIBRARY) |
| 125 | |
| 126 | include $(CLEAR_VARS) |
| 127 | |
| 128 | LOCAL_MODULE := futility-host |
| 129 | LOCAL_IS_HOST_MODULE := true |
| 130 | LOCAL_MODULE_CLASS := EXECUTABLES |
| 131 | generated_sources := $(call local-generated-sources-dir) |
| 132 | |
Chih-Hung Hsieh | 1392bc8 | 2017-10-11 14:40:47 -0700 | [diff] [blame] | 133 | LOCAL_CFLAGS := $(libvboot_common_warning_flags) |
| 134 | |
David Riley | 623d6c4 | 2015-02-09 16:21:57 -0800 | [diff] [blame] | 135 | ifeq ($(HOST_OS),darwin) |
| 136 | LOCAL_CFLAGS += -DHAVE_MACOS |
| 137 | endif |
| 138 | |
| 139 | # These are required to access large disks and files on 32-bit systems. |
| 140 | LOCAL_CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 |
| 141 | |
| 142 | FUTIL_STATIC_SRCS = \ |
| 143 | futility/futility.c \ |
| 144 | futility/cmd_dump_fmap.c \ |
| 145 | futility/cmd_gbb_utility.c \ |
| 146 | futility/misc.c |
| 147 | |
| 148 | FUTIL_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 | |
| 165 | LOCAL_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 | |
| 188 | LOCAL_GENERATED_SOURCES := $(generated_sources)/futility_cmds.c |
| 189 | |
| 190 | LOCAL_STATIC_LIBRARIES := libvboot_util-host |
Dan Willemsen | b6c349c | 2016-07-21 14:14:42 -0700 | [diff] [blame] | 191 | LOCAL_SHARED_LIBRARIES := libcrypto |
David Riley | 623d6c4 | 2015-02-09 16:21:57 -0800 | [diff] [blame] | 192 | include $(BUILD_HOST_EXECUTABLE) |
| 193 | |
Chih-Hung Hsieh | 1392bc8 | 2017-10-11 14:40:47 -0700 | [diff] [blame] | 194 | libvboot_common_warning_flags := |