256
|
1 |
export CGO_ENABLED=0 |
|
2 |
go := go |
|
3 |
go.goos ?= $(shell echo `go version`|cut -f4 -d ' '|cut -d '/' -f1) |
|
4 |
go.goarch ?= $(shell echo `go version`|cut -f4 -d ' '|cut -d '/' -f2) |
|
5 |
|
|
6 |
out.tools := tomll tomljson jsontoml |
|
7 |
out.dist := $(out.tools:=_$(go.goos)_$(go.goarch).tar.xz) |
|
8 |
sources := $(wildcard **/*.go) |
|
9 |
|
|
10 |
|
|
11 |
.PHONY: |
|
12 |
tools: $(out.tools) |
|
13 |
|
|
14 |
$(out.tools): $(sources) |
|
15 |
GOOS=$(go.goos) GOARCH=$(go.goarch) $(go) build ./cmd/$@ |
|
16 |
|
|
17 |
.PHONY: |
|
18 |
dist: $(out.dist) |
|
19 |
|
|
20 |
$(out.dist):%_$(go.goos)_$(go.goarch).tar.xz: % |
|
21 |
if [ "$(go.goos)" = "windows" ]; then \ |
|
22 |
tar -cJf $@ $^.exe; \ |
|
23 |
else \ |
|
24 |
tar -cJf $@ $^; \ |
|
25 |
fi |
|
26 |
|
|
27 |
.PHONY: |
|
28 |
clean: |
|
29 |
rm -rf $(out.tools) $(out.dist) |