blob: b888de1cd9b78b55593fdb4f27e1a1c51426f1c3 [file] [log] [blame]
pulser5c9a4f32013-08-25 14:15:02 +02001# Copyright (C) 2012 The CyanogenMod Project
Rashed Abdel-Tawab73706e02019-10-15 00:56:52 -04002# (C) 2017-2020 The LineageOS Project
pulser5c9a4f32013-08-25 14:15:02 +02003#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
Marko Man3ba2cde2018-03-09 09:14:36 +010016
pulser5c9a4f32013-08-25 14:15:02 +020017# Android makefile to build kernel as a part of Android Build
Marko Man3ba2cde2018-03-09 09:14:36 +010018#
19# Configuration
20# =============
21#
22# These config vars are usually set in BoardConfig.mk:
23#
Marko Man3ba2cde2018-03-09 09:14:36 +010024# TARGET_KERNEL_CONFIG = Kernel defconfig
25# TARGET_KERNEL_VARIANT_CONFIG = Variant defconfig, optional
26# TARGET_KERNEL_SELINUX_CONFIG = SELinux defconfig, optional
27# TARGET_KERNEL_ADDITIONAL_CONFIG = Additional defconfig, optional
Marko Man3ba2cde2018-03-09 09:14:36 +010028#
29# TARGET_KERNEL_CLANG_COMPILE = Compile kernel with clang, defaults to false
30#
31# TARGET_KERNEL_CLANG_VERSION = Clang prebuilts version, optional, defaults to clang-stable
32#
33# TARGET_KERNEL_CLANG_PATH = Clang prebuilts path, optional
34#
35# BOARD_KERNEL_IMAGE_NAME = Built image name
36# for ARM use: zImage
37# for ARM64 use: Image.gz
38# for uncompressed use: Image
39# If using an appended DT, append '-dtb'
40# to the end of the image name.
41# For example, for ARM devices,
42# use zImage-dtb instead of zImage.
43#
Luca Stefani0d0cbe32020-08-03 11:58:00 +020044# BOARD_DTBO_CFG = Path to a mkdtboimg.py config file
45#
Aayush Gupta48411fb2020-08-25 10:03:10 +000046# BOARD_CUSTOM_DTBOIMG_MK = Path to a custom dtboimage makefile
47#
Marko Man3ba2cde2018-03-09 09:14:36 +010048# KERNEL_CC = The C Compiler used. This is automatically set based
49# on whether the clang version is set, optional.
50#
51# KERNEL_CLANG_TRIPLE = Target triple for clang (e.g. aarch64-linux-gnu-)
52# defaults to arm-linux-gnu- for arm
53# aarch64-linux-gnu- for arm64
54# x86_64-linux-gnu- for x86
55#
Marko Man3ba2cde2018-03-09 09:14:36 +010056# NEED_KERNEL_MODULE_ROOT = Optional, if true, install kernel
Marko Man0b2160a2019-09-08 01:28:58 +020057# modules in root instead of vendor
58# NEED_KERNEL_MODULE_SYSTEM = Optional, if true, install kernel
59# modules in system instead of vendor
Vachounetb3baf3e2020-02-04 14:24:30 +010060# NEED_KERNEL_MODULE_VENDOR_OVERLAY = Optional, if true, install kernel
61# modules in vendor overlay instead of vendor
Marko Man3ba2cde2018-03-09 09:14:36 +010062
63ifneq ($(TARGET_NO_KERNEL),true)
pulser5c9a4f32013-08-25 14:15:02 +020064
pulser5c9a4f32013-08-25 14:15:02 +020065## Externally influenced variables
pulser5c9a4f32013-08-25 14:15:02 +020066KERNEL_SRC := $(TARGET_KERNEL_SOURCE)
67# kernel configuration - mandatory
68KERNEL_DEFCONFIG := $(TARGET_KERNEL_CONFIG)
69VARIANT_DEFCONFIG := $(TARGET_KERNEL_VARIANT_CONFIG)
70SELINUX_DEFCONFIG := $(TARGET_KERNEL_SELINUX_CONFIG)
71
72## Internal variables
Rashed Abdel-Tawab73706e02019-10-15 00:56:52 -040073DTC := $(HOST_OUT_EXECUTABLES)/dtc
pulser5c9a4f32013-08-25 14:15:02 +020074KERNEL_OUT := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ
Luca Stefaniacf449e2020-08-02 19:08:31 +020075DTBO_OUT := $(TARGET_OUT_INTERMEDIATES)/DTBO_OBJ
76DTB_OUT := $(TARGET_OUT_INTERMEDIATES)/DTB_OBJ
pulser5c9a4f32013-08-25 14:15:02 +020077KERNEL_CONFIG := $(KERNEL_OUT)/.config
Marko Man0b2160a2019-09-08 01:28:58 +020078KERNEL_RELEASE := $(KERNEL_OUT)/include/config/kernel.release
pulser5c9a4f32013-08-25 14:15:02 +020079
Marko Man3ba2cde2018-03-09 09:14:36 +010080ifeq ($(KERNEL_ARCH),x86_64)
81KERNEL_DEFCONFIG_ARCH := x86
82else
83KERNEL_DEFCONFIG_ARCH := $(KERNEL_ARCH)
84endif
dianlujitaofb133a32019-09-12 17:37:45 +080085KERNEL_DEFCONFIG_DIR := $(KERNEL_SRC)/arch/$(KERNEL_DEFCONFIG_ARCH)/configs
86KERNEL_DEFCONFIG_SRC := $(KERNEL_DEFCONFIG_DIR)/$(KERNEL_DEFCONFIG)
pulser5c9a4f32013-08-25 14:15:02 +020087
pulser5c9a4f32013-08-25 14:15:02 +020088ifneq ($(TARGET_KERNEL_ADDITIONAL_CONFIG),)
89KERNEL_ADDITIONAL_CONFIG := $(TARGET_KERNEL_ADDITIONAL_CONFIG)
dianlujitaofb133a32019-09-12 17:37:45 +080090KERNEL_ADDITIONAL_CONFIG_SRC := $(KERNEL_DEFCONFIG_DIR)/$(KERNEL_ADDITIONAL_CONFIG)
Marko Man3ba2cde2018-03-09 09:14:36 +010091 ifeq ("$(wildcard $(KERNEL_ADDITIONAL_CONFIG_SRC))","")
92 $(warning TARGET_KERNEL_ADDITIONAL_CONFIG '$(TARGET_KERNEL_ADDITIONAL_CONFIG)' doesn't exist)
93 KERNEL_ADDITIONAL_CONFIG_SRC := /dev/null
94 endif
95else
96 KERNEL_ADDITIONAL_CONFIG_SRC := /dev/null
pulser5c9a4f32013-08-25 14:15:02 +020097endif
98
dianlujitaofb133a32019-09-12 17:37:45 +080099ifeq ($(BOARD_KERNEL_IMAGE_NAME),)
100$(error BOARD_KERNEL_IMAGE_NAME not defined.)
101endif
102TARGET_PREBUILT_INT_KERNEL := $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/$(BOARD_KERNEL_IMAGE_NAME)
103
pulser5c9a4f32013-08-25 14:15:02 +0200104ifeq "$(wildcard $(KERNEL_SRC) )" ""
105 ifneq ($(TARGET_PREBUILT_KERNEL),)
106 HAS_PREBUILT_KERNEL := true
107 NEEDS_KERNEL_COPY := true
108 else
109 $(foreach cf,$(PRODUCT_COPY_FILES), \
110 $(eval _src := $(call word-colon,1,$(cf))) \
111 $(eval _dest := $(call word-colon,2,$(cf))) \
112 $(ifeq kernel,$(_dest), \
113 $(eval HAS_PREBUILT_KERNEL := true)))
114 endif
115
116 ifneq ($(HAS_PREBUILT_KERNEL),)
117 $(warning ***************************************************************)
118 $(warning * Using prebuilt kernel binary instead of source *)
119 $(warning * THIS IS DEPRECATED, AND WILL BE DISCONTINUED *)
120 $(warning * Please configure your device to download the kernel *)
121 $(warning * source repository to $(KERNEL_SRC))
pulser5c9a4f32013-08-25 14:15:02 +0200122 $(warning * for more information *)
123 $(warning ***************************************************************)
124 FULL_KERNEL_BUILD := false
125 KERNEL_BIN := $(TARGET_PREBUILT_KERNEL)
126 else
127 $(warning ***************************************************************)
128 $(warning * *)
129 $(warning * No kernel source found, and no fallback prebuilt defined. *)
130 $(warning * Please make sure your device is properly configured to *)
131 $(warning * download the kernel repository to $(KERNEL_SRC))
132 $(warning * and add the TARGET_KERNEL_CONFIG variable to BoardConfig.mk *)
133 $(warning * *)
134 $(warning * As an alternative, define the TARGET_PREBUILT_KERNEL *)
135 $(warning * variable with the path to the prebuilt binary kernel image *)
136 $(warning * in your BoardConfig.mk file *)
137 $(warning * *)
138 $(warning ***************************************************************)
139 $(error "NO KERNEL")
140 endif
141else
142 NEEDS_KERNEL_COPY := true
143 ifeq ($(TARGET_KERNEL_CONFIG),)
144 $(warning **********************************************************)
145 $(warning * Kernel source found, but no configuration was defined *)
146 $(warning * Please add the TARGET_KERNEL_CONFIG variable to your *)
147 $(warning * BoardConfig.mk file *)
148 $(warning **********************************************************)
Luca Stefanicd9eed42020-08-03 11:32:19 +0200149 $(error "NO KERNEL CONFIG")
pulser5c9a4f32013-08-25 14:15:02 +0200150 else
pulser5c9a4f32013-08-25 14:15:02 +0200151 FULL_KERNEL_BUILD := true
152 KERNEL_BIN := $(TARGET_PREBUILT_INT_KERNEL)
153 endif
154endif
155
156ifeq ($(FULL_KERNEL_BUILD),true)
157
Marko Man3ba2cde2018-03-09 09:14:36 +0100158ifeq ($(NEED_KERNEL_MODULE_ROOT),true)
Marko Man0b2160a2019-09-08 01:28:58 +0200159KERNEL_MODULES_OUT := $(TARGET_ROOT_OUT)
Rashed Abdel-Tawab539c2ae2019-09-10 08:44:55 -0700160KERNEL_DEPMOD_STAGING_DIR := $(KERNEL_BUILD_OUT_PREFIX)$(call intermediates-dir-for,PACKAGING,depmod_recovery)
Marko Man3ba2cde2018-03-09 09:14:36 +0100161KERNEL_MODULE_MOUNTPOINT :=
Marko Man0b2160a2019-09-08 01:28:58 +0200162else ifeq ($(NEED_KERNEL_MODULE_SYSTEM),true)
163KERNEL_MODULES_OUT := $(TARGET_OUT)
Rashed Abdel-Tawab539c2ae2019-09-10 08:44:55 -0700164KERNEL_DEPMOD_STAGING_DIR := $(KERNEL_BUILD_OUT_PREFIX)$(call intermediates-dir-for,PACKAGING,depmod_system)
Marko Man3ba2cde2018-03-09 09:14:36 +0100165KERNEL_MODULE_MOUNTPOINT := system
Vachounetb3baf3e2020-02-04 14:24:30 +0100166else ifeq ($(NEED_KERNEL_MODULE_VENDOR_OVERLAY),true)
167KERNEL_MODULES_OUT := $(TARGET_OUT_PRODUCT)/vendor_overlay/29
168KERNEL_DEPMOD_STAGING_DIR := $(KERNEL_BUILD_OUT_PREFIX)$(call intermediates-dir-for,PACKAGING,depmod_product)
169KERNEL_MODULE_MOUNTPOINT := product
Rashed Abdel-Tawabd164cac2019-06-13 12:08:09 +0200170else
Marko Man0b2160a2019-09-08 01:28:58 +0200171KERNEL_MODULES_OUT := $(TARGET_OUT_VENDOR)
Rashed Abdel-Tawab539c2ae2019-09-10 08:44:55 -0700172KERNEL_DEPMOD_STAGING_DIR := $(KERNEL_BUILD_OUT_PREFIX)$(call intermediates-dir-for,PACKAGING,depmod_vendor)
Marko Man0b2160a2019-09-08 01:28:58 +0200173KERNEL_MODULE_MOUNTPOINT := vendor
Rashed Abdel-Tawabd164cac2019-06-13 12:08:09 +0200174endif
Rashed Abdel-Tawab539c2ae2019-09-10 08:44:55 -0700175MODULES_INTERMEDIATES := $(KERNEL_BUILD_OUT_PREFIX)$(call intermediates-dir-for,PACKAGING,kernel_modules)
Vachounet7d6628f2019-01-09 13:54:35 +0100176
Rashed Abdel-Tawab73706e02019-10-15 00:56:52 -0400177# Add host bin out dir to path
178PATH_OVERRIDE := PATH=$(KERNEL_BUILD_OUT_PREFIX)$(HOST_OUT_EXECUTABLES):$$PATH
Marko Man3ba2cde2018-03-09 09:14:36 +0100179ifeq ($(TARGET_KERNEL_CLANG_COMPILE),true)
180 ifneq ($(TARGET_KERNEL_CLANG_VERSION),)
Luca Stefani270b0bf2019-09-14 16:26:26 +0200181 KERNEL_CLANG_VERSION := clang-$(TARGET_KERNEL_CLANG_VERSION)
Marko Man3ba2cde2018-03-09 09:14:36 +0100182 else
Marko Man0b2160a2019-09-08 01:28:58 +0200183 # Use the default version of clang if TARGET_KERNEL_CLANG_VERSION hasn't been set by the device config
184 KERNEL_CLANG_VERSION := $(LLVM_PREBUILTS_VERSION)
pulser5c9a4f32013-08-25 14:15:02 +0200185 endif
Marko Man0de88b12019-10-08 13:28:11 +0200186 TARGET_KERNEL_CLANG_PATH ?= $(BUILD_TOP)/prebuilts/clang/host/$(HOST_OS)-x86/$(KERNEL_CLANG_VERSION)
Marko Man3ba2cde2018-03-09 09:14:36 +0100187 ifeq ($(KERNEL_ARCH),arm64)
188 KERNEL_CLANG_TRIPLE ?= CLANG_TRIPLE=aarch64-linux-gnu-
189 else ifeq ($(KERNEL_ARCH),arm)
190 KERNEL_CLANG_TRIPLE ?= CLANG_TRIPLE=arm-linux-gnu-
191 else ifeq ($(KERNEL_ARCH),x86)
192 KERNEL_CLANG_TRIPLE ?= CLANG_TRIPLE=x86_64-linux-gnu-
193 endif
dianlujitaofb133a32019-09-12 17:37:45 +0800194 PATH_OVERRIDE += PATH=$(TARGET_KERNEL_CLANG_PATH)/bin:$$PATH LD_LIBRARY_PATH=$(TARGET_KERNEL_CLANG_PATH)/lib64:$$LD_LIBRARY_PATH
Marko Man3ba2cde2018-03-09 09:14:36 +0100195 ifeq ($(KERNEL_CC),)
Marko Man0b2160a2019-09-08 01:28:58 +0200196 KERNEL_CC := CC="$(CCACHE_BIN) clang"
Marko Man3ba2cde2018-03-09 09:14:36 +0100197 endif
pulser5c9a4f32013-08-25 14:15:02 +0200198endif
199
dianlujitaofb133a32019-09-12 17:37:45 +0800200ifneq ($(TARGET_KERNEL_MODULES),)
201 $(error TARGET_KERNEL_MODULES is no longer supported!)
pulser5c9a4f32013-08-25 14:15:02 +0200202endif
203
Marko Man0de88b12019-10-08 13:28:11 +0200204PATH_OVERRIDE += PATH=$(KERNEL_TOOLCHAIN_PATH_gcc)/bin:$$PATH
205
Marko Man3ba2cde2018-03-09 09:14:36 +0100206KERNEL_ADDITIONAL_CONFIG_OUT := $(KERNEL_OUT)/.additional_config
207
Marko Man0b2160a2019-09-08 01:28:58 +0200208# Internal implementation of make-kernel-target
209# $(1): output path (The value passed to O=)
210# $(2): target to build (eg. defconfig, modules, dtbo.img)
211define internal-make-kernel-target
Marko Manef692442019-10-08 13:27:09 +0200212$(PATH_OVERRIDE) $(KERNEL_MAKE_CMD) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_BUILD_OUT_PREFIX)$(1) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(2)
Marko Man0b2160a2019-09-08 01:28:58 +0200213endef
214
215# Make a kernel target
216# $(1): The kernel target to build (eg. defconfig, modules, modules_install)
217define make-kernel-target
218$(call internal-make-kernel-target,$(KERNEL_OUT),$(1))
219endef
220
221# Make a DTBO target
222# $(1): The DTBO target to build (eg. dtbo.img, defconfig)
223define make-dtbo-target
Luca Stefaniacf449e2020-08-02 19:08:31 +0200224$(call internal-make-kernel-target,$(DTBO_OUT),$(1))
Marko Man0b2160a2019-09-08 01:28:58 +0200225endef
226
Rashed Abdel-Tawabb1531b62019-09-27 23:37:14 -0400227# Make a DTB targets
228# $(1): The DTB target to build (eg. dtbs, defconfig)
229define make-dtb-target
Luca Stefaniacf449e2020-08-02 19:08:31 +0200230$(call internal-make-kernel-target,$(DTB_OUT),$(1))
Rashed Abdel-Tawabb1531b62019-09-27 23:37:14 -0400231endef
232
dianlujitaofb133a32019-09-12 17:37:45 +0800233$(KERNEL_OUT):
234 mkdir -p $(KERNEL_OUT)
235
236$(KERNEL_ADDITIONAL_CONFIG_OUT): $(KERNEL_OUT)
Marko Man3ba2cde2018-03-09 09:14:36 +0100237 $(hide) cmp -s $(KERNEL_ADDITIONAL_CONFIG_SRC) $@ || cp $(KERNEL_ADDITIONAL_CONFIG_SRC) $@;
238
Marko Man0b2160a2019-09-08 01:28:58 +0200239$(KERNEL_CONFIG): $(KERNEL_DEFCONFIG_SRC) $(KERNEL_ADDITIONAL_CONFIG_OUT)
Marko Man3ba2cde2018-03-09 09:14:36 +0100240 @echo "Building Kernel Config"
Marko Man0b2160a2019-09-08 01:28:58 +0200241 $(call make-kernel-target,VARIANT_DEFCONFIG=$(VARIANT_DEFCONFIG) SELINUX_DEFCONFIG=$(SELINUX_DEFCONFIG) $(KERNEL_DEFCONFIG))
pulser5c9a4f32013-08-25 14:15:02 +0200242 $(hide) if [ ! -z "$(KERNEL_CONFIG_OVERRIDE)" ]; then \
243 echo "Overriding kernel config with '$(KERNEL_CONFIG_OVERRIDE)'"; \
244 echo $(KERNEL_CONFIG_OVERRIDE) >> $(KERNEL_OUT)/.config; \
Marko Man0b2160a2019-09-08 01:28:58 +0200245 $(call make-kernel-target,oldconfig); \
246 fi
Marko Man3ba2cde2018-03-09 09:14:36 +0100247 # Create defconfig build artifact
Marko Man0b2160a2019-09-08 01:28:58 +0200248 $(call make-kernel-target,savedefconfig)
pulser5c9a4f32013-08-25 14:15:02 +0200249 $(hide) if [ ! -z "$(KERNEL_ADDITIONAL_CONFIG)" ]; then \
250 echo "Using additional config '$(KERNEL_ADDITIONAL_CONFIG)'"; \
Marko Man3ba2cde2018-03-09 09:14:36 +0100251 $(KERNEL_SRC)/scripts/kconfig/merge_config.sh -m -O $(KERNEL_OUT) $(KERNEL_OUT)/.config $(KERNEL_SRC)/arch/$(KERNEL_ARCH)/configs/$(KERNEL_ADDITIONAL_CONFIG); \
Marko Man0b2160a2019-09-08 01:28:58 +0200252 $(call make-kernel-target,KCONFIG_ALLCONFIG=$(KERNEL_OUT)/.config alldefconfig); \
253 fi
pulser5c9a4f32013-08-25 14:15:02 +0200254
Rashed Abdel-Tawab73706e02019-10-15 00:56:52 -0400255$(TARGET_PREBUILT_INT_KERNEL): $(KERNEL_CONFIG) $(DEPMOD) $(DTC)
256 @echo "Building Kernel Image ($(BOARD_KERNEL_IMAGE_NAME))"
Marko Man0b2160a2019-09-08 01:28:58 +0200257 $(call make-kernel-target,$(BOARD_KERNEL_IMAGE_NAME))
Marko Man3ba2cde2018-03-09 09:14:36 +0100258 $(hide) if grep -q '^CONFIG_OF=y' $(KERNEL_CONFIG); then \
259 echo "Building DTBs"; \
Marko Man0b2160a2019-09-08 01:28:58 +0200260 $(call make-kernel-target,dtbs); \
Marko Man3ba2cde2018-03-09 09:14:36 +0100261 fi
Marko Man0b2160a2019-09-08 01:28:58 +0200262 $(hide) if grep -q '=m' $(KERNEL_CONFIG); then \
Marko Man3ba2cde2018-03-09 09:14:36 +0100263 echo "Building Kernel Modules"; \
dianlujitaofb133a32019-09-12 17:37:45 +0800264 $(call make-kernel-target,modules) || exit "$$?"; \
Marko Man3ba2cde2018-03-09 09:14:36 +0100265 echo "Installing Kernel Modules"; \
dianlujitaofb133a32019-09-12 17:37:45 +0800266 $(call make-kernel-target,INSTALL_MOD_PATH=$(MODULES_INTERMEDIATES) INSTALL_MOD_STRIP=1 modules_install); \
Marko Man0b2160a2019-09-08 01:28:58 +0200267 kernel_release=$$(cat $(KERNEL_RELEASE)) \
Luca Stefaniebfad6d2020-08-01 21:20:23 +0200268 kernel_modules_dir=$(MODULES_INTERMEDIATES)/lib/modules/$$kernel_release \
269 $(foreach s, $(TARGET_MODULE_ALIASES),\
270 $(eval p := $(subst :,$(space),$(s))) \
271 ; mv $$(find $$kernel_modules_dir -name $(word 1,$(p))) $$kernel_modules_dir/$(word 2,$(p))); \
272 modules=$$(find $$kernel_modules_dir -type f -name '*.ko'); \
Marko Man0b2160a2019-09-08 01:28:58 +0200273 ($(call build-image-kernel-modules,$$modules,$(KERNEL_MODULES_OUT),$(KERNEL_MODULE_MOUNTPOINT)/,$(KERNEL_DEPMOD_STAGING_DIR))); \
Marko Man3ba2cde2018-03-09 09:14:36 +0100274 fi
pulser5c9a4f32013-08-25 14:15:02 +0200275
Marko Man0b2160a2019-09-08 01:28:58 +0200276.PHONY: kerneltags
277kerneltags: $(KERNEL_CONFIG)
Marko Man0b2160a2019-09-08 01:28:58 +0200278 $(call make-kernel-target,tags)
pulser5c9a4f32013-08-25 14:15:02 +0200279
Marko Man0b2160a2019-09-08 01:28:58 +0200280.PHONY: kernelsavedefconfig alldefconfig
pulser5c9a4f32013-08-25 14:15:02 +0200281
dianlujitaofb133a32019-09-12 17:37:45 +0800282kernelsavedefconfig: $(KERNEL_OUT)
Marko Man0b2160a2019-09-08 01:28:58 +0200283 $(call make-kernel-target,$(KERNEL_DEFCONFIG))
pulser5c9a4f32013-08-25 14:15:02 +0200284 env KCONFIG_NOTIMESTAMP=true \
Marko Man0b2160a2019-09-08 01:28:58 +0200285 $(call make-kernel-target,savedefconfig)
Marko Man3ba2cde2018-03-09 09:14:36 +0100286 cp $(KERNEL_OUT)/defconfig $(KERNEL_DEFCONFIG_SRC)
287
dianlujitaofb133a32019-09-12 17:37:45 +0800288alldefconfig: $(KERNEL_OUT)
Marko Man3ba2cde2018-03-09 09:14:36 +0100289 env KCONFIG_NOTIMESTAMP=true \
Marko Man0b2160a2019-09-08 01:28:58 +0200290 $(call make-kernel-target,alldefconfig)
Marko Man3ba2cde2018-03-09 09:14:36 +0100291
Luca Stefaniacf449e2020-08-02 19:08:31 +0200292ifeq (true,$(filter true, $(TARGET_NEEDS_DTBOIMAGE) $(BOARD_KERNEL_SEPARATED_DTBO)))
Aayush Gupta48411fb2020-08-25 10:03:10 +0000293ifneq ($(BOARD_CUSTOM_DTBOIMG_MK),)
294include $(BOARD_CUSTOM_DTBOIMG_MK)
295else
Rashed Abdel-Tawab73706e02019-10-15 00:56:52 -0400296MKDTIMG := $(HOST_OUT_EXECUTABLES)/mkdtimg$(HOST_EXECUTABLE_SUFFIX)
297MKDTBOIMG := $(HOST_OUT_EXECUTABLES)/mkdtboimg.py$(HOST_EXECUTABLE_SUFFIX)
298$(BOARD_PREBUILT_DTBOIMAGE): $(DTC) $(MKDTIMG) $(MKDTBOIMG)
Luca Stefaniacf449e2020-08-02 19:08:31 +0200299ifeq ($(BOARD_KERNEL_SEPARATED_DTBO),true)
300$(BOARD_PREBUILT_DTBOIMAGE):
301 @echo "Building dtbo.img"
302 $(call make-dtbo-target,$(KERNEL_DEFCONFIG))
303 $(call make-dtbo-target,dtbs)
Luca Stefani0d0cbe32020-08-03 11:58:00 +0200304ifdef BOARD_DTBO_CFG
305 $(MKDTBOIMG) cfg_create $@ $(BOARD_DTBO_CFG) -d $(DTBO_OUT)/arch/$(KERNEL_ARCH)/boot/dts
306else
Luca Stefanic4f598a2020-08-05 11:37:46 +0200307 $(MKDTBOIMG) create $@ --page_size=$(BOARD_KERNEL_PAGESIZE) $(shell find $(DTBO_OUT)/arch/$(KERNEL_ARCH)/boot/dts -type f -name "*.dtbo" | sort)
Luca Stefani0d0cbe32020-08-03 11:58:00 +0200308endif
Luca Stefaniacf449e2020-08-02 19:08:31 +0200309else
310$(BOARD_PREBUILT_DTBOIMAGE):
311 @echo "Building dtbo.img"
Marko Man0b2160a2019-09-08 01:28:58 +0200312 $(call make-dtbo-target,$(KERNEL_DEFCONFIG))
313 $(call make-dtbo-target,dtbo.img)
Luca Stefaniacf449e2020-08-02 19:08:31 +0200314endif # BOARD_KERNEL_SEPARATED_DTBO
Aayush Gupta48411fb2020-08-25 10:03:10 +0000315endif # BOARD_CUSTOM_DTBOIMG_MK
Luca Stefaniacf449e2020-08-02 19:08:31 +0200316endif # TARGET_NEEDS_DTBOIMAGE/BOARD_KERNEL_SEPARATED_DTBO
317
318ifeq ($(BOARD_INCLUDE_DTB_IN_BOOTIMG),true)
319ifeq ($(BOARD_PREBUILT_DTBIMAGE_DIR),)
320$(INSTALLED_DTBIMAGE_TARGET): $(DTC)
321 @echo "Building dtb.img"
322 $(call make-dtb-target,$(KERNEL_DEFCONFIG))
323 $(call make-dtb-target,dtbs)
324 cat $(shell find $(DTB_OUT)/arch/$(KERNEL_ARCH)/boot/dts -type f -name "*.dtb" | sort) > $@
325endif # !BOARD_PREBUILT_DTBIMAGE_DIR
326endif # BOARD_INCLUDE_DTB_IN_BOOTIMG
pulser5c9a4f32013-08-25 14:15:02 +0200327
328endif # FULL_KERNEL_BUILD
329
330## Install it
331
332ifeq ($(NEEDS_KERNEL_COPY),true)
333file := $(INSTALLED_KERNEL_TARGET)
334ALL_PREBUILT += $(file)
335$(file) : $(KERNEL_BIN) | $(ACP)
336 $(transform-prebuilt-to-target)
337
338ALL_PREBUILT += $(INSTALLED_KERNEL_TARGET)
339endif
Marko Man3ba2cde2018-03-09 09:14:36 +0100340
Marko Man3ba2cde2018-03-09 09:14:36 +0100341.PHONY: kernel
dianlujitaofb133a32019-09-12 17:37:45 +0800342kernel: $(INSTALLED_KERNEL_TARGET)
Marko Man3ba2cde2018-03-09 09:14:36 +0100343
Marko Man0b2160a2019-09-08 01:28:58 +0200344.PHONY: dtboimage
345dtboimage: $(INSTALLED_DTBOIMAGE_TARGET)
Marko Man3ba2cde2018-03-09 09:14:36 +0100346
Rashed Abdel-Tawabb1531b62019-09-27 23:37:14 -0400347.PHONY: dtbimage
348dtbimage: $(INSTALLED_DTBIMAGE_TARGET)
Rashed Abdel-Tawabb1531b62019-09-27 23:37:14 -0400349
Marko Man3ba2cde2018-03-09 09:14:36 +0100350endif # TARGET_NO_KERNEL