diff --git a/sys/auto_init/auto_init.c b/sys/auto_init/auto_init.c index 5ab321c1ab..6d1e179f45 100644 --- a/sys/auto_init/auto_init.c +++ b/sys/auto_init/auto_init.c @@ -392,7 +392,7 @@ void auto_init(void) extern void auto_init_random(void); auto_init_random(); } - if (IS_USED(MODULE_ZTIMER)) { + if (IS_USED(MODULE_AUTO_INIT_ZTIMER)) { LOG_DEBUG("Auto init ztimer.\n"); void ztimer_init(void); ztimer_init(); diff --git a/sys/ztimer/Makefile.dep b/sys/ztimer/Makefile.dep index b9e0287fa1..fcfc495b60 100644 --- a/sys/ztimer/Makefile.dep +++ b/sys/ztimer/Makefile.dep @@ -5,10 +5,23 @@ # "ztimer" is the default meta-module of ztimer ifneq (,$(filter ztimer,$(USEMODULE))) - USEMODULE += ztimer_auto_init USEMODULE += ztimer_core USEMODULE += ztimer_convert_frac USEMODULE += ztimer_convert_shift + + # ztimer's auto_init code resides in it's submodule "ztimer_auto_init", + # but RIOT's auto_init scheme expects "auto_init_ztimer" in DEFAULT_MODULES so + # it can be disabled (by adding to DISABLE_MODULES). + # + # "auto_init_%" modules cannot have further dependencies, so we cannot do + # "if auto_init_ztimer: use ztimer_auto_init". + # + # So, if neither "auto_init" nor "auto_init_ztimer" are disabled, pull in + # "ztimer_auto_init". + DEFAULT_MODULE += auto_init_ztimer + ifeq (,$(filter auto_init auto_init_ztimer,$(DISABLE_MODULE))) + USEMODULE += ztimer_auto_init + endif endif # "ztimer_xtimer_compat" is a wrapper of the xtimer API on ztimer_used