From 02612ff0caa5ea3ea04109a6165465611abf9c65 Mon Sep 17 00:00:00 2001
From: Oleg Hahm <oleg@hobbykeller.org>
Date: Tue, 24 Dec 2013 14:50:26 +0100
Subject: [PATCH] further Makefile cleanup

---
 Makefile.include                      |  2 +-
 boards/chronos/Makefile               |  1 +
 boards/chronos/Makefile.include       |  2 +-
 boards/chronos/drivers/Makefile       | 24 +++---------------------
 boards/msb-430h/Makefile              |  2 ++
 boards/msb-430h/Makefile.include      |  2 +-
 boards/msba2-common/Makefile.include  |  3 ++-
 boards/msba2-common/drivers/Makefile  |  1 +
 boards/native/Makefile.include        |  2 +-
 boards/native/drivers/native-uart0.c  |  2 ++
 boards/wsn430-common/Makefile.include |  2 +-
 boards/wsn430-v1_3b/Makefile          |  1 +
 boards/wsn430-v1_3b/Makefile.include  |  2 +-
 boards/wsn430-v1_4/Makefile.include   |  2 +-
 cpu/arm_common/Makefile               |  1 -
 cpu/cc430/Makefile                    |  2 ++
 cpu/cc430/Makefile.include            |  4 +++-
 cpu/lpc1768/Makefile                  |  2 --
 cpu/lpc2387/i2c/Makefile              |  2 --
 sys/auto_init/Makefile                |  2 --
 20 files changed, 24 insertions(+), 37 deletions(-)

diff --git a/Makefile.include b/Makefile.include
index 99f8caf091..4d9f143c8e 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -20,9 +20,9 @@ export CFLAGS
 export BINDIR =$(CURDIR)/bin/
 
 # mandatory includes!
+include $(RIOTBASE)/Makefile.modules
 include $(RIOTBOARD)/$(BOARD)/Makefile.include
 include $(RIOTCPU)/$(CPU)/Makefile.include
-include $(RIOTBASE)/Makefile.modules 
 
 # your binaries to link
 BASELIBS += $(BINDIR)$(BOARD)_base.a
diff --git a/boards/chronos/Makefile b/boards/chronos/Makefile
index 08503227da..30a260e0ef 100644
--- a/boards/chronos/Makefile
+++ b/boards/chronos/Makefile
@@ -1,5 +1,6 @@
 MODULE =$(BOARD)_base
 
+INCLUDES += -I$(RIOTBOARD)/$(BOARD)/drivers/include
 DIRS = drivers
 
 all: $(BINDIR)$(MODULE).a
diff --git a/boards/chronos/Makefile.include b/boards/chronos/Makefile.include
index 299b631b51..a034ee2409 100644
--- a/boards/chronos/Makefile.include
+++ b/boards/chronos/Makefile.include
@@ -1,4 +1,4 @@
-export INCLUDES += -I$(RIOTBOARD)/chronos/include -I$(RIOTBOARD)/chronos/drivers/include -I$(RIOTCPU)/cc430/include -I$(RIOTCPU)/msp430-common/include
+export INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include
 
 ## the cpu to build for
 export CPU = cc430
diff --git a/boards/chronos/drivers/Makefile b/boards/chronos/drivers/Makefile
index 03df5e6745..3c61103789 100644
--- a/boards/chronos/drivers/Makefile
+++ b/boards/chronos/drivers/Makefile
@@ -1,23 +1,5 @@
-SRC = $(wildcard *.c)
-OBJ = $(SRC:%.c=$(BINDIR)%.o)
-DEP = $(SRC:%.c=$(BINDIR)%.d)
+MODULE =$(BOARD)_base
 
