From a678e868e9487116228a2996880c6aded4dd590a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= <joakim.nohlgard@eistec.se>
Date: Tue, 12 Jul 2016 07:43:58 +0200
Subject: [PATCH] Makefile.include: Move USEMODULE CFLAGS expansion last

Some USEMODULE parts (e.g. defined in ${BOARD}/Makefile.dep) were not
being properly exported to CFLAGS -DMODULE_xxx options.
---
 Makefile.include | 11 ++++++++++-
 Makefile.modules |  6 ------
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/Makefile.include b/Makefile.include
index 6e7a35a1db..87d3073feb 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -176,8 +176,14 @@ export PREFIX ?= $(if $(TARGET_ARCH),$(TARGET_ARCH)-)
 # Import all toolchain settings
 include $(RIOTCPU)/Makefile.include.$(TOOLCHAIN)
 
+# Add standard include directories
+INCLUDES += -I$(RIOTBASE)/core/include -I$(RIOTBASE)/drivers/include -I$(RIOTBASE)/sys/include
+INCLUDES += -I$(RIOTCPU)/$(CPU)/include
+INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include
+
 # mandatory includes!
-include $(RIOTBASE)/Makefile.modules
+include $(RIOTBASE)/Makefile.pseudomodules
+include $(RIOTBASE)/Makefile.defaultmodules
 include $(RIOTBOARD)/$(BOARD)/Makefile.include
 include $(RIOTCPU)/$(CPU)/Makefile.include
 
@@ -492,6 +498,9 @@ include $(RIOTBASE)/dist/tools/desvirt/Makefile.desvirt
 # include bindist target
 include $(RIOTBASE)/Makefile.bindist
 
+# Add all USEMODULE modules to CFLAGS
+include $(RIOTBASE)/Makefile.modules
+
 # Build a header file with all common macro definitions and undefinitions
 # make it phony to force re-run of the script every time even if the file exists
 # The script will only touch the file if anything has changed since last time.
diff --git a/Makefile.modules b/Makefile.modules
index b6ec9d3428..4a0a990b86 100644
--- a/Makefile.modules
+++ b/Makefile.modules
@@ -1,11 +1,5 @@
-include $(RIOTBASE)/Makefile.pseudomodules
-include $(RIOTBASE)/Makefile.defaultmodules
-
 USEMODULE := $(filter-out $(filter-out $(FEATURES_PROVIDED), $(FEATURES_OPTIONAL)), $(sort $(USEMODULE)))
 
-INCLUDES += -I$(RIOTBASE)/core/include -I$(RIOTBASE)/drivers/include -I$(RIOTBASE)/sys/include
-INCLUDES += -I$(RIOTCPU)/$(CPU)/include
-INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include
 ED = $(addprefix FEATURE_,$(sort $(filter $(FEATURES_PROVIDED), $(FEATURES_REQUIRED))))
 ED += $(addprefix MODULE_,$(sort $(USEMODULE) $(USEPKG)))
 EXTDEFINES = $(addprefix -D,$(shell echo '$(ED)' | tr 'a-z-' 'A-Z_'))
-- 
GitLab