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 | |
| 6 | ifneq ($(wildcard $(SDCLANG_PATH)),) |
| 7 | ifeq ($(shell echo $(SDCLANG_PATH) | head -c 1),/) |
| 8 | CLANG_BIN := $(SDCLANG_PATH)/ |
| 9 | else |
Bhanuprakash Modem | 2372010 | 2018-09-27 21:55:40 +0530 | [diff] [blame] | 10 | CLANG_BIN := $(ANDROID_TOP)/$(SDCLANG_PATH)/ |
lijuang | 65c51d5 | 2018-03-28 13:52:57 +0800 | [diff] [blame] | 11 | endif |
| 12 | |
| 13 | ABL_USE_SDLLVM := true |
Ashwini Muduganti | 36db63f | 2017-12-12 14:20:38 -0800 | [diff] [blame] | 14 | endif |
| 15 | |
Bhanuprakash Modem | 200d4b1 | 2018-11-22 16:29:39 +0530 | [diff] [blame] | 16 | # LD & make are not available in prebuilts for older Android versions |
Bhanuprakash Modem | 78a89d7 | 2018-10-10 19:00:44 +0530 | [diff] [blame] | 17 | ifeq (1,$(filter 1,$(shell echo "$$(( $(PLATFORM_SDK_VERSION) > 27 ))" ))) |
| 18 | LDOPT="-fuse-ld=$(ANDROID_TOP)/$(SOONG_LLVM_PREBUILTS_PATH)/ld.lld" |
Bhanuprakash Modem | 200d4b1 | 2018-11-22 16:29:39 +0530 | [diff] [blame] | 19 | MAKEPATH=$(ANDROID_TOP)/prebuilts/build-tools/linux-x86/bin/ |
Bhanuprakash Modem | a64c964 | 2018-11-30 13:49:09 +0530 | [diff] [blame] | 20 | ifeq (,$(wildcard $(MAKEPATH)make)) |
Bhanuprakash Modem | 200d4b1 | 2018-11-22 16:29:39 +0530 | [diff] [blame] | 21 | MAKEPATH := |
| 22 | endif |
Bhanuprakash Modem | 78a89d7 | 2018-10-10 19:00:44 +0530 | [diff] [blame] | 23 | endif |
| 24 | |
Bhanuprakash Modem | 2372010 | 2018-09-27 21:55:40 +0530 | [diff] [blame] | 25 | # 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] | 26 | PREBUILT_HOST_TOOLS := CC=$(ANDROID_TOP)/$(CLANG)\ \ |
| 27 | CXX=$(ANDROID_TOP)/$(CLANG_CXX)\ \ |
| 28 | LDPATH=$(LDOPT)\ \ |
Bhanuprakash Modem | 2372010 | 2018-09-27 21:55:40 +0530 | [diff] [blame] | 29 | AR=$(ANDROID_TOP)/$(HOST_AR) |
Bhanuprakash Modem | 78a89d7 | 2018-10-10 19:00:44 +0530 | [diff] [blame] | 30 | 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] | 31 | |
Mukesh Ojha | d29676a | 2018-04-10 17:37:56 +0530 | [diff] [blame] | 32 | DISABLE_PARALLEL_DOWNLOAD_FLASH := DISABLE_PARALLEL_DOWNLOAD_FLASH=0 |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 33 | ifeq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),true) |
| 34 | VERIFIED_BOOT := VERIFIED_BOOT=1 |
| 35 | else |
| 36 | VERIFIED_BOOT := VERIFIED_BOOT=0 |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 37 | endif |
| 38 | |
Mukesh Ojha | 8dc65f5 | 2018-03-27 00:59:30 +0530 | [diff] [blame] | 39 | ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true) |
| 40 | BUILD_SYSTEM_ROOT_IMAGE := BUILD_SYSTEM_ROOT_IMAGE=1 |
| 41 | else |
| 42 | BUILD_SYSTEM_ROOT_IMAGE := BUILD_SYSTEM_ROOT_IMAGE=0 |
| 43 | endif |
| 44 | |
Shivaprasad Hongal | 3860bbf | 2017-04-27 17:40:13 -0700 | [diff] [blame] | 45 | ifeq ($(BOARD_AVB_ENABLE),true) |
| 46 | VERIFIED_BOOT_2 := VERIFIED_BOOT_2=1 |
| 47 | else |
| 48 | VERIFIED_BOOT_2 := VERIFIED_BOOT_2=0 |
| 49 | endif |
| 50 | |
Zhen Kong | dd5c5e3 | 2017-07-05 13:44:45 -0700 | [diff] [blame] | 51 | ifeq ($(BOARD_LEVB_ENABLE),true) |
| 52 | VERIFIED_BOOT_LE := VERIFIED_BOOT_LE=1 |
| 53 | else |
| 54 | VERIFIED_BOOT_LE := VERIFIED_BOOT_LE=0 |
| 55 | endif |
| 56 | |
Jeevan Shriram | 0a3ba0b | 2019-01-02 23:21:12 -0800 | [diff] [blame] | 57 | ifeq ($(TARGET_AB_RETRYCOUNT_DISABLE),true) |
| 58 | AB_RETRYCOUNT_DISABLE := AB_RETRYCOUNT_DISABLE=1 |
| 59 | else |
| 60 | AB_RETRYCOUNT_DISABLE := AB_RETRYCOUNT_DISABLE=0 |
| 61 | endif |
| 62 | |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 63 | ifeq ($(TARGET_BUILD_VARIANT),user) |
Vijay Kumar Pendoti | 9946e04 | 2016-09-16 17:38:51 +0530 | [diff] [blame] | 64 | USER_BUILD_VARIANT := USER_BUILD_VARIANT=1 |
| 65 | else |
| 66 | USER_BUILD_VARIANT := USER_BUILD_VARIANT=0 |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 67 | endif |
| 68 | |
Jeevan Shriram | d5d169f | 2018-04-20 16:09:10 -0700 | [diff] [blame] | 69 | ifneq ($(TARGET_BOOTLOADER_BOARD_NAME),) |
| 70 | BOARD_BOOTLOADER_PRODUCT_NAME := $(TARGET_BOOTLOADER_BOARD_NAME) |
| 71 | else |
| 72 | BOARD_BOOTLOADER_PRODUCT_NAME := QC_Reference_Phone |
| 73 | endif |
| 74 | |
Venkata Narendra Kumar Gutta | 688a161 | 2018-04-18 17:12:50 -0700 | [diff] [blame] | 75 | ifeq ($(BOARD_ABL_SAFESTACK_DISABLE),true) |
| 76 | ABL_SAFESTACK := false |
| 77 | else |
| 78 | ABL_SAFESTACK := true |
| 79 | endif |
| 80 | |
Saranya Chidura | 30eb629 | 2019-02-20 15:27:37 +0530 | [diff] [blame] | 81 | ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true) |
| 82 | DYNAMIC_PARTITION_SUPPORT := DYNAMIC_PARTITION_SUPPORT=1 |
| 83 | else |
| 84 | DYNAMIC_PARTITION_SUPPORT := DYNAMIC_PARTITION_SUPPORT=0 |
| 85 | endif |
| 86 | |
Venkata Narendra Kumar Gutta | 688a161 | 2018-04-18 17:12:50 -0700 | [diff] [blame] | 87 | SAFESTACK_SUPPORTED_CLANG_VERSION = 6.0 |
| 88 | |
Maria Yu | 3a174b8 | 2017-06-23 19:33:26 +0800 | [diff] [blame] | 89 | # For most platform, abl needed always be built |
| 90 | # in aarch64 arthitecture to run. |
| 91 | # Specify BOOTLOADER_ARCH if needed to built with |
| 92 | # other ARCHs. |
| 93 | ifeq ($(BOOTLOADER_ARCH),) |
| 94 | BOOTLOADER_ARCH := AARCH64 |
| 95 | endif |
| 96 | TARGET_ARCHITECTURE := $(BOOTLOADER_ARCH) |
| 97 | |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 98 | ifeq ($(TARGET_ARCHITECTURE),arm) |
Bhanuprakash Modem | 2372010 | 2018-09-27 21:55:40 +0530 | [diff] [blame] | 99 | CLANG35_PREFIX := $(ANDROID_TOP)/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-$(TARGET_GCC_VERSION)/bin/arm-linux-androideabi- |
| 100 | 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] | 101 | else |
Bhanuprakash Modem | 2372010 | 2018-09-27 21:55:40 +0530 | [diff] [blame] | 102 | CLANG35_PREFIX := $(ANDROID_TOP)/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-$(TARGET_GCC_VERSION)/bin/aarch64-linux-android- |
| 103 | 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] | 104 | endif |
| 105 | |
| 106 | |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 107 | # ABL ELF output |
| 108 | TARGET_ABL := $(PRODUCT_OUT)/abl.elf |
Channagoud Kadabi | 9dff4e2 | 2016-02-10 11:19:49 -0800 | [diff] [blame] | 109 | TARGET_EMMC_BOOTLOADER := $(TARGET_ABL) |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 110 | ABL_OUT := $(TARGET_OUT_INTERMEDIATES)/ABL_OBJ |
| 111 | |
| 112 | abl_clean: |
| 113 | $(hide) rm -f $(TARGET_ABL) |
| 114 | |
| 115 | $(ABL_OUT): |
| 116 | mkdir -p $(ABL_OUT) |
| 117 | |
| 118 | # Top level target |
Tengfei Fan | 20def99 | 2019-08-01 15:03:47 +0800 | [diff] [blame^] | 119 | LOCAL_ABL_PATH := bootable/bootloader/edk2 |
| 120 | LOCAL_ABL_SRC_FILE := $(shell find $(LOCAL_ABL_PATH) -name "*" -type f | sed "s%\.\/%$(LOCAL_ABL_PATH)\/%g") |
| 121 | $(TARGET_ABL): $(LOCAL_ABL_SRC_FILE) | $(ABL_OUT) $(INSTALLED_KEYSTOREIMAGE_TARGET) |
Bhanuprakash Modem | 200d4b1 | 2018-11-22 16:29:39 +0530 | [diff] [blame] | 122 | $(MAKEPATH)make -C bootable/bootloader/edk2 \ |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 123 | BOOTLOADER_OUT=../../../$(ABL_OUT) \ |
| 124 | all \ |
Bhanuprakash Modem | 2372010 | 2018-09-27 21:55:40 +0530 | [diff] [blame] | 125 | PREBUILT_HOST_TOOLS=$(PREBUILT_HOST_TOOLS) \ |
Bhanuprakash Modem | 78a89d7 | 2018-10-10 19:00:44 +0530 | [diff] [blame] | 126 | PREBUILT_PYTHON_PATH=$(PREBUILT_PYTHON_PATH) \ |
Bhanuprakash Modem | a64c964 | 2018-11-30 13:49:09 +0530 | [diff] [blame] | 127 | MAKEPATH=$(MAKEPATH) \ |
Mukesh Ojha | 8dc65f5 | 2018-03-27 00:59:30 +0530 | [diff] [blame] | 128 | $(BUILD_SYSTEM_ROOT_IMAGE) \ |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 129 | $(VERIFIED_BOOT) \ |
| 130 | $(VERIFIED_BOOT_2) \ |
Zhen Kong | dd5c5e3 | 2017-07-05 13:44:45 -0700 | [diff] [blame] | 131 | $(VERIFIED_BOOT_LE) \ |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 132 | $(USER_BUILD_VARIANT) \ |
Mukesh Ojha | d29676a | 2018-04-10 17:37:56 +0530 | [diff] [blame] | 133 | $(DISABLE_PARALLEL_DOWNLOAD_FLASH) \ |
Jeevan Shriram | 0a3ba0b | 2019-01-02 23:21:12 -0800 | [diff] [blame] | 134 | $(AB_RETRYCOUNT_DISABLE) \ |
Saranya Chidura | 30eb629 | 2019-02-20 15:27:37 +0530 | [diff] [blame] | 135 | $(DYNAMIC_PARTITION_SUPPORT) \ |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 136 | CLANG_BIN=$(CLANG_BIN) \ |
| 137 | CLANG_PREFIX=$(CLANG35_PREFIX)\ |
lijuang | 65c51d5 | 2018-03-28 13:52:57 +0800 | [diff] [blame] | 138 | ABL_USE_SDLLVM=$(ABL_USE_SDLLVM) \ |
Venkata Narendra Kumar Gutta | 688a161 | 2018-04-18 17:12:50 -0700 | [diff] [blame] | 139 | ABL_SAFESTACK=$(ABL_SAFESTACK) \ |
| 140 | SAFESTACK_SUPPORTED_CLANG_VERSION=$(SAFESTACK_SUPPORTED_CLANG_VERSION) \ |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 141 | CLANG_GCC_TOOLCHAIN=$(CLANG35_GCC_TOOLCHAIN)\ |
Jeevan Shriram | d5d169f | 2018-04-20 16:09:10 -0700 | [diff] [blame] | 142 | TARGET_ARCHITECTURE=$(TARGET_ARCHITECTURE) \ |
| 143 | BOARD_BOOTLOADER_PRODUCT_NAME=$(BOARD_BOOTLOADER_PRODUCT_NAME) |