forked from G-Node/gin-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
56 lines (37 loc) · 1.29 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# full pkg name
PKG = github.com/G-Node/gin-cli
# Binary
GIN = gin
# Build loc
BUILDLOC = build
# Install location
INSTLOC = $(GOPATH)/bin
# tests submodule bin
TESTBINLOC = tests/bin
# Build flags
VERNUM = $(shell cut -d= -f2 version)
ncommits = $(shell git rev-list --count HEAD)
BUILDNUM = $(shell printf '%06d' $(ncommits))
COMMITHASH = $(shell git rev-parse HEAD)
LDFLAGS = -ldflags="-X main.gincliversion=$(VERNUM) -X main.build=$(BUILDNUM) -X main.commit=$(COMMITHASH)"
SOURCES = $(shell find . -type f -iname "*.go") version
.PHONY: gin allplatforms install linux windows macos clean uninstall doc
gin: $(BUILDLOC)/$(GIN)
allplatforms: linux windows macos
install: gin
install $(BUILDLOC)/$(GIN) $(INSTLOC)/$(GIN)
linux: $(BUILDLOC)/linux/$(GIN)
windows: $(BUILDLOC)/windows/$(GIN).exe
macos: $(BUILDLOC)/darwin/$(GIN)
clean:
rm -r $(BUILDLOC)
uninstall:
rm $(INSTLOC)/$(GIN)
$(BUILDLOC)/$(GIN): $(SOURCES)
go build $(LDFLAGS) -o $(BUILDLOC)/$(GIN)
$(BUILDLOC)/linux/$(GIN): $(SOURCES)
GOOS=linux GOARCH=amd64 go build -o $(BUILDLOC)/linux/$(GIN) $(LDFLAGS)
$(BUILDLOC)/windows/$(GIN).exe: $(SOURCES)
GOOS=windows GOARCH=386 go build -o $(BUILDLOC)/windows/$(GIN).exe $(LDFLAGS)
$(BUILDLOC)/darwin/$(GIN): $(SOURCES)
GOOS=darwin GOARCH=amd64 go build -o $(BUILDLOC)/darwin/$(GIN) $(LDFLAGS)