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