|
1 | 1 | NAME:=graphite-clickhouse |
2 | | -MAINTAINER:="Roman Lomonosov <r.lomonosov@gmail.com>" |
3 | 2 | DESCRIPTION:="Graphite cluster backend with ClickHouse support" |
4 | 3 | MODULE:=github.com/lomik/graphite-clickhouse |
5 | 4 |
|
|
15 | 14 | VERSION:=$(shell sh -c 'git describe --always --tags | sed -e "s/^v//i"') |
16 | 15 | endif |
17 | 16 |
|
18 | | -OS ?= linux |
19 | | - |
20 | 17 | SRCS:=$(shell find . -name '*.go') |
21 | 18 |
|
22 | 19 | all: $(NAME) |
@@ -57,55 +54,32 @@ test: |
57 | 54 |
|
58 | 55 | e2e-test: $(NAME) |
59 | 56 | $(GO) build $(MODULE)/cmd/e2e-test |
60 | | - |
| 57 | + |
61 | 58 | client: $(NAME) |
62 | 59 | $(GO) build $(MODULE)/cmd/graphite-clickhouse-client |
63 | 60 |
|
64 | | -gox-build: |
65 | | - rm -rf out |
| 61 | +gox-build: out/$(NAME)-linux-amd64 out/$(NAME)-linux-arm64 out/root/etc/$(NAME)/$(NAME).conf |
| 62 | + |
| 63 | +ARCH = amd64 arm64 |
| 64 | +out/$(NAME)-linux-%: out $(SRCS) |
| 65 | + GOOS=linux GOARCH=$* $(GO) build -ldflags '-X main.BuildVersion=$(VERSION)' -o $@ $(MODULE) |
| 66 | + |
| 67 | +out: |
66 | 68 | mkdir -p out |
67 | | - gox -ldflags '-X main.BuildVersion=$(VERSION)' -os="$(OS)" -arch="amd64" -arch="arm64" -output="out/$(NAME)-{{.OS}}-{{.Arch}}" github.com/lomik/$(NAME) |
68 | | - ls -la out/ |
69 | | - mkdir -p out/root/etc/$(NAME)/ |
70 | | - ./out/$(NAME)-$(OS)-amd64 -config-print-default > out/root/etc/$(NAME)/$(NAME).conf |
71 | | - |
72 | | -fpm-deb: |
73 | | - $(MAKE) fpm-build-deb ARCH=amd64 |
74 | | - $(MAKE) fpm-build-deb ARCH=arm64 |
75 | | -fpm-rpm: |
76 | | - $(MAKE) fpm-build-rpm ARCH=amd64 |
77 | | - $(MAKE) fpm-build-rpm ARCH=arm64 |
78 | | - |
79 | | -fpm-build-deb: |
80 | | - fpm -s dir -t deb -n $(NAME) -v $(VERSION) \ |
81 | | - --deb-priority optional --category admin \ |
82 | | - --force \ |
83 | | - --url https://github.com/lomik/$(NAME) \ |
84 | | - --description $(DESCRIPTION) \ |
85 | | - -m $(MAINTAINER) \ |
86 | | - --license "MIT" \ |
87 | | - -a $(ARCH) \ |
88 | | - --config-files /etc/$(NAME)/$(NAME).conf \ |
89 | | - --config-files /etc/logrotate.d/$(NAME) \ |
90 | | - out/$(NAME)-linux-$(ARCH)=/usr/bin/$(NAME) \ |
91 | | - deploy/root/=/ \ |
92 | | - out/root/=/ |
93 | | - |
94 | | - |
95 | | -fpm-build-rpm: |
96 | | - fpm -s dir -t rpm -n $(NAME) -v $(VERSION) \ |
97 | | - --force \ |
98 | | - --rpm-compression bzip2 --rpm-os linux \ |
99 | | - --url https://github.com/lomik/$(NAME) \ |
100 | | - --description $(DESCRIPTION) \ |
101 | | - -m $(MAINTAINER) \ |
102 | | - --license "MIT" \ |
103 | | - -a $(ARCH) \ |
104 | | - --config-files /etc/$(NAME)/$(NAME).conf \ |
105 | | - --config-files /etc/logrotate.d/$(NAME) \ |
106 | | - out/$(NAME)-linux-$(ARCH)=/usr/bin/$(NAME) \ |
107 | | - deploy/root/=/ \ |
108 | | - out/root/=/ |
| 69 | + |
| 70 | +out/root/etc/$(NAME)/$(NAME).conf: $(NAME) |
| 71 | + mkdir -p "$(shell dirname $@)" |
| 72 | + ./$(NAME) -config-print-default > $@ |
| 73 | + |
| 74 | +nfpm-deb: gox-build |
| 75 | + $(MAKE) nfpm-build-deb ARCH=amd64 |
| 76 | + $(MAKE) nfpm-build-deb ARCH=arm64 |
| 77 | +nfpm-rpm: gox-build |
| 78 | + $(MAKE) nfpm-build-rpm ARCH=amd64 |
| 79 | + $(MAKE) nfpm-build-rpm ARCH=arm64 |
| 80 | + |
| 81 | +nfpm-build-%: nfpm.yaml |
| 82 | + NAME=$(NAME) DESCRIPTION=$(DESCRIPTION) ARCH=$(ARCH) VERSION_STRING=$(VERSION) nfpm package --packager $* |
109 | 83 |
|
110 | 84 | .ONESHELL: |
111 | 85 | RPM_VERSION:=$(subst -,_,$(VERSION)) |
|
0 commit comments