-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
100 lines (77 loc) · 2.89 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
TARGET := mapago
PACKAGE := github.com/protocollabs/mapago
DATE := $(shell date +%FT%T%z)
VERSION := $(shell git describe --tags --always --dirty)
GOBIN :=$(GOPATH)/bin
MKDIR_P = @mkdir -p
# notice that
LDFLAGS = "-X $(PACKAGE)/core.BuildVersion=$(VERSION) -X $(PACKAGE)/core.BuildDate=$(DATE)"
SRC = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
.PHONY: all build clean install uninstall fmt simplify check run release
all: $(TARGET)
$(TARGET): $(SRC)
go build -ldflags $(LDFLAGS) mapago-server.go
go build -ldflags $(LDFLAGS) mapago-client.go
$(eval OS := windows)
$(eval PLATFORM := amd64)
$(eval ARCH=release/$(OS)-$(PLATFORM))
GOOS=$(OS) GOARCH=$(PLATFORM) go build -ldflags $(LDFLAGS) -o mapago-server.exe mapago-server.go
GOOS=$(OS) GOARCH=$(PLATFORM) go build -ldflags $(LDFLAGS) -o mapago-client.exe mapago-client.go
XYZs = windows:amd64 linux:arm64
release:
@rm -rf release/
@echo "build release for common architecturs"
@echo "release tag: $(VERSION)"
@sleep 3s
# @$(foreach XYZ,$(XYZs), \
# $(eval OS = $(word 1,$(subst :, ,$(XYZ)))) \
# $(eval PLATFORM = $(word 2,$(subst :, ,$(XYZ)))) \
# $(eval ARCH=release/$(OS)-$(PLATFORM)) \
# - @echo "build $(OS) Executable for $(PLATFORM)\n" \
# @rm -rf $(ARCH) \
# ${MKDIR_P} $(ARCH) \
# GOOS=$(OS) GOARCH=$(PLATFORM) go build -ldflags $(LDFLAGS) -o $(ARCH)/$(TARGET) cmd/mapago/mapago.go \
# )
$(eval OS := windows)
$(eval PLATFORM := amd64)
$(eval ARCH=release/$(OS)-$(PLATFORM))
@echo "build $(OS) Executable for $(PLATFORM)"
@rm -rf $(ARCH)
${MKDIR_P} $(ARCH)
GOOS=$(OS) GOARCH=$(PLATFORM) go build -ldflags $(LDFLAGS) -o $(ARCH)/$(TARGET).exe cmd/mapago/mapago.go
$(eval OS := linux)
$(eval PLATFORM := arm64)
$(eval ARCH=release/$(OS)-$(PLATFORM))
@echo "build $(OS) Executable for $(PLATFORM)"
@rm -rf $(ARCH)
${MKDIR_P} $(ARCH)
GOOS=$(OS) GOARCH=$(PLATFORM) go build -ldflags $(LDFLAGS) -o $(ARCH)/$(TARGET) cmd/mapago/mapago.go
$(eval OS := linux)
$(eval PLATFORM := amd64)
$(eval ARCH=release/$(OS)-$(PLATFORM))
@echo "build $(OS) Executable for $(PLATFORM)"
@rm -rf $(ARCH)
${MKDIR_P} $(ARCH)
GOOS=$(OS) GOARCH=$(PLATFORM) go build -ldflags $(LDFLAGS) -o $(ARCH)/$(TARGET) cmd/mapago/mapago.go
$(eval OS := darwin)
$(eval PLATFORM := amd64)
$(eval ARCH=release/$(OS)-$(PLATFORM))
@echo "build $(OS) Executable for $(PLATFORM)"
@rm -rf $(ARCH)
${MKDIR_P} $(ARCH)
GOOS=$(OS) GOARCH=$(PLATFORM) go build -ldflags $(LDFLAGS) -o $(ARCH)/$(TARGET) cmd/mapago/mapago.go
install:
go install -ldflags $(LDFLAGS) mapago-client.go
go install -ldflags $(LDFLAGS) mapago-server.go
build: $(TARGET)
@true
clean:
@rm -f $(TARGET)
fmt:
gofmt -l -w $(SRC)
simplify:
gofmt -s -l -w $(SRC)
check:
@test -z $(shell gofmt -l main.go | tee /dev/stderr) || echo "[WARN] Fix formatting issues with 'make fmt'"
@for d in $$(go list ./... | grep -v /vendor/); do golint $${d}; done
@go tool vet ${SRC}