rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | LK_ENV_PATH := $(call my-dir) |
| 2 | LK_ROOT_DIR := $(PWD) |
| 3 | HOST_OS ?= $(shell uname | tr '[A-Z]' '[a-z]') |
| 4 | |
| 5 | # BL2 and BL33 LK common tool and directories setting |
| 6 | LK_DIR := $(LK_ENV_PATH) |
| 7 | DRAMK_DIR := $(LK_ENV_PATH)/../dramk_2712 |
| 8 | LK_EXT_DIR := $(LK_ENV_PATH)/../lk_ext_mod |
| 9 | LK_DTS_DIR := $(LK_ROOT_DIR)/device/mediatek/common/tools/bootloader/security/lk_dts |
| 10 | DUMMY_IMG_DIR := $(LK_ROOT_DIR)/device/mediatek/common/tools/bootloader/security/dummy_img |
| 11 | DEV_INFO_DIR := $(LK_ROOT_DIR)/device/mediatek/common/tools/bootloader/security/dev_info |
| 12 | UBOOT_MKIMG_TOOL := $(LK_ROOT_DIR)/prebuilts/u-boot/host/x86_64-linux/usr/bin/uboot-mkimage |
| 13 | BL2_BUILDROOT := $(LK_ROOT_DIR)/$(PRODUCT_OUT)/bl2_out |
| 14 | BL33_BUILDROOT := $(LK_ROOT_DIR)/$(PRODUCT_OUT)/bl33_out |
| 15 | LK_BLOB_INC := $(BL2_BUILDROOT) |
| 16 | BL33_BLOB_INC := $(BL33_BUILDROOT) |
| 17 | |
| 18 | #userdebug/eng setting DEBUG=1, user load setting it to 0 |
| 19 | ifeq ($(TARGET_BUILD_VARIANT), user) |
| 20 | DEBUG = 0 |
| 21 | else |
| 22 | DEBUG = 1 |
| 23 | endif |
| 24 | |
| 25 | COMMON_PROJ_OPTION = \ |
| 26 | SECURE_BOOT_ENABLE \ |
| 27 | AB_OTA_UPDATER |
| 28 | |
| 29 | BL2_PROJ_OPTION = \ |
| 30 | MTK_CLK32K_EXT_REMOVAL_SUPPORT |
| 31 | |
| 32 | define convertOpt |
| 33 | $(eval result := $(empty)) \ |
| 34 | $(foreach opt, $(strip $(1)), $(eval result += $(opt)=$($(opt)))) \ |
| 35 | $(patsubst %=false,%=no,$(patsubst %=true,%=yes,$(result))) |
| 36 | endef |
| 37 | |
| 38 | CONVERTED_COMMON_PROJ_OPTION := $(strip $(call convertOpt,$(COMMON_PROJ_OPTION))) |
| 39 | CONVERTED_BL2_PROJ_OPTION := $(strip $(call convertOpt,$(BL2_PROJ_OPTION))) |
| 40 | |
| 41 | # LK/BL33 make option |
| 42 | LOCAL_COMMON_MAKE_OPTION := $(if $(SHOW_COMMANDS),NOECHO=) $(if $(LK_CROSS_COMPILE),ARCH_arm64_TOOLCHAIN_PREFIX=$(LK_CROSS_COMPILE)) \ |
| 43 | CFLAGS= DEBUG=$(DEBUG) CLANGBUILD=$(LK_CLANGBUILD) CLANG_BINDIR=$(LK_CLANG_BINDIR) \ |
| 44 | $(CONVERTED_COMMON_PROJ_OPTION) \ |
| 45 | SECURE_BOOT_TYPE=$(SECURE_BOOT_TYPE) \ |
| 46 | ANDROID_2712=yes |
| 47 | |
| 48 | # BL2 LK specific |
| 49 | ifeq ($(wildcard $(TARGET_PREBUILT_LK)),) |
| 50 | TARGET_LK_OUT ?= $(TARGET_OUT_INTERMEDIATES)/BOOTLOADER_OBJ |
| 51 | BUILT_LK_TARGET := $(TARGET_LK_OUT)/build-$(LK_PROJECT)/lk.bin |
| 52 | LK_FIT_PACK_SCRIPT := $(LK_ROOT_DIR)/device/mediatek/common/tools/bootloader/mk_lk_img.sh |
| 53 | LK_MAKE_OPTION := PROJECT=$(LK_PROJECT) \ |
| 54 | $(CONVERTED_BL2_PROJ_OPTION) |
| 55 | BL2_OFF_DT_STRINGS=`fdtdump ${BL2_BUILDROOT}/lk.dtb | grep off_dt_strings | sed "s,^\/\/.*:\s*0x,,"` |
| 56 | BL2_SIZE_DT_STRINGS=`fdtdump ${BL2_BUILDROOT}/lk.dtb | grep size_dt_strings | sed "s,^\/\/.*:\s*0x,,"` |
| 57 | endif |
| 58 | |
| 59 | # BL33 LK specific |
| 60 | ifeq ($(wildcard $(TARGET_PREBUILT_BL33)),) |
| 61 | TARGET_BL33_OUT ?= $(TARGET_OUT_INTERMEDIATES)/BL33_OBJ |
| 62 | BUILT_BL33_TARGET := $(TARGET_BL33_OUT)/build-$(BL33_PROJECT)/bl33.bin |
| 63 | BL33_FIT_PACK_SCRIPT := $(LK_ROOT_DIR)/device/mediatek/common/tools/bootloader/mk_bl33_img.sh |
| 64 | BL33_MAKE_OPTION := MTK_MRDUMP_SUPPORT=$(MTK_MRDUMP_SUPPORT) \ |
| 65 | MTK_KEDUMP_MINI_SUPPORT=$(MTK_KEDUMP_MINI_SUPPORT) \ |
| 66 | PROJECT=$(BL33_PROJECT) \ |
| 67 | MTK_BOOT_REASON_SUPPORT=$(MTK_BOOT_REASON_SUPPORT) |
| 68 | BL33_OFF_DT_STRINGS=`fdtdump ${BL33_BUILDROOT}/lk.dtb | grep off_dt_strings | sed "s,^\/\/.*:\s*0x,,"` |
| 69 | BL33_SIZE_DT_STRINGS=`fdtdump ${BL33_BUILDROOT}/lk.dtb | grep size_dt_strings | sed "s,^\/\/.*:\s*0x,,"` |
| 70 | endif |