config.mk 11 KB

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