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 | |
| 7 | LOCAL_PATH := $(call my-dir) |
| 8 | include $(CLEAR_VARS) |
| 9 | |
| 10 | LOCAL_MODULE := libvboot_util-host |
| 11 | |
| 12 | ifeq ($(HOST_OS),darwin) |
Ying Wang | 10ebdb2 | 2015-06-05 19:18:05 -0700 | [diff] [blame] | 13 | LOCAL_CFLAGS += -DHAVE_MACOS -DO_LARGEFILE=0 |
David Riley | 623d6c4 | 2015-02-09 16:21:57 -0800 | [diff] [blame] | 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 \ |
Adam Langley | d6759e4 | 2015-04-01 11:29:03 -0700 | [diff] [blame] | 27 | $(LOCAL_PATH)/host/lib/include |
David Riley | 623d6c4 | 2015-02-09 16:21:57 -0800 | [diff] [blame] | 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_api_firmware.c \ |
| 50 | firmware/lib/vboot_common.c \ |
| 51 | firmware/lib/vboot_firmware.c \ |
| 52 | firmware/lib/region-fw.c \ |
| 53 | |
| 54 | # Additional firmware library sources needed by VbSelectAndLoadKernel() call |
| 55 | VBSLK_SRCS = \ |
| 56 | firmware/lib/cgptlib/cgptlib.c \ |
| 57 | firmware/lib/cgptlib/cgptlib_internal.c \ |
| 58 | firmware/lib/cgptlib/crc32.c \ |
| 59 | firmware/lib/gpt_misc.c \ |
| 60 | firmware/lib/utility_string.c \ |
| 61 | firmware/lib/vboot_api_kernel.c \ |
| 62 | firmware/lib/vboot_audio.c \ |
| 63 | firmware/lib/vboot_display.c \ |
| 64 | firmware/lib/vboot_kernel.c \ |
| 65 | firmware/lib/region-kernel.c \ |
| 66 | |
| 67 | VBINIT_SRCS += \ |
| 68 | firmware/stub/tpm_lite_stub.c \ |
| 69 | firmware/stub/utility_stub.c \ |
| 70 | firmware/stub/vboot_api_stub_init.c \ |
| 71 | firmware/stub/vboot_api_stub_region.c |
| 72 | |
| 73 | VBSF_SRCS += \ |
| 74 | firmware/stub/vboot_api_stub_sf.c |
| 75 | |
| 76 | VBSLK_SRCS += \ |
| 77 | firmware/stub/vboot_api_stub.c \ |
| 78 | firmware/stub/vboot_api_stub_disk.c \ |
| 79 | firmware/stub/vboot_api_stub_stream.c |
| 80 | |
| 81 | UTILLIB_SRCS = \ |
| 82 | cgpt/cgpt_create.c \ |
| 83 | cgpt/cgpt_add.c \ |
| 84 | cgpt/cgpt_boot.c \ |
| 85 | cgpt/cgpt_show.c \ |
| 86 | cgpt/cgpt_repair.c \ |
| 87 | cgpt/cgpt_prioritize.c \ |
| 88 | cgpt/cgpt_common.c \ |
| 89 | futility/dump_kernel_config_lib.c \ |
| 90 | host/lib/crossystem.c \ |
| 91 | host/lib/file_keys.c \ |
| 92 | host/lib/fmap.c \ |
| 93 | host/lib/host_common.c \ |
| 94 | host/lib/host_key.c \ |
| 95 | host/lib/host_keyblock.c \ |
| 96 | host/lib/host_misc.c \ |
| 97 | host/lib/util_misc.c \ |
| 98 | host/lib/host_signature.c \ |
| 99 | host/lib/signature_digest.c |
| 100 | |
| 101 | # host/arch/${HOST_ARCH}/lib/crossystem_arch.c \ |
| 102 | |
| 103 | LOCAL_SRC_FILES := \ |
| 104 | $(VBINIT_SRCS) \ |
| 105 | $(VBSF_SRCS) \ |
| 106 | $(VBSLK_SRCS) \ |
| 107 | $(UTILLIB_SRCS) |
| 108 | |
| 109 | LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_C_INCLUDES) |
Alex Klyubin | 0ad090f | 2017-05-08 14:11:48 -0700 | [diff] [blame^] | 110 | LOCAL_STATIC_LIBRARIES := libcrypto |
David Riley | 623d6c4 | 2015-02-09 16:21:57 -0800 | [diff] [blame] | 111 | |
| 112 | include $(BUILD_HOST_STATIC_LIBRARY) |
| 113 | |
| 114 | include $(CLEAR_VARS) |
| 115 | |
| 116 | LOCAL_MODULE := futility-host |
| 117 | LOCAL_IS_HOST_MODULE := true |
| 118 | LOCAL_MODULE_CLASS := EXECUTABLES |
| 119 | generated_sources := $(call local-generated-sources-dir) |
| 120 | |
| 121 | ifeq ($(HOST_OS),darwin) |
| 122 | LOCAL_CFLAGS += -DHAVE_MACOS |
| 123 | endif |
| 124 | |
| 125 | # These are required to access large disks and files on 32-bit systems. |
| 126 | LOCAL_CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 |
| 127 | |
| 128 | FUTIL_STATIC_SRCS = \ |
| 129 | futility/futility.c \ |
| 130 | futility/cmd_dump_fmap.c \ |
| 131 | futility/cmd_gbb_utility.c \ |
| 132 | futility/misc.c |
| 133 | |
| 134 | FUTIL_SRCS = \ |
| 135 | ${FUTIL_STATIC_SRCS} \ |
| 136 | futility/cmd_dump_kernel_config.c \ |
| 137 | futility/cmd_load_fmap.c \ |
| 138 | futility/cmd_pcr.c \ |
| 139 | futility/cmd_show.c \ |
| 140 | futility/cmd_sign.c \ |
| 141 | futility/cmd_vbutil_firmware.c \ |
| 142 | futility/cmd_vbutil_kernel.c \ |
| 143 | futility/cmd_vbutil_key.c \ |
| 144 | futility/cmd_vbutil_keyblock.c \ |
| 145 | futility/file_type.c \ |
| 146 | futility/traversal.c \ |
| 147 | futility/vb1_helper.c |
| 148 | |
| 149 | # ${FUTIL_STATIC_WORKAROUND_SRCS:%.c=${BUILD}/%.o} \ |
| 150 | |
| 151 | LOCAL_SRC_FILES := \ |
| 152 | $(FUTIL_SRCS) \ |
| 153 | |
| 154 | $(generated_sources)/futility_cmds.c: ${FUTIL_SRCS:%=${LOCAL_PATH}/%} |
| 155 | @echo making $< from ${FUTIL_SRCS} |
| 156 | @rm -f $@ $@_t $@_commands |
| 157 | @mkdir -p $(dir $@) |
| 158 | @grep -hoRE '^DECLARE_FUTIL_COMMAND\([^,]+' $^ \ |
| 159 | | sed 's/DECLARE_FUTIL_COMMAND(\(.*\)/_CMD(\1)/' \ |
| 160 | | sort >>$@_commands |
| 161 | @external/vboot_reference/scripts/getversion.sh >> $@_t |
| 162 | @echo '#define _CMD(NAME) extern const struct' \ |
| 163 | 'futil_cmd_t __cmd_##NAME;' >> $@_t |
| 164 | @cat $@_commands >> $@_t |
| 165 | @echo '#undef _CMD' >> $@_t |
| 166 | @echo '#define _CMD(NAME) &__cmd_##NAME,' >> $@_t |
| 167 | @echo 'const struct futil_cmd_t *const futil_cmds[] = {' >> $@_t |
| 168 | @cat $@_commands >> $@_t |
| 169 | @echo '0}; /* null-terminated */' >> $@_t |
| 170 | @echo '#undef _CMD' >> $@_t |
| 171 | @mv $@_t $@ |
| 172 | @rm -f $@_commands |
| 173 | |
| 174 | LOCAL_GENERATED_SOURCES := $(generated_sources)/futility_cmds.c |
| 175 | |
| 176 | LOCAL_STATIC_LIBRARIES := libvboot_util-host |
Dan Willemsen | b6c349c | 2016-07-21 14:14:42 -0700 | [diff] [blame] | 177 | LOCAL_SHARED_LIBRARIES := libcrypto |
David Riley | 623d6c4 | 2015-02-09 16:21:57 -0800 | [diff] [blame] | 178 | include $(BUILD_HOST_EXECUTABLE) |
| 179 | |