Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 1 | # Copyright (C) 2012 The CyanogenMod Project |
Dan Pasanen | 0344771 | 2016-12-19 11:22:55 -0600 | [diff] [blame] | 2 | # (C) 2017 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 | # |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [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 |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 28 | # |
Joe Maples | da32895 | 2017-11-27 10:09:38 -0500 | [diff] [blame] | 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 | # |
Dan Pasanen | edc1ceb | 2017-01-24 15:46:13 -0600 | [diff] [blame] | 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. |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 43 | # |
Joe Maples | da32895 | 2017-11-27 10:09:38 -0500 | [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 | # |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 52 | # NEED_KERNEL_MODULE_ROOT = Optional, if true, install kernel |
Luca Stefani | a1ade7f | 2018-07-11 00:35:33 +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 |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 56 | |
Dan Pasanen | 8ee5d89 | 2017-12-08 13:46:30 -0600 | [diff] [blame] | 57 | ifneq ($(TARGET_NO_KERNEL),true) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 58 | |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 59 | ## Externally influenced variables |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 60 | KERNEL_SRC := $(TARGET_KERNEL_SOURCE) |
| 61 | # kernel configuration - mandatory |
| 62 | KERNEL_DEFCONFIG := $(TARGET_KERNEL_CONFIG) |
| 63 | VARIANT_DEFCONFIG := $(TARGET_KERNEL_VARIANT_CONFIG) |
| 64 | SELINUX_DEFCONFIG := $(TARGET_KERNEL_SELINUX_CONFIG) |
| 65 | |
| 66 | ## Internal variables |
| 67 | KERNEL_OUT := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ |
| 68 | KERNEL_CONFIG := $(KERNEL_OUT)/.config |
LuK1337 | 6047f5a | 2019-07-12 12:55:35 +0200 | [diff] [blame] | 69 | KERNEL_RELEASE := $(KERNEL_OUT)/include/config/kernel.release |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 70 | |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 71 | ifeq ($(KERNEL_ARCH),x86_64) |
| 72 | KERNEL_DEFCONFIG_ARCH := x86 |
| 73 | else |
| 74 | KERNEL_DEFCONFIG_ARCH := $(KERNEL_ARCH) |
| 75 | endif |
| 76 | KERNEL_DEFCONFIG_SRC := $(KERNEL_SRC)/arch/$(KERNEL_DEFCONFIG_ARCH)/configs/$(KERNEL_DEFCONFIG) |
| 77 | |
Dan Pasanen | edc1ceb | 2017-01-24 15:46:13 -0600 | [diff] [blame] | 78 | ifeq ($(BOARD_KERNEL_IMAGE_NAME),) |
| 79 | $(error BOARD_KERNEL_IMAGE_NAME not defined.) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 80 | endif |
Dan Pasanen | edc1ceb | 2017-01-24 15:46:13 -0600 | [diff] [blame] | 81 | TARGET_PREBUILT_INT_KERNEL := $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/$(BOARD_KERNEL_IMAGE_NAME) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 82 | |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 83 | ifneq ($(TARGET_KERNEL_ADDITIONAL_CONFIG),) |
| 84 | KERNEL_ADDITIONAL_CONFIG := $(TARGET_KERNEL_ADDITIONAL_CONFIG) |
| 85 | KERNEL_ADDITIONAL_CONFIG_SRC := $(KERNEL_SRC)/arch/$(KERNEL_ARCH)/configs/$(KERNEL_ADDITIONAL_CONFIG) |
| 86 | ifeq ("$(wildcard $(KERNEL_ADDITIONAL_CONFIG_SRC))","") |
| 87 | $(warning TARGET_KERNEL_ADDITIONAL_CONFIG '$(TARGET_KERNEL_ADDITIONAL_CONFIG)' doesn't exist) |
| 88 | KERNEL_ADDITIONAL_CONFIG_SRC := /dev/null |
| 89 | endif |
| 90 | else |
| 91 | KERNEL_ADDITIONAL_CONFIG_SRC := /dev/null |
| 92 | endif |
| 93 | |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 94 | ifeq "$(wildcard $(KERNEL_SRC) )" "" |
| 95 | ifneq ($(TARGET_PREBUILT_KERNEL),) |
| 96 | HAS_PREBUILT_KERNEL := true |
| 97 | NEEDS_KERNEL_COPY := true |
| 98 | else |
| 99 | $(foreach cf,$(PRODUCT_COPY_FILES), \ |
| 100 | $(eval _src := $(call word-colon,1,$(cf))) \ |
| 101 | $(eval _dest := $(call word-colon,2,$(cf))) \ |
| 102 | $(ifeq kernel,$(_dest), \ |
| 103 | $(eval HAS_PREBUILT_KERNEL := true))) |
| 104 | endif |
| 105 | |
| 106 | ifneq ($(HAS_PREBUILT_KERNEL),) |
| 107 | $(warning ***************************************************************) |
| 108 | $(warning * Using prebuilt kernel binary instead of source *) |
| 109 | $(warning * THIS IS DEPRECATED, AND WILL BE DISCONTINUED *) |
| 110 | $(warning * Please configure your device to download the kernel *) |
| 111 | $(warning * source repository to $(KERNEL_SRC)) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 112 | $(warning * for more information *) |
| 113 | $(warning ***************************************************************) |
| 114 | FULL_KERNEL_BUILD := false |
| 115 | KERNEL_BIN := $(TARGET_PREBUILT_KERNEL) |
| 116 | else |
| 117 | $(warning ***************************************************************) |
| 118 | $(warning * *) |
| 119 | $(warning * No kernel source found, and no fallback prebuilt defined. *) |
| 120 | $(warning * Please make sure your device is properly configured to *) |
| 121 | $(warning * download the kernel repository to $(KERNEL_SRC)) |
| 122 | $(warning * and add the TARGET_KERNEL_CONFIG variable to BoardConfig.mk *) |
| 123 | $(warning * *) |
| 124 | $(warning * As an alternative, define the TARGET_PREBUILT_KERNEL *) |
| 125 | $(warning * variable with the path to the prebuilt binary kernel image *) |
| 126 | $(warning * in your BoardConfig.mk file *) |
| 127 | $(warning * *) |
| 128 | $(warning ***************************************************************) |
| 129 | $(error "NO KERNEL") |
| 130 | endif |
| 131 | else |
| 132 | NEEDS_KERNEL_COPY := true |
| 133 | ifeq ($(TARGET_KERNEL_CONFIG),) |
| 134 | $(warning **********************************************************) |
| 135 | $(warning * Kernel source found, but no configuration was defined *) |
| 136 | $(warning * Please add the TARGET_KERNEL_CONFIG variable to your *) |
| 137 | $(warning * BoardConfig.mk file *) |
| 138 | $(warning **********************************************************) |
| 139 | # $(error "NO KERNEL CONFIG") |
| 140 | else |
| 141 | #$(info Kernel source found, building it) |
| 142 | FULL_KERNEL_BUILD := true |
| 143 | KERNEL_BIN := $(TARGET_PREBUILT_INT_KERNEL) |
| 144 | endif |
| 145 | endif |
| 146 | |
| 147 | ifeq ($(FULL_KERNEL_BUILD),true) |
| 148 | |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 149 | ifeq ($(NEED_KERNEL_MODULE_ROOT),true) |
Ethan Chen | 9985f59 | 2019-02-09 15:15:11 -0800 | [diff] [blame] | 150 | KERNEL_MODULES_OUT := $(TARGET_ROOT_OUT) |
Ethan Chen | bf38db2 | 2017-12-03 23:59:48 -0800 | [diff] [blame] | 151 | KERNEL_DEPMOD_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_recovery) |
| 152 | KERNEL_MODULE_MOUNTPOINT := |
Luca Stefani | a1ade7f | 2018-07-11 00:35:33 +0200 | [diff] [blame] | 153 | else ifeq ($(NEED_KERNEL_MODULE_SYSTEM),true) |
Ethan Chen | 9985f59 | 2019-02-09 15:15:11 -0800 | [diff] [blame] | 154 | KERNEL_MODULES_OUT := $(TARGET_OUT) |
Luca Stefani | a1ade7f | 2018-07-11 00:35:33 +0200 | [diff] [blame] | 155 | KERNEL_DEPMOD_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_system) |
| 156 | KERNEL_MODULE_MOUNTPOINT := system |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 157 | else |
Ethan Chen | 9985f59 | 2019-02-09 15:15:11 -0800 | [diff] [blame] | 158 | KERNEL_MODULES_OUT := $(TARGET_OUT_VENDOR) |
Ethan Chen | bf38db2 | 2017-12-03 23:59:48 -0800 | [diff] [blame] | 159 | KERNEL_DEPMOD_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor) |
| 160 | KERNEL_MODULE_MOUNTPOINT := vendor |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 161 | endif |
Ethan Chen | 9985f59 | 2019-02-09 15:15:11 -0800 | [diff] [blame] | 162 | MODULES_INTERMEDIATES := $(call intermediates-dir-for,PACKAGING,kernel_modules) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 163 | |
Joe Maples | da32895 | 2017-11-27 10:09:38 -0500 | [diff] [blame] | 164 | ifeq ($(TARGET_KERNEL_CLANG_COMPILE),true) |
| 165 | ifneq ($(TARGET_KERNEL_CLANG_VERSION),) |
| 166 | # Find the clang-* directory containing the specified version |
Rashed Abdel-Tawab | 3d29315 | 2018-08-06 22:01:29 -0700 | [diff] [blame] | 167 | KERNEL_CLANG_VERSION := $(shell find $(BUILD_TOP)/prebuilts/clang/host/$(HOST_OS)-x86/ -name AndroidVersion.txt -exec grep -l $(TARGET_KERNEL_CLANG_VERSION) "{}" \; | sed -e 's|/AndroidVersion.txt$$||g;s|^.*/||g') |
Joe Maples | da32895 | 2017-11-27 10:09:38 -0500 | [diff] [blame] | 168 | else |
Nathan Chancellor | ca40331 | 2018-04-11 16:23:19 -0700 | [diff] [blame] | 169 | # Use the default version of clang if TARGET_KERNEL_CLANG_VERSION hasn't been set by the device config |
| 170 | KERNEL_CLANG_VERSION := $(LLVM_PREBUILTS_VERSION) |
Joe Maples | da32895 | 2017-11-27 10:09:38 -0500 | [diff] [blame] | 171 | endif |
Rashed Abdel-Tawab | 3d29315 | 2018-08-06 22:01:29 -0700 | [diff] [blame] | 172 | TARGET_KERNEL_CLANG_PATH ?= $(BUILD_TOP)/prebuilts/clang/host/$(HOST_OS)-x86/$(KERNEL_CLANG_VERSION)/bin |
Joe Maples | da32895 | 2017-11-27 10:09:38 -0500 | [diff] [blame] | 173 | ifeq ($(KERNEL_ARCH),arm64) |
| 174 | KERNEL_CLANG_TRIPLE ?= CLANG_TRIPLE=aarch64-linux-gnu- |
| 175 | else ifeq ($(KERNEL_ARCH),arm) |
| 176 | KERNEL_CLANG_TRIPLE ?= CLANG_TRIPLE=arm-linux-gnu- |
| 177 | else ifeq ($(KERNEL_ARCH),x86) |
| 178 | KERNEL_CLANG_TRIPLE ?= CLANG_TRIPLE=x86_64-linux-gnu- |
| 179 | endif |
Nathan Chancellor | 4d0d438 | 2018-10-21 19:07:47 -0700 | [diff] [blame] | 180 | PATH_OVERRIDE := PATH=$(TARGET_KERNEL_CLANG_PATH):$$PATH LD_LIBRARY_PATH=$(BUILD_TOP)/prebuilts/clang/host/$(HOST_OS)-x86/$(KERNEL_CLANG_VERSION)/lib64:$$LD_LIBRARY_PATH |
Dan Pasanen | f65a6df | 2018-02-18 22:13:05 -0600 | [diff] [blame] | 181 | ifeq ($(KERNEL_CC),) |
Nathan Chancellor | 4d0d438 | 2018-10-21 19:07:47 -0700 | [diff] [blame] | 182 | KERNEL_CC := CC="$(CCACHE_BIN) clang" |
Dan Pasanen | f65a6df | 2018-02-18 22:13:05 -0600 | [diff] [blame] | 183 | endif |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 184 | endif |
| 185 | |
| 186 | ifeq ($(TARGET_KERNEL_MODULES),) |
Tom Marshall | f15c371 | 2017-11-10 01:00:18 +0100 | [diff] [blame] | 187 | TARGET_KERNEL_MODULES := INSTALLED_KERNEL_MODULES |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 188 | endif |
| 189 | |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 190 | KERNEL_ADDITIONAL_CONFIG_OUT := $(KERNEL_OUT)/.additional_config |
| 191 | |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 192 | # Internal implementation of make-kernel-target |
| 193 | # $(1): output path (The value passed to O=) |
| 194 | # $(2): target to build (eg. defconfig, modules, dtbo.img) |
| 195 | define internal-make-kernel-target |
| 196 | $(PATH_OVERRIDE) $(MAKE) -C $(KERNEL_SRC) O=$(1) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(2) |
| 197 | endef |
| 198 | |
| 199 | # Make a kernel target |
| 200 | # $(1): The kernel target to build (eg. defconfig, modules, modules_install) |
| 201 | define make-kernel-target |
| 202 | $(call internal-make-kernel-target,$(KERNEL_OUT),$(1)) |
| 203 | endef |
| 204 | |
| 205 | # Make a DTBO target |
| 206 | # $(1): The DTBO target to build (eg. dtbo.img, defconfig) |
| 207 | define make-dtbo-target |
| 208 | $(call internal-make-kernel-target,$(PRODUCT_OUT)/dtbo,$(1)) |
| 209 | endef |
| 210 | |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 211 | .PHONY: force_additional_config |
| 212 | $(KERNEL_ADDITIONAL_CONFIG_OUT): force_additional_config |
| 213 | $(hide) cmp -s $(KERNEL_ADDITIONAL_CONFIG_SRC) $@ || cp $(KERNEL_ADDITIONAL_CONFIG_SRC) $@; |
| 214 | |
Tom Marshall | 6b83d83 | 2017-11-09 21:02:33 +0100 | [diff] [blame] | 215 | $(KERNEL_CONFIG): $(KERNEL_DEFCONFIG_SRC) $(KERNEL_ADDITIONAL_CONFIG_OUT) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 216 | @echo "Building Kernel Config" |
Tom Marshall | 6b83d83 | 2017-11-09 21:02:33 +0100 | [diff] [blame] | 217 | $(hide) mkdir -p $(KERNEL_OUT) |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 218 | $(call make-kernel-target,VARIANT_DEFCONFIG=$(VARIANT_DEFCONFIG) SELINUX_DEFCONFIG=$(SELINUX_DEFCONFIG) $(KERNEL_DEFCONFIG)) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 219 | $(hide) if [ ! -z "$(KERNEL_CONFIG_OVERRIDE)" ]; then \ |
| 220 | echo "Overriding kernel config with '$(KERNEL_CONFIG_OVERRIDE)'"; \ |
| 221 | echo $(KERNEL_CONFIG_OVERRIDE) >> $(KERNEL_OUT)/.config; \ |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 222 | $(call make-kernel-target,oldconfig); \ |
| 223 | fi |
Sam Mortimer | b0cecb7 | 2016-10-01 09:56:52 -0700 | [diff] [blame] | 224 | # Create defconfig build artifact |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 225 | $(call make-kernel-target,savedefconfig) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 226 | $(hide) if [ ! -z "$(KERNEL_ADDITIONAL_CONFIG)" ]; then \ |
| 227 | echo "Using additional config '$(KERNEL_ADDITIONAL_CONFIG)'"; \ |
| 228 | $(KERNEL_SRC)/scripts/kconfig/merge_config.sh -m -O $(KERNEL_OUT) $(KERNEL_OUT)/.config $(KERNEL_SRC)/arch/$(KERNEL_ARCH)/configs/$(KERNEL_ADDITIONAL_CONFIG); \ |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 229 | $(call make-kernel-target,KCONFIG_ALLCONFIG=$(KERNEL_OUT)/.config alldefconfig); \ |
| 230 | fi |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 231 | |
Tom Marshall | 6b83d83 | 2017-11-09 21:02:33 +0100 | [diff] [blame] | 232 | .PHONY: TARGET_KERNEL_BINARIES |
| 233 | TARGET_KERNEL_BINARIES: $(KERNEL_CONFIG) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 234 | @echo "Building Kernel" |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 235 | $(call make-kernel-target,$(BOARD_KERNEL_IMAGE_NAME)) |
Tom Marshall | f15c371 | 2017-11-10 01:00:18 +0100 | [diff] [blame] | 236 | $(hide) if grep -q '^CONFIG_OF=y' $(KERNEL_CONFIG); then \ |
| 237 | echo "Building DTBs"; \ |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 238 | $(call make-kernel-target,dtbs); \ |
Tom Marshall | f15c371 | 2017-11-10 01:00:18 +0100 | [diff] [blame] | 239 | fi |
Ethan Chen | 0724f78 | 2019-02-09 21:05:01 -0800 | [diff] [blame] | 240 | $(hide) if grep -q '=m' $(KERNEL_CONFIG); then \ |
Tom Marshall | f15c371 | 2017-11-10 01:00:18 +0100 | [diff] [blame] | 241 | echo "Building Kernel Modules"; \ |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 242 | $(call make-kernel-target,modules); \ |
Tom Marshall | f15c371 | 2017-11-10 01:00:18 +0100 | [diff] [blame] | 243 | fi |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 244 | |
Tom Marshall | f15c371 | 2017-11-10 01:00:18 +0100 | [diff] [blame] | 245 | .PHONY: INSTALLED_KERNEL_MODULES |
Aaron Kling | a078a22 | 2018-01-12 18:19:27 -0600 | [diff] [blame] | 246 | INSTALLED_KERNEL_MODULES: depmod-host |
Ethan Chen | 0724f78 | 2019-02-09 21:05:01 -0800 | [diff] [blame] | 247 | $(hide) if grep -q '=m' $(KERNEL_CONFIG); then \ |
Tom Marshall | f15c371 | 2017-11-10 01:00:18 +0100 | [diff] [blame] | 248 | echo "Installing Kernel Modules"; \ |
Ethan Chen | 9985f59 | 2019-02-09 15:15:11 -0800 | [diff] [blame] | 249 | $(call make-kernel-target,INSTALL_MOD_PATH=$(MODULES_INTERMEDIATES) modules_install); \ |
LuK1337 | 6047f5a | 2019-07-12 12:55:35 +0200 | [diff] [blame] | 250 | kernel_release=$$(cat $(KERNEL_RELEASE)) \ |
| 251 | modules=$$(find $(MODULES_INTERMEDIATES)/lib/modules/$$kernel_release -type f -name '*.ko'); \ |
Ethan Chen | 9985f59 | 2019-02-09 15:15:11 -0800 | [diff] [blame] | 252 | for f in $$modules; do \ |
Tom Marshall | f15c371 | 2017-11-10 01:00:18 +0100 | [diff] [blame] | 253 | $(KERNEL_TOOLCHAIN_PATH)strip --strip-unneeded $$f; \ |
Ethan Chen | 9985f59 | 2019-02-09 15:15:11 -0800 | [diff] [blame] | 254 | done; \ |
Thor Lee | 7597589 | 2019-05-02 09:31:30 +0200 | [diff] [blame] | 255 | ($(call build-image-kernel-modules,$$modules,$(KERNEL_MODULES_OUT),$(KERNEL_MODULE_MOUNTPOINT)/,$(KERNEL_DEPMOD_STAGING_DIR))); \ |
Tom Marshall | f15c371 | 2017-11-10 01:00:18 +0100 | [diff] [blame] | 256 | fi |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 257 | |
| 258 | $(TARGET_KERNEL_MODULES): TARGET_KERNEL_BINARIES |
| 259 | |
| 260 | $(TARGET_PREBUILT_INT_KERNEL): $(TARGET_KERNEL_MODULES) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 261 | |
Tom Marshall | 6b83d83 | 2017-11-09 21:02:33 +0100 | [diff] [blame] | 262 | .PHONY: kerneltags |
| 263 | kerneltags: $(KERNEL_CONFIG) |
| 264 | $(hide) mkdir -p $(KERNEL_OUT) |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 265 | $(call make-kernel-target,tags) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 266 | |
Michael Bestas | b4c4aba | 2018-10-06 22:12:10 +0300 | [diff] [blame] | 267 | .PHONY: kernelsavedefconfig alldefconfig |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 268 | |
Tom Marshall | 6b83d83 | 2017-11-09 21:02:33 +0100 | [diff] [blame] | 269 | kernelsavedefconfig: |
| 270 | $(hide) mkdir -p $(KERNEL_OUT) |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 271 | $(call make-kernel-target,$(KERNEL_DEFCONFIG)) |
Michael Bestas | 296008c | 2017-07-12 20:56:35 +0300 | [diff] [blame] | 272 | env KCONFIG_NOTIMESTAMP=true \ |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 273 | $(call make-kernel-target,savedefconfig) |
Michael Bestas | 296008c | 2017-07-12 20:56:35 +0300 | [diff] [blame] | 274 | cp $(KERNEL_OUT)/defconfig $(KERNEL_DEFCONFIG_SRC) |
| 275 | |
Tom Marshall | 6b83d83 | 2017-11-09 21:02:33 +0100 | [diff] [blame] | 276 | alldefconfig: |
| 277 | $(hide) mkdir -p $(KERNEL_OUT) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 278 | env KCONFIG_NOTIMESTAMP=true \ |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 279 | $(call make-kernel-target,alldefconfig) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 280 | |
Rashed Abdel-Tawab | 60fe935 | 2019-05-16 14:01:19 -0700 | [diff] [blame] | 281 | ifeq ($(TARGET_NEEDS_DTBOIMAGE),true) |
| 282 | BOARD_PREBUILT_DTBOIMAGE = $(PRODUCT_OUT)/dtbo/arch/$(KERNEL_ARCH)/boot/dtbo.img |
| 283 | $(BOARD_PREBUILT_DTBOIMAGE): |
Christian Oder | 8d5db3c | 2017-11-25 16:52:17 +0100 | [diff] [blame] | 284 | echo -e ${CL_GRN}"Building DTBO.img"${CL_RST} |
Ethan Chen | a325446 | 2019-02-09 16:26:51 -0800 | [diff] [blame] | 285 | $(call make-dtbo-target,$(KERNEL_DEFCONFIG)) |
| 286 | $(call make-dtbo-target,dtbo.img) |
Rashed Abdel-Tawab | 60fe935 | 2019-05-16 14:01:19 -0700 | [diff] [blame] | 287 | endif # TARGET_NEEDS_DTBOIMAGE |
Christian Oder | 8d5db3c | 2017-11-25 16:52:17 +0100 | [diff] [blame] | 288 | |
Ethan Chen | 117a0fd | 2019-02-10 12:12:50 -0800 | [diff] [blame] | 289 | endif # FULL_KERNEL_BUILD |
| 290 | |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 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 |
| 301 | |
Rashed Abdel-Tawab | 60fe935 | 2019-05-16 14:01:19 -0700 | [diff] [blame] | 302 | INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img |
Christian Oder | 8d5db3c | 2017-11-25 16:52:17 +0100 | [diff] [blame] | 303 | ALL_PREBUILT += $(INSTALLED_DTBOIMAGE_TARGET) |
Christian Oder | 8d5db3c | 2017-11-25 16:52:17 +0100 | [diff] [blame] | 304 | |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 305 | .PHONY: kernel |
| 306 | kernel: $(INSTALLED_KERNEL_TARGET) |
Dan Pasanen | 8ee5d89 | 2017-12-08 13:46:30 -0600 | [diff] [blame] | 307 | |
Rashed Abdel-Tawab | 60fe935 | 2019-05-16 14:01:19 -0700 | [diff] [blame] | 308 | .PHONY: dtboimage |
| 309 | dtboimage: $(INSTALLED_DTBOIMAGE_TARGET) |
Christian Oder | 8d5db3c | 2017-11-25 16:52:17 +0100 | [diff] [blame] | 310 | |
Dan Pasanen | 8ee5d89 | 2017-12-08 13:46:30 -0600 | [diff] [blame] | 311 | endif # TARGET_NO_KERNEL |