summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2017-04-03 21:40:17 -0400
committerDave Henderson <dhenderson@gmail.com>2017-04-03 21:40:17 -0400
commit4f04674bee1b0ce19a7a4c3b4e68f7181369de2c (patch)
tree2a6f53f4396e06d0ce80ceab3331b53767e74d16
parentc9f161970a1826e48b4bc31258c36464ef20eb31 (diff)
Making cross-compile build step a bit more efficient
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
-rw-r--r--Makefile14
1 files changed, 6 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index fbfaa757..09170aa7 100644
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,8 @@ VERSION ?= `git describe --abbrev=0 --tags $(git rev-list --tags --max-count=1)
COMMIT_FLAG := -X `go list ./version`.GitCommit=$(COMMIT)
VERSION_FLAG := -X `go list ./version`.Version=$(VERSION)
+platforms := linux-amd64 linux-386 linux-arm linux-arm64 darwin-amd64 windows-amd64.exe windows-386.exe
+
define gocross
GOOS=$(1) GOARCH=$(2) \
$(GO) build \
@@ -24,14 +26,7 @@ endef
clean:
rm -Rf $(PREFIX)/bin/*
-build-x: $(shell find . -type f -name '*.go')
- $(call gocross,linux,amd64)
- $(call gocross,linux,386)
- $(call gocross,linux,arm)
- $(call gocross,linux,arm64)
- $(call gocross,darwin,amd64)
- $(call gocross,windows,amd64)
- $(call gocross,windows,386)
+build-x: $(patsubst %,$(PREFIX)/bin/$(PKG_NAME)_%,$(platforms))
compress-all:
$(call compress,linux,amd64)
@@ -40,6 +35,9 @@ compress-all:
build-release: clean build-x compress-all
+$(PREFIX)/bin/$(PKG_NAME)_%: $(shell find . -type f -name '*.go')
+ $(call gocross,$(shell echo $* | sed 's/\([^-]*\)-\([^.]*\).*/\1/'),$(shell echo $* | sed 's/\([^-]*\)-\([^.]*\).*/\2/'))
+
$(PREFIX)/bin/$(PKG_NAME)$(call extension,$(GOOS)): $(shell find . -type f -name '*.go')
$(GO) build -ldflags "-w -s $(COMMIT_FLAG) $(VERSION_FLAG)" -o $@