override SHELL := /bin/sh
override MAKEFLAGS += --no-print-directory

.DEFAULT_GOAL := help
.DELETE_ON_ERROR:

override CARGO := cargo
override CARGO_FLAGS := --locked --offline

override PRIMARY_GOAL := $(firstword $(MAKECMDGOALS))

ifeq ($(PRIMARY_GOAL),run)

.PHONY: run

.DEFAULT:
	@:

else

.PHONY: help run

help: ## Show configurator commands
	@printf '%s\n' 'Configurator' '' \
		'Start the local web application, then select the serial device in the browser:' \
		'  make firmware/tools/configurator'

endif

run: ## Run the configurator with the remaining command-line arguments
	@exec python3 ../../../scripts/make-argv.py exec run \
		$(CARGO) run $(CARGO_FLAGS) -p kaptan-configurator --
