-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
70 lines (54 loc) · 1.68 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
BINARY = timesheet
VET_REPORT = vet.report
TEST_REPORT = tests.xml
GOARCH = amd64
VERSION?=?
# Symlink into GOPATH
GITHUB_USERNAME=praveenprem
BUILD_DIR=${GOPATH}/src/github.com/${GITHUB_USERNAME}/${BINARY}
BIN_DIR=${GOPATH}/bin
CURRENT_DIR=\$(shell pwd)
BUILD_DIR_LINK=\$(shell readlink ${BUILD_DIR})
# Setup the -ldflags option for go build here, interpolate the variable values
LDFLAGS = -ldflags "-X main.VERSION=${VERSION}"
# Build the project
# all: link clean test vet linux darwin windows
#link:
# BUILD_DIR=${BUILD_DIR}; \
# BUILD_DIR_LINK=${BUILD_DIR_LINK}; \
# CURRENT_DIR=${CURRENT_DIR}; \
# if [ "${BUILD_DIR_LINK}" != "${CURRENT_DIR}" ]; then \
# echo "Fixing symlinks for build"; \
# rm -f ${BUILD_DIR}; \
# ln -s ${CURRENT_DIR} ${BUILD_DIR}; \
# fi
linux:
GOOS=linux GOARCH=${GOARCH} go build ${LDFLAGS} -o ${BIN_DIR}/${BINARY}-linux-${GOARCH} .
build:
GOOS=darwin GOARCH=${GOARCH} go build ${LDFLAGS} -o ${BIN_DIR}/${BINARY} .
darwin:
GOOS=darwin GOARCH=${GOARCH} go build ${LDFLAGS} -o ${BIN_DIR}/${BINARY} .
windows:
GOOS=windows GOARCH=${GOARCH} go build ${LDFLAGS} -o ${BINARY}-windows-${GOARCH}.exe .
install:
install ${BIN_DIR}/${BINARY} /usr/local/bin/${BINARY}
test:
if ! hash go2xunit 2>/dev/null; then go install github.com/tebeka/go2xunit; fi
cd ${BUILD_DIR}; \
godep go test -v ./... 2>&1 | go2xunit -output ${TEST_REPORT} ; \
cd - >/dev/null
vet:
-cd ${BUILD_DIR}; \
godep go vet ./... > ${VET_REPORT} 2>&1 ; \
cd - >/dev/null
fmt:
cd ${BUILD_DIR}; \
go fmt \$$(go list ./... | grep -v /vendor/) ; \
cd - >/dev/null
# deps:
# go get gopkg.in/go-ini/ini.v1
# clean:
# -rm -f ${TEST_REPORT}
# -rm -f ${VET_REPORT}
# -rm -f ${BINARY}-*
.PHONY: build