-INCLUDES += -I$(RIOTBASE)/sys/include/ -I$(RIOTBASE)/drivers/cc110x_ng/include/
-
-$(BINDIR)chronos_drivers.a: $(OBJ)
-	$(AR) rcs $(BINDIR)chronos_base.a $(OBJ)
-
-# pull in dependency info for *existing* .o files
--include $(OBJ:.o=.d)
-
-# compile and generate dependency info
-$(BINDIR)%.o: %.c
-	$(CC) $(CFLAGS) $(INCLUDES) $(BOARDINCLUDE) $(PROJECTINCLUDE) $(CPUINCLUDE) -c $*.c -o $(BINDIR)$*.o
-	$(CC) $(CFLAGS) $(INCLUDES) $(BOARDINCLUDE) $(PROJECTINCLUDE) $(CPUINCLUDE) -MM $*.c > $(BINDIR)$*.d
-	@printf "$(BINDIR)" | cat - $(BINDIR)$*.d > /tmp/riot_out && mv /tmp/riot_out $(BINDIR)$*.d
-
-# remove compilation products
-
-clean:
-	rm -f $(OBJ) $(DEP)
+INCLUDES += -I$(RIOTBASE)/drivers/cc110x_ng/include
 
+include $(RIOTBASE)/Makefile.base
diff --git a/boards/msb-430h/Makefile b/boards/msb-430h/Makefile
index 0a7ebeb637..4adc54edf5 100644
--- a/boards/msb-430h/Makefile
+++ b/boards/msb-430h/Makefile
@@ -2,6 +2,8 @@ MODULE =$(BOARD)_base
 
 DIRS = $(RIOTBOARD)/msb-430-common 
 
+INCLUDES += -I$(RIOTBASE)/drivers/cc110x_ng/include
+
 all: $(BINDIR)$(MODULE).a
 	@for i in $(DIRS) ; do "$(MAKE)" -C $$i ; done ;
 
diff --git a/boards/msb-430h/Makefile.include b/boards/msb-430h/Makefile.include
index df267881e0..10ae080875 100644
--- a/boards/msb-430h/Makefile.include
+++ b/boards/msb-430h/Makefile.include
@@ -1,4 +1,4 @@
-export INCLUDES += -I$(RIOTBOARD)/msb-430h/include -I$(RIOTBOARD)/msb-430-common/include -I$(RIOTBASE)/drivers/cc110x_ng/include
+export INCLUDES += -I$(RIOTBOARD)/msb-430h/include
 include $(RIOTBOARD)/$(BOARD)/Makefile.dep
 
 include $(RIOTBOARD)/msb-430-common/Makefile.include
diff --git a/boards/msba2-common/Makefile.include b/boards/msba2-common/Makefile.include
index bb11356664..5ce4335a00 100644
--- a/boards/msba2-common/Makefile.include
+++ b/boards/msba2-common/Makefile.include
@@ -23,5 +23,6 @@ export HEXFILE = bin/$(PROJECT).hex
 export FFLAGS = $(PORT) $(BINDIR)$(PROJECT).hex
 include $(RIOTBOARD)/msba2-common/Makefile.dep
 
-export INCLUDES += -I$(RIOTCPU)/lpc2387/include -I$(RIOTBOARD)/msba2-common/include -I$(RIOTBOARD)/msba2-common/drivers/include/
+export INCLUDES += -I$(RIOTBOARD)/msba2-common/include -I$(RIOTBOARD)/msba2-common/drivers/include
+
 export OFLAGS = -O ihex
diff --git a/boards/msba2-common/drivers/Makefile b/boards/msba2-common/drivers/Makefile
index 2fefbf04b4..c97bf04c92 100644
--- a/boards/msba2-common/drivers/Makefile
+++ b/boards/msba2-common/drivers/Makefile
@@ -1,5 +1,6 @@
 MODULE =$(BOARD)_base
 include $(RIOTBOARD)/$(BOARD)/Makefile.include
+
 INCLUDES += -I$(RIOTBASE)/drivers/cc110x_ng/include
 
 include $(RIOTBASE)/Makefile.base
diff --git a/boards/native/Makefile.include b/boards/native/Makefile.include
index 94e9f3a967..46231f89dc 100644
--- a/boards/native/Makefile.include
+++ b/boards/native/Makefile.include
@@ -1,4 +1,4 @@
-export INCLUDES += -I$(RIOTBOARD)/native/include
+export INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include
 export CPU = native
 
 # toolchain config
