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