diff --git a/makefiles/default_modules.deps.mk b/makefiles/default_modules.deps.mk new file mode 100644 index 000000000000..fb86b1c6b6c5 --- /dev/null +++ b/makefiles/default_modules.deps.mk @@ -0,0 +1,11 @@ +# This files contains dependencies for default modules. They are parsed at the +# end of the dependency loop. They MAY inlcude new modules, but this modules +# MUST NOT have dependencies themselfs. + +ifneq (,$(filter auto_init_ztimer,$(USEMODULE))) + USEMODULE += ztimer_init +endif + +ifneq (,$(filter auto_init_saul,$(USEMODULE))) + USEMODULE += saul_init_devs +endif diff --git a/makefiles/defaultmodules.inc.mk b/makefiles/defaultmodules.inc.mk index f0bc0f9bad47..65ab1286067b 100644 --- a/makefiles/defaultmodules.inc.mk +++ b/makefiles/defaultmodules.inc.mk @@ -1,10 +1,5 @@ DEFAULT_MODULE += board cpu core core_init core_msg core_panic sys -DEFAULT_MODULE += auto_init - -# Initialize all used peripherals by default -DEFAULT_MODULE += periph_init - # Include potentially added default modules by the board -include $(BOARDDIR)/Makefile.default diff --git a/makefiles/dependency_resolution.inc.mk b/makefiles/dependency_resolution.inc.mk index 9fde1a721239..e0db0f771ce7 100644 --- a/makefiles/dependency_resolution.inc.mk +++ b/makefiles/dependency_resolution.inc.mk @@ -35,15 +35,27 @@ NEW_STATE := $(USEMODULE) $(USEPKG) $(FEATURES_USED) ifneq ($(OLD_STATE),$(NEW_STATE)) include $(RIOTMAKE)/dependency_resolution.inc.mk else + # Include late allowing them to have been disabled during dependency resolution + DEFAULT_MODULE += auto_init periph_init + USEMODULE += $(filter-out $(DISABLE_MODULE),auto_init periph_init) + # If module auto_init is not used, silently disable all of its submodules ifeq (,$(filter auto_init,$(USEMODULE))) DISABLE_MODULE += auto_init_% endif - # add default modules again, as $(DEFAULT_MODULE) might have been extended - # during dependency processing + # If module periph_init is not used, silently disable all of its submodules + ifeq (,$(filter periph_init,$(USEMODULE))) + DISABLE_MODULE += periph_init_% + endif + + # Add default modules again, as $(DEFAULT_MODULE) might have been extended + # during dependency resolution USEMODULE += $(filter-out $(DISABLE_MODULE),$(DEFAULT_MODULE)) + # Include eventual dependencies for default modules + include $(RIOTMAKE)/default_modules.deps.mk + # Sort and de-duplicate used modules and default modules for readability USEMODULE := $(sort $(USEMODULE)) DEFAULT_MODULE := $(sort $(DEFAULT_MODULE)) diff --git a/makefiles/features_modules.inc.mk b/makefiles/features_modules.inc.mk index 3fb6eccf6f52..d6afe8b38449 100644 --- a/makefiles/features_modules.inc.mk +++ b/makefiles/features_modules.inc.mk @@ -10,32 +10,30 @@ PERIPH_FEATURES := $(filter periph_%,$(FEATURES_USED)) USEMODULE += $(PERIPH_FEATURES) # Add all USED periph_% init modules unless they are blacklisted -ifneq (,$(filter periph_init, $(USEMODULE))) - PERIPH_IGNORE_MODULES := \ - periph_init% \ - periph_common \ - periph_flexcomm \ - periph_gpio_mux \ - periph_i2c_hw \ - periph_i2c_sw \ - periph_rtc_ms \ - periph_mcg \ - periph_wdog \ - periph_flash \ - periph_rtc_rtt \ - periph_rtt_hw_rtc \ - periph_rtt_hw_sys \ - periph_clic \ - periph_coretimer \ - periph_plic \ - periph_spi_on_qspi - # - PERIPH_MODULES := $(filter-out $(PERIPH_IGNORE_MODULES),\ - $(filter periph_%,$(USEMODULE))) - # Use simple expansion to avoid USEMODULE referencing itself - PERIPH_INIT_MODULES := $(subst periph_,periph_init_,$(PERIPH_MODULES)) - DEFAULT_MODULE += $(PERIPH_INIT_MODULES) -endif +PERIPH_IGNORE_MODULES := \ + periph_init% \ + periph_common \ + periph_flexcomm \ + periph_gpio_mux \ + periph_i2c_hw \ + periph_i2c_sw \ + periph_rtc_ms \ + periph_mcg \ + periph_wdog \ + periph_flash \ + periph_rtc_rtt \ + periph_rtt_hw_rtc \ + periph_rtt_hw_sys \ + periph_clic \ + periph_coretimer \ + periph_plic \ + periph_spi_on_qspi + # +PERIPH_MODULES := $(filter-out $(PERIPH_IGNORE_MODULES),\ + $(filter periph_%,$(USEMODULE))) +# Use simple expansion to avoid USEMODULE referencing itself +PERIPH_INIT_MODULES := $(subst periph_,periph_init_,$(PERIPH_MODULES)) +DEFAULT_MODULE += $(PERIPH_INIT_MODULES) # select cpu_check_address pseudomodule if the corresponding feature is used USEMODULE += $(filter cpu_check_address, $(FEATURES_USED)) diff --git a/sys/Makefile.dep b/sys/Makefile.dep index 53fd1ad29ba1..964c7007ae72 100644 --- a/sys/Makefile.dep +++ b/sys/Makefile.dep @@ -88,10 +88,6 @@ ifneq (,$(filter base64url,$(USEMODULE))) USEMODULE += base64 endif -ifneq (,$(filter auto_init_saul,$(USEMODULE))) - USEMODULE += saul_init_devs -endif - ifneq (,$(filter csma_sender,$(USEMODULE))) USEMODULE += random USEMODULE += xtimer @@ -115,15 +111,12 @@ ifneq (,$(filter dhcpv6_client,$(USEMODULE))) endif ifneq (,$(filter dhcpv6_relay,$(USEMODULE))) + DEFAULT_MODULE += auto_init_dhcpv6_relay USEMODULE += event USEMODULE += sock_async_event USEMODULE += sock_udp endif -ifneq (,$(filter auto_init_dhcpv6_relay,$(USEMODULE))) - USEMODULE += dhcpv6_relay -endif - ifneq (,$(filter dns_%,$(USEMODULE))) USEMODULE += dns endif diff --git a/sys/ztimer/Makefile.dep b/sys/ztimer/Makefile.dep index d75d73e91cd2..009271e26308 100644 --- a/sys/ztimer/Makefile.dep +++ b/sys/ztimer/Makefile.dep @@ -7,9 +7,6 @@ ifneq (,$(filter ztimer,$(USEMODULE))) USEMODULE += ztimer_core USEMODULE += ztimer_convert_frac USEMODULE += ztimer_convert_shift - ifneq (,$(filter auto_init_ztimer,$(USEMODULE))) - USEMODULE += ztimer_init - endif DEFAULT_MODULE += auto_init_ztimer DEFAULT_MODULE += ztimer_init endif diff --git a/tests/gnrc_dhcpv6_relay/Makefile b/tests/gnrc_dhcpv6_relay/Makefile index b9cd770f0212..bf1fce0cc015 100644 --- a/tests/gnrc_dhcpv6_relay/Makefile +++ b/tests/gnrc_dhcpv6_relay/Makefile @@ -4,7 +4,7 @@ RIOTBASE ?= $(CURDIR)/../.. export TAP ?= tap0 -USEMODULE += auto_init_dhcpv6_relay +USEMODULE += dhcpv6_relay USEMODULE += event_thread USEMODULE += gnrc_ipv6_default USEMODULE += gnrc_netif_single # Only one interface used and it makes