Makefile -rw-r--r-- 1.7 KiB
1DOCKER_CMD=docker run --rm -ti -w /build/pomo -v $$PWD:/build/pomo
2DOCKER_IMAGE=pomo-build
3VERSION ?= $(shell git describe --tags 2>/dev/null)
4ifeq "$(VERSION)" ""
5 VERSION := UNKNOWN
6endif
7
8.PHONY: \
9 test \
10 docs \
11 pomo-build \
12 readme \
13 release \
14 release-linux \
15 release-darwin
16
17bin/pomo: test
18 go build -o $@
19
20bindata.go: tomato-icon.png
21 go-bindata -pkg main -o $@ $^
22
23test:
24 go test ./...
25 go vet ./...
26
27pomo-build:
28 docker build -t $(DOCKER_IMAGE) .
29
30bin/pomo-linux: bin/pomo-$(VERSION)-linux-amd64
31
32bin/pomo-darwin: bin/pomo-$(VERSION)-darwin-amd64
33
34bin/pomo-$(VERSION)-linux-amd64: bin bindata.go
35 $(DOCKER_CMD) --env GOOS=linux --env GOARCH=amd64 $(DOCKER_IMAGE) go build -ldflags "-X main.Version=$(VERSION)" -o $@
36
37bin/pomo-$(VERSION)-linux-amd64.md5:
38 md5sum bin/pomo-$(VERSION)-linux-amd64 | sed -e 's/bin\///' > $@
39
40bin/pomo-$(VERSION)-darwin-amd64: bin bindata.go
41 # This is used to cross-compile a Darwin compatible Mach-O executable
42 # on Linux for OSX, you need to install https://github.com/tpoechtrager/osxcross
43 $(DOCKER_CMD) --env GOOS=darwin --env GOARCH=amd64 --env CC=x86_64-apple-darwin15-cc --env CGO_ENABLED=1 $(DOCKER_IMAGE) go build -ldflags "-X main.Version=$(VERSION)" -o $@
44
45
46bin/pomo-$(VERSION)-darwin-amd64.md5:
47 md5sum bin/pomo-$(VERSION)-darwin-amd64 | sed -e 's/bin\///' > $@
48
49release-linux: bin/pomo-$(VERSION)-linux-amd64 bin/pomo-$(VERSION)-linux-amd64.md5
50
51release-darwin: bin/pomo-$(VERSION)-darwin-amd64 bin/pomo-$(VERSION)-darwin-amd64.md5
52
53release: release-linux release-darwin
54
55docs: www/data/readme.json
56 cd www && cp ../install.sh static/ && hugo -d ../docs
57
58www/data/readme.json: www/data README.md
59 cat README.md | python -c 'import json,sys; print(json.dumps({"content": sys.stdin.read()}))' > $@
60
61www/data bin:
62 mkdir -p $@