Makefile

Universal build tool

  • $@ = target name
  • $^ = all prerequisites
  • $< = first prerequisite
  • := evaluated once in whole script
  • = evaluated every time value is being used

Ensuring Cross Platform Compatibility

Here’s some tips on ensuring cross platform compatibility for Linux (shell) and Windows (cmd/powershell):

  • use tabs to indent commands in makefile targets
  • use cd dir && command instead of cd dir; command
  • use built in @echo "TEXT $(VAR)" function for printing output
  • avoid special characters after @echo statements

Generate Help Target

help: ## Show all Makefile targets
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
 
update: ## Update Quartz to the latest version on Github
	go install github.com/jackyzha0/hugo-obsidian@latest
 
update-force: ## Forcefully pull all changes and don't ask to patch
	go install github.com/jackyzha0/hugo-obsidian@latest

GitHub - quartz/Makefile at hugo