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.
62# Setting to yes means the libsystemd-dev or similar package will need to be
63# installed.
64WITH_SYSTEMD:=no
65
66# Build with SRV lookup support.
67WITH_SRV:=no
68
69# Build with websockets support on the broker.
70WITH_WEBSOCKETS:=no
71
72# Use elliptic keys in broker
73WITH_EC:=yes
74
75# Build man page documentation by default.
76WITH_DOCS:=yes
77
78# Build with client support for SOCK5 proxy.
79WITH_SOCKS:=yes
80
81# Strip executables and shared libraries on install.
82WITH_STRIP:=no
83
84# Build static libraries
85WITH_STATIC_LIBRARIES:=no
86
87# Use this variable to add extra library dependencies when building the clients
88# with the static libmosquitto library. This may be required on some systems
89# where e.g. -lz or -latomic are needed for openssl.
90CLIENT_STATIC_LDADD:=
91
92# Build shared libraries
93WITH_SHARED_LIBRARIES:=yes
94
95# Build with async dns lookup support for bridges (temporary). Requires glibc.
96#WITH_ADNS:=yes
97
98# Build with epoll support.
99WITH_EPOLL:=yes
100
101# Build with bundled uthash.h
102WITH_BUNDLED_DEPS:=yes
103
104# Build with coverage options
105WITH_COVERAGE:=no
106
107# Build with unix domain socket support
108WITH_UNIX_SOCKETS:=yes
109
110# Build mosquitto_sub with cJSON support
111WITH_CJSON:=yes
112
113# Build mosquitto with support for the $CONTROL topics.
114WITH_CONTROL:=yes
115
116# Build the broker with the jemalloc allocator
117WITH_JEMALLOC:=no
118
119# Build with xtreport capability. This is for debugging purposes and is
120# probably of no particular interest to end users.
121WITH_XTREPORT=no
122
123# =============================================================================
124# End of user configuration
125# =============================================================================
126
127
128# Also bump lib/mosquitto.h, CMakeLists.txt,
129# installer/mosquitto.nsi, installer/mosquitto64.nsi
130VERSION=2.0.13
131
132# Client library SO version. Bump if incompatible API/ABI changes are made.
133SOVERSION=1
134
135# Man page generation requires xsltproc and docbook-xsl
136XSLTPROC=xsltproc --nonet
137# For html generation
138DB_HTML_XSL=man/html.xsl
139
140#MANCOUNTRIES=en_GB
141
142UNAME:=$(shell uname -s)
143ARCH:=$(shell uname -p)
144
145ifeq ($(UNAME),SunOS)
146	ifeq ($(CC),cc)
147		CFLAGS?=-O
148	else
149		CFLAGS?=-Wall -ggdb -O2
150	endif
151else
152	CFLAGS?=-Wall -ggdb -O2 -Wconversion -Wextra
153endif
154
155STATIC_LIB_DEPS:=
156
157APP_CPPFLAGS=$(CPPFLAGS) -I. -I../../ -I../../include -I../../src -I../../lib
158APP_CFLAGS=$(CFLAGS) -DVERSION=\""${VERSION}\""
159APP_LDFLAGS:=$(LDFLAGS)
160
161LIB_CPPFLAGS=$(CPPFLAGS) -I. -I.. -I../include -I../../include
162LIB_CFLAGS:=$(CFLAGS)
163LIB_CXXFLAGS:=$(CXXFLAGS)
164LIB_LDFLAGS:=$(LDFLAGS)
165LIB_LIBADD:=$(LIBADD)
166
167BROKER_CPPFLAGS:=$(LIB_CPPFLAGS) -I../lib
168BROKER_CFLAGS:=${CFLAGS} -DVERSION="\"${VERSION}\"" -DWITH_BROKER
169BROKER_LDFLAGS:=${LDFLAGS}
170BROKER_LDADD:=
171
172CLIENT_CPPFLAGS:=$(CPPFLAGS) -I.. -I../include
173CLIENT_CFLAGS:=${CFLAGS} -DVERSION="\"${VERSION}\""
174CLIENT_LDFLAGS:=$(LDFLAGS) -L../lib
175CLIENT_LDADD:=
176
177PASSWD_LDADD:=
178
179PLUGIN_CPPFLAGS:=$(CPPFLAGS) -I../.. -I../../include
180PLUGIN_CFLAGS:=$(CFLAGS) -fPIC
181PLUGIN_LDFLAGS:=$(LDFLAGS)
182
183ifneq ($(or $(findstring $(UNAME),FreeBSD), $(findstring $(UNAME),OpenBSD), $(findstring $(UNAME),NetBSD)),)
184	BROKER_LDADD:=$(BROKER_LDADD) -lm
185	BROKER_LDFLAGS:=$(BROKER_LDFLAGS) -Wl,--dynamic-list=linker.syms
186	SEDINPLACE:=-i ""
187else
188	BROKER_LDADD:=$(BROKER_LDADD) -ldl -lm
189	SEDINPLACE:=-i
190endif
191
192ifeq ($(UNAME),Linux)
193	BROKER_LDADD:=$(BROKER_LDADD) -lrt
194	BROKER_LDFLAGS:=$(BROKER_LDFLAGS) -Wl,--dynamic-list=linker.syms
195	LIB_LIBADD:=$(LIB_LIBADD) -lrt
196endif
197
198ifeq ($(WITH_SHARED_LIBRARIES),yes)
199	CLIENT_LDADD:=${CLIENT_LDADD} ../lib/libmosquitto.so.${SOVERSION}
200endif
201
202ifeq ($(UNAME),SunOS)
203	SEDINPLACE:=
204	ifeq ($(ARCH),sparc)
205		ifeq ($(CC),cc)
206			LIB_CFLAGS:=$(LIB_CFLAGS) -xc99 -KPIC
207		else
208			LIB_CFLAGS:=$(LIB_CFLAGS) -fPIC
209		endif
210	endif
211	ifeq ($(ARCH),i386)
212		LIB_CFLAGS:=$(LIB_CFLAGS) -fPIC
213	endif
214
215	ifeq ($(CXX),CC)
216		LIB_CXXFLAGS:=$(LIB_CXXFLAGS) -KPIC
217	else
218		LIB_CXXFLAGS:=$(LIB_CXXFLAGS) -fPIC
219	endif
220else
221	LIB_CFLAGS:=$(LIB_CFLAGS) -fPIC
222	LIB_CXXFLAGS:=$(LIB_CXXFLAGS) -fPIC
223endif
224
225ifneq ($(UNAME),SunOS)
226	LIB_LDFLAGS:=$(LIB_LDFLAGS) -Wl,--version-script=linker.version -Wl,-soname,libmosquitto.so.$(SOVERSION)
227endif
228
229ifeq ($(UNAME),QNX)
230	BROKER_LDADD:=$(BROKER_LDADD) -lsocket
231	LIB_LIBADD:=$(LIB_LIBADD) -lsocket
232endif
233
234ifeq ($(WITH_WRAP),yes)
235	BROKER_LDADD:=$(BROKER_LDADD) -lwrap
236	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_WRAP
237endif
238
239ifeq ($(WITH_TLS),yes)
240	APP_CPPFLAGS:=$(APP_CPPFLAGS) -DWITH_TLS
241	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_TLS
242	BROKER_LDADD:=$(BROKER_LDADD) -lssl -lcrypto
243	CLIENT_CPPFLAGS:=$(CLIENT_CPPFLAGS) -DWITH_TLS
244	LIB_CPPFLAGS:=$(LIB_CPPFLAGS) -DWITH_TLS
245	LIB_LIBADD:=$(LIB_LIBADD) -lssl -lcrypto
246	PASSWD_LDADD:=$(PASSWD_LDADD) -lcrypto
247	STATIC_LIB_DEPS:=$(STATIC_LIB_DEPS) -lssl -lcrypto
248
249	ifeq ($(WITH_TLS_PSK),yes)
250		BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_TLS_PSK
251		LIB_CPPFLAGS:=$(LIB_CPPFLAGS) -DWITH_TLS_PSK
252		CLIENT_CPPFLAGS:=$(CLIENT_CPPFLAGS) -DWITH_TLS_PSK
253	endif
254endif
255
256ifeq ($(WITH_THREADING),yes)
257	LIB_LIBADD:=$(LIB_LIBADD) -lpthread
258	LIB_CPPFLAGS:=$(LIB_CPPFLAGS) -DWITH_THREADING
259	CLIENT_CPPFLAGS:=$(CLIENT_CPPFLAGS) -DWITH_THREADING
260	STATIC_LIB_DEPS:=$(STATIC_LIB_DEPS) -lpthread
261endif
262
263ifeq ($(WITH_SOCKS),yes)
264	LIB_CPPFLAGS:=$(LIB_CPPFLAGS) -DWITH_SOCKS
265	CLIENT_CPPFLAGS:=$(CLIENT_CPPFLAGS) -DWITH_SOCKS
266endif
267
268ifeq ($(WITH_BRIDGE),yes)
269	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_BRIDGE
270endif
271
272ifeq ($(WITH_PERSISTENCE),yes)
273	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_PERSISTENCE
274endif
275
276ifeq ($(WITH_MEMORY_TRACKING),yes)
277	ifneq ($(UNAME),SunOS)
278		BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_MEMORY_TRACKING
279	endif
280endif
281
282ifeq ($(WITH_SYS_TREE),yes)
283	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_SYS_TREE
284endif
285
286ifeq ($(WITH_SYSTEMD),yes)
287	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_SYSTEMD
288	BROKER_LDADD:=$(BROKER_LDADD) -lsystemd
289endif
290
291ifeq ($(WITH_SRV),yes)
292	LIB_CPPFLAGS:=$(LIB_CPPFLAGS) -DWITH_SRV
293	LIB_LIBADD:=$(LIB_LIBADD) -lcares
294	CLIENT_CPPFLAGS:=$(CLIENT_CPPFLAGS) -DWITH_SRV
295	STATIC_LIB_DEPS:=$(STATIC_LIB_DEPS) -lcares
296endif
297
298ifeq ($(UNAME),SunOS)
299	BROKER_LDADD:=$(BROKER_LDADD) -lsocket -lnsl
300	LIB_LIBADD:=$(LIB_LIBADD) -lsocket -lnsl
301endif
302
303ifeq ($(WITH_EC),yes)
304	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_EC
305endif
306
307ifeq ($(WITH_ADNS),yes)
308	BROKER_LDADD:=$(BROKER_LDADD) -lanl
309	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_ADNS
310endif
311
312ifeq ($(WITH_CONTROL),yes)
313	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_CONTROL
314endif
315
316MAKE_ALL:=mosquitto
317ifeq ($(WITH_DOCS),yes)
318	MAKE_ALL:=$(MAKE_ALL) docs
319endif
320
321ifeq ($(WITH_JEMALLOC),yes)
322	BROKER_LDADD:=$(BROKER_LDADD) -ljemalloc
323endif
324
325ifeq ($(WITH_UNIX_SOCKETS),yes)
326	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_UNIX_SOCKETS
327	LIB_CPPFLAGS:=$(LIB_CPPFLAGS) -DWITH_UNIX_SOCKETS
328	CLIENT_CPPFLAGS:=$(CLIENT_CPPFLAGS) -DWITH_UNIX_SOCKETS
329endif
330
331ifeq ($(WITH_WEBSOCKETS),yes)
332	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_WEBSOCKETS
333	BROKER_LDADD:=$(BROKER_LDADD) -lwebsockets
334endif
335
336ifeq ($(WITH_WEBSOCKETS),static)
337	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_WEBSOCKETS
338	BROKER_LDADD:=$(BROKER_LDADD) -static -lwebsockets
339endif
340
341INSTALL?=install
342prefix?=${PREFIX}
343incdir?=${prefix}/include
344libdir?=${prefix}/lib${LIB_SUFFIX}
345localedir?=${prefix}/share/locale
346mandir?=${prefix}/share/man
347STRIP?=strip
348
349ifeq ($(WITH_STRIP),yes)
350	STRIP_OPTS?=-s --strip-program=${CROSS_COMPILE}${STRIP}
351endif
352
353ifeq ($(WITH_EPOLL),yes)
354	ifeq ($(UNAME),Linux)
355		BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_EPOLL
356	endif
357endif
358
359ifeq ($(WITH_BUNDLED_DEPS),yes)
360	BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -I../deps
361	LIB_CPPFLAGS:=$(LIB_CPPFLAGS) -I../deps
362	PLUGIN_CPPFLAGS:=$(PLUGIN_CPPFLAGS) -I../../deps
363endif
364
365ifeq ($(WITH_COVERAGE),yes)
366	BROKER_CFLAGS:=$(BROKER_CFLAGS) -coverage
367	BROKER_LDFLAGS:=$(BROKER_LDFLAGS) -coverage
368	PLUGIN_CFLAGS:=$(PLUGIN_CFLAGS) -coverage
369	PLUGIN_LDFLAGS:=$(PLUGIN_LDFLAGS) -coverage
370	LIB_CFLAGS:=$(LIB_CFLAGS) -coverage
371	LIB_LDFLAGS:=$(LIB_LDFLAGS) -coverage
372	CLIENT_CFLAGS:=$(CLIENT_CFLAGS) -coverage
373	CLIENT_LDFLAGS:=$(CLIENT_LDFLAGS) -coverage
374endif
375
376ifeq ($(WITH_CJSON),yes)
377	CLIENT_CFLAGS:=$(CLIENT_CFLAGS) -DWITH_CJSON
378	CLIENT_LDADD:=$(CLIENT_LDADD) -lcjson
379	CLIENT_STATIC_LDADD:=$(CLIENT_STATIC_LDADD) -lcjson
380	CLIENT_LDFLAGS:=$(CLIENT_LDFLAGS)
381endif
382
383ifeq ($(WITH_XTREPORT),yes)
384	BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_XTREPORT
385endif
386
387BROKER_LDADD:=${BROKER_LDADD} ${LDADD}
388CLIENT_LDADD:=${CLIENT_LDADD} ${LDADD}
389PASSWD_LDADD:=${PASSWD_LDADD} ${LDADD}
390