forked from cloudamqp/lavinmq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
116 lines (88 loc) · 3.99 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
108
109
110
111
112
113
114
115
116
BINS := bin/lavinmq bin/lavinmqctl bin/lavinmqperf
SOURCES := $(shell find src/lavinmq src/stdlib -name '*.cr' 2> /dev/null)
JS := static/js/lib/chunks/helpers.segment.js static/js/lib/chart.js static/js/lib/amqp-websocket-client.mjs static/js/lib/amqp-websocket-client.mjs.map static/js/lib/luxon.js static/js/lib/chartjs-adapter-luxon.esm.js
DOCS := static/docs/index.html
CRYSTAL_FLAGS := --release
override CRYSTAL_FLAGS += --error-on-warnings --link-flags=-pie
.PHONY: all
all: $(BINS)
bin/%: src/%.cr $(SOURCES) lib $(JS) $(DOCS) | bin
crystal build $< -o $@ $(CRYSTAL_FLAGS)
bin/%-debug: src/%.cr $(SOURCES) lib $(JS) $(DOCS) | bin
crystal build $< -o $@ --debug $(CRYSTAL_FLAGS)
bin/lavinmqperf: src/lavinmqperf.cr lib | bin
crystal build $< -o $@ -Dpreview_mt $(CRYSTAL_FLAGS)
bin/lavinmqctl: src/lavinmqctl.cr lib | bin
crystal build $< -o $@ $(CRYSTAL_FLAGS)
lib: shard.yml shard.lock
shards install --production $(if $(nocolor),--no-color)
bin static/js/lib man1 static/js/lib/chunks:
mkdir -p $@
static/js/lib/%: | static/js/lib
curl --retry 5 -sLo $@ https://github.com/cloudamqp/amqp-client.js/releases/download/v2.1.0/$(@F)
static/js/lib/chart.js: | static/js/lib
curl --retry 5 -sL https://github.com/chartjs/Chart.js/releases/download/v4.0.1/chart.js-4.0.1.tgz | \
tar -zxOf- package/dist/chart.js > $@
static/js/lib/chunks/helpers.segment.js: | static/js/lib/chunks
curl --retry 5 -sL https://github.com/chartjs/Chart.js/releases/download/v4.0.1/chart.js-4.0.1.tgz | \
tar -zxOf- package/dist/chunks/helpers.segment.js > $@
static/js/lib/luxon.js: | static/js/lib
curl --retry 5 -sLo $@ https://moment.github.io/luxon/es6/luxon.js
static/js/lib/chartjs-adapter-luxon.esm.js: | static/js/lib
curl --retry 5 -sLo $@ https://cdn.jsdelivr.net/npm/chartjs-adapter-luxon@1.3.0/dist/chartjs-adapter-luxon.esm.js
sed -i'' -e "s|\(import { _adapters } from\).*|\1 './chart.js'|; s|\(import { DateTime } from\).*|\1 './luxon.js'|" $@
static/docs/index.html: openapi/openapi.yaml openapi/.spectral.json $(wildcard openapi/paths/*.yaml) $(wildcard openapi/schemas/*.yaml)
npx --package=@stoplight/spectral-cli spectral --ruleset openapi/.spectral.json lint $<
npx @redocly/cli build-docs --output $@ $<
man1/lavinmq.1: bin/lavinmq | man1
help2man -Nn "fast and advanced message queue server" $< -o $@
man1/lavinmqctl.1: bin/lavinmqctl | man1
help2man -Nn "control utility for lavinmq server" $< -o $@
man1/lavinmqperf.1: bin/lavinmqperf | man1
help2man -Nn "performance testing tool for amqp servers" $< -o $@
MANPAGES := man1/lavinmq.1 man1/lavinmqctl.1 man1/lavinmqperf.1
.PHONY: man
man: $(MANPAGES)
.PHONY: docs
docs: $(DOCS)
.PHONY: js
js: $(JS)
.PHONY: deps
deps: js lib docs
.PHONY: lint
lint: lib
lib/ameba/bin/ameba src/
.PHONY: test
test: lib
crystal spec --order random $(if $(nocolor),--no-color)
.PHONY: format
format:
crystal tool format --check
DESTDIR :=
PREFIX := /usr
BINDIR := $(PREFIX)/bin
DOCDIR := $(PREFIX)/share/doc
MANDIR := $(PREFIX)/share/man
SYSCONFDIR := /etc
UNITDIR := /lib/systemd/system
SHAREDSTATEDIR := /var/lib
.PHONY: install
install: $(BINS) $(MANPAGES) extras/config.ini extras/lavinmq.service README.md CHANGELOG.md NOTICE
install -D -m 0755 -t $(DESTDIR)$(BINDIR) $(BINS)
install -D -m 0644 -t $(DESTDIR)$(MANDIR)/man1 $(MANPAGES)
install -D -m 0644 extras/config.ini $(DESTDIR)$(SYSCONFDIR)/lavinmq/lavinmq.ini
install -D -m 0644 extras/lavinmq.service $(DESTDIR)$(UNITDIR)/lavinmq.service
install -D -m 0644 -t $(DESTDIR)$(DOCDIR)/lavinmq README.md NOTICE
install -D -m 0644 CHANGELOG.md $(DESTDIR)$(DOCDIR)/lavinmq/changelog
install -d -m 0755 $(DESTDIR)$(SHAREDSTATEDIR)/lavinmq
.PHONY: uninstall
uninstall:
$(RM) $(DESTDIR)$(BINDIR)/lavinmq{,ctl,perf}
$(RM) $(DESTDIR)$(MANDIR)/man1/lavinmq{,ctl,perf}.1
$(RM) $(DESTDIR)$(SYSCONFDIR)/lavinmq/lavinmq.ini
$(RM) $(DESTDIR)$(UNITDIR)/lavinmq.service
$(RM) $(DESTDIR)$(DOCDIR)/{lavinmq,README.md,CHANGELOG.md,NOTICE}
$(RM) $(DESTDIR)$(SHAREDSTATEDIR)/lavinmq
.PHONY: clean
clean:
$(RM) $(BINS) $(DOCS) $(JS) $(MANPAGES)