From 0935a5ff202f3c0788439d0c7cc39404c72381dd Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 19 Oct 2018 13:25:16 +0200 Subject: [PATCH 1/5] dist/tools: use external setsid tool for OSX --- dist/tools/setsid/.gitignore | 2 ++ dist/tools/setsid/Makefile | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 dist/tools/setsid/.gitignore create mode 100644 dist/tools/setsid/Makefile diff --git a/dist/tools/setsid/.gitignore b/dist/tools/setsid/.gitignore new file mode 100644 index 0000000000..3dd9233a7a --- /dev/null +++ b/dist/tools/setsid/.gitignore @@ -0,0 +1,2 @@ +setsid +bin diff --git a/dist/tools/setsid/Makefile b/dist/tools/setsid/Makefile new file mode 100644 index 0000000000..164392026f --- /dev/null +++ b/dist/tools/setsid/Makefile @@ -0,0 +1,17 @@ +PKG_NAME = setsid +PKG_URL = https://github.com/tzvetkoff/setsid-macosx +PKG_VERSION = e5b851df41591021baf5cf88d4e41572baf8e08b +PKG_LICENSE = BSD-2-Clause +PKG_BUILDDIR = $(CURDIR)/bin + +.PHONY: all + +all: git-download + @echo "[INFO] compiling setsid from source now" + $(MAKE) BINDIR=$(PKG_BUILDDIR) -C $(PKG_BUILDDIR) + @mv $(PKG_BUILDDIR)/setsid $(CURDIR)/setsid + +distclean:: + @rm -f $(CURDIR)/setsid + +include $(RIOTBASE)/pkg/pkg.mk From 4b53f6b92b5fcb95dc216768a6ee39fdaa27949c Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 19 Oct 2018 13:25:58 +0200 Subject: [PATCH 2/5] makefiles/targets: add target for setsid --- makefiles/tools/targets.inc.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/makefiles/tools/targets.inc.mk b/makefiles/tools/targets.inc.mk index f80fa73b31..baf9dd864f 100644 --- a/makefiles/tools/targets.inc.mk +++ b/makefiles/tools/targets.inc.mk @@ -29,3 +29,8 @@ $(RIOTTOOLS)/mosquitto_rsmb/mosquitto_rsmb: mosquitto_rsmb: $(RIOTTOOLS)/mosquitto_rsmb/mosquitto_rsmb @make -C $(RIOTTOOLS)/mosquitto_rsmb run + +$(RIOTTOOLS)/setsid/setsid: $(RIOTTOOLS)/setsid/Makefile + @echo "[INFO] setsid binary not found - building it from source now" + @make -C $(RIOTTOOLS)/setsid + @echo "[INFO] setsid binary successfully build!" From 5b265088fe1eef5de166e51992e9c31ea52325b1 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 19 Oct 2018 13:27:11 +0200 Subject: [PATCH 3/5] Makefile.include: use external setsid with debug target Only when setsid is not provided by the system which is typically the case on MacOSX --- Makefile.include | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile.include b/Makefile.include index befb9d8647..18f272c6d6 100644 --- a/Makefile.include +++ b/Makefile.include @@ -570,6 +570,16 @@ define check_cmd exit 1;} endef +# Check if setsid command is available on the system for debug target +# This is not the case on MacOSX, so it must be built on the fly +ifneq (,$(filter debug, $(MAKECMDGOALS))) + ifneq (0,$(shell which setsid 2>&1 > /dev/null ; echo $$?)) + SETSID = $(RIOTTOOLS)/setsid/setsid + $(call target-export-variables,debug,$(SETSID)) + DEBUGDEPS += $(SETSID) + endif +endif + ..compiler-check: $(call check_cmd,$(CC),Compiler) @@ -643,7 +653,7 @@ list-ttys: doc: make -BC $(RIOTBASE) doc -debug: +debug: $(DEBUGDEPS) $(call check_cmd,$(DEBUGGER),Debug program) $(DEBUGGER) $(DEBUGGER_FLAGS) From 49967b2c4acfab86fe933bafb1ab7f520f907494 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Tue, 23 Oct 2018 18:59:47 +0200 Subject: [PATCH 4/5] boards/avr/dist: setsid can be set with env variable --- boards/common/arduino-atmega/dist/debug.sh | 6 +++++- boards/mega-xplained/dist/debug.sh | 6 +++++- boards/waspmote-pro/dist/debug.sh | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/boards/common/arduino-atmega/dist/debug.sh b/boards/common/arduino-atmega/dist/debug.sh index 0b10852f20..46dc7377ca 100644 --- a/boards/common/arduino-atmega/dist/debug.sh +++ b/boards/common/arduino-atmega/dist/debug.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash + +# The setsid command is needed so that Ctrl+C in GDB doesn't kill avarice +: ${SETSID:=setsid} + sleep 2 -setsid -w avarice $1 & +${SETSID} -w avarice $1 & #sleep 2 && $2/avr-gdb-wrapper -ex "target remote localhost:$3" $4 sleep 3 && avr-gdb -ex "target remote localhost:$3" $4 diff --git a/boards/mega-xplained/dist/debug.sh b/boards/mega-xplained/dist/debug.sh index 0b10852f20..46dc7377ca 100755 --- a/boards/mega-xplained/dist/debug.sh +++ b/boards/mega-xplained/dist/debug.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash + +# The setsid command is needed so that Ctrl+C in GDB doesn't kill avarice +: ${SETSID:=setsid} + sleep 2 -setsid -w avarice $1 & +${SETSID} -w avarice $1 & #sleep 2 && $2/avr-gdb-wrapper -ex "target remote localhost:$3" $4 sleep 3 && avr-gdb -ex "target remote localhost:$3" $4 diff --git a/boards/waspmote-pro/dist/debug.sh b/boards/waspmote-pro/dist/debug.sh index 0b10852f20..46dc7377ca 100755 --- a/boards/waspmote-pro/dist/debug.sh +++ b/boards/waspmote-pro/dist/debug.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash + +# The setsid command is needed so that Ctrl+C in GDB doesn't kill avarice +: ${SETSID:=setsid} + sleep 2 -setsid -w avarice $1 & +${SETSID} -w avarice $1 & #sleep 2 && $2/avr-gdb-wrapper -ex "target remote localhost:$3" $4 sleep 3 && avr-gdb -ex "target remote localhost:$3" $4 From 914856247634394adc837dae0889f46b687964fc Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 2 Oct 2019 21:12:07 +0200 Subject: [PATCH 5/5] makefiles/vars: document DEBUGDEPS variable --- makefiles/vars.inc.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/makefiles/vars.inc.mk b/makefiles/vars.inc.mk index f2bfcc5557..135bd81605 100644 --- a/makefiles/vars.inc.mk +++ b/makefiles/vars.inc.mk @@ -19,6 +19,7 @@ export USEPKG # Pkg dependencies (third party modules) of the app export DISABLE_MODULE # Used in the application's Makefile to suppress DEFAULT_MODULEs. export APPDEPS # Files / Makefile targets that need to be created before the application can be build. Set in the application's Makefile. # BUILDDEPS # Files / Makefile targets that need to be created before starting to build. +# DEBUGDEPS # Files / Makefile targets that need to be created before starting a debug session. export RIOTBASE # The root folder of RIOT. The folder where this very file lives in. export RIOTCPU # For third party CPUs this folder is the base of the CPUs.