Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 1 | UEFI_TOP_DIR := . |
| 2 | |
| 3 | ifndef $(BOOTLOADER_OUT) |
| 4 | BOOTLOADER_OUT := . |
| 5 | endif |
| 6 | export $(BOOTLOADER_OUT) |
| 7 | |
| 8 | BUILDDIR=$(shell pwd) |
Bhanuprakash Modem | 78a89d7 | 2018-10-10 19:00:44 +0530 | [diff] [blame] | 9 | export WRAPPER := $(PREBUILT_PYTHON_PATH) $(BUILDDIR)/clang-wrapper.py |
Bhanuprakash Modem | a64c964 | 2018-11-30 13:49:09 +0530 | [diff] [blame] | 10 | export MAKEPATH := $(MAKEPATH) |
Jeevan Shriram | 4d4d5e6 | 2017-06-08 16:43:07 -0700 | [diff] [blame] | 11 | |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 12 | export CLANG35_BIN := $(CLANG_BIN) |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 13 | export CLANG35_GCC_TOOLCHAIN := $(CLANG35_GCC_TOOLCHAIN) |
Jeevan Shriram | d5d169f | 2018-04-20 16:09:10 -0700 | [diff] [blame] | 14 | export $(BOARD_BOOTLOADER_PRODUCT_NAME) |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 15 | |
Jeevan Shriram | 4d4d5e6 | 2017-06-08 16:43:07 -0700 | [diff] [blame] | 16 | ifeq ($(TARGET_ARCHITECTURE),arm) |
| 17 | export ARCHITECTURE := ARM |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 18 | export CLANG35_ARM_PREFIX := $(CLANG_PREFIX) |
Jeevan Shriram | 4d4d5e6 | 2017-06-08 16:43:07 -0700 | [diff] [blame] | 19 | else |
| 20 | export ARCHITECTURE := AARCH64 |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 21 | export CLANG35_AARCH64_PREFIX := $(CLANG_PREFIX) |
Jeevan Shriram | 4d4d5e6 | 2017-06-08 16:43:07 -0700 | [diff] [blame] | 22 | endif |
| 23 | |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 24 | export BUILD_REPORT_DIR := $(BOOTLOADER_OUT)/build_report |
| 25 | ANDROID_PRODUCT_OUT := $(BOOTLOADER_OUT)/Build |
| 26 | |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 27 | WORKSPACE=$(BUILDDIR) |
| 28 | TARGET_TOOLS := CLANG35 |
| 29 | TARGET := DEBUG |
| 30 | BUILD_ROOT := $(ANDROID_PRODUCT_OUT)/$(TARGET)_$(TARGET_TOOLS) |
Channagoud Kadabi | 1ed4a15 | 2016-02-05 15:15:41 -0800 | [diff] [blame] | 31 | EDK_TOOLS := $(BUILDDIR)/BaseTools |
| 32 | EDK_TOOLS_BIN := $(EDK_TOOLS)/Source/C/bin |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 33 | ABL_FV_IMG := $(BUILD_ROOT)/FV/abl.fv |
| 34 | ABL_FV_ELF := $(BOOTLOADER_OUT)/../../abl.elf |
lijuang | 4d342f6 | 2016-09-13 15:51:26 +0800 | [diff] [blame] | 35 | SHELL:=/bin/bash |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 36 | |
Venkata Narendra Kumar Gutta | 688a161 | 2018-04-18 17:12:50 -0700 | [diff] [blame] | 37 | # This function is to check version compatibility, used to control features based on the compiler version. \ |
| 38 | Arguments should be return value, current version and supported version in order. \ |
| 39 | It sets return value to true if the current version is equal or greater than the supported version. |
| 40 | define 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 |
| 56 | endef |
| 57 | |
Trilok Soni | c1a2d14 | 2017-04-26 17:32:05 -0700 | [diff] [blame] | 58 | # UEFI UBSAN Configuration |
| 59 | # ENABLE_UEFI_UBSAN := true |
| 60 | |
| 61 | ifeq "$(ENABLE_UEFI_UBSAN)" "true" |
| 62 | UBSAN_GCC_FLAG_UNDEFINED := -fsanitize=undefined |
| 63 | UBSAN_GCC_FLAG_ALIGNMENT := -fno-sanitize=alignment |
| 64 | else |
| 65 | UBSAN_GCC_FLAG_UNDEFINED := |
| 66 | UBSAN_GCC_FLAG_ALIGNMENT := |
| 67 | endif |
| 68 | |
Jeevan Shriram | 90c404b | 2018-03-29 15:11:44 -0700 | [diff] [blame] | 69 | ifeq ($(TARGET_ARCHITECTURE), arm) |
Jeevan Shriram | 3254117 | 2017-12-02 10:19:23 -0800 | [diff] [blame] | 70 | LOAD_ADDRESS := 0X8FB00000 |
Jeevan Shriram | 995c231 | 2017-10-10 14:25:00 -0700 | [diff] [blame] | 71 | else |
Jeevan Shriram | 3254117 | 2017-12-02 10:19:23 -0800 | [diff] [blame] | 72 | LOAD_ADDRESS := 0X9FA00000 |
Jeevan Shriram | 995c231 | 2017-10-10 14:25:00 -0700 | [diff] [blame] | 73 | endif |
| 74 | |
Jeevan Shriram | 90c404b | 2018-03-29 15:11:44 -0700 | [diff] [blame] | 75 | ifeq ($(ENABLE_LE_VARIANT), true) |
| 76 | ENABLE_LE_VARIANT := 1 |
| 77 | else |
| 78 | ENABLE_LE_VARIANT := 0 |
| 79 | endif |
| 80 | |
lijuang | 65c51d5 | 2018-03-28 13:52:57 +0800 | [diff] [blame] | 81 | ifeq "$(ABL_USE_SDLLVM)" "true" |
| 82 | SDLLVM_COMPILE_ANALYZE := --compile-and-analyze |
| 83 | SDLLVM_ANALYZE_REPORT := $(BUILD_REPORT_DIR) |
| 84 | else |
| 85 | SDLLVM_COMPILE_ANALYZE := |
| 86 | SDLLVM_ANALYZE_REPORT := |
| 87 | endif |
S A Muqthyar | b25e5b3 | 2018-04-26 16:02:41 +0530 | [diff] [blame] | 88 | |
| 89 | ifneq "$(INIT_BIN_LE)" "" |
| 90 | INIT_BIN := $(INIT_BIN_LE) |
| 91 | else |
| 92 | INIT_BIN := \"/init\" |
| 93 | endif |
| 94 | |
Prateek Sood | c86ef5d | 2020-01-30 00:18:13 +0530 | [diff] [blame] | 95 | ifeq "$(USERDATAIMAGE_FILE_SYSTEM_TYPE)" "" |
| 96 | USERDATAIMAGE_FILE_SYSTEM_TYPE := ext4 |
| 97 | endif |
| 98 | |
lijuang | 65c51d5 | 2018-03-28 13:52:57 +0800 | [diff] [blame] | 99 | export SDLLVM_COMPILE_ANALYZE := $(SDLLVM_COMPILE_ANALYZE) |
| 100 | export SDLLVM_ANALYZE_REPORT := $(SDLLVM_ANALYZE_REPORT) |
| 101 | |
Venkata Narendra Kumar Gutta | 688a161 | 2018-04-18 17:12:50 -0700 | [diff] [blame] | 102 | CLANG_SUPPORTS_SAFESTACK := false |
| 103 | $(eval $(call check_version_compatibility, CLANG_SUPPORTS_SAFESTACK, $(CLANG_BIN), $(SAFESTACK_SUPPORTED_CLANG_VERSION))) |
| 104 | |
| 105 | ifeq "$(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 |
| 111 | else |
| 112 | LLVM_ENABLE_SAFESTACK := |
| 113 | LLVM_SAFESTACK_USE_PTR := |
| 114 | LLVM_SAFESTACK_COLORING := |
| 115 | endif |
| 116 | export LLVM_ENABLE_SAFESTACK := $(LLVM_ENABLE_SAFESTACK) |
| 117 | export LLVM_SAFESTACK_USE_PTR := $(LLVM_SAFESTACK_USE_PTR) |
| 118 | export LLVM_SAFESTACK_COLORING := $(LLVM_SAFESTACK_COLORING) |
| 119 | |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 120 | .PHONY: all cleanall |
| 121 | |
| 122 | all: ABL_FV_ELF |
| 123 | |
| 124 | cleanall: |
| 125 | @. ./edksetup.sh BaseTools && \ |
Jeevan Shriram | 4d4d5e6 | 2017-06-08 16:43:07 -0700 | [diff] [blame] | 126 | build -p $(WORKSPACE)/QcomModulePkg/QcomModulePkg.dsc -a $(ARCHITECTURE) -t $(TARGET_TOOLS) -b $(TARGET) -j build_modulepkg.log cleanall |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 127 | rm -rf $(WORKSPACE)/QcomModulePkg/Bin64 |
| 128 | |
Channagoud Kadabi | 1ed4a15 | 2016-02-05 15:15:41 -0800 | [diff] [blame] | 129 | EDK_TOOLS_BIN: |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 130 | @. ./edksetup.sh BaseTools && \ |
Bhanuprakash Modem | 200d4b1 | 2018-11-22 16:29:39 +0530 | [diff] [blame] | 131 | $(MAKEPATH)make -C $(EDK_TOOLS) $(PREBUILT_HOST_TOOLS) -j1 |
Channagoud Kadabi | 1ed4a15 | 2016-02-05 15:15:41 -0800 | [diff] [blame] | 132 | |
| 133 | ABL_FV_IMG: EDK_TOOLS_BIN |
| 134 | @. ./edksetup.sh BaseTools && \ |
Jeevan Shriram | 995c231 | 2017-10-10 14:25:00 -0700 | [diff] [blame] | 135 | 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 Ojha | 8dc65f5 | 2018-03-27 00:59:30 +0530 | [diff] [blame] | 140 | -D BUILD_SYSTEM_ROOT_IMAGE=$(BUILD_SYSTEM_ROOT_IMAGE) \ |
Jeevan Shriram | 995c231 | 2017-10-10 14:25:00 -0700 | [diff] [blame] | 141 | -D VERIFIED_BOOT=$(VERIFIED_BOOT) \ |
| 142 | -D VERIFIED_BOOT_2=$(VERIFIED_BOOT_2) \ |
Zhen Kong | dd5c5e3 | 2017-07-05 13:44:45 -0700 | [diff] [blame] | 143 | -D VERIFIED_BOOT_LE=$(VERIFIED_BOOT_LE) \ |
Jeevan Shriram | 0a3ba0b | 2019-01-02 23:21:12 -0800 | [diff] [blame] | 144 | -D AB_RETRYCOUNT_DISABLE=$(AB_RETRYCOUNT_DISABLE) \ |
Anuj Garg | ae40955 | 2020-06-03 19:21:55 +0530 | [diff] [blame] | 145 | -D TARGET_BOARD_TYPE_AUTO=$(TARGET_BOARD_TYPE_AUTO) \ |
vijay.rayabarapu | 18a6404 | 2018-08-08 02:23:27 +0530 | [diff] [blame] | 146 | -D VERITY_LE=$(VERITY_LE) \ |
Jeevan Shriram | 995c231 | 2017-10-10 14:25:00 -0700 | [diff] [blame] | 147 | -D USER_BUILD_VARIANT=$(USER_BUILD_VARIANT) \ |
Mukesh Ojha | d29676a | 2018-04-10 17:37:56 +0530 | [diff] [blame] | 148 | -D DISABLE_PARALLEL_DOWNLOAD_FLASH=$(DISABLE_PARALLEL_DOWNLOAD_FLASH) \ |
Jeevan Shriram | 995c231 | 2017-10-10 14:25:00 -0700 | [diff] [blame] | 149 | -D ENABLE_LE_VARIANT=$(ENABLE_LE_VARIANT) \ |
Saranya Chidura | 30eb629 | 2019-02-20 15:27:37 +0530 | [diff] [blame] | 150 | -D DYNAMIC_PARTITION_SUPPORT=$(DYNAMIC_PARTITION_SUPPORT) \ |
Jeevan Shriram | 91492b4 | 2020-01-20 17:34:53 -0800 | [diff] [blame] | 151 | -D VIRTUAL_AB_OTA=$(VIRTUAL_AB_OTA) \ |
Raghavendra Rao Ananta | 508792f | 2019-12-09 14:11:21 -0800 | [diff] [blame] | 152 | -D BUILD_USES_RECOVERY_AS_BOOT=$(BUILD_USES_RECOVERY_AS_BOOT) \ |
S A Muqthyar | b25e5b3 | 2018-04-26 16:02:41 +0530 | [diff] [blame] | 153 | -D INIT_BIN=$(INIT_BIN) \ |
Jeevan Shriram | 995c231 | 2017-10-10 14:25:00 -0700 | [diff] [blame] | 154 | -D UBSAN_UEFI_GCC_FLAG_UNDEFINED=$(UBSAN_GCC_FLAG_UNDEFINED) \ |
| 155 | -D UBSAN_UEFI_GCC_FLAG_ALIGNMENT=$(UBSAN_GCC_FLAG_ALIGNMENT) \ |
Sourabh Banerjee | 54a5bd7 | 2019-03-15 15:16:24 +0530 | [diff] [blame] | 156 | -D NAND_SQUASHFS_SUPPORT=$(NAND_SQUASHFS_SUPPORT) \ |
Nagireddy Annem | ab58798 | 2020-01-30 16:02:15 +0530 | [diff] [blame] | 157 | -D ENABLE_SYSTEMD_BOOTSLOT=$(ENABLE_SYSTEMD_BOOTSLOT) \ |
Prateek Sood | c86ef5d | 2020-01-30 00:18:13 +0530 | [diff] [blame] | 158 | -D RW_ROOTFS=$(RW_ROOTFS) \ |
| 159 | -D USERDATAIMAGE_FILE_SYSTEM_TYPE=$(USERDATAIMAGE_FILE_SYSTEM_TYPE) \ |
Jeevan Shriram | 995c231 | 2017-10-10 14:25:00 -0700 | [diff] [blame] | 160 | -j build_modulepkg.log $* |
| 161 | |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 162 | cp $(BUILD_ROOT)/FV/FVMAIN_COMPACT.Fv $(ABL_FV_IMG) |
| 163 | |
lijuang | cd8329b | 2019-10-29 17:08:53 +0800 | [diff] [blame] | 164 | BASETOOLS_CLEAN: ABL_FV_IMG |
| 165 | @$(MAKEPATH)make -C $(BUILDDIR)/BaseTools/Source/C clean > /dev/null |
| 166 | |
| 167 | ABL_FV_ELF: BASETOOLS_CLEAN |
Jeevan Shriram | 19a5381 | 2017-06-14 15:39:48 -0700 | [diff] [blame] | 168 | python $(WORKSPACE)/QcomModulePkg/Tools/image_header.py $(ABL_FV_IMG) $(ABL_FV_ELF) $(LOAD_ADDRESS) elf 32 |