1# =============================================================================
2# User configuration section.
3#
4# These options control compilation on all systems apart from Windows and Mac
5# OS X. Use CMake to compile on Windows and Mac.
6#
7# Largely, these are options that are designed to make mosquitto run more
8# easily in restrictive environments by removing features.
9#
10# Modify the variable below to enable/disable features.
11#
12# Can also be overriden at the command line, e.g.:
13#
14# make WITH_TLS=no
15# =============================================================================
16
17# Uncomment to compile the broker with tcpd/libwrap support.
18#WITH_WRAP:=yes
19
20# Comment out to disable SSL/TLS support in the broker and client.
21# Disabling this will also mean that passwords must be stored in plain text. It
22# is strongly recommended that you only disable WITH_TLS if you are not using
23# password authentication at all.
24WITH_TLS:=yes
25
26# Comment out to disable TLS/PSK support in the broker and client. Requires
27# WITH_TLS=yes.
28# This must be disabled if using openssl < 1.0.
29WITH_TLS_PSK:=yes
30
31# Comment out to disable client threading support.
32WITH_THREADING:=yes
33
34# Comment out to remove bridge support from the broker. This allow the broker
35# to connect to other brokers and subscribe/publish to topics. You probably
36# want to leave this included unless you want to save a very small amount of
37# memory size and CPU time.
38WITH_BRIDGE:=yes
39
40# Comment out to remove persistent database support from the broker. This
41# allows the broker to store retained messages and durable subscriptions to a
42# file periodically and on shutdown. This is usually desirable (and is
43# suggested by the MQTT spec), but it can be disabled if required.
44WITH_PERSISTENCE:=yes
45
46# Comment out to remove memory tracking support from the broker. If disabled,
47# mosquitto won't track heap memory usage nor export '$SYS/broker/heap/current
48# size', but will use slightly less memory and CPU time.
49WITH_MEMORY_TRACKING:=yes
50
51# Compile with database upgrading support? If disabled, mosquitto won't
52# automatically upgrade old database versions.
53# Not currently supported.
54#WITH_DB_UPGRADE:=yes
55
56# Comment out to remove publishing of the $SYS topic hierarchy containing
57# information about the broker state.
58WITH_SYS_TREE:=yes
59
60# Build with systemd support. If enabled, mosquitto will notify systemd after
61# initialization. See README in service/systemd/ for more information.
62WITH_SYSTEMD:=no
63
64# Build with SRV lookup support.
65WITH_SRV:=no
66
67# Build with websockets support on the broker.
68WITH_WEBSOCKETS:=no
69
70# Use elliptic keys in broker
71WITH_EC:=yes
72
73# Build man page documentation by default.
74WITH_DOCS:=yes
75
76# Build with client support for SOCK5 proxy.
77WITH_SOCKS:=yes
78
79# Strip executables and shared libraries on install.
80WITH_STRIP:=no
81
82# Build static libraries
83WITH_STATIC_LIBRARIES:=no
84
85# Use this variable to add extra library dependencies when building the clients
86# with the static libmosquitto library. This may be required on some systems
87# where e.g. -lz or -latomic are needed for openssl.
88CLIENT_STATIC_LDADD:=
89
90# Build shared libraries
91WITH_SHARED_LIBRARIES:=yes
92
93# Build with async dns lookup support for bridges (temporary). Requires glibc.
94#WITH_ADNS:=yes
95
96# Build with epoll support.
97WITH_EPOLL:=yes
98
99# Build with bundled uthash.h
100WITH_BUNDLED_DEPS:=yes
101
102# Build with coverage options
103WITH_COVERAGE:=no
104
105# =============================================================================
106# End of user configuration
107# =============================================================================
108
109
110# Also bump lib/mosquitto.h, CMakeLists.txt,
111# installer/mosquitto.nsi, installer/mosquitto64.nsi
112VERSION=1.6.9
113
114# Client library SO version. Bump if incompatible API/ABI changes are made.
115SOVERSION=1
116
117# Man page generation requires xsltproc and docbook-xsl
118XSLTPROC=xsltproc --nonet
119# For html generation
120DB_HTML_XSL=man/html.xsl
121
122#MANCOUNTRIES=en_GB
123
124UNAME:=$(shell uname -s)
125
126ifeq ($(UNAME),SunOS)
127	ifeq ($(CC),cc)
128		CFLAGS?=-O
129	else
130		CFLAGS?=-Wall -ggdb -O2
131	endif
132else
133	CFLAGS?=-Wall -ggdb -O2
134endif
135
136STATIC_LIB_DEPS:=
137
138LIB_CPPFLAGS=$(CPPFLAGS) -I. -I.. -I../lib
139ifeq ($(WITH_BUNDLED_DEPS),yes)
140	LIB_CPPFLAGS:=$(LIB_CPPFLAGS) -I../src/deps
141endif
142LIB_CFLAGS:=$(CFLAGS)
143LIB_CXXFLAGS:=$(CXXFLAGS)
144LIB_LDFLAGS:=$(LDFLAGS)
145LIB_LIBADD:=$(LIBADD)
146
147BROKER_CPPFLAGS:=$(LIB_CPPFLAGS)
148BROKER_CFLAGS:=${CFLAGS} -DVERSION="\"${VERSION}\"" -DWITH_BROKER
149BROKER_LDFLAGS:=${LDFLAGS}
150BROKER_LDADD:=
151
152CLIENT_CPPFLAGS:=$(CPPFLAGS) -I.. -I../lib
153CLIENT_CFLAGS:=${CFLAGS} -DVERSION="\"${VERSION}\""
154CLIENT_LDFLAGS:=$(LDFLAGS) -L../lib
155CLIENT_LDADD:=
156
157PASSWD_LDADD:=
158
159ifneq ($(or $(findstring $(UNAME),FreeBSD), $(findstring $(UNAME),OpenBSD), $(findstring $(UNAME),NetBSD)),)
160	BROKER_LDADD:=$(BROKER_LDADD) -lm
161else
162	BROKER_LDADD:=$(BROKER_LDADD) -ldl -lm
163endif
164
165ifeq ($(UNAME),Linux)
166	BROKER_LDADD:=$(BROKER_LDADD) -lrt
167	BROKER_LDFLAGS:=$(BROKER_LDFLAGS) -Wl,--dynamic-list=linker.syms
168	LIB_LIBADD:=$(LIB_LIBADD) -lrt
169endif
170
171ifeq ($(WITH_SHARED_LIBRARIES),yes)
172	CLIENT_LDADD:=${CLIENT_LDADD} ../lib/libmosquitto.so.${SOVERSION}
173endif
174
175ifeq ($(UNAME),SunOS)
176	ifeq ($(CC),cc)
177		LIB_CFLAGS:=$(LIB_CFLAGS) -xc99 -KPIC
178	else
179		LIB_CFLAGS:=$(LIB_CFLAGS) -fPIC
180	endif
181
182	ifeq ($(CXX),CC)
183		LIB_CXXFLAGS:=$(LIB_CXXFLAGS) -KPIC
184	else
185		LIB_CXXFLAGS:=$(LIB_CXXFLAGS) -fPIC
186	endif
187else
188	LIB_CFLAGS:=$(LIB_CFLAGS) -fPIC
189	LIB_CXXFLAGS:=$(LIB_CXXFLAGS) -fPIC
190endif
191
192ifneq ($(UNAME),SunOS)
193	LIB_LDFLAGS:=$(LIB_LDFLAGS) -Wl,--version-script=linker.version -Wl,-soname,libmosquitto.so.$(SOVERSION)
194endif
195
196ifeq ($(UNAME),QNX)
197	BROKER_LDADD:=$(BROKER_LDADD) -lsocket
198	LIB_LIBADD:=$(LIB_LIBADD) -lsocket
199endif
200
201ifeq ($(WITH_WRAP),yes)
202	BROKER_LDADD:=$(BROKER_LDADD) -lwrap
203	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_WRAP
204endif
205
206ifeq ($(WITH_TLS),yes)
207	BROKER_LDADD:=$(BROKER_LDADD) -lssl -lcrypto
208	LIB_LIBADD:=$(LIB_LIBADD) -lssl -lcrypto
209	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_TLS
210	LIB_CPPFLAGS:=$(LIB_CPPFLAGS) -DWITH_TLS
211	PASSWD_LDADD:=$(PASSWD_LDADD) -lcrypto
212	CLIENT_CPPFLAGS:=$(CLIENT_CPPFLAGS) -DWITH_TLS
213	STATIC_LIB_DEPS:=$(STATIC_LIB_DEPS) -lssl -lcrypto
214
215	ifeq ($(WITH_TLS_PSK),yes)
216		BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_TLS_PSK
217		LIB_CPPFLAGS:=$(LIB_CPPFLAGS) -DWITH_TLS_PSK
218		CLIENT_CPPFLAGS:=$(CLIENT_CPPFLAGS) -DWITH_TLS_PSK
219	endif
220endif
221
222ifeq ($(WITH_THREADING),yes)
223	LIB_LIBADD:=$(LIB_LIBADD) -lpthread
224	LIB_CPPFLAGS:=$(LIB_CPPFLAGS) -DWITH_THREADING
225	CLIENT_CPPFLAGS:=$(CLIENT_CPPFLAGS) -DWITH_THREADING
226	STATIC_LIB_DEPS:=$(STATIC_LIB_DEPS) -lpthread
227endif
228
229ifeq ($(WITH_SOCKS),yes)
230	LIB_CPPFLAGS:=$(LIB_CPPFLAGS) -DWITH_SOCKS
231	CLIENT_CPPFLAGS:=$(CLIENT_CPPFLAGS) -DWITH_SOCKS
232endif
233
234ifeq ($(WITH_BRIDGE),yes)
235	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_BRIDGE
236endif
237
238ifeq ($(WITH_PERSISTENCE),yes)
239	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_PERSISTENCE
240endif
241
242ifeq ($(WITH_MEMORY_TRACKING),yes)
243	ifneq ($(UNAME),SunOS)
244		BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_MEMORY_TRACKING
245	endif
246endif
247
248ifeq ($(WITH_SYS_TREE),yes)
249	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_SYS_TREE
250endif
251
252ifeq ($(WITH_SYSTEMD),yes)
253	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_SYSTEMD
254	BROKER_LDADD:=$(BROKER_LDADD) -lsystemd
255endif
256
257ifeq ($(WITH_SRV),yes)
258	LIB_CPPFLAGS:=$(LIB_CPPFLAGS) -DWITH_SRV
259	LIB_LIBADD:=$(LIB_LIBADD) -lcares
260	CLIENT_CPPFLAGS:=$(CLIENT_CPPFLAGS) -DWITH_SRV
261	STATIC_LIB_DEPS:=$(STATIC_LIB_DEPS) -lcares
262endif
263
264ifeq ($(UNAME),SunOS)
265	BROKER_LDADD:=$(BROKER_LDADD) -lsocket -lnsl
266	LIB_LIBADD:=$(LIB_LIBADD) -lsocket -lnsl
267endif
268
269ifeq ($(WITH_EC),yes)
270	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_EC
271endif
272
273ifeq ($(WITH_ADNS),yes)
274	BROKER_LDADD:=$(BROKER_LDADD) -lanl
275	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_ADNS
276endif
277
278MAKE_ALL:=mosquitto
279ifeq ($(WITH_DOCS),yes)
280	MAKE_ALL:=$(MAKE_ALL) docs
281endif
282
283ifeq ($(WITH_WEBSOCKETS),yes)
284	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_WEBSOCKETS
285	BROKER_LDADD:=$(BROKER_LDADD) -lwebsockets
286endif
287
288ifeq ($(WITH_WEBSOCKETS),static)
289	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_WEBSOCKETS
290	BROKER_LDADD:=$(BROKER_LDADD) -static -lwebsockets
291endif
292
293INSTALL?=install
294prefix?=/usr/local
295incdir?=${prefix}/include
296libdir?=${prefix}/lib${LIB_SUFFIX}
297localedir?=${prefix}/share/locale
298mandir?=${prefix}/share/man
299STRIP?=strip
300
301ifeq ($(WITH_STRIP),yes)
302	STRIP_OPTS?=-s --strip-program=${CROSS_COMPILE}${STRIP}
303endif
304
305ifeq ($(WITH_EPOLL),yes)
306	ifeq ($(UNAME),Linux)
307		BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_EPOLL
308	endif
309endif
310
311ifeq ($(WITH_BUNDLED_DEPS),yes)
312	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -Ideps
313endif
314
315ifeq ($(WITH_COVERAGE),yes)
316	BROKER_CFLAGS:=$(BROKER_CFLAGS) -coverage
317	BROKER_LDFLAGS:=$(BROKER_LDFLAGS) -coverage
318	LIB_CFLAGS:=$(LIB_CFLAGS) -coverage
319	LIB_LDFLAGS:=$(LIB_LDFLAGS) -coverage
320	CLIENT_CFLAGS:=$(CLIENT_CFLAGS) -coverage
321	CLIENT_LDFLAGS:=$(CLIENT_LDFLAGS) -coverage
322endif
323
324BROKER_LDADD:=${BROKER_LDADD} ${LDADD}
325CLIENT_LDADD:=${CLIENT_LDADD} ${LDADD}
326PASSWD_LDADD:=${PASSWD_LDADD} ${LDADD}
327