blob: 25097db5f53dc57eeaf6bc78ee57cc36dba698a8 [file] [log] [blame]
Jeevan Shriram062058c2016-11-07 16:46:44 -08001#Android makefile to build bootloader as a part of Android Build
Bhanuprakash Modem23720102018-09-27 21:55:40 +05302ANDROID_TOP=$(shell pwd)
3CLANG_BIN := $(ANDROID_TOP)/$(LLVM_PREBUILTS_PATH)/
lijuang65c51d52018-03-28 13:52:57 +08004ABL_USE_SDLLVM := false
5
Paul Strong4568ca92019-12-16 14:28:11 -08006ifneq ($(FORCE_SDCLANG_OFF),true)
lijuang65c51d52018-03-28 13:52:57 +08007ifneq ($(wildcard $(SDCLANG_PATH)),)
8 ifeq ($(shell echo $(SDCLANG_PATH) | head -c 1),/)
9 CLANG_BIN := $(SDCLANG_PATH)/
10 else
Bhanuprakash Modem23720102018-09-27 21:55:40 +053011 CLANG_BIN := $(ANDROID_TOP)/$(SDCLANG_PATH)/
lijuang65c51d52018-03-28 13:52:57 +080012 endif
13
14 ABL_USE_SDLLVM := true
Ashwini Muduganti36db63f2017-12-12 14:20:38 -080015endif
Paul Strong4568ca92019-12-16 14:28:11 -080016endif
Ashwini Muduganti36db63f2017-12-12 14:20:38 -080017
Bhanuprakash Modem200d4b12018-11-22 16:29:39 +053018# LD & make are not available in prebuilts for older Android versions
Bhanuprakash Modem78a89d72018-10-10 19:00:44 +053019ifeq (1,$(filter 1,$(shell echo "$$(( $(PLATFORM_SDK_VERSION) > 27 ))" )))
20LDOPT="-fuse-ld=$(ANDROID_TOP)/$(SOONG_LLVM_PREBUILTS_PATH)/ld.lld"
Bhanuprakash Modem200d4b12018-11-22 16:29:39 +053021MAKEPATH=$(ANDROID_TOP)/prebuilts/build-tools/linux-x86/bin/
Bhanuprakash Modema64c9642018-11-30 13:49:09 +053022 ifeq (,$(wildcard $(MAKEPATH)make))
Bhanuprakash Modem200d4b12018-11-22 16:29:39 +053023 MAKEPATH :=
24 endif
Bhanuprakash Modem78a89d72018-10-10 19:00:44 +053025endif
26
Bhanuprakash Modem23720102018-09-27 21:55:40 +053027# Use host tools from prebuilts. Partner should determine the correct host tools to use
Bhanuprakash Modem78a89d72018-10-10 19:00:44 +053028PREBUILT_HOST_TOOLS := CC=$(ANDROID_TOP)/$(CLANG)\ \
29 CXX=$(ANDROID_TOP)/$(CLANG_CXX)\ \
30 LDPATH=$(LDOPT)\ \
Bhanuprakash Modem23720102018-09-27 21:55:40 +053031 AR=$(ANDROID_TOP)/$(HOST_AR)
Bhanuprakash Modem78a89d72018-10-10 19:00:44 +053032PREBUILT_PYTHON_PATH=$(ANDROID_TOP)/prebuilts/python/linux-x86/2.7.5/bin/python2
Bhanuprakash Modem23720102018-09-27 21:55:40 +053033
Mukesh Ojhad29676a2018-04-10 17:37:56 +053034DISABLE_PARALLEL_DOWNLOAD_FLASH := DISABLE_PARALLEL_DOWNLOAD_FLASH=0
Jeevan Shriram9e617b22019-11-27 13:54:42 -080035ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -080036 VERIFIED_BOOT := VERIFIED_BOOT=1
37else
38 VERIFIED_BOOT := VERIFIED_BOOT=0
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -080039endif
40
Mukesh Ojha8dc65f52018-03-27 00:59:30 +053041ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
42 BUILD_SYSTEM_ROOT_IMAGE := BUILD_SYSTEM_ROOT_IMAGE=1
43else
44 BUILD_SYSTEM_ROOT_IMAGE := BUILD_SYSTEM_ROOT_IMAGE=0
45endif
46
Shivaprasad Hongal3860bbf2017-04-27 17:40:13 -070047ifeq ($(BOARD_AVB_ENABLE),true)
48 VERIFIED_BOOT_2 := VERIFIED_BOOT_2=1
49else
50 VERIFIED_BOOT_2 := VERIFIED_BOOT_2=0
51endif
52
Zhen Kongdd5c5e32017-07-05 13:44:45 -070053ifeq ($(BOARD_LEVB_ENABLE),true)
54 VERIFIED_BOOT_LE := VERIFIED_BOOT_LE=1
55else
56 VERIFIED_BOOT_LE := VERIFIED_BOOT_LE=0
57endif
58
Jeevan Shriram0a3ba0b2019-01-02 23:21:12 -080059ifeq ($(TARGET_AB_RETRYCOUNT_DISABLE),true)
60 AB_RETRYCOUNT_DISABLE := AB_RETRYCOUNT_DISABLE=1
61else
62 AB_RETRYCOUNT_DISABLE := AB_RETRYCOUNT_DISABLE=0
63endif
64
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -080065ifeq ($(TARGET_BUILD_VARIANT),user)
Vijay Kumar Pendoti9946e042016-09-16 17:38:51 +053066 USER_BUILD_VARIANT := USER_BUILD_VARIANT=1
67else
68 USER_BUILD_VARIANT := USER_BUILD_VARIANT=0
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -080069endif
70
Jeevan Shriramd5d169f2018-04-20 16:09:10 -070071ifneq ($(TARGET_BOOTLOADER_BOARD_NAME),)
72 BOARD_BOOTLOADER_PRODUCT_NAME := $(TARGET_BOOTLOADER_BOARD_NAME)
73else
74 BOARD_BOOTLOADER_PRODUCT_NAME := QC_Reference_Phone
75endif
76
Alexander Martinz968ec912020-06-02 14:06:24 +020077ifneq ($(TARGET_BOOTLOADER_BOARD_MODEL),)
78 BOARD_BOOTLOADER_PRODUCT_MODEL := $(TARGET_BOOTLOADER_BOARD_MODEL)
79else
80 BOARD_BOOTLOADER_PRODUCT_MODEL := unknown
81endif
Alexander Martinza5ea42b2021-09-10 19:50:46 +020082ifneq ($(TARGET_BOOTLOADER_VERSION),)
83 BOARD_BOOTLOADER_VERSION := $(TARGET_BOOTLOADER_VERSION)
84else
85 BOARD_BOOTLOADER_VERSION := unknown
86endif
Alexander Martinz968ec912020-06-02 14:06:24 +020087
Anuj Gargae409552020-06-03 19:21:55 +053088ifneq ($(TARGET_BOARD_TYPE),auto)
89 TARGET_BOARD_TYPE_AUTO := TARGET_BOARD_TYPE_AUTO=0
90else
91 TARGET_BOARD_TYPE_AUTO := TARGET_BOARD_TYPE_AUTO=1
92endif
Prateek Soodc86ef5d2020-01-30 00:18:13 +053093
94ifneq ($(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),)
95 USERDATAIMAGE_FILE_SYSTEM_TYPE := $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)
96else
97 USERDATAIMAGE_FILE_SYSTEM_TYPE := ext4
98endif
99
Venkata Narendra Kumar Gutta688a1612018-04-18 17:12:50 -0700100ifeq ($(BOARD_ABL_SAFESTACK_DISABLE),true)
101 ABL_SAFESTACK := false
102else
103 ABL_SAFESTACK := true
104endif
105
Saranya Chidura30eb6292019-02-20 15:27:37 +0530106ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true)
107 DYNAMIC_PARTITION_SUPPORT := DYNAMIC_PARTITION_SUPPORT=1
108else
109 DYNAMIC_PARTITION_SUPPORT := DYNAMIC_PARTITION_SUPPORT=0
110endif
111
Jeevan Shriram91492b42020-01-20 17:34:53 -0800112ifeq ($(PRODUCT_VIRTUAL_AB_OTA),true)
113 VIRTUAL_AB_OTA := VIRTUAL_AB_OTA=1
114else
115 VIRTUAL_AB_OTA := VIRTUAL_AB_OTA=0
116endif
117
Raghavendra Rao Ananta508792f2019-12-09 14:11:21 -0800118ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
119 BUILD_USES_RECOVERY_AS_BOOT := BUILD_USES_RECOVERY_AS_BOOT=1
120else
121 BUILD_USES_RECOVERY_AS_BOOT := BUILD_USES_RECOVERY_AS_BOOT=0
122endif
123
Venkata Narendra Kumar Gutta688a1612018-04-18 17:12:50 -0700124SAFESTACK_SUPPORTED_CLANG_VERSION = 6.0
125
Maria Yu3a174b82017-06-23 19:33:26 +0800126# 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.
130ifeq ($(BOOTLOADER_ARCH),)
131 BOOTLOADER_ARCH := AARCH64
132endif
133TARGET_ARCHITECTURE := $(BOOTLOADER_ARCH)
134
Jeevan Shriramd29e4402017-11-06 14:04:11 -0800135ifeq ($(TARGET_ARCHITECTURE),arm)
Bhanuprakash Modem23720102018-09-27 21:55:40 +0530136 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 Shriramd29e4402017-11-06 14:04:11 -0800138else
Bhanuprakash Modem23720102018-09-27 21:55:40 +0530139 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 Shriramd29e4402017-11-06 14:04:11 -0800141endif
142
143
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -0800144# ABL ELF output
145TARGET_ABL := $(PRODUCT_OUT)/abl.elf
Channagoud Kadabi9dff4e22016-02-10 11:19:49 -0800146TARGET_EMMC_BOOTLOADER := $(TARGET_ABL)
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -0800147ABL_OUT := $(TARGET_OUT_INTERMEDIATES)/ABL_OBJ
148
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -0800149$(ABL_OUT):
150 mkdir -p $(ABL_OUT)
151
152# Top level target
Tengfei Fan20def992019-08-01 15:03:47 +0800153LOCAL_ABL_PATH := bootable/bootloader/edk2
154LOCAL_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 Modem200d4b12018-11-22 16:29:39 +0530156 $(MAKEPATH)make -C bootable/bootloader/edk2 \
Jeevan Shriramd29e4402017-11-06 14:04:11 -0800157 BOOTLOADER_OUT=../../../$(ABL_OUT) \
158 all \
Bhanuprakash Modem23720102018-09-27 21:55:40 +0530159 PREBUILT_HOST_TOOLS=$(PREBUILT_HOST_TOOLS) \
Bhanuprakash Modem78a89d72018-10-10 19:00:44 +0530160 PREBUILT_PYTHON_PATH=$(PREBUILT_PYTHON_PATH) \
Bhanuprakash Modema64c9642018-11-30 13:49:09 +0530161 MAKEPATH=$(MAKEPATH) \
Mukesh Ojha8dc65f52018-03-27 00:59:30 +0530162 $(BUILD_SYSTEM_ROOT_IMAGE) \
Jeevan Shriramd29e4402017-11-06 14:04:11 -0800163 $(VERIFIED_BOOT) \
164 $(VERIFIED_BOOT_2) \
Zhen Kongdd5c5e32017-07-05 13:44:45 -0700165 $(VERIFIED_BOOT_LE) \
Jeevan Shriramd29e4402017-11-06 14:04:11 -0800166 $(USER_BUILD_VARIANT) \
Mukesh Ojhad29676a2018-04-10 17:37:56 +0530167 $(DISABLE_PARALLEL_DOWNLOAD_FLASH) \
Jeevan Shriram0a3ba0b2019-01-02 23:21:12 -0800168 $(AB_RETRYCOUNT_DISABLE) \
Saranya Chidura30eb6292019-02-20 15:27:37 +0530169 $(DYNAMIC_PARTITION_SUPPORT) \
Anuj Gargae409552020-06-03 19:21:55 +0530170 $(TARGET_BOARD_TYPE_AUTO) \
Jeevan Shriram91492b42020-01-20 17:34:53 -0800171 $(VIRTUAL_AB_OTA) \
Raghavendra Rao Ananta508792f2019-12-09 14:11:21 -0800172 $(BUILD_USES_RECOVERY_AS_BOOT) \
Jeevan Shriramd29e4402017-11-06 14:04:11 -0800173 CLANG_BIN=$(CLANG_BIN) \
174 CLANG_PREFIX=$(CLANG35_PREFIX)\
lijuang65c51d52018-03-28 13:52:57 +0800175 ABL_USE_SDLLVM=$(ABL_USE_SDLLVM) \
Venkata Narendra Kumar Gutta688a1612018-04-18 17:12:50 -0700176 ABL_SAFESTACK=$(ABL_SAFESTACK) \
177 SAFESTACK_SUPPORTED_CLANG_VERSION=$(SAFESTACK_SUPPORTED_CLANG_VERSION) \
Jeevan Shriramd29e4402017-11-06 14:04:11 -0800178 CLANG_GCC_TOOLCHAIN=$(CLANG35_GCC_TOOLCHAIN)\
Jeevan Shriramd5d169f2018-04-20 16:09:10 -0700179 TARGET_ARCHITECTURE=$(TARGET_ARCHITECTURE) \
Prateek Soodc86ef5d2020-01-30 00:18:13 +0530180 BOARD_BOOTLOADER_PRODUCT_NAME=$(BOARD_BOOTLOADER_PRODUCT_NAME) \
Alexander Martinz968ec912020-06-02 14:06:24 +0200181 BOARD_BOOTLOADER_PRODUCT_MODEL=$(BOARD_BOOTLOADER_PRODUCT_MODEL) \
Alexander Martinza5ea42b2021-09-10 19:50:46 +0200182 BOARD_BOOTLOADER_VERSION=$(BOARD_BOOTLOADER_VERSION) \
Prateek Soodc86ef5d2020-01-30 00:18:13 +0530183 USERDATAIMAGE_FILE_SYSTEM_TYPE=$(USERDATAIMAGE_FILE_SYSTEM_TYPE)