# TODO: Add default targets
################################################################################
#                        CO2 Ampel Firmware - Makefile                         #
################################################################################

## Run `make` to show available targets

help:     ## Show this help.
	@egrep -h '(\s##\s|^##\s)' $(MAKEFILE_LIST) | egrep -v '^--' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m  %-35s\033[0m %s\n", $$1, $$2}'

build: ## Build. (board should be defined)
ifdef board
	pio -f run -e $(board)
else
	@echo "Please define board parameter:"
	@echo "make build board=esp8266"
	@echo "or"
	@echo "make build board=esp32"
	@exit 1
endif

build_all: ## Build for all boards
	pio -f run

upload: ## Upload to ESP. (board should be defined)
ifdef board
	pio -f run --target upload -e $(board)
else
	@echo "Please define board parameter:"
	@echo "make upload board=esp8266"
	@exit 1
endif

clean: ## Clean project
	pio -f run --target clean

update: ## Update PIO
	pio pkg update

monitor: ## Monitor ESP output
	pio device monitor --filter colorize

compiledb: ## Creates compilation DB, e.g. for Clang LSP
	pio run -t compiledb
