blob: 9a3fd3a1f91808170689bb2eb870ba28360fad68 [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
6ifneq ($(wildcard $(SDCLANG_PATH)),)
7 ifeq ($(shell echo $(SDCLANG_PATH) | head -c 1),/)
8 CLANG_BIN := $(SDCLANG_PATH)/
9 else
Bhanuprakash Modem23720102018-09-27 21:55:40 +053010 CLANG_BIN := $(ANDROID_TOP)/$(SDCLANG_PATH)/
lijuang65c51d52018-03-28 13:52:57 +080011 endif
12
13 ABL_USE_SDLLVM := true
Ashwini Muduganti36db63f2017-12-12 14:20:38 -080014endif
15
Bhanuprakash Modem200d4b12018-11-22 16:29:39 +053016# LD & make are not available in prebuilts for older Android versions
Bhanuprakash Modem78a89d72018-10-10 19:00:44 +053017ifeq (1,$(filter 1,$(shell echo "$$(( $(PLATFORM_SDK_VERSION) > 27 ))" )))
18LDOPT="-fuse-ld=$(ANDROID_TOP)/$(SOONG_LLVM_PREBUILTS_PATH)/ld.lld"
Bhanuprakash Modem200d4b12018-11-22 16:29:39 +053019MAKEPATH=$(ANDROID_TOP)/prebuilts/build-tools/linux-x86/bin/
Bhanuprakash Modema64c9642018-11-30 13:49:09 +053020 ifeq (,$(wildcard $(MAKEPATH)make))
Bhanuprakash Modem200d4b12018-11-22 16:29:39 +053021 MAKEPATH :=
22 endif
Bhanuprakash Modem78a89d72018-10-10 19:00:44 +053023endif
24
Bhanuprakash Modem23720102018-09-27 21:55:40 +053025# Use host tools from prebuilts. Partner should determine the correct host tools to use
Bhanuprakash Modem78a89d72018-10-10 19:00:44 +053026PREBUILT_HOST_TOOLS := CC=$(ANDROID_TOP)/$(CLANG)\ \
27 CXX=$(ANDROID_TOP)/$(CLANG_CXX)\ \
28 LDPATH=$(LDOPT)\ \
Bhanuprakash Modem23720102018-09-27 21:55:40 +053029 AR=$(ANDROID_TOP)/$(HOST_AR)
Bhanuprakash Modem78a89d72018-10-10 19:00:44 +053030PREBUILT_PYTHON_PATH=$(ANDROID_TOP)/prebuilts/python/linux-x86/2.7.5/bin/python2
Bhanuprakash Modem23720102018-09-27 21:55:40 +053031
Mukesh Ojhad29676a2018-04-10 17:37:56 +053032DISABLE_PARALLEL_DOWNLOAD_FLASH := DISABLE_PARALLEL_DOWNLOAD_FLASH=0
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -080033ifeq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),true)
34 VERIFIED_BOOT := VERIFIED_BOOT=1
35else
36 VERIFIED_BOOT := VERIFIED_BOOT=0
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -080037endif
38
Mukesh Ojha8dc65f52018-03-27 00:59:30 +053039ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
40 BUILD_SYSTEM_ROOT_IMAGE := BUILD_SYSTEM_ROOT_IMAGE=1
41else
42 BUILD_SYSTEM_ROOT_IMAGE := BUILD_SYSTEM_ROOT_IMAGE=0
43endif
44
Shivaprasad Hongal3860bbf2017-04-27 17:40:13 -070045ifeq ($(BOARD_AVB_ENABLE),true)
46 VERIFIED_BOOT_2 := VERIFIED_BOOT_2=1
47else
48 VERIFIED_BOOT_2 := VERIFIED_BOOT_2=0
49endif
50
Zhen Kongdd5c5e32017-07-05 13:44:45 -070051ifeq ($(BOARD_LEVB_ENABLE),true)
52 VERIFIED_BOOT_LE := VERIFIED_BOOT_LE=1
53else
54 VERIFIED_BOOT_LE := VERIFIED_BOOT_LE=0
55endif
56
Jeevan Shriram0a3ba0b2019-01-02 23:21:12 -080057ifeq ($(TARGET_AB_RETRYCOUNT_DISABLE),true)
58 AB_RETRYCOUNT_DISABLE := AB_RETRYCOUNT_DISABLE=1
59else
60 AB_RETRYCOUNT_DISABLE := AB_RETRYCOUNT_DISABLE=0
61endif
62
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -080063ifeq ($(TARGET_BUILD_VARIANT),user)
Vijay Kumar Pendoti9946e042016-09-16 17:38:51 +053064 USER_BUILD_VARIANT := USER_BUILD_VARIANT=1
65else
66 USER_BUILD_VARIANT := USER_BUILD_VARIANT=0
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -080067endif
68
Jeevan Shriramd5d169f2018-04-20 16:09:10 -070069ifneq ($(TARGET_BOOTLOADER_BOARD_NAME),)
70 BOARD_BOOTLOADER_PRODUCT_NAME := $(TARGET_BOOTLOADER_BOARD_NAME)
71else
72 BOARD_BOOTLOADER_PRODUCT_NAME := QC_Reference_Phone
73endif
74
Venkata Narendra Kumar Gutta688a1612018-04-18 17:12:50 -070075ifeq ($(BOARD_ABL_SAFESTACK_DISABLE),true)
76 ABL_SAFESTACK := false
77else
78 ABL_SAFESTACK := true
79endif
80
81SAFESTACK_SUPPORTED_CLANG_VERSION = 6.0
82
Maria Yu3a174b82017-06-23 19:33:26 +080083# For most platform, abl needed always be built
84# in aarch64 arthitecture to run.
85# Specify BOOTLOADER_ARCH if needed to built with
86# other ARCHs.
87ifeq ($(BOOTLOADER_ARCH),)
88 BOOTLOADER_ARCH := AARCH64
89endif
90TARGET_ARCHITECTURE := $(BOOTLOADER_ARCH)
91
Jeevan Shriramd29e4402017-11-06 14:04:11 -080092ifeq ($(TARGET_ARCHITECTURE),arm)
Bhanuprakash Modem23720102018-09-27 21:55:40 +053093 CLANG35_PREFIX := $(ANDROID_TOP)/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-$(TARGET_GCC_VERSION)/bin/arm-linux-androideabi-
94 CLANG35_GCC_TOOLCHAIN := $(ANDROID_TOP)/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-$(TARGET_GCC_VERSION)
Jeevan Shriramd29e4402017-11-06 14:04:11 -080095else
Bhanuprakash Modem23720102018-09-27 21:55:40 +053096 CLANG35_PREFIX := $(ANDROID_TOP)/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-$(TARGET_GCC_VERSION)/bin/aarch64-linux-android-
97 CLANG35_GCC_TOOLCHAIN := $(ANDROID_TOP)/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-$(TARGET_GCC_VERSION)
Jeevan Shriramd29e4402017-11-06 14:04:11 -080098endif
99
100
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -0800101# ABL ELF output
102TARGET_ABL := $(PRODUCT_OUT)/abl.elf
Channagoud Kadabi9dff4e22016-02-10 11:19:49 -0800103TARGET_EMMC_BOOTLOADER := $(TARGET_ABL)
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -0800104ABL_OUT := $(TARGET_OUT_INTERMEDIATES)/ABL_OBJ
105
106abl_clean:
107 $(hide) rm -f $(TARGET_ABL)
108
109$(ABL_OUT):
110 mkdir -p $(ABL_OUT)
111
112# Top level target
113$(TARGET_ABL): abl_clean | $(ABL_OUT) $(INSTALLED_KEYSTOREIMAGE_TARGET)
Bhanuprakash Modem200d4b12018-11-22 16:29:39 +0530114 $(MAKEPATH)make -C bootable/bootloader/edk2 \
Jeevan Shriramd29e4402017-11-06 14:04:11 -0800115 BOOTLOADER_OUT=../../../$(ABL_OUT) \
116 all \
Bhanuprakash Modem23720102018-09-27 21:55:40 +0530117 PREBUILT_HOST_TOOLS=$(PREBUILT_HOST_TOOLS) \
Bhanuprakash Modem78a89d72018-10-10 19:00:44 +0530118 PREBUILT_PYTHON_PATH=$(PREBUILT_PYTHON_PATH) \
Bhanuprakash Modema64c9642018-11-30 13:49:09 +0530119 MAKEPATH=$(MAKEPATH) \
Mukesh Ojha8dc65f52018-03-27 00:59:30 +0530120 $(BUILD_SYSTEM_ROOT_IMAGE) \
Jeevan Shriramd29e4402017-11-06 14:04:11 -0800121 $(VERIFIED_BOOT) \
122 $(VERIFIED_BOOT_2) \
Zhen Kongdd5c5e32017-07-05 13:44:45 -0700123 $(VERIFIED_BOOT_LE) \
Jeevan Shriramd29e4402017-11-06 14:04:11 -0800124 $(USER_BUILD_VARIANT) \
Mukesh Ojhad29676a2018-04-10 17:37:56 +0530125 $(DISABLE_PARALLEL_DOWNLOAD_FLASH) \
Jeevan Shriram0a3ba0b2019-01-02 23:21:12 -0800126 $(AB_RETRYCOUNT_DISABLE) \
Jeevan Shriramd29e4402017-11-06 14:04:11 -0800127 CLANG_BIN=$(CLANG_BIN) \
128 CLANG_PREFIX=$(CLANG35_PREFIX)\
lijuang65c51d52018-03-28 13:52:57 +0800129 ABL_USE_SDLLVM=$(ABL_USE_SDLLVM) \
Venkata Narendra Kumar Gutta688a1612018-04-18 17:12:50 -0700130 ABL_SAFESTACK=$(ABL_SAFESTACK) \
131 SAFESTACK_SUPPORTED_CLANG_VERSION=$(SAFESTACK_SUPPORTED_CLANG_VERSION) \
Jeevan Shriramd29e4402017-11-06 14:04:11 -0800132 CLANG_GCC_TOOLCHAIN=$(CLANG35_GCC_TOOLCHAIN)\
Jeevan Shriramd5d169f2018-04-20 16:09:10 -0700133 TARGET_ARCHITECTURE=$(TARGET_ARCHITECTURE) \
134 BOARD_BOOTLOADER_PRODUCT_NAME=$(BOARD_BOOTLOADER_PRODUCT_NAME)
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -0800135