From 248a8531a51cbe7496d66b9109b9a06d143f9960 Mon Sep 17 00:00:00 2001
From: Martine Lenders <mail@martine-lenders.eu>
Date: Sun, 10 Aug 2014 05:20:57 +0200
Subject: [PATCH] make: Fix TERMFLAGS

Sometimes boards/*/Makefile.include (e. g. in case of the msba2) gets included
twice somehow, leading the TERMFLAG to be set twice and faulty. This
fixes that.
---
 Makefile.include                         | 2 +-
 boards/arduino-due/Makefile.include      | 2 +-
 boards/msb-430-common/Makefile.include   | 2 +-
 boards/msba2-common/Makefile.include     | 2 +-
 boards/native/Makefile.include           | 4 ++++
 boards/pca10000/Makefile.include         | 2 +-
 boards/pca10005/Makefile.include         | 2 +-
 boards/redbee-econotag/Makefile.include  | 2 +-
 boards/stm32f0discovery/Makefile.include | 2 +-
 boards/stm32f3discovery/Makefile.include | 2 +-
 boards/stm32f4discovery/Makefile.include | 2 +-
 boards/telosb/Makefile.include           | 2 +-
 boards/udoo/Makefile.include             | 2 +-
 boards/z1/Makefile.include               | 2 +-
 14 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/Makefile.include b/Makefile.include
index a30ce2be4f..f51b8c9cfe 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -193,7 +193,7 @@ flash: all
 	$(FLASHER) $(FFLAGS)
 
 term:
-	$(TERMPROG) $(TERMFLAGS) $(PORT)
+	$(TERMPROG) $(TERMFLAGS)
 
 doc:
 	make -BC $(RIOTBASE) doc
diff --git a/boards/arduino-due/Makefile.include b/boards/arduino-due/Makefile.include
index 32fa833303..eb4b782964 100644
--- a/boards/arduino-due/Makefile.include
+++ b/boards/arduino-due/Makefile.include
@@ -36,7 +36,7 @@ export LINKFLAGS += -g3 -ggdb -std=gnu99 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endi
 export LINKFLAGS += -T$(LINKERSCRIPT)
 export OFLAGS += -O binary
 export FFLAGS += -R -e -w -v -b bin/$(BOARD)/$(APPLICATION).hex
-export TERMFLAGS += -p
+export TERMFLAGS += -p "$(PORT)"
 
 # use the nano-specs of the NewLib when available
 ifeq ($(shell $(LINK) -specs=nano.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
diff --git a/boards/msb-430-common/Makefile.include b/boards/msb-430-common/Makefile.include
index 68bdb30fe7..fdfcad9333 100644
--- a/boards/msb-430-common/Makefile.include
+++ b/boards/msb-430-common/Makefile.include
@@ -26,7 +26,7 @@ export DEBUGSERVER = $(FLASHER)
 export DEBUGSERVER_FLAGS = $(MSPDEBUGFLAGS) gdb
 export DEBUGGER = $(PREFIX)gdb
 export DEBUGGER_FLAGS = --tui --ex="target remote localhost:2000" --ex "monitor reset halt" --ex load -ex "monitor reset halt"  $(ELFFILE)
-export TERMFLAGS += -p
+export TERMFLAGS += -p "$(PORT)"
 
 export FFLAGS = $(MSPDEBUGFLAGS) "prog $(HEXFILE)"
 
diff --git a/boards/msba2-common/Makefile.include b/boards/msba2-common/Makefile.include
index c7cc56c77f..866478226d 100644
--- a/boards/msba2-common/Makefile.include
+++ b/boards/msba2-common/Makefile.include
@@ -20,7 +20,7 @@ ifeq ($(strip $(PORT)),)
 	export PORT = /dev/ttyUSB0
 endif
 export FFLAGS = $(PORT) $(HEXFILE)
-export TERMFLAGS += -p
+export TERMFLAGS += -p "$(PORT)"
 include $(RIOTBOARD)/msba2-common/Makefile.dep
 
 export INCLUDES += -I$(RIOTBOARD)/msba2-common/include -I$(RIOTBOARD)/msba2-common/drivers/include
diff --git a/boards/native/Makefile.include b/boards/native/Makefile.include
index 6b5a8ccc77..fcde57dfad 100644
--- a/boards/native/Makefile.include
+++ b/boards/native/Makefile.include
@@ -84,6 +84,10 @@ else
 	export PORT =
 endif
 
+ifeq (,$(filter $(PORT),$(TERMFLAGS)))
+    export TERMFLAGS += $(PORT)
+endif
+
 all: # do not override first target
 
 all-debug: all
diff --git a/boards/pca10000/Makefile.include b/boards/pca10000/Makefile.include
index ee20cc6263..ce83d80d1b 100644
--- a/boards/pca10000/Makefile.include
+++ b/boards/pca10000/Makefile.include
@@ -39,7 +39,7 @@ export LINKFLAGS += -g3 -ggdb -std=gnu99 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endi
 export LINKFLAGS += -T$(LINKERSCRIPT)
 export OFLAGS = -O binary
 export HEXFILE = $(ELFFILE:.elf=.bin)
-export TERMFLAGS = -p
+export TERMFLAGS += -p "$(PORT)"
 export FFLAGS = $(BINDIR) $(HEXFILE)
 export DEBUGGER_FLAGS = $(BINDIR) $(ELFFILE)
 export RESET_FLAGS = $(BINDIR)
diff --git a/boards/pca10005/Makefile.include b/boards/pca10005/Makefile.include
index 110707b276..4e79b70a82 100644
--- a/boards/pca10005/Makefile.include
+++ b/boards/pca10005/Makefile.include
@@ -36,7 +36,7 @@ export LINKFLAGS += -g3 -ggdb -std=gnu99 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endi
 # $(LINKERSCRIPT) is specified in cpu/Makefile.include
 export LINKFLAGS += -T$(LINKERSCRIPT)
 export OFLAGS = -O binary
-export TERMFLAGS = -p
+export TERMFLAGS += -p "$(PORT)"
 
 # use the nano-specs of the NewLib when available
 ifeq ($(shell $(LINK) -specs=nano.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
diff --git a/boards/redbee-econotag/Makefile.include b/boards/redbee-econotag/Makefile.include
index 2cedc3c686..0f01f88f5c 100644
--- a/boards/redbee-econotag/Makefile.include
+++ b/boards/redbee-econotag/Makefile.include
@@ -26,7 +26,7 @@ ifeq ($(strip $(PORT)),)
 endif
 export FFLAGS = -t $(PORT) -f $(HEXFILE) -c 'bbmc -l redbee-econotag reset'
 export OFLAGS = -O binary --gap-fill=0xff
-export TERMFLAGS += -p
+export TERMFLAGS += -p "$(PORT)"
 
 export INCLUDES += -I$(RIOTCPU)/$(CPU)/include/ -I$(RIOTBOARD)/$(BOARD)/include/
 export INCLUDES += -I$(RIOTCPU)/$(CPU)/maca/include
diff --git a/boards/stm32f0discovery/Makefile.include b/boards/stm32f0discovery/Makefile.include
index 94058251a9..0dfddc9a7f 100644
--- a/boards/stm32f0discovery/Makefile.include
+++ b/boards/stm32f0discovery/Makefile.include
@@ -39,7 +39,7 @@ export LINKFLAGS += -T$(LINKERSCRIPT)
 export OFLAGS = -O binary
 export FFLAGS = write bin/$(BOARD)/$(APPLICATION).hex 0x08000000
 export DEBUGGER_FLAGS = $(RIOTBOARD)/$(BOARD)/dist/gdb.conf bin/$(BOARD)/$(APPLICATION).elf
-export TERMFLAGS += -p
+export TERMFLAGS += -p "$(PORT)"
 
 # use the nano-specs of the NewLib when available
 ifeq ($(shell $(LINK) -specs=nano.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
diff --git a/boards/stm32f3discovery/Makefile.include b/boards/stm32f3discovery/Makefile.include
index 60a9ea884d..744a557b78 100644
--- a/boards/stm32f3discovery/Makefile.include
+++ b/boards/stm32f3discovery/Makefile.include
@@ -38,7 +38,7 @@ export LINKFLAGS += -T$(LINKERSCRIPT)
 export OFLAGS = -O binary
 export FFLAGS = write bin/$(BOARD)/$(APPLICATION).hex 0x8000000
 export DEBUGGER_FLAGS = $(RIOTBOARD)/$(BOARD)/dist/gdb.conf $(BINDIR)/$(APPLICATION).elf
-export TERMFLAGS = -p
+export TERMFLAGS += -p "$(PORT)"
 
 # use newLib nano-specs if available
 ifeq ($(shell $(LINK) -specs=nano.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
diff --git a/boards/stm32f4discovery/Makefile.include b/boards/stm32f4discovery/Makefile.include
index 6919759a3a..d0232f0fa4 100644
--- a/boards/stm32f4discovery/Makefile.include
+++ b/boards/stm32f4discovery/Makefile.include
@@ -38,7 +38,7 @@ export LINKFLAGS += -T$(LINKERSCRIPT)
 export OFLAGS = -O binary
 export FFLAGS = write bin/$(BOARD)/$(APPLICATION).hex 0x8000000
 export DEBUGGER_FLAGS = $(RIOTBOARD)/$(BOARD)/dist/gdb.conf $(BINDIR)/$(APPLICATION).elf
-export TERMFLAGS += -p
+export TERMFLAGS += -p "$(PORT)"
 
 # use newLib nano-specs if available
 ifeq ($(shell $(LINK) -specs=nano.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
diff --git a/boards/telosb/Makefile.include b/boards/telosb/Makefile.include
index af5153818e..3bc3023a8c 100644
--- a/boards/telosb/Makefile.include
+++ b/boards/telosb/Makefile.include
@@ -20,7 +20,7 @@ ifeq ($(strip $(PORT)),)
     export PORT = /dev/ttyUSB0
 endif
 export FFLAGS = --telosb -c $(PORT) -r -e -I -p $(HEXFILE)
-export TERMFLAGS += -p
+export TERMFLAGS += -p "$(PORT)"
 
 export INCLUDES += -I$(RIOTCPU)/msp430-common/include -I$(RIOTBOARD)/$(BOARD)/include -I$(RIOTBASE)/drivers/cc2420/include -I$(RIOTBASE)/sys/net/include
 export OFLAGS = -O ihex
diff --git a/boards/udoo/Makefile.include b/boards/udoo/Makefile.include
index 8fcc8e1ad7..6f539174d0 100644
--- a/boards/udoo/Makefile.include
+++ b/boards/udoo/Makefile.include
@@ -36,7 +36,7 @@ export LINKFLAGS += -g3 -ggdb -std=gnu99 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endi
 export LINKFLAGS += -T$(LINKERSCRIPT)
 export OFLAGS += -O binary
 export FFLAGS += -R -e -w -v -b bin/$(BOARD)/$(APPLICATION).hex
-export TERMFLAGS += -p
+export TERMFLAGS += -p "$(PORT)"
 
 # use the nano-specs of the NewLib when available
 ifeq ($(shell $(LINK) -specs=nano.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
diff --git a/boards/z1/Makefile.include b/boards/z1/Makefile.include
index f2ed73a405..f0a4f29ea2 100644
--- a/boards/z1/Makefile.include
+++ b/boards/z1/Makefile.include
@@ -21,7 +21,7 @@ ifeq ($(strip $(PORT)),)
 endif
 export FFLAGS = --z1 -I -c $(PORT) -r -e -p $(HEXFILE)
 export OFLAGS = -O ihex
-export TERMFLAGS += -p
+export TERMFLAGS += -p "$(PORT)"
 
 export INCLUDES += -I $(RIOTCPU)/msp430-common/include -I$(RIOTBOARD)/$(BOARD)/include -I$(RIOTBASE)/drivers/cc2420/include -I$(RIOTBASE)/sys/net/include
 
-- 
GitLab