-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathMakefile
41 lines (33 loc) · 1.54 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
# Makefile for p4prometheus project
BINARY=p4prometheus
# These are the values we want to pass for VERSION and BUILD
# git tag 1.0.1
# git commit -am "One more change after the tags"
VERSION=`git describe --tags`
BUILD_DATE=`date +%FT%T%z`
USER=`git config user.email`
BRANCH=`git rev-parse --abbrev-ref HEAD`
REVISION=`git rev-parse --short HEAD`
# Setup the -ldflags option for go build here, interpolate the variable values
MODULE="github.com/perforce/p4prometheus"
LDFLAGS=-ldflags "-w -s -X ${MODULE}/version.Version=${VERSION} -X ${MODULE}/version.BuildDate=${BUILD_DATE} -X ${MODULE}/version.Branch=${BRANCH} -X ${MODULE}/version.Revision=${REVISION} -X ${MODULE}/version.BuildUser=${USER}"
# Builds the project
build:
go build ${LDFLAGS}
# Builds distribution
dist:
GOOS=linux GOARCH=amd64 go build -o bin/p4prometheus.linux-amd64 ${LDFLAGS}
GOOS=linux GOARCH=arm64 go build -o bin/p4prometheus.linux-arm64 ${LDFLAGS}
GOOS=windows GOARCH=amd64 go build -o bin/p4prometheus.windows-amd64.exe ${LDFLAGS}
GOOS=darwin GOARCH=amd64 go build -o bin/p4prometheus.darwin-amd64 ${LDFLAGS}
GOOS=darwin GOARCH=arm64 go build -o bin/p4prometheus.darwin-arm64 ${LDFLAGS}
-chmod +x bin/p4prometheus.linux-* bin/p4prometheus.windows-*.exe bin/p4prometheus.darwin-*
rm -f bin/p4prometheus.*.gz
gzip bin/p4prometheus.linux-* bin/p4prometheus.windows-*.exe bin/p4prometheus.darwin-*
# Installs our project: copies binaries
install:
go install ${LDFLAGS_f1}
# Cleans our project: deletes binaries
clean:
if [ -f ${BINARY} ] ; then rm ${BINARY} ; fi
.PHONY: clean install