Jeevan Shriram | 062058c | 2016-11-07 16:46:44 -0800 | [diff] [blame] | 1 | #Android makefile to build bootloader as a part of Android Build |
Bhanuprakash Modem | 2372010 | 2018-09-27 21:55:40 +0530 | [diff] [blame] | 2 | ANDROID_TOP=$(shell pwd) |
| 3 | CLANG_BIN := $(ANDROID_TOP)/$(LLVM_PREBUILTS_PATH)/ |
lijuang | 65c51d5 | 2018-03-28 13:52:57 +0800 | [diff] [blame] | 4 | ABL_USE_SDLLVM := false |
| 5 | |
Paul Strong | 4568ca9 | 2019-12-16 14:28:11 -0800 | [diff] [blame] | 6 | ifneq ($(FORCE_SDCLANG_OFF),true) |
lijuang | 65c51d5 | 2018-03-28 13:52:57 +0800 | [diff] [blame] | 7 | ifneq ($(wildcard $(SDCLANG_PATH)),) |
| 8 | ifeq ($(shell echo $(SDCLANG_PATH) | head -c 1),/) |
| 9 | CLANG_BIN := $(SDCLANG_PATH)/ |
| 10 | else |
Bhanuprakash Modem | 2372010 | 2018-09-27 21:55:40 +0530 | [diff] [blame] | 11 | CLANG_BIN := $(ANDROID_TOP)/$(SDCLANG_PATH)/ |
lijuang | 65c51d5 | 2018-03-28 13:52:57 +0800 | [diff] [blame] | 12 | endif |
| 13 | |
| 14 | ABL_USE_SDLLVM := true |
Ashwini Muduganti | 36db63f | 2017-12-12 14:20:38 -0800 | [diff] [blame] | 15 | endif |
Paul Strong | 4568ca9 | 2019-12-16 14:28:11 -0800 | [diff] [blame] | 16 | endif |
Ashwini Muduganti | 36db63f | 2017-12-12 14:20:38 -0800 | [diff] [blame] | 17 | |
Bhanuprakash Modem | 200d4b1 | 2018-11-22 16:29:39 +0530 | [diff] [blame] | 18 | # LD & make are not available in prebuilts for older Android versions |
Bhanuprakash Modem | 78a89d7 | 2018-10-10 19:00:44 +0530 | [diff] [blame] | 19 | ifeq (1,$(filter 1,$(shell echo "$$(( $(PLATFORM_SDK_VERSION) > 27 ))" ))) |
| 20 | LDOPT="-fuse-ld=$(ANDROID_TOP)/$(SOONG_LLVM_PREBUILTS_PATH)/ld.lld" |
Bhanuprakash Modem | 200d4b1 | 2018-11-22 16:29:39 +0530 | [diff] [blame] | 21 | MAKEPATH=$(ANDROID_TOP)/prebuilts/build-tools/linux-x86/bin/ |
Bhanuprakash Modem | a64c964 | 2018-11-30 13:49:09 +0530 | [diff] [blame] | 22 | ifeq (,$(wildcard $(MAKEPATH)make)) |
Bhanuprakash Modem | 200d4b1 | 2018-11-22 16:29:39 +0530 | [diff] [blame] | 23 | MAKEPATH := |
| 24 | endif |
Bhanuprakash Modem | 78a89d7 | 2018-10-10 19:00:44 +0530 | [diff] [blame] | 25 | endif |
| 26 | |
Bhanuprakash Modem | 2372010 | 2018-09-27 21:55:40 +0530 | [diff] [blame] | 27 | # Use host tools from prebuilts. Partner should determine the correct host tools to use |
Bhanuprakash Modem | 78a89d7 | 2018-10-10 19:00:44 +0530 | [diff] [blame] | 28 | PREBUILT_HOST_TOOLS := CC=$(ANDROID_TOP)/$(CLANG)\ \ |
| 29 | CXX=$(ANDROID_TOP)/$(CLANG_CXX)\ \ |
| 30 | LDPATH=$(LDOPT)\ \ |
Bhanuprakash Modem | 2372010 | 2018-09-27 21:55:40 +0530 | [diff] [blame] | 31 | AR=$(ANDROID_TOP)/$(HOST_AR) |
Bhanuprakash Modem | 78a89d7 | 2018-10-10 19:00:44 +0530 | [diff] [blame] | 32 | PREBUILT_PYTHON_PATH=$(ANDROID_TOP)/prebuilts/python/linux-x86/2.7.5/bin/python2 |
Bhanuprakash Modem | 2372010 | 2018-09-27 21:55:40 +0530 | [diff] [blame] | 33 | |
Alexander Martinz | cc4e9e7 | 2022-12-19 21:32:57 +0100 | [diff] [blame] | 34 | DISABLE_PARALLEL_DOWNLOAD_FLASH := DISABLE_PARALLEL_DOWNLOAD_FLASH=1 |
Jeevan Shriram | 9e617b2 | 2019-11-27 13:54:42 -0800 | [diff] [blame] | 35 | ifeq ($(PRODUCT_SUPPORTS_VERITY),true) |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 36 | VERIFIED_BOOT := VERIFIED_BOOT=1 |
| 37 | else |
| 38 | VERIFIED_BOOT := VERIFIED_BOOT=0 |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 39 | endif |
| 40 | |
Mukesh Ojha | 8dc65f5 | 2018-03-27 00:59:30 +0530 | [diff] [blame] | 41 | ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true) |
| 42 | BUILD_SYSTEM_ROOT_IMAGE := BUILD_SYSTEM_ROOT_IMAGE=1 |
| 43 | else |
| 44 | BUILD_SYSTEM_ROOT_IMAGE := BUILD_SYSTEM_ROOT_IMAGE=0 |
| 45 | endif |
| 46 | |
Shivaprasad Hongal | 3860bbf | 2017-04-27 17:40:13 -0700 | [diff] [blame] | 47 | ifeq ($(BOARD_AVB_ENABLE),true) |
| 48 | VERIFIED_BOOT_2 := VERIFIED_BOOT_2=1 |
| 49 | else |
| 50 | VERIFIED_BOOT_2 := VERIFIED_BOOT_2=0 |
| 51 | endif |
| 52 | |
Zhen Kong | dd5c5e3 | 2017-07-05 13:44:45 -0700 | [diff] [blame] | 53 | ifeq ($(BOARD_LEVB_ENABLE),true) |
| 54 | VERIFIED_BOOT_LE := VERIFIED_BOOT_LE=1 |
| 55 | else |
| 56 | VERIFIED_BOOT_LE := VERIFIED_BOOT_LE=0 |
| 57 | endif |
| 58 | |
Jeevan Shriram | 0a3ba0b | 2019-01-02 23:21:12 -0800 | [diff] [blame] | 59 | ifeq ($(TARGET_AB_RETRYCOUNT_DISABLE),true) |
| 60 | AB_RETRYCOUNT_DISABLE := AB_RETRYCOUNT_DISABLE=1 |
| 61 | else |
| 62 | AB_RETRYCOUNT_DISABLE := AB_RETRYCOUNT_DISABLE=0 |
| 63 | endif |
| 64 | |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 65 | ifeq ($(TARGET_BUILD_VARIANT),user) |
Vijay Kumar Pendoti | 9946e04 | 2016-09-16 17:38:51 +0530 | [diff] [blame] | 66 | USER_BUILD_VARIANT := USER_BUILD_VARIANT=1 |
| 67 | else |
| 68 | USER_BUILD_VARIANT := USER_BUILD_VARIANT=0 |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 69 | endif |
| 70 | |
Jeevan Shriram | d5d169f | 2018-04-20 16:09:10 -0700 | [diff] [blame] | 71 | ifneq ($(TARGET_BOOTLOADER_BOARD_NAME),) |
| 72 | BOARD_BOOTLOADER_PRODUCT_NAME := $(TARGET_BOOTLOADER_BOARD_NAME) |
| 73 | else |
| 74 | BOARD_BOOTLOADER_PRODUCT_NAME := QC_Reference_Phone |
| 75 | endif |
| 76 | |
Alexander Martinz | 32ab18a | 2020-06-02 14:06:24 +0200 | [diff] [blame] | 77 | ifneq ($(TARGET_BOOTLOADER_BOARD_MODEL),) |
| 78 | BOARD_BOOTLOADER_PRODUCT_MODEL := $(TARGET_BOOTLOADER_BOARD_MODEL) |
| 79 | else |
| 80 | BOARD_BOOTLOADER_PRODUCT_MODEL := unknown |
| 81 | endif |
Alexander Martinz | 932c429 | 2021-09-10 19:50:46 +0200 | [diff] [blame] | 82 | ifneq ($(TARGET_BOOTLOADER_VERSION),) |
| 83 | BOARD_BOOTLOADER_VERSION := $(TARGET_BOOTLOADER_VERSION) |
| 84 | else |
| 85 | BOARD_BOOTLOADER_VERSION := unknown |
| 86 | endif |
Alexander Martinz | 32ab18a | 2020-06-02 14:06:24 +0200 | [diff] [blame] | 87 | |
Anuj Garg | ae40955 | 2020-06-03 19:21:55 +0530 | [diff] [blame] | 88 | ifneq ($(TARGET_BOARD_TYPE),auto) |
| 89 | TARGET_BOARD_TYPE_AUTO := TARGET_BOARD_TYPE_AUTO=0 |
| 90 | else |
| 91 | TARGET_BOARD_TYPE_AUTO := TARGET_BOARD_TYPE_AUTO=1 |
| 92 | endif |
Prateek Sood | c86ef5d | 2020-01-30 00:18:13 +0530 | [diff] [blame] | 93 | |
| 94 | ifneq ($(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),) |
| 95 | USERDATAIMAGE_FILE_SYSTEM_TYPE := $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE) |
| 96 | else |
| 97 | USERDATAIMAGE_FILE_SYSTEM_TYPE := ext4 |
| 98 | endif |
| 99 | |
Venkata Narendra Kumar Gutta | 688a161 | 2018-04-18 17:12:50 -0700 | [diff] [blame] | 100 | ifeq ($(BOARD_ABL_SAFESTACK_DISABLE),true) |
| 101 | ABL_SAFESTACK := false |
| 102 | else |
| 103 | ABL_SAFESTACK := true |
| 104 | endif |
| 105 | |
Saranya Chidura | 30eb629 | 2019-02-20 15:27:37 +0530 | [diff] [blame] | 106 | ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true) |
| 107 | DYNAMIC_PARTITION_SUPPORT := DYNAMIC_PARTITION_SUPPORT=1 |
| 108 | else |
| 109 | DYNAMIC_PARTITION_SUPPORT := DYNAMIC_PARTITION_SUPPORT=0 |
| 110 | endif |
| 111 | |
Jeevan Shriram | 91492b4 | 2020-01-20 17:34:53 -0800 | [diff] [blame] | 112 | ifeq ($(PRODUCT_VIRTUAL_AB_OTA),true) |
| 113 | VIRTUAL_AB_OTA := VIRTUAL_AB_OTA=1 |
| 114 | else |
| 115 | VIRTUAL_AB_OTA := VIRTUAL_AB_OTA=0 |
| 116 | endif |
| 117 | |
Raghavendra Rao Ananta | 508792f | 2019-12-09 14:11:21 -0800 | [diff] [blame] | 118 | ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true) |
| 119 | BUILD_USES_RECOVERY_AS_BOOT := BUILD_USES_RECOVERY_AS_BOOT=1 |
| 120 | else |
| 121 | BUILD_USES_RECOVERY_AS_BOOT := BUILD_USES_RECOVERY_AS_BOOT=0 |
| 122 | endif |
| 123 | |
Venkata Narendra Kumar Gutta | 688a161 | 2018-04-18 17:12:50 -0700 | [diff] [blame] | 124 | SAFESTACK_SUPPORTED_CLANG_VERSION = 6.0 |
| 125 | |
Maria Yu | 3a174b8 | 2017-06-23 19:33:26 +0800 | [diff] [blame] | 126 | # For most platform, abl needed always be built |
| 127 | # in aarch64 arthitecture to run. |
| 128 | # Specify BOOTLOADER_ARCH if needed to built with |
| 129 | # other ARCHs. |
| 130 | ifeq ($(BOOTLOADER_ARCH),) |
| 131 | BOOTLOADER_ARCH := AARCH64 |
| 132 | endif |
| 133 | TARGET_ARCHITECTURE := $(BOOTLOADER_ARCH) |
| 134 | |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 135 | ifeq ($(TARGET_ARCHITECTURE),arm) |
Bhanuprakash Modem | 2372010 | 2018-09-27 21:55:40 +0530 | [diff] [blame] | 136 | CLANG35_PREFIX := $(ANDROID_TOP)/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-$(TARGET_GCC_VERSION)/bin/arm-linux-androideabi- |
| 137 | CLANG35_GCC_TOOLCHAIN := $(ANDROID_TOP)/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-$(TARGET_GCC_VERSION) |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 138 | else |
Bhanuprakash Modem | 2372010 | 2018-09-27 21:55:40 +0530 | [diff] [blame] | 139 | CLANG35_PREFIX := $(ANDROID_TOP)/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-$(TARGET_GCC_VERSION)/bin/aarch64-linux-android- |
| 140 | CLANG35_GCC_TOOLCHAIN := $(ANDROID_TOP)/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-$(TARGET_GCC_VERSION) |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 141 | endif |
| 142 | |
| 143 | |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 144 | # ABL ELF output |
| 145 | TARGET_ABL := $(PRODUCT_OUT)/abl.elf |
Channagoud Kadabi | 9dff4e2 | 2016-02-10 11:19:49 -0800 | [diff] [blame] | 146 | TARGET_EMMC_BOOTLOADER := $(TARGET_ABL) |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 147 | ABL_OUT := $(TARGET_OUT_INTERMEDIATES)/ABL_OBJ |
| 148 | |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 149 | $(ABL_OUT): |
| 150 | mkdir -p $(ABL_OUT) |
| 151 | |
| 152 | # Top level target |
Tengfei Fan | 20def99 | 2019-08-01 15:03:47 +0800 | [diff] [blame] | 153 | LOCAL_ABL_PATH := bootable/bootloader/edk2 |
| 154 | LOCAL_ABL_SRC_FILE := $(shell find $(LOCAL_ABL_PATH) -name "*" -type f | sed "s%\.\/%$(LOCAL_ABL_PATH)\/%g") |
| 155 | $(TARGET_ABL): $(LOCAL_ABL_SRC_FILE) | $(ABL_OUT) $(INSTALLED_KEYSTOREIMAGE_TARGET) |
Bhanuprakash Modem | 200d4b1 | 2018-11-22 16:29:39 +0530 | [diff] [blame] | 156 | $(MAKEPATH)make -C bootable/bootloader/edk2 \ |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 157 | BOOTLOADER_OUT=../../../$(ABL_OUT) \ |
| 158 | all \ |
Bhanuprakash Modem | 2372010 | 2018-09-27 21:55:40 +0530 | [diff] [blame] | 159 | PREBUILT_HOST_TOOLS=$(PREBUILT_HOST_TOOLS) \ |
Bhanuprakash Modem | 78a89d7 | 2018-10-10 19:00:44 +0530 | [diff] [blame] | 160 | PREBUILT_PYTHON_PATH=$(PREBUILT_PYTHON_PATH) \ |
Bhanuprakash Modem | a64c964 | 2018-11-30 13:49:09 +0530 | [diff] [blame] | 161 | MAKEPATH=$(MAKEPATH) \ |
Mukesh Ojha | 8dc65f5 | 2018-03-27 00:59:30 +0530 | [diff] [blame] | 162 | $(BUILD_SYSTEM_ROOT_IMAGE) \ |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 163 | $(VERIFIED_BOOT) \ |
| 164 | $(VERIFIED_BOOT_2) \ |
Zhen Kong | dd5c5e3 | 2017-07-05 13:44:45 -0700 | [diff] [blame] | 165 | $(VERIFIED_BOOT_LE) \ |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 166 | $(USER_BUILD_VARIANT) \ |
Mukesh Ojha | d29676a | 2018-04-10 17:37:56 +0530 | [diff] [blame] | 167 | $(DISABLE_PARALLEL_DOWNLOAD_FLASH) \ |
Jeevan Shriram | 0a3ba0b | 2019-01-02 23:21:12 -0800 | [diff] [blame] | 168 | $(AB_RETRYCOUNT_DISABLE) \ |
Saranya Chidura | 30eb629 | 2019-02-20 15:27:37 +0530 | [diff] [blame] | 169 | $(DYNAMIC_PARTITION_SUPPORT) \ |
Anuj Garg | ae40955 | 2020-06-03 19:21:55 +0530 | [diff] [blame] | 170 | $(TARGET_BOARD_TYPE_AUTO) \ |
Jeevan Shriram | 91492b4 | 2020-01-20 17:34:53 -0800 | [diff] [blame] | 171 | $(VIRTUAL_AB_OTA) \ |
Raghavendra Rao Ananta | 508792f | 2019-12-09 14:11:21 -0800 | [diff] [blame] | 172 | $(BUILD_USES_RECOVERY_AS_BOOT) \ |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 173 | CLANG_BIN=$(CLANG_BIN) \ |
| 174 | CLANG_PREFIX=$(CLANG35_PREFIX)\ |
lijuang | 65c51d5 | 2018-03-28 13:52:57 +0800 | [diff] [blame] | 175 | ABL_USE_SDLLVM=$(ABL_USE_SDLLVM) \ |
Venkata Narendra Kumar Gutta | 688a161 | 2018-04-18 17:12:50 -0700 | [diff] [blame] | 176 | ABL_SAFESTACK=$(ABL_SAFESTACK) \ |
| 177 | SAFESTACK_SUPPORTED_CLANG_VERSION=$(SAFESTACK_SUPPORTED_CLANG_VERSION) \ |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 178 | CLANG_GCC_TOOLCHAIN=$(CLANG35_GCC_TOOLCHAIN)\ |
Jeevan Shriram | d5d169f | 2018-04-20 16:09:10 -0700 | [diff] [blame] | 179 | TARGET_ARCHITECTURE=$(TARGET_ARCHITECTURE) \ |
Prateek Sood | c86ef5d | 2020-01-30 00:18:13 +0530 | [diff] [blame] | 180 | BOARD_BOOTLOADER_PRODUCT_NAME=$(BOARD_BOOTLOADER_PRODUCT_NAME) \ |
Alexander Martinz | 32ab18a | 2020-06-02 14:06:24 +0200 | [diff] [blame] | 181 | BOARD_BOOTLOADER_PRODUCT_MODEL=$(BOARD_BOOTLOADER_PRODUCT_MODEL) \ |
Alexander Martinz | 932c429 | 2021-09-10 19:50:46 +0200 | [diff] [blame] | 182 | BOARD_BOOTLOADER_VERSION=$(BOARD_BOOTLOADER_VERSION) \ |
Prateek Sood | c86ef5d | 2020-01-30 00:18:13 +0530 | [diff] [blame] | 183 | USERDATAIMAGE_FILE_SYSTEM_TYPE=$(USERDATAIMAGE_FILE_SYSTEM_TYPE) |