-
Notifications
You must be signed in to change notification settings - Fork 7
/
kenv.mk
106 lines (97 loc) · 3.88 KB
/
kenv.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2019 MediaTek Inc.
KERNEL_ENV_PATH := $(call my-dir)
KERNEL_ROOT_DIR := $(PWD)
define touch-kernel-image-timestamp
if [ -e $(1) ] && [ -e $(2) ] && cmp -s $(1) $(2); then \
echo $(2) has no change;\
mv -f $(1) $(2);\
else \
rm -f $(1);\
fi
endef
# '\\' in command is wrongly replaced to '\\\\' in kernel/out/arch/arm/boot/compressed/.piggy.xzkern.cmd
define fixup-kernel-cmd-file
if [ -e $(1) ]; then cp $(1) $(1).bak; sed -e 's/\\\\\\\\/\\\\/g' < $(1).bak > $(1); rm -f $(1).bak; fi
endef
ifneq ($(strip $(TARGET_NO_KERNEL)),true)
KERNEL_DIR := $(KERNEL_ENV_PATH)
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
current_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path))))
kernel_build_config_suffix := .mtk
ifeq ($(KERNEL_TARGET_ARCH),arm64)
kernel_build_config_suffix := $(kernel_build_config_suffix).aarch64
ifeq ($(strip $(TARGET_KERNEL_USE_CLANG)),true)
else
kernel_build_config_suffix := $(kernel_build_config_suffix).gcc
endif
else
kernel_build_config_suffix := $(kernel_build_config_suffix).arm
ifeq ($(strip $(TARGET_KERNEL_USE_CLANG)),true)
else
$(error TARGET_KERNEL_USE_CLANG is not set)
endif
endif
ifeq ($(PLATFORM_VERSION),Tiramisu)
kernel_build_config_suffix := $(kernel_build_config_suffix).tiramisu
endif
include $(current_dir)/build.config$(kernel_build_config_suffix)
ARGS := CROSS_COMPILE=$(CROSS_COMPILE)
ifneq ($(LLVM),)
ARGS += LLVM=1
ifneq ($(filter-out false,$(USE_CCACHE)),)
CCACHE_EXEC ?= /usr/bin/ccache
CCACHE_EXEC := $(abspath $(wildcard $(CCACHE_EXEC)))
else
CCACHE_EXEC :=
endif
ifneq ($(CCACHE_EXEC),)
ARGS += CCACHE_CPP2=yes CC='$(CCACHE_EXEC) clang'
else
ARGS += CC=clang
endif
ifneq ($(LLVM_IAS),)
ARGS += LLVM_IAS=$(LLVM_IAS)
endif
ifeq ($(HOSTCC),)
ifneq ($(CC),)
ARGS += HOSTCC=$(CC)
endif
else
ARGS += HOSTCC=$(HOSTCC)
endif
ifneq ($(LD),)
ARGS += LD=$(LD) HOSTLD=$(LD)
ifneq ($(suffix $(LD)),)
ARGS += HOSTLDFLAGS=-fuse-ld=$(subst .,,$(suffix $(LD)))
endif
endif
ifneq ($(LD_LIBRARY_PATH),)
ARGS += LD_LIBRARY_PATH=$(KERNEL_ROOT_DIR)/$(LD_LIBRARY_PATH)
endif
endif
TARGET_KERNEL_CROSS_COMPILE := $(KERNEL_ROOT_DIR)/$(LINUX_GCC_CROSS_COMPILE_PREBUILTS_BIN)/$(CROSS_COMPILE)
ifeq ($(wildcard $(TARGET_PREBUILT_KERNEL)),)
KERNEL_OUT ?= $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ
KERNEL_ROOT_OUT := $(if $(filter /% ~%,$(KERNEL_OUT)),,$(KERNEL_ROOT_DIR)/)$(KERNEL_OUT)
ifeq ($(KERNEL_TARGET_ARCH), arm64)
KERNEL_ZIMAGE_OUT := $(KERNEL_OUT)/arch/$(KERNEL_TARGET_ARCH)/boot/Image.gz
KERNEL_DTB_TARGET := $(KERNEL_OUT)/arch/$(KERNEL_TARGET_ARCH)/boot/dts/mediatek/$(TARGET_BOARD_PLATFORM).dtb
else
KERNEL_ZIMAGE_OUT := $(KERNEL_OUT)/arch/$(KERNEL_TARGET_ARCH)/boot/zImage
KERNEL_DTB_TARGET := $(KERNEL_OUT)/arch/$(KERNEL_TARGET_ARCH)/boot/dts/$(TARGET_BOARD_PLATFORM).dtb
endif
INSTALLED_MTK_DTB_TARGET := $(BOARD_PREBUILT_DTBIMAGE_DIR)/mtk_dtb
BUILT_KERNEL_TARGET := $(KERNEL_ZIMAGE_OUT).bin
INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
TARGET_KERNEL_CONFIG := $(KERNEL_OUT)/.config
KERNEL_CONFIG_FILE := $(KERNEL_DIR)/arch/$(KERNEL_TARGET_ARCH)/configs/$(word 1,$(KERNEL_DEFCONFIG))
KERNEL_MODULES_OUT := $(TARGET_OUT_VENDOR)/lib/modules
KERNEL_MAKE_OPTION := O=$(KERNEL_ROOT_OUT) ARCH=$(KERNEL_TARGET_ARCH) $(ARGS) ROOTDIR=$(KERNEL_ROOT_DIR)
KERNEL_MAKE_PATH_OPTION := /usr/bin:/bin
KERNEL_MAKE_OPTION += PATH=$(KERNEL_ROOT_DIR)/$(CLANG_PREBUILT_BIN):$(KERNEL_ROOT_DIR)/$(LINUX_GCC_CROSS_COMPILE_PREBUILTS_BIN):$(KERNEL_MAKE_PATH_OPTION):$$PATH
else
BUILT_KERNEL_TARGET := $(TARGET_PREBUILT_KERNEL)
endif #TARGET_PREBUILT_KERNEL is empty
KERNEL_MAKE_OPTION += PROJECT_DTB_NAMES='$(PROJECT_DTB_NAMES)'
endif #TARGET_NO_KERNEL