diff --git a/Makefile.include b/Makefile.include index 0e66ee4a6e49..f5515c2ceaff 100644 --- a/Makefile.include +++ b/Makefile.include @@ -46,6 +46,8 @@ RIOTCPU ?= $(RIOTBASE)/cpu # Deprecated to set RIOTBOARD, use EXTERNAL_BOARD_DIRS RIOTBOARD ?= $(RIOTBASE)/boards EXTERNAL_BOARD_DIRS ?= +MODULE_DIRS := $(RIOTBASE)/drivers +MODULE_DIRS += $(RIOTBASE)/sys RIOTMAKE ?= $(RIOTBASE)/makefiles RIOTPKG ?= $(RIOTBASE)/pkg RIOTTOOLS ?= $(RIOTBASE)/dist/tools @@ -149,6 +151,7 @@ EXTERNAL_BOARD_DIRS := $(foreach dir,\ EXTERNAL_MODULE_DIRS := $(foreach dir,\ $(EXTERNAL_MODULE_DIRS),\ $(abspath $(dir))) +MODULE_DIRS := $(foreach dir,$(MODULE_DIRS),$(abspath $(dir))) # Ensure that all directories are set and don't contain spaces. ifneq (, $(filter-out 1, $(foreach v,$(__DIRECTORY_VARIABLES),$(words $($(v)))))) @@ -403,6 +406,8 @@ ifeq (1,$(TEST_KCONFIG)) USEMODULE := $(KCONFIG_MODULES) KCONFIG_PACKAGES := $(call lowercase,$(patsubst CONFIG_PACKAGE_%,%,$(filter CONFIG_PACKAGE_%,$(.VARIABLES)))) USEPKG := $(KCONFIG_PACKAGES) + # auto-locate modules + include $(RIOTMAKE)/locate_modules.inc.mk else # check if required features are provided and update $(FEATURES_USED) include $(RIOTMAKE)/features_check.inc.mk @@ -619,8 +624,8 @@ endif # We assume $(LINK) to be gcc-like. Use `LINKFLAGPREFIX :=` for ld-like linker options. LINKFLAGPREFIX ?= -Wl, -# Also build external modules -DIRS += $(EXTERNAL_MODULE_PATHS) +# Also build automatically located modules +DIRS += $(EXTERNAL_MODULE_PATHS) $(MODULE_PATHS) # Define dependencies required for building (headers, downloading source files,) BUILDDEPS += $(RIOTBUILD_CONFIG_HEADER_C) diff --git a/drivers/Makefile b/drivers/Makefile index 13612d5cdb3c..3d513f9ea069 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -1,5 +1,3 @@ -DIRS += $(dir $(wildcard $(addsuffix /Makefile, $(USEMODULE)))) - ifneq (,$(filter saul_init_devs,$(USEMODULE))) DIRS += saul/init_devs endif diff --git a/makefiles/dependency_resolution.inc.mk b/makefiles/dependency_resolution.inc.mk index a3a76223c223..b740a3f3745f 100644 --- a/makefiles/dependency_resolution.inc.mk +++ b/makefiles/dependency_resolution.inc.mk @@ -2,9 +2,8 @@ # until no new modules, pkgs, or features are pull in order to catch all # transient dependencies -# Locate used modules in $(EXTERNAL_MODULE_DIRS). -EXTERNAL_MODULE_PATHS := $(sort $(foreach dir,$(EXTERNAL_MODULE_DIRS),\ - $(foreach mod,$(USEMODULE),$(dir $(wildcard $(dir)/$(mod)/Makefile))))) +# auto-locate modules +include $(RIOTMAKE)/locate_modules.inc.mk # Back up current state to detect changes OLD_STATE := $(USEMODULE) $(USEPKG) $(FEATURES_USED) diff --git a/makefiles/locate_modules.inc.mk b/makefiles/locate_modules.inc.mk new file mode 100644 index 000000000000..21d64af768d6 --- /dev/null +++ b/makefiles/locate_modules.inc.mk @@ -0,0 +1,11 @@ +# Only locate non-pseudo-modules +MODS2LOCATE := $(filter-out $(PSEUDOMODULES) $(NO_AUTOLOCATE),\ + $(USEMODULE)) $(filter $(NO_PSEUDOMODULES),$(USEMODULE)) +EXTERNAL_MODULE_PATHS := $(sort $(foreach dir,$(EXTERNAL_MODULE_DIRS),\ +$(foreach mod,$(MODS2LOCATE),$(dir $(wildcard $(dir)/$(mod)/Makefile))))) + +# Ignore modules already located as external modules +MODS2LOCATE := $(filter-out $(basename $(EXTERNAL_MODULE_PATHS)),$(MODS2LOCATE)) + +MODULE_PATHS := $(sort $(foreach dir,$(MODULE_DIRS),\ + $(foreach mod,$(MODS2LOCATE),$(dir $(wildcard $(dir)/$(mod)/Makefile))))) diff --git a/sys/Makefile b/sys/Makefile index fc5c0633c238..68c536451260 100644 --- a/sys/Makefile +++ b/sys/Makefile @@ -23,9 +23,6 @@ endif ifneq (,$(filter cord_lc,$(USEMODULE))) DIRS += net/application_layer/cord/lc endif -ifneq (,$(filter cpp11-compat,$(USEMODULE))) - DIRS += cpp11-compat -endif ifneq (,$(filter credman,$(USEMODULE))) DIRS += net/credman endif @@ -41,9 +38,6 @@ endif ifneq (,$(filter dummy_thread,$(USEMODULE))) DIRS += test_utils/dummy_thread endif -ifneq (,$(filter eepreg,$(USEMODULE))) - DIRS += eepreg -endif ifneq (,$(filter emcute,$(USEMODULE))) DIRS += net/application_layer/emcute endif @@ -89,9 +83,6 @@ endif ifneq (,$(filter l2util,$(USEMODULE))) DIRS += net/link_layer/l2util endif -ifneq (,$(filter log_%,$(USEMODULE))) - DIRS += log -endif ifneq (,$(filter nanocoap,$(USEMODULE))) DIRS += net/application_layer/nanocoap endif @@ -110,12 +101,6 @@ endif ifneq (,$(filter netstats_neighbor,$(USEMODULE))) DIRS += net/netstats endif -ifneq (,$(filter sema,$(USEMODULE))) - DIRS += sema -endif -ifneq (,$(filter sema_inv,$(USEMODULE))) - DIRS += sema_inv -endif ifneq (,$(filter sixlowpan,$(USEMODULE))) DIRS += net/network_layer/sixlowpan endif @@ -131,9 +116,6 @@ endif ifneq (,$(filter sock_util,$(USEMODULE))) DIRS += net/sock endif -ifneq (,$(filter oneway_malloc,$(USEMODULE))) - DIRS += oneway-malloc -endif ifneq (,$(filter posix_inet,$(USEMODULE))) DIRS += posix/inet endif @@ -161,12 +143,6 @@ endif ifneq (,$(filter shell_commands,$(USEMODULE))) DIRS += shell/commands endif -ifneq (,$(filter suit%,$(USEMODULE))) - DIRS += suit -endif -ifneq (,$(filter sys_bus,$(USEMODULE))) - DIRS += bus -endif ifneq (,$(filter tcp,$(USEMODULE))) DIRS += net/transport_layer/tcp endif @@ -188,10 +164,5 @@ endif ifneq (,$(filter ztimer_core,$(USEMODULE))) DIRS += ztimer endif -ifneq (,$(filter ztimer_xtimer_compat,$(USEMODULE))) - FILTER += xtimer -endif - -DIRS += $(dir $(wildcard $(addsuffix /Makefile, $(filter-out $(FILTER), $(USEMODULE))))) include $(RIOTBASE)/Makefile.base diff --git a/sys/Makefile.dep b/sys/Makefile.dep index 73b0fa818b61..92d85de4cfef 100644 --- a/sys/Makefile.dep +++ b/sys/Makefile.dep @@ -698,6 +698,7 @@ ifneq (,$(filter xtimer,$(USEMODULE))) endif else # ztimer_xtimer_compat is used, all of *xtimer's API will be mapped on ztimer.* + NO_AUTOLOCATE += xtimer endif endif diff --git a/sys/bus/Makefile b/sys/sys_bus/Makefile similarity index 65% rename from sys/bus/Makefile rename to sys/sys_bus/Makefile index d66bde0cec91..48422e909a47 100644 --- a/sys/bus/Makefile +++ b/sys/sys_bus/Makefile @@ -1,3 +1 @@ -MODULE = sys_bus - include $(RIOTBASE)/Makefile.base diff --git a/sys/bus/sys_bus_init.c b/sys/sys_bus/sys_bus_init.c similarity index 100% rename from sys/bus/sys_bus_init.c rename to sys/sys_bus/sys_bus_init.c