[PATCH] kconfig: Add support for out-of-tree config fragment and defconfig

Neha Malcom Francis n-francis at ti.com
Wed Nov 5 11:23:16 CET 2025


Add support for fetching config fragments and defconfigs out-of-tree using
CONFIG_FRAGMENT_PATH and CONFIG_DEFCONFIG_PATH respectively.

Signed-off-by: Neha Malcom Francis <n-francis at ti.com>
---
 scripts/kconfig/Makefile | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index f0f93c56bdb..051c801eadb 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -12,6 +12,13 @@ PHONY += xconfig gconfig menuconfig config localmodconfig localyesconfig \
 #  Set SRCARCH to .. fake this Makefile.
 SRCARCH := ..
 
+# If a config fragment file is kept in an out-of-tree path, add it to the list
+# of paths to be searched within
+CONFIG_FRAGMENT_PATH ?= $(srctree)/arch/$(SRCARCH)/configs
+
+# If a defconfig file is kept in an out-of-tree path, pick it from there
+CONFIG_DEFCONFIG_PATH ?= $(srctree)/arch/$(SRCARCH)/configs
+
 ifdef KBUILD_KCONFIG
 Kconfig := $(KBUILD_KCONFIG)
 else
@@ -93,7 +100,7 @@ endif
 endif
 
 %_defconfig: $(obj)/conf
-	$(Q)$(CPP) -nostdinc -P -I $(srctree) -undef -x assembler-with-cpp $(srctree)/arch/$(SRCARCH)/configs/$@ -o generated_defconfig
+	$(Q)$(CPP) -nostdinc -P -I $(srctree) -undef -x assembler-with-cpp $(CONFIG_DEFCONFIG_PATH)/$@ -o generated_defconfig
 	$(Q)sed -i -e 's/^[[:space:]]//' generated_defconfig
 	$(Q)$< $(silent) --defconfig=generated_defconfig $(Kconfig)
 
@@ -103,6 +110,7 @@ endif
 
 configfiles=$(wildcard $(srctree)/kernel/configs/$@ \
 		$(srctree)/arch/$(SRCARCH)/configs/$@ \
+		$(CONFIG_FRAGMENT_PATH)/$@ \
 		$(shell find $(srctree)/board -name "$@"))
 
 %.config: $(obj)/conf
-- 
2.34.1



More information about the U-Boot mailing list