Makefile 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. IMAGE_REPO ?= tailscale/tailscale
  2. SYNO_ARCH ?= "amd64"
  3. SYNO_DSM ?= "7"
  4. TAGS ?= "latest"
  5. PLATFORM ?= "flyio" ## flyio==linux/amd64. Set to "" to build all platforms.
  6. vet: ## Run go vet
  7. ./tool/go vet ./...
  8. tidy: ## Run go mod tidy
  9. ./tool/go mod tidy
  10. lint: ## Run golangci-lint
  11. ./tool/go run github.com/golangci/golangci-lint/cmd/golangci-lint run
  12. updatedeps: ## Update depaware deps
  13. # depaware (via x/tools/go/packages) shells back to "go", so make sure the "go"
  14. # it finds in its $$PATH is the right one.
  15. PATH="$$(./tool/go env GOROOT)/bin:$$PATH" ./tool/go run github.com/tailscale/depaware --update \
  16. tailscale.com/cmd/tailscaled \
  17. tailscale.com/cmd/tailscale \
  18. tailscale.com/cmd/derper \
  19. tailscale.com/cmd/stund
  20. depaware: ## Run depaware checks
  21. # depaware (via x/tools/go/packages) shells back to "go", so make sure the "go"
  22. # it finds in its $$PATH is the right one.
  23. PATH="$$(./tool/go env GOROOT)/bin:$$PATH" ./tool/go run github.com/tailscale/depaware --check \
  24. tailscale.com/cmd/tailscaled \
  25. tailscale.com/cmd/tailscale \
  26. tailscale.com/cmd/derper \
  27. tailscale.com/cmd/stund
  28. buildwindows: ## Build tailscale CLI for windows/amd64
  29. GOOS=windows GOARCH=amd64 ./tool/go install tailscale.com/cmd/tailscale tailscale.com/cmd/tailscaled
  30. build386: ## Build tailscale CLI for linux/386
  31. GOOS=linux GOARCH=386 ./tool/go install tailscale.com/cmd/tailscale tailscale.com/cmd/tailscaled
  32. buildlinuxarm: ## Build tailscale CLI for linux/arm
  33. GOOS=linux GOARCH=arm ./tool/go install tailscale.com/cmd/tailscale tailscale.com/cmd/tailscaled
  34. buildwasm: ## Build tailscale CLI for js/wasm
  35. GOOS=js GOARCH=wasm ./tool/go install ./cmd/tsconnect/wasm ./cmd/tailscale/cli
  36. buildplan9:
  37. GOOS=plan9 GOARCH=amd64 ./tool/go install ./cmd/tailscale ./cmd/tailscaled
  38. buildlinuxloong64: ## Build tailscale CLI for linux/loong64
  39. GOOS=linux GOARCH=loong64 ./tool/go install tailscale.com/cmd/tailscale tailscale.com/cmd/tailscaled
  40. buildmultiarchimage: ## Build (and optionally push) multiarch docker image
  41. ./build_docker.sh
  42. check: staticcheck vet depaware buildwindows build386 buildlinuxarm buildwasm ## Perform basic checks and compilation tests
  43. staticcheck: ## Run staticcheck.io checks
  44. ./tool/go run honnef.co/go/tools/cmd/staticcheck -- $$(./tool/go list ./... | grep -v tempfork)
  45. kube-generate-all: kube-generate-deepcopy ## Refresh generated files for Tailscale Kubernetes Operator
  46. ./tool/go generate ./cmd/k8s-operator
  47. # Tailscale operator watches Connector custom resources in a Kubernetes cluster
  48. # and caches them locally. Caching is done implicitly by controller-runtime
  49. # library (the middleware used by Tailscale operator to create kube control
  50. # loops). When a Connector resource is GET/LIST-ed from within our control loop,
  51. # the request goes through the cache. To ensure that cache contents don't get
  52. # modified by control loops, controller-runtime deep copies the requested
  53. # object. In order for this to work, Connector must implement deep copy
  54. # functionality so we autogenerate it here.
  55. # https://github.com/kubernetes-sigs/controller-runtime/blob/v0.16.3/pkg/cache/internal/cache_reader.go#L86-L89
  56. kube-generate-deepcopy: ## Refresh generated deepcopy functionality for Tailscale kube API types
  57. ./scripts/kube-deepcopy.sh
  58. spk: ## Build synology package for ${SYNO_ARCH} architecture and ${SYNO_DSM} DSM version
  59. ./tool/go run ./cmd/dist build synology/dsm${SYNO_DSM}/${SYNO_ARCH}
  60. spkall: ## Build synology packages for all architectures and DSM versions
  61. ./tool/go run ./cmd/dist build synology
  62. pushspk: spk ## Push and install synology package on ${SYNO_HOST} host
  63. echo "Pushing SPK to root@${SYNO_HOST} (env var SYNO_HOST) ..."
  64. scp tailscale.spk root@${SYNO_HOST}:
  65. ssh root@${SYNO_HOST} /usr/syno/bin/synopkg install tailscale.spk
  66. publishdevimage: ## Build and publish tailscale image to location specified by ${REPO}
  67. @test -n "${REPO}" || (echo "REPO=... required; e.g. REPO=ghcr.io/${USER}/tailscale" && exit 1)
  68. @test "${REPO}" != "tailscale/tailscale" || (echo "REPO=... must not be tailscale/tailscale" && exit 1)
  69. @test "${REPO}" != "ghcr.io/tailscale/tailscale" || (echo "REPO=... must not be ghcr.io/tailscale/tailscale" && exit 1)
  70. @test "${REPO}" != "tailscale/k8s-operator" || (echo "REPO=... must not be tailscale/k8s-operator" && exit 1)
  71. @test "${REPO}" != "ghcr.io/tailscale/k8s-operator" || (echo "REPO=... must not be ghcr.io/tailscale/k8s-operator" && exit 1)
  72. TAGS="${TAGS}" REPOS=${REPO} PLATFORM=${PLATFORM} PUSH=true TARGET=client ./build_docker.sh
  73. publishdevoperator: ## Build and publish k8s-operator image to location specified by ${REPO}
  74. @test -n "${REPO}" || (echo "REPO=... required; e.g. REPO=ghcr.io/${USER}/tailscale" && exit 1)
  75. @test "${REPO}" != "tailscale/tailscale" || (echo "REPO=... must not be tailscale/tailscale" && exit 1)
  76. @test "${REPO}" != "ghcr.io/tailscale/tailscale" || (echo "REPO=... must not be ghcr.io/tailscale/tailscale" && exit 1)
  77. @test "${REPO}" != "tailscale/k8s-operator" || (echo "REPO=... must not be tailscale/k8s-operator" && exit 1)
  78. @test "${REPO}" != "ghcr.io/tailscale/k8s-operator" || (echo "REPO=... must not be ghcr.io/tailscale/k8s-operator" && exit 1)
  79. TAGS="${TAGS}" REPOS=${REPO} PLATFORM=${PLATFORM} PUSH=true TARGET=operator ./build_docker.sh
  80. help: ## Show this help
  81. @echo "\nSpecify a command. The choices are:\n"
  82. @grep -hE '^[0-9a-zA-Z_-]+:.*?## .*$$' ${MAKEFILE_LIST} | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[0;36m%-20s\033[m %s\n", $$1, $$2}'
  83. @echo ""
  84. .PHONY: help
  85. .DEFAULT_GOAL := help