kernel: Fix module installation and clean up

* Fold module installation into kernel image recipe.
 * Specify make argument to strip modules on installation instead of
   explicitly invoking the strip tool.
 * Remove support of TARGET_KERNEL_MODULES, it's a phony target thus
   we're not allowed to depend on it per Android 10 restriction. It
   has been useless for years anyway.
 * Apply minor clean-ups.

Change-Id: I288af1b2f741f524c2ef49554e15cb91c3115209
This commit is contained in:
dianlujitao 2019-09-12 17:37:45 +08:00 committed by Luca Stefani
parent 6802b723a9
commit f30ad9eac7

View file

@ -73,16 +73,12 @@ 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
TARGET_PREBUILT_INT_KERNEL := $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/$(BOARD_KERNEL_IMAGE_NAME)
KERNEL_DEFCONFIG_DIR := $(KERNEL_SRC)/arch/$(KERNEL_DEFCONFIG_ARCH)/configs
KERNEL_DEFCONFIG_SRC := $(KERNEL_DEFCONFIG_DIR)/$(KERNEL_DEFCONFIG)
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)
KERNEL_ADDITIONAL_CONFIG_SRC := $(KERNEL_DEFCONFIG_DIR)/$(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
@ -91,6 +87,11 @@ else
KERNEL_ADDITIONAL_CONFIG_SRC := /dev/null
endif
ifeq ($(BOARD_KERNEL_IMAGE_NAME),)
$(error BOARD_KERNEL_IMAGE_NAME not defined.)
endif
TARGET_PREBUILT_INT_KERNEL := $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/$(BOARD_KERNEL_IMAGE_NAME)
ifeq "$(wildcard $(KERNEL_SRC) )" ""
ifneq ($(TARGET_PREBUILT_KERNEL),)
HAS_PREBUILT_KERNEL := true
@ -161,6 +162,7 @@ KERNEL_MODULE_MOUNTPOINT := vendor
endif
MODULES_INTERMEDIATES := $(KERNEL_BUILD_OUT_PREFIX)$(call intermediates-dir-for,PACKAGING,kernel_modules)
PATH_OVERRIDE :=
ifeq ($(TARGET_KERNEL_CLANG_COMPILE),true)
ifneq ($(TARGET_KERNEL_CLANG_VERSION),)
# Find the clang-* directory containing the specified version
@ -177,14 +179,14 @@ ifeq ($(TARGET_KERNEL_CLANG_COMPILE),true)
else ifeq ($(KERNEL_ARCH),x86)
KERNEL_CLANG_TRIPLE ?= CLANG_TRIPLE=x86_64-linux-gnu-
endif
PATH_OVERRIDE := PATH=$(TARGET_KERNEL_CLANG_PATH)/bin:$$PATH LD_LIBRARY_PATH=$(TARGET_KERNEL_CLANG_PATH)/lib64:$$LD_LIBRARY_PATH
PATH_OVERRIDE += PATH=$(TARGET_KERNEL_CLANG_PATH)/bin:$$PATH LD_LIBRARY_PATH=$(TARGET_KERNEL_CLANG_PATH)/lib64:$$LD_LIBRARY_PATH
ifeq ($(KERNEL_CC),)
KERNEL_CC := CC="$(CCACHE_BIN) clang"
endif
endif
ifeq ($(TARGET_KERNEL_MODULES),)
TARGET_KERNEL_MODULES := INSTALLED_KERNEL_MODULES
ifneq ($(TARGET_KERNEL_MODULES),)
$(error TARGET_KERNEL_MODULES is no longer supported!)
endif
PATH_OVERRIDE += PATH=$(KERNEL_TOOLCHAIN_PATH_gcc)/bin:$$PATH
@ -213,12 +215,14 @@ define make-dtbo-target
$(call internal-make-kernel-target,$(PRODUCT_OUT)/dtbo,$(1))
endef
$(KERNEL_ADDITIONAL_CONFIG_OUT):
$(KERNEL_OUT):
mkdir -p $(KERNEL_OUT)
$(KERNEL_ADDITIONAL_CONFIG_OUT): $(KERNEL_OUT)
$(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)
$(call make-kernel-target,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)'"; \
@ -242,40 +246,27 @@ $(TARGET_PREBUILT_INT_KERNEL): $(KERNEL_CONFIG)
fi
$(hide) if grep -q '=m' $(KERNEL_CONFIG); then \
echo "Building Kernel Modules"; \
$(call make-kernel-target,modules); \
fi
.PHONY: INSTALLED_KERNEL_MODULES
INSTALLED_KERNEL_MODULES: depmod-host
$(hide) if grep -q '=m' $(KERNEL_CONFIG); then \
$(call make-kernel-target,modules) || exit "$$?"; \
echo "Installing Kernel Modules"; \
$(call make-kernel-target,INSTALL_MOD_PATH=$(MODULES_INTERMEDIATES) modules_install); \
$(call make-kernel-target,INSTALL_MOD_PATH=$(MODULES_INTERMEDIATES) INSTALL_MOD_STRIP=1 modules_install); \
kernel_release=$$(cat $(KERNEL_RELEASE)) \
modules=$$(find $(MODULES_INTERMEDIATES)/lib/modules/$$kernel_release -type f -name '*.ko'); \
for f in $$modules; do \
$(KERNEL_TOOLCHAIN_PATH)strip --strip-unneeded $$f; \
done; \
($(call build-image-kernel-modules,$$modules,$(KERNEL_MODULES_OUT),$(KERNEL_MODULE_MOUNTPOINT)/,$(KERNEL_DEPMOD_STAGING_DIR))); \
fi
$(TARGET_KERNEL_MODULES): $(TARGET_PREBUILT_INT_KERNEL)
.PHONY: kerneltags
kerneltags: $(KERNEL_CONFIG)
$(hide) mkdir -p $(KERNEL_OUT)
$(call make-kernel-target,tags)
.PHONY: kernelsavedefconfig alldefconfig
kernelsavedefconfig:
$(hide) mkdir -p $(KERNEL_OUT)
kernelsavedefconfig: $(KERNEL_OUT)
$(call make-kernel-target,$(KERNEL_DEFCONFIG))
env KCONFIG_NOTIMESTAMP=true \
$(call make-kernel-target,savedefconfig)
cp $(KERNEL_OUT)/defconfig $(KERNEL_DEFCONFIG_SRC)
alldefconfig:
$(hide) mkdir -p $(KERNEL_OUT)
alldefconfig: $(KERNEL_OUT)
env KCONFIG_NOTIMESTAMP=true \
$(call make-kernel-target,alldefconfig)
@ -304,7 +295,7 @@ INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
ALL_PREBUILT += $(INSTALLED_DTBOIMAGE_TARGET)
.PHONY: kernel
kernel: $(INSTALLED_KERNEL_TARGET) $(TARGET_KERNEL_MODULES)
kernel: $(INSTALLED_KERNEL_TARGET)
.PHONY: dtboimage
dtboimage: $(INSTALLED_DTBOIMAGE_TARGET)