-
Notifications
You must be signed in to change notification settings - Fork 49
/
Makefile
98 lines (75 loc) · 2.51 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
NAME:=carbon-clickhouse
DESCRIPTION:="Graphite metrics receiver with ClickHouse as storage"
MODULE:=github.com/lomik/carbon-clickhouse
GO ?= go
export GOFLAGS += -mod=vendor
export GO111MODULE := on
TEMPDIR:=$(shell mktemp -d)
DEVEL ?= 0
ifeq ($(DEVEL), 0)
VERSION:=$(shell sh -c 'grep "const Version" $(NAME).go | cut -d\" -f2')
else
VERSION:=$(shell sh -c 'git describe --always --tags | sed -e "s/^v//i"')
endif
SRCS:=$(shell find . -name '*.go')
all: $(NAME)
.PHONY: clean
clean:
rm -f $(NAME)
rm -f e2e-test
rm -rf out
rm -f *deb *rpm
rm -f sha256sum md5sum
$(NAME): $(SRCS)
$(GO) build $(MODULE)
e2e-test: $(NAME)
$(GO) build $(MODULE)/cmd/e2e-test
test:
$(GO) test -race ./...
gox-build: out/$(NAME)-linux-amd64 out/$(NAME)-linux-arm64 out/root/etc/$(NAME)/$(NAME).conf
ARCH = amd64 arm64
out/$(NAME)-linux-%: out $(SRCS)
GOOS=linux GOARCH=$* $(GO) build -o $@ $(MODULE)
out:
mkdir -p out
out/root/etc/$(NAME)/$(NAME).conf: $(NAME)
mkdir -p "$(shell dirname $@)"
./$(NAME) -config-print-default > $@
nfpm-deb: gox-build
$(MAKE) nfpm-build-deb ARCH=amd64
$(MAKE) nfpm-build-deb ARCH=arm64
nfpm-rpm: gox-build
$(MAKE) nfpm-build-rpm ARCH=amd64
$(MAKE) nfpm-build-rpm ARCH=arm64
nfpm-build-%: nfpm.yaml
NAME=$(NAME) DESCRIPTION=$(DESCRIPTION) ARCH=$(ARCH) VERSION_STRING=$(VERSION) nfpm package --packager $*
.ONESHELL:
RPM_VERSION:=$(subst -,_,$(VERSION))
packagecloud-push-rpm: $(wildcard $(NAME)-$(RPM_VERSION)-1.*.rpm)
for pkg in $^; do
package_cloud push $(REPO)/el/7 $${pkg} || true
package_cloud push $(REPO)/el/8 $${pkg} || true
package_cloud push $(REPO)/el/9 $${pkg} || true
done
.ONESHELL:
packagecloud-push-deb: $(wildcard $(NAME)_$(VERSION)_*.deb)
for pkg in $^; do
package_cloud push $(REPO)/ubuntu/xenial $${pkg} || true
package_cloud push $(REPO)/ubuntu/bionic $${pkg} || true
package_cloud push $(REPO)/ubuntu/focal $${pkg} || true
package_cloud push $(REPO)/debian/stretch $${pkg} || true
package_cloud push $(REPO)/debian/buster $${pkg} || true
package_cloud push $(REPO)/debian/bullseye $${pkg} || true
done
packagecloud-push:
@$(MAKE) packagecloud-push-rpm
@$(MAKE) packagecloud-push-deb
packagecloud-autobuilds:
$(MAKE) packagecloud-push REPO=go-graphite/autobuilds
packagecloud-stable:
$(MAKE) packagecloud-push REPO=go-graphite/stable
sum-files: | sha256sum md5sum
md5sum:
md5sum $(wildcard $(NAME)_$(VERSION)*.deb) $(wildcard $(NAME)-$(VERSION)*.rpm) > md5sum
sha256sum:
sha256sum $(wildcard $(NAME)_$(VERSION)*.deb) $(wildcard $(NAME)-$(VERSION)*.rpm) > sha256sum