-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
31 lines (24 loc) · 1.18 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
PKG=github.com/CGamesPlay/git-remote-restic
RESTIC_VERSION = $(shell cat restic/VERSION)
GOFLAGS_debug = -ldflags '-X "main.Version=$(shell git rev-parse --short HEAD; [ -z "$$(git status --porcelain --untracked-files=no)" ] || echo 'with uncommitted changes')" -X "main.ResticVersion=$(RESTIC_VERSION)"'
GOFLAGS_release = -ldflags '-s -w -extldflags "-static" -X "main.Version=$(shell cat VERSION)" -X "main.ResticVersion=$(RESTIC_VERSION)"'
OSARCHS = darwin/amd64 darwin/arm64 linux/amd64 linux/arm64
.PHONY: install
install:
go install $(GOFLAGS_debug) $(PKG)/...
.PHONY: test
test: install
go test $(PKG)/...
./fixtures/test.sh
.PHONY: bins
bins:
go install github.com/mitchellh/gox@latest
gox -osarch "$(OSARCHS)" -output "bin/{{.OS}}_{{.Arch}}/git-remote-restic" $(GOFLAGS_release) $(PKG)/cmd/git-remote-restic
.PHONY: release
release: test $(patsubst %,bin/%.tar.gz,$(subst /,_,$(OSARCHS)))
define ruletemp
$(patsubst %,bin/%.tar.gz,$(subst /,_,$(1))): $(patsubst %,bin/%/git-remote-restic,$(subst /,_,$(1)))
tar -czf $$@ -C $$(dir $$^) $$(notdir $$^)
$(patsubst %,bin/%/git-remote-restic,$(subst /,_,$(1))): bins
endef
$(foreach osarch,$(OSARCHS),$(eval $(call ruletemp, $(osarch))))