diff --git a/Makefile.include b/Makefile.include index 8df7939bfe..96a3381aff 100644 --- a/Makefile.include +++ b/Makefile.include @@ -774,13 +774,11 @@ $(RIOTBUILD_CONFIG_HEADER_C): FORCE $(Q)'$(RIOTTOOLS)/genconfigheader/genconfigheader.sh' $(CFLAGS_WITH_MACROS) \ | '$(LAZYSPONGE)' $(LAZYSPONGE_FLAGS) '$@' -# Immediate evaluation but keep CLAGS_WITH_MACROS deferred -_CFLAGS := $(CFLAGS) -CFLAGS_WITH_MACROS = $(_CFLAGS) +CFLAGS_WITH_MACROS += $(CFLAGS) CFLAGS_WITH_MACROS += -DRIOT_VERSION=\"$(RIOT_VERSION)\" +# MODULE_NAME defines. Declared in 'makefiles/modules.inc.mk' +CFLAGS_WITH_MACROS += $(EXTDEFINES) -CFLAGS := $(patsubst -D%,,$(CFLAGS)) -CFLAGS := $(patsubst -U%,,$(CFLAGS)) CFLAGS += -include '$(RIOTBUILD_CONFIG_HEADER_C)' # include mcuboot support diff --git a/makefiles/modules.inc.mk b/makefiles/modules.inc.mk index 7aa1e78ec6..e337750439 100644 --- a/makefiles/modules.inc.mk +++ b/makefiles/modules.inc.mk @@ -2,8 +2,8 @@ _ALLMODULES = $(sort $(USEMODULE) $(USEPKG)) # Define MODULE_MODULE_NAME preprocessor macros for all modules. ED = $(addprefix MODULE_,$(_ALLMODULES)) +# EXTDEFINES will be put in CFLAGS_WITH_MACROS EXTDEFINES = $(addprefix -D,$(shell echo '$(ED)' | tr 'a-z-' 'A-Z_')) -CFLAGS += $(EXTDEFINES) # filter "pseudomodules" from "real modules", but not "no_pseudomodules" REALMODULES += $(filter-out $(PSEUDOMODULES), $(_ALLMODULES))