blob: 580b3cc7b297bab8d909707a12131c96bacf2e4c [file] [log] [blame]
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -08001UEFI_TOP_DIR := .
2
3ifndef $(BOOTLOADER_OUT)
4 BOOTLOADER_OUT := .
5endif
6export $(BOOTLOADER_OUT)
7
8BUILDDIR=$(shell pwd)
Bhanuprakash Modem78a89d72018-10-10 19:00:44 +05309export WRAPPER := $(PREBUILT_PYTHON_PATH) $(BUILDDIR)/clang-wrapper.py
Bhanuprakash Modema64c9642018-11-30 13:49:09 +053010export MAKEPATH := $(MAKEPATH)
Jeevan Shriram4d4d5e62017-06-08 16:43:07 -070011
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -080012export CLANG35_BIN := $(CLANG_BIN)
Jeevan Shriramd29e4402017-11-06 14:04:11 -080013export CLANG35_GCC_TOOLCHAIN := $(CLANG35_GCC_TOOLCHAIN)
Jeevan Shriramd5d169f2018-04-20 16:09:10 -070014export $(BOARD_BOOTLOADER_PRODUCT_NAME)
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -080015
Jeevan Shriram4d4d5e62017-06-08 16:43:07 -070016ifeq ($(TARGET_ARCHITECTURE),arm)
17export ARCHITECTURE := ARM
Jeevan Shriramd29e4402017-11-06 14:04:11 -080018export CLANG35_ARM_PREFIX := $(CLANG_PREFIX)
Jeevan Shriram4d4d5e62017-06-08 16:43:07 -070019else
20export ARCHITECTURE := AARCH64
Jeevan Shriramd29e4402017-11-06 14:04:11 -080021export CLANG35_AARCH64_PREFIX := $(CLANG_PREFIX)
Jeevan Shriram4d4d5e62017-06-08 16:43:07 -070022endif
23
Jeevan Shriramd29e4402017-11-06 14:04:11 -080024export BUILD_REPORT_DIR := $(BOOTLOADER_OUT)/build_report
25ANDROID_PRODUCT_OUT := $(BOOTLOADER_OUT)/Build
26
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -080027WORKSPACE=$(BUILDDIR)
28TARGET_TOOLS := CLANG35
29TARGET := DEBUG
30BUILD_ROOT := $(ANDROID_PRODUCT_OUT)/$(TARGET)_$(TARGET_TOOLS)
Channagoud Kadabi1ed4a152016-02-05 15:15:41 -080031EDK_TOOLS := $(BUILDDIR)/BaseTools
32EDK_TOOLS_BIN := $(EDK_TOOLS)/Source/C/bin
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -080033ABL_FV_IMG := $(BUILD_ROOT)/FV/abl.fv
34ABL_FV_ELF := $(BOOTLOADER_OUT)/../../abl.elf
lijuang4d342f62016-09-13 15:51:26 +080035SHELL:=/bin/bash
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -080036
Venkata Narendra Kumar Gutta688a1612018-04-18 17:12:50 -070037# This function is to check version compatibility, used to control features based on the compiler version. \
38Arguments should be return value, current version and supported version in order. \
39It sets return value to true if the current version is equal or greater than the supported version.
40define check_version_compatibility
41 $(eval CURR_VERSION := $(shell $(2)/clang --version |& grep -i "clang version" |& sed 's/[^0-9.]//g'))
42 $(eval CURR_VERSION_MAJOR := $(shell echo $(CURR_VERSION) |& cut -d. -f1))
43 $(eval CURR_VERSION_MINOR := $(shell echo $(CURR_VERSION) |& cut -d. -f2))
44 $(eval SUPPORTED_VERSION := $(3))
45 $(eval SUPPORTED_VERSION_MAJOR := $(shell echo $(SUPPORTED_VERSION) |& cut -d. -f1))
46 $(eval SUPPORTED_VERSION_MINOR := $(shell echo $(SUPPORTED_VERSION) |& cut -d. -f2))
47
48 ifeq ($(shell expr $(CURR_VERSION_MAJOR) \> $(SUPPORTED_VERSION_MAJOR)), 1)
49 $(1) := true
50 endif
51 ifeq ($(shell expr $(CURR_VERSION_MAJOR) \= $(SUPPORTED_VERSION_MAJOR)), 1)
52 ifeq ($(shell expr $(CURR_VERSION_MINOR) \>= $(SUPPORTED_VERSION_MINOR)), 1)
53 $(1) := true
54 endif
55 endif
56endef
57
Trilok Sonic1a2d142017-04-26 17:32:05 -070058# UEFI UBSAN Configuration
59# ENABLE_UEFI_UBSAN := true
60
61ifeq "$(ENABLE_UEFI_UBSAN)" "true"
62 UBSAN_GCC_FLAG_UNDEFINED := -fsanitize=undefined
63 UBSAN_GCC_FLAG_ALIGNMENT := -fno-sanitize=alignment
64else
65 UBSAN_GCC_FLAG_UNDEFINED :=
66 UBSAN_GCC_FLAG_ALIGNMENT :=
67endif
68
Jeevan Shriram90c404b2018-03-29 15:11:44 -070069ifeq ($(TARGET_ARCHITECTURE), arm)
Jeevan Shriram32541172017-12-02 10:19:23 -080070 LOAD_ADDRESS := 0X8FB00000
Jeevan Shriram995c2312017-10-10 14:25:00 -070071else
Jeevan Shriram32541172017-12-02 10:19:23 -080072 LOAD_ADDRESS := 0X9FA00000
Jeevan Shriram995c2312017-10-10 14:25:00 -070073endif
74
Jeevan Shriram90c404b2018-03-29 15:11:44 -070075ifeq ($(ENABLE_LE_VARIANT), true)
76 ENABLE_LE_VARIANT := 1
77else
78 ENABLE_LE_VARIANT := 0
79endif
80
lijuang65c51d52018-03-28 13:52:57 +080081ifeq "$(ABL_USE_SDLLVM)" "true"
82 SDLLVM_COMPILE_ANALYZE := --compile-and-analyze
83 SDLLVM_ANALYZE_REPORT := $(BUILD_REPORT_DIR)
84else
85 SDLLVM_COMPILE_ANALYZE :=
86 SDLLVM_ANALYZE_REPORT :=
87endif
S A Muqthyarb25e5b32018-04-26 16:02:41 +053088
89ifneq "$(INIT_BIN_LE)" ""
90 INIT_BIN := $(INIT_BIN_LE)
91else
92 INIT_BIN := \"/init\"
93endif
94
Prateek Soodc86ef5d2020-01-30 00:18:13 +053095ifeq "$(USERDATAIMAGE_FILE_SYSTEM_TYPE)" ""
96 USERDATAIMAGE_FILE_SYSTEM_TYPE := ext4
97endif
98
lijuang65c51d52018-03-28 13:52:57 +080099export SDLLVM_COMPILE_ANALYZE := $(SDLLVM_COMPILE_ANALYZE)
100export SDLLVM_ANALYZE_REPORT := $(SDLLVM_ANALYZE_REPORT)
101
Venkata Narendra Kumar Gutta688a1612018-04-18 17:12:50 -0700102CLANG_SUPPORTS_SAFESTACK := false
103$(eval $(call check_version_compatibility, CLANG_SUPPORTS_SAFESTACK, $(CLANG_BIN), $(SAFESTACK_SUPPORTED_CLANG_VERSION)))
104
105ifeq "$(ABL_SAFESTACK)" "true"
106 ifeq "$(CLANG_SUPPORTS_SAFESTACK)" "true"
107 LLVM_ENABLE_SAFESTACK := -fsanitize=safe-stack
108 LLVM_SAFESTACK_USE_PTR := -mllvm -safestack-use-pointer-address
109 LLVM_SAFESTACK_COLORING := -mllvm -safe-stack-coloring=true
110 endif
111else
112 LLVM_ENABLE_SAFESTACK :=
113 LLVM_SAFESTACK_USE_PTR :=
114 LLVM_SAFESTACK_COLORING :=
115endif
116export LLVM_ENABLE_SAFESTACK := $(LLVM_ENABLE_SAFESTACK)
117export LLVM_SAFESTACK_USE_PTR := $(LLVM_SAFESTACK_USE_PTR)
118export LLVM_SAFESTACK_COLORING := $(LLVM_SAFESTACK_COLORING)
119
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -0800120.PHONY: all cleanall
121
122all: ABL_FV_ELF
123
124cleanall:
125 @. ./edksetup.sh BaseTools && \
Jeevan Shriram4d4d5e62017-06-08 16:43:07 -0700126 build -p $(WORKSPACE)/QcomModulePkg/QcomModulePkg.dsc -a $(ARCHITECTURE) -t $(TARGET_TOOLS) -b $(TARGET) -j build_modulepkg.log cleanall
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -0800127 rm -rf $(WORKSPACE)/QcomModulePkg/Bin64
128
Channagoud Kadabi1ed4a152016-02-05 15:15:41 -0800129EDK_TOOLS_BIN:
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -0800130 @. ./edksetup.sh BaseTools && \
Bhanuprakash Modem200d4b12018-11-22 16:29:39 +0530131 $(MAKEPATH)make -C $(EDK_TOOLS) $(PREBUILT_HOST_TOOLS) -j1
Channagoud Kadabi1ed4a152016-02-05 15:15:41 -0800132
133ABL_FV_IMG: EDK_TOOLS_BIN
134 @. ./edksetup.sh BaseTools && \
Jeevan Shriram995c2312017-10-10 14:25:00 -0700135 build -p $(WORKSPACE)/QcomModulePkg/QcomModulePkg.dsc \
136 -a $(ARCHITECTURE) \
137 -t $(TARGET_TOOLS) \
138 -b $(TARGET) \
139 -D ABL_OUT_DIR=$(ANDROID_PRODUCT_OUT) \
Mukesh Ojha8dc65f52018-03-27 00:59:30 +0530140 -D BUILD_SYSTEM_ROOT_IMAGE=$(BUILD_SYSTEM_ROOT_IMAGE) \
Jeevan Shriram995c2312017-10-10 14:25:00 -0700141 -D VERIFIED_BOOT=$(VERIFIED_BOOT) \
142 -D VERIFIED_BOOT_2=$(VERIFIED_BOOT_2) \
Zhen Kongdd5c5e32017-07-05 13:44:45 -0700143 -D VERIFIED_BOOT_LE=$(VERIFIED_BOOT_LE) \
Jeevan Shriram0a3ba0b2019-01-02 23:21:12 -0800144 -D AB_RETRYCOUNT_DISABLE=$(AB_RETRYCOUNT_DISABLE) \
Anuj Gargae409552020-06-03 19:21:55 +0530145 -D TARGET_BOARD_TYPE_AUTO=$(TARGET_BOARD_TYPE_AUTO) \
vijay.rayabarapu18a64042018-08-08 02:23:27 +0530146 -D VERITY_LE=$(VERITY_LE) \
Jeevan Shriram995c2312017-10-10 14:25:00 -0700147 -D USER_BUILD_VARIANT=$(USER_BUILD_VARIANT) \
Mukesh Ojhad29676a2018-04-10 17:37:56 +0530148 -D DISABLE_PARALLEL_DOWNLOAD_FLASH=$(DISABLE_PARALLEL_DOWNLOAD_FLASH) \
Jeevan Shriram995c2312017-10-10 14:25:00 -0700149 -D ENABLE_LE_VARIANT=$(ENABLE_LE_VARIANT) \
Saranya Chidura30eb6292019-02-20 15:27:37 +0530150 -D DYNAMIC_PARTITION_SUPPORT=$(DYNAMIC_PARTITION_SUPPORT) \
Jeevan Shriram91492b42020-01-20 17:34:53 -0800151 -D VIRTUAL_AB_OTA=$(VIRTUAL_AB_OTA) \
Raghavendra Rao Ananta508792f2019-12-09 14:11:21 -0800152 -D BUILD_USES_RECOVERY_AS_BOOT=$(BUILD_USES_RECOVERY_AS_BOOT) \
S A Muqthyarb25e5b32018-04-26 16:02:41 +0530153 -D INIT_BIN=$(INIT_BIN) \
Jeevan Shriram995c2312017-10-10 14:25:00 -0700154 -D UBSAN_UEFI_GCC_FLAG_UNDEFINED=$(UBSAN_GCC_FLAG_UNDEFINED) \
155 -D UBSAN_UEFI_GCC_FLAG_ALIGNMENT=$(UBSAN_GCC_FLAG_ALIGNMENT) \
Sourabh Banerjee54a5bd72019-03-15 15:16:24 +0530156 -D NAND_SQUASHFS_SUPPORT=$(NAND_SQUASHFS_SUPPORT) \
Nagireddy Annemab587982020-01-30 16:02:15 +0530157 -D ENABLE_SYSTEMD_BOOTSLOT=$(ENABLE_SYSTEMD_BOOTSLOT) \
Prateek Soodc86ef5d2020-01-30 00:18:13 +0530158 -D RW_ROOTFS=$(RW_ROOTFS) \
159 -D USERDATAIMAGE_FILE_SYSTEM_TYPE=$(USERDATAIMAGE_FILE_SYSTEM_TYPE) \
Jeevan Shriram995c2312017-10-10 14:25:00 -0700160 -j build_modulepkg.log $*
161
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -0800162 cp $(BUILD_ROOT)/FV/FVMAIN_COMPACT.Fv $(ABL_FV_IMG)
163
lijuangcd8329b2019-10-29 17:08:53 +0800164BASETOOLS_CLEAN: ABL_FV_IMG
165 @$(MAKEPATH)make -C $(BUILDDIR)/BaseTools/Source/C clean > /dev/null
166
167ABL_FV_ELF: BASETOOLS_CLEAN
Jeevan Shriram19a53812017-06-14 15:39:48 -0700168 python $(WORKSPACE)/QcomModulePkg/Tools/image_header.py $(ABL_FV_IMG) $(ABL_FV_ELF) $(LOAD_ADDRESS) elf 32