-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
86 lines (75 loc) · 3.02 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
PROJECT=gdrive2discord
UID=$(shell id -u)
GID=$(shell id -g)
VERSION=$(shell git describe --always)
SHELL = /bin/bash
local: FORCE
@echo spawning docker container
@docker run --rm=true \
-v ${PWD}/:/go/src/github.com/RISE-Project-STI2D/gdrive2discord/ \
-v ${PWD}/Makefile:/go/Makefile \
-v ${PWD}/bin:/go/bin \
-w /go/src/github.com/RISE-Project-STI2D/gdrive2discord/ \
golang:1.4-cross \
make -f /go/Makefile $(PROJECT)-linux-amd64 UID=${UID} GID=${GID} VERSION=${VERSION}
run-local: local
bin/$(PROJECT)-linux-amd64 configuration.json
opfa: FORCE
@echo spawning docker container
@docker run --rm=true \
-v ${PWD}/:/go/src/github.com/RISE-Project-STI2D/gdrive2discord/ \
-v ${PWD}/Makefile:/go/Makefile \
-v ${PWD}/bin:/go/bin \
-w /go/src/github.com/RISE-Project-STI2D/gdrive2discord/ \
golang:1.4-cross \
make -f /go/Makefile $(PROJECT)-linux-amd64 UID=${UID} GID=${GID} VERSION=${VERSION}
all: FORCE
@echo spawning docker container
@docker run --rm=true \
-v ${PWD}/:/go/src/github.com/optionfactory/gdrive2slack/ \
-v ${PWD}/Makefile:/go/Makefile \
-v ${PWD}/bin:/go/bin \
-w /go/src/github.com/optionfactory/gdrive2slack/ \
golang:1.4-cross \
make -f /go/Makefile build UID=${UID} GID=${GID} VERSION=${VERSION}
clean: FORCE
-rm -rf bin/$(PROJECT)-*
build: \
$(PROJECT)-linux-386 $(PROJECT)-linux-amd64 $(PROJECT)-linux-arm \
$(PROJECT)-darwin-386 $(PROJECT)-darwin-amd64 \
$(PROJECT)-dragonfly-386 $(PROJECT)-dragonfly-amd64 \
$(PROJECT)-freebsd-386 $(PROJECT)-freebsd-amd64 $(PROJECT)-freebsd-arm \
$(PROJECT)-netbsd-386 $(PROJECT)-netbsd-amd64 $(PROJECT)-netbsd-arm \
$(PROJECT)-openbsd-386 $(PROJECT)-openbsd-amd64 \
$(PROJECT)-solaris-amd64 \
$(PROJECT)-windows-386 $(PROJECT)-windows-amd64
$(PROJECT)-linux-%: GOOS = linux
$(PROJECT)-darwin-%: GOOS = darwin
$(PROJECT)-dragonfly-%: GOOS = dragonfly
$(PROJECT)-freebsd-%: GOOS = freebsd
$(PROJECT)-netbsd-%: GOOS = netbsd
$(PROJECT)-openbsd-%: GOOS = openbsd
$(PROJECT)-solaris-%: GOOS = solaris
$(PROJECT)-windows-%: GOOS = windows
$(PROJECT)-windows-%: EXT = .exe
$(PROJECT)-%-amd64: GOARCH = amd64
$(PROJECT)-%-386: GOARCH = 386
$(PROJECT)-%-arm: GOARCH = arm
$(PROJECT)-%: format *.go
@echo building for $(GOOS):$(GOARCH)
@GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go get -installsuffix netgo ./...
@if [ "${GOOS}" == "linux" -a "${GOARCH}" == "amd64" ]; then \
GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go test -a -tags netgo -installsuffix netgo -ldflags "-X main.version $(VERSION)" ./...; \
fi
@GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go install -a -tags netgo -installsuffix netgo -ldflags "-X main.version $(VERSION)"
@if [ "${GOOS}" == "linux" -a "${GOARCH}" == "amd64" ]; then \
mv "/go/bin/${PROJECT}${EXT}" "/go/bin/${PROJECT}-${GOOS}-${GOARCH}${EXT}"; \
else \
mv "/go/bin/${GOOS}_${GOARCH}/${PROJECT}${EXT}" "/go/bin/${PROJECT}-${GOOS}-${GOARCH}${EXT}"; \
rm -rf "/go/bin/${GOOS}_${GOARCH}/"; \
fi
@chown ${UID}:${GID} "/go/bin/${PROJECT}-${GOOS}-${GOARCH}${EXT}"
format:
@echo reformatting
@gofmt -w=true -s=true .
FORCE: