kernel: prevent additional config from being always rebuilt
* A simple "make kernel" or incremental system build
always triggers a complete kernel recompilation,
even though the kernel sources were unchanged
* The reason is because .additional_config is always
considered new and invalidates the .config file,
forcing the kernel to rebuild itself every time
* Instead, prevent the /dev/null and KERNEL_OBJ dependencies
having irrelevant timestamp changes with an empty variable
* Command "make kernel" takes 3 seconds versus 40s before
Change-Id: I3b583077b7ef5873eebde3e4b0e790f5d7587ed3
Signed-off-by: Adrian DC <radian.dc@gmail.com>
diff --git a/build/tasks/kernel.mk b/build/tasks/kernel.mk
index bdf264d..23806d9 100644
--- a/build/tasks/kernel.mk
+++ b/build/tasks/kernel.mk
@@ -89,10 +89,13 @@
ifneq ($(TARGET_KERNEL_ADDITIONAL_CONFIG),)
KERNEL_ADDITIONAL_CONFIG := $(TARGET_KERNEL_ADDITIONAL_CONFIG)
+KERNEL_ADDITIONAL_CONFIG_DEPENDENCY :=
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
+ else
+ KERNEL_ADDITIONAL_CONFIG_DEPENDENCY := $(KERNEL_ADDITIONAL_CONFIG_SRC)
endif
else
KERNEL_ADDITIONAL_CONFIG_SRC := /dev/null
@@ -239,10 +242,8 @@
$(call internal-make-kernel-target,$(DTB_OUT),$(1))
endef
-$(KERNEL_OUT):
+$(KERNEL_ADDITIONAL_CONFIG_OUT): $(KERNEL_ADDITIONAL_CONFIG_DEPENDENCY)
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)
@@ -288,13 +289,15 @@
.PHONY: kernelsavedefconfig alldefconfig
-kernelsavedefconfig: $(KERNEL_OUT)
+kernelsavedefconfig:
+ mkdir -p $(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: $(KERNEL_OUT)
+alldefconfig:
+ mkdir -p $(KERNEL_OUT)
env KCONFIG_NOTIMESTAMP=true \
$(call make-kernel-target,alldefconfig)