diff --git a/Kconfig b/Kconfig index 75fb259853..f8b316c30e 100644 --- a/Kconfig +++ b/Kconfig @@ -33,6 +33,10 @@ rsource "drivers/Kconfig" rsource "sys/Kconfig" rsource "pkg/Kconfig" +menu "External Modules" +osource "$(KCONFIG_EXTERNAL_CONFIGS)" +endmenu # External Modules + comment "RIOT is in a migration phase." comment "Some configuration options may not be here. Use CFLAGS instead." diff --git a/makefiles/kconfig.mk b/makefiles/kconfig.mk index 42bfafbe6d..02f5701359 100644 --- a/makefiles/kconfig.mk +++ b/makefiles/kconfig.mk @@ -26,6 +26,9 @@ export KCONFIG_AUTOHEADER_HEADER # This file will contain the calculated dependencies formated in Kconfig export KCONFIG_GENERATED_DEPENDENCIES = $(GENERATED_DIR)/Kconfig.dep +# This file will contain external module configurations +export KCONFIG_EXTERNAL_CONFIGS = $(GENERATED_DIR)/Kconfig.external_modules + # This file will contain application default configurations KCONFIG_APP_CONFIG = $(APPDIR)/app.config @@ -140,6 +143,23 @@ $(KCONFIG_GENERATED_DEPENDENCIES): FORCE | $(GENERATED_DIR) printf "config %s\n\tbool\n\tdefault y\n", toupper($$0)}' \ | $(LAZYSPONGE) $(LAZYSPONGE_FLAGS) $@ +# All directories in EXTERNAL_MODULES_DIR which have a Kconfig file +EXTERNAL_MODULE_KCONFIGS ?= $(sort $(foreach dir,$(EXTERNAL_MODULE_DIRS),\ + $(wildcard $(dir)/Kconfig))) +# Build a Kconfig file that source all external modules configuration +# files. Every EXTERNAL_MODULE_DIRS with a Kconfig file is written to +# KCONFIG_EXTERNAL_CONFIGS as 'osource dir/Kconfig' +$(KCONFIG_EXTERNAL_CONFIGS): FORCE | $(GENERATED_DIR) + $(Q)\ + if [ -n "$(EXTERNAL_MODULE_KCONFIGS)" ] ; then \ + printf "%s\n" $(EXTERNAL_MODULE_KCONFIGS) \ + | awk '{ printf "osource \"%s\"\n", $$0 }' \ + | $(LAZYSPONGE) $(LAZYSPONGE_FLAGS) $@ ; \ + else \ + printf "# no external modules" \ + | $(LAZYSPONGE) $(LAZYSPONGE_FLAGS) $@ ; \ + fi + # When the 'clean' target is called, the files inside GENERATED_DIR should be # regenerated. For that, we conditionally change GENERATED_DIR from an 'order # only' requisite to a normal one. @@ -156,6 +176,7 @@ GENERATED_DIR_DEP := $(if $(CLEAN),,|) $(GENERATED_DIR) # Generates a .config file by merging multiple sources specified in # MERGE_SOURCES. This will also generate KCONFIG_OUT_DEP with the list of used # Kconfig files. +$(KCONFIG_OUT_CONFIG): $(KCONFIG_EXTERNAL_CONFIGS) $(KCONFIG_OUT_CONFIG): $(GENERATED_DEPENDENCIES_DEP) $(GENCONFIG) $(MERGE_SOURCES) $(GENERATED_DIR_DEP) $(Q) $(GENCONFIG) \ --config-out=$(KCONFIG_OUT_CONFIG) \