Skip to content

Instantly share code, notes, and snippets.

@NucciTheBoss
Last active June 25, 2024 14:14
Show Gist options
  • Save NucciTheBoss/2325897e8bdc130951297386ecd209f1 to your computer and use it in GitHub Desktop.
Save NucciTheBoss/2325897e8bdc130951297386ecd209f1 to your computer and use it in GitHub Desktop.
Template Makefile for non-Python based projects
##@ Build
.PHONY: build
build: ## Build project
# Where targets related to building the project - e.g. compiling, preprocessing, snapping, etc. - should go.
##@ Lint
# Where targets related to linting the project source code should go.
.PHONY: fmt
fmt: ## Format project
.PHONY: lint
lint: ## Lint project
##@ Clean
# Where targets related to cleaning the environment of the project should go.
.PHONY: clean
clean: ## Clean up project
# Don't this. This block is necessary for rendering the help text in a nice way from the shell.
.PHONY: help
help:
@awk 'BEGIN {\
FS = ":.*##"; \
printf "Usage: ${FORMATTING_BEGIN_BLUE}OPTION${FORMATTING_END}=<value> make ${FORMATTING_BEGIN_YELLOW}<target>${FORMATTING_END}\n"\
} \
/^[a-zA-Z0-9_-]+:.*?##/ { printf " ${FORMATTING_BEGIN_BLUE}%-46s${FORMATTING_END} %s\n", $$1, $$2 } \
/^.?.?##~/ { printf " %-46s${FORMATTING_BEGIN_YELLOW}%-46s${FORMATTING_END}\n", "", substr($$1, 6) } \
/^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment