forked from yyyar/gobetween
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
113 lines (92 loc) · 3.06 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
101
102
103
104
105
106
107
108
109
110
111
112
113
#
# Makefile
# @author Yaroslav Pogrebnyak <[email protected]>
# @author Ievgen Ponomarenko <[email protected]>
#
.PHONY: update clean build build-all run package deploy test authors dist
export GOPATH := ${PWD}/vendor:${PWD}
export GOBIN := ${PWD}/vendor/bin
NAME := gobetween
VERSION := $(shell cat VERSION)
LDFLAGS := -X main.version=${VERSION}
default: build
clean:
@echo Cleaning up...
@rm bin/* -rf
@rm dist/* -rf
@echo Done.
build:
@echo Building...
go build -v -o ./bin/$(NAME) -ldflags '${LDFLAGS}' ./src/*.go
@echo Done.
build-static:
@echo Building...
CGO_ENABLED=1 go build -v -o ./bin/$(NAME) -ldflags '-s -w --extldflags "-static" ${LDFLAGS}' ./src/*.go
@echo Done.
run: build
./bin/$(NAME) -c ./config/${NAME}.toml
test:
@go test test/*.go
install: build
install -d ${DESTDIR}/usr/local/bin/
install -m 755 ./bin/${NAME} ${DESTDIR}/usr/local/bin/${NAME}
install ./config/${NAME}.toml ${DESTDIR}/etc/${NAME}.toml
uninstall:
rm -f ${DESTDIR}/usr/local/bin/${NAME}
rm -f ${DESTDIR}/etc/${NAME}.toml
authors:
@git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort | uniq -c -i | sort -nr | sed "s/^ *[0-9]* //g" > AUTHORS
@cat AUTHORS
clean-deps:
rm -rf ./vendor/src
rm -rf ./vendor/pkg
rm -rf ./vendor/bin
deps: clean-deps
GOPATH=${PWD}/vendor go get -u -v \
github.com/BurntSushi/toml \
github.com/miekg/dns \
github.com/fsouza/go-dockerclient \
github.com/Sirupsen/logrus \
github.com/elgs/gojq \
github.com/gin-gonic/gin \
github.com/hashicorp/consul/api \
github.com/spf13/cobra \
github.com/Microsoft/go-winio \
golang.org/x/sys/windows \
github.com/inconshreveable/mousetrap \
github.com/gin-contrib/cors \
github.com/lxc/lxd/client \
github.com/lxc/lxd/lxc/config \
github.com/lxc/lxd/shared \
github.com/lxc/lxd/shared/api \
github.com/pires/go-proxyproto \
golang.org/x/crypto/acme/autocert
clean-dist:
rm -rf ./dist/${VERSION}
dist:
@# For linux 386 when building on linux amd64 you'll need 'libc6-dev-i386' package
@echo Building dist
@# os arch cgo ext
@for arch in "linux 386 1 " "linux amd64 1 " \
"windows 386 0 .exe " "windows amd64 0 .exe " \
"darwin 386 0 " "darwin amd64 0 "; \
do \
set -- $$arch ; \
echo "******************* $$1_$$2 ********************" ;\
distpath="./dist/${VERSION}/$$1_$$2" ;\
mkdir -p $$distpath ; \
CGO_ENABLED=$$3 GOOS=$$1 GOARCH=$$2 go build -v -o $$distpath/$(NAME)$$4 -ldflags '-s -w --extldflags "-static" ${LDFLAGS}' ./src/*.go ;\
cp "README.md" "LICENSE" "CHANGELOG.md" "AUTHORS" $$distpath ;\
mkdir -p $$distpath/config && cp "./config/gobetween.toml" $$distpath/config ;\
if [ "$$1" = "linux" ]; then \
cd $$distpath && tar -zcvf ../../${NAME}_${VERSION}_$$1_$$2.tar.gz * && cd - ;\
else \
cd $$distpath && zip -r ../../${NAME}_${VERSION}_$$1_$$2.zip . && cd - ;\
fi \
done
build-container-latest: build
@echo Building docker container LATEST
docker build -t yyyar/gobetween .
build-container-tagged: build
@echo Building docker container ${VERSION}
docker build -t yyyar/gobetween:${VERSION} .