diff --git a/boards/native/drivers/native-uart0.c b/boards/native/drivers/native-uart0.c
index 4ea76dca6d..74f2328b0d 100644
--- a/boards/native/drivers/native-uart0.c
+++ b/boards/native/drivers/native-uart0.c
@@ -225,6 +225,7 @@ void handle_uart_sock()
     _native_uart_conn = s;
 }
 
+#ifdef MODULE_UART0
 void _native_handle_uart0_input()
 {
     if (FD_ISSET(STDIN_FILENO, &_native_rfds)) {
@@ -250,6 +251,7 @@ int _native_set_uart_fds(void)
         return ((STDIN_FILENO > _native_uart_sock) ? STDIN_FILENO : _native_uart_sock);
     }
 }
+#endif
 
 void _native_init_uart0(char *stdiotype, char *ioparam)
 {
diff --git a/boards/wsn430-common/Makefile.include b/boards/wsn430-common/Makefile.include
index 923f694fe4..0bbd9e8f1d 100644
--- a/boards/wsn430-common/Makefile.include
+++ b/boards/wsn430-common/Makefile.include
@@ -20,6 +20,6 @@ endif
 export HEXFILE = bin/$(PROJECT).hex
 export FFLAGS = -d $(PORT) -j uif "prog $(HEXFILE)"
 
-export INCLUDES += -I $(RIOTCPU)/msp430-common/include/ -I$(RIOTBASE)/sys/net/include/
+export INCLUDES += -I$(RIOTBOARD)/wsn430-common/include
 export OFLAGS = -O ihex
 
diff --git a/boards/wsn430-v1_3b/Makefile b/boards/wsn430-v1_3b/Makefile
index 7f7fba05ea..b7b75b794b 100644
--- a/boards/wsn430-v1_3b/Makefile
+++ b/boards/wsn430-v1_3b/Makefile
@@ -1,6 +1,7 @@
 MODULE =$(BOARD)_base
 
 DIRS = $(RIOTBOARD)/wsn430-common
+INCLUDES += -I$(RIOTBASE)/drivers/cc110x_ng/include
 
 all: $(BINDIR)$(MODULE).a
 	@for i in $(DIRS) ; do "$(MAKE)" -C $$i ; done ;
diff --git a/boards/wsn430-v1_3b/Makefile.include b/boards/wsn430-v1_3b/Makefile.include
index b061a77ee0..ed87f884e3 100644
--- a/boards/wsn430-v1_3b/Makefile.include
+++ b/boards/wsn430-v1_3b/Makefile.include
@@ -1,4 +1,4 @@
-export INCLUDES += -I$(RIOTBOARD)/wsn430-v1_3b/include -I$(RIOTBOARD)/wsn430-common/include -I$(RIOTBASE)/drivers/cc110x_ng/include
+export INCLUDES += -I$(RIOTBOARD)/wsn430-v1_3b/include
 
 include $(RIOTBOARD)/$(BOARD)/Makefile.dep
 include $(RIOTBOARD)/wsn430-common/Makefile.include
diff --git a/boards/wsn430-v1_4/Makefile.include b/boards/wsn430-v1_4/Makefile.include
index 5d8024da6e..a5ba9a0c94 100644
--- a/boards/wsn430-v1_4/Makefile.include
+++ b/boards/wsn430-v1_4/Makefile.include
@@ -1,4 +1,4 @@
-export INCLUDES += -I$(RIOTBOARD)/wsn430-v1_4/include -I$(RIOTBOARD)/wsn430-common/include -I$(RIOTBASE)/drivers/cc2420/include
+export INCLUDES += -I$(RIOTBOARD)/wsn430-v1_4/include -I$(RIOTBOARD)/wsn430-common/include -I$(RIOTBASE)/drivers/cc2420/include -I$(RIOTBASE)/sys/net/include
 
 include $(RIOTBOARD)/$(BOARD)/Makefile.dep
 include $(RIOTBOARD)/wsn430-common/Makefile.include
diff --git a/cpu/arm_common/Makefile b/cpu/arm_common/Makefile
index c9bf68070c..68ec505674 100644
--- a/cpu/arm_common/Makefile
+++ b/cpu/arm_common/Makefile
@@ -1,5 +1,4 @@
 MODULE =arm_common
-INCLUDES = -Iinclude -I../$(CPU)/include -I../../sys/lib -I../../drivers/include -I../../core/include -I../../sys/include -I../../hal/include -I../../.. -I../../sys/lib/fat
 
 CFLAGS += $(CFLAGS_BASIC)
 include $(RIOTBASE)/Makefile.base
diff --git a/cpu/cc430/Makefile b/cpu/cc430/Makefile
index 3e10d1237a..16802b433f 100644
--- a/cpu/cc430/Makefile
+++ b/cpu/cc430/Makefile
@@ -2,6 +2,8 @@ MODULE = cpu
 
 DIRS = $(RIOTCPU)/msp430-common
 
+INCLUDES += -I$(RIOTBASE)/drivers/cc110x_ng/include
+
 all: $(BINDIR)$(MODULE).a
 	@for i in $(DIRS) ; do "$(MAKE)" -C $$i ; done ;
 
diff --git a/cpu/cc430/Makefile.include b/cpu/cc430/Makefile.include
index 901122b7a6..9cabdc9c4f 100644
--- a/cpu/cc430/Makefile.include
+++ b/cpu/cc430/Makefile.include
@@ -1,2 +1,4 @@
- INCLUDES += -I$(MAKEBASE)/cpu/cc430/include/
+INCLUDES += -I$(MAKEBASE)/cpu/cc430/include/
+
+include $(RIOTCPU)/msp430-common/Makefile.include
 
diff --git a/cpu/lpc1768/Makefile b/cpu/lpc1768/Makefile
index 263b41a374..ed34d81c6b 100644
--- a/cpu/lpc1768/Makefile
+++ b/cpu/lpc1768/Makefile
@@ -7,8 +7,6 @@ CC_SYMBOLS = -DTARGET_LPC1769 -DTOOLCHAIN_GCC_ARM -DNDEBUG -D__CORTEX_M3
 LD_FLAGS = -mcpu=cortex-m3 -mthumb -Wl,--gc-sections,-Map=$(PROJECT).map,--cref --specs=nano.specs
 LD_SYS_LIBS = -lc -lgcc -lnosys
 
-INCLUDES = -Iinclude -I$(RIOTBASE)/core/include -I$(RIOTBASE)/sys/include -I$(RIOTBASE)/sys/lib 
-
 all: $(BINDIR)$(MODULE).a
 
 include $(RIOTBASE)/Makefile.base
diff --git a/cpu/lpc2387/i2c/Makefile b/cpu/lpc2387/i2c/Makefile
index 0d25ac4dfa..825b7ecde6 100644
--- a/cpu/lpc2387/i2c/Makefile
+++ b/cpu/lpc2387/i2c/Makefile
@@ -1,5 +1,3 @@
-INCLUDES = -I$(RIOTBASE)/drivers/include -I$(RIOTBASE)/sys/include -I../../net -I../include -I../../lib -I../../../.. -I../../../cpu/ -I../../../core/include -I../../
-
 MODULE =i2c
 
 include $(MAKEBASE)/Makefile.base
diff --git a/sys/auto_init/Makefile b/sys/auto_init/Makefile
index 3d5723287c..8b2b20a9fd 100644
--- a/sys/auto_init/Makefile
+++ b/sys/auto_init/Makefile
@@ -1,6 +1,4 @@
 MODULE = auto_init
 
-INCLUDES += -I$(RIOTBASE)/drivers/cc110x -I$(RIOTBASE)/drivers/cc110x_ng/include
-
 include $(RIOTBASE)/Makefile.base
 
-- 
GitLab