-
Notifications
You must be signed in to change notification settings - Fork 8
/
AndroidKernel.mk
executable file
·155 lines (138 loc) · 6.78 KB
/
AndroidKernel.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#Android makefile to build kernel as a part of Android Build
ifeq ($(KERNEL_DEFCONFIG),)
$(error KERNEL_DEFCONFIG must be set as environment variable)
endif
ifeq ($(KERNEL_DEFCONFIG), universal7885_FHD_P_Treble_defconfig)
TARGET_KERNEL_DTB := exynos7885-universal7885_FHD_P_Treble.dtb
else ifeq ($(KERNEL_DEFCONFIG), universal7905_FHD_P_Treble_defconfig)
TARGET_KERNEL_DTB := exynos7905-universal7905_FHD_P_Treble.dtb
else ifeq ($(KERNEL_DEFCONFIG), universal7905_P_Treble_defconfig)
TARGET_KERNEL_DTB := exynos7905-universal7905_P_Treble.dtb
else ifeq ($(KERNEL_DEFCONFIG), universal7904_FHD_P_Treble_defconfig)
TARGET_KERNEL_DTB := exynos7904-universal7904_FHD_P_Treble.dtb
else ifeq ($(KERNEL_DEFCONFIG), universal7904_P_Treble_defconfig)
TARGET_KERNEL_DTB := exynos7904-universal7904_P_Treble.dtb
else ifeq ($(KERNEL_DEFCONFIG), universal7884_P_Treble_defconfig)
TARGET_KERNEL_DTB := exynos7884-universal7884_P_Treble.dtb
else ifeq ($(KERNEL_DEFCONFIG), universal7884_FHD_P_Treble_defconfig)
TARGET_KERNEL_DTB := exynos7884-universal7884_FHD_P_Treble.dts
else ifeq ($(KERNEL_DEFCONFIG), universal7884B_P_Treble_defconfig)
TARGET_KERNEL_DTB := exynos7884b-universal7884b_P_Treble.dtb
else ifeq ($(KERNEL_DEFCONFIG), universal7884B_FHD_P_Treble_defconfig)
TARGET_KERNEL_DTB := exynos7884b-universal7884b_FHD_P_Treble.dtb
else ifeq ($(KERNEL_DEFCONFIG), universal7885_FHD_Q_MR_Treble_defconfig)
TARGET_KERNEL_DTB := exynos7885-universal7885_FHD_P_Treble.dtb
else ifeq ($(KERNEL_DEFCONFIG), universal7885_Q_MR_Treble_defconfig)
TARGET_KERNEL_DTB := exynos7885-universal7885_P_Treble.dtb
else ifeq ($(KERNEL_DEFCONFIG), universal7905_FHD_Q_MR_Treble_defconfig)
TARGET_KERNEL_DTB := exynos7905-universal7905_FHD_P_Treble.dtb
else ifeq ($(KERNEL_DEFCONFIG), universal7905_Q_MR_Treble_defconfig)
TARGET_KERNEL_DTB := exynos7905-universal7905_P_Treble.dtb
else ifeq ($(KERNEL_DEFCONFIG), universal7904_FHD_Q_MR_Treble_defconfig)
TARGET_KERNEL_DTB := exynos7904-universal7904_FHD_P_Treble.dtb
else ifeq ($(KERNEL_DEFCONFIG), universal7904_Q_MR_Treble_defconfig)
TARGET_KERNEL_DTB := exynos7904-universal7904_P_Treble.dtb
else ifeq ($(KERNEL_DEFCONFIG), universal7884B_FHD_Q_MR_Treble_defconfig)
TARGET_KERNEL_DTB := exynos7884b-universal7884b_FHD_P_Treble.dtb
else ifeq ($(KERNEL_DEFCONFIG), universal7884B_Q_MR_Treble_defconfig)
TARGET_KERNEL_DTB := exynos7884b-universal7884b_P_Treble.dtb
else
TARGET_KERNEL_DTB := exynos7885-universal7885_P_Treble.dtb
endif
ifeq ($(INSTALLED_KERNEL_TARGET),)
INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
INSTALLED_DTBO_TARGET := $(PRODUCT_OUT)/dtbo.img
INSTALLED_DTB_TARGET := $(PRODUCT_OUT)/dtb.img
endif
TARGET_KERNEL_ARCH := $(strip $(TARGET_KERNEL_ARCH))
ifeq ($(TARGET_KERNEL_ARCH),)
KERNEL_ARCH := arm64
else
KERNEL_ARCH := $(TARGET_KERNEL_ARCH)
endif
ifeq ($(CROSS_COMPILE),)
KERNEL_CROSS_COMPILE := aarch64-linux-android-
else
KERNEL_CROSS_COMPILE := $(CROSS_COMPILE)
endif
ifeq ($(TARGET_PREBUILT_KERNEL),)
TARGET_KERNEL_SOURCE := kernel/$(TARGET_KERNEL)
KERNEL_CONFIG := $(TARGET_KERNEL_SOURCE)/.config
KERNEL_BOOT := $(TARGET_KERNEL_SOURCE)/arch/$(KERNEL_ARCH)/boot
KERNEL_BIN := $(KERNEL_BOOT)/Image
KERNEL_DTB_DIR := $(KERNEL_BOOT)/dts/exynos/dtbo
KERNEL_DTB := $(KERNEL_DTB_DIR)/exynos7885.dtb
ifeq ($(KERNEL_DEFCONFIG), universal7885_FHD_P_Treble_defconfig)
KERNEL_DTBO_CFG := $(KERNEL_DTB_DIR)/exynos7885_FHD_dtboimg.cfg
else ifeq ($(KERNEL_DEFCONFIG), universal7905_FHD_P_Treble_defconfig)
KERNEL_DTBO_CFG := $(KERNEL_DTB_DIR)/exynos7905_FHD_dtboimg.cfg
else ifeq ($(KERNEL_DEFCONFIG), universal7905_P_Treble_defconfig)
KERNEL_DTBO_CFG := $(KERNEL_DTB_DIR)/exynos7905_dtboimg.cfg
else ifeq ($(KERNEL_DEFCONFIG), universal7904_FHD_P_Treble_defconfig)
KERNEL_DTBO_CFG := $(KERNEL_DTB_DIR)/exynos7904_FHD_dtboimg.cfg
else ifeq ($(KERNEL_DEFCONFIG), universal7904_P_Treble_defconfig)
KERNEL_DTBO_CFG := $(KERNEL_DTB_DIR)/exynos7904_dtboimg.cfg
else ifeq ($(KERNEL_DEFCONFIG), universal7884_FHD_P_Treble_defconfig)
KERNEL_DTBO_CFG := $(KERNEL_DTB_DIR)/exynos7884_FHD_dtboimg.cfg
else ifeq ($(KERNEL_DEFCONFIG), universal7884_P_Treble_defconfig)
KERNEL_DTBO_CFG := $(KERNEL_DTB_DIR)/exynos7884_dtboimg.cfg
else ifeq ($(KERNEL_DEFCONFIG), universal7884B_P_Treble_defconfig)
KERNEL_DTBO_CFG := $(KERNEL_DTB_DIR)/exynos7884B_dtboimg.cfg
else ifeq ($(KERNEL_DEFCONFIG), universal7884B_FHD_P_Treble_defconfig)
KERNEL_DTBO_CFG := $(KERNEL_DTB_DIR)/exynos7884B_FHD_dtboimg.cfg
else ifeq ($(KERNEL_DEFCONFIG), universal7885_FHD_Q_MR_Treble_defconfig)
KERNEL_DTBO_CFG := $(KERNEL_DTB_DIR)/exynos7885_FHD_dtboimg.cfg
else ifeq ($(KERNEL_DEFCONFIG), universal7885_Q_MR_Treble_defconfig)
KERNEL_DTBO_CFG := $(KERNEL_DTB_DIR)/exynos7885_dtboimg.cfg
else ifeq ($(KERNEL_DEFCONFIG), universal7905_FHD_Q_MR_Treble_defconfig)
KERNEL_DTBO_CFG := $(KERNEL_DTB_DIR)/exynos7905_FHD_dtboimg.cfg
else ifeq ($(KERNEL_DEFCONFIG), universal7905_Q_MR_Treble_defconfig)
KERNEL_DTBO_CFG := $(KERNEL_DTB_DIR)/exynos7905_dtboimg.cfg
else ifeq ($(KERNEL_DEFCONFIG), universal7904_FHD_Q_MR_Treble_defconfig)
KERNEL_DTBO_CFG := $(KERNEL_DTB_DIR)/exynos7904_FHD_dtboimg.cfg
else ifeq ($(KERNEL_DEFCONFIG), universal7904_Q_MR_Treble_defconfig)
KERNEL_DTBO_CFG := $(KERNEL_DTB_DIR)/exynos7904_dtboimg.cfg
else ifeq ($(KERNEL_DEFCONFIG), universal7884B_FHD_Q_MR_Treble_defconfig)
KERNEL_DTBO_CFG := $(KERNEL_DTB_DIR)/exynos7884B_FHD_dtboimg.cfg
else ifeq ($(KERNEL_DEFCONFIG), universal7884B_Q_MR_Treble_defconfig)
KERNEL_DTBO_CFG := $(KERNEL_DTB_DIR)/exynos7884B_dtboimg.cfg
else
KERNEL_DTBO_CFG := $(KERNEL_DTB_DIR)/exynos7885_dtboimg.cfg
endif
MKDTIMG := $(HOST_OUT_EXECUTABLES)/mkdtimg
ifeq ($(KERNEL_DEFCONFIG),)
$(error Kernel configuration not defined, cannot build kernel)
else
ifeq ($(N_KERNEL_BUILD_THREAD),)
N_KERNEL_BUILD_THREAD := 1
endif
TARGET_PREBUILT_KERNEL := $(KERNEL_BIN)
.PHONY: remove-bins
remove-bin:
$(hide) echo "Clean Up prebuilts"
rm -f $(KERNEL_CONFIG)
rm -f $(KERNEL_BIN)
rm -f $(KERNEL_DTB)
rm -f $(INSTALLED_KERNEL_TARGET)
rm -f $(INSTALLED_DTBO_TARGET)
rm -f $(INSTALLED_DTB_TARGET)
.PHONY: kernel
kernel: $(KERNEL_BIN)
.PHONY: kernel-distclean
kernel-distclean:
$(MAKE) -C $(TARGET_KERNEL_SOURCE) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) distclean
$(KERNEL_CONFIG): remove-bins
$(hide) echo "make $(KERNEL_DEFCONFIG)"
$(MAKE) -C $(TARGET_KERNEL_SOURCE) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(KERNEL_DEFCONFIG)
$(KERNEL_BIN): $(KERNEL_CONFIG)
$(hide) echo "Building kernel..."
$(MAKE) -C $(TARGET_KERNEL_SOURCE) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) -j$(N_KERNEL_BUILD_THREAD)
$(INSTALLED_KERNEL_TARGET): $(KERNEL_BIN) $(MKDTIMG)
cp $(KERNEL_BIN) $(INSTALLED_KERNEL_TARGET)
cp $(KERNEL_DTB) $(INSTALLED_DTB_TARGET)
$(hide) echo "Building DTBO..."
ln -sf $(TARGET_KERNEL_SOURCE)/arch
$(MKDTIMG) cfg_create $(INSTALLED_DTBO_TARGET) $(KERNEL_DTBO_CFG)
rm -f arch
endif #TARGET_PREBUILT_KERNEL
endif #KERNEL_DEFCONFIG