From db5b1aa5f6b31a9d571e02e592888e23f435d265 Mon Sep 17 00:00:00 2001 From: Sylvain Rabot Date: Mon, 6 Nov 2017 15:55:43 +0100 Subject: [PATCH] Makefile: Allow $(GO) to be set with environmental variable (#2919) * promu: Use same go invocation as prometheus' for building If you override $(GO) var in prometheus Makefile in order to use a custom go binary you might encounter errors while building promu as promu's Makefile $(GO) var is also defined to look for go in the $PATH and you might end up using different go binaries for building prometheus and promu. This patch makes prometheus Makefile pass its $(GO) var to promu's makefile as environmental variable. Signed-off-by: Sylvain Rabot * Makefile: Allow $(GO) to be set with environmental variable Signed-off-by: Sylvain Rabot * Makefile: Fix hardcoded call to gofmt Signed-off-by: Sylvain Rabot --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 5535427c6..570ab33cc 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -GO := GO15VENDOREXPERIMENT=1 go +GO ?= GO15VENDOREXPERIMENT=1 go +GOFMT ?= $(GO)fmt FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH))) PROMU := $(FIRST_GOPATH)/bin/promu STATICCHECK := $(FIRST_GOPATH)/bin/staticcheck @@ -39,7 +40,7 @@ all: format staticcheck build test style: @echo ">> checking code style" - @! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^' + @! $(GOFMT) -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^' check_license: @echo ">> checking license header" @@ -88,6 +89,7 @@ promu: @echo ">> fetching promu" @GOOS=$(shell uname -s | tr A-Z a-z) \ GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \ + GO="$(GO)" \ $(GO) get -u github.com/prometheus/promu $(FIRST_GOPATH)/bin/staticcheck: