|
| 1 | +# If you update this file, please follow |
| 2 | +# https://suva.sh/posts/well-documented-makefiles |
| 3 | + |
| 4 | +## -------------------------------------- |
| 5 | +## General |
| 6 | +## -------------------------------------- |
| 7 | + |
| 8 | +.DEFAULT_GOAL := help |
| 9 | + |
| 10 | +BINARY_NAME=kubernetes-mcp-server |
| 11 | +LD_FLAGS=-s -w \ |
| 12 | + -X '$(PACKAGE)/pkg/version.CommitHash=$(COMMIT_HASH)' \ |
| 13 | + -X '$(PACKAGE)/pkg/version.BuildTime=$(BUILD_TIME)' \ |
| 14 | + -X '$(PACKAGE)/pkg/version.BinaryName=$(BINARY_NAME)' |
| 15 | +COMMON_BUILD_ARGS=-ldflags "$(LD_FLAGS)" |
| 16 | +CLEAN_TARGETS:= |
| 17 | + |
| 18 | +# The help will print out all targets with their descriptions organized bellow their categories. The categories are represented by `##@` and the target descriptions by `##`. |
| 19 | +# The awk commands is responsible to read the entire set of makefiles included in this invocation, looking for lines of the file as xyz: ## something, and then pretty-format the target and help. Then, if there's a line with ##@ something, that gets pretty-printed as a category. |
| 20 | +# More info over the usage of ANSI control characters for terminal formatting: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters |
| 21 | +# More info over awk command: http://linuxcommand.org/lc3_adv_awk.php |
| 22 | +# |
| 23 | +# Notice that we have a little modification on the awk command to support slash in the recipe name: |
| 24 | +# origin: /^[a-zA-Z_0-9-]+:.*?##/ |
| 25 | +# modified /^[a-zA-Z_0-9\/\.-]+:.*?##/ |
| 26 | +.PHONY: help |
| 27 | +help: ## Display this help |
| 28 | + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9\/\.-]+:.*?##/ { printf " \033[36m%-21s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) |
| 29 | + |
| 30 | +.PHONY: clean |
| 31 | +clean: ## Clean up all build artifacts |
| 32 | + rm -rf $(CLEAN_TARGETS) |
| 33 | + |
| 34 | +.PHONY: build |
| 35 | +build: ## Build the project |
| 36 | + go build $(COMMON_BUILD_ARGS) -o $(BINARY_NAME) ./cmd/kubernetes-mcp-server |
| 37 | + |
| 38 | +CLEAN_TARGETS+='$(BINARY_NAME)' |
| 39 | + |
| 40 | +.PHONY: tidy |
| 41 | +tidy: ## Tidy up the go modules |
| 42 | + go mod tidy |
0 commit comments