Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 1 | # Copyright (C) 2012 The CyanogenMod Project |
Bruno Martins | 3bd34be | 2022-04-08 19:37:17 +0100 | [diff] [blame] | 2 | # (C) 2017-2022 The LineageOS Project |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [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 | |
| 16 | |
| 17 | # Android makefile to build kernel as a part of Android Build |
| 18 | # |
| 19 | # Configuration |
| 20 | # ============= |
| 21 | # |
| 22 | # These config vars are usually set in BoardConfig.mk: |
| 23 | # |
Sebastiano Barezzi | 94b9680 | 2022-03-16 17:42:13 +0100 | [diff] [blame] | 24 | # TARGET_KERNEL_CONFIG = List of kernel defconfigs, first one being the base one, |
Bruno Martins | f70f8a3 | 2022-04-08 21:17:01 +0100 | [diff] [blame] | 25 | # while all the others are fragments that will be merged |
Sebastiano Barezzi | 94b9680 | 2022-03-16 17:42:13 +0100 | [diff] [blame] | 26 | # to main one in .config. |
Bruno Martins | f70f8a3 | 2022-04-08 21:17:01 +0100 | [diff] [blame] | 27 | # TARGET_KERNEL_RECOVERY_CONFIG = Same as above, but applicable to recovery kernel instead. |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 28 | # TARGET_KERNEL_VARIANT_CONFIG = Variant defconfig, optional |
| 29 | # TARGET_KERNEL_SELINUX_CONFIG = SELinux defconfig, optional |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 30 | # |
Alexander Koskovich | e8e46e6 | 2022-03-07 11:29:34 -0700 | [diff] [blame] | 31 | # TARGET_KERNEL_CLANG_COMPILE = Compile kernel with clang, defaults to true |
Joe Maples | da32895 | 2017-11-27 10:09:38 -0500 | [diff] [blame] | 32 | # |
| 33 | # TARGET_KERNEL_CLANG_VERSION = Clang prebuilts version, optional, defaults to clang-stable |
| 34 | # |
| 35 | # TARGET_KERNEL_CLANG_PATH = Clang prebuilts path, optional |
| 36 | # |
Dan Pasanen | edc1ceb | 2017-01-24 15:46:13 -0600 | [diff] [blame] | 37 | # BOARD_KERNEL_IMAGE_NAME = Built image name |
| 38 | # for ARM use: zImage |
| 39 | # for ARM64 use: Image.gz |
| 40 | # for uncompressed use: Image |
| 41 | # If using an appended DT, append '-dtb' |
| 42 | # to the end of the image name. |
| 43 | # For example, for ARM devices, |
| 44 | # use zImage-dtb instead of zImage. |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 45 | # |
Luca Stefani | 05ce3dc | 2020-08-03 11:58:00 +0200 | [diff] [blame] | 46 | # BOARD_DTBO_CFG = Path to a mkdtboimg.py config file |
| 47 | # |
Aayush Gupta | 1de3b30 | 2020-08-25 10:03:10 +0000 | [diff] [blame] | 48 | # BOARD_CUSTOM_DTBOIMG_MK = Path to a custom dtboimage makefile |
| 49 | # |
Joe Maples | da32895 | 2017-11-27 10:09:38 -0500 | [diff] [blame] | 50 | # KERNEL_CC = The C Compiler used. This is automatically set based |
| 51 | # on whether the clang version is set, optional. |
Luca Stefani | 83dee70 | 2020-04-03 18:58:16 +0200 | [diff] [blame] | 52 | # KERNEL_LD = The Linker used. This is automatically set based |
| 53 | # on whether the clang/gcc version is set, optional. |
Joe Maples | da32895 | 2017-11-27 10:09:38 -0500 | [diff] [blame] | 54 | # |
| 55 | # KERNEL_CLANG_TRIPLE = Target triple for clang (e.g. aarch64-linux-gnu-) |
| 56 | # defaults to arm-linux-gnu- for arm |
| 57 | # aarch64-linux-gnu- for arm64 |
| 58 | # x86_64-linux-gnu- for x86 |
| 59 | # |
Chirayu Desai | 3eed09a | 2021-12-03 22:39:46 +0530 | [diff] [blame] | 60 | # KERNEL_LTO = Optional, force LTO to none / thin / full |
| 61 | # |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 62 | # NEED_KERNEL_MODULE_ROOT = Optional, if true, install kernel |
Luca Stefani | a1ade7f | 2018-07-11 00:35:33 +0200 | [diff] [blame] | 63 | # modules in root instead of vendor |
| 64 | # NEED_KERNEL_MODULE_SYSTEM = Optional, if true, install kernel |
| 65 | # modules in system instead of vendor |
Luca Stefani | edc2e0c | 2020-08-01 17:24:29 +0200 | [diff] [blame] | 66 | # NEED_KERNEL_MODULE_VENDOR_OVERLAY = Optional, if true, install kernel |
| 67 | # modules in vendor_overlay instead of vendor |
Sebastiano Barezzi | c251f1b | 2021-02-09 00:31:49 +0100 | [diff] [blame] | 68 | # |
| 69 | # TARGET_FORCE_PREBUILT_KERNEL = Optional, use TARGET_PREBUILT_KERNEL even if |
| 70 | # kernel sources are present |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 71 | |
Dan Pasanen | 8ee5d89 | 2017-12-08 13:46:30 -0600 | [diff] [blame] | 72 | ifneq ($(TARGET_NO_KERNEL),true) |
LuK1337 | d034c3f | 2020-09-15 11:06:18 +0200 | [diff] [blame] | 73 | ifneq ($(TARGET_NO_KERNEL_OVERRIDE),true) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 74 | |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 75 | ## Externally influenced variables |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 76 | KERNEL_SRC := $(TARGET_KERNEL_SOURCE) |
| 77 | # kernel configuration - mandatory |
| 78 | KERNEL_DEFCONFIG := $(TARGET_KERNEL_CONFIG) |
marcost2 | 9b4cfe0 | 2021-07-06 12:55:59 -0300 | [diff] [blame] | 79 | RECOVERY_DEFCONFIG := $(TARGET_KERNEL_RECOVERY_CONFIG) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 80 | VARIANT_DEFCONFIG := $(TARGET_KERNEL_VARIANT_CONFIG) |
| 81 | SELINUX_DEFCONFIG := $(TARGET_KERNEL_SELINUX_CONFIG) |
| 82 | |
| 83 | ## Internal variables |
Rashed Abdel-Tawab | e523884 | 2019-10-15 00:56:52 -0400 | [diff] [blame] | 84 | DTC := $(HOST_OUT_EXECUTABLES)/dtc |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 85 | KERNEL_OUT := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ |
marcost2 | 9b4cfe0 | 2021-07-06 12:55:59 -0300 | [diff] [blame] | 86 | RECOVERY_KERNEL_OUT := $(TARGET_OUT_INTERMEDIATES)/RECOVERY_KERNEL_OBJ |
Luca Stefani | fe00ea9 | 2020-08-02 19:08:31 +0200 | [diff] [blame] | 87 | DTBO_OUT := $(TARGET_OUT_INTERMEDIATES)/DTBO_OBJ |
| 88 | DTB_OUT := $(TARGET_OUT_INTERMEDIATES)/DTB_OBJ |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 89 | KERNEL_CONFIG := $(KERNEL_OUT)/.config |
LuK1337 | 6047f5a | 2019-07-12 12:55:35 +0200 | [diff] [blame] | 90 | KERNEL_RELEASE := $(KERNEL_OUT)/include/config/kernel.release |
marcost2 | 9b4cfe0 | 2021-07-06 12:55:59 -0300 | [diff] [blame] | 91 | RECOVERY_KERNEL_CONFIG := $(RECOVERY_KERNEL_OUT)/.config |
| 92 | RECOVERY_KERNEL_RELEASE := $(RECOVERY_KERNEL_OUT)/include/config/kernel.release |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 93 | |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 94 | ifeq ($(KERNEL_ARCH),x86_64) |
| 95 | KERNEL_DEFCONFIG_ARCH := x86 |
| 96 | else |
| 97 | KERNEL_DEFCONFIG_ARCH := $(KERNEL_ARCH) |
| 98 | endif |
dianlujitao | f30ad9e | 2019-09-12 17:37:45 +0800 | [diff] [blame] | 99 | KERNEL_DEFCONFIG_DIR := $(KERNEL_SRC)/arch/$(KERNEL_DEFCONFIG_ARCH)/configs |
Sebastiano Barezzi | 94b9680 | 2022-03-16 17:42:13 +0100 | [diff] [blame] | 100 | ALL_KERNEL_DEFCONFIG_SRCS := $(foreach config,$(KERNEL_DEFCONFIG),$(KERNEL_DEFCONFIG_DIR)/$(config)) |
| 101 | ALL_RECOVERY_KERNEL_DEFCONFIG_SRCS := $(foreach config,$(RECOVERY_DEFCONFIG),$(KERNEL_DEFCONFIG_DIR)/$(config)) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 102 | |
Sebastiano Barezzi | 94b9680 | 2022-03-16 17:42:13 +0100 | [diff] [blame] | 103 | BASE_KERNEL_DEFCONFIG := $(word 1, $(KERNEL_DEFCONFIG)) |
| 104 | BASE_KERNEL_DEFCONFIG_SRC := $(word 1, $(ALL_KERNEL_DEFCONFIG_SRCS)) |
| 105 | BASE_RECOVERY_KERNEL_DEFCONFIG := $(word 1, $(RECOVERY_DEFCONFIG)) |
| 106 | BASE_RECOVERY_KERNEL_DEFCONFIG_SRC := $(word 1, $(ALL_RECOVERY_KERNEL_DEFCONFIG_SRCS)) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 107 | |
Aayush Gupta | 3ebfa5e | 2020-10-27 17:59:21 +0530 | [diff] [blame] | 108 | ifeq ($(TARGET_PREBUILT_KERNEL),) |
| 109 | ifeq ($(BOARD_KERNEL_IMAGE_NAME),) |
| 110 | $(error BOARD_KERNEL_IMAGE_NAME not defined.) |
| 111 | endif |
dianlujitao | f30ad9e | 2019-09-12 17:37:45 +0800 | [diff] [blame] | 112 | endif |
| 113 | TARGET_PREBUILT_INT_KERNEL := $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/$(BOARD_KERNEL_IMAGE_NAME) |
| 114 | |
marcost2 | 9b4cfe0 | 2021-07-06 12:55:59 -0300 | [diff] [blame] | 115 | TARGET_PREBUILT_INT_RECOVERY_KERNEL := $(RECOVERY_KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/$(BOARD_KERNEL_IMAGE_NAME) |
| 116 | |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 117 | ifeq "$(wildcard $(KERNEL_SRC) )" "" |
| 118 | ifneq ($(TARGET_PREBUILT_KERNEL),) |
| 119 | HAS_PREBUILT_KERNEL := true |
| 120 | NEEDS_KERNEL_COPY := true |
| 121 | else |
| 122 | $(foreach cf,$(PRODUCT_COPY_FILES), \ |
| 123 | $(eval _src := $(call word-colon,1,$(cf))) \ |
| 124 | $(eval _dest := $(call word-colon,2,$(cf))) \ |
| 125 | $(ifeq kernel,$(_dest), \ |
| 126 | $(eval HAS_PREBUILT_KERNEL := true))) |
| 127 | endif |
| 128 | |
| 129 | ifneq ($(HAS_PREBUILT_KERNEL),) |
| 130 | $(warning ***************************************************************) |
| 131 | $(warning * Using prebuilt kernel binary instead of source *) |
Nolen Johnson | c0b837d | 2020-04-17 13:13:20 -0400 | [diff] [blame] | 132 | $(warning * THIS IS DEPRECATED, AND IS NOT ADVISED. *) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 133 | $(warning * Please configure your device to download the kernel *) |
| 134 | $(warning * source repository to $(KERNEL_SRC)) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 135 | $(warning * for more information *) |
| 136 | $(warning ***************************************************************) |
| 137 | FULL_KERNEL_BUILD := false |
| 138 | KERNEL_BIN := $(TARGET_PREBUILT_KERNEL) |
| 139 | else |
| 140 | $(warning ***************************************************************) |
| 141 | $(warning * *) |
| 142 | $(warning * No kernel source found, and no fallback prebuilt defined. *) |
| 143 | $(warning * Please make sure your device is properly configured to *) |
| 144 | $(warning * download the kernel repository to $(KERNEL_SRC)) |
| 145 | $(warning * and add the TARGET_KERNEL_CONFIG variable to BoardConfig.mk *) |
| 146 | $(warning * *) |
| 147 | $(warning * As an alternative, define the TARGET_PREBUILT_KERNEL *) |
| 148 | $(warning * variable with the path to the prebuilt binary kernel image *) |
| 149 | $(warning * in your BoardConfig.mk file *) |
| 150 | $(warning * *) |
| 151 | $(warning ***************************************************************) |
| 152 | $(error "NO KERNEL") |
| 153 | endif |
| 154 | else |
| 155 | NEEDS_KERNEL_COPY := true |
| 156 | ifeq ($(TARGET_KERNEL_CONFIG),) |
| 157 | $(warning **********************************************************) |
| 158 | $(warning * Kernel source found, but no configuration was defined *) |
| 159 | $(warning * Please add the TARGET_KERNEL_CONFIG variable to your *) |
| 160 | $(warning * BoardConfig.mk file *) |
| 161 | $(warning **********************************************************) |
Luca Stefani | fb58f78 | 2020-08-03 11:32:19 +0200 | [diff] [blame] | 162 | $(error "NO KERNEL CONFIG") |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 163 | else |
Tim Schumacher | 6303cd7 | 2021-06-27 11:27:27 +0200 | [diff] [blame] | 164 | ifneq ($(TARGET_FORCE_PREBUILT_KERNEL),) |
| 165 | ifneq ($(filter RELEASE NIGHTLY SNAPSHOT EXPERIMENTAL,$(LINEAGE_BUILDTYPE)),) |
| 166 | $(error "PREBUILT KERNEL IS NOT ALLOWED ON OFFICIAL BUILDS!") |
| 167 | else |
Sebastiano Barezzi | c251f1b | 2021-02-09 00:31:49 +0100 | [diff] [blame] | 168 | $(warning **********************************************************) |
| 169 | $(warning * Kernel source found and configuration was defined, *) |
| 170 | $(warning * but prebuilt kernel is being forced. *) |
| 171 | $(warning * While this is likely intentional, *) |
| 172 | $(warning * it is NOT SUPPORTED WHATSOEVER. *) |
| 173 | $(warning * Generated kernel headers may not align with *) |
| 174 | $(warning * the ABI of kernel you're including. *) |
| 175 | $(warning * Please unset TARGET_FORCE_PREBUILT_KERNEL *) |
| 176 | $(warning * to build the kernel from source. *) |
| 177 | $(warning **********************************************************) |
| 178 | FULL_KERNEL_BUILD := false |
| 179 | KERNEL_BIN := $(TARGET_PREBUILT_KERNEL) |
Sebastiano Barezzi | c251f1b | 2021-02-09 00:31:49 +0100 | [diff] [blame] | 180 | endif |
Tim Schumacher | 6303cd7 | 2021-06-27 11:27:27 +0200 | [diff] [blame] | 181 | else |
| 182 | FULL_KERNEL_BUILD := true |
| 183 | KERNEL_BIN := $(TARGET_PREBUILT_INT_KERNEL) |
Sebastiano Barezzi | c251f1b | 2021-02-09 00:31:49 +0100 | [diff] [blame] | 184 | endif |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 185 | endif |
| 186 | endif |
| 187 | |
marcost2 | 9b4cfe0 | 2021-07-06 12:55:59 -0300 | [diff] [blame] | 188 | ifneq ($(TARGET_KERNEL_RECOVERY_CONFIG),) |
| 189 | ifeq "$(wildcard $(KERNEL_SRC) )" "" |
| 190 | ifeq ($(TARGET_PREBUILT_RECOVERY_KERNEL),) |
| 191 | $(warning ***************************************************************) |
| 192 | $(warning * *) |
| 193 | $(warning * No recovery kernel source found, and no fallback prebuilt *) |
| 194 | $(warning * defined. Please make sure your device is properly *) |
| 195 | $(warning * configured to download the kernel repository to $(KERNEL_SRC)) |
| 196 | $(warning * or remove TARGET_KERNEL_RECOVERY_CONFIG from BoardConfig.mk *) |
| 197 | $(warning * *) |
| 198 | $(warning * Or, define the TARGET_PREBUILT_RECOVERY_KERNEL *) |
| 199 | $(warning * variable with the path to the prebuilt recovery kernel image*) |
| 200 | $(warning * in your BoardConfig.mk file *) |
| 201 | $(warning * *) |
| 202 | $(warning ***************************************************************) |
| 203 | $(error "NO RECOVERY KERNEL SOURCE") |
| 204 | endif |
| 205 | endif |
| 206 | ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),) |
| 207 | $(warning ********************************************************) |
| 208 | $(warning * TARGET_KERNEL_RECOVERY_CONFIG set but device uses *) |
| 209 | $(warning * RECOVERY_AS_BOOT, which uses boot kernel as recovery *) |
| 210 | $(warning * kernel, as such it's not possible to use different *) |
| 211 | $(warning * configs *) |
| 212 | $(warning ********************************************************) |
| 213 | $(error "INVALID CONFIGURATION") |
| 214 | else |
| 215 | FULL_RECOVERY_KERNEL_BUILD := true |
| 216 | RECOVERY_KERNEL_COPY := true |
| 217 | RECOVERY_BIN := $(TARGET_PREBUILT_INT_RECOVERY_KERNEL) |
| 218 | endif |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 219 | else |
marcost2 | 9b4cfe0 | 2021-07-06 12:55:59 -0300 | [diff] [blame] | 220 | ifneq ($(TARGET_PREBUILT_RECOVERY_KERNEL),) |
| 221 | RECOVERY_BIN := $(TARGET_PREBUILT_RECOVERY_KERNEL) |
| 222 | RECOVERY_KERNEL_COPY := true |
| 223 | endif |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 224 | endif |
| 225 | |
marcost2 | 9b4cfe0 | 2021-07-06 12:55:59 -0300 | [diff] [blame] | 226 | ifeq ($(or $(FULL_RECOVERY_KERNEL_BUILD), $(FULL_KERNEL_BUILD)),true) |
Rashed Abdel-Tawab | e523884 | 2019-10-15 00:56:52 -0400 | [diff] [blame] | 227 | # Add host bin out dir to path |
| 228 | PATH_OVERRIDE := PATH=$(KERNEL_BUILD_OUT_PREFIX)$(HOST_OUT_EXECUTABLES):$$PATH |
Alexander Koskovich | e8e46e6 | 2022-03-07 11:29:34 -0700 | [diff] [blame] | 229 | ifneq ($(TARGET_KERNEL_CLANG_COMPILE),false) |
Joe Maples | da32895 | 2017-11-27 10:09:38 -0500 | [diff] [blame] | 230 | ifneq ($(TARGET_KERNEL_CLANG_VERSION),) |
Luca Stefani | 736f1be | 2019-09-14 16:26:26 +0200 | [diff] [blame] | 231 | KERNEL_CLANG_VERSION := clang-$(TARGET_KERNEL_CLANG_VERSION) |
Joe Maples | da32895 | 2017-11-27 10:09:38 -0500 | [diff] [blame] | 232 | else |
Nathan Chancellor | ca40331 | 2018-04-11 16:23:19 -0700 | [diff] [blame] | 233 | # Use the default version of clang if TARGET_KERNEL_CLANG_VERSION hasn't been set by the device config |
| 234 | KERNEL_CLANG_VERSION := $(LLVM_PREBUILTS_VERSION) |
Joe Maples | da32895 | 2017-11-27 10:09:38 -0500 | [diff] [blame] | 235 | endif |
Bruno Martins | 63d13c3 | 2020-09-24 11:51:33 +0100 | [diff] [blame] | 236 | TARGET_KERNEL_CLANG_PATH ?= $(BUILD_TOP)/prebuilts/clang/host/$(HOST_PREBUILT_TAG)/$(KERNEL_CLANG_VERSION) |
Joe Maples | da32895 | 2017-11-27 10:09:38 -0500 | [diff] [blame] | 237 | ifeq ($(KERNEL_ARCH),arm64) |
| 238 | KERNEL_CLANG_TRIPLE ?= CLANG_TRIPLE=aarch64-linux-gnu- |
| 239 | else ifeq ($(KERNEL_ARCH),arm) |
| 240 | KERNEL_CLANG_TRIPLE ?= CLANG_TRIPLE=arm-linux-gnu- |
| 241 | else ifeq ($(KERNEL_ARCH),x86) |
| 242 | KERNEL_CLANG_TRIPLE ?= CLANG_TRIPLE=x86_64-linux-gnu- |
| 243 | endif |
dianlujitao | f30ad9e | 2019-09-12 17:37:45 +0800 | [diff] [blame] | 244 | PATH_OVERRIDE += PATH=$(TARGET_KERNEL_CLANG_PATH)/bin:$$PATH LD_LIBRARY_PATH=$(TARGET_KERNEL_CLANG_PATH)/lib64:$$LD_LIBRARY_PATH |
Dan Pasanen | f65a6df | 2018-02-18 22:13:05 -0600 | [diff] [blame] | 245 | ifeq ($(KERNEL_CC),) |
Nathan Chancellor | 4d0d438 | 2018-10-21 19:07:47 -0700 | [diff] [blame] | 246 | KERNEL_CC := CC="$(CCACHE_BIN) clang" |
Dan Pasanen | f65a6df | 2018-02-18 22:13:05 -0600 | [diff] [blame] | 247 | endif |
Luca Stefani | 83dee70 | 2020-04-03 18:58:16 +0200 | [diff] [blame] | 248 | ifeq ($(KERNEL_LD),) |
| 249 | KERNEL_LD := |
| 250 | endif |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 251 | endif |
| 252 | |
dianlujitao | f30ad9e | 2019-09-12 17:37:45 +0800 | [diff] [blame] | 253 | ifneq ($(TARGET_KERNEL_MODULES),) |
| 254 | $(error TARGET_KERNEL_MODULES is no longer supported!) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 255 | endif |
| 256 | |
Alessandro Astone | 8fb7cda | 2021-12-11 01:49:53 +0100 | [diff] [blame] | 257 | PATH_OVERRIDE += PATH=$(KERNEL_TOOLCHAIN_PATH_gcc):$$PATH |
Rashed Abdel-Tawab | c648519 | 2019-09-10 08:38:34 -0700 | [diff] [blame] | 258 | |
Rashed Abdel-Tawab | dfc3d18 | 2019-09-06 10:44:50 -0700 | [diff] [blame] | 259 | # System tools are no longer allowed on 10+ |
| 260 | PATH_OVERRIDE += $(TOOLS_PATH_OVERRIDE) |
| 261 | |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 262 | # Internal implementation of make-kernel-target |
| 263 | # $(1): output path (The value passed to O=) |
| 264 | # $(2): target to build (eg. defconfig, modules, dtbo.img) |
| 265 | define internal-make-kernel-target |
Luca Stefani | 83dee70 | 2020-04-03 18:58:16 +0200 | [diff] [blame] | 266 | $(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) $(KERNEL_LD) $(2) |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 267 | endef |
| 268 | |
marcost2 | 9b4cfe0 | 2021-07-06 12:55:59 -0300 | [diff] [blame] | 269 | # Generate kernel .config from a given defconfig |
| 270 | # $(1): Output path (The value passed to O=) |
| 271 | # $(2): The defconfig to process (just the filename, no need for full path to file) |
| 272 | define make-kernel-config |
| 273 | $(call internal-make-kernel-target,$(1),VARIANT_DEFCONFIG=$(VARIANT_DEFCONFIG) SELINUX_DEFCONFIG=$(SELINUX_DEFCONFIG) $(2)) |
Chirayu Desai | 3eed09a | 2021-12-03 22:39:46 +0530 | [diff] [blame] | 274 | $(hide) if [ "$(KERNEL_LTO)" = "none" ]; then \ |
| 275 | $(KERNEL_SRC)/scripts/config --file $(1)/.config \ |
| 276 | -d LTO_CLANG \ |
| 277 | -e LTO_NONE \ |
| 278 | -d LTO_CLANG_THIN \ |
| 279 | -d LTO_CLANG_FULL \ |
| 280 | -d THINLTO; \ |
| 281 | $(call make-kernel-target,olddefconfig); \ |
| 282 | elif [ "$(KERNEL_LTO)" = "thin" ]; then \ |
| 283 | $(KERNEL_SRC)/scripts/config --file $(1)/.config \ |
| 284 | -e LTO_CLANG \ |
| 285 | -d LTO_NONE \ |
| 286 | -e LTO_CLANG_THIN \ |
| 287 | -d LTO_CLANG_FULL \ |
| 288 | -e THINLTO; \ |
| 289 | $(call make-kernel-target,olddefconfig); \ |
| 290 | elif [ "$(KERNEL_LTO)" = "full" ]; then \ |
| 291 | $(KERNEL_SRC)/scripts/config --file $(1)/.config \ |
| 292 | -e LTO_CLANG \ |
| 293 | -d LTO_NONE \ |
| 294 | -d LTO_CLANG_THIN \ |
| 295 | -e LTO_CLANG_FULL \ |
| 296 | -d THINLTO; \ |
| 297 | $(call make-kernel-target,olddefconfig); \ |
| 298 | fi |
marcost2 | 9b4cfe0 | 2021-07-06 12:55:59 -0300 | [diff] [blame] | 299 | $(hide) if [ ! -z "$(KERNEL_CONFIG_OVERRIDE)" ]; then \ |
| 300 | echo "Overriding kernel config with '$(KERNEL_CONFIG_OVERRIDE)'"; \ |
| 301 | echo $(KERNEL_CONFIG_OVERRIDE) >> $(1)/.config; \ |
| 302 | $(call make-kernel-target,oldconfig); \ |
| 303 | fi |
| 304 | # Create defconfig build artifact |
| 305 | $(call internal-make-kernel-target,$(1),savedefconfig) |
marcost2 | 9b4cfe0 | 2021-07-06 12:55:59 -0300 | [diff] [blame] | 306 | endef |
| 307 | |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 308 | # Make a kernel target |
| 309 | # $(1): The kernel target to build (eg. defconfig, modules, modules_install) |
| 310 | define make-kernel-target |
| 311 | $(call internal-make-kernel-target,$(KERNEL_OUT),$(1)) |
| 312 | endef |
| 313 | |
marcost2 | 9b4cfe0 | 2021-07-06 12:55:59 -0300 | [diff] [blame] | 314 | # Make a recovery kernel target |
| 315 | # $(1): The kernel target to build (eg. defconfig, modules, modules_install) |
| 316 | define make-recovery-kernel-target |
| 317 | $(call internal-make-kernel-target,$(RECOVERY_KERNEL_OUT),$(1)) |
| 318 | endef |
| 319 | |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 320 | # Make a DTBO target |
| 321 | # $(1): The DTBO target to build (eg. dtbo.img, defconfig) |
| 322 | define make-dtbo-target |
Luca Stefani | fe00ea9 | 2020-08-02 19:08:31 +0200 | [diff] [blame] | 323 | $(call internal-make-kernel-target,$(DTBO_OUT),$(1)) |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 324 | endef |
| 325 | |
Rashed Abdel-Tawab | 2c247d8 | 2019-09-27 23:37:14 -0400 | [diff] [blame] | 326 | # Make a DTB targets |
| 327 | # $(1): The DTB target to build (eg. dtbs, defconfig) |
| 328 | define make-dtb-target |
Luca Stefani | fe00ea9 | 2020-08-02 19:08:31 +0200 | [diff] [blame] | 329 | $(call internal-make-kernel-target,$(DTB_OUT),$(1)) |
Rashed Abdel-Tawab | 2c247d8 | 2019-09-27 23:37:14 -0400 | [diff] [blame] | 330 | endef |
| 331 | |
Alessandro Astone | 1ab6313 | 2020-09-14 21:14:47 +0200 | [diff] [blame] | 332 | # $(1): modules list |
| 333 | # $(2): output dir |
| 334 | # $(3): mount point |
| 335 | # $(4): staging dir |
Alessandro Astone | 8d6e3d6 | 2021-01-08 17:43:27 +0100 | [diff] [blame] | 336 | # $(5): module load list |
Alessandro Astone | 1ab6313 | 2020-09-14 21:14:47 +0200 | [diff] [blame] | 337 | # Depmod requires a well-formed kernel version so 0.0 is used as a placeholder. |
| 338 | define build-image-kernel-modules-lineage |
Alessandro Astone | 1ab6313 | 2020-09-14 21:14:47 +0200 | [diff] [blame] | 339 | mkdir -p $(2)/lib/modules |
| 340 | cp $(1) $(2)/lib/modules/ |
| 341 | rm -rf $(4) |
| 342 | mkdir -p $(4)/lib/modules/0.0/$(3)lib/modules |
| 343 | cp $(1) $(4)/lib/modules/0.0/$(3)lib/modules |
| 344 | $(DEPMOD) -b $(4) 0.0 |
| 345 | sed -e 's/\(.*modules.*\):/\/\1:/g' -e 's/ \([^ ]*modules[^ ]*\)/ \/\1/g' $(4)/lib/modules/0.0/modules.dep > $(2)/lib/modules/modules.dep |
Alessandro Astone | 8d6e3d6 | 2021-01-08 17:43:27 +0100 | [diff] [blame] | 346 | cp $(4)/lib/modules/0.0/modules.softdep $(2)/lib/modules |
Alessandro Astone | 1ab6313 | 2020-09-14 21:14:47 +0200 | [diff] [blame] | 347 | cp $(4)/lib/modules/0.0/modules.alias $(2)/lib/modules |
Alessandro Astone | 8d6e3d6 | 2021-01-08 17:43:27 +0100 | [diff] [blame] | 348 | rm -f $(2)/lib/modules/modules.load |
| 349 | for MODULE in $(5); do \ |
| 350 | basename $$MODULE >> $(2)/lib/modules/modules.load; \ |
| 351 | done |
Alessandro Astone | 1ab6313 | 2020-09-14 21:14:47 +0200 | [diff] [blame] | 352 | endef |
| 353 | |
marcost2 | 9b4cfe0 | 2021-07-06 12:55:59 -0300 | [diff] [blame] | 354 | endif # FULL_RECOVERY_KERNEL_BUILD or FULL_KERNEL_BUILD |
| 355 | |
| 356 | ifeq ($(FULL_KERNEL_BUILD),true) |
| 357 | |
| 358 | ifeq ($(NEED_KERNEL_MODULE_ROOT),true) |
| 359 | KERNEL_MODULES_OUT := $(TARGET_ROOT_OUT) |
| 360 | KERNEL_DEPMOD_STAGING_DIR := $(KERNEL_BUILD_OUT_PREFIX)$(call intermediates-dir-for,PACKAGING,depmod_recovery) |
| 361 | KERNEL_MODULE_MOUNTPOINT := |
| 362 | else ifeq ($(NEED_KERNEL_MODULE_SYSTEM),true) |
| 363 | KERNEL_MODULES_OUT := $(TARGET_OUT) |
| 364 | KERNEL_DEPMOD_STAGING_DIR := $(KERNEL_BUILD_OUT_PREFIX)$(call intermediates-dir-for,PACKAGING,depmod_system) |
| 365 | KERNEL_MODULE_MOUNTPOINT := system |
| 366 | $(INSTALLED_SYSTEMIMAGE_TARGET): $(TARGET_PREBUILT_INT_KERNEL) |
| 367 | else ifeq ($(NEED_KERNEL_MODULE_VENDOR_OVERLAY),true) |
| 368 | KERNEL_MODULES_OUT := $(TARGET_OUT_PRODUCT)/vendor_overlay/$(PRODUCT_TARGET_VNDK_VERSION) |
| 369 | KERNEL_DEPMOD_STAGING_DIR := $(KERNEL_BUILD_OUT_PREFIX)$(call intermediates-dir-for,PACKAGING,depmod_product) |
| 370 | KERNEL_MODULE_MOUNTPOINT := vendor |
| 371 | $(INSTALLED_PRODUCTIMAGE_TARGET): $(TARGET_PREBUILT_INT_KERNEL) |
Alexander Koskovich | 20ca83c | 2022-01-22 22:26:50 -0700 | [diff] [blame] | 372 | else ifeq ($(BOARD_USES_VENDOR_DLKMIMAGE),true) |
| 373 | KERNEL_MODULES_OUT := $(TARGET_OUT_VENDOR_DLKM) |
| 374 | KERNEL_DEPMOD_STAGING_DIR := $(KERNEL_BUILD_OUT_PREFIX)$(call intermediates-dir-for,PACKAGING,depmod_vendor) |
| 375 | KERNEL_MODULE_MOUNTPOINT := vendor_dlkm |
| 376 | $(INSTALLED_VENDOR_DLKMIMAGE_TARGET): $(TARGET_PREBUILT_INT_KERNEL) |
marcost2 | 9b4cfe0 | 2021-07-06 12:55:59 -0300 | [diff] [blame] | 377 | else |
| 378 | KERNEL_MODULES_OUT := $(TARGET_OUT_VENDOR) |
| 379 | KERNEL_DEPMOD_STAGING_DIR := $(KERNEL_BUILD_OUT_PREFIX)$(call intermediates-dir-for,PACKAGING,depmod_vendor) |
| 380 | KERNEL_MODULE_MOUNTPOINT := vendor |
| 381 | $(INSTALLED_VENDORIMAGE_TARGET): $(TARGET_PREBUILT_INT_KERNEL) |
| 382 | endif |
| 383 | MODULES_INTERMEDIATES := $(KERNEL_BUILD_OUT_PREFIX)$(call intermediates-dir-for,PACKAGING,kernel_modules) |
| 384 | |
| 385 | KERNEL_VENDOR_RAMDISK_DEPMOD_STAGING_DIR := $(KERNEL_BUILD_OUT_PREFIX)$(call intermediates-dir-for,PACKAGING,depmod_vendor_ramdisk) |
| 386 | $(INTERNAL_VENDOR_RAMDISK_TARGET): $(TARGET_PREBUILT_INT_KERNEL) |
| 387 | |
Luca Stefani | e30626d | 2020-09-03 20:56:29 +0200 | [diff] [blame] | 388 | $(KERNEL_OUT): |
dianlujitao | f30ad9e | 2019-09-12 17:37:45 +0800 | [diff] [blame] | 389 | mkdir -p $(KERNEL_OUT) |
Luca Stefani | e30626d | 2020-09-03 20:56:29 +0200 | [diff] [blame] | 390 | |
Bruno Martins | 3bd34be | 2022-04-08 19:37:17 +0100 | [diff] [blame] | 391 | $(KERNEL_CONFIG): $(KERNEL_OUT) $(ALL_KERNEL_DEFCONFIG_SRCS) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 392 | @echo "Building Kernel Config" |
marcost2 | 9b4cfe0 | 2021-07-06 12:55:59 -0300 | [diff] [blame] | 393 | $(call make-kernel-config,$(KERNEL_OUT),$(KERNEL_DEFCONFIG)) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 394 | |
Rashed Abdel-Tawab | e523884 | 2019-10-15 00:56:52 -0400 | [diff] [blame] | 395 | $(TARGET_PREBUILT_INT_KERNEL): $(KERNEL_CONFIG) $(DEPMOD) $(DTC) |
| 396 | @echo "Building Kernel Image ($(BOARD_KERNEL_IMAGE_NAME))" |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 397 | $(call make-kernel-target,$(BOARD_KERNEL_IMAGE_NAME)) |
Tom Marshall | f15c371 | 2017-11-10 01:00:18 +0100 | [diff] [blame] | 398 | $(hide) if grep -q '^CONFIG_OF=y' $(KERNEL_CONFIG); then \ |
| 399 | echo "Building DTBs"; \ |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 400 | $(call make-kernel-target,dtbs); \ |
Tom Marshall | f15c371 | 2017-11-10 01:00:18 +0100 | [diff] [blame] | 401 | fi |
Ethan Chen | 0724f78 | 2019-02-09 21:05:01 -0800 | [diff] [blame] | 402 | $(hide) if grep -q '=m' $(KERNEL_CONFIG); then \ |
Tom Marshall | f15c371 | 2017-11-10 01:00:18 +0100 | [diff] [blame] | 403 | echo "Building Kernel Modules"; \ |
dianlujitao | f30ad9e | 2019-09-12 17:37:45 +0800 | [diff] [blame] | 404 | $(call make-kernel-target,modules) || exit "$$?"; \ |
Tom Marshall | f15c371 | 2017-11-10 01:00:18 +0100 | [diff] [blame] | 405 | echo "Installing Kernel Modules"; \ |
dianlujitao | f30ad9e | 2019-09-12 17:37:45 +0800 | [diff] [blame] | 406 | $(call make-kernel-target,INSTALL_MOD_PATH=$(MODULES_INTERMEDIATES) INSTALL_MOD_STRIP=1 modules_install); \ |
LuK1337 | 6047f5a | 2019-07-12 12:55:35 +0200 | [diff] [blame] | 407 | kernel_release=$$(cat $(KERNEL_RELEASE)) \ |
Luca Stefani | 4b7a0a0 | 2020-08-01 21:20:23 +0200 | [diff] [blame] | 408 | kernel_modules_dir=$(MODULES_INTERMEDIATES)/lib/modules/$$kernel_release \ |
| 409 | $(foreach s, $(TARGET_MODULE_ALIASES),\ |
| 410 | $(eval p := $(subst :,$(space),$(s))) \ |
| 411 | ; mv $$(find $$kernel_modules_dir -name $(word 1,$(p))) $$kernel_modules_dir/$(word 2,$(p))); \ |
| 412 | modules=$$(find $$kernel_modules_dir -type f -name '*.ko'); \ |
Alessandro Astone | 8d6e3d6 | 2021-01-08 17:43:27 +0100 | [diff] [blame] | 413 | ($(call build-image-kernel-modules-lineage,$$modules,$(KERNEL_MODULES_OUT),$(KERNEL_MODULE_MOUNTPOINT)/,$(KERNEL_DEPMOD_STAGING_DIR),$(BOARD_VENDOR_KERNEL_MODULES_LOAD))); \ |
| 414 | $(if $(BOOT_KERNEL_MODULES),\ |
| 415 | vendor_boot_modules=$$(for m in $(BOOT_KERNEL_MODULES); do \ |
| 416 | p=$$(find $$kernel_modules_dir -type f -name $$m); \ |
| 417 | if [ -n "$$p" ]; then echo $$p; else echo "ERROR: $$m from BOOT_KERNEL_MODULES was not found" 1>&2 && exit 1; fi; \ |
| 418 | done); \ |
| 419 | [ $$? -ne 0 ] && exit 1; \ |
| 420 | ($(call build-image-kernel-modules-lineage,$$vendor_boot_modules,$(TARGET_VENDOR_RAMDISK_OUT),/,$(KERNEL_VENDOR_RAMDISK_DEPMOD_STAGING_DIR),$(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD))); \ |
| 421 | ) \ |
Tom Marshall | f15c371 | 2017-11-10 01:00:18 +0100 | [diff] [blame] | 422 | fi |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 423 | |
Tom Marshall | 6b83d83 | 2017-11-09 21:02:33 +0100 | [diff] [blame] | 424 | .PHONY: kerneltags |
| 425 | kerneltags: $(KERNEL_CONFIG) |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 426 | $(call make-kernel-target,tags) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 427 | |
Michael Bestas | b4c4aba | 2018-10-06 22:12:10 +0300 | [diff] [blame] | 428 | .PHONY: kernelsavedefconfig alldefconfig |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 429 | |
Luca Stefani | e30626d | 2020-09-03 20:56:29 +0200 | [diff] [blame] | 430 | kernelsavedefconfig: $(KERNEL_OUT) |
Sebastiano Barezzi | 94b9680 | 2022-03-16 17:42:13 +0100 | [diff] [blame] | 431 | $(call make-kernel-config,$(KERNEL_OUT),$(BASE_KERNEL_DEFCONFIG)) |
| 432 | cp $(KERNEL_OUT)/defconfig $(BASE_KERNEL_DEFCONFIG_SRC) |
Michael Bestas | 296008c | 2017-07-12 20:56:35 +0300 | [diff] [blame] | 433 | |
Luca Stefani | e30626d | 2020-09-03 20:56:29 +0200 | [diff] [blame] | 434 | alldefconfig: $(KERNEL_OUT) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 435 | env KCONFIG_NOTIMESTAMP=true \ |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 436 | $(call make-kernel-target,alldefconfig) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 437 | |
Luca Stefani | fe00ea9 | 2020-08-02 19:08:31 +0200 | [diff] [blame] | 438 | ifeq (true,$(filter true, $(TARGET_NEEDS_DTBOIMAGE) $(BOARD_KERNEL_SEPARATED_DTBO))) |
Aayush Gupta | 1de3b30 | 2020-08-25 10:03:10 +0000 | [diff] [blame] | 439 | ifneq ($(BOARD_CUSTOM_DTBOIMG_MK),) |
| 440 | include $(BOARD_CUSTOM_DTBOIMG_MK) |
| 441 | else |
Rashed Abdel-Tawab | e523884 | 2019-10-15 00:56:52 -0400 | [diff] [blame] | 442 | MKDTIMG := $(HOST_OUT_EXECUTABLES)/mkdtimg$(HOST_EXECUTABLE_SUFFIX) |
| 443 | MKDTBOIMG := $(HOST_OUT_EXECUTABLES)/mkdtboimg.py$(HOST_EXECUTABLE_SUFFIX) |
| 444 | $(BOARD_PREBUILT_DTBOIMAGE): $(DTC) $(MKDTIMG) $(MKDTBOIMG) |
Luca Stefani | fe00ea9 | 2020-08-02 19:08:31 +0200 | [diff] [blame] | 445 | ifeq ($(BOARD_KERNEL_SEPARATED_DTBO),true) |
| 446 | $(BOARD_PREBUILT_DTBOIMAGE): |
| 447 | @echo "Building dtbo.img" |
Alexander Koskovich | 7f28099 | 2022-05-11 16:02:12 -0700 | [diff] [blame] | 448 | rm -rf $(DTBO_OUT) |
Luca Stefani | fe00ea9 | 2020-08-02 19:08:31 +0200 | [diff] [blame] | 449 | $(call make-dtbo-target,$(KERNEL_DEFCONFIG)) |
| 450 | $(call make-dtbo-target,dtbs) |
Luca Stefani | 05ce3dc | 2020-08-03 11:58:00 +0200 | [diff] [blame] | 451 | ifdef BOARD_DTBO_CFG |
| 452 | $(MKDTBOIMG) cfg_create $@ $(BOARD_DTBO_CFG) -d $(DTBO_OUT)/arch/$(KERNEL_ARCH)/boot/dts |
| 453 | else |
Luca Stefani | 16ea814 | 2020-08-05 11:37:46 +0200 | [diff] [blame] | 454 | $(MKDTBOIMG) create $@ --page_size=$(BOARD_KERNEL_PAGESIZE) $(shell find $(DTBO_OUT)/arch/$(KERNEL_ARCH)/boot/dts -type f -name "*.dtbo" | sort) |
Luca Stefani | 05ce3dc | 2020-08-03 11:58:00 +0200 | [diff] [blame] | 455 | endif |
Luca Stefani | fe00ea9 | 2020-08-02 19:08:31 +0200 | [diff] [blame] | 456 | else |
| 457 | $(BOARD_PREBUILT_DTBOIMAGE): |
| 458 | @echo "Building dtbo.img" |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 459 | $(call make-dtbo-target,$(KERNEL_DEFCONFIG)) |
| 460 | $(call make-dtbo-target,dtbo.img) |
Luca Stefani | fe00ea9 | 2020-08-02 19:08:31 +0200 | [diff] [blame] | 461 | endif # BOARD_KERNEL_SEPARATED_DTBO |
Aayush Gupta | 1de3b30 | 2020-08-25 10:03:10 +0000 | [diff] [blame] | 462 | endif # BOARD_CUSTOM_DTBOIMG_MK |
Luca Stefani | fe00ea9 | 2020-08-02 19:08:31 +0200 | [diff] [blame] | 463 | endif # TARGET_NEEDS_DTBOIMAGE/BOARD_KERNEL_SEPARATED_DTBO |
| 464 | |
| 465 | ifeq ($(BOARD_INCLUDE_DTB_IN_BOOTIMG),true) |
| 466 | ifeq ($(BOARD_PREBUILT_DTBIMAGE_DIR),) |
| 467 | $(INSTALLED_DTBIMAGE_TARGET): $(DTC) |
| 468 | @echo "Building dtb.img" |
Alexander Koskovich | 7f28099 | 2022-05-11 16:02:12 -0700 | [diff] [blame] | 469 | rm -rf $(DTB_OUT) |
Luca Stefani | fe00ea9 | 2020-08-02 19:08:31 +0200 | [diff] [blame] | 470 | $(call make-dtb-target,$(KERNEL_DEFCONFIG)) |
| 471 | $(call make-dtb-target,dtbs) |
| 472 | cat $(shell find $(DTB_OUT)/arch/$(KERNEL_ARCH)/boot/dts -type f -name "*.dtb" | sort) > $@ |
| 473 | endif # !BOARD_PREBUILT_DTBIMAGE_DIR |
| 474 | endif # BOARD_INCLUDE_DTB_IN_BOOTIMG |
Christian Oder | 8d5db3c | 2017-11-25 16:52:17 +0100 | [diff] [blame] | 475 | |
Ethan Chen | 117a0fd | 2019-02-10 12:12:50 -0800 | [diff] [blame] | 476 | endif # FULL_KERNEL_BUILD |
| 477 | |
marcost2 | 9b4cfe0 | 2021-07-06 12:55:59 -0300 | [diff] [blame] | 478 | ifeq ($(FULL_RECOVERY_KERNEL_BUILD),true) |
| 479 | |
| 480 | $(RECOVERY_KERNEL_OUT): |
| 481 | mkdir -p $(RECOVERY_KERNEL_OUT) |
| 482 | |
Bruno Martins | 164dfec | 2022-04-08 20:49:25 +0100 | [diff] [blame] | 483 | $(RECOVERY_KERNEL_CONFIG): $(ALL_RECOVERY_KERNEL_DEFCONFIG_SRCS) |
marcost2 | 9b4cfe0 | 2021-07-06 12:55:59 -0300 | [diff] [blame] | 484 | @echo "Building Recovery Kernel Config" |
| 485 | $(call make-kernel-config,$(RECOVERY_KERNEL_OUT),$(RECOVERY_DEFCONFIG)) |
| 486 | |
| 487 | $(TARGET_PREBUILT_INT_RECOVERY_KERNEL): $(RECOVERY_KERNEL_CONFIG) $(DEPMOD) $(DTC) |
| 488 | @echo "Building Recovery Kernel Image ($(BOARD_KERNEL_IMAGE_NAME))" |
| 489 | $(call make-recovery-kernel-target,$(BOARD_KERNEL_IMAGE_NAME)) |
| 490 | |
| 491 | |
| 492 | endif |
| 493 | |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 494 | ## Install it |
| 495 | |
| 496 | ifeq ($(NEEDS_KERNEL_COPY),true) |
| 497 | file := $(INSTALLED_KERNEL_TARGET) |
| 498 | ALL_PREBUILT += $(file) |
| 499 | $(file) : $(KERNEL_BIN) | $(ACP) |
| 500 | $(transform-prebuilt-to-target) |
| 501 | |
| 502 | ALL_PREBUILT += $(INSTALLED_KERNEL_TARGET) |
| 503 | endif |
| 504 | |
marcost2 | 9b4cfe0 | 2021-07-06 12:55:59 -0300 | [diff] [blame] | 505 | ifeq ($(RECOVERY_KERNEL_COPY),true) |
Jarl-Penguin | 91ed129 | 2022-02-20 13:26:31 +0100 | [diff] [blame] | 506 | file := $(INSTALLED_RECOVERY_KERNEL_TARGET) |
marcost2 | 9b4cfe0 | 2021-07-06 12:55:59 -0300 | [diff] [blame] | 507 | ALL_PREBUILT += $(file) |
| 508 | $(file) : $(RECOVERY_BIN) | $(ACP) |
| 509 | $(transform-prebuilt-to-target) |
| 510 | |
Jarl-Penguin | 91ed129 | 2022-02-20 13:26:31 +0100 | [diff] [blame] | 511 | ALL_PREBUILT += $(INSTALLED_RECOVERY_KERNEL_TARGET) |
marcost2 | 9b4cfe0 | 2021-07-06 12:55:59 -0300 | [diff] [blame] | 512 | endif |
| 513 | |
| 514 | .PHONY: recovery-kernel |
Jarl-Penguin | 91ed129 | 2022-02-20 13:26:31 +0100 | [diff] [blame] | 515 | recovery-kernel: $(INSTALLED_RECOVERY_KERNEL_TARGET) |
marcost2 | 9b4cfe0 | 2021-07-06 12:55:59 -0300 | [diff] [blame] | 516 | |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 517 | .PHONY: kernel |
dianlujitao | f30ad9e | 2019-09-12 17:37:45 +0800 | [diff] [blame] | 518 | kernel: $(INSTALLED_KERNEL_TARGET) |
Dan Pasanen | 8ee5d89 | 2017-12-08 13:46:30 -0600 | [diff] [blame] | 519 | |
Rashed Abdel-Tawab | 60fe935 | 2019-05-16 14:01:19 -0700 | [diff] [blame] | 520 | .PHONY: dtboimage |
| 521 | dtboimage: $(INSTALLED_DTBOIMAGE_TARGET) |
Christian Oder | 8d5db3c | 2017-11-25 16:52:17 +0100 | [diff] [blame] | 522 | |
Rashed Abdel-Tawab | 2c247d8 | 2019-09-27 23:37:14 -0400 | [diff] [blame] | 523 | .PHONY: dtbimage |
| 524 | dtbimage: $(INSTALLED_DTBIMAGE_TARGET) |
Rashed Abdel-Tawab | 2c247d8 | 2019-09-27 23:37:14 -0400 | [diff] [blame] | 525 | |
LuK1337 | d034c3f | 2020-09-15 11:06:18 +0200 | [diff] [blame] | 526 | endif # TARGET_NO_KERNEL_OVERRIDE |
Dan Pasanen | 8ee5d89 | 2017-12-08 13:46:30 -0600 | [diff] [blame] | 527 | endif # TARGET_NO_KERNEL |