-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
91 lines (73 loc) · 2.26 KB
/
Makefile
File metadata and controls
91 lines (73 loc) · 2.26 KB
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
# This how we want to name the binary output
BINARY=strongback
OUTPUT_DIR=out
WHAT=strongback.org/cli
# Read the version information from our file
VERSION=$(shell cat VERSION)
# Or could get from most recent tag reachable from the latest commit
#VERSION=`git describe --tags`
# Set the build date
BUILD_TIMESTAMP=`date +%FT%T%z`
BUILD_DATE=`date +"%Y-%m-%d"`
# Setup the -ldflags option for go build here
LDFLAGS=-ldflags "-w -s -X main.Version=${VERSION} -X main.Date=${BUILD_DATE} -X main.ExecName=${BINARY} -X main.Build=${BUILD_TIMESTAMP}"
GCFLAGS=-gcflags=-trimpath=${GOPATH} -asmflags=-trimpath=${GOPATH}
#
# Make everything
#
.PHONY: all
all: macos linux windows
#
# Cleans and builds everything
#
.PHONY: clean
clean:
$(info Cleaning 'out' directory)
@rm -rf ${OUTPUT_DIR}
#
# Packaging for each OS
#
.PHONY: macos
macos: out/macos package-macos
.PHONY: linux
linux: out/linux package-linux
.PHONY: windows
windows: out/windows package-windows
#
# Compile
#
out/macos: dependencies
$(info macos: building executable)
@GOOS="darwin" GOARCH="amd64" go build ${LDFLAGS} ${GCFLAGS} -o ${OUTPUT_DIR}/macos/strongback ${WHAT}
out/linux: dependencies
$(info Linux: building executable)
@GOOS="linux" GOARCH="amd64" go build ${LDFLAGS} ${GCFLAGS} -o ${OUTPUT_DIR}/linux/strongback ${WHAT}
out/windows: dependencies
$(info Windows: building executable)
@GOOS="windows" GOARCH="386" go build ${LDFLAGS} ${GCFLAGS} -o ${OUTPUT_DIR}/windows/strongback.exe ${WHAT}
.PHONY: test
test:
echo ${VERSION}
#
# Packaging
#
package: package-macos package-linux package-windows
.PHONY: package-macos
package-macos: out/macos
$(info macos: packaging archive)
@tar -czf ${OUTPUT_DIR}/strongback-cli-${VERSION}-macos.tar.gz -C ${OUTPUT_DIR}/macos strongback
.PHONY: package-linux
package-linux: out/linux
$(info Linux: packaging archive)
@tar -czf ${OUTPUT_DIR}/strongback-cli-${VERSION}-linux.tar.gz -C ${OUTPUT_DIR}/linux strongback
.PHONY: package-windows
package-windows: out/windows
$(info Windows: packaging archive)
@zip -r -j ${OUTPUT_DIR}/strongback-cli-${VERSION}-windows.zip ${OUTPUT_DIR}/windows > /dev/null
#
# Dependencies
#
dependencies: ../../github.com/rickar/props
../../github.com/rickar/props:
# Used to read Java properties files
go get -u github.com/rickar/props