From db1c4523f0b0b217512e8eb51e7cebb6eac139dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Tue, 17 Oct 2017 17:25:24 +0200 Subject: [PATCH 01/28] example/saul: rename application as their already is a 'saul' module --- examples/saul/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/saul/Makefile b/examples/saul/Makefile index be2b858d8194..38c83c5baac8 100644 --- a/examples/saul/Makefile +++ b/examples/saul/Makefile @@ -1,5 +1,5 @@ # name of your application -APPLICATION = saul +APPLICATION = saul_example # If no BOARD is found in the environment, use this default: BOARD ?= native From 32ec1d067b6cc5763087405f727ceb2b836cf71b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Tue, 17 Oct 2017 18:36:19 +0200 Subject: [PATCH 02/28] cpu/native/Makefile: only build vfs is necessary --- cpu/native/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cpu/native/Makefile b/cpu/native/Makefile index 55c4961b4eda..a19c566bc4a7 100644 --- a/cpu/native/Makefile +++ b/cpu/native/Makefile @@ -1,15 +1,16 @@ MODULE = cpu DIRS += periph -DIRS += vfs +ifneq (,$(filter native_vfs,$(USEMODULE))) + DIRS += vfs +endif ifneq (,$(filter netdev_tap,$(USEMODULE))) DIRS += netdev_tap endif ifneq (,$(filter mtd_native,$(USEMODULE))) DIRS += mtd endif - ifneq (,$(filter can_linux,$(USEMODULE))) DIRS += can endif From 513d58014c5bbdb683a3824eb355df7d61b1321d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Tue, 17 Oct 2017 18:14:59 +0200 Subject: [PATCH 03/28] sys/random/Makefile: Fix 'DIRS' setting relative to tinymt32 tinymt32 dir is required to build 'tinymt32' module, not 'prng_tinymt32'. It was working because tinymt32 is only pulled as a prng_tinymt32 dependency. --- sys/random/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/random/Makefile b/sys/random/Makefile index 372beceac515..4123432be2e7 100644 --- a/sys/random/Makefile +++ b/sys/random/Makefile @@ -1,7 +1,7 @@ BASE_MODULE := prng SUBMODULES := 1 -ifneq (,$(filter prng_tinymt32,$(USEMODULE))) +ifneq (,$(filter tinymt32,$(USEMODULE))) DIRS += tinymt32 endif From 83100d842063a8e4e8411b7aa2538c1f72290eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Tue, 5 Sep 2017 20:33:57 +0200 Subject: [PATCH 04/28] sys: Makefile.modules: Define MODULE_DIR_$(module) vars Define MODULE_DIR_$(module) for each module in sys. Modules with names matching a subdirectory are automatically created. Others should be explicitely defined. Makefile.modules are made to be importable from any directory. --- sys/Makefile.modules | 50 ++++++++++++++++++++++++++++++++++ sys/auto_init/Makefile.modules | 7 +++++ sys/can/Makefile.modules | 5 ++++ sys/log/Makefile.modules | 6 ++++ sys/net/gnrc/Makefile.modules | 49 +++++++++++++++++++++++++++++++++ sys/random/Makefile.modules | 4 +++ 6 files changed, 121 insertions(+) create mode 100644 sys/Makefile.modules create mode 100644 sys/auto_init/Makefile.modules create mode 100644 sys/can/Makefile.modules create mode 100644 sys/log/Makefile.modules create mode 100644 sys/net/gnrc/Makefile.modules create mode 100644 sys/random/Makefile.modules diff --git a/sys/Makefile.modules b/sys/Makefile.modules new file mode 100644 index 000000000000..1dbb05b24c27 --- /dev/null +++ b/sys/Makefile.modules @@ -0,0 +1,50 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +# Define for modules which are directly in a subfolder +__SUBFOLDER_MODULES = $(patsubst $(D)/%/Makefile,%,$(wildcard $(D)/*/Makefile)) +$(foreach module, $(__SUBFOLDER_MODULES), $(eval MODULE_DIR_$(module) := $(D)/$(module))) + +MODULE_DIR_sys := $(D) + +# Define for modules which are in subdirectories +MODULE_DIR_csma_sender := $(D)/net/link_layer/csma_sender +MODULE_DIR_posix_semaphore := $(D)/posix/semaphore +MODULE_DIR_posix_sockets := $(D)/posix/sockets +MODULE_DIR_pthread := $(D)/posix/pthread +MODULE_DIR_shell_commands := $(D)/shell/commands +MODULE_DIR_net_help := $(D)/net/crosslayer/net_help +MODULE_DIR_routing := $(D)/net/routing +MODULE_DIR_oneway_malloc := $(D)/oneway-malloc +MODULE_DIR_ieee802154 := $(D)/net/link_layer/ieee802154 +MODULE_DIR_netdev_test := $(D)/net/netdev_test +MODULE_DIR_icmpv6 := $(D)/net/network_layer/icmpv6 +MODULE_DIR_ipv4_addr := $(D)/net/network_layer/ipv4/addr +MODULE_DIR_ipv6_addr := $(D)/net/network_layer/ipv6/addr +MODULE_DIR_ipv6_ext_rh := $(D)/net/network_layer/ipv6/ext/rh +MODULE_DIR_ipv6_ext := $(D)/net/network_layer/ipv6/ext +MODULE_DIR_ipv6_hdr := $(D)/net/network_layer/ipv6/hdr +MODULE_DIR_gnrc := $(D)/net/gnrc +MODULE_DIR_inet_csum := $(D)/net/crosslayer/inet_csum +MODULE_DIR_cipher_modes := $(D)/crypto/modes +MODULE_DIR_nhdp := $(D)/net/routing/nhdp +MODULE_DIR_gnrc_netdev := $(D)/net/gnrc/link_layer/netdev +MODULE_DIR_fib := $(D)/net/network_layer/fib +MODULE_DIR_sixlowpan := $(D)/net/network_layer/sixlowpan +MODULE_DIR_xtimer := $(D)/xtimer +MODULE_DIR_cpp11 := $(D)/cpp11-compat +MODULE_DIR_udp := $(D)/net/transport_layer/udp +MODULE_DIR_tcp := $(D)/net/transport_layer/tcp +MODULE_DIR_hamming256 := $(D)/ecc/hamming256 +MODULE_DIR_uhcpc := $(D)/net/application_layer/uhcp +MODULE_DIR_gnrc_uhcpc := $(D)/net/gnrc/application_layer/uhcpc +MODULE_DIR_sntp := $(D)/net/application_layer/sntp +MODULE_DIR_netopt := $(D)/net/crosslayer/netopt +MODULE_DIR_sema := $(D)/sema +MODULE_DIR_gcoap := $(D)/net/application_layer/gcoap +MODULE_DIR_emcute := $(D)/net/application_layer/emcute +MODULE_DIR_sock_util := $(D)/net/sock +MODULE_DIR_sock_dns := $(D)/net/application_layer/dns +MODULE_DIR_constfs := $(D)/fs/constfs +MODULE_DIR_devfs := $(D)/fs/devfs +MODULE_DIR_l2filter := $(D)/net/link_layer/l2filter diff --git a/sys/auto_init/Makefile.modules b/sys/auto_init/Makefile.modules new file mode 100644 index 000000000000..263231acf308 --- /dev/null +++ b/sys/auto_init/Makefile.modules @@ -0,0 +1,7 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +MODULE_DIR_auto_init_gnrc_netif := $(D)/netif +MODULE_DIR_auto_init_saul := $(D)/saul +MODULE_DIR_auto_init_storage := $(D)/storage +MODULE_DIR_auto_init_can := $(D)/can diff --git a/sys/can/Makefile.modules b/sys/can/Makefile.modules new file mode 100644 index 000000000000..110a774d9991 --- /dev/null +++ b/sys/can/Makefile.modules @@ -0,0 +1,5 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +MODULE_DIR_can_isotp := $(D)/isotp +MODULE_DIR_conn_can := $(D)/conn diff --git a/sys/log/Makefile.modules b/sys/log/Makefile.modules new file mode 100644 index 000000000000..16dafd190d48 --- /dev/null +++ b/sys/log/Makefile.modules @@ -0,0 +1,6 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +# Define for modules which are directly in a subfolder +__SUBFOLDER_MODULES = $(patsubst $(D)/%/Makefile,%,$(wildcard $(D)/*/Makefile)) +$(foreach module, $(__SUBFOLDER_MODULES), $(eval MODULE_DIR_$(module) := $(D)/$(module))) diff --git a/sys/net/gnrc/Makefile.modules b/sys/net/gnrc/Makefile.modules new file mode 100644 index 000000000000..9e3dca1f20ee --- /dev/null +++ b/sys/net/gnrc/Makefile.modules @@ -0,0 +1,49 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +MODULE_DIR_gnrc_icmpv6 := $(D)/network_layer/icmpv6 +MODULE_DIR_gnrc_icmpv6_echo := $(D)/network_layer/icmpv6/echo +MODULE_DIR_gnrc_icmpv6_error := $(D)/network_layer/icmpv6/error +MODULE_DIR_gnrc_ipv6 := $(D)/network_layer/ipv6 +MODULE_DIR_gnrc_ipv6_ext := $(D)/network_layer/ipv6/ext +MODULE_DIR_gnrc_ipv6_hdr := $(D)/network_layer/ipv6/hdr +MODULE_DIR_gnrc_ipv6_nc := $(D)/network_layer/ipv6/nc +MODULE_DIR_gnrc_ipv6_netif := $(D)/network_layer/ipv6/netif +MODULE_DIR_gnrc_ipv6_nib := $(D)/network_layer/ipv6/nib +MODULE_DIR_gnrc_ipv6_whitelist := $(D)/network_layer/ipv6/whitelist +MODULE_DIR_gnrc_ipv6_blacklist := $(D)/network_layer/ipv6/blacklist +MODULE_DIR_gnrc_ndp := $(D)/network_layer/ndp +MODULE_DIR_gnrc_ndp_internal := $(D)/network_layer/ndp/internal +MODULE_DIR_gnrc_ndp_host := $(D)/network_layer/ndp/host +MODULE_DIR_gnrc_ndp_node := $(D)/network_layer/ndp/node +MODULE_DIR_gnrc_ndp_router := $(D)/network_layer/ndp/router +MODULE_DIR_gnrc_ndp2 := $(D)/network_layer/ndp2 +MODULE_DIR_gnrc_netapi := $(D)/netapi +MODULE_DIR_gnrc_netif := $(D)/netif +MODULE_DIR_gnrc_netif2 := $(D)/netif2 +MODULE_DIR_gnrc_netif_hdr := $(D)/netif/hdr +MODULE_DIR_gnrc_netreg := $(D)/netreg +MODULE_DIR_gnrc_nettest := $(D)/nettest +MODULE_DIR_gnrc_mac := $(D)/link_layer/gnrc_mac +MODULE_DIR_gnrc_pkt := $(D)/pkt +MODULE_DIR_gnrc_lwmac := $(D)/link_layer/lwmac +MODULE_DIR_gnrc_pktbuf_static := $(D)/pktbuf_static +MODULE_DIR_gnrc_pktbuf := $(D)/pktbuf +MODULE_DIR_gnrc_priority_pktqueue := $(D)/priority_pktqueue +MODULE_DIR_gnrc_pktdump := $(D)/pktdump +MODULE_DIR_gnrc_rpl := $(D)/routing/rpl +MODULE_DIR_gnrc_rpl_srh := $(D)/routing/rpl/srh +MODULE_DIR_gnrc_rpl_p2p := $(D)/routing/rpl/p2p +MODULE_DIR_gnrc_sixlowpan := $(D)/network_layer/sixlowpan +MODULE_DIR_gnrc_sixlowpan_ctx := $(D)/network_layer/sixlowpan/ctx +MODULE_DIR_gnrc_sixlowpan_frag := $(D)/network_layer/sixlowpan/frag +MODULE_DIR_gnrc_sixlowpan_iphc := $(D)/network_layer/sixlowpan/iphc +MODULE_DIR_gnrc_sixlowpan_nd := $(D)/network_layer/sixlowpan/nd +MODULE_DIR_gnrc_sixlowpan_nd_router := $(D)/network_layer/sixlowpan/nd/router +MODULE_DIR_gnrc_sixlowpan_netif := $(D)/network_layer/sixlowpan/netif +MODULE_DIR_gnrc_sock := $(D)/sock +MODULE_DIR_gnrc_sock_ip := $(D)/sock/ip +MODULE_DIR_gnrc_sock_udp := $(D)/sock/udp +MODULE_DIR_gnrc_udp := $(D)/transport_layer/udp +MODULE_DIR_gnrc_tcp := $(D)/transport_layer/tcp +MODULE_DIR_gnrc_tftp := $(D)/application_layer/tftp diff --git a/sys/random/Makefile.modules b/sys/random/Makefile.modules new file mode 100644 index 000000000000..487ac1ce78b2 --- /dev/null +++ b/sys/random/Makefile.modules @@ -0,0 +1,4 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +MODULE_DIR_tinymt32 := $(D)/tinymt32 From a2e3d0ae9f37e9b16d2ae52d07362b2ef9bec47f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Tue, 5 Sep 2017 20:49:08 +0200 Subject: [PATCH 05/28] sys: Use Makefile.modules in sys Makefile Use MODULE_DIR_$(module) variables to populate DIRS from USEMODULE. DIRS is now calculaded directly in the main Makefile. --- sys/Makefile | 128 ++----------------------------------- sys/auto_init/Makefile | 16 ----- sys/can/Makefile | 9 --- sys/log/Makefile | 2 - sys/net/gnrc/Makefile | 139 ----------------------------------------- sys/random/Makefile | 4 -- 6 files changed, 4 insertions(+), 294 deletions(-) diff --git a/sys/Makefile b/sys/Makefile index 38a50741b75b..8aa77af0bf47 100644 --- a/sys/Makefile +++ b/sys/Makefile @@ -1,127 +1,7 @@ -ifneq (,$(filter csma_sender,$(USEMODULE))) - DIRS += net/link_layer/csma_sender -endif -ifneq (,$(filter posix_semaphore,$(USEMODULE))) - DIRS += posix/semaphore -endif -ifneq (,$(filter posix_sockets,$(USEMODULE))) - DIRS += posix/sockets -endif -ifneq (,$(filter pthread,$(USEMODULE))) - DIRS += posix/pthread -endif -ifneq (,$(filter shell_commands,$(USEMODULE))) - DIRS += shell/commands -endif -ifneq (,$(filter net_help,$(USEMODULE))) - DIRS += net/crosslayer/net_help -endif -ifneq (,$(filter routing,$(USEMODULE))) - DIRS += net/routing -endif -ifneq (,$(filter oneway_malloc,$(USEMODULE))) - DIRS += oneway-malloc -endif -ifneq (,$(filter ieee802154,$(USEMODULE))) - DIRS += net/link_layer/ieee802154 -endif -ifneq (,$(filter netdev_test,$(USEMODULE))) - DIRS += net/netdev_test -endif -ifneq (,$(filter icmpv6,$(USEMODULE))) - DIRS += net/network_layer/icmpv6 -endif -ifneq (,$(filter ipv4_addr,$(USEMODULE))) - DIRS += net/network_layer/ipv4/addr -endif -ifneq (,$(filter ipv6_addr,$(USEMODULE))) - DIRS += net/network_layer/ipv6/addr -endif -ifneq (,$(filter ipv6_ext_rh,$(USEMODULE))) - DIRS += net/network_layer/ipv6/ext/rh -endif -ifneq (,$(filter ipv6_ext,$(USEMODULE))) - DIRS += net/network_layer/ipv6/ext -endif -ifneq (,$(filter ipv6_hdr,$(USEMODULE))) - DIRS += net/network_layer/ipv6/hdr -endif -ifneq (,$(filter gnrc gnrc_%,$(USEMODULE))) - DIRS += net/gnrc -endif -ifneq (,$(filter inet_csum,$(USEMODULE))) - DIRS += net/crosslayer/inet_csum -endif -ifneq (,$(filter cipher_modes,$(USEMODULE))) - DIRS += crypto/modes -endif -ifneq (,$(filter nhdp,$(USEMODULE))) - DIRS += net/routing/nhdp -endif -ifneq (,$(filter gnrc_netdev,$(USEMODULE))) - DIRS += net/gnrc/link_layer/netdev -endif -ifneq (,$(filter fib,$(USEMODULE))) - DIRS += net/network_layer/fib -endif -ifneq (,$(filter sixlowpan,$(USEMODULE))) - DIRS += net/network_layer/sixlowpan -endif -ifneq (,$(filter log_%,$(USEMODULE))) - DIRS += log -endif -ifneq (,$(filter xtimer,$(USEMODULE))) - DIRS += xtimer -endif -ifneq (,$(filter cpp11-compat,$(USEMODULE))) - DIRS += cpp11-compat -endif -ifneq (,$(filter udp,$(USEMODULE))) - DIRS += net/transport_layer/udp -endif -ifneq (,$(filter tcp,$(USEMODULE))) - DIRS += net/transport_layer/tcp -endif -ifneq (,$(filter hamming256,$(USEMODULE))) - DIRS += ecc/hamming256 -endif -ifneq (,$(filter uhcpc,$(USEMODULE))) - DIRS += net/application_layer/uhcp -endif -ifneq (,$(filter gnrc_uhcpc,$(USEMODULE))) - DIRS += net/gnrc/application_layer/uhcpc -endif -ifneq (,$(filter sntp,$(USEMODULE))) - DIRS += net/application_layer/sntp -endif -ifneq (,$(filter netopt,$(USEMODULE))) - DIRS += net/crosslayer/netopt -endif -ifneq (,$(filter sema,$(USEMODULE))) - DIRS += sema -endif -ifneq (,$(filter gcoap,$(USEMODULE))) - DIRS += net/application_layer/gcoap -endif -ifneq (,$(filter emcute,$(USEMODULE))) - DIRS += net/application_layer/emcute -endif -ifneq (,$(filter sock_util,$(USEMODULE))) - DIRS += net/sock -endif -ifneq (,$(filter sock_dns,$(USEMODULE))) - DIRS += net/application_layer/dns -endif -ifneq (,$(filter constfs,$(USEMODULE))) - DIRS += fs/constfs -endif -ifneq (,$(filter devfs,$(USEMODULE))) - DIRS += fs/devfs -endif -ifneq (,$(filter l2filter,$(USEMODULE))) - DIRS += net/link_layer/l2filter -endif +include Makefile.modules +include $(wildcard */Makefile.modules) +include $(wildcard */*/Makefile.modules) -DIRS += $(dir $(wildcard $(addsuffix /Makefile, ${USEMODULE}))) +DIRS += $(foreach module, $(USEMODULE), $(MODULE_DIR_$(module))) include $(RIOTBASE)/Makefile.base diff --git a/sys/auto_init/Makefile b/sys/auto_init/Makefile index 1c2c0816d40f..48422e909a47 100644 --- a/sys/auto_init/Makefile +++ b/sys/auto_init/Makefile @@ -1,17 +1 @@ -ifneq (,$(filter auto_init_gnrc_netif,$(USEMODULE))) - DIRS += netif -endif - -ifneq (,$(filter auto_init_saul,$(USEMODULE))) - DIRS += saul -endif - -ifneq (,$(filter auto_init_storage,$(USEMODULE))) - DIRS += storage -endif - -ifneq (,$(filter auto_init_can,$(USEMODULE))) - DIRS += can -endif - include $(RIOTBASE)/Makefile.base diff --git a/sys/can/Makefile b/sys/can/Makefile index ea01f90d5335..48422e909a47 100644 --- a/sys/can/Makefile +++ b/sys/can/Makefile @@ -1,10 +1 @@ - -ifneq (,$(filter can_isotp,$(USEMODULE))) - DIRS += isotp -endif - -ifneq (,$(filter conn_can,$(USEMODULE))) - DIRS += conn -endif - include $(RIOTBASE)/Makefile.base diff --git a/sys/log/Makefile b/sys/log/Makefile index f1eb9fa686a0..48422e909a47 100644 --- a/sys/log/Makefile +++ b/sys/log/Makefile @@ -1,3 +1 @@ -DIRS += $(dir $(wildcard $(addsuffix /Makefile, ${USEMODULE}))) - include $(RIOTBASE)/Makefile.base diff --git a/sys/net/gnrc/Makefile b/sys/net/gnrc/Makefile index 1d01eaa27ec9..48422e909a47 100644 --- a/sys/net/gnrc/Makefile +++ b/sys/net/gnrc/Makefile @@ -1,140 +1 @@ -ifneq (,$(filter gnrc_icmpv6,$(USEMODULE))) - DIRS += network_layer/icmpv6 -endif -ifneq (,$(filter gnrc_icmpv6_echo,$(USEMODULE))) - DIRS += network_layer/icmpv6/echo -endif -ifneq (,$(filter gnrc_icmpv6_error,$(USEMODULE))) - DIRS += network_layer/icmpv6/error -endif -ifneq (,$(filter gnrc_ipv6,$(USEMODULE))) - DIRS += network_layer/ipv6 -endif -ifneq (,$(filter gnrc_ipv6_ext,$(USEMODULE))) - DIRS += network_layer/ipv6/ext -endif -ifneq (,$(filter gnrc_ipv6_hdr,$(USEMODULE))) - DIRS += network_layer/ipv6/hdr -endif -ifneq (,$(filter gnrc_ipv6_nc,$(USEMODULE))) - DIRS += network_layer/ipv6/nc -endif -ifneq (,$(filter gnrc_ipv6_netif,$(USEMODULE))) - DIRS += network_layer/ipv6/netif -endif -ifneq (,$(filter gnrc_ipv6_nib,$(USEMODULE))) - DIRS += network_layer/ipv6/nib -endif -ifneq (,$(filter gnrc_ipv6_whitelist,$(USEMODULE))) - DIRS += network_layer/ipv6/whitelist -endif -ifneq (,$(filter gnrc_ipv6_blacklist,$(USEMODULE))) - DIRS += network_layer/ipv6/blacklist -endif -ifneq (,$(filter gnrc_ndp,$(USEMODULE))) - DIRS += network_layer/ndp -endif -ifneq (,$(filter gnrc_ndp_internal,$(USEMODULE))) - DIRS += network_layer/ndp/internal -endif -ifneq (,$(filter gnrc_ndp_host,$(USEMODULE))) - DIRS += network_layer/ndp/host -endif -ifneq (,$(filter gnrc_ndp_node,$(USEMODULE))) - DIRS += network_layer/ndp/node -endif -ifneq (,$(filter gnrc_ndp_router,$(USEMODULE))) - DIRS += network_layer/ndp/router -endif -ifneq (,$(filter gnrc_ndp2,$(USEMODULE))) - DIRS += network_layer/ndp2 -endif -ifneq (,$(filter gnrc_netapi,$(USEMODULE))) - DIRS += netapi -endif -ifneq (,$(filter gnrc_netif2,$(USEMODULE))) - DIRS += netif2 -endif -ifneq (,$(filter gnrc_netif,$(USEMODULE))) - DIRS += netif -endif -ifneq (,$(filter gnrc_netif_hdr,$(USEMODULE))) - DIRS += netif/hdr -endif -ifneq (,$(filter gnrc_netreg,$(USEMODULE))) - DIRS += netreg -endif -ifneq (,$(filter gnrc_nettest,$(USEMODULE))) - DIRS += nettest -endif -ifneq (,$(filter gnrc_mac,$(USEMODULE))) - DIRS += link_layer/gnrc_mac -endif -ifneq (,$(filter gnrc_pkt,$(USEMODULE))) - DIRS += pkt -endif -ifneq (,$(filter gnrc_lwmac,$(USEMODULE))) - DIRS += link_layer/lwmac -endif -ifneq (,$(filter gnrc_pktbuf_static,$(USEMODULE))) - DIRS += pktbuf_static -endif -ifneq (,$(filter gnrc_pktbuf,$(USEMODULE))) - DIRS += pktbuf -endif -ifneq (,$(filter gnrc_priority_pktqueue,$(USEMODULE))) - DIRS += priority_pktqueue -endif -ifneq (,$(filter gnrc_pktdump,$(USEMODULE))) - DIRS += pktdump -endif -ifneq (,$(filter gnrc_rpl,$(USEMODULE))) - DIRS += routing/rpl -endif -ifneq (,$(filter gnrc_rpl_srh,$(USEMODULE))) - DIRS += routing/rpl/srh -endif -ifneq (,$(filter gnrc_rpl_p2p,$(USEMODULE))) - DIRS += routing/rpl/p2p -endif -ifneq (,$(filter gnrc_sixlowpan,$(USEMODULE))) - DIRS += network_layer/sixlowpan -endif -ifneq (,$(filter gnrc_sixlowpan_ctx,$(USEMODULE))) - DIRS += network_layer/sixlowpan/ctx -endif -ifneq (,$(filter gnrc_sixlowpan_frag,$(USEMODULE))) - DIRS += network_layer/sixlowpan/frag -endif -ifneq (,$(filter gnrc_sixlowpan_iphc,$(USEMODULE))) - DIRS += network_layer/sixlowpan/iphc -endif -ifneq (,$(filter gnrc_sixlowpan_nd,$(USEMODULE))) - DIRS += network_layer/sixlowpan/nd -endif -ifneq (,$(filter gnrc_sixlowpan_nd_router,$(USEMODULE))) - DIRS += network_layer/sixlowpan/nd/router -endif -ifneq (,$(filter gnrc_sixlowpan_netif,$(USEMODULE))) - DIRS += network_layer/sixlowpan/netif -endif -ifneq (,$(filter gnrc_sock,$(USEMODULE))) - DIRS += sock -endif -ifneq (,$(filter gnrc_sock_ip,$(USEMODULE))) - DIRS += sock/ip -endif -ifneq (,$(filter gnrc_sock_udp,$(USEMODULE))) - DIRS += sock/udp -endif -ifneq (,$(filter gnrc_udp,$(USEMODULE))) - DIRS += transport_layer/udp -endif -ifneq (,$(filter gnrc_tcp,$(USEMODULE))) - DIRS += transport_layer/tcp -endif -ifneq (,$(filter gnrc_tftp,$(USEMODULE))) - DIRS += application_layer/tftp -endif - include $(RIOTBASE)/Makefile.base diff --git a/sys/random/Makefile b/sys/random/Makefile index 4123432be2e7..6ab4fb0a9ee2 100644 --- a/sys/random/Makefile +++ b/sys/random/Makefile @@ -1,8 +1,4 @@ BASE_MODULE := prng SUBMODULES := 1 -ifneq (,$(filter tinymt32,$(USEMODULE))) - DIRS += tinymt32 -endif - include $(RIOTBASE)/Makefile.base From 9a4e6f69be7aba67c4cd1fa269f310f9495bc953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Thu, 12 Oct 2017 14:18:04 +0200 Subject: [PATCH 06/28] Makefile.base: create a per module ..nothing target ..nothing targets removes print "make[2]: Nothing to be done for 'all'." when changing directory. However, because Makefile.base gets imported multiple times, its overrwritten. --- Makefile.base | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.base b/Makefile.base index 0c5da103d13a..c49d46c69c6a 100644 --- a/Makefile.base +++ b/Makefile.base @@ -9,9 +9,9 @@ MODULE ?= $(shell basename $(CURDIR)) .PHONY: all ${DIRS:%=ALL--%} ${DIRS:%=CLEAN--%} -all: $(BINDIR)/$(MODULE).a ..nothing +all: $(BINDIR)/$(MODULE).a ..nothing_$(MODULE) -..nothing: +..nothing_$(MODULE): @: clean:: ${DIRS:%=CLEAN--%} From aa1a5f87b87eacde30956b4a8faee90d81bb2f87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 2 Oct 2017 15:19:28 +0200 Subject: [PATCH 07/28] Makefile.base: Group 'DIRS' management at the end --- Makefile.base | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/Makefile.base b/Makefile.base index c49d46c69c6a..a7974597ad8c 100644 --- a/Makefile.base +++ b/Makefile.base @@ -2,25 +2,12 @@ ifeq (, $(__RIOTBUILD_FLAG)) $(error You cannot build a module on its own. Use "make" in your application's directory instead.) endif -unexport DIRS -DIRS := $(sort $(abspath ${DIRS})) - MODULE ?= $(shell basename $(CURDIR)) -.PHONY: all ${DIRS:%=ALL--%} ${DIRS:%=CLEAN--%} - -all: $(BINDIR)/$(MODULE).a ..nothing_$(MODULE) - -..nothing_$(MODULE): - @: +.PHONY: all -clean:: ${DIRS:%=CLEAN--%} +all: $(BINDIR)/$(MODULE).a -${DIRS:%=ALL--%}: - $(QQ)"$(MAKE)" -C ${@:ALL--%=%} - -${DIRS:%=CLEAN--%}: - $(QQ)"$(MAKE)" -C ${@:CLEAN--%=%} clean ## submodules ifeq (1, $(SUBMODULES)) @@ -62,13 +49,13 @@ ASSMOBJ := $(ASSMSRC:%.S=$(BINDIR)/$(MODULE)/%.o) OBJ := $(OBJC) $(OBJCXX) $(ASMOBJ) $(ASSMOBJ) DEP := $(OBJC:.o=.d) $(OBJCXX:.o=.d) $(ASSMOBJ:.o=.d) -$(BINDIR)/$(MODULE)/: - $(Q)mkdir -p $@ +$(BINDIR)/$(MODULE).a: $(OBJ) + $(Q)$(AR) $(ARFLAGS) $@ $? $(BINDIR)/$(MODULE).a $(OBJ): | $(BINDIR)/$(MODULE)/ -$(BINDIR)/$(MODULE).a: $(OBJ) | ${DIRS:%=ALL--%} - $(Q)$(AR) $(ARFLAGS) $@ $? +$(BINDIR)/$(MODULE)/: + $(Q)mkdir -p $@ CXXFLAGS = $(filter-out $(CXXUWFLAGS), $(CFLAGS)) $(CXXEXFLAGS) CCASFLAGS = $(filter-out $(CCASUWFLAGS), $(CFLAGS)) $(CCASEXFLAGS) @@ -95,6 +82,29 @@ $(ASMOBJ): $(BINDIR)/$(MODULE)/%.o: %.s $(ASSMOBJ): $(BINDIR)/$(MODULE)/%.o: %.S $(RIOTBUILD_CONFIG_HEADER_C) $(Q)$(CCAS) $(CCASFLAGS) $(INCLUDES) -MD -MP -c -o $@ $(abspath $<) + +# Building DIRS + +unexport DIRS +DIRS := $(sort $(abspath ${DIRS})) +.PHONY: ${DIRS:%=ALL--%} ${DIRS:%=CLEAN--%} + +clean:: ${DIRS:%=CLEAN--%} + +${DIRS:%=ALL--%}: + $(QQ)"$(MAKE)" -C ${@:ALL--%=%} + +${DIRS:%=CLEAN--%}: + $(QQ)"$(MAKE)" -C ${@:CLEAN--%=%} clean + +$(BINDIR)/$(MODULE).a $(OBJ): | ${DIRS:%=ALL--%} + +# No message when changing directory and nothing to do +all: ..nothing_$(MODULE) +..nothing_$(MODULE): + @: + + # pull in dependency info for *existing* .o files # deleted header files will be silently ignored -include $(DEP) From a7ee17a08835336824fdd12d17e70b1843ce113a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 2 Oct 2017 15:56:37 +0200 Subject: [PATCH 08/28] Makefile.base: use current module directory in source path --- Makefile.base | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/Makefile.base b/Makefile.base index a7974597ad8c..0a2db847d4ca 100644 --- a/Makefile.base +++ b/Makefile.base @@ -2,12 +2,20 @@ ifeq (, $(__RIOTBUILD_FLAG)) $(error You cannot build a module on its own. Use "make" in your application's directory instead.) endif -MODULE ?= $(shell basename $(CURDIR)) +MODULE_DIR ?= $(CURDIR) +MODULE ?= $(shell basename $(MODULE_DIR)) + +# Add MODULE_DIR to files path to work from another dir than CURDIR +D := $(MODULE_DIR) .PHONY: all all: $(BINDIR)/$(MODULE).a +# dir_wildcard: Same as 'wildcard' but for given directory +# call dir_wildcard,PATTERN,DIRECTORY +# The 'DIRECTORY' part is not included in returned paths +dir_wildcard = $(patsubst $(2)/%,%,$(wildcard $(2)/$(1))) ## submodules ifeq (1, $(SUBMODULES)) @@ -22,21 +30,22 @@ ifeq (1, $(SUBMODULES)) # don't fail if a selected *.c file does not exist ifeq (1, $(SUBMODULES_NOFORCE)) - SRC := $(filter $(SRC), $(wildcard *.c)) + SRC := $(filter $(SRC), $(call dir_wildcard,*.c,$(D))) endif endif ifeq ($(strip $(SRC))$(NO_AUTO_SRC),) - SRC := $(filter-out $(SRC_NOLTO), $(wildcard *.c)) + SRC := $(call dir_wildcard,*.c,$(D)) + SRC := $(filter-out $(SRC_NOLTO), $(SRC)) endif ifeq ($(strip $(SRCXX))$(NO_AUTO_SRC),) - SRCXX := $(wildcard *.cpp) + SRCXX := $(call dir_wildcard,*.cpp,$(D)) endif ifeq ($(strip $(ASMSRC))$(NO_AUTO_SRC),) - ASMSRC := $(wildcard *.s) + ASMSRC := $(call dir_wildcard,*.s,$(D)) endif ifeq ($(strip $(ASSMSRC))$(NO_AUTO_SRC),) - ASSMSRC := $(wildcard *.S) + ASSMSRC := $(call dir_wildcard,*.S,$(D)) endif OBJC_LTO := $(SRC:%.c=$(BINDIR)/$(MODULE)/%.o) @@ -64,22 +73,22 @@ CCASFLAGS = $(filter-out $(CCASUWFLAGS), $(CFLAGS)) $(CCASEXFLAGS) $(OBJC_LTO): CFLAGS+=$(LTOFLAGS) -$(OBJC): $(BINDIR)/$(MODULE)/%.o: %.c $(RIOTBUILD_CONFIG_HEADER_C) +$(OBJC): $(BINDIR)/$(MODULE)/%.o: $(D)/%.c $(RIOTBUILD_CONFIG_HEADER_C) $(Q)$(CCACHE) $(CC) \ -DRIOT_FILE_RELATIVE=\"$(patsubst $(RIOTBASE)/%,%,$(abspath $<))\" \ -DRIOT_FILE_NOPATH=\"$(notdir $<)\" \ $(CFLAGS) $(INCLUDES) -MD -MP -c -o $@ $(abspath $<) -$(OBJCXX): $(BINDIR)/$(MODULE)/%.o: %.cpp $(RIOTBUILD_CONFIG_HEADER_C) +$(OBJCXX): $(BINDIR)/$(MODULE)/%.o: $(D)/%.cpp $(RIOTBUILD_CONFIG_HEADER_C) $(Q)$(CCACHE) $(CXX) \ -DRIOT_FILE_RELATIVE=\"$(patsubst $(RIOTBASE)/%,%,$(abspath $<))\" \ -DRIOT_FILE_NOPATH=\"$(notdir $<)\" \ $(CXXFLAGS) $(CXXINCLUDES) $(INCLUDES) -MD -MP -c -o $@ $(abspath $<) -$(ASMOBJ): $(BINDIR)/$(MODULE)/%.o: %.s +$(ASMOBJ): $(BINDIR)/$(MODULE)/%.o: $(D)/%.s $(Q)$(AS) $(ASFLAGS) -o $@ $(abspath $<) -$(ASSMOBJ): $(BINDIR)/$(MODULE)/%.o: %.S $(RIOTBUILD_CONFIG_HEADER_C) +$(ASSMOBJ): $(BINDIR)/$(MODULE)/%.o: $(D)/%.S $(RIOTBUILD_CONFIG_HEADER_C) $(Q)$(CCAS) $(CCASFLAGS) $(INCLUDES) -MD -MP -c -o $@ $(abspath $<) From 3fd05836569801f93bed147cc818b25b383d157c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Wed, 4 Oct 2017 12:26:17 +0200 Subject: [PATCH 09/28] Makefile.base: undefine 'local' variables --- Makefile.base | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Makefile.base b/Makefile.base index 0a2db847d4ca..5bff4a6ba2e1 100644 --- a/Makefile.base +++ b/Makefile.base @@ -117,3 +117,18 @@ all: ..nothing_$(MODULE) # pull in dependency info for *existing* .o files # deleted header files will be silently ignored -include $(DEP) + +# Undefine local variables as they would break if in non-recursive mode +undefine SRC +undefine SRC_NOLTO +undefine SRCXX +undefine ASMSRC +undefine ASSMSRC + +undefine SUBMODULES +undefine NO_AUTO_SRC +undefine BASE_MODULE +undefine SUBMODULES_NOFORCE + +undefine MODULE +undefine MODULE_DIR From ed76b6a2bf2bf1e82ce2d73805bf77ddfb95179f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 2 Oct 2017 16:26:59 +0200 Subject: [PATCH 10/28] Makefile.base: use defined XXXFLAGS_module_name This will allow setting modules specific FLAGS in non recursive mode. --- Makefile.base | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Makefile.base b/Makefile.base index 5bff4a6ba2e1..7f2f8b08139a 100644 --- a/Makefile.base +++ b/Makefile.base @@ -66,30 +66,41 @@ $(BINDIR)/$(MODULE).a $(OBJ): | $(BINDIR)/$(MODULE)/ $(BINDIR)/$(MODULE)/: $(Q)mkdir -p $@ -CXXFLAGS = $(filter-out $(CXXUWFLAGS), $(CFLAGS)) $(CXXEXFLAGS) -CCASFLAGS = $(filter-out $(CCASUWFLAGS), $(CFLAGS)) $(CCASEXFLAGS) +# Use MODULE specific FLAGS variables for non recursive makefiles +# In targets, they are only evaluated at execution time +CFLAGS_$(MODULE) := $(CFLAGS) $(CFLAGS_$(MODULE)) +CXXFLAGS_$(MODULE) := $(filter-out $(CXXUWFLAGS), $(CFLAGS_$(MODULE))) $(CXXEXFLAGS) $(CXXFLAGS_$(MODULE)) +ASFLAGS_$(MODULE) := $(ASFLAGS) $(ASFLAGS_$(MODULE)) +CCASFLAGS_$(MODULE) := $(filter-out $(CCASUWFLAGS), $(CFLAGS_$(MODULE))) $(CCASEXFLAGS) $(CCASFLAGS_$(MODULE)) # compile and generate dependency info $(OBJC_LTO): CFLAGS+=$(LTOFLAGS) +# Return module name from object path +module_from_obj = $(notdir $(realpath $(dir $1))) + $(OBJC): $(BINDIR)/$(MODULE)/%.o: $(D)/%.c $(RIOTBUILD_CONFIG_HEADER_C) + $(eval MODULE = $(call module_from_obj,$@)) $(Q)$(CCACHE) $(CC) \ -DRIOT_FILE_RELATIVE=\"$(patsubst $(RIOTBASE)/%,%,$(abspath $<))\" \ -DRIOT_FILE_NOPATH=\"$(notdir $<)\" \ - $(CFLAGS) $(INCLUDES) -MD -MP -c -o $@ $(abspath $<) + $(CFLAGS_$(MODULE)) $(INCLUDES) -MD -MP -c -o $@ $(abspath $<) $(OBJCXX): $(BINDIR)/$(MODULE)/%.o: $(D)/%.cpp $(RIOTBUILD_CONFIG_HEADER_C) + $(eval MODULE = $(call module_from_obj,$@)) $(Q)$(CCACHE) $(CXX) \ -DRIOT_FILE_RELATIVE=\"$(patsubst $(RIOTBASE)/%,%,$(abspath $<))\" \ -DRIOT_FILE_NOPATH=\"$(notdir $<)\" \ - $(CXXFLAGS) $(CXXINCLUDES) $(INCLUDES) -MD -MP -c -o $@ $(abspath $<) + $(CXXFLAGS_$(MODULE)) $(CXXINCLUDES) $(INCLUDES) -MD -MP -c -o $@ $(abspath $<) $(ASMOBJ): $(BINDIR)/$(MODULE)/%.o: $(D)/%.s - $(Q)$(AS) $(ASFLAGS) -o $@ $(abspath $<) + $(eval MODULE = $(call module_from_obj,$@)) + $(Q)$(AS) $(ASFLAGS_$(MODULE)) -o $@ $(abspath $<) $(ASSMOBJ): $(BINDIR)/$(MODULE)/%.o: $(D)/%.S $(RIOTBUILD_CONFIG_HEADER_C) - $(Q)$(CCAS) $(CCASFLAGS) $(INCLUDES) -MD -MP -c -o $@ $(abspath $<) + $(eval MODULE = $(call module_from_obj,$@)) + $(Q)$(CCAS) $(CCASFLAGS_$(MODULE)) $(INCLUDES) -MD -MP -c -o $@ $(abspath $<) # Building DIRS From 54f61d74b9f49238c910dbc9db9afa6417fafbc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 2 Oct 2017 17:00:03 +0200 Subject: [PATCH 11/28] VERIFY ME IF MISSING OTHER FILES! Modules Makefile: set FLAGS specific to current module. --- cpu/arm7_common/Makefile | 2 +- sys/cbor/Makefile | 2 +- sys/cpp11-compat/Makefile | 2 +- sys/crypto/Makefile | 2 +- sys/net/application_layer/uhcp/Makefile | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cpu/arm7_common/Makefile b/cpu/arm7_common/Makefile index 3a26b43827b7..af815a285be8 100644 --- a/cpu/arm7_common/Makefile +++ b/cpu/arm7_common/Makefile @@ -1,4 +1,4 @@ -CFLAGS += $(CFLAGS_BASIC) +CFLAGS_arm7_common += $(CFLAGS_BASIC) DIRS = periph diff --git a/sys/cbor/Makefile b/sys/cbor/Makefile index bd0de579634d..fe6378abf085 100644 --- a/sys/cbor/Makefile +++ b/sys/cbor/Makefile @@ -1,7 +1,7 @@ MODULE = cbor ifneq ($(shell uname -s),Darwin) - CFLAGS += -D_XOPEN_SOURCE=600 + CFLAGS_cbor += -D_XOPEN_SOURCE=600 endif include $(RIOTBASE)/Makefile.base diff --git a/sys/cpp11-compat/Makefile b/sys/cpp11-compat/Makefile index 9e24ecf1373a..f75cf8b555a1 100644 --- a/sys/cpp11-compat/Makefile +++ b/sys/cpp11-compat/Makefile @@ -1,4 +1,4 @@ # This module requires cpp 11 -CXXEXFLAGS += -std=c++11 +CXXFLAGS_cpp11-compat += -std=c++11 include $(RIOTBASE)/Makefile.base diff --git a/sys/crypto/Makefile b/sys/crypto/Makefile index 883d8c0aeda9..eeabc4a4222e 100644 --- a/sys/crypto/Makefile +++ b/sys/crypto/Makefile @@ -2,6 +2,6 @@ ifeq (, ${RIOT_CHACHA_PRNG_DEFAULT}) RIOT_CHACHA_PRNG_DEFAULT := $(shell head -c 64 /dev/urandom | hexdump -e '"0x%4xull,"') endif -CFLAGS += -DRIOT_CHACHA_PRNG_DEFAULT="${RIOT_CHACHA_PRNG_DEFAULT}" +CFLAGS_crypto += -DRIOT_CHACHA_PRNG_DEFAULT="${RIOT_CHACHA_PRNG_DEFAULT}" include $(RIOTBASE)/Makefile.base diff --git a/sys/net/application_layer/uhcp/Makefile b/sys/net/application_layer/uhcp/Makefile index 5bf81d28db45..fa31490449c5 100644 --- a/sys/net/application_layer/uhcp/Makefile +++ b/sys/net/application_layer/uhcp/Makefile @@ -1,3 +1,3 @@ -MODULE=uhcpc -CFLAGS += -DUHCP_CLIENT +MODULE = uhcpc +CFLAGS_uhcpc += -DUHCP_CLIENT include $(RIOTBASE)/Makefile.base From 7a8ca42995372699f3a43cb2f5c793c6e27cad27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 2 Oct 2017 17:22:32 +0200 Subject: [PATCH 12/28] MAGIC HERE SEE COMMENTS: Makefile.base: add support for non recursive makefiles By defining 'NONRECURSIVE', multiple modules Makefile can be included in the same makefile and handled seperately. WARNING: If for any reason, a module includes another Makefile before Makefile.base it will break the including makefile magic. So maybe it would be good separate it to a Makefile.base.head and Makefile.base.tail for this kind of modules. --- Makefile.base | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile.base b/Makefile.base index 7f2f8b08139a..3d95d7d92544 100644 --- a/Makefile.base +++ b/Makefile.base @@ -2,6 +2,14 @@ ifeq (, $(__RIOTBUILD_FLAG)) $(error You cannot build a module on its own. Use "make" in your application's directory instead.) endif +ifneq (,$(NONRECURSIVE)) + # This makefile should be included before including other makefiles ! + # Or you must define MODULE_DIR to the realpath of your module + # Including Makefile should be the penultimate included one + INCLUDING_MAKEFILE := $(shell echo $(MAKEFILE_LIST) | awk '{print $$(NF-1)}') + MODULE_DIR ?= $(realpath $(dir $(INCLUDING_MAKEFILE))) +endif + MODULE_DIR ?= $(CURDIR) MODULE ?= $(shell basename $(MODULE_DIR)) From fe320829200f6ff6457b1e5381ff8f5c149b3c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 2 Oct 2017 17:27:45 +0200 Subject: [PATCH 13/28] sys/Makefile: build all sys modules with nonrecursive makefiles --- sys/Makefile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/Makefile b/sys/Makefile index 8aa77af0bf47..70658adf6802 100644 --- a/sys/Makefile +++ b/sys/Makefile @@ -1,7 +1,12 @@ +NONRECURSIVE = 1 +# First include for current module (should be done before any 'include') +include $(RIOTBASE)/Makefile.base + +# Then take care of other modules + include Makefile.modules include $(wildcard */Makefile.modules) include $(wildcard */*/Makefile.modules) -DIRS += $(foreach module, $(USEMODULE), $(MODULE_DIR_$(module))) - -include $(RIOTBASE)/Makefile.base +MAKEFILE_DIRS = $(sort $(foreach module, $(USEMODULE), $(MODULE_DIR_$(module)))) +include $(MAKEFILE_DIRS:%=%/Makefile) From b096ee122d61fc3f9a7734f5d14fa1e737934a0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Wed, 4 Oct 2017 14:42:13 +0200 Subject: [PATCH 14/28] drivers: Makefile.modules: Define MODULE_DIR_$(module) vars Define MODULE_DIR_$(module) for each module in drivers. Makefile.modules are made to be importable from any directory. --- drivers/Makefile.modules | 8 ++++++++ drivers/cc110x/Makefile.modules | 4 ++++ 2 files changed, 12 insertions(+) create mode 100644 drivers/Makefile.modules create mode 100644 drivers/cc110x/Makefile.modules diff --git a/drivers/Makefile.modules b/drivers/Makefile.modules new file mode 100644 index 000000000000..6a640f28b9d9 --- /dev/null +++ b/drivers/Makefile.modules @@ -0,0 +1,8 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +# Define for modules which are directly in a subfolder +__SUBFOLDER_MODULES = $(patsubst $(D)/%/Makefile,%,$(wildcard $(D)/*/Makefile)) +$(foreach module, $(__SUBFOLDER_MODULES), $(eval MODULE_DIR_$(module) := $(D)/$(module))) + +undefine D diff --git a/drivers/cc110x/Makefile.modules b/drivers/cc110x/Makefile.modules new file mode 100644 index 000000000000..365830f7a7e8 --- /dev/null +++ b/drivers/cc110x/Makefile.modules @@ -0,0 +1,4 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +MODULE_DIR_gnrc_cc110x := $(D)/gnrc_cc110x From e54b05c7a9fd0a181a30386bcd4e50417ab7a120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Wed, 4 Oct 2017 14:54:30 +0200 Subject: [PATCH 15/28] drivers: use all Makefile.modules in drivers Makefile Use MODULE_DIR_$(module) variables to populate DIRS from USERMODULE DIRS is now calculaded directly in the main Makefile. --- drivers/Makefile | 5 ++++- drivers/cc110x/Makefile | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/Makefile b/drivers/Makefile index f1eb9fa686a0..3fd1ca768bb4 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -1,3 +1,6 @@ -DIRS += $(dir $(wildcard $(addsuffix /Makefile, ${USEMODULE}))) +include Makefile.modules +include $(wildcard */Makefile.modules) + +DIRS += $(foreach module, $(USEMODULE), $(MODULE_DIR_$(module))) include $(RIOTBASE)/Makefile.base diff --git a/drivers/cc110x/Makefile b/drivers/cc110x/Makefile index a6588efa9cd4..48422e909a47 100644 --- a/drivers/cc110x/Makefile +++ b/drivers/cc110x/Makefile @@ -1,3 +1 @@ -DIRS += gnrc_cc110x - include $(RIOTBASE)/Makefile.base From 9f704b666119deb9d51a00ab5e6c46b32c801b70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Wed, 4 Oct 2017 17:54:51 +0200 Subject: [PATCH 16/28] drivers/Makefile: build all drivers modules with nonrecursive makefiles --- drivers/Makefile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/Makefile b/drivers/Makefile index 3fd1ca768bb4..db7e3bd7c19a 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -1,6 +1,13 @@ +OLD_NONRECURSIVE := $(NONRECURSIVE) +NONRECURSIVE = 1 +# First include for current module (should be done before any 'include') +include $(RIOTBASE)/Makefile.base + +# Then take care of other modules + include Makefile.modules include $(wildcard */Makefile.modules) -DIRS += $(foreach module, $(USEMODULE), $(MODULE_DIR_$(module))) - -include $(RIOTBASE)/Makefile.base +MAKEFILE_DIRS = $(sort $(foreach module, $(USEMODULE), $(MODULE_DIR_$(module)))) +include $(MAKEFILE_DIRS:%=%/Makefile) +NONRECURSIVE := $(OLD_NONRECURSIVE) From b42911baec8a91ffa6e751ff9e61cecc7ba301cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Thu, 12 Oct 2017 15:02:58 +0200 Subject: [PATCH 17/28] boards/Makefile.modules: add MODULE_DIR for each boards module --- boards/Makefile.modules | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 boards/Makefile.modules diff --git a/boards/Makefile.modules b/boards/Makefile.modules new file mode 100644 index 000000000000..5c518d730275 --- /dev/null +++ b/boards/Makefile.modules @@ -0,0 +1,21 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +# $(BOARD) implements "board" module +MODULE_DIR_board := $(D)/$(BOARD) + +MODULE_DIR_arduino-atmega-common := $(D)/arduino-atmega-common +MODULE_DIR_arduino-mkr-common := $(D)/arduino-mkr-common +MODULE_DIR_mini := $(D)/calliope-mini/mini +MODULE_DIR_chronos-drivers := $(D)/chronos/drivers +MODULE_DIR_iotlab-common := $(D)/iotlab-common +MODULE_DIR_microbit := $(D)/microbit/microbit +MODULE_DIR_msb-430-common := $(D)/msb-430-common +MODULE_DIR_msb-430-common-drivers := $(D)/msb-430-common/drivers +MODULE_DIR_msba2-common := $(D)/msba2-common +MODULE_DIR_msba2-common-drivers := $(D)/msba2-common/drivers +MODULE_DIR_native-drivers := $(D)/native/drivers +MODULE_DIR_remote-common := $(D)/remote-common +MODULE_DIR_wsn430-common := $(D)/wsn430-common +MODULE_DIR_wsn430-common-drivers := $(D)/wsn430-common/drivers +MODULE_DIR_x86-multiboot-common := $(D)/x86-multiboot-common From 544aeb1bbd0a7b968cbecc2b270a9a5089413c78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Thu, 12 Oct 2017 15:05:58 +0200 Subject: [PATCH 18/28] makefiles/applications.inc.mk: build 'boards' directory --- boards/Makefile | 2 ++ makefiles/application.inc.mk | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 boards/Makefile diff --git a/boards/Makefile b/boards/Makefile new file mode 100644 index 000000000000..d0b4bcbb51e4 --- /dev/null +++ b/boards/Makefile @@ -0,0 +1,2 @@ +DIRS = $(RIOTBOARD)/$(BOARD) +include $(RIOTBASE)/Makefile.base diff --git a/makefiles/application.inc.mk b/makefiles/application.inc.mk index 36450d1e1d8a..4f2f5428ffd6 100644 --- a/makefiles/application.inc.mk +++ b/makefiles/application.inc.mk @@ -1,6 +1,6 @@ MODULE = $(APPLICATION) -DIRS += $(RIOTCPU)/$(CPU) $(RIOTBOARD)/$(BOARD) +DIRS += $(RIOTCPU)/$(CPU) $(RIOTBOARD) DIRS += $(RIOTBASE)/core $(RIOTBASE)/drivers $(RIOTBASE)/sys include $(RIOTBASE)/Makefile.base From 66358f1b47bc511557ab3fcbf6e86b0443eee3d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Thu, 12 Oct 2017 15:12:16 +0200 Subject: [PATCH 19/28] boards: use Makefile.modules in Makefile Use MODULE_DIR_$(module) variables to populate DIRS from USEMODULE. --- boards/Makefile | 4 +++- boards/arduino-duemilanove/Makefile | 2 -- boards/arduino-mega2560/Makefile | 2 -- boards/arduino-mkr1000/Makefile | 2 -- boards/arduino-mkrzero/Makefile | 2 -- boards/arduino-uno/Makefile | 2 -- boards/avsextrem/Makefile | 2 -- boards/calliope-mini/Makefile | 4 ---- boards/chronos/Makefile | 2 -- boards/iotlab-a8-m3/Makefile | 2 -- boards/iotlab-m3/Makefile | 2 -- boards/microbit/Makefile | 4 ---- boards/msb-430-common/Makefile | 2 -- boards/msb-430/Makefile | 2 -- boards/msb-430h/Makefile | 2 -- boards/msba2-common/Makefile | 2 -- boards/msba2/Makefile | 2 -- boards/native/Makefile | 3 +-- boards/qemu-i386/Makefile | 2 -- boards/remote-pa/Makefile | 2 -- boards/remote-reva/Makefile | 2 -- boards/remote-revb/Makefile | 2 -- boards/wsn430-v1_3b/Makefile | 2 -- boards/wsn430-v1_4/Makefile | 2 -- 24 files changed, 4 insertions(+), 51 deletions(-) diff --git a/boards/Makefile b/boards/Makefile index d0b4bcbb51e4..7e04d4392ab5 100644 --- a/boards/Makefile +++ b/boards/Makefile @@ -1,2 +1,4 @@ -DIRS = $(RIOTBOARD)/$(BOARD) +include Makefile.modules +DIRS = $(foreach module, $(USEMODULE), $(MODULE_DIR_$(module))) + include $(RIOTBASE)/Makefile.base diff --git a/boards/arduino-duemilanove/Makefile b/boards/arduino-duemilanove/Makefile index b597cd662a6f..f8fcbb53a065 100644 --- a/boards/arduino-duemilanove/Makefile +++ b/boards/arduino-duemilanove/Makefile @@ -1,5 +1,3 @@ MODULE = board -DIRS = $(RIOTBOARD)/arduino-atmega-common - include $(RIOTBASE)/Makefile.base diff --git a/boards/arduino-mega2560/Makefile b/boards/arduino-mega2560/Makefile index b597cd662a6f..f8fcbb53a065 100644 --- a/boards/arduino-mega2560/Makefile +++ b/boards/arduino-mega2560/Makefile @@ -1,5 +1,3 @@ MODULE = board -DIRS = $(RIOTBOARD)/arduino-atmega-common - include $(RIOTBASE)/Makefile.base diff --git a/boards/arduino-mkr1000/Makefile b/boards/arduino-mkr1000/Makefile index f2684f1e543a..f8fcbb53a065 100644 --- a/boards/arduino-mkr1000/Makefile +++ b/boards/arduino-mkr1000/Makefile @@ -1,5 +1,3 @@ MODULE = board -DIRS = $(RIOTBOARD)/arduino-mkr-common - include $(RIOTBASE)/Makefile.base diff --git a/boards/arduino-mkrzero/Makefile b/boards/arduino-mkrzero/Makefile index f2684f1e543a..f8fcbb53a065 100644 --- a/boards/arduino-mkrzero/Makefile +++ b/boards/arduino-mkrzero/Makefile @@ -1,5 +1,3 @@ MODULE = board -DIRS = $(RIOTBOARD)/arduino-mkr-common - include $(RIOTBASE)/Makefile.base diff --git a/boards/arduino-uno/Makefile b/boards/arduino-uno/Makefile index b597cd662a6f..f8fcbb53a065 100644 --- a/boards/arduino-uno/Makefile +++ b/boards/arduino-uno/Makefile @@ -1,5 +1,3 @@ MODULE = board -DIRS = $(RIOTBOARD)/arduino-atmega-common - include $(RIOTBASE)/Makefile.base diff --git a/boards/avsextrem/Makefile b/boards/avsextrem/Makefile index 5f15bf5c405c..f8fcbb53a065 100644 --- a/boards/avsextrem/Makefile +++ b/boards/avsextrem/Makefile @@ -1,5 +1,3 @@ MODULE = board -DIRS = $(RIOTBOARD)/msba2-common - include $(RIOTBASE)/Makefile.base diff --git a/boards/calliope-mini/Makefile b/boards/calliope-mini/Makefile index ed5e3a66ac2e..f8fcbb53a065 100644 --- a/boards/calliope-mini/Makefile +++ b/boards/calliope-mini/Makefile @@ -1,7 +1,3 @@ MODULE = board -ifneq (,$(filter mini,$(USEMODULE))) - DIRS += mini -endif - include $(RIOTBASE)/Makefile.base diff --git a/boards/chronos/Makefile b/boards/chronos/Makefile index 1f64a6ab7620..f8fcbb53a065 100644 --- a/boards/chronos/Makefile +++ b/boards/chronos/Makefile @@ -1,5 +1,3 @@ MODULE = board -DIRS = drivers - include $(RIOTBASE)/Makefile.base diff --git a/boards/iotlab-a8-m3/Makefile b/boards/iotlab-a8-m3/Makefile index 1e46aa27d7e1..f8fcbb53a065 100644 --- a/boards/iotlab-a8-m3/Makefile +++ b/boards/iotlab-a8-m3/Makefile @@ -1,5 +1,3 @@ MODULE = board -DIRS = $(RIOTBOARD)/iotlab-common - include $(RIOTBASE)/Makefile.base diff --git a/boards/iotlab-m3/Makefile b/boards/iotlab-m3/Makefile index 1e46aa27d7e1..f8fcbb53a065 100644 --- a/boards/iotlab-m3/Makefile +++ b/boards/iotlab-m3/Makefile @@ -1,5 +1,3 @@ MODULE = board -DIRS = $(RIOTBOARD)/iotlab-common - include $(RIOTBASE)/Makefile.base diff --git a/boards/microbit/Makefile b/boards/microbit/Makefile index c3375d9f760f..f8fcbb53a065 100644 --- a/boards/microbit/Makefile +++ b/boards/microbit/Makefile @@ -1,7 +1,3 @@ MODULE = board -ifneq (,$(filter microbit,$(USEMODULE))) - DIRS += microbit -endif - include $(RIOTBASE)/Makefile.base diff --git a/boards/msb-430-common/Makefile b/boards/msb-430-common/Makefile index afb0e3e90108..5173bf8f1a21 100644 --- a/boards/msb-430-common/Makefile +++ b/boards/msb-430-common/Makefile @@ -1,5 +1,3 @@ MODULE = msb-430-common -DIRS = drivers - include $(RIOTBASE)/Makefile.base diff --git a/boards/msb-430/Makefile b/boards/msb-430/Makefile index 7746dd4dd9f1..f8fcbb53a065 100644 --- a/boards/msb-430/Makefile +++ b/boards/msb-430/Makefile @@ -1,5 +1,3 @@ MODULE = board -DIRS = $(RIOTBOARD)/msb-430-common - include $(RIOTBASE)/Makefile.base diff --git a/boards/msb-430h/Makefile b/boards/msb-430h/Makefile index 7746dd4dd9f1..f8fcbb53a065 100644 --- a/boards/msb-430h/Makefile +++ b/boards/msb-430h/Makefile @@ -1,5 +1,3 @@ MODULE = board -DIRS = $(RIOTBOARD)/msb-430-common - include $(RIOTBASE)/Makefile.base diff --git a/boards/msba2-common/Makefile b/boards/msba2-common/Makefile index da37386c49e0..d8b8178dba98 100644 --- a/boards/msba2-common/Makefile +++ b/boards/msba2-common/Makefile @@ -1,5 +1,3 @@ MODULE = msba2-common -DIRS = drivers - include $(RIOTBASE)/Makefile.base diff --git a/boards/msba2/Makefile b/boards/msba2/Makefile index 5f15bf5c405c..f8fcbb53a065 100644 --- a/boards/msba2/Makefile +++ b/boards/msba2/Makefile @@ -1,5 +1,3 @@ MODULE = board -DIRS = $(RIOTBOARD)/msba2-common - include $(RIOTBASE)/Makefile.base diff --git a/boards/native/Makefile b/boards/native/Makefile index 4bd97629910c..36c874b669de 100644 --- a/boards/native/Makefile +++ b/boards/native/Makefile @@ -1,7 +1,6 @@ MODULE = board -DIRS = drivers - include $(RIOTBASE)/Makefile.base +# TODO Why here ? INCLUDES = $(NATIVEINCLUDES) diff --git a/boards/qemu-i386/Makefile b/boards/qemu-i386/Makefile index 003e3fc6e68b..f8fcbb53a065 100644 --- a/boards/qemu-i386/Makefile +++ b/boards/qemu-i386/Makefile @@ -1,5 +1,3 @@ MODULE = board -DIRS = $(RIOTBOARD)/x86-multiboot-common - include $(RIOTBASE)/Makefile.base diff --git a/boards/remote-pa/Makefile b/boards/remote-pa/Makefile index 3e20e72e8c37..f8fcbb53a065 100644 --- a/boards/remote-pa/Makefile +++ b/boards/remote-pa/Makefile @@ -1,5 +1,3 @@ MODULE = board -DIRS = $(RIOTBOARD)/remote-common - include $(RIOTBASE)/Makefile.base diff --git a/boards/remote-reva/Makefile b/boards/remote-reva/Makefile index 3e20e72e8c37..f8fcbb53a065 100644 --- a/boards/remote-reva/Makefile +++ b/boards/remote-reva/Makefile @@ -1,5 +1,3 @@ MODULE = board -DIRS = $(RIOTBOARD)/remote-common - include $(RIOTBASE)/Makefile.base diff --git a/boards/remote-revb/Makefile b/boards/remote-revb/Makefile index 3e20e72e8c37..f8fcbb53a065 100644 --- a/boards/remote-revb/Makefile +++ b/boards/remote-revb/Makefile @@ -1,5 +1,3 @@ MODULE = board -DIRS = $(RIOTBOARD)/remote-common - include $(RIOTBASE)/Makefile.base diff --git a/boards/wsn430-v1_3b/Makefile b/boards/wsn430-v1_3b/Makefile index c28e0e33e316..f8fcbb53a065 100644 --- a/boards/wsn430-v1_3b/Makefile +++ b/boards/wsn430-v1_3b/Makefile @@ -1,5 +1,3 @@ MODULE = board -DIRS = $(RIOTBOARD)/wsn430-common - include $(RIOTBASE)/Makefile.base diff --git a/boards/wsn430-v1_4/Makefile b/boards/wsn430-v1_4/Makefile index c28e0e33e316..f8fcbb53a065 100644 --- a/boards/wsn430-v1_4/Makefile +++ b/boards/wsn430-v1_4/Makefile @@ -1,5 +1,3 @@ MODULE = board -DIRS = $(RIOTBOARD)/wsn430-common - include $(RIOTBASE)/Makefile.base From be0affe17f76cb8c0802884662b87d9868def7c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Thu, 12 Oct 2017 17:02:42 +0200 Subject: [PATCH 20/28] boards/Makefile: build all board/common modules with nonrecursive makefiles --- boards/Makefile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/boards/Makefile b/boards/Makefile index 7e04d4392ab5..0de47d5769bd 100644 --- a/boards/Makefile +++ b/boards/Makefile @@ -1,4 +1,12 @@ +OLD_NONRECURSIVE := $(NONRECURSIVE) +NONRECURSIVE = 1 +# First include for current module (should be done before any 'include') +include $(RIOTBASE)/Makefile.base + +# Then take care of other modules + include Makefile.modules -DIRS = $(foreach module, $(USEMODULE), $(MODULE_DIR_$(module))) -include $(RIOTBASE)/Makefile.base +MAKEFILE_DIRS = $(sort $(foreach module, $(USEMODULE), $(MODULE_DIR_$(module)))) +include $(MAKEFILE_DIRS:%=%/Makefile) +NONRECURSIVE := $(OLD_NONRECURSIVE) From 911bfa27da731574388bdfdccd078fab664938e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Thu, 12 Oct 2017 17:11:27 +0200 Subject: [PATCH 21/28] cpu: prefix all common modules by CPUCOMMON_ name --- cpu/atmega_common/periph/Makefile | 1 + cpu/mips32r2_common/Makefile.include | 2 +- cpu/mips32r2_common/periph/Makefile | 2 ++ cpu/mips_pic32_common/periph/Makefile | 2 ++ cpu/mips_pic32mx/Makefile.include | 2 +- cpu/mips_pic32mz/Makefile.include | 2 +- cpu/nrf5x_common/Makefile.include | 2 +- 7 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cpu/atmega_common/periph/Makefile b/cpu/atmega_common/periph/Makefile index 144a7a19b4fa..c8f48e906dbd 100644 --- a/cpu/atmega_common/periph/Makefile +++ b/cpu/atmega_common/periph/Makefile @@ -1,2 +1,3 @@ MODULE = atmega_common_periph + include $(RIOTMAKE)/periph.mk diff --git a/cpu/mips32r2_common/Makefile.include b/cpu/mips32r2_common/Makefile.include index ceaed692fc70..dcf6875a81b9 100644 --- a/cpu/mips32r2_common/Makefile.include +++ b/cpu/mips32r2_common/Makefile.include @@ -4,7 +4,7 @@ export APP_START=0x80000000 include $(RIOTMAKE)/arch/mips.inc.mk -export USEMODULE += periph +export USEMODULE += mips32r2_common_periph export USEMODULE += periph_common export USEMODULE += newlib diff --git a/cpu/mips32r2_common/periph/Makefile b/cpu/mips32r2_common/periph/Makefile index a36df249ac1d..162a1ce8dbcc 100644 --- a/cpu/mips32r2_common/periph/Makefile +++ b/cpu/mips32r2_common/periph/Makefile @@ -1 +1,3 @@ +MODULE = mips32r2_common_periph + include $(RIOTMAKE)/periph.mk diff --git a/cpu/mips_pic32_common/periph/Makefile b/cpu/mips_pic32_common/periph/Makefile index a36df249ac1d..73db0ce651b8 100644 --- a/cpu/mips_pic32_common/periph/Makefile +++ b/cpu/mips_pic32_common/periph/Makefile @@ -1 +1,3 @@ +MODULE = mips_pic32_common_periph + include $(RIOTMAKE)/periph.mk diff --git a/cpu/mips_pic32mx/Makefile.include b/cpu/mips_pic32mx/Makefile.include index 0b930d2e8f40..29d969b88afd 100644 --- a/cpu/mips_pic32mx/Makefile.include +++ b/cpu/mips_pic32mx/Makefile.include @@ -7,7 +7,7 @@ include $(RIOTCPU)/mips_pic32_common/Makefile.include export CFLAGS += -march=m4k -DSKIP_COPY_TO_RAM export USEMODULE += mips_pic32_common -export USEMODULE += periph +export USEMODULE += mips_pic32_common_periph export USEMODULE += periph_common export USEMODULE += newlib diff --git a/cpu/mips_pic32mz/Makefile.include b/cpu/mips_pic32mz/Makefile.include index cbff7d409fe5..bba69f9278b1 100644 --- a/cpu/mips_pic32mz/Makefile.include +++ b/cpu/mips_pic32mz/Makefile.include @@ -8,7 +8,7 @@ export CFLAGS += -march=m5101 -mmicromips -DSKIP_COPY_TO_RAM export CFLAGS += -DMIPS_MICROMIPS export USEMODULE += mips_pic32_common -export USEMODULE += periph +export USEMODULE += mips_pic32_common_periph export USEMODULE += periph_common export USEMODULE += newlib diff --git a/cpu/nrf5x_common/Makefile.include b/cpu/nrf5x_common/Makefile.include index 3bb12bc97558..3f35268e06a7 100644 --- a/cpu/nrf5x_common/Makefile.include +++ b/cpu/nrf5x_common/Makefile.include @@ -9,7 +9,7 @@ USEMODULE += periph_common USEMODULE += nrf5x_common_periph # link common cpu code -USEMODULE += cpu_common +USEMODULE += nrf5x_common # export the common include directory export INCLUDES += -I$(RIOTCPU)/nrf5x_common/include From d8ea116c7e12ef57500974f50f94699f2264d5e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Tue, 17 Oct 2017 18:42:36 +0200 Subject: [PATCH 22/28] cpu/Makefile.modules: Define MODULE_DIR_$(module) vars --- cpu/Makefile.modules | 10 ++++++++++ cpu/arm7_common/Makefile.modules | 5 +++++ cpu/atmega_common/Makefile.modules | 5 +++++ cpu/cc2538/Makefile.modules | 4 ++++ cpu/cortexm_common/Makefile.modules | 5 +++++ cpu/kinetis_common/Makefile.modules | 5 +++++ cpu/lpc2387/Makefile.modules | 5 +++++ cpu/mips32r2_common/Makefile.modules | 6 ++++++ cpu/mips_pic32_common/Makefile.modules | 5 +++++ cpu/msp430_common/Makefile.modules | 5 +++++ cpu/native/Makefile.modules | 7 +++++++ cpu/nrf5x_common/Makefile.modules | 6 ++++++ cpu/sam0_common/Makefile.modules | 5 +++++ cpu/stm32_common/Makefile.modules | 5 +++++ 14 files changed, 78 insertions(+) create mode 100644 cpu/Makefile.modules create mode 100644 cpu/arm7_common/Makefile.modules create mode 100644 cpu/atmega_common/Makefile.modules create mode 100644 cpu/cc2538/Makefile.modules create mode 100644 cpu/cortexm_common/Makefile.modules create mode 100644 cpu/kinetis_common/Makefile.modules create mode 100644 cpu/lpc2387/Makefile.modules create mode 100644 cpu/mips32r2_common/Makefile.modules create mode 100644 cpu/mips_pic32_common/Makefile.modules create mode 100644 cpu/msp430_common/Makefile.modules create mode 100644 cpu/native/Makefile.modules create mode 100644 cpu/nrf5x_common/Makefile.modules create mode 100644 cpu/sam0_common/Makefile.modules create mode 100644 cpu/stm32_common/Makefile.modules diff --git a/cpu/Makefile.modules b/cpu/Makefile.modules new file mode 100644 index 000000000000..882af291a0f5 --- /dev/null +++ b/cpu/Makefile.modules @@ -0,0 +1,10 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +# $(CPU) implements "cpu" module +MODULE_DIR_cpu := $(D)/$(CPU) + +# $(CPU)/periph implements "periph" module if it exists +ifneq (,$(wildcard $(D)/$(CPU)/periph/Makefile)) +MODULE_DIR_periph := $(D)/$(CPU)/periph +endif diff --git a/cpu/arm7_common/Makefile.modules b/cpu/arm7_common/Makefile.modules new file mode 100644 index 000000000000..321b926d49bd --- /dev/null +++ b/cpu/arm7_common/Makefile.modules @@ -0,0 +1,5 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +MODULE_DIR_arm7_common := $(D) +MODULE_DIR_arm7_common_periph := $(D)/periph diff --git a/cpu/atmega_common/Makefile.modules b/cpu/atmega_common/Makefile.modules new file mode 100644 index 000000000000..ef0c12cf6d3a --- /dev/null +++ b/cpu/atmega_common/Makefile.modules @@ -0,0 +1,5 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +MODULE_DIR_atmega_common := $(D) +MODULE_DIR_atmega_common_periph := $(D)/periph diff --git a/cpu/cc2538/Makefile.modules b/cpu/cc2538/Makefile.modules new file mode 100644 index 000000000000..5acad396affb --- /dev/null +++ b/cpu/cc2538/Makefile.modules @@ -0,0 +1,4 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +MODULE_DIR_cc2538_rf := $(D)/radio diff --git a/cpu/cortexm_common/Makefile.modules b/cpu/cortexm_common/Makefile.modules new file mode 100644 index 000000000000..a33edc0e0325 --- /dev/null +++ b/cpu/cortexm_common/Makefile.modules @@ -0,0 +1,5 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +MODULE_DIR_cortexm_common := $(D) +MODULE_DIR_cortexm_common_periph := $(D)/periph diff --git a/cpu/kinetis_common/Makefile.modules b/cpu/kinetis_common/Makefile.modules new file mode 100644 index 000000000000..e75608583825 --- /dev/null +++ b/cpu/kinetis_common/Makefile.modules @@ -0,0 +1,5 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +MODULE_DIR_kinetis_common := $(D) +MODULE_DIR_kinetis_common_periph := $(D)/periph diff --git a/cpu/lpc2387/Makefile.modules b/cpu/lpc2387/Makefile.modules new file mode 100644 index 000000000000..f09f684d4026 --- /dev/null +++ b/cpu/lpc2387/Makefile.modules @@ -0,0 +1,5 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +MODULE_DIR_mci := $(D)/mci +MODULE_DIR_i2c := $(D)/i2c diff --git a/cpu/mips32r2_common/Makefile.modules b/cpu/mips32r2_common/Makefile.modules new file mode 100644 index 000000000000..285a066a1827 --- /dev/null +++ b/cpu/mips32r2_common/Makefile.modules @@ -0,0 +1,6 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +MODULE_DIR_mips32r2_common := $(D) +MODULE_DIR_mips32r2_common_periph := $(D)/periph +MODULE_DIR_newlib_syscalls_mips_uhi := $(D)/newlib_syscalls_mips_uhi diff --git a/cpu/mips_pic32_common/Makefile.modules b/cpu/mips_pic32_common/Makefile.modules new file mode 100644 index 000000000000..b9be63e6a74f --- /dev/null +++ b/cpu/mips_pic32_common/Makefile.modules @@ -0,0 +1,5 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +MODULE_DIR_mips_pic32_common := $(D) +MODULE_DIR_mips_pic32_common_periph := $(D)/periph diff --git a/cpu/msp430_common/Makefile.modules b/cpu/msp430_common/Makefile.modules new file mode 100644 index 000000000000..7248c2e9c4c1 --- /dev/null +++ b/cpu/msp430_common/Makefile.modules @@ -0,0 +1,5 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +MODULE_DIR_msp430_common := $(D) +MODULE_DIR_msp430_common_periph := $(D)/periph diff --git a/cpu/native/Makefile.modules b/cpu/native/Makefile.modules new file mode 100644 index 000000000000..92115cc97dfb --- /dev/null +++ b/cpu/native/Makefile.modules @@ -0,0 +1,7 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +MODULE_DIR_native_vfs := $(D)/vfs +MODULE_DIR_netdev_tap := $(D)/netdev_tap +MODULE_DIR_mtd_native := $(D)/mtd +MODULE_DIR_can_linux := $(D)/can diff --git a/cpu/nrf5x_common/Makefile.modules b/cpu/nrf5x_common/Makefile.modules new file mode 100644 index 000000000000..570f1b56aad9 --- /dev/null +++ b/cpu/nrf5x_common/Makefile.modules @@ -0,0 +1,6 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +MODULE_DIR_nrf5x_common := $(D) +MODULE_DIR_nrf5x_common_periph := $(D)/periph +MODULE_DIR_nrfmin := $(D)/radio/nrfmin diff --git a/cpu/sam0_common/Makefile.modules b/cpu/sam0_common/Makefile.modules new file mode 100644 index 000000000000..b34fb87949fc --- /dev/null +++ b/cpu/sam0_common/Makefile.modules @@ -0,0 +1,5 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +MODULE_DIR_sam0_common := $(D) +MODULE_DIR_sam0_common_periph := $(D)/periph diff --git a/cpu/stm32_common/Makefile.modules b/cpu/stm32_common/Makefile.modules new file mode 100644 index 000000000000..095b413bd4c7 --- /dev/null +++ b/cpu/stm32_common/Makefile.modules @@ -0,0 +1,5 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +MODULE_DIR_stm32_common := $(D) +MODULE_DIR_stm32_common_periph := $(D)/periph From bf4d8d822ae0749dc884bd720070f82a25cf6f3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Thu, 12 Oct 2017 17:13:21 +0200 Subject: [PATCH 23/28] makefiles/applications.inc.mk: build 'cpu' directory --- cpu/Makefile | 4 ++++ makefiles/application.inc.mk | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 cpu/Makefile diff --git a/cpu/Makefile b/cpu/Makefile new file mode 100644 index 000000000000..8fd6959df491 --- /dev/null +++ b/cpu/Makefile @@ -0,0 +1,4 @@ +MODULE = cpu_dir + +DIRS = $(RIOTCPU)/$(CPU) +include $(RIOTBASE)/Makefile.base diff --git a/makefiles/application.inc.mk b/makefiles/application.inc.mk index 4f2f5428ffd6..770404c5e410 100644 --- a/makefiles/application.inc.mk +++ b/makefiles/application.inc.mk @@ -1,6 +1,6 @@ MODULE = $(APPLICATION) -DIRS += $(RIOTCPU)/$(CPU) $(RIOTBOARD) +DIRS += $(RIOTCPU) $(RIOTBOARD) DIRS += $(RIOTBASE)/core $(RIOTBASE)/drivers $(RIOTBASE)/sys include $(RIOTBASE)/Makefile.base From f57cd36e348652a0d31c5fc1e9a44af5513018e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Thu, 12 Oct 2017 17:15:54 +0200 Subject: [PATCH 24/28] cpu: use Makefile.modules in Makefile Use MODULE_DIR_$(module) variables to populate DIRS from USEMODULE. --- cpu/Makefile | 5 ++++- cpu/arm7_common/Makefile | 2 -- cpu/atmega1281/Makefile | 3 --- cpu/atmega2560/Makefile | 2 -- cpu/atmega328p/Makefile | 2 -- cpu/atmega_common/Makefile | 2 -- cpu/cc2538/Makefile | 8 -------- cpu/cc26x0/Makefile | 3 --- cpu/cc430/Makefile | 2 -- cpu/cortexm_common/Makefile | 2 -- cpu/ezr32wg/Makefile | 3 --- cpu/k22f/Makefile | 3 --- cpu/k60/Makefile | 3 --- cpu/k64f/Makefile | 3 --- cpu/kinetis_common/Makefile | 2 -- cpu/kw2xd/Makefile | 3 --- cpu/lm4f120/Makefile | 3 --- cpu/lpc1768/Makefile | 3 --- cpu/lpc2387/Makefile | 9 --------- cpu/mips32r2_common/Makefile | 2 -- cpu/mips_pic32_common/Makefile | 1 - cpu/mips_pic32mx/Makefile | 2 -- cpu/mips_pic32mz/Makefile | 2 -- cpu/msp430_common/Makefile | 2 -- cpu/msp430fxyz/Makefile | 2 -- cpu/native/Makefile | 15 --------------- cpu/native/vfs/Makefile | 2 +- cpu/nrf51/Makefile | 3 --- cpu/nrf52/Makefile | 3 --- cpu/nrf5x_common/Makefile | 8 -------- cpu/sam0_common/Makefile | 2 -- cpu/sam3/Makefile | 3 --- cpu/samd21/Makefile | 3 --- cpu/saml21/Makefile | 3 --- cpu/stm32_common/Makefile | 2 -- cpu/stm32f0/Makefile | 3 --- cpu/stm32f1/Makefile | 3 --- cpu/stm32f2/Makefile | 3 --- cpu/stm32f3/Makefile | 3 --- cpu/stm32f4/Makefile | 3 --- cpu/stm32f7/Makefile | 3 --- cpu/stm32l0/Makefile | 3 --- cpu/stm32l1/Makefile | 3 --- cpu/stm32l4/Makefile | 3 --- 44 files changed, 5 insertions(+), 140 deletions(-) diff --git a/cpu/Makefile b/cpu/Makefile index 8fd6959df491..ab85226db139 100644 --- a/cpu/Makefile +++ b/cpu/Makefile @@ -1,4 +1,7 @@ MODULE = cpu_dir -DIRS = $(RIOTCPU)/$(CPU) +include Makefile.modules +include $(wildcard */Makefile.modules) + +DIRS = $(foreach module, $(USEMODULE), $(MODULE_DIR_$(module))) include $(RIOTBASE)/Makefile.base diff --git a/cpu/arm7_common/Makefile b/cpu/arm7_common/Makefile index af815a285be8..5ae133f308e3 100644 --- a/cpu/arm7_common/Makefile +++ b/cpu/arm7_common/Makefile @@ -1,5 +1,3 @@ CFLAGS_arm7_common += $(CFLAGS_BASIC) -DIRS = periph - include $(RIOTBASE)/Makefile.base diff --git a/cpu/atmega1281/Makefile b/cpu/atmega1281/Makefile index e17e41db7225..e33bd31107d3 100644 --- a/cpu/atmega1281/Makefile +++ b/cpu/atmega1281/Makefile @@ -1,5 +1,2 @@ -# define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS = $(ATMEGA_COMMON) include $(RIOTBASE)/Makefile.base diff --git a/cpu/atmega2560/Makefile b/cpu/atmega2560/Makefile index e17e41db7225..234d3a6d5312 100644 --- a/cpu/atmega2560/Makefile +++ b/cpu/atmega2560/Makefile @@ -1,5 +1,3 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS = $(ATMEGA_COMMON) include $(RIOTBASE)/Makefile.base diff --git a/cpu/atmega328p/Makefile b/cpu/atmega328p/Makefile index 81f110b68d09..45f8651f8e3f 100644 --- a/cpu/atmega328p/Makefile +++ b/cpu/atmega328p/Makefile @@ -1,6 +1,4 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS = $(ATMEGA_COMMON) include $(RIOTBASE)/Makefile.base diff --git a/cpu/atmega_common/Makefile b/cpu/atmega_common/Makefile index 387e91627c45..6bfabb271f80 100644 --- a/cpu/atmega_common/Makefile +++ b/cpu/atmega_common/Makefile @@ -1,5 +1,3 @@ # define the module that is build MODULE = atmega_common -# add a list of subdirectories, that should also be build -DIRS = periph include $(RIOTBASE)/Makefile.base diff --git a/cpu/cc2538/Makefile b/cpu/cc2538/Makefile index 069fc4e400d4..a4c3b7258e60 100644 --- a/cpu/cc2538/Makefile +++ b/cpu/cc2538/Makefile @@ -1,14 +1,6 @@ # Define the module that is built: MODULE = cpu -# Add a list of subdirectories, that should also be built: -DIRS = periph $(RIOTCPU)/cortexm_common - -# cc2538_rf radio driver -ifneq (,$(filter cc2538_rf,$(USEMODULE))) - DIRS += radio -endif - # (file triggers compiler bug. see #5775) SRC_NOLTO += vectors.c diff --git a/cpu/cc26x0/Makefile b/cpu/cc26x0/Makefile index 40dc0d8f0581..a4c3b7258e60 100644 --- a/cpu/cc26x0/Makefile +++ b/cpu/cc26x0/Makefile @@ -1,9 +1,6 @@ # Define the module that is built: MODULE = cpu -# Add a list of subdirectories, that should also be built: -DIRS = periph $(RIOTCPU)/cortexm_common - # (file triggers compiler bug. see #5775) SRC_NOLTO += vectors.c diff --git a/cpu/cc430/Makefile b/cpu/cc430/Makefile index d523ddf700a5..08e25a221a23 100644 --- a/cpu/cc430/Makefile +++ b/cpu/cc430/Makefile @@ -1,5 +1,3 @@ MODULE = cpu -DIRS = $(RIOTCPU)/msp430_common periph - include $(RIOTBASE)/Makefile.base diff --git a/cpu/cortexm_common/Makefile b/cpu/cortexm_common/Makefile index 144a76712b2d..f08fa96d44f6 100644 --- a/cpu/cortexm_common/Makefile +++ b/cpu/cortexm_common/Makefile @@ -5,6 +5,4 @@ SRC_NOLTO += thread_arch.c # see https://github.com/RIOT-OS/RIOT/issues/5775. SRC_NOLTO += vectors_cortexm.c -DIRS = periph - include $(RIOTBASE)/Makefile.base diff --git a/cpu/ezr32wg/Makefile b/cpu/ezr32wg/Makefile index edc9a57a6bdb..a857212883bc 100644 --- a/cpu/ezr32wg/Makefile +++ b/cpu/ezr32wg/Makefile @@ -1,9 +1,6 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS = periph $(RIOTCPU)/cortexm_common - # (file triggers compiler bug. see #5775) SRC_NOLTO += vectors.c diff --git a/cpu/k22f/Makefile b/cpu/k22f/Makefile index 4e53b72929a0..45f8651f8e3f 100644 --- a/cpu/k22f/Makefile +++ b/cpu/k22f/Makefile @@ -1,7 +1,4 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories that should also be built -DIRS = periph $(RIOTCPU)/cortexm_common $(KINETIS_COMMON) - include $(RIOTBASE)/Makefile.base diff --git a/cpu/k60/Makefile b/cpu/k60/Makefile index 12ba41f9cf16..45f8651f8e3f 100644 --- a/cpu/k60/Makefile +++ b/cpu/k60/Makefile @@ -1,7 +1,4 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS = periph $(RIOTCPU)/cortexm_common $(KINETIS_COMMON) - include $(RIOTBASE)/Makefile.base diff --git a/cpu/k64f/Makefile b/cpu/k64f/Makefile index 12ba41f9cf16..45f8651f8e3f 100644 --- a/cpu/k64f/Makefile +++ b/cpu/k64f/Makefile @@ -1,7 +1,4 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS = periph $(RIOTCPU)/cortexm_common $(KINETIS_COMMON) - include $(RIOTBASE)/Makefile.base diff --git a/cpu/kinetis_common/Makefile b/cpu/kinetis_common/Makefile index 8b1b43dea4d6..c169393e3d19 100644 --- a/cpu/kinetis_common/Makefile +++ b/cpu/kinetis_common/Makefile @@ -1,8 +1,6 @@ # define the module that is build MODULE = kinetis_common -DIRS += periph - # (file triggers compiler bug. see #5775) SRC_NOLTO += vectors.c diff --git a/cpu/kw2xd/Makefile b/cpu/kw2xd/Makefile index 12ba41f9cf16..45f8651f8e3f 100644 --- a/cpu/kw2xd/Makefile +++ b/cpu/kw2xd/Makefile @@ -1,7 +1,4 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS = periph $(RIOTCPU)/cortexm_common $(KINETIS_COMMON) - include $(RIOTBASE)/Makefile.base diff --git a/cpu/lm4f120/Makefile b/cpu/lm4f120/Makefile index edc9a57a6bdb..a857212883bc 100644 --- a/cpu/lm4f120/Makefile +++ b/cpu/lm4f120/Makefile @@ -1,9 +1,6 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS = periph $(RIOTCPU)/cortexm_common - # (file triggers compiler bug. see #5775) SRC_NOLTO += vectors.c diff --git a/cpu/lpc1768/Makefile b/cpu/lpc1768/Makefile index edc9a57a6bdb..a857212883bc 100644 --- a/cpu/lpc1768/Makefile +++ b/cpu/lpc1768/Makefile @@ -1,9 +1,6 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS = periph $(RIOTCPU)/cortexm_common - # (file triggers compiler bug. see #5775) SRC_NOLTO += vectors.c diff --git a/cpu/lpc2387/Makefile b/cpu/lpc2387/Makefile index 838625f8da33..33d93fe550ec 100644 --- a/cpu/lpc2387/Makefile +++ b/cpu/lpc2387/Makefile @@ -2,13 +2,4 @@ MODULE =cpu include $(RIOTCPU)/$(CPU)/Makefile.include -DIRS = $(RIOTCPU)/arm7_common periph - -ifneq (,$(filter mci,$(USEMODULE))) - DIRS += mci -endif -ifneq (,$(filter i2c,$(USEMODULE))) - DIRS += i2c -endif - include $(RIOTBASE)/Makefile.base diff --git a/cpu/mips32r2_common/Makefile b/cpu/mips32r2_common/Makefile index 9524c712945c..e33bd31107d3 100644 --- a/cpu/mips32r2_common/Makefile +++ b/cpu/mips32r2_common/Makefile @@ -1,4 +1,2 @@ MODULE = cpu -DIRS = periph newlib_syscalls_mips_uhi - include $(RIOTBASE)/Makefile.base diff --git a/cpu/mips_pic32_common/Makefile b/cpu/mips_pic32_common/Makefile index 66e1405a83b4..48422e909a47 100644 --- a/cpu/mips_pic32_common/Makefile +++ b/cpu/mips_pic32_common/Makefile @@ -1,2 +1 @@ -DIRS += periph include $(RIOTBASE)/Makefile.base diff --git a/cpu/mips_pic32mx/Makefile b/cpu/mips_pic32mx/Makefile index 6f41cad6c090..62e307967418 100644 --- a/cpu/mips_pic32mx/Makefile +++ b/cpu/mips_pic32mx/Makefile @@ -3,6 +3,4 @@ MODULE = cpu USEMODULE += mips_pic32_common USEMODULE += mips32r2_common -DIRS += $(RIOTCPU)/mips_pic32_common $(RIOTCPU)/mips32r2_common - include $(RIOTBASE)/Makefile.base diff --git a/cpu/mips_pic32mz/Makefile b/cpu/mips_pic32mz/Makefile index 6f41cad6c090..62e307967418 100644 --- a/cpu/mips_pic32mz/Makefile +++ b/cpu/mips_pic32mz/Makefile @@ -3,6 +3,4 @@ MODULE = cpu USEMODULE += mips_pic32_common USEMODULE += mips32r2_common -DIRS += $(RIOTCPU)/mips_pic32_common $(RIOTCPU)/mips32r2_common - include $(RIOTBASE)/Makefile.base diff --git a/cpu/msp430_common/Makefile b/cpu/msp430_common/Makefile index c8b2ffd8f1e6..93db83f9fbe4 100644 --- a/cpu/msp430_common/Makefile +++ b/cpu/msp430_common/Makefile @@ -1,5 +1,3 @@ MODULE = msp430_common -DIRS = periph - include $(RIOTBASE)/Makefile.base diff --git a/cpu/msp430fxyz/Makefile b/cpu/msp430fxyz/Makefile index 5fe0beeda735..33d93fe550ec 100644 --- a/cpu/msp430fxyz/Makefile +++ b/cpu/msp430fxyz/Makefile @@ -2,6 +2,4 @@ MODULE =cpu include $(RIOTCPU)/$(CPU)/Makefile.include -DIRS = $(RIOTCPU)/msp430_common periph - include $(RIOTBASE)/Makefile.base diff --git a/cpu/native/Makefile b/cpu/native/Makefile index a19c566bc4a7..e4ad907bcf9d 100644 --- a/cpu/native/Makefile +++ b/cpu/native/Makefile @@ -1,20 +1,5 @@ MODULE = cpu -DIRS += periph - -ifneq (,$(filter native_vfs,$(USEMODULE))) - DIRS += vfs -endif -ifneq (,$(filter netdev_tap,$(USEMODULE))) - DIRS += netdev_tap -endif -ifneq (,$(filter mtd_native,$(USEMODULE))) - DIRS += mtd -endif -ifneq (,$(filter can_linux,$(USEMODULE))) - DIRS += can -endif - include $(RIOTBASE)/Makefile.base INCLUDES = $(NATIVEINCLUDES) diff --git a/cpu/native/vfs/Makefile b/cpu/native/vfs/Makefile index e3b46ebd7f4e..2faf9c64d0d2 100644 --- a/cpu/native/vfs/Makefile +++ b/cpu/native/vfs/Makefile @@ -1,3 +1,3 @@ -MODULE=native_vfs +MODULE = native_vfs include $(RIOTBASE)/Makefile.base diff --git a/cpu/nrf51/Makefile b/cpu/nrf51/Makefile index 7600b58931f0..a857212883bc 100644 --- a/cpu/nrf51/Makefile +++ b/cpu/nrf51/Makefile @@ -1,9 +1,6 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS = periph $(RIOTCPU)/cortexm_common $(RIOTCPU)/nrf5x_common - # (file triggers compiler bug. see #5775) SRC_NOLTO += vectors.c diff --git a/cpu/nrf52/Makefile b/cpu/nrf52/Makefile index 7600b58931f0..a857212883bc 100644 --- a/cpu/nrf52/Makefile +++ b/cpu/nrf52/Makefile @@ -1,9 +1,6 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS = periph $(RIOTCPU)/cortexm_common $(RIOTCPU)/nrf5x_common - # (file triggers compiler bug. see #5775) SRC_NOLTO += vectors.c diff --git a/cpu/nrf5x_common/Makefile b/cpu/nrf5x_common/Makefile index ef599b387d55..48422e909a47 100644 --- a/cpu/nrf5x_common/Makefile +++ b/cpu/nrf5x_common/Makefile @@ -1,9 +1 @@ -MODULE = cpu_common -DIRS = periph - -# build one of the radio drivers, if enabled -ifneq (,$(filter nrfmin,$(USEMODULE))) - DIRS += radio/nrfmin -endif - include $(RIOTBASE)/Makefile.base diff --git a/cpu/sam0_common/Makefile b/cpu/sam0_common/Makefile index e09377cd1e39..48422e909a47 100644 --- a/cpu/sam0_common/Makefile +++ b/cpu/sam0_common/Makefile @@ -1,3 +1 @@ -DIRS = periph - include $(RIOTBASE)/Makefile.base diff --git a/cpu/sam3/Makefile b/cpu/sam3/Makefile index 7907dbac9774..a857212883bc 100644 --- a/cpu/sam3/Makefile +++ b/cpu/sam3/Makefile @@ -1,9 +1,6 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS = periph $(RIOTCPU)/cortexm_common $(RIOTCPU)/sam_common - # (file triggers compiler bug. see #5775) SRC_NOLTO += vectors.c diff --git a/cpu/samd21/Makefile b/cpu/samd21/Makefile index 8794dfbc47ef..a857212883bc 100644 --- a/cpu/samd21/Makefile +++ b/cpu/samd21/Makefile @@ -1,9 +1,6 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS = periph $(RIOTCPU)/cortexm_common $(RIOTCPU)/sam0_common - # (file triggers compiler bug. see #5775) SRC_NOLTO += vectors.c diff --git a/cpu/saml21/Makefile b/cpu/saml21/Makefile index 8794dfbc47ef..a857212883bc 100644 --- a/cpu/saml21/Makefile +++ b/cpu/saml21/Makefile @@ -1,9 +1,6 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS = periph $(RIOTCPU)/cortexm_common $(RIOTCPU)/sam0_common - # (file triggers compiler bug. see #5775) SRC_NOLTO += vectors.c diff --git a/cpu/stm32_common/Makefile b/cpu/stm32_common/Makefile index f367a0fc7375..a8d1ddfd073f 100644 --- a/cpu/stm32_common/Makefile +++ b/cpu/stm32_common/Makefile @@ -1,5 +1,3 @@ MODULE = stm32_common -DIRS = periph - include $(RIOTBASE)/Makefile.base diff --git a/cpu/stm32f0/Makefile b/cpu/stm32f0/Makefile index 9ee4ce4e3e23..a857212883bc 100644 --- a/cpu/stm32f0/Makefile +++ b/cpu/stm32f0/Makefile @@ -1,9 +1,6 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS = periph $(RIOTCPU)/cortexm_common $(RIOTCPU)/stm32_common - # (file triggers compiler bug. see #5775) SRC_NOLTO += vectors.c diff --git a/cpu/stm32f1/Makefile b/cpu/stm32f1/Makefile index 7610bbb5e2a8..a857212883bc 100644 --- a/cpu/stm32f1/Makefile +++ b/cpu/stm32f1/Makefile @@ -1,9 +1,6 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS += periph $(RIOTCPU)/cortexm_common $(RIOTCPU)/stm32_common - # (file triggers compiler bug. see #5775) SRC_NOLTO += vectors.c diff --git a/cpu/stm32f2/Makefile b/cpu/stm32f2/Makefile index 9836e38e6d8c..45f8651f8e3f 100644 --- a/cpu/stm32f2/Makefile +++ b/cpu/stm32f2/Makefile @@ -1,7 +1,4 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS = periph $(RIOTCPU)/cortexm_common $(RIOTCPU)/stm32_common - include $(RIOTBASE)/Makefile.base diff --git a/cpu/stm32f3/Makefile b/cpu/stm32f3/Makefile index 9ee4ce4e3e23..a857212883bc 100644 --- a/cpu/stm32f3/Makefile +++ b/cpu/stm32f3/Makefile @@ -1,9 +1,6 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS = periph $(RIOTCPU)/cortexm_common $(RIOTCPU)/stm32_common - # (file triggers compiler bug. see #5775) SRC_NOLTO += vectors.c diff --git a/cpu/stm32f4/Makefile b/cpu/stm32f4/Makefile index 9ee4ce4e3e23..a857212883bc 100644 --- a/cpu/stm32f4/Makefile +++ b/cpu/stm32f4/Makefile @@ -1,9 +1,6 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS = periph $(RIOTCPU)/cortexm_common $(RIOTCPU)/stm32_common - # (file triggers compiler bug. see #5775) SRC_NOLTO += vectors.c diff --git a/cpu/stm32f7/Makefile b/cpu/stm32f7/Makefile index 7610bbb5e2a8..a857212883bc 100644 --- a/cpu/stm32f7/Makefile +++ b/cpu/stm32f7/Makefile @@ -1,9 +1,6 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS += periph $(RIOTCPU)/cortexm_common $(RIOTCPU)/stm32_common - # (file triggers compiler bug. see #5775) SRC_NOLTO += vectors.c diff --git a/cpu/stm32l0/Makefile b/cpu/stm32l0/Makefile index 7610bbb5e2a8..a857212883bc 100644 --- a/cpu/stm32l0/Makefile +++ b/cpu/stm32l0/Makefile @@ -1,9 +1,6 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS += periph $(RIOTCPU)/cortexm_common $(RIOTCPU)/stm32_common - # (file triggers compiler bug. see #5775) SRC_NOLTO += vectors.c diff --git a/cpu/stm32l1/Makefile b/cpu/stm32l1/Makefile index 7610bbb5e2a8..a857212883bc 100644 --- a/cpu/stm32l1/Makefile +++ b/cpu/stm32l1/Makefile @@ -1,9 +1,6 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS += periph $(RIOTCPU)/cortexm_common $(RIOTCPU)/stm32_common - # (file triggers compiler bug. see #5775) SRC_NOLTO += vectors.c diff --git a/cpu/stm32l4/Makefile b/cpu/stm32l4/Makefile index 7610bbb5e2a8..a857212883bc 100644 --- a/cpu/stm32l4/Makefile +++ b/cpu/stm32l4/Makefile @@ -1,9 +1,6 @@ # define the module that is build MODULE = cpu -# add a list of subdirectories, that should also be build -DIRS += periph $(RIOTCPU)/cortexm_common $(RIOTCPU)/stm32_common - # (file triggers compiler bug. see #5775) SRC_NOLTO += vectors.c From 4df093fc602527d5e9c386195dd83f804bae245c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Thu, 12 Oct 2017 17:44:06 +0200 Subject: [PATCH 25/28] boards/Makefile: do not build empty module for nothing --- boards/Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/boards/Makefile b/boards/Makefile index 0de47d5769bd..6a32131454ac 100644 --- a/boards/Makefile +++ b/boards/Makefile @@ -1,9 +1,5 @@ OLD_NONRECURSIVE := $(NONRECURSIVE) NONRECURSIVE = 1 -# First include for current module (should be done before any 'include') -include $(RIOTBASE)/Makefile.base - -# Then take care of other modules include Makefile.modules From 0d8c6d80517f3f810039c46bdb2c87c00c284c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Tue, 17 Oct 2017 15:41:18 +0200 Subject: [PATCH 26/28] Makefile.base: set MODULE as immediate variable --- Makefile.base | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile.base b/Makefile.base index 3d95d7d92544..e8b595955f6a 100644 --- a/Makefile.base +++ b/Makefile.base @@ -13,8 +13,10 @@ endif MODULE_DIR ?= $(CURDIR) MODULE ?= $(shell basename $(MODULE_DIR)) -# Add MODULE_DIR to files path to work from another dir than CURDIR -D := $(MODULE_DIR) +# Use immediate variables for D and MODULE as they are undefined at the end +MODULE := $(MODULE) +D := $(MODULE_DIR) +# D is for prepending the module directory to files path when importing .PHONY: all From 1788f863e6e885bc2a8bb39c66804ac98ecc9f36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Tue, 17 Oct 2017 16:16:04 +0200 Subject: [PATCH 27/28] core/Makefile.modules: add MODULE_DIR for core module --- core/Makefile.modules | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 core/Makefile.modules diff --git a/core/Makefile.modules b/core/Makefile.modules new file mode 100644 index 000000000000..abfd98e55892 --- /dev/null +++ b/core/Makefile.modules @@ -0,0 +1,4 @@ +# Current makefile directory +D := $(abspath $(dir $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +MODULE_DIR_core := $(D) From 60e16472687c66ed534e314d9381d40d5725f5f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 23 Oct 2017 15:24:44 +0200 Subject: [PATCH 28/28] FIXUP MAKEFILE.BASE: CFLAGS_$(MODULE) for LTO objects --- Makefile.base | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.base b/Makefile.base index e8b595955f6a..23eabed98ff8 100644 --- a/Makefile.base +++ b/Makefile.base @@ -85,7 +85,7 @@ CCASFLAGS_$(MODULE) := $(filter-out $(CCASUWFLAGS), $(CFLAGS_$(MODULE))) $(CCASE # compile and generate dependency info -$(OBJC_LTO): CFLAGS+=$(LTOFLAGS) +$(OBJC_LTO): CFLAGS_$(MODULE)+=$(LTOFLAGS) # Return module name from object path module_from_obj = $(notdir $(realpath $(dir $1)))