blob: 74972e6a6843c6537f255b780bcf237a9a9c8751 [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)
Prathyush Katukojwalaeec0cc62017-08-23 12:00:14 -07009export WRAPPER := $(BUILDDIR)/clang-wrapper.py
Jeevan Shriram4d4d5e62017-06-08 16:43:07 -070010
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -080011export CLANG35_BIN := $(CLANG_BIN)
Jeevan Shriramd29e4402017-11-06 14:04:11 -080012export CLANG35_GCC_TOOLCHAIN := $(CLANG35_GCC_TOOLCHAIN)
Jeevan Shriramd5d169f2018-04-20 16:09:10 -070013export $(BOARD_BOOTLOADER_PRODUCT_NAME)
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -080014
Jeevan Shriram4d4d5e62017-06-08 16:43:07 -070015ifeq ($(TARGET_ARCHITECTURE),arm)
16export ARCHITECTURE := ARM
Jeevan Shriramd29e4402017-11-06 14:04:11 -080017export CLANG35_ARM_PREFIX := $(CLANG_PREFIX)
Jeevan Shriram4d4d5e62017-06-08 16:43:07 -070018else
19export ARCHITECTURE := AARCH64
Jeevan Shriramd29e4402017-11-06 14:04:11 -080020export CLANG35_AARCH64_PREFIX := $(CLANG_PREFIX)
Jeevan Shriram4d4d5e62017-06-08 16:43:07 -070021endif
22
Jeevan Shriramd29e4402017-11-06 14:04:11 -080023export BUILD_REPORT_DIR := $(BOOTLOADER_OUT)/build_report
24ANDROID_PRODUCT_OUT := $(BOOTLOADER_OUT)/Build
25
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -080026WORKSPACE=$(BUILDDIR)
27TARGET_TOOLS := CLANG35
28TARGET := DEBUG
29BUILD_ROOT := $(ANDROID_PRODUCT_OUT)/$(TARGET)_$(TARGET_TOOLS)
Channagoud Kadabi1ed4a152016-02-05 15:15:41 -080030EDK_TOOLS := $(BUILDDIR)/BaseTools
31EDK_TOOLS_BIN := $(EDK_TOOLS)/Source/C/bin
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -080032ABL_FV_IMG := $(BUILD_ROOT)/FV/abl.fv
33ABL_FV_ELF := $(BOOTLOADER_OUT)/../../abl.elf
lijuang4d342f62016-09-13 15:51:26 +080034SHELL:=/bin/bash
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -080035
Venkata Narendra Kumar Gutta688a1612018-04-18 17:12:50 -070036# This function is to check version compatibility, used to control features based on the compiler version. \
37Arguments should be return value, current version and supported version in order. \
38It sets return value to true if the current version is equal or greater than the supported version.
39define 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
55endef
56
Trilok Sonic1a2d142017-04-26 17:32:05 -070057# UEFI UBSAN Configuration
58# ENABLE_UEFI_UBSAN := true
59
60ifeq "$(ENABLE_UEFI_UBSAN)" "true"
61 UBSAN_GCC_FLAG_UNDEFINED := -fsanitize=undefined
62 UBSAN_GCC_FLAG_ALIGNMENT := -fno-sanitize=alignment
63else
64 UBSAN_GCC_FLAG_UNDEFINED :=
65 UBSAN_GCC_FLAG_ALIGNMENT :=
66endif
67
Jeevan Shriram90c404b2018-03-29 15:11:44 -070068ifeq ($(TARGET_ARCHITECTURE), arm)
Jeevan Shriram32541172017-12-02 10:19:23 -080069 LOAD_ADDRESS := 0X8FB00000
Jeevan Shriram995c2312017-10-10 14:25:00 -070070else
Jeevan Shriram32541172017-12-02 10:19:23 -080071 LOAD_ADDRESS := 0X9FA00000
Jeevan Shriram995c2312017-10-10 14:25:00 -070072endif
73
Jeevan Shriram90c404b2018-03-29 15:11:44 -070074ifeq ($(ENABLE_LE_VARIANT), true)
75 ENABLE_LE_VARIANT := 1
76else
77 ENABLE_LE_VARIANT := 0
78endif
79
lijuang65c51d52018-03-28 13:52:57 +080080ifeq "$(ABL_USE_SDLLVM)" "true"
81 SDLLVM_COMPILE_ANALYZE := --compile-and-analyze
82 SDLLVM_ANALYZE_REPORT := $(BUILD_REPORT_DIR)
83else
84 SDLLVM_COMPILE_ANALYZE :=
85 SDLLVM_ANALYZE_REPORT :=
86endif
S A Muqthyarb25e5b32018-04-26 16:02:41 +053087
88ifneq "$(INIT_BIN_LE)" ""
89 INIT_BIN := $(INIT_BIN_LE)
90else
91 INIT_BIN := \"/init\"
92endif
93
lijuang65c51d52018-03-28 13:52:57 +080094export SDLLVM_COMPILE_ANALYZE := $(SDLLVM_COMPILE_ANALYZE)
95export SDLLVM_ANALYZE_REPORT := $(SDLLVM_ANALYZE_REPORT)
96
Venkata Narendra Kumar Gutta688a1612018-04-18 17:12:50 -070097CLANG_SUPPORTS_SAFESTACK := false
98$(eval $(call check_version_compatibility, CLANG_SUPPORTS_SAFESTACK, $(CLANG_BIN), $(SAFESTACK_SUPPORTED_CLANG_VERSION)))
99
100ifeq "$(ABL_SAFESTACK)" "true"
101 ifeq "$(CLANG_SUPPORTS_SAFESTACK)" "true"
102 LLVM_ENABLE_SAFESTACK := -fsanitize=safe-stack
103 LLVM_SAFESTACK_USE_PTR := -mllvm -safestack-use-pointer-address
104 LLVM_SAFESTACK_COLORING := -mllvm -safe-stack-coloring=true
105 endif
106else
107 LLVM_ENABLE_SAFESTACK :=
108 LLVM_SAFESTACK_USE_PTR :=
109 LLVM_SAFESTACK_COLORING :=
110endif
111export LLVM_ENABLE_SAFESTACK := $(LLVM_ENABLE_SAFESTACK)
112export LLVM_SAFESTACK_USE_PTR := $(LLVM_SAFESTACK_USE_PTR)
113export LLVM_SAFESTACK_COLORING := $(LLVM_SAFESTACK_COLORING)
114
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -0800115.PHONY: all cleanall
116
117all: ABL_FV_ELF
118
119cleanall:
120 @. ./edksetup.sh BaseTools && \
Jeevan Shriram4d4d5e62017-06-08 16:43:07 -0700121 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 -0800122 rm -rf $(WORKSPACE)/QcomModulePkg/Bin64
123
Channagoud Kadabi1ed4a152016-02-05 15:15:41 -0800124EDK_TOOLS_BIN:
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -0800125 @. ./edksetup.sh BaseTools && \
Channagoud Kadabi1ed4a152016-02-05 15:15:41 -0800126 $(MAKE) -C $(EDK_TOOLS) -j1
127
128ABL_FV_IMG: EDK_TOOLS_BIN
129 @. ./edksetup.sh BaseTools && \
Jeevan Shriram995c2312017-10-10 14:25:00 -0700130 build -p $(WORKSPACE)/QcomModulePkg/QcomModulePkg.dsc \
131 -a $(ARCHITECTURE) \
132 -t $(TARGET_TOOLS) \
133 -b $(TARGET) \
134 -D ABL_OUT_DIR=$(ANDROID_PRODUCT_OUT) \
Mukesh Ojha8dc65f52018-03-27 00:59:30 +0530135 -D BUILD_SYSTEM_ROOT_IMAGE=$(BUILD_SYSTEM_ROOT_IMAGE) \
Jeevan Shriram995c2312017-10-10 14:25:00 -0700136 -D VERIFIED_BOOT=$(VERIFIED_BOOT) \
137 -D VERIFIED_BOOT_2=$(VERIFIED_BOOT_2) \
Zhen Kongdd5c5e32017-07-05 13:44:45 -0700138 -D VERIFIED_BOOT_LE=$(VERIFIED_BOOT_LE) \
vijay.rayabarapu18a64042018-08-08 02:23:27 +0530139 -D VERITY_LE=$(VERITY_LE) \
Jeevan Shriram995c2312017-10-10 14:25:00 -0700140 -D USER_BUILD_VARIANT=$(USER_BUILD_VARIANT) \
Mukesh Ojhad29676a2018-04-10 17:37:56 +0530141 -D DISABLE_PARALLEL_DOWNLOAD_FLASH=$(DISABLE_PARALLEL_DOWNLOAD_FLASH) \
Jeevan Shriram995c2312017-10-10 14:25:00 -0700142 -D ENABLE_LE_VARIANT=$(ENABLE_LE_VARIANT) \
S A Muqthyarb25e5b32018-04-26 16:02:41 +0530143 -D INIT_BIN=$(INIT_BIN) \
Jeevan Shriram995c2312017-10-10 14:25:00 -0700144 -D UBSAN_UEFI_GCC_FLAG_UNDEFINED=$(UBSAN_GCC_FLAG_UNDEFINED) \
145 -D UBSAN_UEFI_GCC_FLAG_ALIGNMENT=$(UBSAN_GCC_FLAG_ALIGNMENT) \
146 -j build_modulepkg.log $*
147
Sridhar Parasuramfedf9ac2015-11-03 16:20:50 -0800148 cp $(BUILD_ROOT)/FV/FVMAIN_COMPACT.Fv $(ABL_FV_IMG)
149
150ABL_FV_ELF: ABL_FV_IMG
Jeevan Shriram19a53812017-06-14 15:39:48 -0700151 python $(WORKSPACE)/QcomModulePkg/Tools/image_header.py $(ABL_FV_IMG) $(ABL_FV_ELF) $(LOAD_ADDRESS) elf 32