diff --git a/Makefile.include b/Makefile.include index 26aeddd850..71173907d6 100644 --- a/Makefile.include +++ b/Makefile.include @@ -713,6 +713,9 @@ flash-only: $(FLASHDEPS) preflash: $(BUILD_BEFORE_FLASH) $(PREFLASHER_PREFIX)$(PREFLASHER) $(PREFFLAGS) +ifneq (,$(TERMLOG)$(TERMTEE)) + TERMTEE ?= | tee -a $(TERMLOG) +endif TERMFLASHDEPS ?= $(filter flash flash-only,$(MAKECMDGOALS)) # Add TERMFLASHDEPS to TERMDEPS so it also applies to `test` TERMDEPS += $(TERMFLASHDEPS) @@ -720,14 +723,14 @@ termdeps: $(TERMDEPS) term: $(TERMDEPS) $(call check_cmd,$(TERMPROG),Terminal program) - $(TERMPROG) $(TERMFLAGS) + $(TERMPROG) $(TERMFLAGS) $(TERMTEE) # Term without the pyterm added logging # PYTERMFLAGS must be exported for `jlink.sh term-rtt`. cleanterm: export PYTERMFLAGS += --no-reconnect --noprefix --no-repeat-command-on-empty-line cleanterm: $(TERMDEPS) $(call check_cmd,$(TERMPROG),Terminal program) - $(TERMPROG) $(TERMFLAGS) + $(TERMPROG) $(TERMFLAGS) $(TERMTEE) list-ttys: $(Q)$(RIOTTOOLS)/usb-serial/list-ttys.sh diff --git a/makefiles/vars.inc.mk b/makefiles/vars.inc.mk index 473c546c99..82c4386b25 100644 --- a/makefiles/vars.inc.mk +++ b/makefiles/vars.inc.mk @@ -92,6 +92,8 @@ export WPEDANTIC # Issue all (extensive) compiler warnings demanded export FLASH_ADDR # Define an offset to flash code into ROM memory. # TERMPROG # The command to call on "make term". # TERMFLAGS # Additional parameters to supply to TERMPROG. +# TERMLOG # Optional file to log "make term" output to. +# TERMTEE # Optional pipe to redirect "make term" output. Default: '| tee -a ${TERMLOG}' when TERMLOG is defined else undefined. # PORT # The port to connect the TERMPROG to. export ELFFILE # The unstripped result of the compilation. export HEXFILE # The 'intel hex' stripped result of the compilation.