-
Notifications
You must be signed in to change notification settings - Fork 6
/
makefile
168 lines (142 loc) · 5.47 KB
/
makefile
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
UEFI_TOP_DIR := .
ifndef $(BOOTLOADER_OUT)
BOOTLOADER_OUT := .
endif
export $(BOOTLOADER_OUT)
BUILDDIR=$(shell pwd)
export WRAPPER := $(PREBUILT_PYTHON_PATH) $(BUILDDIR)/clang-wrapper.py
export MAKEPATH := $(MAKEPATH)
export CLANG35_BIN := $(CLANG_BIN)
export CLANG35_GCC_TOOLCHAIN := $(CLANG35_GCC_TOOLCHAIN)
export $(BOARD_BOOTLOADER_PRODUCT_NAME)
ifeq ($(TARGET_ARCHITECTURE),arm)
export ARCHITECTURE := ARM
export CLANG35_ARM_PREFIX := $(CLANG_PREFIX)
else
export ARCHITECTURE := AARCH64
export CLANG35_AARCH64_PREFIX := $(CLANG_PREFIX)
endif
export BUILD_REPORT_DIR := $(BOOTLOADER_OUT)/build_report
ANDROID_PRODUCT_OUT := $(BOOTLOADER_OUT)/Build
WORKSPACE=$(BUILDDIR)
TARGET_TOOLS := CLANG35
TARGET := DEBUG
BUILD_ROOT := $(ANDROID_PRODUCT_OUT)/$(TARGET)_$(TARGET_TOOLS)
EDK_TOOLS := $(BUILDDIR)/BaseTools
EDK_TOOLS_BIN := $(EDK_TOOLS)/Source/C/bin
ABL_FV_IMG := $(BUILD_ROOT)/FV/abl.fv
ABL_FV_ELF := $(BOOTLOADER_OUT)/../../abl.elf
SHELL:=/bin/bash
# This function is to check version compatibility, used to control features based on the compiler version. \
Arguments should be return value, current version and supported version in order. \
It sets return value to true if the current version is equal or greater than the supported version.
define check_version_compatibility
$(eval CURR_VERSION := $(shell $(2)/clang --version |& grep -i "clang version" |& sed 's/[^0-9.]//g'))
$(eval CURR_VERSION_MAJOR := $(shell echo $(CURR_VERSION) |& cut -d. -f1))
$(eval CURR_VERSION_MINOR := $(shell echo $(CURR_VERSION) |& cut -d. -f2))
$(eval SUPPORTED_VERSION := $(3))
$(eval SUPPORTED_VERSION_MAJOR := $(shell echo $(SUPPORTED_VERSION) |& cut -d. -f1))
$(eval SUPPORTED_VERSION_MINOR := $(shell echo $(SUPPORTED_VERSION) |& cut -d. -f2))
ifeq ($(shell expr $(CURR_VERSION_MAJOR) \> $(SUPPORTED_VERSION_MAJOR)), 1)
$(1) := true
endif
ifeq ($(shell expr $(CURR_VERSION_MAJOR) \= $(SUPPORTED_VERSION_MAJOR)), 1)
ifeq ($(shell expr $(CURR_VERSION_MINOR) \>= $(SUPPORTED_VERSION_MINOR)), 1)
$(1) := true
endif
endif
endef
# UEFI UBSAN Configuration
# ENABLE_UEFI_UBSAN := true
ifeq "$(ENABLE_UEFI_UBSAN)" "true"
UBSAN_GCC_FLAG_UNDEFINED := -fsanitize=undefined
UBSAN_GCC_FLAG_ALIGNMENT := -fno-sanitize=alignment
else
UBSAN_GCC_FLAG_UNDEFINED :=
UBSAN_GCC_FLAG_ALIGNMENT :=
endif
ifeq ($(TARGET_ARCHITECTURE), arm)
LOAD_ADDRESS := 0X8FB00000
else
LOAD_ADDRESS := 0X9FA00000
endif
ifeq ($(ENABLE_LE_VARIANT), true)
ENABLE_LE_VARIANT := 1
else
ENABLE_LE_VARIANT := 0
endif
ifeq "$(ABL_USE_SDLLVM)" "true"
SDLLVM_COMPILE_ANALYZE := --compile-and-analyze
SDLLVM_ANALYZE_REPORT := $(BUILD_REPORT_DIR)
else
SDLLVM_COMPILE_ANALYZE :=
SDLLVM_ANALYZE_REPORT :=
endif
ifneq "$(INIT_BIN_LE)" ""
INIT_BIN := $(INIT_BIN_LE)
else
INIT_BIN := \"/init\"
endif
ifeq "$(USERDATAIMAGE_FILE_SYSTEM_TYPE)" ""
USERDATAIMAGE_FILE_SYSTEM_TYPE := ext4
endif
export SDLLVM_COMPILE_ANALYZE := $(SDLLVM_COMPILE_ANALYZE)
export SDLLVM_ANALYZE_REPORT := $(SDLLVM_ANALYZE_REPORT)
CLANG_SUPPORTS_SAFESTACK := false
$(eval $(call check_version_compatibility, CLANG_SUPPORTS_SAFESTACK, $(CLANG_BIN), $(SAFESTACK_SUPPORTED_CLANG_VERSION)))
ifeq "$(ABL_SAFESTACK)" "true"
ifeq "$(CLANG_SUPPORTS_SAFESTACK)" "true"
LLVM_ENABLE_SAFESTACK := -fsanitize=safe-stack
LLVM_SAFESTACK_USE_PTR := -mllvm -safestack-use-pointer-address
LLVM_SAFESTACK_COLORING := -mllvm -safe-stack-coloring=true
endif
else
LLVM_ENABLE_SAFESTACK :=
LLVM_SAFESTACK_USE_PTR :=
LLVM_SAFESTACK_COLORING :=
endif
export LLVM_ENABLE_SAFESTACK := $(LLVM_ENABLE_SAFESTACK)
export LLVM_SAFESTACK_USE_PTR := $(LLVM_SAFESTACK_USE_PTR)
export LLVM_SAFESTACK_COLORING := $(LLVM_SAFESTACK_COLORING)
.PHONY: all cleanall
all: ABL_FV_ELF
cleanall:
@. ./edksetup.sh BaseTools && \
build -p $(WORKSPACE)/QcomModulePkg/QcomModulePkg.dsc -a $(ARCHITECTURE) -t $(TARGET_TOOLS) -b $(TARGET) -j build_modulepkg.log cleanall
rm -rf $(WORKSPACE)/QcomModulePkg/Bin64
EDK_TOOLS_BIN:
@. ./edksetup.sh BaseTools && \
$(MAKEPATH)make -C $(EDK_TOOLS) $(PREBUILT_HOST_TOOLS) -j1
ABL_FV_IMG: EDK_TOOLS_BIN
@. ./edksetup.sh BaseTools && \
build -p $(WORKSPACE)/QcomModulePkg/QcomModulePkg.dsc \
-a $(ARCHITECTURE) \
-t $(TARGET_TOOLS) \
-b $(TARGET) \
-D ABL_OUT_DIR=$(ANDROID_PRODUCT_OUT) \
-D BUILD_SYSTEM_ROOT_IMAGE=$(BUILD_SYSTEM_ROOT_IMAGE) \
-D VERIFIED_BOOT=$(VERIFIED_BOOT) \
-D VERIFIED_BOOT_2=$(VERIFIED_BOOT_2) \
-D VERIFIED_BOOT_LE=$(VERIFIED_BOOT_LE) \
-D AB_RETRYCOUNT_DISABLE=$(AB_RETRYCOUNT_DISABLE) \
-D TARGET_BOARD_TYPE_AUTO=$(TARGET_BOARD_TYPE_AUTO) \
-D VERITY_LE=$(VERITY_LE) \
-D USER_BUILD_VARIANT=$(USER_BUILD_VARIANT) \
-D DISABLE_PARALLEL_DOWNLOAD_FLASH=$(DISABLE_PARALLEL_DOWNLOAD_FLASH) \
-D ENABLE_LE_VARIANT=$(ENABLE_LE_VARIANT) \
-D DYNAMIC_PARTITION_SUPPORT=$(DYNAMIC_PARTITION_SUPPORT) \
-D VIRTUAL_AB_OTA=$(VIRTUAL_AB_OTA) \
-D BUILD_USES_RECOVERY_AS_BOOT=$(BUILD_USES_RECOVERY_AS_BOOT) \
-D INIT_BIN=$(INIT_BIN) \
-D UBSAN_UEFI_GCC_FLAG_UNDEFINED=$(UBSAN_GCC_FLAG_UNDEFINED) \
-D UBSAN_UEFI_GCC_FLAG_ALIGNMENT=$(UBSAN_GCC_FLAG_ALIGNMENT) \
-D NAND_SQUASHFS_SUPPORT=$(NAND_SQUASHFS_SUPPORT) \
-D ENABLE_SYSTEMD_BOOTSLOT=$(ENABLE_SYSTEMD_BOOTSLOT) \
-D RW_ROOTFS=$(RW_ROOTFS) \
-D USERDATAIMAGE_FILE_SYSTEM_TYPE=$(USERDATAIMAGE_FILE_SYSTEM_TYPE) \
-j build_modulepkg.log $*
cp $(BUILD_ROOT)/FV/FVMAIN_COMPACT.Fv $(ABL_FV_IMG)
BASETOOLS_CLEAN: ABL_FV_IMG
@$(MAKEPATH)make -C $(BUILDDIR)/BaseTools/Source/C clean > /dev/null
ABL_FV_ELF: BASETOOLS_CLEAN
python $(WORKSPACE)/QcomModulePkg/Tools/image_header.py $(ABL_FV_IMG) $(ABL_FV_ELF) $(LOAD_ADDRESS) elf 32