-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
45 lines (34 loc) · 1.05 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
BINARY = ../../copysql
GOARCH = amd64
VERSION?=?
COMMIT=$(shell git rev-parse HEAD)
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
BUILD_DIR=${GOPATH}/src/github.com/oleh-ozimok/copysql/cmd/copysql
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} -X main.COMMIT=${COMMIT} -X main.BRANCH=${BRANCH}"
all: clean test vet linux darwin
linux:
cd ${BUILD_DIR}; \
GOOS=linux GOARCH=${GOARCH} go build ${LDFLAGS} -o ${BINARY}-linux-${GOARCH} . ; \
cd - >/dev/null
darwin:
cd ${BUILD_DIR}; \
GOOS=darwin GOARCH=${GOARCH} go build ${LDFLAGS} -o ${BINARY}-darwin-${GOARCH} . ; \
cd - >/dev/null
test:
cd ${BUILD_DIR}/../..; \
go test -v ./...; \
cd - >/dev/null
vet:
-cd ${BUILD_DIR}/../..; \
go vet $$(go list ./... | grep -v /vendor/); \
cd - >/dev/null
fmt:
cd ${BUILD_DIR}/../..; \
go fmt $$(go list ./... | grep -v /vendor/) ; \
cd - >/dev/null
clean:
-rm -f ${BINARY}-*
.PHONY: linux darwin test vet fmt clean