1export CGO_ENABLED=0 2go := go 3go.goos ?= $(shell echo `go version`|cut -f4 -d ' '|cut -d '/' -f1) 4go.goarch ?= $(shell echo `go version`|cut -f4 -d ' '|cut -d '/' -f2) 5 6out.tools := tomll tomljson jsontoml 7out.dist := $(out.tools:=_$(go.goos)_$(go.goarch).tar.xz) 8sources := $(wildcard **/*.go) 9 10 11.PHONY: 12tools: $(out.tools) 13 14$(out.tools): $(sources) 15 GOOS=$(go.goos) GOARCH=$(go.goarch) $(go) build ./cmd/$@ 16 17.PHONY: 18dist: $(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: 28clean: 29 rm -rf $(out.tools) $(out.dist) 30