forked from vernemq/vernemq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
151 lines (133 loc) · 4.68 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
BASE_DIR = $(shell pwd)
ERLANG_BIN = $(shell dirname $(shell which erl))
GIT_VERSION = $(shell git describe --tags)
NOW = $(shell date +%s)
OS = $(shell uname -s)
OVERLAY_VARS ?=
REBAR ?= $(BASE_DIR)/rebar3
$(if $(ERLANG_BIN),,$(warning "Warning: No Erlang found in your path, this will probably not work"))
all: compile
compile:
$(REBAR) $(PROFILE) compile
rpi32: PROFILE = as rpi32
rpi32: rel
##
## Release targets
##
rel:
cat vars.config > vars.generated
echo "{app_version, \"${GIT_VERSION}\"}." >> vars.generated
ifeq ($(OVERLAY_VARS),)
else
cat $(OVERLAY_VARS) >> vars.generated
endif
$(REBAR) $(PROFILE) release
##
## Support RPM and Debian based linux systems
##
ifeq ($(OS),Linux)
ARCH = $(shell uname -m)
ISRPM = $(shell cat /etc/redhat-release 2> /dev/null)
ISDEB = $(shell cat /etc/debian_version 2> /dev/null)
ISSLES = $(shell cat /etc/SuSE-release 2> /dev/null)
ifneq ($(ISRPM),)
PKGTARGET = rpm
else
ifneq ($(ISDEB),)
PKGTARGET = deb
else
ifneq ($(ISSLES),)
PKGTARGET = rpm
endif # SLES
endif # deb
endif # rpm
endif # linux
package: $(PKGTARGET)
pkg_rel: pkg_clean
$(MAKE) rel
pkg_strip:
$(shell find _build/default/rel/vernemq -type f -executable | xargs strip --remove-section=.comment --remove-section=.note --strip-unneeded)
deb_prep:
# required for running dpkg-shlibdeps
mkdir -p debian
touch debian/control
deb: OVERLAY_VARS=vars/deb_vars.config
deb: ERLVSN=$(shell erl -eval 'erlang:display(erlang:system_info(version)), halt().' -noshell)
deb: DEPENDS=$(shell find _build/default/rel/vernemq -type f -name "*.so" | xargs dpkg-shlibdeps -O | cut -c16- | sed "s/,/\" --depends \"/g")
deb: deb_prep pkg_rel pkg_strip
fpm -s dir -t deb -v "$(GIT_VERSION)" \
--force \
--name vernemq \
--epoch $(NOW) \
--license "Apache 2.0" \
--url "https://vernemq.com" \
--vendor "Octavo Labs AG" \
--maintainer "<[email protected]>" \
--description "A distributed MQTT message broker based on Erlang/OTP" \
--depends logrotate \
--depends sudo \
--depends adduser \
--depends "$(DEPENDS)" \
--deb-user vernemq \
--deb-group vernemq \
--deb-changelog ./changelog.md \
--deb-no-default-config-files \
--deb-systemd files/vernemq.service \
--after-install files/deb-vernemq.postinst \
--config-files /etc/vernemq/vernemq.conf \
_build/default/rel/vernemq/bin/vernemq=/usr/bin/vernemq \
_build/default/rel/vernemq/bin/vmq-admin=/usr/bin/vmq-admin \
_build/default/rel/vernemq/bin/vmq-passwd=/usr/bin/vmq-passwd \
_build/default/rel/vernemq/data=/var/lib/vernemq/ \
_build/default/rel/vernemq/etc/=/etc/vernemq/ \
_build/default/rel/vernemq/bin/=/usr/lib/vernemq/bin/ \
_build/default/rel/vernemq/lib=/usr/lib/vernemq/ \
_build/default/rel/vernemq/releases=/usr/lib/vernemq/ \
_build/default/rel/vernemq/erts-$(ERLVSN)=/usr/lib/vernemq/ \
_build/default/rel/vernemq/share/=/usr/share/vernemq/ \
_build/default/rel/vernemq/log/=/var/log/vernemq/
rpm: OVERLAY_VARS=vars/rpm_vars.config
rpm: ERLVSN=$(shell erl -eval 'erlang:display(erlang:system_info(version)), halt().' -noshell)
rpm: pkg_rel pkg_strip
fpm -s dir -t rpm -v "$(GIT_VERSION)" \
--force \
--name vernemq \
--epoch $(NOW) \
--license "Apache 2.0" \
--url "https://vernemq.com" \
--vendor "Octavo Labs AG" \
--maintainer "<[email protected]>" \
--description "A distributed MQTT message broker based on Erlang/OTP" \
--depends logrotate \
--depends sudo \
--rpm-user vernemq \
--rpm-group vernemq \
--rpm-autoreqprov \
--rpm-compression xz \
--before-install files/rpm-vernemq.preinst \
--after-install files/rpm-vernemq.postinst \
--config-files /etc/vernemq/vernemq.conf \
files/vernemq-centos.service=/etc/systemd/system/vernemq.service \
_build/default/rel/vernemq/bin/vernemq=/usr/sbin/vernemq \
_build/default/rel/vernemq/bin/vmq-admin=/usr/sbin/vmq-admin \
_build/default/rel/vernemq/bin/vmq-passwd=/usr/sbin/vmq-passwd \
_build/default/rel/vernemq/data=/var/lib/vernemq/ \
_build/default/rel/vernemq/etc/=/etc/vernemq/ \
_build/default/rel/vernemq/bin/=/usr/lib64/vernemq/bin/ \
_build/default/rel/vernemq/lib=/usr/lib64/vernemq/ \
_build/default/rel/vernemq/releases=/usr/lib64/vernemq/ \
_build/default/rel/vernemq/erts-$(ERLVSN)=/usr/lib64/vernemq/ \
_build/default/rel/vernemq/share/=/usr/share/vernemq/ \
_build/default/rel/vernemq/log/=/var/log/vernemq/
pkg_clean:
rm -rf _build/default/rel
##
## Developer targets
##
## devN - Make a dev build for node N
dev% :
./gen_dev $@ vars/dev_vars.config.src vars/$@_vars.config
cat vars/$@_vars.config > vars.generated
(./rebar3 as $@ release)
.PHONY: all compile rpi32 pkg_rel pkg_clean deb rpm rel
export OVERLAY_VARS