From 41d10cf005bb3ee9d1901d08679144bc6767a060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Tue, 17 Sep 2019 15:39:26 +0200 Subject: [PATCH] makefiles: do not remove defines from CFLAGS Do not remove the '-D' and '-U' values from CFLAGS. This prevents issues where a '-D' could contain a space. Some values way be duplicated from the 'riotbuild.h' header and the command line but with the same value so without conflict. To not put too many things in the command line, the -DMODULE_NAME are only put in CFLAGS_WITH_MACROS. Also, as now, the deferred value of CFLAGS is used for 'riotbuild.h', macros set after the inclusion of `Makefile.include` will be taken into account. --- Makefile.include | 8 +++----- makefiles/modules.inc.mk | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) 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))