| # Copyright (C) 2012 The CyanogenMod Project |
| # (C) 2017 The LineageOS Project |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| |
| # Android makefile to build kernel as a part of Android Build |
| # |
| # Configuration |
| # ============= |
| # |
| # These config vars are usually set in BoardConfig.mk: |
| # |
| # TARGET_KERNEL_SOURCE = Kernel source dir, optional, defaults |
| # to kernel/$(TARGET_DEVICE_DIR) |
| # TARGET_KERNEL_CONFIG = Kernel defconfig |
| # TARGET_KERNEL_VARIANT_CONFIG = Variant defconfig, optional |
| # TARGET_KERNEL_SELINUX_CONFIG = SELinux defconfig, optional |
| # TARGET_KERNEL_ADDITIONAL_CONFIG = Additional defconfig, optional |
| # TARGET_KERNEL_ARCH = Kernel Arch |
| # TARGET_KERNEL_CROSS_COMPILE_PREFIX = Compiler prefix (e.g. arm-eabi-) |
| # defaults to arm-linux-androidkernel- for arm |
| # aarch64-linux-androidkernel- for arm64 |
| # x86_64-linux-androidkernel- for x86 |
| # |
| # TARGET_KERNEL_CLANG_COMPILE = Compile kernel with clang, defaults to false |
| # |
| # TARGET_KERNEL_CLANG_VERSION = Clang prebuilts version, optional, defaults to clang-stable |
| # |
| # TARGET_KERNEL_CLANG_PATH = Clang prebuilts path, optional |
| # |
| # BOARD_KERNEL_IMAGE_NAME = Built image name |
| # for ARM use: zImage |
| # for ARM64 use: Image.gz |
| # for uncompressed use: Image |
| # If using an appended DT, append '-dtb' |
| # to the end of the image name. |
| # For example, for ARM devices, |
| # use zImage-dtb instead of zImage. |
| # |
| # KERNEL_TOOLCHAIN_PREFIX = Overrides TARGET_KERNEL_CROSS_COMPILE_PREFIX, |
| # Set this var in shell to override |
| # toolchain specified in BoardConfig.mk |
| # KERNEL_TOOLCHAIN = Path to toolchain, if unset, assumes |
| # TARGET_KERNEL_CROSS_COMPILE_PREFIX |
| # is in PATH |
| # |
| # KERNEL_CC = The C Compiler used. This is automatically set based |
| # on whether the clang version is set, optional. |
| # |
| # KERNEL_CLANG_TRIPLE = Target triple for clang (e.g. aarch64-linux-gnu-) |
| # defaults to arm-linux-gnu- for arm |
| # aarch64-linux-gnu- for arm64 |
| # x86_64-linux-gnu- for x86 |
| # |
| # USE_CCACHE = Enable ccache (global Android flag) |
| # |
| # NEED_KERNEL_MODULE_ROOT = Optional, if true, install kernel |
| # modules in root instead of system |
| |
| ifneq ($(TARGET_NO_KERNEL),true) |
| |
| TARGET_AUTO_KDIR := $(shell echo $(TARGET_DEVICE_DIR) | sed -e 's/^device/kernel/g') |
| |
| ## Externally influenced variables |
| # kernel location - optional, defaults to kernel/<vendor>/<device> |
| TARGET_KERNEL_SOURCE ?= $(TARGET_AUTO_KDIR) |
| KERNEL_SRC := $(TARGET_KERNEL_SOURCE) |
| # kernel configuration - mandatory |
| KERNEL_DEFCONFIG := $(TARGET_KERNEL_CONFIG) |
| VARIANT_DEFCONFIG := $(TARGET_KERNEL_VARIANT_CONFIG) |
| SELINUX_DEFCONFIG := $(TARGET_KERNEL_SELINUX_CONFIG) |
| |
| ## Internal variables |
| KERNEL_OUT := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ |
| KERNEL_CONFIG := $(KERNEL_OUT)/.config |
| |
| TARGET_KERNEL_ARCH := $(strip $(TARGET_KERNEL_ARCH)) |
| ifeq ($(TARGET_KERNEL_ARCH),) |
| KERNEL_ARCH := $(TARGET_ARCH) |
| else |
| KERNEL_ARCH := $(TARGET_KERNEL_ARCH) |
| endif |
| |
| ifeq ($(KERNEL_ARCH),x86_64) |
| KERNEL_DEFCONFIG_ARCH := x86 |
| else |
| KERNEL_DEFCONFIG_ARCH := $(KERNEL_ARCH) |
| endif |
| KERNEL_DEFCONFIG_SRC := $(KERNEL_SRC)/arch/$(KERNEL_DEFCONFIG_ARCH)/configs/$(KERNEL_DEFCONFIG) |
| |
| ifeq ($(BOARD_KERNEL_IMAGE_NAME),) |
| $(error BOARD_KERNEL_IMAGE_NAME not defined.) |
| endif |
| ifneq ($(TARGET_USES_UNCOMPRESSED_KERNEL),) |
| $(error TARGET_USES_UNCOMPRESSED_KERNEL is deprecated.) |
| endif |
| ifneq ($(TARGET_KERNEL_APPEND_DTB),) |
| $(error TARGET_KERNEL_APPEND_DTB is deprecated.) |
| endif |
| TARGET_PREBUILT_INT_KERNEL := $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/$(BOARD_KERNEL_IMAGE_NAME) |
| |
| # Clear this first to prevent accidental poisoning from env |
| MAKE_FLAGS := |
| |
| ifeq ($(KERNEL_ARCH),arm) |
| # Avoid "Unknown symbol _GLOBAL_OFFSET_TABLE_" errors |
| MAKE_FLAGS += CFLAGS_MODULE="-fno-pic" |
| endif |
| |
| ifeq ($(KERNEL_ARCH),arm64) |
| # Avoid "unsupported RELA relocation: 311" errors (R_AARCH64_ADR_GOT_PAGE) |
| MAKE_FLAGS += CFLAGS_MODULE="-fno-pic" |
| ifeq ($(TARGET_ARCH),arm) |
| KERNEL_CONFIG_OVERRIDE := CONFIG_ANDROID_BINDER_IPC_32BIT=y |
| endif |
| endif |
| |
| ifneq ($(TARGET_KERNEL_ADDITIONAL_CONFIG),) |
| KERNEL_ADDITIONAL_CONFIG := $(TARGET_KERNEL_ADDITIONAL_CONFIG) |
| KERNEL_ADDITIONAL_CONFIG_SRC := $(KERNEL_SRC)/arch/$(KERNEL_ARCH)/configs/$(KERNEL_ADDITIONAL_CONFIG) |
| ifeq ("$(wildcard $(KERNEL_ADDITIONAL_CONFIG_SRC))","") |
| $(warning TARGET_KERNEL_ADDITIONAL_CONFIG '$(TARGET_KERNEL_ADDITIONAL_CONFIG)' doesn't exist) |
| KERNEL_ADDITIONAL_CONFIG_SRC := /dev/null |
| endif |
| else |
| KERNEL_ADDITIONAL_CONFIG_SRC := /dev/null |
| endif |
| |
| ifeq "$(wildcard $(KERNEL_SRC) )" "" |
| ifneq ($(TARGET_PREBUILT_KERNEL),) |
| HAS_PREBUILT_KERNEL := true |
| NEEDS_KERNEL_COPY := true |
| else |
| $(foreach cf,$(PRODUCT_COPY_FILES), \ |
| $(eval _src := $(call word-colon,1,$(cf))) \ |
| $(eval _dest := $(call word-colon,2,$(cf))) \ |
| $(ifeq kernel,$(_dest), \ |
| $(eval HAS_PREBUILT_KERNEL := true))) |
| endif |
| |
| ifneq ($(HAS_PREBUILT_KERNEL),) |
| $(warning ***************************************************************) |
| $(warning * Using prebuilt kernel binary instead of source *) |
| $(warning * THIS IS DEPRECATED, AND WILL BE DISCONTINUED *) |
| $(warning * Please configure your device to download the kernel *) |
| $(warning * source repository to $(KERNEL_SRC)) |
| $(warning * for more information *) |
| $(warning ***************************************************************) |
| FULL_KERNEL_BUILD := false |
| KERNEL_BIN := $(TARGET_PREBUILT_KERNEL) |
| else |
| $(warning ***************************************************************) |
| $(warning * *) |
| $(warning * No kernel source found, and no fallback prebuilt defined. *) |
| $(warning * Please make sure your device is properly configured to *) |
| $(warning * download the kernel repository to $(KERNEL_SRC)) |
| $(warning * and add the TARGET_KERNEL_CONFIG variable to BoardConfig.mk *) |
| $(warning * *) |
| $(warning * As an alternative, define the TARGET_PREBUILT_KERNEL *) |
| $(warning * variable with the path to the prebuilt binary kernel image *) |
| $(warning * in your BoardConfig.mk file *) |
| $(warning * *) |
| $(warning ***************************************************************) |
| $(error "NO KERNEL") |
| endif |
| else |
| NEEDS_KERNEL_COPY := true |
| ifeq ($(TARGET_KERNEL_CONFIG),) |
| $(warning **********************************************************) |
| $(warning * Kernel source found, but no configuration was defined *) |
| $(warning * Please add the TARGET_KERNEL_CONFIG variable to your *) |
| $(warning * BoardConfig.mk file *) |
| $(warning **********************************************************) |
| # $(error "NO KERNEL CONFIG") |
| else |
| #$(info Kernel source found, building it) |
| FULL_KERNEL_BUILD := true |
| KERNEL_BIN := $(TARGET_PREBUILT_INT_KERNEL) |
| endif |
| endif |
| |
| ifeq ($(FULL_KERNEL_BUILD),true) |
| |
| KERNEL_HEADERS_INSTALL_DIR := $(KERNEL_OUT)/usr |
| KERNEL_HEADERS_INSTALL_DEPS := $(KERNEL_OUT)/.headers_install_deps |
| |
| ifeq ($(NEED_KERNEL_MODULE_ROOT),true) |
| KERNEL_MODULES_INSTALL := root |
| KERNEL_MODULES_OUT := $(TARGET_ROOT_OUT)/lib/modules |
| KERNEL_DEPMOD_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_recovery) |
| KERNEL_MODULE_MOUNTPOINT := |
| else |
| KERNEL_MODULES_INSTALL := $(TARGET_COPY_OUT_VENDOR) |
| KERNEL_MODULES_OUT := $(TARGET_OUT_VENDOR)/lib/modules |
| KERNEL_DEPMOD_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor) |
| KERNEL_MODULE_MOUNTPOINT := vendor |
| endif |
| |
| TARGET_KERNEL_CROSS_COMPILE_PREFIX := $(strip $(TARGET_KERNEL_CROSS_COMPILE_PREFIX)) |
| ifneq ($(TARGET_KERNEL_CROSS_COMPILE_PREFIX),) |
| KERNEL_TOOLCHAIN_PREFIX ?= $(TARGET_KERNEL_CROSS_COMPILE_PREFIX) |
| else ifeq ($(KERNEL_ARCH),arm64) |
| KERNEL_TOOLCHAIN_PREFIX ?= aarch64-linux-androidkernel- |
| else ifeq ($(KERNEL_ARCH),arm) |
| KERNEL_TOOLCHAIN_PREFIX ?= arm-linux-androidkernel- |
| else ifeq ($(KERNEL_ARCH),x86) |
| KERNEL_TOOLCHAIN_PREFIX ?= x86_64-linux-androidkernel- |
| endif |
| |
| ifeq ($(KERNEL_TOOLCHAIN),) |
| KERNEL_TOOLCHAIN_PATH := $(KERNEL_TOOLCHAIN_PREFIX) |
| else |
| ifneq ($(KERNEL_TOOLCHAIN_PREFIX),) |
| KERNEL_TOOLCHAIN_PATH := $(KERNEL_TOOLCHAIN)/$(KERNEL_TOOLCHAIN_PREFIX) |
| endif |
| endif |
| |
| ifeq ($(TARGET_KERNEL_CLANG_COMPILE),true) |
| ifneq ($(TARGET_KERNEL_CLANG_VERSION),) |
| # Find the clang-* directory containing the specified version |
| KERNEL_CLANG_VERSION := $(shell find $(ANDROID_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') |
| else |
| # Only set the latest version of clang if TARGET_KERNEL_CLANG_VERSION hasn't been set by the device config |
| KERNEL_CLANG_VERSION := $(shell ls -d $(ANDROID_BUILD_TOP)/prebuilts/clang/host/$(HOST_OS)-x86/clang-* | xargs -n 1 basename | tail -1) |
| endif |
| TARGET_KERNEL_CLANG_PATH ?= $(ANDROID_BUILD_TOP)/prebuilts/clang/host/$(HOST_OS)-x86/$(KERNEL_CLANG_VERSION)/bin |
| ifeq ($(KERNEL_ARCH),arm64) |
| KERNEL_CLANG_TRIPLE ?= CLANG_TRIPLE=aarch64-linux-gnu- |
| else ifeq ($(KERNEL_ARCH),arm) |
| KERNEL_CLANG_TRIPLE ?= CLANG_TRIPLE=arm-linux-gnu- |
| else ifeq ($(KERNEL_ARCH),x86) |
| KERNEL_CLANG_TRIPLE ?= CLANG_TRIPLE=x86_64-linux-gnu- |
| endif |
| endif |
| |
| ifneq ($(USE_CCACHE),) |
| # Detect if the system already has ccache installed to use instead of the prebuilt |
| ccache := $(shell which ccache) |
| |
| ifeq ($(ccache),) |
| ccache := $(ANDROID_BUILD_TOP)/prebuilts/misc/$(HOST_PREBUILT_TAG)/ccache/ccache |
| # Check that the executable is here. |
| ccache := $(strip $(wildcard $(ccache))) |
| endif |
| endif |
| |
| ifeq ($(TARGET_KERNEL_CLANG_COMPILE),true) |
| KERNEL_CROSS_COMPILE := CROSS_COMPILE="$(KERNEL_TOOLCHAIN_PATH)" |
| KERNEL_CC ?= CC="$(ccache) $(TARGET_KERNEL_CLANG_PATH)/clang" |
| else |
| KERNEL_CROSS_COMPILE := CROSS_COMPILE="$(ccache) $(KERNEL_TOOLCHAIN_PATH)" |
| endif |
| ccache = |
| |
| ifeq ($(HOST_OS),darwin) |
| MAKE_FLAGS += C_INCLUDE_PATH=$(ANDROID_BUILD_TOP)/external/elfutils/libelf:/usr/local/opt/openssl/include |
| MAKE_FLAGS += LIBRARY_PATH=/usr/local/opt/openssl/lib |
| endif |
| |
| ifeq ($(TARGET_KERNEL_MODULES),) |
| TARGET_KERNEL_MODULES := INSTALLED_KERNEL_MODULES |
| endif |
| |
| KERNEL_ADDITIONAL_CONFIG_OUT := $(KERNEL_OUT)/.additional_config |
| |
| .PHONY: force_additional_config |
| $(KERNEL_ADDITIONAL_CONFIG_OUT): force_additional_config |
| $(hide) cmp -s $(KERNEL_ADDITIONAL_CONFIG_SRC) $@ || cp $(KERNEL_ADDITIONAL_CONFIG_SRC) $@; |
| |
| $(KERNEL_CONFIG): $(KERNEL_DEFCONFIG_SRC) $(KERNEL_ADDITIONAL_CONFIG_OUT) |
| @echo "Building Kernel Config" |
| $(hide) mkdir -p $(KERNEL_OUT) |
| $(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) VARIANT_DEFCONFIG=$(VARIANT_DEFCONFIG) SELINUX_DEFCONFIG=$(SELINUX_DEFCONFIG) $(KERNEL_DEFCONFIG) |
| $(hide) if [ ! -z "$(KERNEL_CONFIG_OVERRIDE)" ]; then \ |
| echo "Overriding kernel config with '$(KERNEL_CONFIG_OVERRIDE)'"; \ |
| echo $(KERNEL_CONFIG_OVERRIDE) >> $(KERNEL_OUT)/.config; \ |
| $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) oldconfig; fi |
| # Create defconfig build artifact |
| $(hide) $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) savedefconfig |
| $(hide) if [ ! -z "$(KERNEL_ADDITIONAL_CONFIG)" ]; then \ |
| echo "Using additional config '$(KERNEL_ADDITIONAL_CONFIG)'"; \ |
| $(KERNEL_SRC)/scripts/kconfig/merge_config.sh -m -O $(KERNEL_OUT) $(KERNEL_OUT)/.config $(KERNEL_SRC)/arch/$(KERNEL_ARCH)/configs/$(KERNEL_ADDITIONAL_CONFIG); \ |
| $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) KCONFIG_ALLCONFIG=$(KERNEL_OUT)/.config alldefconfig; fi |
| |
| .PHONY: TARGET_KERNEL_BINARIES |
| TARGET_KERNEL_BINARIES: $(KERNEL_CONFIG) |
| @echo "Building Kernel" |
| $(hide) rm -rf $(KERNEL_MODULES_OUT) |
| $(hide) mkdir -p $(KERNEL_MODULES_OUT) |
| $(hide) rm -rf $(KERNEL_DEPMOD_STAGING_DIR) |
| $(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(BOARD_KERNEL_IMAGE_NAME) |
| $(hide) if grep -q '^CONFIG_OF=y' $(KERNEL_CONFIG); then \ |
| echo "Building DTBs"; \ |
| $(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) dtbs; \ |
| fi |
| $(hide) if grep -q '^CONFIG_MODULES=y' $(KERNEL_CONFIG); then \ |
| echo "Building Kernel Modules"; \ |
| $(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) modules; \ |
| fi |
| |
| .PHONY: INSTALLED_KERNEL_MODULES |
| INSTALLED_KERNEL_MODULES: |
| $(hide) if grep -q '^CONFIG_MODULES=y' $(KERNEL_CONFIG); then \ |
| echo "Installing Kernel Modules"; \ |
| $(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) INSTALL_MOD_PATH=../../$(KERNEL_MODULES_INSTALL) modules_install && \ |
| mofile=$$(find $(KERNEL_MODULES_OUT) -type f -name modules.order) && \ |
| mpath=$$(dirname $$mofile) && \ |
| for f in $$(find $$mpath/kernel -type f -name '*.ko'); do \ |
| $(KERNEL_TOOLCHAIN_PATH)strip --strip-unneeded $$f; \ |
| mv $$f $(KERNEL_MODULES_OUT); \ |
| done && \ |
| rm -rf $$mpath && \ |
| mkdir -p $(KERNEL_DEPMOD_STAGING_DIR)/lib/modules/0.0/$(KERNEL_MODULE_MOUNTPOINT)/lib/modules && \ |
| find $(KERNEL_MODULES_OUT) -name *.ko -exec cp {} $(KERNEL_DEPMOD_STAGING_DIR)/lib/modules/0.0/$(KERNEL_MODULE_MOUNTPOINT)/lib/modules \; && \ |
| $(DEPMOD) -b $(KERNEL_DEPMOD_STAGING_DIR) 0.0 && \ |
| sed -e 's/\(.*modules.*\):/\/\1:/g' -e 's/ \([^ ]*modules[^ ]*\)/ \/\1/g' $(KERNEL_DEPMOD_STAGING_DIR)/lib/modules/0.0/modules.dep > $(KERNEL_MODULES_OUT)/modules.dep; \ |
| fi |
| |
| $(TARGET_KERNEL_MODULES): TARGET_KERNEL_BINARIES |
| |
| $(TARGET_PREBUILT_INT_KERNEL): $(TARGET_KERNEL_MODULES) |
| |
| # Install kernel (uapi) headers. |
| # |
| # The dependency file serves two purposes: |
| # - It is a stamp indicating when the headers were last installed. |
| # - It contains a rule to regenerate itself when any kernel header |
| # files change. This rule is identical to the rule emitted by |
| # GCC using the M/MM flags. |
| # |
| # Note that the location of installed kernel headers changed when the |
| # kernel uapi system was introduced in 3.7. Unfortunately, it is not |
| # sufficient to test whether the uapi directories exist because some |
| # kernels backport patches that contain uapi headers. So we look for |
| # the string "version_h" in the kernel makefile which was introduced |
| # as a part of the uapi system (commit d183e6f570f3). |
| -include $(KERNEL_HEADERS_INSTALL_DEPS) |
| $(KERNEL_HEADERS_INSTALL_DEPS): |
| @echo "Building Kernel Headers" |
| $(hide) mkdir -p $(KERNEL_OUT) |
| $(hide) rm -f $@ |
| $(hide) $(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) headers_install |
| $(hide) echo "$@: \\" > $@ |
| $(hide) ( cd $(KERNEL_SRC); \ |
| if grep -q '^version_h' 'Makefile'; then \ |
| depdirs="arch/$(KERNEL_ARCH)/include/uapi include/uapi"; \ |
| else \ |
| depdirs="arch/$(KERNEL_ARCH)/include/asm include"; \ |
| fi; \ |
| deps="Makefile $$(find $$depdirs -type f -name '*.h')"; \ |
| for f in $$deps; do \ |
| echo " $(KERNEL_SRC)/$$f \\" >> $@; \ |
| done ; \ |
| echo "" >> $@ ; \ |
| for f in $$deps; do \ |
| echo "$(KERNEL_SRC)/$$f:" >> $@; \ |
| echo "" >> $@; \ |
| done \ |
| ) |
| |
| .PHONY: INSTALLED_KERNEL_HEADERS |
| INSTALLED_KERNEL_HEADERS: $(KERNEL_HEADERS_INSTALL_DEPS) |
| |
| # Dependencies on $(KERNEL_OUT)/usr are deprecated |
| $(KERNEL_HEADERS_INSTALL_DIR): $(KERNEL_HEADERS_INSTALL_DEPS) |
| @echo "Depending on $(KERNEL_HEADERS_INSTALL_DIR) is deprecated." 1>&2 |
| @echo "Use INSTALLED_KERNEL_HEADERS instead." 1>&2 |
| @exit 1 |
| |
| .PHONY: kerneltags |
| kerneltags: $(KERNEL_CONFIG) |
| $(hide) mkdir -p $(KERNEL_OUT) |
| $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) tags |
| |
| .PHONY: kernelconfig kernelxconfig kernelsavedefconfig alldefconfig |
| |
| kernelconfig: KERNELCONFIG_MODE := menuconfig |
| kernelxconfig: KERNELCONFIG_MODE := xconfig |
| kernelxconfig kernelconfig: |
| $(hide) mkdir -p $(KERNEL_OUT) |
| $(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(KERNEL_DEFCONFIG) |
| env KCONFIG_NOTIMESTAMP=true \ |
| $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(KERNELCONFIG_MODE) |
| env KCONFIG_NOTIMESTAMP=true \ |
| $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) savedefconfig |
| cp $(KERNEL_OUT)/defconfig $(KERNEL_DEFCONFIG_SRC) |
| |
| kernelsavedefconfig: |
| $(hide) mkdir -p $(KERNEL_OUT) |
| $(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(KERNEL_DEFCONFIG) |
| env KCONFIG_NOTIMESTAMP=true \ |
| $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) savedefconfig |
| cp $(KERNEL_OUT)/defconfig $(KERNEL_DEFCONFIG_SRC) |
| |
| alldefconfig: |
| $(hide) mkdir -p $(KERNEL_OUT) |
| env KCONFIG_NOTIMESTAMP=true \ |
| $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) alldefconfig |
| |
| endif # FULL_KERNEL_BUILD |
| |
| TARGET_PREBUILT_DTBO = $(PRODUCT_OUT)/dtbo/arch/$(KERNEL_ARCH)/boot/dtbo.img |
| $(TARGET_PREBUILT_DTBO): $(AVBTOOL) |
| echo -e ${CL_GRN}"Building DTBO.img"${CL_RST} |
| $(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(PRODUCT_OUT)/dtbo ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(KERNEL_DEFCONFIG) |
| $(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(PRODUCT_OUT)/dtbo ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) dtbo.img |
| $(AVBTOOL) add_hash_footer \ |
| --image $@ \ |
| --partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \ |
| --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \ |
| $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS) |
| |
| ## Install it |
| |
| ifeq ($(NEEDS_KERNEL_COPY),true) |
| file := $(INSTALLED_KERNEL_TARGET) |
| ALL_PREBUILT += $(file) |
| $(file) : $(KERNEL_BIN) | $(ACP) |
| $(transform-prebuilt-to-target) |
| |
| ALL_PREBUILT += $(INSTALLED_KERNEL_TARGET) |
| endif |
| |
| ifeq ($(TARGET_NEEDS_DTBOIMAGE),true) |
| file := $(INSTALLED_DTBOIMAGE_TARGET) |
| ALL_PREBUILT += $(file) |
| $(file) : $(TARGET_PREBUILT_DTBO) | $(ACP) |
| $(transform-prebuilt-to-target) |
| |
| ALL_PREBUILT += $(INSTALLED_DTBOIMAGE_TARGET) |
| endif |
| |
| .PHONY: kernel |
| kernel: $(INSTALLED_KERNEL_TARGET) |
| |
| .PHONY: dtbo |
| dtbo: $(INSTALLED_DTBOIMAGE_TARGET) |
| |
| endif # TARGET_NO_KERNEL |