-
Notifications
You must be signed in to change notification settings - Fork 6
/
AndroidBoot.mk
183 lines (158 loc) · 5.65 KB
/
AndroidBoot.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#Android makefile to build bootloader as a part of Android Build
ANDROID_TOP=$(shell pwd)
CLANG_BIN := $(ANDROID_TOP)/$(LLVM_PREBUILTS_PATH)/
ABL_USE_SDLLVM := false
ifneq ($(FORCE_SDCLANG_OFF),true)
ifneq ($(wildcard $(SDCLANG_PATH)),)
ifeq ($(shell echo $(SDCLANG_PATH) | head -c 1),/)
CLANG_BIN := $(SDCLANG_PATH)/
else
CLANG_BIN := $(ANDROID_TOP)/$(SDCLANG_PATH)/
endif
ABL_USE_SDLLVM := true
endif
endif
# LD & make are not available in prebuilts for older Android versions
ifeq (1,$(filter 1,$(shell echo "$$(( $(PLATFORM_SDK_VERSION) > 27 ))" )))
LDOPT="-fuse-ld=$(ANDROID_TOP)/$(SOONG_LLVM_PREBUILTS_PATH)/ld.lld"
MAKEPATH=$(ANDROID_TOP)/prebuilts/build-tools/linux-x86/bin/
ifeq (,$(wildcard $(MAKEPATH)make))
MAKEPATH :=
endif
endif
# Use host tools from prebuilts. Partner should determine the correct host tools to use
PREBUILT_HOST_TOOLS := CC=$(ANDROID_TOP)/$(CLANG)\ \
CXX=$(ANDROID_TOP)/$(CLANG_CXX)\ \
LDPATH=$(LDOPT)\ \
AR=$(ANDROID_TOP)/$(HOST_AR)
PREBUILT_PYTHON_PATH=$(ANDROID_TOP)/prebuilts/python/linux-x86/2.7.5/bin/python2
DISABLE_PARALLEL_DOWNLOAD_FLASH := DISABLE_PARALLEL_DOWNLOAD_FLASH=1
ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
VERIFIED_BOOT := VERIFIED_BOOT=1
else
VERIFIED_BOOT := VERIFIED_BOOT=0
endif
ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
BUILD_SYSTEM_ROOT_IMAGE := BUILD_SYSTEM_ROOT_IMAGE=1
else
BUILD_SYSTEM_ROOT_IMAGE := BUILD_SYSTEM_ROOT_IMAGE=0
endif
ifeq ($(BOARD_AVB_ENABLE),true)
VERIFIED_BOOT_2 := VERIFIED_BOOT_2=1
else
VERIFIED_BOOT_2 := VERIFIED_BOOT_2=0
endif
ifeq ($(BOARD_LEVB_ENABLE),true)
VERIFIED_BOOT_LE := VERIFIED_BOOT_LE=1
else
VERIFIED_BOOT_LE := VERIFIED_BOOT_LE=0
endif
ifeq ($(TARGET_AB_RETRYCOUNT_DISABLE),true)
AB_RETRYCOUNT_DISABLE := AB_RETRYCOUNT_DISABLE=1
else
AB_RETRYCOUNT_DISABLE := AB_RETRYCOUNT_DISABLE=0
endif
ifeq ($(TARGET_BUILD_VARIANT),user)
USER_BUILD_VARIANT := USER_BUILD_VARIANT=1
else
USER_BUILD_VARIANT := USER_BUILD_VARIANT=0
endif
ifneq ($(TARGET_BOOTLOADER_BOARD_NAME),)
BOARD_BOOTLOADER_PRODUCT_NAME := $(TARGET_BOOTLOADER_BOARD_NAME)
else
BOARD_BOOTLOADER_PRODUCT_NAME := QC_Reference_Phone
endif
ifneq ($(TARGET_BOOTLOADER_BOARD_MODEL),)
BOARD_BOOTLOADER_PRODUCT_MODEL := $(TARGET_BOOTLOADER_BOARD_MODEL)
else
BOARD_BOOTLOADER_PRODUCT_MODEL := unknown
endif
ifneq ($(TARGET_BOOTLOADER_VERSION),)
BOARD_BOOTLOADER_VERSION := $(TARGET_BOOTLOADER_VERSION)
else
BOARD_BOOTLOADER_VERSION := unknown
endif
ifneq ($(TARGET_BOARD_TYPE),auto)
TARGET_BOARD_TYPE_AUTO := TARGET_BOARD_TYPE_AUTO=0
else
TARGET_BOARD_TYPE_AUTO := TARGET_BOARD_TYPE_AUTO=1
endif
ifneq ($(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),)
USERDATAIMAGE_FILE_SYSTEM_TYPE := $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)
else
USERDATAIMAGE_FILE_SYSTEM_TYPE := ext4
endif
ifeq ($(BOARD_ABL_SAFESTACK_DISABLE),true)
ABL_SAFESTACK := false
else
ABL_SAFESTACK := true
endif
ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true)
DYNAMIC_PARTITION_SUPPORT := DYNAMIC_PARTITION_SUPPORT=1
else
DYNAMIC_PARTITION_SUPPORT := DYNAMIC_PARTITION_SUPPORT=0
endif
ifeq ($(PRODUCT_VIRTUAL_AB_OTA),true)
VIRTUAL_AB_OTA := VIRTUAL_AB_OTA=1
else
VIRTUAL_AB_OTA := VIRTUAL_AB_OTA=0
endif
ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
BUILD_USES_RECOVERY_AS_BOOT := BUILD_USES_RECOVERY_AS_BOOT=1
else
BUILD_USES_RECOVERY_AS_BOOT := BUILD_USES_RECOVERY_AS_BOOT=0
endif
SAFESTACK_SUPPORTED_CLANG_VERSION = 6.0
# For most platform, abl needed always be built
# in aarch64 arthitecture to run.
# Specify BOOTLOADER_ARCH if needed to built with
# other ARCHs.
ifeq ($(BOOTLOADER_ARCH),)
BOOTLOADER_ARCH := AARCH64
endif
TARGET_ARCHITECTURE := $(BOOTLOADER_ARCH)
ifeq ($(TARGET_ARCHITECTURE),arm)
CLANG35_PREFIX := $(ANDROID_TOP)/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-$(TARGET_GCC_VERSION)/bin/arm-linux-androideabi-
CLANG35_GCC_TOOLCHAIN := $(ANDROID_TOP)/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-$(TARGET_GCC_VERSION)
else
CLANG35_PREFIX := $(ANDROID_TOP)/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-$(TARGET_GCC_VERSION)/bin/aarch64-linux-android-
CLANG35_GCC_TOOLCHAIN := $(ANDROID_TOP)/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-$(TARGET_GCC_VERSION)
endif
# ABL ELF output
TARGET_ABL := $(PRODUCT_OUT)/abl.elf
TARGET_EMMC_BOOTLOADER := $(TARGET_ABL)
ABL_OUT := $(TARGET_OUT_INTERMEDIATES)/ABL_OBJ
$(ABL_OUT):
mkdir -p $(ABL_OUT)
# Top level target
LOCAL_ABL_PATH := bootable/bootloader/edk2
LOCAL_ABL_SRC_FILE := $(shell find $(LOCAL_ABL_PATH) -name "*" -type f | sed "s%\.\/%$(LOCAL_ABL_PATH)\/%g")
$(TARGET_ABL): $(LOCAL_ABL_SRC_FILE) | $(ABL_OUT) $(INSTALLED_KEYSTOREIMAGE_TARGET)
$(MAKEPATH)make -C bootable/bootloader/edk2 \
BOOTLOADER_OUT=../../../$(ABL_OUT) \
all \
PREBUILT_HOST_TOOLS=$(PREBUILT_HOST_TOOLS) \
PREBUILT_PYTHON_PATH=$(PREBUILT_PYTHON_PATH) \
MAKEPATH=$(MAKEPATH) \
$(BUILD_SYSTEM_ROOT_IMAGE) \
$(VERIFIED_BOOT) \
$(VERIFIED_BOOT_2) \
$(VERIFIED_BOOT_LE) \
$(USER_BUILD_VARIANT) \
$(DISABLE_PARALLEL_DOWNLOAD_FLASH) \
$(AB_RETRYCOUNT_DISABLE) \
$(DYNAMIC_PARTITION_SUPPORT) \
$(TARGET_BOARD_TYPE_AUTO) \
$(VIRTUAL_AB_OTA) \
$(BUILD_USES_RECOVERY_AS_BOOT) \
CLANG_BIN=$(CLANG_BIN) \
CLANG_PREFIX=$(CLANG35_PREFIX)\
ABL_USE_SDLLVM=$(ABL_USE_SDLLVM) \
ABL_SAFESTACK=$(ABL_SAFESTACK) \
SAFESTACK_SUPPORTED_CLANG_VERSION=$(SAFESTACK_SUPPORTED_CLANG_VERSION) \
CLANG_GCC_TOOLCHAIN=$(CLANG35_GCC_TOOLCHAIN)\
TARGET_ARCHITECTURE=$(TARGET_ARCHITECTURE) \
BOARD_BOOTLOADER_PRODUCT_NAME=$(BOARD_BOOTLOADER_PRODUCT_NAME) \
BOARD_BOOTLOADER_PRODUCT_MODEL=$(BOARD_BOOTLOADER_PRODUCT_MODEL) \
BOARD_BOOTLOADER_VERSION=$(BOARD_BOOTLOADER_VERSION) \
USERDATAIMAGE_FILE_SYSTEM_TYPE=$(USERDATAIMAGE_FILE_SYSTEM_TYPE)