diff --git a/Makefile.include b/Makefile.include index 456f4da850..74c0806f3c 100644 --- a/Makefile.include +++ b/Makefile.include @@ -640,16 +640,19 @@ flash-only: $(FLASHDEPS) preflash: $(BUILD_BEFORE_FLASH) $(PREFLASHER) $(PREFFLAGS) +TERMFLASHDEPS ?= $(filter flash flash-only,$(MAKECMDGOALS)) +# Add TERMFLASHDEPS to TERMDEPS so it also applies to `test` +TERMDEPS += $(TERMFLASHDEPS) termdeps: $(TERMDEPS) -term: $(filter flash flash-only, $(MAKECMDGOALS)) $(TERMDEPS) +term: $(TERMDEPS) $(call check_cmd,$(TERMPROG),Terminal program) $(TERMPROG) $(TERMFLAGS) # Term without the pyterm added logging # TERMFLAGS must be exported for `jlink.sh term_rtt`. cleanterm: export PYTERMFLAGS += --noprefix --no-repeat-command-on-empty-line -cleanterm: $(filter flash, $(MAKECMDGOALS)) $(TERMDEPS) +cleanterm: $(TERMDEPS) $(call check_cmd,$(TERMPROG),Terminal program) $(TERMPROG) $(TERMFLAGS)