pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 1 | # Copyright (C) 2012 The CyanogenMod Project |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 2 | # (C) 2017 The LineageOS Project |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 3 | # |
| 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 Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 16 | |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 17 | # Android makefile to build kernel as a part of Android Build |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 18 | # |
| 19 | # Configuration |
| 20 | # ============= |
| 21 | # |
| 22 | # These config vars are usually set in BoardConfig.mk: |
| 23 | # |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 24 | # 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 Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 28 | # |
| 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 | # |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 44 | # KERNEL_CC = The C Compiler used. This is automatically set based |
| 45 | # on whether the clang version is set, optional. |
| 46 | # |
| 47 | # KERNEL_CLANG_TRIPLE = Target triple for clang (e.g. aarch64-linux-gnu-) |
| 48 | # defaults to arm-linux-gnu- for arm |
| 49 | # aarch64-linux-gnu- for arm64 |
| 50 | # x86_64-linux-gnu- for x86 |
| 51 | # |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 52 | # NEED_KERNEL_MODULE_ROOT = Optional, if true, install kernel |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 53 | # modules in root instead of vendor |
| 54 | # NEED_KERNEL_MODULE_SYSTEM = Optional, if true, install kernel |
| 55 | # modules in system instead of vendor |
Vachounet | b3baf3e | 2020-02-04 14:24:30 +0100 | [diff] [blame^] | 56 | # NEED_KERNEL_MODULE_VENDOR_OVERLAY = Optional, if true, install kernel |
| 57 | # modules in vendor overlay instead of vendor |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 58 | |
| 59 | ifneq ($(TARGET_NO_KERNEL),true) |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 60 | |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 61 | ## Externally influenced variables |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 62 | KERNEL_SRC := $(TARGET_KERNEL_SOURCE) |
| 63 | # kernel configuration - mandatory |
| 64 | KERNEL_DEFCONFIG := $(TARGET_KERNEL_CONFIG) |
| 65 | VARIANT_DEFCONFIG := $(TARGET_KERNEL_VARIANT_CONFIG) |
| 66 | SELINUX_DEFCONFIG := $(TARGET_KERNEL_SELINUX_CONFIG) |
| 67 | |
| 68 | ## Internal variables |
Rashed Abdel-Tawab | 8735c42 | 2019-10-13 16:59:57 -0700 | [diff] [blame] | 69 | DTBS_OUT := $(PRODUCT_OUT)/dtbs |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 70 | KERNEL_OUT := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ |
| 71 | KERNEL_CONFIG := $(KERNEL_OUT)/.config |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 72 | KERNEL_RELEASE := $(KERNEL_OUT)/include/config/kernel.release |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 73 | |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 74 | ifeq ($(KERNEL_ARCH),x86_64) |
| 75 | KERNEL_DEFCONFIG_ARCH := x86 |
| 76 | else |
| 77 | KERNEL_DEFCONFIG_ARCH := $(KERNEL_ARCH) |
| 78 | endif |
dianlujitao | fb133a3 | 2019-09-12 17:37:45 +0800 | [diff] [blame] | 79 | KERNEL_DEFCONFIG_DIR := $(KERNEL_SRC)/arch/$(KERNEL_DEFCONFIG_ARCH)/configs |
| 80 | KERNEL_DEFCONFIG_SRC := $(KERNEL_DEFCONFIG_DIR)/$(KERNEL_DEFCONFIG) |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 81 | |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 82 | ifneq ($(TARGET_KERNEL_ADDITIONAL_CONFIG),) |
| 83 | KERNEL_ADDITIONAL_CONFIG := $(TARGET_KERNEL_ADDITIONAL_CONFIG) |
dianlujitao | fb133a3 | 2019-09-12 17:37:45 +0800 | [diff] [blame] | 84 | KERNEL_ADDITIONAL_CONFIG_SRC := $(KERNEL_DEFCONFIG_DIR)/$(KERNEL_ADDITIONAL_CONFIG) |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 85 | ifeq ("$(wildcard $(KERNEL_ADDITIONAL_CONFIG_SRC))","") |
| 86 | $(warning TARGET_KERNEL_ADDITIONAL_CONFIG '$(TARGET_KERNEL_ADDITIONAL_CONFIG)' doesn't exist) |
| 87 | KERNEL_ADDITIONAL_CONFIG_SRC := /dev/null |
| 88 | endif |
| 89 | else |
| 90 | KERNEL_ADDITIONAL_CONFIG_SRC := /dev/null |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 91 | endif |
| 92 | |
dianlujitao | fb133a3 | 2019-09-12 17:37:45 +0800 | [diff] [blame] | 93 | ifeq ($(BOARD_KERNEL_IMAGE_NAME),) |
| 94 | $(error BOARD_KERNEL_IMAGE_NAME not defined.) |
| 95 | endif |
| 96 | TARGET_PREBUILT_INT_KERNEL := $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/$(BOARD_KERNEL_IMAGE_NAME) |
| 97 | |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 98 | ifeq "$(wildcard $(KERNEL_SRC) )" "" |
| 99 | ifneq ($(TARGET_PREBUILT_KERNEL),) |
| 100 | HAS_PREBUILT_KERNEL := true |
| 101 | NEEDS_KERNEL_COPY := true |
| 102 | else |
| 103 | $(foreach cf,$(PRODUCT_COPY_FILES), \ |
| 104 | $(eval _src := $(call word-colon,1,$(cf))) \ |
| 105 | $(eval _dest := $(call word-colon,2,$(cf))) \ |
| 106 | $(ifeq kernel,$(_dest), \ |
| 107 | $(eval HAS_PREBUILT_KERNEL := true))) |
| 108 | endif |
| 109 | |
| 110 | ifneq ($(HAS_PREBUILT_KERNEL),) |
| 111 | $(warning ***************************************************************) |
| 112 | $(warning * Using prebuilt kernel binary instead of source *) |
| 113 | $(warning * THIS IS DEPRECATED, AND WILL BE DISCONTINUED *) |
| 114 | $(warning * Please configure your device to download the kernel *) |
| 115 | $(warning * source repository to $(KERNEL_SRC)) |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 116 | $(warning * for more information *) |
| 117 | $(warning ***************************************************************) |
| 118 | FULL_KERNEL_BUILD := false |
| 119 | KERNEL_BIN := $(TARGET_PREBUILT_KERNEL) |
| 120 | else |
| 121 | $(warning ***************************************************************) |
| 122 | $(warning * *) |
| 123 | $(warning * No kernel source found, and no fallback prebuilt defined. *) |
| 124 | $(warning * Please make sure your device is properly configured to *) |
| 125 | $(warning * download the kernel repository to $(KERNEL_SRC)) |
| 126 | $(warning * and add the TARGET_KERNEL_CONFIG variable to BoardConfig.mk *) |
| 127 | $(warning * *) |
| 128 | $(warning * As an alternative, define the TARGET_PREBUILT_KERNEL *) |
| 129 | $(warning * variable with the path to the prebuilt binary kernel image *) |
| 130 | $(warning * in your BoardConfig.mk file *) |
| 131 | $(warning * *) |
| 132 | $(warning ***************************************************************) |
| 133 | $(error "NO KERNEL") |
| 134 | endif |
| 135 | else |
| 136 | NEEDS_KERNEL_COPY := true |
| 137 | ifeq ($(TARGET_KERNEL_CONFIG),) |
| 138 | $(warning **********************************************************) |
| 139 | $(warning * Kernel source found, but no configuration was defined *) |
| 140 | $(warning * Please add the TARGET_KERNEL_CONFIG variable to your *) |
| 141 | $(warning * BoardConfig.mk file *) |
| 142 | $(warning **********************************************************) |
| 143 | # $(error "NO KERNEL CONFIG") |
| 144 | else |
| 145 | #$(info Kernel source found, building it) |
| 146 | FULL_KERNEL_BUILD := true |
| 147 | KERNEL_BIN := $(TARGET_PREBUILT_INT_KERNEL) |
| 148 | endif |
| 149 | endif |
| 150 | |
| 151 | ifeq ($(FULL_KERNEL_BUILD),true) |
| 152 | |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 153 | ifeq ($(NEED_KERNEL_MODULE_ROOT),true) |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 154 | KERNEL_MODULES_OUT := $(TARGET_ROOT_OUT) |
Rashed Abdel-Tawab | 539c2ae | 2019-09-10 08:44:55 -0700 | [diff] [blame] | 155 | KERNEL_DEPMOD_STAGING_DIR := $(KERNEL_BUILD_OUT_PREFIX)$(call intermediates-dir-for,PACKAGING,depmod_recovery) |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 156 | KERNEL_MODULE_MOUNTPOINT := |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 157 | else ifeq ($(NEED_KERNEL_MODULE_SYSTEM),true) |
| 158 | KERNEL_MODULES_OUT := $(TARGET_OUT) |
Rashed Abdel-Tawab | 539c2ae | 2019-09-10 08:44:55 -0700 | [diff] [blame] | 159 | KERNEL_DEPMOD_STAGING_DIR := $(KERNEL_BUILD_OUT_PREFIX)$(call intermediates-dir-for,PACKAGING,depmod_system) |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 160 | KERNEL_MODULE_MOUNTPOINT := system |
Vachounet | b3baf3e | 2020-02-04 14:24:30 +0100 | [diff] [blame^] | 161 | else ifeq ($(NEED_KERNEL_MODULE_VENDOR_OVERLAY),true) |
| 162 | KERNEL_MODULES_OUT := $(TARGET_OUT_PRODUCT)/vendor_overlay/29 |
| 163 | KERNEL_DEPMOD_STAGING_DIR := $(KERNEL_BUILD_OUT_PREFIX)$(call intermediates-dir-for,PACKAGING,depmod_product) |
| 164 | KERNEL_MODULE_MOUNTPOINT := product |
Rashed Abdel-Tawab | d164cac | 2019-06-13 12:08:09 +0200 | [diff] [blame] | 165 | else |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 166 | KERNEL_MODULES_OUT := $(TARGET_OUT_VENDOR) |
Rashed Abdel-Tawab | 539c2ae | 2019-09-10 08:44:55 -0700 | [diff] [blame] | 167 | KERNEL_DEPMOD_STAGING_DIR := $(KERNEL_BUILD_OUT_PREFIX)$(call intermediates-dir-for,PACKAGING,depmod_vendor) |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 168 | KERNEL_MODULE_MOUNTPOINT := vendor |
Rashed Abdel-Tawab | d164cac | 2019-06-13 12:08:09 +0200 | [diff] [blame] | 169 | endif |
Rashed Abdel-Tawab | 539c2ae | 2019-09-10 08:44:55 -0700 | [diff] [blame] | 170 | MODULES_INTERMEDIATES := $(KERNEL_BUILD_OUT_PREFIX)$(call intermediates-dir-for,PACKAGING,kernel_modules) |
Vachounet | 7d6628f | 2019-01-09 13:54:35 +0100 | [diff] [blame] | 171 | |
dianlujitao | fb133a3 | 2019-09-12 17:37:45 +0800 | [diff] [blame] | 172 | PATH_OVERRIDE := |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 173 | ifeq ($(TARGET_KERNEL_CLANG_COMPILE),true) |
| 174 | ifneq ($(TARGET_KERNEL_CLANG_VERSION),) |
Luca Stefani | 270b0bf | 2019-09-14 16:26:26 +0200 | [diff] [blame] | 175 | KERNEL_CLANG_VERSION := clang-$(TARGET_KERNEL_CLANG_VERSION) |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 176 | else |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 177 | # Use the default version of clang if TARGET_KERNEL_CLANG_VERSION hasn't been set by the device config |
| 178 | KERNEL_CLANG_VERSION := $(LLVM_PREBUILTS_VERSION) |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 179 | endif |
Marko Man | 0de88b1 | 2019-10-08 13:28:11 +0200 | [diff] [blame] | 180 | TARGET_KERNEL_CLANG_PATH ?= $(BUILD_TOP)/prebuilts/clang/host/$(HOST_OS)-x86/$(KERNEL_CLANG_VERSION) |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 181 | ifeq ($(KERNEL_ARCH),arm64) |
| 182 | KERNEL_CLANG_TRIPLE ?= CLANG_TRIPLE=aarch64-linux-gnu- |
| 183 | else ifeq ($(KERNEL_ARCH),arm) |
| 184 | KERNEL_CLANG_TRIPLE ?= CLANG_TRIPLE=arm-linux-gnu- |
| 185 | else ifeq ($(KERNEL_ARCH),x86) |
| 186 | KERNEL_CLANG_TRIPLE ?= CLANG_TRIPLE=x86_64-linux-gnu- |
| 187 | endif |
dianlujitao | fb133a3 | 2019-09-12 17:37:45 +0800 | [diff] [blame] | 188 | PATH_OVERRIDE += PATH=$(TARGET_KERNEL_CLANG_PATH)/bin:$$PATH LD_LIBRARY_PATH=$(TARGET_KERNEL_CLANG_PATH)/lib64:$$LD_LIBRARY_PATH |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 189 | ifeq ($(KERNEL_CC),) |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 190 | KERNEL_CC := CC="$(CCACHE_BIN) clang" |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 191 | endif |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 192 | endif |
| 193 | |
dianlujitao | fb133a3 | 2019-09-12 17:37:45 +0800 | [diff] [blame] | 194 | ifneq ($(TARGET_KERNEL_MODULES),) |
| 195 | $(error TARGET_KERNEL_MODULES is no longer supported!) |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 196 | endif |
| 197 | |
Marko Man | 0de88b1 | 2019-10-08 13:28:11 +0200 | [diff] [blame] | 198 | PATH_OVERRIDE += PATH=$(KERNEL_TOOLCHAIN_PATH_gcc)/bin:$$PATH |
| 199 | |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 200 | KERNEL_ADDITIONAL_CONFIG_OUT := $(KERNEL_OUT)/.additional_config |
| 201 | |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 202 | # Internal implementation of make-kernel-target |
| 203 | # $(1): output path (The value passed to O=) |
| 204 | # $(2): target to build (eg. defconfig, modules, dtbo.img) |
| 205 | define internal-make-kernel-target |
Marko Man | ef69244 | 2019-10-08 13:27:09 +0200 | [diff] [blame] | 206 | $(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 Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 207 | endef |
| 208 | |
| 209 | # Make a kernel target |
| 210 | # $(1): The kernel target to build (eg. defconfig, modules, modules_install) |
| 211 | define make-kernel-target |
| 212 | $(call internal-make-kernel-target,$(KERNEL_OUT),$(1)) |
| 213 | endef |
| 214 | |
| 215 | # Make a DTBO target |
| 216 | # $(1): The DTBO target to build (eg. dtbo.img, defconfig) |
| 217 | define make-dtbo-target |
| 218 | $(call internal-make-kernel-target,$(PRODUCT_OUT)/dtbo,$(1)) |
| 219 | endef |
| 220 | |
Rashed Abdel-Tawab | b1531b6 | 2019-09-27 23:37:14 -0400 | [diff] [blame] | 221 | # Make a DTB targets |
| 222 | # $(1): The DTB target to build (eg. dtbs, defconfig) |
| 223 | define make-dtb-target |
Rashed Abdel-Tawab | 8735c42 | 2019-10-13 16:59:57 -0700 | [diff] [blame] | 224 | $(call internal-make-kernel-target,$(DTBS_OUT),$(1)) |
Rashed Abdel-Tawab | b1531b6 | 2019-09-27 23:37:14 -0400 | [diff] [blame] | 225 | endef |
| 226 | |
dianlujitao | fb133a3 | 2019-09-12 17:37:45 +0800 | [diff] [blame] | 227 | $(KERNEL_OUT): |
| 228 | mkdir -p $(KERNEL_OUT) |
| 229 | |
| 230 | $(KERNEL_ADDITIONAL_CONFIG_OUT): $(KERNEL_OUT) |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 231 | $(hide) cmp -s $(KERNEL_ADDITIONAL_CONFIG_SRC) $@ || cp $(KERNEL_ADDITIONAL_CONFIG_SRC) $@; |
| 232 | |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 233 | $(KERNEL_CONFIG): $(KERNEL_DEFCONFIG_SRC) $(KERNEL_ADDITIONAL_CONFIG_OUT) |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 234 | @echo "Building Kernel Config" |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 235 | $(call make-kernel-target,VARIANT_DEFCONFIG=$(VARIANT_DEFCONFIG) SELINUX_DEFCONFIG=$(SELINUX_DEFCONFIG) $(KERNEL_DEFCONFIG)) |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 236 | $(hide) if [ ! -z "$(KERNEL_CONFIG_OVERRIDE)" ]; then \ |
| 237 | echo "Overriding kernel config with '$(KERNEL_CONFIG_OVERRIDE)'"; \ |
| 238 | echo $(KERNEL_CONFIG_OVERRIDE) >> $(KERNEL_OUT)/.config; \ |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 239 | $(call make-kernel-target,oldconfig); \ |
| 240 | fi |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 241 | # Create defconfig build artifact |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 242 | $(call make-kernel-target,savedefconfig) |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 243 | $(hide) if [ ! -z "$(KERNEL_ADDITIONAL_CONFIG)" ]; then \ |
| 244 | echo "Using additional config '$(KERNEL_ADDITIONAL_CONFIG)'"; \ |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 245 | $(KERNEL_SRC)/scripts/kconfig/merge_config.sh -m -O $(KERNEL_OUT) $(KERNEL_OUT)/.config $(KERNEL_SRC)/arch/$(KERNEL_ARCH)/configs/$(KERNEL_ADDITIONAL_CONFIG); \ |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 246 | $(call make-kernel-target,KCONFIG_ALLCONFIG=$(KERNEL_OUT)/.config alldefconfig); \ |
| 247 | fi |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 248 | |
Rashed Abdel-Tawab | 8dcf444 | 2019-09-30 11:11:50 -0400 | [diff] [blame] | 249 | $(TARGET_PREBUILT_INT_KERNEL): $(KERNEL_CONFIG) $(DEPMOD) |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 250 | @echo "Building Kernel" |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 251 | $(call make-kernel-target,$(BOARD_KERNEL_IMAGE_NAME)) |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 252 | $(hide) if grep -q '^CONFIG_OF=y' $(KERNEL_CONFIG); then \ |
| 253 | echo "Building DTBs"; \ |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 254 | $(call make-kernel-target,dtbs); \ |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 255 | fi |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 256 | $(hide) if grep -q '=m' $(KERNEL_CONFIG); then \ |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 257 | echo "Building Kernel Modules"; \ |
dianlujitao | fb133a3 | 2019-09-12 17:37:45 +0800 | [diff] [blame] | 258 | $(call make-kernel-target,modules) || exit "$$?"; \ |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 259 | echo "Installing Kernel Modules"; \ |
dianlujitao | fb133a3 | 2019-09-12 17:37:45 +0800 | [diff] [blame] | 260 | $(call make-kernel-target,INSTALL_MOD_PATH=$(MODULES_INTERMEDIATES) INSTALL_MOD_STRIP=1 modules_install); \ |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 261 | kernel_release=$$(cat $(KERNEL_RELEASE)) \ |
| 262 | modules=$$(find $(MODULES_INTERMEDIATES)/lib/modules/$$kernel_release -type f -name '*.ko'); \ |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 263 | ($(call build-image-kernel-modules,$$modules,$(KERNEL_MODULES_OUT),$(KERNEL_MODULE_MOUNTPOINT)/,$(KERNEL_DEPMOD_STAGING_DIR))); \ |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 264 | fi |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 265 | |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 266 | .PHONY: kerneltags |
| 267 | kerneltags: $(KERNEL_CONFIG) |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 268 | $(call make-kernel-target,tags) |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 269 | |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 270 | .PHONY: kernelsavedefconfig alldefconfig |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 271 | |
dianlujitao | fb133a3 | 2019-09-12 17:37:45 +0800 | [diff] [blame] | 272 | kernelsavedefconfig: $(KERNEL_OUT) |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 273 | $(call make-kernel-target,$(KERNEL_DEFCONFIG)) |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 274 | env KCONFIG_NOTIMESTAMP=true \ |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 275 | $(call make-kernel-target,savedefconfig) |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 276 | cp $(KERNEL_OUT)/defconfig $(KERNEL_DEFCONFIG_SRC) |
| 277 | |
dianlujitao | fb133a3 | 2019-09-12 17:37:45 +0800 | [diff] [blame] | 278 | alldefconfig: $(KERNEL_OUT) |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 279 | env KCONFIG_NOTIMESTAMP=true \ |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 280 | $(call make-kernel-target,alldefconfig) |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 281 | |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 282 | ifeq ($(TARGET_NEEDS_DTBOIMAGE),true) |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 283 | $(BOARD_PREBUILT_DTBOIMAGE): |
| 284 | echo -e ${CL_GRN}"Building DTBO.img"${CL_RST} |
| 285 | $(call make-dtbo-target,$(KERNEL_DEFCONFIG)) |
| 286 | $(call make-dtbo-target,dtbo.img) |
| 287 | endif # TARGET_NEEDS_DTBOIMAGE |
pulser | 5c9a4f3 | 2013-08-25 14:15:02 +0200 | [diff] [blame] | 288 | |
| 289 | endif # FULL_KERNEL_BUILD |
| 290 | |
| 291 | ## Install it |
| 292 | |
| 293 | ifeq ($(NEEDS_KERNEL_COPY),true) |
| 294 | file := $(INSTALLED_KERNEL_TARGET) |
| 295 | ALL_PREBUILT += $(file) |
| 296 | $(file) : $(KERNEL_BIN) | $(ACP) |
| 297 | $(transform-prebuilt-to-target) |
| 298 | |
| 299 | ALL_PREBUILT += $(INSTALLED_KERNEL_TARGET) |
| 300 | endif |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 301 | |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 302 | INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 303 | ALL_PREBUILT += $(INSTALLED_DTBOIMAGE_TARGET) |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 304 | |
| 305 | .PHONY: kernel |
dianlujitao | fb133a3 | 2019-09-12 17:37:45 +0800 | [diff] [blame] | 306 | kernel: $(INSTALLED_KERNEL_TARGET) |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 307 | |
Marko Man | 0b2160a | 2019-09-08 01:28:58 +0200 | [diff] [blame] | 308 | .PHONY: dtboimage |
| 309 | dtboimage: $(INSTALLED_DTBOIMAGE_TARGET) |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 310 | |
Rashed Abdel-Tawab | b1531b6 | 2019-09-27 23:37:14 -0400 | [diff] [blame] | 311 | ifeq ($(BOARD_INCLUDE_DTB_IN_BOOTIMG),true) |
Rashed Abdel-Tawab | 2ece42b | 2019-10-07 14:42:30 -0400 | [diff] [blame] | 312 | $(INSTALLED_DTBIMAGE_TARGET): |
Rashed Abdel-Tawab | b1531b6 | 2019-09-27 23:37:14 -0400 | [diff] [blame] | 313 | echo -e ${CL_GRN}"Building DTBs"${CL_RST} |
| 314 | $(call make-dtb-target,$(KERNEL_DEFCONFIG)) |
| 315 | $(call make-dtb-target,dtbs) |
Rashed Abdel-Tawab | 2ece42b | 2019-10-07 14:42:30 -0400 | [diff] [blame] | 316 | cat $(shell find $(DTBS_OUT)/arch/$(KERNEL_ARCH)/boot/dts/** -type f -name "*.dtb" | sort) > $@ |
Rashed Abdel-Tawab | b1531b6 | 2019-09-27 23:37:14 -0400 | [diff] [blame] | 317 | .PHONY: dtbimage |
| 318 | dtbimage: $(INSTALLED_DTBIMAGE_TARGET) |
| 319 | endif # BOARD_INCLUDE_DTB_IN_BOOTIMG |
| 320 | |
Marko Man | 3ba2cde | 2018-03-09 09:14:36 +0100 | [diff] [blame] | 321 | endif # TARGET_NO_KERNEL |