1# 2# Copyright 2016, The Android Open Source Project 3# 4# Permission is hereby granted, free of charge, to any person 5# obtaining a copy of this software and associated documentation 6# files (the "Software"), to deal in the Software without 7# restriction, including without limitation the rights to use, copy, 8# modify, merge, publish, distribute, sublicense, and/or sell copies 9# of the Software, and to permit persons to whom the Software is 10# furnished to do so, subject to the following conditions: 11# 12# The above copyright notice and this permission notice shall be 13# included in all copies or substantial portions of the Software. 14# 15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22# SOFTWARE. 23# 24 25LOCAL_PATH := $(my-dir) 26 27avb_common_cflags := \ 28 -D_FILE_OFFSET_BITS=64 \ 29 -D_POSIX_C_SOURCE=199309L \ 30 -Wa,--noexecstack \ 31 -Werror \ 32 -Wall \ 33 -Wextra \ 34 -Wformat=2 \ 35 -Wno-psabi \ 36 -Wno-unused-parameter \ 37 -ffunction-sections \ 38 -fstack-protector-strong \ 39 -g 40avb_common_cppflags := \ 41 -Wnon-virtual-dtor \ 42 -fno-strict-aliasing 43avb_common_ldflags := \ 44 -Wl,--gc-sections \ 45 -rdynamic 46 47include $(CLEAR_VARS) 48LOCAL_SRC_FILES := avbtool 49LOCAL_MODULE_CLASS := EXECUTABLES 50LOCAL_REQUIRED_MODULES := fec 51LOCAL_IS_HOST_MODULE := true 52LOCAL_MODULE := avbtool 53include $(BUILD_PREBUILT) 54 55# Build libavb for the target (for e.g. fs_mgr usage). 56include $(CLEAR_VARS) 57LOCAL_MODULE := libavb 58LOCAL_MODULE_HOST_OS := linux 59LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) 60LOCAL_CLANG := true 61LOCAL_CFLAGS := $(avb_common_cflags) -DAVB_ENABLE_DEBUG -DAVB_COMPILATION 62LOCAL_LDFLAGS := $(avb_common_ldflags) 63LOCAL_SRC_FILES := \ 64 libavb/avb_chain_partition_descriptor.c \ 65 libavb/avb_crc32.c \ 66 libavb/avb_crypto.c \ 67 libavb/avb_descriptor.c \ 68 libavb/avb_footer.c \ 69 libavb/avb_hash_descriptor.c \ 70 libavb/avb_hashtree_descriptor.c \ 71 libavb/avb_kernel_cmdline_descriptor.c \ 72 libavb/avb_property_descriptor.c \ 73 libavb/avb_rsa.c \ 74 libavb/avb_sha256.c \ 75 libavb/avb_sha512.c \ 76 libavb/avb_slot_verify.c \ 77 libavb/avb_sysdeps_posix.c \ 78 libavb/avb_util.c \ 79 libavb/avb_vbmeta_image.c \ 80 libavb/avb_version.c 81include $(BUILD_STATIC_LIBRARY) 82 83# Build avbctl for the target. 84include $(CLEAR_VARS) 85LOCAL_MODULE := avbctl 86LOCAL_MODULE_CLASS := EXECUTABLES 87LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) 88LOCAL_CPP_EXTENSION := .cc 89LOCAL_CLANG := true 90LOCAL_CFLAGS := $(avb_common_cflags) -DAVB_COMPILATION -DAVB_ENABLE_DEBUG 91LOCAL_CPPFLAGS := $(avb_common_cppflags) 92LOCAL_LDFLAGS := $(avb_common_ldflags) 93LOCAL_STATIC_LIBRARIES := \ 94 libavb \ 95 libfs_mgr 96LOCAL_SHARED_LIBRARIES := \ 97 libbase \ 98 libhidlbase \ 99 libhidltransport \ 100 libhwbinder \ 101 libutils \ 102 android.hardware.boot@1.0 103LOCAL_SRC_FILES := \ 104 libavb_ab/avb_ab_flow.c \ 105 libavb_user/avb_ops_user.c \ 106 tools/avbctl/avbctl.cc 107include $(BUILD_EXECUTABLE) 108 109# Build libavb for the host (for unit tests). 110include $(CLEAR_VARS) 111LOCAL_MODULE := libavb_host 112LOCAL_MODULE_HOST_OS := linux 113LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) 114LOCAL_MODULE_CLASS := STATIC_LIBRARIES 115LOCAL_CLANG := true 116LOCAL_CFLAGS := $(avb_common_cflags) -fno-stack-protector -DAVB_ENABLE_DEBUG -DAVB_COMPILATION 117LOCAL_LDFLAGS := $(avb_common_ldflags) 118LOCAL_SRC_FILES := \ 119 libavb/avb_chain_partition_descriptor.c \ 120 libavb/avb_crc32.c \ 121 libavb/avb_crypto.c \ 122 libavb/avb_descriptor.c \ 123 libavb/avb_footer.c \ 124 libavb/avb_hash_descriptor.c \ 125 libavb/avb_hashtree_descriptor.c \ 126 libavb/avb_kernel_cmdline_descriptor.c \ 127 libavb/avb_property_descriptor.c \ 128 libavb/avb_rsa.c \ 129 libavb/avb_sha256.c \ 130 libavb/avb_sha512.c \ 131 libavb/avb_slot_verify.c \ 132 libavb/avb_util.c \ 133 libavb/avb_vbmeta_image.c \ 134 libavb/avb_version.c 135include $(BUILD_HOST_STATIC_LIBRARY) 136 137# Build libavb_ab for the host (for unit tests). 138include $(CLEAR_VARS) 139LOCAL_MODULE := libavb_ab_host 140LOCAL_REQUIRED_MODULES := libavb_host 141LOCAL_MODULE_HOST_OS := linux 142LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) 143LOCAL_MODULE_CLASS := STATIC_LIBRARIES 144LOCAL_CLANG := true 145LOCAL_CFLAGS := $(avb_common_cflags) -fno-stack-protector -DAVB_ENABLE_DEBUG -DAVB_COMPILATION 146LOCAL_LDFLAGS := $(avb_common_ldflags) 147LOCAL_SRC_FILES := \ 148 libavb_ab/avb_ab_flow.c 149include $(BUILD_HOST_STATIC_LIBRARY) 150 151# Build libavb_atx for the host (for unit tests). 152include $(CLEAR_VARS) 153LOCAL_MODULE := libavb_atx_host 154LOCAL_REQUIRED_MODULES := libavb_host 155LOCAL_MODULE_HOST_OS := linux 156LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) 157LOCAL_MODULE_CLASS := STATIC_LIBRARIES 158LOCAL_CLANG := true 159LOCAL_CFLAGS := $(avb_common_cflags) -fno-stack-protector -DAVB_ENABLE_DEBUG -DAVB_COMPILATION 160LOCAL_LDFLAGS := $(avb_common_ldflags) 161LOCAL_SRC_FILES := \ 162 libavb_atx/avb_atx_validate.c 163include $(BUILD_HOST_STATIC_LIBRARY) 164 165include $(CLEAR_VARS) 166LOCAL_MODULE := libavb_host_sysdeps 167LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) 168LOCAL_MODULE_HOST_OS := linux 169LOCAL_MODULE_CLASS := STATIC_LIBRARIES 170LOCAL_CLANG := true 171LOCAL_CFLAGS := $(avb_common_cflags) -DAVB_ENABLE_DEBUG -DAVB_COMPILATION 172LOCAL_LDFLAGS := $(avb_common_ldflags) 173LOCAL_SRC_FILES := \ 174 libavb/avb_sysdeps_posix.c 175include $(BUILD_HOST_STATIC_LIBRARY) 176 177include $(CLEAR_VARS) 178LOCAL_MODULE := libavb_host_unittest 179LOCAL_REQUIRED_MODULES := simg2img img2simg avbtool 180LOCAL_MODULE_HOST_OS := linux 181LOCAL_CPP_EXTENSION := .cc 182LOCAL_CLANG := true 183LOCAL_CFLAGS := $(avb_common_cflags) -DAVB_ENABLE_DEBUG -DAVB_COMPILATION 184LOCAL_CPPFLAGS := $(avb_common_cppflags) 185LOCAL_LDFLAGS := $(avb_common_ldflags) 186LOCAL_STATIC_LIBRARIES := \ 187 libavb_host \ 188 libavb_ab_host \ 189 libavb_atx_host \ 190 libgmock_host \ 191 libgtest_host 192LOCAL_SHARED_LIBRARIES := \ 193 libchrome \ 194 libcrypto 195LOCAL_SRC_FILES := \ 196 test/avb_ab_flow_unittest.cc \ 197 test/avb_atx_validate_unittest.cc \ 198 test/avb_slot_verify_unittest.cc \ 199 test/avb_unittest_util.cc \ 200 test/avb_util_unittest.cc \ 201 test/avb_vbmeta_image_unittest.cc \ 202 test/avbtool_unittest.cc \ 203 test/fake_avb_ops.cc \ 204 test/avb_sysdeps_posix_testing.cc 205LOCAL_LDLIBS_linux := -lrt 206include $(BUILD_HOST_NATIVE_TEST) 207 208include $(CLEAR_VARS) 209LOCAL_MODULE := libavb_host_user_code_test 210LOCAL_MODULE_HOST_OS := linux 211LOCAL_MODULE_CLASS := STATIC_LIBRARIES 212LOCAL_CPP_EXTENSION := .cc 213LOCAL_CLANG := true 214LOCAL_CFLAGS := $(avb_common_cflags) 215LOCAL_CPPFLAGS := $(avb_common_cppflags) 216LOCAL_LDFLAGS := $(avb_common_ldflags) 217LOCAL_SRC_FILES := test/user_code_test.cc 218include $(BUILD_HOST_STATIC_LIBRARY) 219 220include $(CLEAR_VARS) 221LOCAL_MODULE := bootctrl.avb 222LOCAL_MODULE_RELATIVE_PATH := hw 223LOCAL_REQUIRED_MODULES := libavb 224LOCAL_SRC_FILES := \ 225 libavb_ab/avb_ab_flow.c \ 226 libavb_user/avb_ops_user.c \ 227 boot_control/boot_control_avb.c 228LOCAL_CLANG := true 229LOCAL_CFLAGS := $(avb_common_cflags) -DAVB_COMPILATION 230LOCAL_LDFLAGS := $(avb_common_ldflags) 231LOCAL_SHARED_LIBRARIES := libbase libcutils 232LOCAL_STATIC_LIBRARIES := libfs_mgr libavb 233LOCAL_POST_INSTALL_CMD := \ 234 $(hide) mkdir -p $(TARGET_OUT_SHARED_LIBRARIES)/hw && \ 235 ln -sf bootctrl.avb.so $(TARGET_OUT_SHARED_LIBRARIES)/hw/bootctrl.default.so 236include $(BUILD_SHARED_LIBRARY) 237 238include $(CLEAR_VARS) 239LOCAL_SRC_FILES := libavb_host_symbols_test 240LOCAL_MODULE_TAGS := debug 241LOCAL_ADDITIONAL_DEPENDENCIES := libavb_ab_host 242include $(BUILD_HOST_PREBUILT) 243