From e740fbc800c59e6d06321389c1c9be1ba58ca830 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= <rene.kijewski@fu-berlin.de>
Date: Fri, 28 Mar 2014 22:55:56 +0100
Subject: [PATCH] make: Add DEFAULT_MODULE and DISABLE_MODULE

Closes #926
---
 Makefile.defaultmodules           | 3 +++
 Makefile.include                  | 5 +++++
 Makefile.modules                  | 4 +++-
 examples/ccn-lite-client/Makefile | 1 -
 examples/ccn-lite-relay/Makefile  | 3 ---
 examples/default/Makefile         | 1 -
 examples/rpl_udp/Makefile         | 1 -
 tests/test_irq/Makefile           | 1 -
 tests/test_nativenet/Makefile     | 1 -
 tests/test_net_if/Makefile        | 1 -
 tests/test_pnet/Makefile          | 1 -
 tests/test_vtimer_msg/Makefile    | 1 -
 12 files changed, 11 insertions(+), 12 deletions(-)
 create mode 100644 Makefile.defaultmodules

diff --git a/Makefile.defaultmodules b/Makefile.defaultmodules
new file mode 100644
index 0000000000..fa37f3e551
--- /dev/null
+++ b/Makefile.defaultmodules
@@ -0,0 +1,3 @@
+DEFAULT_MODULE += cpu core sys
+
+DEFAULT_MODULE += auto_init
diff --git a/Makefile.include b/Makefile.include
index 330768004e..8977118f46 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -48,6 +48,11 @@ include $(RIOTBOARD)/$(BOARD)/Makefile.include
 include $(RIOTCPU)/$(CPU)/Makefile.include
 include $(RIOTBASE)/Makefile.dep
 
+# Test if there where dependencies against a module in DISABLE_MODULE.
+ifneq (, $(filter $(DISABLE_MODULE), $(USEMODULE)))
+$(error "Required modules were disabled using DISABLE_MODULE: $(sort $(filter $(DISABLE_MODULE), $(USEMODULE)))")
+endif
+
 # Test if the input language was specified externally.
 # Otherwise test if the compiler unterstands the "-std=gnu99" flag, and use it if so.
 # Otherwise test if the compiler unterstands the "-std=c99" flag, and use it if so.
diff --git a/Makefile.modules b/Makefile.modules
index 0c378806e7..6013c3b359 100644
--- a/Makefile.modules
+++ b/Makefile.modules
@@ -1,8 +1,10 @@
 UNDEF += $(BINDIR)startup.o
 
 include $(RIOTBASE)/Makefile.pseudomodules
+include $(RIOTBASE)/Makefile.defaultmodules
+
+USEMODULE += $(filter-out $(DISABLE_MODULE), $(DEFAULT_MODULE))
 
-USEMODULE += cpu core sys
 INCLUDES += -I$(RIOTBASE)/core/include -I$(RIOTBASE)/drivers/include -I$(RIOTBASE)/sys/include
 ED = $(USEMODULE:%=-DMODULE_%)
 ED += $(USEPKG:%=-DMODULE_%)
diff --git a/examples/ccn-lite-client/Makefile b/examples/ccn-lite-client/Makefile
index 57420b8359..9118a91a20 100644
--- a/examples/ccn-lite-client/Makefile
+++ b/examples/ccn-lite-client/Makefile
@@ -34,7 +34,6 @@ USEMODULE += shell
 USEMODULE += shell_commands
 USEMODULE += posix
 USEMODULE += ps
-USEMODULE += auto_init
 USEMODULE += random
 USEMODULE += transceiver
 ifeq ($(BOARD),msba2)
diff --git a/examples/ccn-lite-relay/Makefile b/examples/ccn-lite-relay/Makefile
index b5ad2a0207..80aa25d0d6 100644
--- a/examples/ccn-lite-relay/Makefile
+++ b/examples/ccn-lite-relay/Makefile
@@ -31,9 +31,6 @@ export QUIET ?= 1
 
 USEMODULE += config
 USEMODULE += posix
-USEMODULE += auto_init
-
-USEMODULE += auto_init
 
 USEMODULE += transceiver
 ifeq ($(BOARD),msba2)
diff --git a/examples/default/Makefile b/examples/default/Makefile
index 04f948076c..b1b135e65c 100644
--- a/examples/default/Makefile
+++ b/examples/default/Makefile
@@ -34,7 +34,6 @@ USEMODULE += shell
 USEMODULE += shell_commands
 USEMODULE += ps
 USEMODULE += vtimer
-USEMODULE += auto_init
 USEMODULE += defaulttransceiver
 
 ifneq (,$(filter msb-430,$(BOARD)))
diff --git a/examples/rpl_udp/Makefile b/examples/rpl_udp/Makefile
index 0a0d91c5e0..6ca74b2f90 100644
--- a/examples/rpl_udp/Makefile
+++ b/examples/rpl_udp/Makefile
@@ -32,7 +32,6 @@ CFLAGS += "-Wno-cpp"
 
 # Modules to include:
 
-USEMODULE += auto_init
 USEMODULE += shell
 USEMODULE += shell_commands
 USEMODULE += posix
diff --git a/tests/test_irq/Makefile b/tests/test_irq/Makefile
index 37536811bd..bb56d21053 100644
--- a/tests/test_irq/Makefile
+++ b/tests/test_irq/Makefile
@@ -5,7 +5,6 @@ ifeq (,$(filter native,$(BOARD)))
 	include $(RIOTBASE)/Makefile.unsupported
 else
 
-USEMODULE += auto_init
 USEMODULE += posix
 
 include $(RIOTBASE)/Makefile.include
diff --git a/tests/test_nativenet/Makefile b/tests/test_nativenet/Makefile
index 7813fdda6c..730a3608f8 100644
--- a/tests/test_nativenet/Makefile
+++ b/tests/test_nativenet/Makefile
@@ -5,7 +5,6 @@ ifeq (,$(filter native,$(BOARD)))
 include $(RIOTBASE)/Makefile.unsupported
 else
 
-USEMODULE += auto_init
 USEMODULE += nativenet
 USEMODULE += transceiver
 
diff --git a/tests/test_net_if/Makefile b/tests/test_net_if/Makefile
index 073f4b76ab..4e41b8ac75 100644
--- a/tests/test_net_if/Makefile
+++ b/tests/test_net_if/Makefile
@@ -8,7 +8,6 @@ ifeq ($(BOARD),stm32f4discovery)
 	include Makefile.$(BOARD)
 endif
 
-USEMODULE += auto_init
 USEMODULE += net_if
 USEMODULE += defaulttransceiver
 
diff --git a/tests/test_pnet/Makefile b/tests/test_pnet/Makefile
index b1c34b788e..8ca3400f81 100644
--- a/tests/test_pnet/Makefile
+++ b/tests/test_pnet/Makefile
@@ -1,7 +1,6 @@
 export PROJECT = test_pnet
 include ../Makefile.tests_common
 
-USEMODULE += auto_init
 USEMODULE += posix
 USEMODULE += pnet
 USEMODULE += vtimer
diff --git a/tests/test_vtimer_msg/Makefile b/tests/test_vtimer_msg/Makefile
index fa9f98a683..ba57fc7b9c 100644
--- a/tests/test_vtimer_msg/Makefile
+++ b/tests/test_vtimer_msg/Makefile
@@ -1,7 +1,6 @@
 export PROJECT = test_vtimer_msg
 include ../Makefile.tests_common
 
-USEMODULE += auto_init
 USEMODULE += vtimer
 
 include $(RIOTBASE)/Makefile.include
-- 
GitLab