-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Makefile
107 lines (93 loc) · 3.41 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
CMD = agent aggregator graph hbs judge nodata transfer gateway api alarm falcon2p8s
TARGET = open-falcon
PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*")
GOFMT ?= gofmt "-s"
VERSION := $(shell cat VERSION)
all: $(CMD) $(TARGET)
.PHONY: misspell-check
misspell-check:
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
go get -u github.com/client9/misspell/cmd/misspell; \
fi
misspell -error $(GOFILES)
.PHONY: misspell
misspell:
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
go get -u github.com/client9/misspell/cmd/misspell; \
fi
misspell -w $(GOFILES)
vet:
go vet $(PACKAGES)
fmt:
$(GOFMT) -w $(GOFILES)
.PHONY: fmt-check
fmt-check:
# get all go files and run go fmt on them
@diff=$$($(GOFMT) -d $(GOFILES)); \
if [ -n "$$diff" ]; then \
echo "Please run 'make fmt' and commit the result:"; \
echo "$${diff}"; \
exit 1; \
fi;
$(CMD):
if [ $@ = "gateway" ]; then \
GO111MODULE=on go build -ldflags "-X main.BinaryName=gateway -X main.GitCommit=`git rev-parse --short HEAD` -X main.Version=$(VERSION)" \
-o bin/gateway/falcon-gateway ./modules/transfer ; \
else \
GO111MODULE=on go build -ldflags "-X main.BinaryName=$@ -X main.GitCommit=`git rev-parse --short HEAD` -X main.Version=$(VERSION)" \
-o bin/$@/falcon-$@ ./modules/$@ ; \
fi
.PHONY: $(TARGET)
$(TARGET): $(GOFILES)
GO111MODULE=on go build -ldflags "-X main.BinaryName=Open-Falcon -X main.GitCommit=`git rev-parse --short HEAD` -X main.Version=$(VERSION)" -o open-falcon
checkbin: bin/ config/ open-falcon
pack: checkbin
@if [ -e out ] ; then rm -rf out; fi
@mkdir out
@$(foreach var,$(CMD),mkdir -p ./out/$(var)/bin;)
@$(foreach var,$(CMD),mkdir -p ./out/$(var)/config;)
@$(foreach var,$(CMD),mkdir -p ./out/$(var)/logs;)
@$(foreach var,$(CMD),cp ./config/$(var).json ./out/$(var)/config/cfg.json;)
@$(foreach var,$(CMD),cp ./bin/$(var)/falcon-$(var) ./out/$(var)/bin;)
@cp -r ./modules/agent/public ./out/agent/
@(cd ./out && ln -s ./agent/public ./public)
@(cd ./out && mkdir -p ./agent/plugin && ln -s ./agent/plugin ./plugin)
@cp -r ./modules/api/data ./out/api/
@mkdir out/graph/data
@bash ./config/confgen.sh
@cp $(TARGET) ./out/$(TARGET)
tar -C out -zcf open-falcon-v$(VERSION).tar.gz .
@rm -rf out
pack4docker: checkbin
@if [ -e out ] ; then rm -rf out; fi
@mkdir out
@$(foreach var,$(CMD),mkdir -p ./out/$(var)/bin;)
@$(foreach var,$(CMD),mkdir -p ./out/$(var)/config;)
@$(foreach var,$(CMD),mkdir -p ./out/$(var)/logs;)
@$(foreach var,$(CMD),cp ./config/$(var).json ./out/$(var)/config/cfg.json;)
@$(foreach var,$(CMD),cp ./bin/$(var)/falcon-$(var) ./out/$(var)/bin;)
@if expr "$(CMD)" : "agent" > /dev/null; then \
(cp -r ./modules/agent/public ./out/agent/); \
(cd ./out && ln -s ./agent/public ./public); \
(cd ./out && mkdir -p ./agent/plugin && ln -s ./agent/plugin ./plugin); \
fi
@if expr "$(CMD)" : "api" > /dev/null; then \
cp -r ./modules/api/data ./out/api/; \
fi
@if expr "$(CMD)" : "graph" > /dev/null; then \
mkdir out/graph/data; \
fi
@cp ./docker/ctrl.sh ./out/ && chmod +x ./out/ctrl.sh
@cp $(TARGET) ./out/$(TARGET)
tar -C out -zcf open-falcon-v$(VERSION).tar.gz .
@rm -rf out
.PHONY: test
test:
@go test ./modules/api/test
clean:
@rm -rf ./bin
@rm -rf ./out
@rm -rf ./$(TARGET)
@rm -rf open-falcon-v$(VERSION).tar.gz
.PHONY: clean all agent aggregator graph hbs judge nodata transfer gateway api alarm