diff --git a/Makefile b/Makefile index 5a3e042fa..322df6db4 100644 --- a/Makefile +++ b/Makefile @@ -25,10 +25,12 @@ CTIMEVAR=-X $(PKG)/internal/version.GitCommit=$(GITCOMMIT) \ -X $(PKG)/internal/version.BuildMeta=$(BUILDMETA) \ -X $(PKG)/internal/version.ProjectName=$(NAME) \ -X $(PKG)/internal/version.ProjectURL=$(PKG) + +GO ?= "go" GO_LDFLAGS=-ldflags "-s -w $(CTIMEVAR)" GOOSARCHES = linux/amd64 darwin/amd64 windows/amd64 -GOOS = $(shell go env GOOS) -GOARCH= $(shell go env GOARCH) +GOOS = $(shell $(GO) env GOOS) +GOARCH= $(shell $(GO) env GOARCH) MISSPELL_VERSION = v0.3.4 GOLANGCI_VERSION = v1.21.0 OPA_VERSION = v0.21.0 @@ -46,10 +48,10 @@ generate-mocks: ## Generate mocks .PHONY: build-deps build-deps: ## Install build dependencies @echo "==> $@" - @cd /tmp; GO111MODULE=on go get github.com/client9/misspell/cmd/misspell@${MISSPELL_VERSION} - @cd /tmp; GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_VERSION} - @cd /tmp; GO111MODULE=on go get github.com/open-policy-agent/opa@${OPA_VERSION} - @cd /tmp; GO111MODULE=on go get github.com/tetratelabs/getenvoy/cmd/getenvoy@${GETENVOY_VERSION} + @cd /tmp; GO111MODULE=on $(GO) get github.com/client9/misspell/cmd/misspell@${MISSPELL_VERSION} + @cd /tmp; GO111MODULE=on $(GO) get github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_VERSION} + @cd /tmp; GO111MODULE=on $(GO) get github.com/open-policy-agent/opa@${OPA_VERSION} + @cd /tmp; GO111MODULE=on $(GO) get github.com/tetratelabs/getenvoy/cmd/getenvoy@${GETENVOY_VERSION} .PHONY: docs docs: ## Start the vuepress docs development server @@ -64,12 +66,12 @@ tag: ## Create a new git tag to prepare to build a release .PHONY: frontend frontend: ## Runs go generate on the static assets package. @echo "==> $@" - @CGO_ENABLED=0 GO111MODULE=on go generate github.com/pomerium/pomerium/internal/frontend + @CGO_ENABLED=0 GO111MODULE=on $(GO) generate github.com/pomerium/pomerium/internal/frontend .PHONY: build build: ## Builds dynamic executables and/or packages. @echo "==> $@" - @CGO_ENABLED=0 GO111MODULE=on go build -tags "$(BUILDTAGS)" ${GO_LDFLAGS} -o $(BINDIR)/$(NAME) ./cmd/"$(NAME)" + @CGO_ENABLED=0 GO111MODULE=on $(GO) build -tags "$(BUILDTAGS)" ${GO_LDFLAGS} -o $(BINDIR)/$(NAME) ./cmd/"$(NAME)" ./scripts/embed-envoy.bash $(BINDIR)/$(NAME) .PHONY: lint @@ -80,7 +82,7 @@ lint: ## Verifies `golint` passes. .PHONY: test test: ## Runs the go tests. @echo "==> $@" - @go test -tags "$(BUILDTAGS)" $(shell go list ./... | grep -v vendor | grep -v github.com/pomerium/pomerium/integration) + @$(GO) test -tags "$(BUILDTAGS)" $(shell $(GO) list ./... | grep -v vendor | grep -v github.com/pomerium/pomerium/integration) @opa test ./authorize/evaluator/opa/policy .PHONY: spellcheck @@ -93,7 +95,7 @@ spellcheck: # Spellcheck docs cover: ## Runs go test with coverage @echo "" > coverage.txt @for d in $(shell go list ./... | grep -v vendor); do \ - go test -race -coverprofile=profile.out -covermode=atomic "$$d"; \ + $(GO) test -race -coverprofile=profile.out -covermode=atomic "$$d"; \ if [ -f profile.out ]; then \ cat profile.out >> coverage.txt; \ rm profile.out; \ @@ -109,7 +111,7 @@ clean: ## Cleanup any build binaries or packages. .PHONY: release snapshot: ## Builds the cross-compiled binaries, naming them in such a way for release (eg. binary-GOOS-GOARCH) @echo "+ $@" - @cd /tmp; GO111MODULE=on go get github.com/goreleaser/goreleaser + @cd /tmp; GO111MODULE=on $(GO) get github.com/goreleaser/goreleaser goreleaser release --rm-dist -f .github/goreleaser.yaml --snapshot .PHONY: help