Makefile 631 B

123456789101112131415161718192021222324252627282930
  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. out.tools := tomll tomljson jsontoml
  6. out.dist := $(out.tools:=_$(go.goos)_$(go.goarch).tar.xz)
  7. sources := $(wildcard **/*.go)
  8. .PHONY:
  9. tools: $(out.tools)
  10. $(out.tools): $(sources)
  11. GOOS=$(go.goos) GOARCH=$(go.goarch) $(go) build ./cmd/$@
  12. .PHONY:
  13. dist: $(out.dist)
  14. $(out.dist):%_$(go.goos)_$(go.goarch).tar.xz: %
  15. if [ "$(go.goos)" = "windows" ]; then \
  16. tar -cJf $@ $^.exe; \
  17. else \
  18. tar -cJf $@ $^; \
  19. fi
  20. .PHONY:
  21. clean:
  22. rm -rf $(out.tools) $(out.dist)