Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 1 | # Copyright (C) 2012 The CyanogenMod Project |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | |
| 16 | # Android makefile to build kernel as a part of Android Build |
| 17 | # |
| 18 | # Configuration |
| 19 | # ============= |
| 20 | # |
| 21 | # These config vars are usually set in BoardConfig.mk: |
| 22 | # |
| 23 | # TARGET_KERNEL_SOURCE = Kernel source dir, optional, defaults |
| 24 | # to kernel/$(TARGET_DEVICE_DIR) |
| 25 | # TARGET_KERNEL_CONFIG = Kernel defconfig |
| 26 | # TARGET_KERNEL_VARIANT_CONFIG = Variant defconfig, optional |
| 27 | # TARGET_KERNEL_SELINUX_CONFIG = SELinux defconfig, optional |
| 28 | # TARGET_KERNEL_ADDITIONAL_CONFIG = Additional defconfig, optional |
| 29 | # TARGET_KERNEL_ARCH = Kernel Arch |
| 30 | # TARGET_KERNEL_HEADER_ARCH = Optional Arch for kernel headers if |
| 31 | # different from TARGET_KERNEL_ARCH |
| 32 | # TARGET_USES_UNCOMPRESSED_KERNEL = 'true' if Kernel is uncompressed, |
| 33 | # optional, defaults to false |
| 34 | # TARGET_KERNEL_CROSS_COMPILE_PREFIX = Compiler prefix (e.g. arm-eabi-) |
Michael Bestas | 1d55ece | 2016-09-28 20:16:25 +0300 | [diff] [blame] | 35 | # defaults to arm-linux-androidkernel- for arm |
| 36 | # aarch64-linux-androidkernel- for arm64 |
| 37 | # x86_64-linux-androidkernel- for x86 |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 38 | # |
| 39 | # BOARD_KERNEL_IMAGE_NAME = Built image name, optional, |
| 40 | # defaults to Image.gz on arm64 |
| 41 | # defaults to Image if TARGET_USES_UNCOMPRESSED_KERNEL |
| 42 | # defaults to zImage otherwise |
| 43 | # |
| 44 | # KERNEL_TOOLCHAIN_PREFIX = Overrides TARGET_KERNEL_CROSS_COMPILE_PREFIX, |
| 45 | # Set this var in shell to override |
| 46 | # toolchain specified in BoardConfig.mk |
| 47 | # KERNEL_TOOLCHAIN = Path to toolchain, if unset, assumes |
| 48 | # TARGET_KERNEL_CROSS_COMPILE_PREFIX |
| 49 | # is in PATH |
| 50 | # USE_CCACHE = Enable ccache (global Android flag) |
| 51 | # |
| 52 | # NEED_KERNEL_MODULE_ROOT = Optional, if true, install kernel |
| 53 | # modules in root instead of system |
| 54 | |
| 55 | |
| 56 | TARGET_AUTO_KDIR := $(shell echo $(TARGET_DEVICE_DIR) | sed -e 's/^device/kernel/g') |
| 57 | |
| 58 | ## Externally influenced variables |
| 59 | # kernel location - optional, defaults to kernel/<vendor>/<device> |
| 60 | TARGET_KERNEL_SOURCE ?= $(TARGET_AUTO_KDIR) |
| 61 | KERNEL_SRC := $(TARGET_KERNEL_SOURCE) |
| 62 | # kernel configuration - mandatory |
| 63 | KERNEL_DEFCONFIG := $(TARGET_KERNEL_CONFIG) |
| 64 | VARIANT_DEFCONFIG := $(TARGET_KERNEL_VARIANT_CONFIG) |
| 65 | SELINUX_DEFCONFIG := $(TARGET_KERNEL_SELINUX_CONFIG) |
| 66 | |
| 67 | ## Internal variables |
| 68 | KERNEL_OUT := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ |
| 69 | KERNEL_CONFIG := $(KERNEL_OUT)/.config |
| 70 | KERNEL_OUT_STAMP := $(KERNEL_OUT)/.mkdir_stamp |
| 71 | |
| 72 | TARGET_KERNEL_ARCH := $(strip $(TARGET_KERNEL_ARCH)) |
| 73 | ifeq ($(TARGET_KERNEL_ARCH),) |
| 74 | KERNEL_ARCH := $(TARGET_ARCH) |
| 75 | else |
| 76 | KERNEL_ARCH := $(TARGET_KERNEL_ARCH) |
| 77 | endif |
| 78 | |
| 79 | ifeq ($(KERNEL_ARCH),x86_64) |
| 80 | KERNEL_DEFCONFIG_ARCH := x86 |
| 81 | else |
| 82 | KERNEL_DEFCONFIG_ARCH := $(KERNEL_ARCH) |
| 83 | endif |
| 84 | KERNEL_DEFCONFIG_SRC := $(KERNEL_SRC)/arch/$(KERNEL_DEFCONFIG_ARCH)/configs/$(KERNEL_DEFCONFIG) |
| 85 | |
| 86 | TARGET_KERNEL_HEADER_ARCH := $(strip $(TARGET_KERNEL_HEADER_ARCH)) |
| 87 | ifeq ($(TARGET_KERNEL_HEADER_ARCH),) |
| 88 | KERNEL_HEADER_ARCH := $(KERNEL_ARCH) |
| 89 | else |
| 90 | KERNEL_HEADER_ARCH := $(TARGET_KERNEL_HEADER_ARCH) |
| 91 | endif |
| 92 | |
| 93 | KERNEL_HEADER_DEFCONFIG := $(strip $(KERNEL_HEADER_DEFCONFIG)) |
| 94 | ifeq ($(KERNEL_HEADER_DEFCONFIG),) |
| 95 | KERNEL_HEADER_DEFCONFIG := $(KERNEL_DEFCONFIG) |
| 96 | endif |
| 97 | |
| 98 | |
| 99 | ifneq ($(BOARD_KERNEL_IMAGE_NAME),) |
| 100 | TARGET_PREBUILT_INT_KERNEL_TYPE := $(BOARD_KERNEL_IMAGE_NAME) |
| 101 | else |
| 102 | ifeq ($(TARGET_USES_UNCOMPRESSED_KERNEL),true) |
| 103 | TARGET_PREBUILT_INT_KERNEL_TYPE := Image |
| 104 | else |
| 105 | ifeq ($(KERNEL_ARCH),arm64) |
| 106 | TARGET_PREBUILT_INT_KERNEL_TYPE := Image.gz |
| 107 | else |
| 108 | TARGET_PREBUILT_INT_KERNEL_TYPE := zImage |
| 109 | endif |
| 110 | endif |
| 111 | endif |
| 112 | |
| 113 | TARGET_PREBUILT_INT_KERNEL := $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/$(TARGET_PREBUILT_INT_KERNEL_TYPE) |
| 114 | |
| 115 | # Clear this first to prevent accidental poisoning from env |
| 116 | MAKE_FLAGS := |
| 117 | |
| 118 | ifeq ($(KERNEL_ARCH),arm64) |
| 119 | # Avoid "unsupported RELA relocation: 311" errors (R_AARCH64_ADR_GOT_PAGE) |
| 120 | MAKE_FLAGS += CFLAGS_MODULE="-fno-pic" |
| 121 | ifeq ($(TARGET_ARCH),arm) |
| 122 | KERNEL_CONFIG_OVERRIDE := CONFIG_ANDROID_BINDER_IPC_32BIT=y |
| 123 | endif |
| 124 | endif |
| 125 | |
| 126 | ifneq ($(TARGET_KERNEL_ADDITIONAL_CONFIG),) |
| 127 | KERNEL_ADDITIONAL_CONFIG := $(TARGET_KERNEL_ADDITIONAL_CONFIG) |
| 128 | KERNEL_ADDITIONAL_CONFIG_SRC := $(KERNEL_SRC)/arch/$(KERNEL_ARCH)/configs/$(KERNEL_ADDITIONAL_CONFIG) |
| 129 | ifeq ("$(wildcard $(KERNEL_ADDITIONAL_CONFIG_SRC))","") |
| 130 | $(warning TARGET_KERNEL_ADDITIONAL_CONFIG '$(TARGET_KERNEL_ADDITIONAL_CONFIG)' doesn't exist) |
| 131 | KERNEL_ADDITIONAL_CONFIG_SRC := /dev/null |
| 132 | endif |
| 133 | else |
| 134 | KERNEL_ADDITIONAL_CONFIG_SRC := /dev/null |
| 135 | endif |
| 136 | |
| 137 | ## Do be discontinued in a future version. Notify builder about target |
| 138 | ## kernel format requirement |
| 139 | ifeq ($(BOARD_KERNEL_IMAGE_NAME),) |
| 140 | ifeq ($(BOARD_USES_UBOOT),true) |
| 141 | $(error "Please set BOARD_KERNEL_IMAGE_NAME to uImage") |
| 142 | else ifeq ($(BOARD_USES_UNCOMPRESSED_BOOT),true) |
| 143 | $(error "Please set BOARD_KERNEL_IMAGE_NAME to Image") |
| 144 | endif |
| 145 | endif |
| 146 | |
| 147 | ifeq "$(wildcard $(KERNEL_SRC) )" "" |
| 148 | ifneq ($(TARGET_PREBUILT_KERNEL),) |
| 149 | HAS_PREBUILT_KERNEL := true |
| 150 | NEEDS_KERNEL_COPY := true |
| 151 | else |
| 152 | $(foreach cf,$(PRODUCT_COPY_FILES), \ |
| 153 | $(eval _src := $(call word-colon,1,$(cf))) \ |
| 154 | $(eval _dest := $(call word-colon,2,$(cf))) \ |
| 155 | $(ifeq kernel,$(_dest), \ |
| 156 | $(eval HAS_PREBUILT_KERNEL := true))) |
| 157 | endif |
| 158 | |
| 159 | ifneq ($(HAS_PREBUILT_KERNEL),) |
| 160 | $(warning ***************************************************************) |
| 161 | $(warning * Using prebuilt kernel binary instead of source *) |
| 162 | $(warning * THIS IS DEPRECATED, AND WILL BE DISCONTINUED *) |
| 163 | $(warning * Please configure your device to download the kernel *) |
| 164 | $(warning * source repository to $(KERNEL_SRC)) |
| 165 | $(warning * See http://wiki.cyanogenmod.org/w/Doc:_integrated_kernel_building) |
| 166 | $(warning * for more information *) |
| 167 | $(warning ***************************************************************) |
| 168 | FULL_KERNEL_BUILD := false |
| 169 | KERNEL_BIN := $(TARGET_PREBUILT_KERNEL) |
| 170 | else |
| 171 | $(warning ***************************************************************) |
| 172 | $(warning * *) |
| 173 | $(warning * No kernel source found, and no fallback prebuilt defined. *) |
| 174 | $(warning * Please make sure your device is properly configured to *) |
| 175 | $(warning * download the kernel repository to $(KERNEL_SRC)) |
| 176 | $(warning * and add the TARGET_KERNEL_CONFIG variable to BoardConfig.mk *) |
| 177 | $(warning * *) |
| 178 | $(warning * As an alternative, define the TARGET_PREBUILT_KERNEL *) |
| 179 | $(warning * variable with the path to the prebuilt binary kernel image *) |
| 180 | $(warning * in your BoardConfig.mk file *) |
| 181 | $(warning * *) |
| 182 | $(warning ***************************************************************) |
| 183 | $(error "NO KERNEL") |
| 184 | endif |
| 185 | else |
| 186 | NEEDS_KERNEL_COPY := true |
| 187 | ifeq ($(TARGET_KERNEL_CONFIG),) |
| 188 | $(warning **********************************************************) |
| 189 | $(warning * Kernel source found, but no configuration was defined *) |
| 190 | $(warning * Please add the TARGET_KERNEL_CONFIG variable to your *) |
| 191 | $(warning * BoardConfig.mk file *) |
| 192 | $(warning **********************************************************) |
| 193 | # $(error "NO KERNEL CONFIG") |
| 194 | else |
| 195 | #$(info Kernel source found, building it) |
| 196 | FULL_KERNEL_BUILD := true |
| 197 | KERNEL_BIN := $(TARGET_PREBUILT_INT_KERNEL) |
| 198 | endif |
| 199 | endif |
| 200 | |
| 201 | ifeq ($(FULL_KERNEL_BUILD),true) |
| 202 | |
| 203 | KERNEL_HEADERS_INSTALL := $(KERNEL_OUT)/usr |
| 204 | KERNEL_HEADERS_INSTALL_STAMP := $(KERNEL_OUT)/.headers_install_stamp |
| 205 | |
| 206 | ifeq ($(NEED_KERNEL_MODULE_ROOT),true) |
| 207 | KERNEL_MODULES_INSTALL := root |
| 208 | KERNEL_MODULES_OUT := $(TARGET_ROOT_OUT)/lib/modules |
| 209 | else |
| 210 | KERNEL_MODULES_INSTALL := system |
| 211 | KERNEL_MODULES_OUT := $(TARGET_OUT)/lib/modules |
| 212 | endif |
| 213 | |
| 214 | TARGET_KERNEL_CROSS_COMPILE_PREFIX := $(strip $(TARGET_KERNEL_CROSS_COMPILE_PREFIX)) |
| 215 | ifneq ($(TARGET_KERNEL_CROSS_COMPILE_PREFIX),) |
| 216 | KERNEL_TOOLCHAIN_PREFIX ?= $(TARGET_KERNEL_CROSS_COMPILE_PREFIX) |
Zhao Wei Liew | 9689bb9 | 2016-11-10 20:02:58 +0800 | [diff] [blame] | 217 | else ifeq ($(KERNEL_ARCH),arm64) |
Michael Bestas | 1d55ece | 2016-09-28 20:16:25 +0300 | [diff] [blame] | 218 | KERNEL_TOOLCHAIN_PREFIX ?= aarch64-linux-androidkernel- |
Zhao Wei Liew | 9689bb9 | 2016-11-10 20:02:58 +0800 | [diff] [blame] | 219 | else ifeq ($(KERNEL_ARCH),arm) |
Michael Bestas | 1d55ece | 2016-09-28 20:16:25 +0300 | [diff] [blame] | 220 | KERNEL_TOOLCHAIN_PREFIX ?= arm-linux-androidkernel- |
Zhao Wei Liew | 9689bb9 | 2016-11-10 20:02:58 +0800 | [diff] [blame] | 221 | else ifeq ($(KERNEL_ARCH),x86) |
Michael Bestas | 1d55ece | 2016-09-28 20:16:25 +0300 | [diff] [blame] | 222 | KERNEL_TOOLCHAIN_PREFIX ?= x86_64-linux-androidkernel- |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 223 | endif |
| 224 | |
| 225 | ifeq ($(KERNEL_TOOLCHAIN),) |
| 226 | KERNEL_TOOLCHAIN_PATH := $(KERNEL_TOOLCHAIN_PREFIX) |
| 227 | else |
| 228 | ifneq ($(KERNEL_TOOLCHAIN_PREFIX),) |
| 229 | KERNEL_TOOLCHAIN_PATH := $(KERNEL_TOOLCHAIN)/$(KERNEL_TOOLCHAIN_PREFIX) |
| 230 | endif |
| 231 | endif |
| 232 | |
| 233 | ifneq ($(USE_CCACHE),) |
Steve Kondik | 6a37828 | 2016-09-25 22:37:01 -0700 | [diff] [blame] | 234 | # Detect if the system already has ccache installed to use instead of the prebuilt |
| 235 | ccache := $(shell which ccache) |
| 236 | |
| 237 | ifeq ($(ccache),) |
| 238 | ccache := $(ANDROID_BUILD_TOP)/prebuilts/misc/$(HOST_PREBUILT_TAG)/ccache/ccache |
| 239 | # Check that the executable is here. |
| 240 | ccache := $(strip $(wildcard $(ccache))) |
| 241 | endif |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 242 | endif |
| 243 | |
| 244 | KERNEL_CROSS_COMPILE := CROSS_COMPILE="$(ccache) $(KERNEL_TOOLCHAIN_PATH)" |
| 245 | ccache = |
| 246 | |
| 247 | define mv-modules |
| 248 | mdpath=`find $(KERNEL_MODULES_OUT) -type f -name modules.order`;\ |
| 249 | if [ "$$mdpath" != "" ];then\ |
| 250 | mpath=`dirname $$mdpath`;\ |
| 251 | ko=`find $$mpath/kernel -type f -name *.ko`;\ |
| 252 | for i in $$ko; do $(KERNEL_TOOLCHAIN_PATH)strip --strip-unneeded $$i;\ |
| 253 | mv $$i $(KERNEL_MODULES_OUT)/; done;\ |
| 254 | fi |
| 255 | endef |
| 256 | |
| 257 | define clean-module-folder |
| 258 | mdpath=`find $(KERNEL_MODULES_OUT) -type f -name modules.order`;\ |
| 259 | if [ "$$mdpath" != "" ];then\ |
| 260 | mpath=`dirname $$mdpath`; rm -rf $$mpath;\ |
| 261 | fi |
| 262 | endef |
| 263 | |
| 264 | ifeq ($(HOST_OS),darwin) |
| 265 | MAKE_FLAGS += C_INCLUDE_PATH=$(ANDROID_BUILD_TOP)/external/elfutils/libelf/ |
| 266 | endif |
| 267 | |
| 268 | ifeq ($(TARGET_KERNEL_MODULES),) |
| 269 | TARGET_KERNEL_MODULES := no-external-modules |
| 270 | endif |
| 271 | |
| 272 | $(KERNEL_OUT_STAMP): |
| 273 | $(hide) mkdir -p $(KERNEL_OUT) |
| 274 | $(hide) rm -rf $(KERNEL_MODULES_OUT) |
| 275 | $(hide) mkdir -p $(KERNEL_MODULES_OUT) |
| 276 | $(hide) touch $@ |
| 277 | |
| 278 | KERNEL_ADDITIONAL_CONFIG_OUT := $(KERNEL_OUT)/.additional_config |
| 279 | |
| 280 | .PHONY: force_additional_config |
| 281 | $(KERNEL_ADDITIONAL_CONFIG_OUT): force_additional_config |
| 282 | $(hide) cmp -s $(KERNEL_ADDITIONAL_CONFIG_SRC) $@ || cp $(KERNEL_ADDITIONAL_CONFIG_SRC) $@; |
| 283 | |
| 284 | $(KERNEL_CONFIG): $(KERNEL_OUT_STAMP) $(KERNEL_DEFCONFIG_SRC) $(KERNEL_ADDITIONAL_CONFIG_OUT) |
| 285 | @echo "Building Kernel Config" |
| 286 | $(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) VARIANT_DEFCONFIG=$(VARIANT_DEFCONFIG) SELINUX_DEFCONFIG=$(SELINUX_DEFCONFIG) $(KERNEL_DEFCONFIG) |
| 287 | $(hide) if [ ! -z "$(KERNEL_CONFIG_OVERRIDE)" ]; then \ |
| 288 | echo "Overriding kernel config with '$(KERNEL_CONFIG_OVERRIDE)'"; \ |
| 289 | echo $(KERNEL_CONFIG_OVERRIDE) >> $(KERNEL_OUT)/.config; \ |
| 290 | $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) oldconfig; fi |
Sam Mortimer | b0cecb7 | 2016-10-01 09:56:52 -0700 | [diff] [blame] | 291 | # Create defconfig build artifact |
| 292 | $(hide) $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) savedefconfig |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 293 | $(hide) if [ ! -z "$(KERNEL_ADDITIONAL_CONFIG)" ]; then \ |
| 294 | echo "Using additional config '$(KERNEL_ADDITIONAL_CONFIG)'"; \ |
| 295 | $(KERNEL_SRC)/scripts/kconfig/merge_config.sh -m -O $(KERNEL_OUT) $(KERNEL_OUT)/.config $(KERNEL_SRC)/arch/$(KERNEL_ARCH)/configs/$(KERNEL_ADDITIONAL_CONFIG); \ |
| 296 | $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) KCONFIG_ALLCONFIG=$(KERNEL_OUT)/.config alldefconfig; fi |
| 297 | |
| 298 | TARGET_KERNEL_BINARIES: $(KERNEL_OUT_STAMP) $(KERNEL_CONFIG) $(KERNEL_HEADERS_INSTALL_STAMP) |
| 299 | @echo "Building Kernel" |
| 300 | $(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(TARGET_PREBUILT_INT_KERNEL_TYPE) |
| 301 | $(hide) if grep -q 'CONFIG_OF=y' $(KERNEL_CONFIG) ; \ |
| 302 | then \ |
| 303 | echo "Building DTBs" ; \ |
| 304 | $(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) dtbs ; \ |
| 305 | else \ |
| 306 | echo "DTBs not enabled" ; \ |
| 307 | fi ; |
| 308 | $(hide) if grep -q 'CONFIG_MODULES=y' $(KERNEL_CONFIG) ; \ |
| 309 | then \ |
| 310 | echo "Building Kernel Modules" ; \ |
| 311 | $(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) modules && \ |
| 312 | $(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) INSTALL_MOD_PATH=../../$(KERNEL_MODULES_INSTALL) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) modules_install && \ |
| 313 | $(mv-modules) && \ |
| 314 | $(clean-module-folder) ; \ |
| 315 | else \ |
| 316 | echo "Kernel Modules not enabled" ; \ |
| 317 | fi ; |
| 318 | |
| 319 | |
| 320 | $(TARGET_KERNEL_MODULES): TARGET_KERNEL_BINARIES |
| 321 | |
| 322 | $(TARGET_PREBUILT_INT_KERNEL): $(TARGET_KERNEL_MODULES) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 323 | |
| 324 | $(KERNEL_HEADERS_INSTALL_STAMP): $(KERNEL_OUT_STAMP) $(KERNEL_CONFIG) |
| 325 | @echo "Building Kernel Headers" |
| 326 | $(hide) if [ ! -z "$(KERNEL_HEADER_DEFCONFIG)" ]; then \ |
| 327 | rm -f ../$(KERNEL_CONFIG); \ |
| 328 | $(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_HEADER_ARCH) $(KERNEL_CROSS_COMPILE) VARIANT_DEFCONFIG=$(VARIANT_DEFCONFIG) SELINUX_DEFCONFIG=$(SELINUX_DEFCONFIG) $(KERNEL_HEADER_DEFCONFIG); \ |
| 329 | $(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_HEADER_ARCH) $(KERNEL_CROSS_COMPILE) headers_install; fi |
| 330 | $(hide) if [ "$(KERNEL_HEADER_DEFCONFIG)" != "$(KERNEL_DEFCONFIG)" ]; then \ |
| 331 | echo "Used a different defconfig for header generation"; \ |
| 332 | rm -f ../$(KERNEL_CONFIG); \ |
| 333 | $(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) VARIANT_DEFCONFIG=$(VARIANT_DEFCONFIG) SELINUX_DEFCONFIG=$(SELINUX_DEFCONFIG) $(KERNEL_DEFCONFIG); fi |
| 334 | $(hide) if [ ! -z "$(KERNEL_CONFIG_OVERRIDE)" ]; then \ |
| 335 | echo "Overriding kernel config with '$(KERNEL_CONFIG_OVERRIDE)'"; \ |
| 336 | echo $(KERNEL_CONFIG_OVERRIDE) >> $(KERNEL_OUT)/.config; \ |
| 337 | $(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) oldconfig; fi |
| 338 | $(hide) if [ ! -z "$(KERNEL_ADDITIONAL_CONFIG)" ]; then \ |
| 339 | echo "Using additional config '$(KERNEL_ADDITIONAL_CONFIG)'"; \ |
| 340 | $(KERNEL_SRC)/scripts/kconfig/merge_config.sh -m -O $(KERNEL_OUT) $(KERNEL_OUT)/.config $(KERNEL_SRC)/arch/$(KERNEL_ARCH)/configs/$(KERNEL_ADDITIONAL_CONFIG); \ |
| 341 | $(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) KCONFIG_ALLCONFIG=$(KERNEL_OUT)/.config alldefconfig; fi |
| 342 | $(hide) touch $@ |
| 343 | |
| 344 | # provide this rule because there are dependencies on this throughout the repo |
| 345 | $(KERNEL_HEADERS_INSTALL): $(KERNEL_HEADERS_INSTALL_STAMP) |
| 346 | |
| 347 | kerneltags: $(KERNEL_OUT_STAMP) $(KERNEL_CONFIG) |
| 348 | $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) tags |
| 349 | |
| 350 | kernelconfig: KERNELCONFIG_MODE := menuconfig |
| 351 | kernelxconfig: KERNELCONFIG_MODE := xconfig |
| 352 | kernelxconfig kernelconfig: $(KERNEL_OUT_STAMP) |
| 353 | $(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_DEFCONFIG) |
| 354 | env KCONFIG_NOTIMESTAMP=true \ |
| 355 | $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNELCONFIG_MODE) |
| 356 | env KCONFIG_NOTIMESTAMP=true \ |
| 357 | $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) savedefconfig |
| 358 | cp $(KERNEL_OUT)/defconfig $(KERNEL_DEFCONFIG_SRC) |
| 359 | |
| 360 | alldefconfig: $(KERNEL_OUT_STAMP) |
| 361 | env KCONFIG_NOTIMESTAMP=true \ |
| 362 | $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) alldefconfig |
| 363 | |
| 364 | endif # FULL_KERNEL_BUILD |
| 365 | |
| 366 | ## Install it |
| 367 | |
| 368 | ifeq ($(NEEDS_KERNEL_COPY),true) |
| 369 | file := $(INSTALLED_KERNEL_TARGET) |
| 370 | ALL_PREBUILT += $(file) |
| 371 | $(file) : $(KERNEL_BIN) | $(ACP) |
| 372 | $(transform-prebuilt-to-target) |
| 373 | |
| 374 | ALL_PREBUILT += $(INSTALLED_KERNEL_TARGET) |
| 375 | endif |
| 376 | |
| 377 | .PHONY: kernel |
| 378 | kernel: $(INSTALLED_KERNEL_TARGET) |