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 | |
Mukesh Ojha | d29676a | 2018-04-10 17:37:56 +0530 | [diff] [blame] | 34 | DISABLE_PARALLEL_DOWNLOAD_FLASH := DISABLE_PARALLEL_DOWNLOAD_FLASH=0 |
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 | |
Anuj Garg | ae40955 | 2020-06-03 19:21:55 +0530 | [diff] [blame] | 77 | ifneq ($(TARGET_BOARD_TYPE),auto) |
| 78 | TARGET_BOARD_TYPE_AUTO := TARGET_BOARD_TYPE_AUTO=0 |
| 79 | else |
| 80 | TARGET_BOARD_TYPE_AUTO := TARGET_BOARD_TYPE_AUTO=1 |
| 81 | endif |
Venkata Narendra Kumar Gutta | 688a161 | 2018-04-18 17:12:50 -0700 | [diff] [blame] | 82 | ifeq ($(BOARD_ABL_SAFESTACK_DISABLE),true) |
| 83 | ABL_SAFESTACK := false |
| 84 | else |
| 85 | ABL_SAFESTACK := true |
| 86 | endif |
| 87 | |
Saranya Chidura | 30eb629 | 2019-02-20 15:27:37 +0530 | [diff] [blame] | 88 | ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true) |
| 89 | DYNAMIC_PARTITION_SUPPORT := DYNAMIC_PARTITION_SUPPORT=1 |
| 90 | else |
| 91 | DYNAMIC_PARTITION_SUPPORT := DYNAMIC_PARTITION_SUPPORT=0 |
| 92 | endif |
| 93 | |
Jeevan Shriram | 91492b4 | 2020-01-20 17:34:53 -0800 | [diff] [blame] | 94 | ifeq ($(PRODUCT_VIRTUAL_AB_OTA),true) |
| 95 | VIRTUAL_AB_OTA := VIRTUAL_AB_OTA=1 |
| 96 | else |
| 97 | VIRTUAL_AB_OTA := VIRTUAL_AB_OTA=0 |
| 98 | endif |
| 99 | |
Raghavendra Rao Ananta | 508792f | 2019-12-09 14:11:21 -0800 | [diff] [blame] | 100 | ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true) |
| 101 | BUILD_USES_RECOVERY_AS_BOOT := BUILD_USES_RECOVERY_AS_BOOT=1 |
| 102 | else |
| 103 | BUILD_USES_RECOVERY_AS_BOOT := BUILD_USES_RECOVERY_AS_BOOT=0 |
| 104 | endif |
| 105 | |
Venkata Narendra Kumar Gutta | 688a161 | 2018-04-18 17:12:50 -0700 | [diff] [blame] | 106 | SAFESTACK_SUPPORTED_CLANG_VERSION = 6.0 |
| 107 | |
Maria Yu | 3a174b8 | 2017-06-23 19:33:26 +0800 | [diff] [blame] | 108 | # For most platform, abl needed always be built |
| 109 | # in aarch64 arthitecture to run. |
| 110 | # Specify BOOTLOADER_ARCH if needed to built with |
| 111 | # other ARCHs. |
| 112 | ifeq ($(BOOTLOADER_ARCH),) |
| 113 | BOOTLOADER_ARCH := AARCH64 |
| 114 | endif |
| 115 | TARGET_ARCHITECTURE := $(BOOTLOADER_ARCH) |
| 116 | |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 117 | ifeq ($(TARGET_ARCHITECTURE),arm) |
Bhanuprakash Modem | 2372010 | 2018-09-27 21:55:40 +0530 | [diff] [blame] | 118 | CLANG35_PREFIX := $(ANDROID_TOP)/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-$(TARGET_GCC_VERSION)/bin/arm-linux-androideabi- |
| 119 | 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] | 120 | else |
Bhanuprakash Modem | 2372010 | 2018-09-27 21:55:40 +0530 | [diff] [blame] | 121 | CLANG35_PREFIX := $(ANDROID_TOP)/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-$(TARGET_GCC_VERSION)/bin/aarch64-linux-android- |
| 122 | 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] | 123 | endif |
| 124 | |
| 125 | |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 126 | # ABL ELF output |
| 127 | TARGET_ABL := $(PRODUCT_OUT)/abl.elf |
Channagoud Kadabi | 9dff4e2 | 2016-02-10 11:19:49 -0800 | [diff] [blame] | 128 | TARGET_EMMC_BOOTLOADER := $(TARGET_ABL) |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 129 | ABL_OUT := $(TARGET_OUT_INTERMEDIATES)/ABL_OBJ |
| 130 | |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 131 | $(ABL_OUT): |
| 132 | mkdir -p $(ABL_OUT) |
| 133 | |
| 134 | # Top level target |
Tengfei Fan | 20def99 | 2019-08-01 15:03:47 +0800 | [diff] [blame] | 135 | LOCAL_ABL_PATH := bootable/bootloader/edk2 |
| 136 | LOCAL_ABL_SRC_FILE := $(shell find $(LOCAL_ABL_PATH) -name "*" -type f | sed "s%\.\/%$(LOCAL_ABL_PATH)\/%g") |
| 137 | $(TARGET_ABL): $(LOCAL_ABL_SRC_FILE) | $(ABL_OUT) $(INSTALLED_KEYSTOREIMAGE_TARGET) |
Bhanuprakash Modem | 200d4b1 | 2018-11-22 16:29:39 +0530 | [diff] [blame] | 138 | $(MAKEPATH)make -C bootable/bootloader/edk2 \ |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 139 | BOOTLOADER_OUT=../../../$(ABL_OUT) \ |
| 140 | all \ |
Bhanuprakash Modem | 2372010 | 2018-09-27 21:55:40 +0530 | [diff] [blame] | 141 | PREBUILT_HOST_TOOLS=$(PREBUILT_HOST_TOOLS) \ |
Bhanuprakash Modem | 78a89d7 | 2018-10-10 19:00:44 +0530 | [diff] [blame] | 142 | PREBUILT_PYTHON_PATH=$(PREBUILT_PYTHON_PATH) \ |
Bhanuprakash Modem | a64c964 | 2018-11-30 13:49:09 +0530 | [diff] [blame] | 143 | MAKEPATH=$(MAKEPATH) \ |
Mukesh Ojha | 8dc65f5 | 2018-03-27 00:59:30 +0530 | [diff] [blame] | 144 | $(BUILD_SYSTEM_ROOT_IMAGE) \ |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 145 | $(VERIFIED_BOOT) \ |
| 146 | $(VERIFIED_BOOT_2) \ |
Zhen Kong | dd5c5e3 | 2017-07-05 13:44:45 -0700 | [diff] [blame] | 147 | $(VERIFIED_BOOT_LE) \ |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 148 | $(USER_BUILD_VARIANT) \ |
Mukesh Ojha | d29676a | 2018-04-10 17:37:56 +0530 | [diff] [blame] | 149 | $(DISABLE_PARALLEL_DOWNLOAD_FLASH) \ |
Jeevan Shriram | 0a3ba0b | 2019-01-02 23:21:12 -0800 | [diff] [blame] | 150 | $(AB_RETRYCOUNT_DISABLE) \ |
Saranya Chidura | 30eb629 | 2019-02-20 15:27:37 +0530 | [diff] [blame] | 151 | $(DYNAMIC_PARTITION_SUPPORT) \ |
Anuj Garg | ae40955 | 2020-06-03 19:21:55 +0530 | [diff] [blame] | 152 | $(TARGET_BOARD_TYPE_AUTO) \ |
Jeevan Shriram | 91492b4 | 2020-01-20 17:34:53 -0800 | [diff] [blame] | 153 | $(VIRTUAL_AB_OTA) \ |
Raghavendra Rao Ananta | 508792f | 2019-12-09 14:11:21 -0800 | [diff] [blame] | 154 | $(BUILD_USES_RECOVERY_AS_BOOT) \ |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 155 | CLANG_BIN=$(CLANG_BIN) \ |
| 156 | CLANG_PREFIX=$(CLANG35_PREFIX)\ |
lijuang | 65c51d5 | 2018-03-28 13:52:57 +0800 | [diff] [blame] | 157 | ABL_USE_SDLLVM=$(ABL_USE_SDLLVM) \ |
Venkata Narendra Kumar Gutta | 688a161 | 2018-04-18 17:12:50 -0700 | [diff] [blame] | 158 | ABL_SAFESTACK=$(ABL_SAFESTACK) \ |
| 159 | SAFESTACK_SUPPORTED_CLANG_VERSION=$(SAFESTACK_SUPPORTED_CLANG_VERSION) \ |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 160 | CLANG_GCC_TOOLCHAIN=$(CLANG35_GCC_TOOLCHAIN)\ |
Jeevan Shriram | d5d169f | 2018-04-20 16:09:10 -0700 | [diff] [blame] | 161 | TARGET_ARCHITECTURE=$(TARGET_ARCHITECTURE) \ |
| 162 | BOARD_BOOTLOADER_PRODUCT_NAME=$(BOARD_BOOTLOADER_PRODUCT_NAME) |