From d8080a66e4c49e177440d0c8813997861d8a9962 Mon Sep 17 00:00:00 2001
From: cladmi <gaetan.harter@fu-berlin.de>
Date: Thu, 11 Oct 2018 15:13:15 +0200
Subject: [PATCH] cpu/stm32_common: Do not use USEMODULE to select i2c implem

`cpu/stm32_common/Makefile.dep` was never included by the global
`Makefile.dep`, so declaring this `USEMODULE +=` here was never shown to
the build system and never exported as `MODULE_PERIPH_I2C_X` variables.

In fact, `USEMODULE` was only used to trigger the `periph.mk`/`SUBMODULES`
mechanism to add matching source files names to `SRC` and so select
the implementation for each CPU type.

It is replaced by just explicitly selecting the right source file.
---
 cpu/stm32_common/Makefile.dep    | 7 -------
 cpu/stm32_common/periph/Makefile | 9 ++++++++-
 2 files changed, 8 insertions(+), 8 deletions(-)
 delete mode 100644 cpu/stm32_common/Makefile.dep

diff --git a/cpu/stm32_common/Makefile.dep b/cpu/stm32_common/Makefile.dep
deleted file mode 100644
index 878dc5a7e0..0000000000
--- a/cpu/stm32_common/Makefile.dep
+++ /dev/null
@@ -1,7 +0,0 @@
-ifneq (,$(filter periph_i2c,$(USEMODULE)))
-  ifneq (,$(filter $(CPU),stm32f0 stm32f3 stm32f7 stm32l0 stm32l4))
-    USEMODULE += periph_i2c_1
-  else # stm32f1/f2/f4/l1
-    USEMODULE += periph_i2c_2
-  endif
-endif
diff --git a/cpu/stm32_common/periph/Makefile b/cpu/stm32_common/periph/Makefile
index 1870d4557c..d549119759 100644
--- a/cpu/stm32_common/periph/Makefile
+++ b/cpu/stm32_common/periph/Makefile
@@ -1,5 +1,12 @@
 MODULE = stm32_common_periph
 
-include $(RIOTCPU)/stm32_common/Makefile.dep
+# Select the specific implementation for `periph_i2c`
+ifneq (,$(filter periph_i2c,$(USEMODULE)))
+  ifneq (,$(filter $(CPU),stm32f0 stm32f3 stm32f7 stm32l0 stm32l4))
+    SRC += i2c_1.c
+  else # stm32f1/f2/f4/l1
+    SRC += i2c_2.c
+  endif
+endif
 
 include $(RIOTMAKE)/periph.mk
-- 
GitLab