-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmakefile
34 lines (28 loc) · 1.03 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
GOCMD=go
GOBUILD=${GOCMD} build
GOCLEAN=${GOCMD} clean
GOTEST=${GOCMD} test
GOGET=${GOCMD} get
DATE= `date +%FT%T%z`
BINARY_NAME="`pwd |awk -F '/' '{print $NF}'`"
BINARY_LINUX=${BINARY_NAME}_linux
BUILDUSER=`whoami`@`hostname`
BUILDDATE=`date +'%Y-%m-%d %H:%M:%S'`
GITREVISION=`git rev-parse HEAD`
GITVERSION=`cat VERSION`
GITBRANCH=`git symbolic-ref --short -q HEAD`
LDFLAGES=" -X 'github.com/prometheus/common/version.BuildUser=${BUILDUSER}' -X 'github.com/prometheus/common/version.BuildDate=${BUILDDATE}' -X 'github.com/prometheus/common/version.Revision=${GITREVISION}' -X 'github.com/prometheus/common/version.Version=${GITVERSION}' -X 'github.com/prometheus/common/version.Branch=${GITBRANCH}' "
all: build
build:
${GOBUILD} -v -ldflags ${LDFLAGES} -o ${BINARY_NAME}
test:
${GOTEST} -v ./...
clean:
${GOCLEAN}
rm -f ${BINARY_NAME}
rm -f ${BINARY_LINUX}
run:
${GOBUILD} -o ${BINARY_NAME} -v ./...
./${BINARY_NAME}
build-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 ${GOBUILD} -ldflags ${LDFLAGES} -o ${BINARY_LINUX} -v