From 8b9ee7a5583b4e2bd13bfcba898ab4541c96b507 Mon Sep 17 00:00:00 2001 From: Will Norris Date: Thu, 16 Feb 2023 14:35:54 -0800 Subject: [PATCH] Makefile: add help text to Makefile https://rosszurowski.com/log/2022/makefiles#self-documenting-makefiles Signed-off-by: Will Norris --- Makefile | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 9a6bf51ac..1c26f0451 100644 --- a/Makefile +++ b/Makefile @@ -2,16 +2,13 @@ IMAGE_REPO ?= tailscale/tailscale SYNO_ARCH ?= "amd64" SYNO_DSM ?= "7" -usage: - echo "See Makefile" - -vet: +vet: ## Run go vet ./tool/go vet ./... -tidy: +tidy: ## Run go mod tidy ./tool/go mod tidy -updatedeps: +updatedeps: ## Update depaware deps # depaware (via x/tools/go/packages) shells back to "go", so make sure the "go" # it finds in its $$PATH is the right one. PATH="$$(./tool/go env GOROOT)/bin:$$PATH" ./tool/go run github.com/tailscale/depaware --update \ @@ -19,7 +16,7 @@ updatedeps: tailscale.com/cmd/tailscale \ tailscale.com/cmd/derper -depaware: +depaware: ## Run depaware checks # depaware (via x/tools/go/packages) shells back to "go", so make sure the "go" # it finds in its $$PATH is the right one. PATH="$$(./tool/go env GOROOT)/bin:$$PATH" ./tool/go run github.com/tailscale/depaware --check \ @@ -27,42 +24,42 @@ depaware: tailscale.com/cmd/tailscale \ tailscale.com/cmd/derper -buildwindows: +buildwindows: ## Build tailscale CLI for windows/amd64 GOOS=windows GOARCH=amd64 ./tool/go install tailscale.com/cmd/tailscale tailscale.com/cmd/tailscaled -build386: +build386: ## Build tailscale CLI for linux/386 GOOS=linux GOARCH=386 ./tool/go install tailscale.com/cmd/tailscale tailscale.com/cmd/tailscaled -buildlinuxarm: +buildlinuxarm: ## Build tailscale CLI for linux/arm GOOS=linux GOARCH=arm ./tool/go install tailscale.com/cmd/tailscale tailscale.com/cmd/tailscaled -buildwasm: +buildwasm: ## Build tailscale CLI for js/wasm GOOS=js GOARCH=wasm ./tool/go install ./cmd/tsconnect/wasm ./cmd/tailscale/cli -buildlinuxloong64: +buildlinuxloong64: ## Build tailscale CLI for linux/loong64 GOOS=linux GOARCH=loong64 ./tool/go install tailscale.com/cmd/tailscale tailscale.com/cmd/tailscaled -buildmultiarchimage: +buildmultiarchimage: ## Build (and optionally push) multiarch docker image ./build_docker.sh -check: staticcheck vet depaware buildwindows build386 buildlinuxarm buildwasm +check: staticcheck vet depaware buildwindows build386 buildlinuxarm buildwasm ## Perform basic checks and compilation tests -staticcheck: +staticcheck: ## Run staticcheck.io checks ./tool/go run honnef.co/go/tools/cmd/staticcheck -- $$(./tool/go list ./... | grep -v tempfork) -spk: +spk: ## Build synology package for ${SYNO_ARCH} architecture and ${SYNO_DSM} DSM version PATH="${PWD}/tool:${PATH}" ./tool/go run github.com/tailscale/tailscale-synology@main -o tailscale.spk --source=. --goarch=${SYNO_ARCH} --dsm-version=${SYNO_DSM} -spkall: +spkall: ## Build synology packages for all architectures and DSM versions mkdir -p spks PATH="${PWD}/tool:${PATH}" ./tool/go run github.com/tailscale/tailscale-synology@main -o spks --source=. --goarch=all --dsm-version=all -pushspk: spk +pushspk: spk ## Push and install synology package on ${SYNO_HOST} host echo "Pushing SPK to root@${SYNO_HOST} (env var SYNO_HOST) ..." scp tailscale.spk root@${SYNO_HOST}: ssh root@${SYNO_HOST} /usr/syno/bin/synopkg install tailscale.spk -publishdevimage: +publishdevimage: ## Build and publish tailscale image to location specified by ${REPO} @test -n "${REPO}" || (echo "REPO=... required; e.g. REPO=ghcr.io/${USER}/tailscale" && exit 1) @test "${REPO}" != "tailscale/tailscale" || (echo "REPO=... must not be tailscale/tailscale" && exit 1) @test "${REPO}" != "ghcr.io/tailscale/tailscale" || (echo "REPO=... must not be ghcr.io/tailscale/tailscale" && exit 1) @@ -70,10 +67,18 @@ publishdevimage: @test "${REPO}" != "ghcr.io/tailscale/k8s-operator" || (echo "REPO=... must not be ghcr.io/tailscale/k8s-operator" && exit 1) TAGS=latest REPOS=${REPO} PUSH=true TARGET=client ./build_docker.sh -publishdevoperator: +publishdevoperator: ## Build and publish k8s-operator image to location specified by ${REPO} @test -n "${REPO}" || (echo "REPO=... required; e.g. REPO=ghcr.io/${USER}/tailscale" && exit 1) @test "${REPO}" != "tailscale/tailscale" || (echo "REPO=... must not be tailscale/tailscale" && exit 1) @test "${REPO}" != "ghcr.io/tailscale/tailscale" || (echo "REPO=... must not be ghcr.io/tailscale/tailscale" && exit 1) @test "${REPO}" != "tailscale/k8s-operator" || (echo "REPO=... must not be tailscale/k8s-operator" && exit 1) @test "${REPO}" != "ghcr.io/tailscale/k8s-operator" || (echo "REPO=... must not be ghcr.io/tailscale/k8s-operator" && exit 1) TAGS=latest REPOS=${REPO} PUSH=true TARGET=operator ./build_docker.sh + +help: ## Show this help + @echo "\nSpecify a command. The choices are:\n" + @grep -hE '^[0-9a-zA-Z_-]+:.*?## .*$$' ${MAKEFILE_LIST} | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[0;36m%-20s\033[m %s\n", $$1, $$2}' + @echo "" +.PHONY: help + +.DEFAULT_GOAL := help