From c442cbcc2322dac3f237965c3cae99e8788c7466 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Wed, 22 Mar 2017 11:04:41 +0100 Subject: [PATCH 1/3] make: Makefile.base: don't collect wildcard sources if NO_AUTO_SRC is nonempty --- Makefile.base | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile.base b/Makefile.base index 8bbe3e39ad..06f4563251 100644 --- a/Makefile.base +++ b/Makefile.base @@ -22,16 +22,16 @@ ${DIRS:%=ALL--%}: ${DIRS:%=CLEAN--%}: $(QQ)"$(MAKE)" -C ${@:CLEAN--%=%} clean -ifeq ($(strip $(SRC)),) +ifeq ($(strip $(SRC))$(NO_AUTO_SRC),) SRC := $(filter-out $(SRC_NOLTO), $(wildcard *.c)) endif -ifeq ($(strip $(SRCXX)),) +ifeq ($(strip $(SRCXX))$(NO_AUTO_SRC),) SRCXX := $(wildcard *.cpp) endif -ifeq ($(strip $(ASMSRC)),) +ifeq ($(strip $(ASMSRC))$(NO_AUTO_SRC),) ASMSRC := $(wildcard *.s) endif -ifeq ($(strip $(ASSMSRC)),) +ifeq ($(strip $(ASSMSRC))$(NO_AUTO_SRC),) ASSMSRC := $(wildcard *.S) endif From 933a7a3efe9f33493a1e04a83626bd4d3b037341 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Wed, 22 Mar 2017 15:51:36 +0100 Subject: [PATCH 2/3] make: add submodule support --- Makefile.base | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Makefile.base b/Makefile.base index 06f4563251..533e1e7017 100644 --- a/Makefile.base +++ b/Makefile.base @@ -22,6 +22,23 @@ ${DIRS:%=ALL--%}: ${DIRS:%=CLEAN--%}: $(QQ)"$(MAKE)" -C ${@:CLEAN--%=%} clean +## submodules +ifeq (1, $(SUBMODULES)) + # don't use *.c as SRC if SRC is empty (e.g., no module selected) + NO_AUTO_SRC := 1 + + # allow different submodule basename (e.g., MODULE=cpu_periph_common, but match just periph_%) + BASE_MODULE ?= $(MODULE) + + # for each $(BASE_MODULE)_ in USEMODULE, add .c to SRC + SRC += $(patsubst $(BASE_MODULE)_%,%.c,$(filter $(BASE_MODULE)_%,$(USEMODULE))) + + # don't fail if a selected *.c file does not exist + ifeq (1, $(SUBMODULES_NOFORCE)) + SRC := $(filter $(SRC), $(wildcard *.c)) + endif +endif + ifeq ($(strip $(SRC))$(NO_AUTO_SRC),) SRC := $(filter-out $(SRC_NOLTO), $(wildcard *.c)) endif From 0b10dccf6443a8c6c5720ea2b12badd352b4eed3 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Wed, 22 Mar 2017 15:01:45 +0100 Subject: [PATCH 3/3] core: adapt to Makefile.submodule --- Makefile.pseudomodules | 4 +--- core/Makefile | 6 ++++++ core/mbox.c | 4 ---- core/msg.c | 4 ---- core/thread_flags.c | 2 -- 5 files changed, 7 insertions(+), 13 deletions(-) diff --git a/Makefile.pseudomodules b/Makefile.pseudomodules index a91c8c63ea..2602805b4b 100644 --- a/Makefile.pseudomodules +++ b/Makefile.pseudomodules @@ -3,9 +3,7 @@ PSEUDOMODULES += conn PSEUDOMODULES += conn_ip PSEUDOMODULES += conn_tcp PSEUDOMODULES += conn_udp -PSEUDOMODULES += core_msg -PSEUDOMODULES += core_mbox -PSEUDOMODULES += core_thread_flags +PSEUDOMODULES += core_% PSEUDOMODULES += emb6_router PSEUDOMODULES += gnrc_ipv6_default PSEUDOMODULES += gnrc_ipv6_router diff --git a/core/Makefile b/core/Makefile index 48422e909a..4f12366947 100644 --- a/core/Makefile +++ b/core/Makefile @@ -1 +1,7 @@ +# exclude submodule sources from *.c wildcard source selection +SRC := $(filter-out mbox.c msg.c thread_flags.c,$(wildcard *.c)) + +# enable submodules +SUBMODULES := 1 + include $(RIOTBASE)/Makefile.base diff --git a/core/mbox.c b/core/mbox.c index 7c14f35147..bd5e32415a 100644 --- a/core/mbox.c +++ b/core/mbox.c @@ -28,8 +28,6 @@ #define ENABLE_DEBUG (0) #include "debug.h" -#ifdef MODULE_CORE_MBOX - static void _wake_waiter(thread_t *thread, unsigned irqstate) { sched_set_status(thread, STATUS_PENDING); @@ -122,5 +120,3 @@ int _mbox_get(mbox_t *mbox, msg_t *msg, int blocking) return 0; } } - -#endif /* MODULE_CORE_MBOX */ diff --git a/core/msg.c b/core/msg.c index 4ab2061411..190244cca8 100644 --- a/core/msg.c +++ b/core/msg.c @@ -34,8 +34,6 @@ #include "debug.h" #include "thread.h" -#ifdef MODULE_CORE_MSG - static int _msg_receive(msg_t *m, int block); static int _msg_send(msg_t *m, kernel_pid_t target_pid, bool block, unsigned state); @@ -409,5 +407,3 @@ void msg_queue_print(void) irq_restore(state); } - -#endif /* MODULE_CORE_MSG */ diff --git a/core/thread_flags.c b/core/thread_flags.c index 9396c31e30..281a592306 100644 --- a/core/thread_flags.c +++ b/core/thread_flags.c @@ -26,7 +26,6 @@ #define ENABLE_DEBUG (0) #include "debug.h" -#ifdef MODULE_CORE_THREAD_FLAGS static thread_flags_t _thread_flags_clear_atomic(thread_t *thread, thread_flags_t mask) { unsigned state = irq_disable(); @@ -133,4 +132,3 @@ void thread_flags_set(thread_t *thread, thread_flags_t mask) irq_restore(state); } } -#endif /* MODULE_CORE_THREAD_FLAGS */