-
Notifications
You must be signed in to change notification settings - Fork 29
/
Makefile
61 lines (47 loc) · 1.46 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
.PHONY: all clean-all build cleand-deps deps ver make-gopath
DATE := $(shell git log -1 --format="%cd" --date=short | sed s/-//g)
COUNT := $(shell git rev-list --count HEAD)
COMMIT := $(shell git rev-parse --short HEAD)
CWD := $(shell pwd)
BINARYNAME := zabbix-agent-extension-elasticsearch
CONFIG := configs/zabbix_agentd.d/zabbix-agent-extension-elasticsearch.conf
VERSION := "${DATE}.${COUNT}_${COMMIT}"
LDFLAGS := "-X main.version=${VERSION}"
default: all
all: clean-all make-gopath deps build
ver:
@echo ${VERSION}
clean-all: clean-deps
@echo Clean builded binaries
rm -rf .out/
rm -rf .gopath/
@echo Done
build:
@echo Build
cd ${CWD}/.gopath/src/${BINARYNAME}; \
GOPATH=${CWD}/.gopath \
go build -v -o ${CWD}/.out/${BINARYNAME} -ldflags ${LDFLAGS} *.go
@echo Done
clean-deps:
@echo Clean dependencies
rm -rf ${CWD}/.gopath/src/${BINARYNAME}/vendor/
deps:
@echo Fetch dependencies
cd ${CWD}/.gopath/src/${BINARYNAME}; \
GOPATH=${CWD}/.gopath \
dep ensure -v
make-gopath:
@echo Creating GOPATH
mkdir -p .gopath/src
ln -s ${CWD}/cmd/${BINARYNAME} ${CWD}/.gopath/src/${BINARYNAME}
install:
@echo Install
cp .out/${BINARYNAME} /usr/bin/${BINARYNAME}
cp configs/zabbix_agentd.d/zabbix-agent-extension-elasticsearch.conf \
/etc/zabbix/zabbix_agentd.conf.d/zabbix-agent-extension-elasticsearch.conf
@echo Done
remove:
@echo Remove
rm -f /usr/bin/${BINARYNAME}
rm -f /etc/zabbix/zabbix_agentd.conf.d/zabbix-agent-extension-elasticsearch.conf
@echo Done