forked from Edgio/vflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
76 lines (63 loc) · 2.35 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
71
72
73
74
75
76
VERSION= 0.8.0
PACKAGES= $(shell find . -name '*.go' -print0 | xargs -0 -n1 dirname | sort --unique)
LDFLAGS= -ldflags "-X main.version=${VERSION}"
DEBPATH= scripts/dpkg
RPMPATH= scripts/rpmbuild
ARCH=`uname -m`
default: test
test:
go test -v ./... -timeout 1m
bench:
go test -v ./... -bench=. -timeout 2m
run: build
cd vflow; ./vflow -sflow-workers 100 -ipfix-workers 100
debug: build
cd vflow; ./vflow -sflow-workers 100 -ipfix-workers 100 -verbose=true
gctrace: build
cd vflow; env GODEBUG=gctrace=1 ./vflow -sflow-workers 100 -ipfix-workers 100
lint:
golint ./...
cyclo:
gocyclo -over 15 $(PACKAGES)
errcheck:
errcheck ./...
tools:
go get github.com/golang/lint/golint
go get github.com/kisielk/errcheck
go get github.com/alecthomas/gocyclo
build:
cd vflow; CGO_ENABLED=0 go build $(LDFLAGS)
cd stress; CGO_ENABLED=0 go build
dpkg: build
mkdir -p ${DEBPATH}/etc/init.d ${DEBPATH}/etc/logrotate.d
mkdir -p ${DEBPATH}/etc/vflow ${DEBPATH}/usr/share/doc/vflow
mkdir -p ${DEBPATH}/usr/bin ${DEBPATH}/usr/local/vflow
sed -i 's/%VERSION%/${VERSION}/' ${DEBPATH}/DEBIAN/control
cp vflow/vflow ${DEBPATH}/usr/bin/
cp stress/stress ${DEBPATH}/usr/bin/vflow_stress
cp scripts/vflow.service ${DEBPATH}/etc/init.d/vflow
cp scripts/vflow.logrotate ${DEBPATH}/etc/logrotate.d/vflow
cp scripts/vflow.conf ${DEBPATH}/etc/vflow/vflow.conf
cp scripts/kafka.conf ${DEBPATH}/etc/vflow/mq.conf
cp scripts/ipfix.elements ${DEBPATH}/etc/vflow/
cp ${DEBPATH}/DEBIAN/copyright ${DEBPATH}/usr/share/doc/vflow/
cp LICENSE ${DEBPATH}/usr/share/doc/vflow/license
dpkg-deb -b ${DEBPATH}
mv ${DEBPATH}.deb scripts/vflow-${VERSION}-${ARCH}.deb
sed -i 's/${VERSION}/%VERSION%/' ${DEBPATH}/DEBIAN/control
rpm: build
sed -i 's/%VERSION%/${VERSION}/' ${RPMPATH}/SPECS/vflow.spec
rm -rf ${RPMPATH}/SOURCES/
mkdir ${RPMPATH}/SOURCES/
cp vflow/vflow ${RPMPATH}/SOURCES/
cp stress/stress ${RPMPATH}/SOURCES/vflow_stress
cp scripts/vflow.conf ${RPMPATH}/SOURCES/
cp scripts/vflow.service ${RPMPATH}/SOURCES/
cp scripts/vflow.logrotate ${RPMPATH}/SOURCES/
cp scripts/kafka.conf ${RPMPATH}/SOURCES/mq.conf
cp scripts/ipfix.elements ${RPMPATH}/SOURCES/
cp LICENSE ${RPMPATH}/SOURCES/license
cp NOTICE ${RPMPATH}/SOURCES/notice
apt-get install rpm
rpmbuild -ba ${RPMPATH}/SPECS/vflow.spec --define "_topdir `pwd`/scripts/rpmbuild"
sed -i 's/${VERSION}/%VERSION%/' ${RPMPATH}/SPECS/vflow.spec