# Variables

BREW_FORMULAE := clang-format swiftlint

# --- ENVIRONMENT ---

set-environment: ## Setup your development environment for this project.
ifeq (, $(shell which brew))
	@echo "You're required to enter your root password to install HOMEBREW in your Mac."
	@sudo true
	@curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | sudo -u $$USER bash
else
	@echo "Updating HOMEBREW before installing the dependencies. This might take a little while..."
	@brew update
endif
	@brew install $(BREW_FORMULAE) || brew upgrade $(BREW_FORMULAE)

unset-environment: ## Unset your development environment for this project.
	@brew uninstall $(BREW_FORMULAE)
	@brew cleanup

# --- HELP ---

# Output the documentation for each of the defined tasks when `help` is called.
# Reference: https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.PHONY: help

help: ## Print the written documentation for all the defined tasks.
	@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

.DEFAULT_GOAL := help
