summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2022-02-27 16:32:41 -0500
committerDave Henderson <dhenderson@gmail.com>2022-02-27 16:57:14 -0500
commitbfc045aa1c01da5e9fdb9d408a3ac6aa143948a7 (patch)
tree3a0395e4ee68a06479b48753c8a7207fba77edac /Makefile
parent5f87a079db6ee741812ef7c2e88bd741f5a58f31 (diff)
Build with Go 1.18rc1
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile31
1 files changed, 16 insertions, 15 deletions
diff --git a/Makefile b/Makefile
index d424ecee..a627b81a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,5 @@
.DEFAULT_GOAL = build
+GO ?= go
extension = $(patsubst windows,.exe,$(filter windows,$(1)))
PKG_NAME := gomplate
DOCKER_REPO ?= hairyhenderson/$(PKG_NAME)
@@ -20,11 +21,11 @@ endif
COMMIT ?= `git rev-parse --short HEAD 2>/dev/null`
VERSION ?= `git describe --abbrev=0 --tags $(git rev-list --tags --max-count=1) 2>/dev/null | sed 's/v\(.*\)/\1/'`
-COMMIT_FLAG := -X `go list ./version`.GitCommit=$(COMMIT)
-VERSION_FLAG := -X `go list ./version`.Version=$(VERSION)
+COMMIT_FLAG := -X `$(GO) list ./version`.GitCommit=$(COMMIT)
+VERSION_FLAG := -X `$(GO) list ./version`.Version=$(VERSION)
-GOOS ?= $(shell go version | sed 's/^.*\ \([a-z0-9]*\)\/\([a-z0-9]*\)/\1/')
-GOARCH ?= $(shell go version | sed 's/^.*\ \([a-z0-9]*\)\/\([a-z0-9]*\)/\2/')
+GOOS ?= $(shell $(GO) version | sed 's/^.*\ \([a-z0-9]*\)\/\([a-z0-9]*\)/\1/')
+GOARCH ?= $(shell $(GO) version | sed 's/^.*\ \([a-z0-9]*\)\/\([a-z0-9]*\)/\2/')
ifeq ("$(TARGETVARIANT)","")
ifneq ("$(GOARM)","")
@@ -134,35 +135,35 @@ docker-images: gomplate.iid gomplate-slim.iid
$(PREFIX)/bin/$(PKG_NAME)_%v5$(call extension,$(GOOS)): $(shell find $(PREFIX) -type f -name "*.go")
GOOS=$(shell echo $* | cut -f1 -d-) GOARCH=$(shell echo $* | cut -f2 -d- ) GOARM=5 CGO_ENABLED=0 \
- go build \
+ $(GO) build \
-ldflags "-w -s $(COMMIT_FLAG) $(VERSION_FLAG)" \
-o $@ \
./cmd/$(PKG_NAME)
$(PREFIX)/bin/$(PKG_NAME)_%v6$(call extension,$(GOOS)): $(shell find $(PREFIX) -type f -name "*.go")
GOOS=$(shell echo $* | cut -f1 -d-) GOARCH=$(shell echo $* | cut -f2 -d- ) GOARM=6 CGO_ENABLED=0 \
- go build \
+ $(GO) build \
-ldflags "-w -s $(COMMIT_FLAG) $(VERSION_FLAG)" \
-o $@ \
./cmd/$(PKG_NAME)
$(PREFIX)/bin/$(PKG_NAME)_%v7$(call extension,$(GOOS)): $(shell find $(PREFIX) -type f -name "*.go")
GOOS=$(shell echo $* | cut -f1 -d-) GOARCH=$(shell echo $* | cut -f2 -d- ) GOARM=7 CGO_ENABLED=0 \
- go build \
+ $(GO) build \
-ldflags "-w -s $(COMMIT_FLAG) $(VERSION_FLAG)" \
-o $@ \
./cmd/$(PKG_NAME)
$(PREFIX)/bin/$(PKG_NAME)_windows-%.exe: $(shell find $(PREFIX) -type f -name "*.go")
GOOS=windows GOARCH=$* GOARM= CGO_ENABLED=0 \
- go build \
+ $(GO) build \
-ldflags "-w -s $(COMMIT_FLAG) $(VERSION_FLAG)" \
-o $@ \
./cmd/$(PKG_NAME)
$(PREFIX)/bin/$(PKG_NAME)_%$(TARGETVARIANT)$(call extension,$(GOOS)): $(shell find $(PREFIX) -type f -name "*.go")
GOOS=$(shell echo $* | cut -f1 -d-) GOARCH=$(shell echo $* | cut -f2 -d- ) GOARM=$(GOARM) CGO_ENABLED=0 \
- go build \
+ $(GO) build \
-ldflags "-w -s $(COMMIT_FLAG) $(VERSION_FLAG)" \
-o $@ \
./cmd/$(PKG_NAME)
@@ -174,21 +175,21 @@ build: $(PREFIX)/bin/$(PKG_NAME)_$(GOOS)-$(GOARCH)$(TARGETVARIANT)$(call extensi
ifeq ($(OS),Windows_NT)
test:
- go test -coverprofile=c.out ./...
+ $(GO) test -coverprofile=c.out ./...
else
test:
- go test -race -coverprofile=c.out ./...
+ $(GO) test -race -coverprofile=c.out ./...
endif
ifeq ($(OS),Windows_NT)
integration: $(PREFIX)/bin/$(PKG_NAME)$(call extension,$(GOOS))
- go test -v \
- -ldflags "-X `go list ./internal/tests/integration`.GomplateBinPath=$(shell cygpath -ma .)/$<" \
+ $(GO) test -v \
+ -ldflags "-X `$(GO) list ./internal/tests/integration`.GomplateBinPath=$(shell cygpath -ma .)/$<" \
./internal/tests/integration
else
integration: $(PREFIX)/bin/$(PKG_NAME)
- go test -v \
- -ldflags "-X `go list ./internal/tests/integration`.GomplateBinPath=$(shell pwd)/$<" \
+ $(GO) test -v \
+ -ldflags "-X `$(GO) list ./internal/tests/integration`.GomplateBinPath=$(shell pwd)/$<" \
./internal/tests/integration
endif