Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 17 additions & 32 deletions Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,17 @@ endif
endif
endif # BUILD_IN_DOCKER

# Check given command is available in the path

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to move it in a separate .mk file in makefiles directory so it can be easily imported by other makefiles ? I think it could also be usefull for #8573.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Folo!

# check_cmd 'command' 'description'
define check_cmd
@command -v $1 >/dev/null 2>&1 || \
{ $(COLOR_ECHO) \
'$(COLOR_RED)$2 $1 is required but not found in PATH. Aborting.$(COLOR_RESET)'; \
exit 1;}
endef

..compiler-check:
@command -v $(CC) >/dev/null 2>&1 || \
{ $(COLOR_ECHO) \
'$(COLOR_RED)Compiler $(CC) is required but not found in PATH. Aborting.$(COLOR_RESET)'; \
exit 1; }
$(call check_cmd,$(CC),Compiler)

..build-message:
@$(COLOR_ECHO) '$(COLOR_GREEN)Building application "$(APPLICATION)" for "$(BOARD)" with MCU "$(MCU)".$(COLOR_RESET)'
Expand Down Expand Up @@ -400,10 +406,7 @@ ifeq (,$(filter flash-only, $(MAKECMDGOALS)))
endif

flash: $(BUILD_BEFORE_FLASH) $(FLASHDEPS)
@command -v $(FLASHER) >/dev/null 2>&1 || \
{ $(COLOR_ECHO) \
'$(COLOR_RED)Flash program $(FLASHER) not found. Aborting.$(COLOR_RESET)'; \
exit 1; }
$(call check_cmd,$(FLASHER),Flash program)
$(FLASHER) $(FFLAGS)

flash-only: flash
Expand All @@ -412,10 +415,7 @@ preflash: $(BUILD_BEFORE_FLASH)
$(PREFLASHER) $(PREFFLAGS)

term: $(filter flash, $(MAKECMDGOALS)) $(TERMDEPS)
@command -v $(TERMPROG) >/dev/null 2>&1 || \
{ $(COLOR_ECHO) \
'$(COLOR_RED)Terminal program $(TERMPROG) not found. Aborting.$(COLOR_RESET)'; \
exit 1; }
$(call check_cmd,$(TERMPROG),Terminal program)
$(TERMPROG) $(TERMFLAGS)

list-ttys:
Expand All @@ -425,41 +425,26 @@ doc:
make -BC $(RIOTBASE) doc

debug:
@command -v $(DEBUGGER) >/dev/null 2>&1 || \
{ $(COLOR_ECHO) \
'$(COLOR_RED)Debug program $(DEBUGGER) not found. Aborting.$(COLOR_RESET)'; \
exit 1; }
$(call check_cmd,$(DEBUGGER),Debug program)
$(DEBUGGER) $(DEBUGGER_FLAGS)

debug-server:
@command -v $(DEBUGSERVER) >/dev/null 2>&1 || \
{ $(COLOR_ECHO) \
'$(COLOR_RED)Debug server program $(DEBUGSERVER) not found. Aborting.$(COLOR_RESET)'; \
exit 1; }
$(call check_cmd,$(DEBUGSERVER),Debug server program)
$(DEBUGSERVER) $(DEBUGSERVER_FLAGS)

emulate:
@command -v $(EMULATOR) >/dev/null 2>&1 || \
{ $(COLOR_ECHO) \
'$(COLOR_RED)Emulation program $(EMULATOR) not found. Aborting.$(COLOR_RESET)'; \
exit 1; }
$(call check_cmd,$(EMULATOR),Emulation program)
$(EMULATOR) $(EMULATOR_FLAGS)

reset:
@command -v $(RESET) >/dev/null 2>&1 || \
{ $(COLOR_ECHO) \
'$(COLOR_RED)Reset program $(RESET) not found. Aborting.$(COLOR_RESET)'; \
exit 1; }
$(call check_cmd,$(RESET),Reset program)
$(RESET) $(RESET_FLAGS)

# Default OBJDUMPFLAGS for platforms which do not specify it:
OBJDUMPFLAGS ?= -S -D -h

objdump:
@command -v $(OBJDUMP) >/dev/null 2>&1 || \
{ $(COLOR_ECHO) \
'$(COLOR_RED)Objdump program $(OBJDUMP) not found. Aborting.$(COLOR_RESET)'; \
exit 1; }
$(call check_cmd,$(OBJDUMP),Objdump program)
$(OBJDUMP) $(OBJDUMPFLAGS) $(ELFFILE) | less

# Generate an XML file containing all macro definitions and include paths for
Expand Down