-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
60 lines (48 loc) · 1.82 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
## use BASH
SHELL:=/bin/bash
## name of binary
BINARY?=gobcly
## used for compiling with debug enabled / disabled
DEBUGFLAG?=TRUE
## OS
GOOS?=$(shell uname -s | perl -ne "chomp; print lc($$_);")
## ARCH
GOARCH?=$(shell uname -m | perl -ne "chomp; s/^x86_64$$/amd64/; print;")
## arch-specific
BINARY:=$(if $(GOOS) && $(GOARCH),$(BINARY).$(GOOS)_$(GOARCH),"")
## default
LDFLAGS:="-X main.Binary=${BINARY} -X main.DebugFlag=${DEBUGFLAG}"
## DIST
DIST:=./dist
DISTBIN:=${DIST}/gobcly
## will write this to a file 'VERSION' in the repo, used by 'govvv'
## expecting that we are using git flow and tagging releases
VERSION=`(git flow release list 2>/dev/null | cut -f 2 -d " ") | (git describe --tags)`
# Builds the project
build:
## this shouldn't be necessary but check anyway
command -v go >/dev/null 2>&1 || ( echo "Make requires \'go\' in your path" 1>&2 ; exit 1 )
## requires govvv is installed
command -v govvv >/dev/null 2>&1 || ( go get -u github.com/ahmetb/govvv )
command -v govvv >/dev/null 2>&1 || ( echo "Tried to install \'govvv\' but doesn\'t appear to be in your path!" 1>&2 ; exit 1 )
## write the version file
echo ${VERSION} >VERSION
## do the build with govvv
env GOOS=${GOOS} GOARCH=${GOARCH} govvv build -o ${BINARY} -ldflags ${LDFLAGS} .
# Installs our project: copies binaries
install: export BINARY=gobcly
install:
env GOOS=${GOOS} GOARCH=${GOARCH} govvv install -ldflags ${LDFLAGS} .
# Cleans our project: deletes binaries
clean:
if [ -f ${BINARY} ] ; then rm ${BINARY} ; fi
if [ -f ${DISTBIN} ] ; then rm ${DISTBIN} && rmdir ${DIST} ; fi
dist: export CGO_CFLAGS="-I/usr/local/Cellar/hyperscan/5.2.1/include/hs"
dist: export GOOS=linux
dist: export GOARCH=amd64
dist: export BINARY=gobcly.linux_amd64
dist: build
if [ -x upx ] ; then upx ${BINARY} ; fi
mkdir -p ${DIST}
mv ${BINARY} ${DISTBIN}
.PHONY: clean install dist