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) |
Prathyush Katukojwala | eec0cc6 | 2017-08-23 12:00:14 -0700 | [diff] [blame] | 9 | export WRAPPER := $(BUILDDIR)/clang-wrapper.py |
Jeevan Shriram | 4d4d5e6 | 2017-06-08 16:43:07 -0700 | [diff] [blame] | 10 | |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 11 | export CLANG35_BIN := $(CLANG_BIN) |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 12 | export CLANG35_GCC_TOOLCHAIN := $(CLANG35_GCC_TOOLCHAIN) |
Jeevan Shriram | d5d169f | 2018-04-20 16:09:10 -0700 | [diff] [blame] | 13 | export $(BOARD_BOOTLOADER_PRODUCT_NAME) |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 14 | |
Jeevan Shriram | 4d4d5e6 | 2017-06-08 16:43:07 -0700 | [diff] [blame] | 15 | ifeq ($(TARGET_ARCHITECTURE),arm) |
| 16 | export ARCHITECTURE := ARM |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 17 | export CLANG35_ARM_PREFIX := $(CLANG_PREFIX) |
Jeevan Shriram | 4d4d5e6 | 2017-06-08 16:43:07 -0700 | [diff] [blame] | 18 | else |
| 19 | export ARCHITECTURE := AARCH64 |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 20 | export CLANG35_AARCH64_PREFIX := $(CLANG_PREFIX) |
Jeevan Shriram | 4d4d5e6 | 2017-06-08 16:43:07 -0700 | [diff] [blame] | 21 | endif |
| 22 | |
Jeevan Shriram | d29e440 | 2017-11-06 14:04:11 -0800 | [diff] [blame] | 23 | export BUILD_REPORT_DIR := $(BOOTLOADER_OUT)/build_report |
| 24 | ANDROID_PRODUCT_OUT := $(BOOTLOADER_OUT)/Build |
| 25 | |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 26 | WORKSPACE=$(BUILDDIR) |
| 27 | TARGET_TOOLS := CLANG35 |
| 28 | TARGET := DEBUG |
| 29 | BUILD_ROOT := $(ANDROID_PRODUCT_OUT)/$(TARGET)_$(TARGET_TOOLS) |
Channagoud Kadabi | 1ed4a15 | 2016-02-05 15:15:41 -0800 | [diff] [blame] | 30 | EDK_TOOLS := $(BUILDDIR)/BaseTools |
| 31 | EDK_TOOLS_BIN := $(EDK_TOOLS)/Source/C/bin |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 32 | ABL_FV_IMG := $(BUILD_ROOT)/FV/abl.fv |
| 33 | ABL_FV_ELF := $(BOOTLOADER_OUT)/../../abl.elf |
lijuang | 4d342f6 | 2016-09-13 15:51:26 +0800 | [diff] [blame] | 34 | SHELL:=/bin/bash |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 35 | |
Venkata Narendra Kumar Gutta | 688a161 | 2018-04-18 17:12:50 -0700 | [diff] [blame] | 36 | # This function is to check version compatibility, used to control features based on the compiler version. \ |
| 37 | Arguments should be return value, current version and supported version in order. \ |
| 38 | It sets return value to true if the current version is equal or greater than the supported version. |
| 39 | define check_version_compatibility |
| 40 | $(eval CURR_VERSION := $(shell $(2)/clang --version |& grep -i "clang version" |& sed 's/[^0-9.]//g')) |
| 41 | $(eval CURR_VERSION_MAJOR := $(shell echo $(CURR_VERSION) |& cut -d. -f1)) |
| 42 | $(eval CURR_VERSION_MINOR := $(shell echo $(CURR_VERSION) |& cut -d. -f2)) |
| 43 | $(eval SUPPORTED_VERSION := $(3)) |
| 44 | $(eval SUPPORTED_VERSION_MAJOR := $(shell echo $(SUPPORTED_VERSION) |& cut -d. -f1)) |
| 45 | $(eval SUPPORTED_VERSION_MINOR := $(shell echo $(SUPPORTED_VERSION) |& cut -d. -f2)) |
| 46 | |
| 47 | ifeq ($(shell expr $(CURR_VERSION_MAJOR) \> $(SUPPORTED_VERSION_MAJOR)), 1) |
| 48 | $(1) := true |
| 49 | endif |
| 50 | ifeq ($(shell expr $(CURR_VERSION_MAJOR) \= $(SUPPORTED_VERSION_MAJOR)), 1) |
| 51 | ifeq ($(shell expr $(CURR_VERSION_MINOR) \>= $(SUPPORTED_VERSION_MINOR)), 1) |
| 52 | $(1) := true |
| 53 | endif |
| 54 | endif |
| 55 | endef |
| 56 | |
Trilok Soni | c1a2d14 | 2017-04-26 17:32:05 -0700 | [diff] [blame] | 57 | # UEFI UBSAN Configuration |
| 58 | # ENABLE_UEFI_UBSAN := true |
| 59 | |
| 60 | ifeq "$(ENABLE_UEFI_UBSAN)" "true" |
| 61 | UBSAN_GCC_FLAG_UNDEFINED := -fsanitize=undefined |
| 62 | UBSAN_GCC_FLAG_ALIGNMENT := -fno-sanitize=alignment |
| 63 | else |
| 64 | UBSAN_GCC_FLAG_UNDEFINED := |
| 65 | UBSAN_GCC_FLAG_ALIGNMENT := |
| 66 | endif |
| 67 | |
Jeevan Shriram | 90c404b | 2018-03-29 15:11:44 -0700 | [diff] [blame] | 68 | ifeq ($(TARGET_ARCHITECTURE), arm) |
Jeevan Shriram | 3254117 | 2017-12-02 10:19:23 -0800 | [diff] [blame] | 69 | LOAD_ADDRESS := 0X8FB00000 |
lijuang | 31b93db | 2018-09-05 19:48:22 +0800 | [diff] [blame^] | 70 | TARGET_ARCH_ARM64 := 0 |
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 |
lijuang | 31b93db | 2018-09-05 19:48:22 +0800 | [diff] [blame^] | 73 | TARGET_ARCH_ARM64 := 1 |
Jeevan Shriram | 995c231 | 2017-10-10 14:25:00 -0700 | [diff] [blame] | 74 | endif |
| 75 | |
Jeevan Shriram | 90c404b | 2018-03-29 15:11:44 -0700 | [diff] [blame] | 76 | ifeq ($(ENABLE_LE_VARIANT), true) |
| 77 | ENABLE_LE_VARIANT := 1 |
| 78 | else |
| 79 | ENABLE_LE_VARIANT := 0 |
| 80 | endif |
| 81 | |
lijuang | 65c51d5 | 2018-03-28 13:52:57 +0800 | [diff] [blame] | 82 | ifeq "$(ABL_USE_SDLLVM)" "true" |
| 83 | SDLLVM_COMPILE_ANALYZE := --compile-and-analyze |
| 84 | SDLLVM_ANALYZE_REPORT := $(BUILD_REPORT_DIR) |
| 85 | else |
| 86 | SDLLVM_COMPILE_ANALYZE := |
| 87 | SDLLVM_ANALYZE_REPORT := |
| 88 | endif |
S A Muqthyar | b25e5b3 | 2018-04-26 16:02:41 +0530 | [diff] [blame] | 89 | |
| 90 | ifneq "$(INIT_BIN_LE)" "" |
| 91 | INIT_BIN := $(INIT_BIN_LE) |
| 92 | else |
| 93 | INIT_BIN := \"/init\" |
| 94 | endif |
| 95 | |
lijuang | 65c51d5 | 2018-03-28 13:52:57 +0800 | [diff] [blame] | 96 | export SDLLVM_COMPILE_ANALYZE := $(SDLLVM_COMPILE_ANALYZE) |
| 97 | export SDLLVM_ANALYZE_REPORT := $(SDLLVM_ANALYZE_REPORT) |
| 98 | |
Venkata Narendra Kumar Gutta | 688a161 | 2018-04-18 17:12:50 -0700 | [diff] [blame] | 99 | CLANG_SUPPORTS_SAFESTACK := false |
| 100 | $(eval $(call check_version_compatibility, CLANG_SUPPORTS_SAFESTACK, $(CLANG_BIN), $(SAFESTACK_SUPPORTED_CLANG_VERSION))) |
| 101 | |
| 102 | ifeq "$(ABL_SAFESTACK)" "true" |
| 103 | ifeq "$(CLANG_SUPPORTS_SAFESTACK)" "true" |
| 104 | LLVM_ENABLE_SAFESTACK := -fsanitize=safe-stack |
| 105 | LLVM_SAFESTACK_USE_PTR := -mllvm -safestack-use-pointer-address |
| 106 | LLVM_SAFESTACK_COLORING := -mllvm -safe-stack-coloring=true |
| 107 | endif |
| 108 | else |
| 109 | LLVM_ENABLE_SAFESTACK := |
| 110 | LLVM_SAFESTACK_USE_PTR := |
| 111 | LLVM_SAFESTACK_COLORING := |
| 112 | endif |
| 113 | export LLVM_ENABLE_SAFESTACK := $(LLVM_ENABLE_SAFESTACK) |
| 114 | export LLVM_SAFESTACK_USE_PTR := $(LLVM_SAFESTACK_USE_PTR) |
| 115 | export LLVM_SAFESTACK_COLORING := $(LLVM_SAFESTACK_COLORING) |
| 116 | |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 117 | .PHONY: all cleanall |
| 118 | |
| 119 | all: ABL_FV_ELF |
| 120 | |
| 121 | cleanall: |
| 122 | @. ./edksetup.sh BaseTools && \ |
Jeevan Shriram | 4d4d5e6 | 2017-06-08 16:43:07 -0700 | [diff] [blame] | 123 | 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] | 124 | rm -rf $(WORKSPACE)/QcomModulePkg/Bin64 |
| 125 | |
Channagoud Kadabi | 1ed4a15 | 2016-02-05 15:15:41 -0800 | [diff] [blame] | 126 | EDK_TOOLS_BIN: |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 127 | @. ./edksetup.sh BaseTools && \ |
Bhanuprakash Modem | 2372010 | 2018-09-27 21:55:40 +0530 | [diff] [blame] | 128 | $(MAKE) -C $(EDK_TOOLS) $(PREBUILT_HOST_TOOLS) -j1 |
Channagoud Kadabi | 1ed4a15 | 2016-02-05 15:15:41 -0800 | [diff] [blame] | 129 | |
| 130 | ABL_FV_IMG: EDK_TOOLS_BIN |
| 131 | @. ./edksetup.sh BaseTools && \ |
Jeevan Shriram | 995c231 | 2017-10-10 14:25:00 -0700 | [diff] [blame] | 132 | build -p $(WORKSPACE)/QcomModulePkg/QcomModulePkg.dsc \ |
| 133 | -a $(ARCHITECTURE) \ |
| 134 | -t $(TARGET_TOOLS) \ |
| 135 | -b $(TARGET) \ |
| 136 | -D ABL_OUT_DIR=$(ANDROID_PRODUCT_OUT) \ |
Mukesh Ojha | 8dc65f5 | 2018-03-27 00:59:30 +0530 | [diff] [blame] | 137 | -D BUILD_SYSTEM_ROOT_IMAGE=$(BUILD_SYSTEM_ROOT_IMAGE) \ |
Jeevan Shriram | 995c231 | 2017-10-10 14:25:00 -0700 | [diff] [blame] | 138 | -D VERIFIED_BOOT=$(VERIFIED_BOOT) \ |
| 139 | -D VERIFIED_BOOT_2=$(VERIFIED_BOOT_2) \ |
Zhen Kong | dd5c5e3 | 2017-07-05 13:44:45 -0700 | [diff] [blame] | 140 | -D VERIFIED_BOOT_LE=$(VERIFIED_BOOT_LE) \ |
vijay.rayabarapu | 18a6404 | 2018-08-08 02:23:27 +0530 | [diff] [blame] | 141 | -D VERITY_LE=$(VERITY_LE) \ |
lijuang | 31b93db | 2018-09-05 19:48:22 +0800 | [diff] [blame^] | 142 | -D TARGET_ARCH_ARM64=$(TARGET_ARCH_ARM64) \ |
Jeevan Shriram | 995c231 | 2017-10-10 14:25:00 -0700 | [diff] [blame] | 143 | -D USER_BUILD_VARIANT=$(USER_BUILD_VARIANT) \ |
Mukesh Ojha | d29676a | 2018-04-10 17:37:56 +0530 | [diff] [blame] | 144 | -D DISABLE_PARALLEL_DOWNLOAD_FLASH=$(DISABLE_PARALLEL_DOWNLOAD_FLASH) \ |
Jeevan Shriram | 995c231 | 2017-10-10 14:25:00 -0700 | [diff] [blame] | 145 | -D ENABLE_LE_VARIANT=$(ENABLE_LE_VARIANT) \ |
S A Muqthyar | b25e5b3 | 2018-04-26 16:02:41 +0530 | [diff] [blame] | 146 | -D INIT_BIN=$(INIT_BIN) \ |
Jeevan Shriram | 995c231 | 2017-10-10 14:25:00 -0700 | [diff] [blame] | 147 | -D UBSAN_UEFI_GCC_FLAG_UNDEFINED=$(UBSAN_GCC_FLAG_UNDEFINED) \ |
| 148 | -D UBSAN_UEFI_GCC_FLAG_ALIGNMENT=$(UBSAN_GCC_FLAG_ALIGNMENT) \ |
| 149 | -j build_modulepkg.log $* |
| 150 | |
Sridhar Parasuram | fedf9ac | 2015-11-03 16:20:50 -0800 | [diff] [blame] | 151 | cp $(BUILD_ROOT)/FV/FVMAIN_COMPACT.Fv $(ABL_FV_IMG) |
| 152 | |
| 153 | ABL_FV_ELF: ABL_FV_IMG |
Jeevan Shriram | 19a5381 | 2017-06-14 15:39:48 -0700 | [diff] [blame] | 154 | python $(WORKSPACE)/QcomModulePkg/Tools/image_header.py $(ABL_FV_IMG) $(ABL_FV_ELF) $(LOAD_ADDRESS) elf 32 |