configure.ac 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400
  1. #
  2. # Copyright (C) 2015 Alon Bar-Lev <alon.barlev@gmail.com>
  3. # SPDX-License-Identifier: GPL-3.0-or-later
  4. #
  5. AC_PREREQ(2.60)
  6. # We do not use m4_esyscmd_s to support older autoconf.
  7. define([VERSION_STRING], m4_esyscmd([git describe 2>/dev/null | tr -d '\n']))
  8. define([VERSION_FROM_FILE], m4_esyscmd([cat packaging/version | tr -d '\n']))
  9. m4_ifval(VERSION_STRING, [], [define([VERSION_STRING], VERSION_FROM_FILE)])
  10. AC_INIT([netdata], VERSION_STRING[])
  11. AM_MAINTAINER_MODE([disable])
  12. if test x"$USE_MAINTAINER_MODE" = xyes; then
  13. AC_MSG_NOTICE(***************** MAINTAINER MODE *****************)
  14. fi
  15. PACKAGE_RPM_VERSION="VERSION_STRING"
  16. AC_SUBST([PACKAGE_RPM_VERSION])
  17. # -----------------------------------------------------------------------------
  18. # autoconf initialization
  19. AC_CONFIG_AUX_DIR([.])
  20. AC_CONFIG_HEADERS([config.h])
  21. AC_CONFIG_MACRO_DIR([build/m4])
  22. AC_CONFIG_SRCDIR([daemon/main.c])
  23. define([AUTOMATE_INIT_OPTIONS], [tar-pax subdir-objects])
  24. m4_ifdef([AM_SILENT_RULES], [
  25. define([AUTOMATE_INIT_OPTIONS], [tar-pax silent-rules subdir-objects])
  26. ])
  27. AM_INIT_AUTOMAKE(AUTOMATE_INIT_OPTIONS)
  28. m4_ifdef([AM_SILENT_RULES], [
  29. AM_SILENT_RULES([yes])
  30. ])
  31. AC_CANONICAL_HOST
  32. AC_PROG_CC
  33. AC_PROG_CC_C99
  34. AM_PROG_CC_C_O
  35. AC_PROG_CXX
  36. AC_PROG_INSTALL
  37. PKG_PROG_PKG_CONFIG
  38. AC_USE_SYSTEM_EXTENSIONS
  39. # -----------------------------------------------------------------------------
  40. # configurable options
  41. AC_ARG_ENABLE(
  42. [plugin-nfacct],
  43. [AS_HELP_STRING([--enable-plugin-nfacct], [enable nfacct plugin @<:@default autodetect@:>@])],
  44. ,
  45. [enable_plugin_nfacct="detect"]
  46. )
  47. AC_ARG_ENABLE(
  48. [plugin-freeipmi],
  49. [AS_HELP_STRING([--enable-plugin-freeipmi], [enable freeipmi plugin @<:@default autodetect@:>@])],
  50. ,
  51. [enable_plugin_freeipmi="detect"]
  52. )
  53. AC_ARG_ENABLE(
  54. [plugin-cups],
  55. [AS_HELP_STRING([--enable-plugin-cups], [enable cups plugin @<:@default autodetect@:>@])],
  56. ,
  57. [enable_plugin_cups="detect"]
  58. )
  59. AC_ARG_ENABLE(
  60. [plugin-xenstat],
  61. [AS_HELP_STRING([--enable-plugin-xenstat], [enable xenstat plugin @<:@default autodetect@:>@])],
  62. ,
  63. [enable_plugin_xenstat="detect"]
  64. )
  65. AC_ARG_ENABLE(
  66. [backend-kinesis],
  67. [AS_HELP_STRING([--enable-backend-kinesis], [enable kinesis backend @<:@default autodetect@:>@])],
  68. ,
  69. [enable_backend_kinesis="detect"]
  70. )
  71. AC_ARG_ENABLE(
  72. [backend-prometheus-remote-write],
  73. [AS_HELP_STRING([--enable-backend-prometheus-remote-write], [enable prometheus remote write backend @<:@default autodetect@:>@])],
  74. ,
  75. [enable_backend_prometheus_remote_write="detect"]
  76. )
  77. AC_ARG_ENABLE(
  78. [backend-mongodb],
  79. [AS_HELP_STRING([--enable-backend-mongodb], [enable mongodb backend @<:@default autodetect@:>@])],
  80. ,
  81. [enable_backend_mongodb="detect"]
  82. )
  83. AC_ARG_ENABLE(
  84. [pedantic],
  85. [AS_HELP_STRING([--enable-pedantic], [enable pedantic compiler warnings @<:@default disabled@:>@])],
  86. ,
  87. [enable_pedantic="no"]
  88. )
  89. AC_ARG_ENABLE(
  90. [accept4],
  91. [AS_HELP_STRING([--disable-accept4], [System does not have accept4 @<:@default autodetect@:>@])],
  92. ,
  93. [enable_accept4="detect"]
  94. )
  95. AC_ARG_WITH(
  96. [webdir],
  97. [AS_HELP_STRING([--with-webdir], [location of webdir @<:@PKGDATADIR/web@:>@])],
  98. [webdir="${withval}"],
  99. [webdir="\$(pkgdatadir)/web"]
  100. )
  101. AC_ARG_WITH(
  102. [libcap],
  103. [AS_HELP_STRING([--with-libcap], [build with libcap @<:@default autodetect@:>@])],
  104. ,
  105. [with_libcap="detect"]
  106. )
  107. AC_ARG_WITH(
  108. [zlib],
  109. [AS_HELP_STRING([--without-zlib], [build without zlib @<:@default enabled@:>@])],
  110. ,
  111. [with_zlib="yes"]
  112. )
  113. AC_ARG_WITH(
  114. [math],
  115. [AS_HELP_STRING([--without-math], [build without math @<:@default enabled@:>@])],
  116. ,
  117. [with_math="yes"]
  118. )
  119. AC_ARG_WITH(
  120. [user],
  121. [AS_HELP_STRING([--with-user], [use this user to drop privilege @<:@default nobody@:>@])],
  122. ,
  123. [with_user="nobody"]
  124. )
  125. AC_ARG_ENABLE(
  126. [x86-sse],
  127. [AS_HELP_STRING([--disable-x86-sse], [SSE/SS2 optimizations on x86 @<:@default enabled@:>@])],
  128. ,
  129. [enable_x86_sse="yes"]
  130. )
  131. AC_ARG_ENABLE(
  132. [lto],
  133. [AS_HELP_STRING([--disable-lto], [Link Time Optimizations @<:@default autodetect@:>@])],
  134. ,
  135. [enable_lto="detect"]
  136. )
  137. AC_ARG_ENABLE(
  138. [https],
  139. [AS_HELP_STRING([--enable-https], [Enable SSL support @<:@default autodetect@:>@])],
  140. ,
  141. [enable_https="detect"]
  142. )
  143. AC_ARG_ENABLE(
  144. [dbengine],
  145. [AS_HELP_STRING([--disable-dbengine], [disable netdata dbengine @<:@default autodetect@:>@])],
  146. ,
  147. [enable_dbengine="detect"]
  148. )
  149. AC_ARG_ENABLE(
  150. [jsonc],
  151. [AS_HELP_STRING([--enable-jsonc], [Enable JSON-C support @<:@default autodetect@:>@])],
  152. ,
  153. [enable_jsonc="detect"]
  154. )
  155. # -----------------------------------------------------------------------------
  156. # Check if cloud is enabled and if the functionality is available
  157. AC_ARG_ENABLE(
  158. [cloud],
  159. [AS_HELP_STRING([--disable-cloud],
  160. [Disables all cloud functionality])],
  161. [ enable_cloud="$enableval" ],
  162. [ enable_cloud="detect" ]
  163. )
  164. aclk_required="${enable_cloud}"
  165. if test "${enable_cloud}" = "no"; then
  166. AC_DEFINE([DISABLE_CLOUD], [1], [disable netdata cloud functionality])
  167. fi
  168. # -----------------------------------------------------------------------------
  169. # netdata required checks
  170. # fails on centos6
  171. #AX_CHECK_ENABLE_DEBUG()
  172. AX_GCC_FUNC_ATTRIBUTE([returns_nonnull])
  173. AX_GCC_FUNC_ATTRIBUTE([malloc])
  174. AX_GCC_FUNC_ATTRIBUTE([noreturn])
  175. AX_GCC_FUNC_ATTRIBUTE([noinline])
  176. AX_GCC_FUNC_ATTRIBUTE([format])
  177. AX_GCC_FUNC_ATTRIBUTE([warn_unused_result])
  178. AC_CHECK_TYPES([struct timespec, clockid_t], [], [], [[#include <time.h>]])
  179. AC_SEARCH_LIBS([clock_gettime], [rt posix4])
  180. AC_CHECK_FUNCS([clock_gettime])
  181. AC_CHECK_FUNCS([sched_setscheduler sched_getscheduler sched_getparam sched_get_priority_min sched_get_priority_max getpriority setpriority nice])
  182. AC_CHECK_FUNCS([recvmmsg])
  183. AC_TYPE_INT8_T
  184. AC_TYPE_INT16_T
  185. AC_TYPE_INT32_T
  186. AC_TYPE_INT64_T
  187. AC_TYPE_UINT8_T
  188. AC_TYPE_UINT16_T
  189. AC_TYPE_UINT32_T
  190. AC_TYPE_UINT64_T
  191. AC_C_INLINE
  192. AC_FUNC_STRERROR_R
  193. AC_C__GENERIC
  194. AC_C___ATOMIC
  195. # AC_C_STMT_EXPR
  196. AC_CHECK_SIZEOF([void *])
  197. AC_CANONICAL_HOST
  198. AC_HEADER_MAJOR
  199. AC_HEADER_RESOLV
  200. AC_CHECK_HEADERS_ONCE([sys/prctl.h])
  201. AC_CHECK_HEADERS_ONCE([sys/vfs.h])
  202. AC_CHECK_HEADERS_ONCE([sys/statfs.h])
  203. AC_CHECK_HEADERS_ONCE([sys/statvfs.h])
  204. AC_CHECK_HEADERS_ONCE([sys/mount.h])
  205. if test "${enable_accept4}" != "no"; then
  206. AC_CHECK_FUNCS_ONCE(accept4)
  207. fi
  208. # -----------------------------------------------------------------------------
  209. # operating system detection
  210. AC_MSG_CHECKING([operating system])
  211. case "$host_os" in
  212. freebsd*)
  213. build_target=freebsd
  214. build_target_id=2
  215. CFLAGS="${CFLAGS} -I/usr/local/include -L/usr/local/lib"
  216. ;;
  217. darwin*)
  218. build_target=macos
  219. build_target_id=3
  220. LDFLAGS="${LDFLAGS} -framework CoreFoundation -framework IOKit"
  221. ;;
  222. *)
  223. build_target=linux
  224. build_target_id=1
  225. ;;
  226. esac
  227. AM_CONDITIONAL([FREEBSD], [test "${build_target}" = "freebsd"])
  228. AM_CONDITIONAL([MACOS], [test "${build_target}" = "macos"])
  229. AM_CONDITIONAL([LINUX], [test "${build_target}" = "linux"])
  230. AC_MSG_RESULT([${build_target} with id ${build_target_id}])
  231. # -----------------------------------------------------------------------------
  232. # pthreads
  233. ACX_PTHREAD(, [AC_MSG_ERROR([Cannot initialize pthread environment])])
  234. LIBS="${PTHREAD_LIBS} ${LIBS}"
  235. CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}"
  236. CC="${PTHREAD_CC}"
  237. # -----------------------------------------------------------------------------
  238. # libm
  239. AC_ARG_VAR([MATH_CFLAGS], [C compiler flags for math])
  240. AC_ARG_VAR([MATH_LIBS], [linker flags for math])
  241. if test -z "${MATH_LIBS}"; then
  242. AC_CHECK_LIB(
  243. [m],
  244. [sin],
  245. [MATH_LIBS="-lm"]
  246. )
  247. fi
  248. test "${with_math}" = "yes" -a -z "${MATH_LIBS}" && AC_MSG_ERROR([math required but not found])
  249. AC_MSG_CHECKING([if libm should be used])
  250. if test "${with_math}" != "no" -a ! -z "${MATH_LIBS}"; then
  251. with_math="yes"
  252. AC_DEFINE([STORAGE_WITH_MATH], [1], [math usability])
  253. OPTIONAL_MATH_CFLAGS="${MATH_CFLAGS}"
  254. OPTIONAL_MATH_LIBS="${MATH_LIBS}"
  255. else
  256. with_math="no"
  257. fi
  258. AC_MSG_RESULT([${with_math}])
  259. # -----------------------------------------------------------------------------
  260. # libuv multi-platform support library with a focus on asynchronous I/O
  261. # TODO: check version, uv_fs_scandir_next only available in version >= 1.0
  262. AC_CHECK_LIB(
  263. [uv],
  264. [uv_fs_scandir_next],
  265. [UV_LIBS="-luv"]
  266. )
  267. test -z "${UV_LIBS}" && \
  268. AC_MSG_ERROR([libuv required but not found. Try installing 'libuv1-dev' or 'libuv-devel'.])
  269. OPTIONAL_UV_CFLAGS="${UV_CFLAGS}"
  270. OPTIONAL_UV_LIBS="${UV_LIBS}"
  271. # -----------------------------------------------------------------------------
  272. # lz4 Extremely Fast Compression algorithm
  273. AC_CHECK_LIB(
  274. [lz4],
  275. [LZ4_compress_default],
  276. [LZ4_LIBS="-llz4"]
  277. )
  278. # -----------------------------------------------------------------------------
  279. # Judy General purpose dynamic array
  280. AC_CHECK_LIB(
  281. [Judy],
  282. [JudyLIns],
  283. [JUDY_LIBS="-lJudy"]
  284. )
  285. # -----------------------------------------------------------------------------
  286. # zlib
  287. PKG_CHECK_MODULES(
  288. [ZLIB],
  289. [zlib],
  290. [have_zlib=yes],
  291. [have_zlib=no]
  292. )
  293. test "${with_zlib}" = "yes" -a "${have_zlib}" != "yes" && AC_MSG_ERROR([zlib required but not found. Try installing 'zlib1g-dev' or 'zlib-devel'.])
  294. AC_MSG_CHECKING([if zlib should be used])
  295. if test "${with_zlib}" != "no" -a "${have_zlib}" = "yes"; then
  296. with_zlib="yes"
  297. AC_DEFINE([NETDATA_WITH_ZLIB], [1], [zlib usability])
  298. OPTIONAL_ZLIB_CFLAGS="${ZLIB_CFLAGS}"
  299. OPTIONAL_ZLIB_LIBS="${ZLIB_LIBS}"
  300. else
  301. with_zlib="no"
  302. fi
  303. AC_MSG_RESULT([${with_zlib}])
  304. # -----------------------------------------------------------------------------
  305. # libuuid
  306. PKG_CHECK_MODULES(
  307. [UUID],
  308. [uuid],
  309. [have_uuid=yes],
  310. [AC_MSG_ERROR([libuuid required but not found. Try installing 'uuid-dev' or 'libuuid-devel'.])]
  311. )
  312. AC_DEFINE([NETDATA_WITH_UUID], [1], [uuid usability])
  313. OPTIONAL_UUID_CFLAGS="${UUID_CFLAGS}"
  314. OPTIONAL_UUID_LIBS="${UUID_LIBS}"
  315. # -----------------------------------------------------------------------------
  316. # OpenSSL Cryptography and SSL/TLS Toolkit
  317. AC_CHECK_LIB(
  318. [crypto],
  319. [SHA256_Init],
  320. [SSL_LIBS="-lcrypto -lssl"]
  321. )
  322. # -----------------------------------------------------------------------------
  323. # JSON-C library
  324. PKG_CHECK_MODULES([JSON],[json-c],AC_CHECK_LIB(
  325. [json-c],
  326. [json_object_get_type],
  327. [JSONC_LIBS="-ljson-c"]),AC_CHECK_LIB(
  328. [json],
  329. [json_object_get_type],
  330. [JSONC_LIBS="-ljson"])
  331. )
  332. OPTIONAL_JSONC_LIBS="${JSONC_LIBS}"
  333. # -----------------------------------------------------------------------------
  334. # VFS plugin libs
  335. AC_CHECK_LIB(
  336. [dl],
  337. [dlopen],
  338. [EBPF_LIBS="-ldl"]
  339. )
  340. OPTIONAL_EBPF_LIBS="${EBPF_LIBS}"
  341. # -----------------------------------------------------------------------------
  342. # DB engine and HTTPS
  343. test "${enable_dbengine}" = "yes" -a -z "${LZ4_LIBS}" && \
  344. AC_MSG_ERROR([liblz4 required but not found. Try installing 'liblz4-dev' or 'lz4-devel'.])
  345. test "${enable_dbengine}" = "yes" -a -z "${JUDY_LIBS}" && \
  346. AC_MSG_ERROR([libJudy required but not found. Try installing 'libjudy-dev' or 'Judy-devel'.])
  347. test "${enable_https}" = "yes" -a -z "${SSL_LIBS}" && \
  348. AC_MSG_ERROR([OpenSSL required for HTTPS but not found. Try installing 'libssl-dev' or 'openssl-devel'.])
  349. test "${enable_dbengine}" = "yes" -a -z "${SSL_LIBS}" && \
  350. AC_MSG_ERROR([OpenSSL required for DBENGINE but not found. Try installing 'libssl-dev' or 'openssl-devel'.])
  351. AC_MSG_CHECKING([if netdata dbengine should be used])
  352. if test "${enable_dbengine}" != "no" -a "${UV_LIBS}" -a "${LZ4_LIBS}" -a "${JUDY_LIBS}" -a "${SSL_LIBS}"; then
  353. enable_dbengine="yes"
  354. AC_DEFINE([ENABLE_DBENGINE], [1], [netdata dbengine usability])
  355. OPTIONAL_LZ4_CFLAGS="${LZ4_CFLAGS}"
  356. OPTIONAL_LZ4_LIBS="${LZ4_LIBS}"
  357. OPTIONAL_JUDY_CFLAGS="${JUDY_CFLAGS}"
  358. OPTIONAL_JUDY_LIBS="${JUDY_LIBS}"
  359. OPTIONAL_SSL_CFLAGS="${SSL_CFLAGS}"
  360. OPTIONAL_SSL_LIBS="${SSL_LIBS}"
  361. else
  362. enable_dbengine="no"
  363. fi
  364. AC_MSG_RESULT([${enable_dbengine}])
  365. AM_CONDITIONAL([ENABLE_DBENGINE], [test "${enable_dbengine}" = "yes"])
  366. AC_MSG_CHECKING([if netdata https should be used])
  367. if test "${enable_https}" != "no" -a "${SSL_LIBS}"; then
  368. enable_https="yes"
  369. AC_DEFINE([ENABLE_HTTPS], [1], [netdata HTTPS usability])
  370. OPTIONAL_SSL_CFLAGS="${SSL_CFLAGS}"
  371. OPTIONAL_SSL_LIBS="${SSL_LIBS}"
  372. else
  373. enable_https="no"
  374. fi
  375. AC_MSG_RESULT([${enable_https}])
  376. AM_CONDITIONAL([ENABLE_HTTPS], [test "${enable_https}" = "yes"])
  377. # -----------------------------------------------------------------------------
  378. # JSON-C
  379. test "${enable_jsonc}" = "yes" -a -z "${JSONC_LIBS}" && \
  380. AC_MSG_ERROR([JSON-C required but not found. Try installing 'libjson-c-dev' or 'json-c'.])
  381. AC_MSG_CHECKING([if json-c should be used])
  382. if test "${enable_jsonc}" != "no" -a "${JSONC_LIBS}"; then
  383. enable_jsonc="yes"
  384. AC_DEFINE([ENABLE_JSONC], [1], [netdata json-c usability])
  385. else
  386. enable_jsonc="no"
  387. fi
  388. AC_MSG_RESULT([${enable_jsonc}])
  389. AM_CONDITIONAL([ENABLE_JSONC], [test "${enable_jsonc}" = "yes"])
  390. # -----------------------------------------------------------------------------
  391. # compiler options
  392. AC_ARG_VAR([SSE_CANDIDATE], [C compiler flags for SSE])
  393. AS_CASE([$host_cpu],
  394. [i?86], [SSE_CANDIDATE="yes"]
  395. )
  396. AC_SUBST([SSE_CANDIDATE])
  397. if test "${SSE_CANDIDATE}" = "yes" -a "${enable_x86_sse}" = "yes"; then
  398. opt="-msse2 -mfpmath=sse"
  399. AX_CHECK_COMPILE_FLAG(${opt}, [CFLAGS="${CFLAGS} ${opt}"], [])
  400. fi
  401. if test "${GCC}" = "yes"; then
  402. AC_DEFINE_UNQUOTED([likely(x)], [__builtin_expect(!!(x), 1)], [gcc branch optimization])
  403. AC_DEFINE_UNQUOTED([unlikely(x)], [__builtin_expect(!!(x), 0)], [gcc branch optimization])
  404. else
  405. AC_DEFINE_UNQUOTED([likely(x)], [(x)], [gcc branch optimization])
  406. AC_DEFINE_UNQUOTED([unlikely(x)], [(x)], [gcc branch optimization])
  407. fi
  408. if test "${GCC}" = "yes"; then
  409. AC_DEFINE([__always_unused], [__attribute__((unused))], [gcc unused attribute])
  410. AC_DEFINE([__maybe_unused], [__attribute__((unused))], [gcc unused attribute])
  411. else
  412. AC_DEFINE([__always_unused], [], [dummy unused attribute])
  413. AC_DEFINE([__maybe_unused], [], [dummy unused attribute])
  414. fi
  415. if test "${enable_pedantic}" = "yes"; then
  416. enable_strict="yes"
  417. CFLAGS="${CFLAGS} -pedantic -Wall -Wextra -Wno-long-long"
  418. fi
  419. # -----------------------------------------------------------------------------
  420. # memory allocation library
  421. AC_MSG_CHECKING([for memory allocator])
  422. TS_CHECK_JEMALLOC
  423. if test "$has_jemalloc" = "1"; then
  424. AC_DEFINE([ENABLE_JEMALLOC], [1], [compile and link with jemalloc])
  425. AC_MSG_RESULT([jemalloc])
  426. else
  427. TS_CHECK_TCMALLOC
  428. if test "$has_tcmalloc" = "1"; then
  429. AC_DEFINE([ENABLE_TCMALLOC], [1], [compile and link with tcmalloc])
  430. AC_MSG_RESULT([tcmalloc])
  431. else
  432. AC_MSG_RESULT([system])
  433. AC_C_MALLOPT
  434. AC_C_MALLINFO
  435. fi
  436. fi
  437. # -----------------------------------------------------------------------------
  438. # libcap
  439. PKG_CHECK_MODULES(
  440. [LIBCAP],
  441. [libcap],
  442. [AC_CHECK_LIB([cap], [cap_get_proc, cap_set_proc],
  443. [AC_CHECK_HEADER(
  444. [sys/capability.h],
  445. [have_libcap=yes],
  446. [have_libcap=no]
  447. )],
  448. [have_libcap=no]
  449. )],
  450. [have_libcap=no]
  451. )
  452. test "${with_libcap}" = "yes" -a "${have_libcap}" != "yes" && AC_MSG_ERROR([libcap required but not found.])
  453. AC_MSG_CHECKING([if libcap should be used])
  454. if test "${with_libcap}" != "no" -a "${have_libcap}" = "yes"; then
  455. with_libcap="yes"
  456. AC_DEFINE([HAVE_CAPABILITY], [1], [libcap usability])
  457. OPTIONAL_LIBCAP_CFLAGS="${LIBCAP_CFLAGS}"
  458. OPTIONAL_LIBCAP_LIBS="${LIBCAP_LIBS}"
  459. else
  460. with_libcap="no"
  461. fi
  462. AC_MSG_RESULT([${with_libcap}])
  463. AM_CONDITIONAL([ENABLE_CAPABILITY], [test "${with_libcap}" = "yes"])
  464. # -----------------------------------------------------------------------------
  465. # ACLK
  466. AC_MSG_CHECKING([if cloud functionality should be enabled])
  467. AC_MSG_RESULT([${enable_cloud}])
  468. if test "$enable_cloud" != "no"; then
  469. # just to have all messages that can fail ACLK build in one place
  470. # so it is easier to see why it can't be built
  471. if test -n "${SSL_LIBS}"; then
  472. OPTIONAL_SSL_CFLAGS="${SSL_CFLAGS}"
  473. OPTIONAL_SSL_LIBS="${SSL_LIBS}"
  474. else
  475. AC_MSG_WARN([OpenSSL required for agent-cloud-link but not found. Try installing 'libssl-dev' or 'openssl-devel'.])
  476. fi
  477. AC_MSG_CHECKING([if libmosquitto static lib is present (and builds)])
  478. if test -f "externaldeps/mosquitto/libmosquitto.a"; then
  479. LIBS_BKP="${LIBS}"
  480. LIBS="externaldeps/mosquitto/libmosquitto.a ${OPTIONAL_SSL_LIBS}"
  481. AC_LINK_IFELSE([AC_LANG_SOURCE([[#include "externaldeps/mosquitto/mosquitto.h"
  482. int main (int argc, char **argv) {
  483. int m,mm,r;
  484. mosquitto_lib_version(&m, &mm, &r);
  485. }]])],
  486. [HAVE_libmosquitto_a="yes"],
  487. [HAVE_libmosquitto_a="no"])
  488. LIBS="${LIBS_BKP}"
  489. else
  490. HAVE_libmosquitto_a="no"
  491. AC_DEFINE([ACLK_NO_LIBMOSQ], [1], [Libmosquitto.a was not found during build.])
  492. fi
  493. AC_MSG_RESULT([${HAVE_libmosquitto_a}])
  494. AC_MSG_CHECKING([if libwebsockets static lib is present])
  495. if test -f "externaldeps/libwebsockets/libwebsockets.a"; then
  496. LWS_CFLAGS="-I externaldeps/libwebsockets/include"
  497. HAVE_libwebsockets_a="yes"
  498. else
  499. HAVE_libwebsockets_a="no"
  500. AC_DEFINE([ACLK_NO_LWS], [1], [libwebsockets.a was not found during build.])
  501. fi
  502. AC_MSG_RESULT([${HAVE_libwebsockets_a}])
  503. if test "${build_target}" = "linux" -a "${aclk_required}" != "no"; then
  504. if test "${have_libcap}" = "yes" -a "${with_libcap}" = "no"; then
  505. AC_MSG_ERROR([agent-cloud-link can't be built without libcap. Disable it by --disable-cloud or enable libcap])
  506. fi
  507. if test "${with_libcap}" = "yes"; then
  508. LWS_CFLAGS+=" ${LIBCAP_CFLAGS}"
  509. fi
  510. fi
  511. AC_MSG_CHECKING([if netdata agent-cloud-link can be enabled])
  512. if test "${HAVE_libmosquitto_a}" = "yes" -a "${HAVE_libwebsockets_a}" = "yes" -a -n "${SSL_LIBS}"; then
  513. can_enable_aclk="yes"
  514. else
  515. can_enable_aclk="no"
  516. fi
  517. AC_MSG_RESULT([${can_enable_aclk}])
  518. test "${aclk_required}" = "yes" -a "${can_enable_aclk}" = "no" && \
  519. AC_MSG_ERROR([User required agent-cloud-link but it can't be built!])
  520. AC_MSG_CHECKING([if netdata agent-cloud-link should/will be enabled])
  521. if test "${aclk_required}" = "detect"; then
  522. enable_aclk=$can_enable_aclk
  523. else
  524. enable_aclk=$aclk_required
  525. fi
  526. if test "${enable_aclk}" = "yes"; then
  527. AC_DEFINE([ENABLE_ACLK], [1], [netdata ACLK])
  528. fi
  529. AC_MSG_RESULT([${enable_aclk}])
  530. fi
  531. AM_CONDITIONAL([ENABLE_ACLK], [test "${enable_aclk}" = "yes"])
  532. # -----------------------------------------------------------------------------
  533. # apps.plugin
  534. AC_MSG_CHECKING([if apps.plugin should be enabled])
  535. if test "${build_target}" != "macos"; then
  536. enable_plugin_apps="yes"
  537. else
  538. enable_plugin_apps="no"
  539. fi
  540. AC_MSG_RESULT([${enable_plugin_apps}])
  541. AM_CONDITIONAL([ENABLE_PLUGIN_APPS], [test "${enable_plugin_apps}" = "yes"])
  542. # -----------------------------------------------------------------------------
  543. # freeipmi.plugin - libipmimonitoring
  544. PKG_CHECK_MODULES(
  545. [IPMIMONITORING],
  546. [libipmimonitoring],
  547. [AC_CHECK_LIB([ipmimonitoring], [
  548. ipmi_monitoring_sensor_readings_by_record_id,
  549. ipmi_monitoring_sensor_readings_by_sensor_type,
  550. ipmi_monitoring_sensor_read_sensor_number,
  551. ipmi_monitoring_sensor_read_sensor_name,
  552. ipmi_monitoring_sensor_read_sensor_state,
  553. ipmi_monitoring_sensor_read_sensor_units,
  554. ipmi_monitoring_sensor_iterator_next,
  555. ipmi_monitoring_ctx_sensor_config_file,
  556. ipmi_monitoring_ctx_sdr_cache_directory,
  557. ipmi_monitoring_ctx_errormsg,
  558. ipmi_monitoring_ctx_create
  559. ],
  560. [AC_CHECK_HEADER(
  561. [ipmi_monitoring.h],
  562. [AC_CHECK_HEADER(
  563. [ipmi_monitoring_bitmasks.h],
  564. [have_ipmimonitoring=yes],
  565. [have_ipmimonitoring=no]
  566. )],
  567. [have_ipmimonitoring=no]
  568. )],
  569. [have_ipmimonitoring=no]
  570. )],
  571. [have_ipmimonitoring=no]
  572. )
  573. test "${enable_plugin_freeipmi}" = "yes" -a "${have_ipmimonitoring}" != "yes" && \
  574. AC_MSG_ERROR([ipmimonitoring required but not found. Try installing 'libipmimonitoring-dev' or 'libipmimonitoring-devel'])
  575. AC_MSG_CHECKING([if freeipmi.plugin should be enabled])
  576. if test "${enable_plugin_freeipmi}" != "no" -a "${have_ipmimonitoring}" = "yes"; then
  577. enable_plugin_freeipmi="yes"
  578. AC_DEFINE([HAVE_FREEIPMI], [1], [ipmimonitoring usability])
  579. OPTIONAL_IPMIMONITORING_CFLAGS="${IPMIMONITORING_CFLAGS}"
  580. OPTIONAL_IPMIMONITORING_LIBS="${IPMIMONITORING_LIBS}"
  581. else
  582. enable_plugin_freeipmi="no"
  583. fi
  584. AC_MSG_RESULT([${enable_plugin_freeipmi}])
  585. AM_CONDITIONAL([ENABLE_PLUGIN_FREEIPMI], [test "${enable_plugin_freeipmi}" = "yes"])
  586. # -----------------------------------------------------------------------------
  587. # cups.plugin - libcups
  588. # Only check most recently added method of cups
  589. AC_CHECK_LIB([cups], [httpConnect2],
  590. [AC_CHECK_HEADER(
  591. [cups/cups.h],
  592. [have_cups=yes],
  593. [have_cups=no]
  594. )],
  595. [have_cups=no]
  596. )
  597. test "${enable_plugin_cups}" = "yes" -a "${have_cups}" != "yes" && \
  598. AC_MSG_ERROR([cups required but not found. Try installing 'cups'])
  599. AC_ARG_WITH([cups-config],
  600. [AS_HELP_STRING([--with-cups-config=path], [Specify path to cups-config executable.])],
  601. [with_cups_config="$withval"],
  602. [with_cups_config=system]
  603. )
  604. AS_IF([test "x$with_cups_config" != "xsystem"], [
  605. CUPSCONFIG=$with_cups_config
  606. ], [
  607. AC_PATH_TOOL(CUPSCONFIG, [cups-config])
  608. AS_IF([test -z "$CUPSCONFIG"], [
  609. have_cups=no
  610. ])
  611. ])
  612. AC_MSG_CHECKING([if cups.plugin should be enabled])
  613. if test "${enable_plugin_cups}" != "no" -a "${have_cups}" = "yes"; then
  614. enable_plugin_cups="yes"
  615. AC_DEFINE([HAVE_CUPS], [1], [cups usability])
  616. CUPS_CFLAGS="${CUPS_CFLAGS} `$CUPSCONFIG --cflags`"
  617. CUPS_LIBS="${CUPS_LIBS} `$CUPSCONFIG --libs`"
  618. OPTIONAL_CUPS_CFLAGS="${CUPS_CFLAGS}"
  619. OPTIONAL_CUPS_LIBS="${CUPS_LIBS}"
  620. else
  621. enable_plugin_cups="no"
  622. fi
  623. AC_MSG_RESULT([${enable_plugin_cups}])
  624. AM_CONDITIONAL([ENABLE_PLUGIN_CUPS], [test "${enable_plugin_cups}" = "yes"])
  625. # -----------------------------------------------------------------------------
  626. # nfacct.plugin - libmnl, libnetfilter_acct
  627. AC_CHECK_HEADER(
  628. [linux/netfilter/nfnetlink_conntrack.h],
  629. [AC_CHECK_DECL(
  630. [CTA_STATS_MAX],
  631. [have_nfnetlink_conntrack=yes],
  632. [have_nfnetlink_conntrack=no],
  633. [#include <linux/netfilter/nfnetlink_conntrack.h>]
  634. )],
  635. [have_nfnetlink_conntrack=no]
  636. )
  637. PKG_CHECK_MODULES(
  638. [NFACCT],
  639. [libnetfilter_acct],
  640. [AC_CHECK_LIB(
  641. [netfilter_acct],
  642. [nfacct_alloc],
  643. [have_libnetfilter_acct=yes],
  644. [have_libnetfilter_acct=no]
  645. )],
  646. [have_libnetfilter_acct=no]
  647. )
  648. PKG_CHECK_MODULES(
  649. [LIBMNL],
  650. [libmnl],
  651. [AC_CHECK_LIB(
  652. [mnl],
  653. [mnl_socket_open],
  654. [have_libmnl=yes],
  655. [have_libmnl=no]
  656. )],
  657. [have_libmnl=no]
  658. )
  659. test "${enable_plugin_nfacct}" = "yes" -a "${have_nfnetlink_conntrack}" != "yes" && \
  660. AC_MSG_ERROR([nfnetlink_conntrack.h required but not found or too old])
  661. test "${enable_plugin_nfacct}" = "yes" -a "${have_libnetfilter_acct}" != "yes" && \
  662. AC_MSG_ERROR([netfilter_acct required but not found])
  663. test "${enable_plugin_nfacct}" = "yes" -a "${have_libmnl}" != "yes" && \
  664. AC_MSG_ERROR([libmnl required but not found. Try installing 'libmnl-dev' or 'libmnl-devel'])
  665. AC_MSG_CHECKING([if nfacct.plugin should be enabled])
  666. if test "${enable_plugin_nfacct}" != "no" -a "${have_libnetfilter_acct}" = "yes" \
  667. -a "${have_libmnl}" = "yes" \
  668. -a "${have_nfnetlink_conntrack}" = "yes"; then
  669. enable_plugin_nfacct="yes"
  670. AC_DEFINE([HAVE_LIBMNL], [1], [libmnl usability])
  671. AC_DEFINE([HAVE_LIBNETFILTER_ACCT], [1], [libnetfilter_acct usability])
  672. AC_DEFINE([HAVE_LINUX_NETFILTER_NFNETLINK_CONNTRACK_H], [1], [libnetfilter_nfnetlink_conntrack header usability])
  673. OPTIONAL_NFACCT_CFLAGS="${NFACCT_CFLAGS} ${LIBMNL_CFLAGS}"
  674. OPTIONAL_NFACCT_LIBS="${NFACCT_LIBS} ${LIBMNL_LIBS}"
  675. else
  676. enable_plugin_nfacct="no"
  677. fi
  678. AC_MSG_RESULT([${enable_plugin_nfacct}])
  679. AM_CONDITIONAL([ENABLE_PLUGIN_NFACCT], [test "${enable_plugin_nfacct}" = "yes"])
  680. # -----------------------------------------------------------------------------
  681. # xenstat.plugin - libxenstat
  682. PKG_CHECK_MODULES(
  683. [YAJL],
  684. [yajl],
  685. [AC_CHECK_LIB(
  686. [yajl],
  687. [yajl_tree_get],
  688. [have_libyajl=yes],
  689. [have_libyajl=no]
  690. )],
  691. [have_libyajl=no]
  692. )
  693. AC_CHECK_LIB(
  694. [xenstat],
  695. [xenstat_init],
  696. [AC_CHECK_HEADER(
  697. [xenstat.h],
  698. [have_libxenstat=yes],
  699. [have_libxenstat=no]
  700. )],
  701. [have_libxenstat=no],
  702. [-lyajl]
  703. )
  704. PKG_CHECK_MODULES(
  705. [XENLIGHT],
  706. [xenlight],
  707. [AC_CHECK_LIB(
  708. [xenlight],
  709. [libxl_domain_info],
  710. [AC_CHECK_HEADER(
  711. [libxl.h],
  712. [have_libxenlight=yes],
  713. [have_libxenlight=no]
  714. )],
  715. [have_libxenlight=no]
  716. )],
  717. [have_libxenlight=no]
  718. )
  719. test "${enable_plugin_xenstat}" = "yes" -a "${have_libxenstat}" != "yes" && \
  720. AC_MSG_ERROR([libxenstat required but not found. try installing 'xen-dom0-libs-devel'])
  721. test "${enable_plugin_xenstat}" = "yes" -a "${have_libxenlight}" != "yes" && \
  722. AC_MSG_ERROR([libxenlight required but not found. try installing 'xen-dom0-libs-devel'])
  723. test "${enable_plugin_xenstat}" = "yes" -a "${have_libyajl}" != "yes" && \
  724. AC_MSG_ERROR([libyajl required but not found. Try installing 'yajl-devel'])
  725. AC_MSG_CHECKING([if xenstat.plugin should be enabled])
  726. if test "${enable_plugin_xenstat}" != "no" -a "${have_libxenstat}" = "yes" -a "${have_libxenlight}" = "yes" -a "${have_libyajl}" = "yes"; then
  727. enable_plugin_xenstat="yes"
  728. AC_DEFINE([HAVE_LIBXENSTAT], [1], [libxenstat usability])
  729. AC_DEFINE([HAVE_LIBXENLIGHT], [1], [libxenlight usability])
  730. AC_DEFINE([HAVE_LIBYAJL], [1], [libyajl usability])
  731. OPTIONAL_XENSTAT_CFLAGS="${XENLIGHT_CFLAGS} ${YAJL_CFLAGS}"
  732. OPTIONAL_XENSTAT_LIBS="-lxenstat ${XENLIGHT_LIBS} ${YAJL_LIBS}"
  733. else
  734. enable_plugin_xenstat="no"
  735. fi
  736. AC_MSG_RESULT([${enable_plugin_xenstat}])
  737. AM_CONDITIONAL([ENABLE_PLUGIN_XENSTAT], [test "${enable_plugin_xenstat}" = "yes"])
  738. if test "${enable_plugin_xenstat}" == "yes"; then
  739. AC_MSG_CHECKING([for xenstat_vbd_error in -lxenstat])
  740. AC_TRY_LINK(
  741. [ #include <xenstat.h> ],
  742. [
  743. xenstat_vbd * vbd;
  744. int out = xenstat_vbd_error(vbd);
  745. ],
  746. [
  747. have_xenstat_vbd_error=yes
  748. AC_DEFINE([HAVE_XENSTAT_VBD_ERROR], [1], [xenstat_vbd_error usability])
  749. ],
  750. [ have_xenstat_vbd_error=no ]
  751. )
  752. AC_MSG_RESULT([${have_xenstat_vbd_error}])
  753. fi
  754. # -----------------------------------------------------------------------------
  755. # perf.plugin
  756. AC_CHECK_HEADER(
  757. [linux/perf_event.h],
  758. [AC_CHECK_DECL(
  759. [PERF_COUNT_HW_REF_CPU_CYCLES],
  760. [have_perf_event=yes],
  761. [have_perf_event=no],
  762. [#include <linux/perf_event.h>]
  763. )],
  764. [have_perf_event=no]
  765. )
  766. AC_MSG_CHECKING([if perf.plugin should be enabled])
  767. if test "${build_target}" == "linux" -a "${have_perf_event}" = "yes"; then
  768. enable_plugin_perf="yes"
  769. else
  770. enable_plugin_perf="no"
  771. fi
  772. AC_MSG_RESULT([${enable_plugin_perf}])
  773. AM_CONDITIONAL([ENABLE_PLUGIN_PERF], [test "${enable_plugin_perf}" = "yes"])
  774. # -----------------------------------------------------------------------------
  775. # ebpf_process.plugin
  776. AC_MSG_CHECKING([if ebpf_process.plugin should be enabled])
  777. if test "${build_target}" == "linux" -a "${EBPF_LIBS}"; then
  778. enable_vfs="yes"
  779. else
  780. enable_vfs="no"
  781. fi
  782. AC_MSG_RESULT([${enable_vfs}])
  783. AM_CONDITIONAL([ENABLE_PLUGIN_EBPF], [test "${enable_vfs}" = "yes"])
  784. # -----------------------------------------------------------------------------
  785. # slabinfo.plugin
  786. AC_MSG_CHECKING([if slabinfo.plugin should be enabled])
  787. if test "${build_target}" == "linux"; then
  788. enable_plugin_slabinfo="yes"
  789. else
  790. enable_plugin_slabinfo="no"
  791. fi
  792. AC_MSG_RESULT([${enable_plugin_slabinfo}])
  793. AM_CONDITIONAL([ENABLE_PLUGIN_SLABINFO], [test "${enable_plugin_slabinfo}" = "yes"])
  794. # -----------------------------------------------------------------------------
  795. # AWS Kinesis backend - libaws-cpp-sdk-kinesis, libaws-cpp-sdk-core, libssl, libcrypto, libcurl
  796. PKG_CHECK_MODULES(
  797. [LIBCRYPTO],
  798. [libcrypto],
  799. [AC_CHECK_LIB(
  800. [crypto],
  801. [CRYPTO_new_ex_data],
  802. [have_libcrypto=yes],
  803. [have_libcrypto=no]
  804. )],
  805. [have_libcrypto=no]
  806. )
  807. PKG_CHECK_MODULES(
  808. [LIBSSL],
  809. [libssl],
  810. [AC_CHECK_LIB(
  811. [ssl],
  812. [SSL_connect],
  813. [have_libssl=yes],
  814. [have_libssl=no]
  815. )],
  816. [have_libssl=no]
  817. )
  818. PKG_CHECK_MODULES(
  819. [LIBCURL],
  820. [libcurl],
  821. [AC_CHECK_LIB(
  822. [curl],
  823. [curl_easy_init],
  824. [have_libcurl=yes],
  825. [have_libcurl=no]
  826. )],
  827. [have_libcurl=no]
  828. )
  829. AC_CHECK_LIB(
  830. [aws-cpp-sdk-core],
  831. [cJSON_free],
  832. [have_libaws_cpp_sdk_core=yes],
  833. [have_libaws_cpp_sdk_core=no],
  834. [${LIBCRYPTO_LIBS} ${LIBSSL_LIBS} ${LIBCURL_LIBS}]
  835. )
  836. AC_MSG_CHECKING([for Aws::Kinesis::Model::PutRecordRequest in -laws-cpp-sdk-kinesis])
  837. if test "${have_libaws_cpp_sdk_core}" = "yes" -a "${have_libcrypto}" = "yes" -a "${have_libssl}" = "yes" -a "${have_libcurl}" = "yes"; then
  838. AC_LANG_SAVE
  839. AC_LANG_CPLUSPLUS
  840. save_LIBS="${LIBS}"
  841. LIBS="-laws-cpp-sdk-kinesis -laws-cpp-sdk-core ${LIBCRYPTO_LIBS} ${LIBSSL_LIBS} ${LIBCURL_LIBS}"
  842. save_CXXFLAGS="${CXXFLAGS}"
  843. CXXFLAGS="${CXXFLAGS} -std=c++11"
  844. AC_TRY_LINK(
  845. [
  846. #include <aws/core/Aws.h>
  847. #include <aws/core/client/ClientConfiguration.h>
  848. #include <aws/core/auth/AWSCredentials.h>
  849. #include <aws/core/utils/Outcome.h>
  850. #include <aws/kinesis/KinesisClient.h>
  851. #include <aws/kinesis/model/PutRecordRequest.h>
  852. ],
  853. [Aws::Kinesis::Model::PutRecordRequest request;],
  854. [have_libaws_cpp_sdk_kinesis=yes],
  855. [have_libaws_cpp_sdk_kinesis=no]
  856. )
  857. LIBS="${save_LIBS}"
  858. CXXFLAGS="${save_CXXFLAGS}"
  859. AC_LANG_RESTORE
  860. else
  861. have_libaws_cpp_sdk_kinesis=no
  862. fi
  863. AC_MSG_RESULT([${have_libaws_cpp_sdk_kinesis}])
  864. test "${enable_backend_kinesis}" = "yes" -a "${have_libaws_cpp_sdk_kinesis}" != "yes" && \
  865. AC_MSG_ERROR([libaws-cpp-sdk-kinesis required but not found. try installing AWS C++ SDK])
  866. test "${enable_backend_kinesis}" = "yes" -a "${have_libaws_cpp_sdk_core}" != "yes" && \
  867. AC_MSG_ERROR([libaws-cpp-sdk-core required but not found. try installing AWS C++ SDK])
  868. test "${enable_backend_kinesis}" = "yes" -a "${have_libcurl}" != "yes" && \
  869. AC_MSG_ERROR([libcurl required but not found])
  870. test "${enable_backend_kinesis}" = "yes" -a "${have_libssl}" != "yes" && \
  871. AC_MSG_ERROR([libssl required but not found])
  872. test "${enable_backend_kinesis}" = "yes" -a "${have_libcrypto}" != "yes" && \
  873. AC_MSG_ERROR([libcrypto required but not found])
  874. AC_MSG_CHECKING([if kinesis backend should be enabled])
  875. if test "${enable_backend_kinesis}" != "no" -a "${have_libaws_cpp_sdk_kinesis}" = "yes" -a "${have_libaws_cpp_sdk_core}" = "yes" \
  876. -a "${have_libcurl}" = "yes" -a "${have_libssl}" = "yes" -a "${have_libcrypto}" = "yes"; then
  877. enable_backend_kinesis="yes"
  878. AC_DEFINE([HAVE_KINESIS], [1], [libaws-cpp-sdk-kinesis usability])
  879. OPTIONAL_KINESIS_CFLAGS="${LIBCRYPTO_CFLAGS} ${LIBSSL_CFLAGS} ${LIBCURL_CFLAGS}"
  880. CXX11FLAG="-std=c++11"
  881. OPTIONAL_KINESIS_LIBS="-laws-cpp-sdk-kinesis -laws-cpp-sdk-core ${LIBCRYPTO_LIBS} ${LIBSSL_LIBS} ${LIBCURL_LIBS}"
  882. else
  883. enable_backend_kinesis="no"
  884. fi
  885. AC_MSG_RESULT([${enable_backend_kinesis}])
  886. AM_CONDITIONAL([ENABLE_BACKEND_KINESIS], [test "${enable_backend_kinesis}" = "yes"])
  887. # -----------------------------------------------------------------------------
  888. # Prometheus remote write backend - libprotobuf, libsnappy, protoc
  889. PKG_CHECK_MODULES(
  890. [PROTOBUF],
  891. [protobuf >= 3],
  892. [have_libprotobuf=yes],
  893. [have_libprotobuf=no]
  894. )
  895. AC_MSG_CHECKING([for snappy::RawCompress in -lsnappy])
  896. AC_LANG_SAVE
  897. AC_LANG_CPLUSPLUS
  898. save_LIBS="${LIBS}"
  899. LIBS="-lsnappy"
  900. save_CXXFLAGS="${CXXFLAGS}"
  901. CXXFLAGS="${CXXFLAGS} -std=c++11"
  902. AC_TRY_LINK(
  903. [
  904. #include <stdlib.h>
  905. #include <snappy.h>
  906. ],
  907. [
  908. const char *input = "test";
  909. size_t compressed_length;
  910. char *buffer = (char *)malloc(5 * sizeof(char));
  911. snappy::RawCompress(input, 4, buffer, &compressed_length);
  912. free(buffer);
  913. ],
  914. [
  915. have_libsnappy=yes
  916. SNAPPY_CFLAGS=""
  917. SNAPPY_LIBS="-lsnappy"
  918. ],
  919. [have_libsnappy=no]
  920. )
  921. LIBS="${save_LIBS}"
  922. CXXFLAGS="${save_CXXFLAGS}"
  923. AC_LANG_RESTORE
  924. AC_MSG_RESULT([${have_libsnappy}])
  925. AC_PATH_PROG([PROTOC], [protoc], [no])
  926. AS_IF(
  927. [test x"${PROTOC}" == x"no"],
  928. [have_protoc=no],
  929. [have_protoc=yes]
  930. )
  931. AC_PATH_PROG([CXX_BINARY], [${CXX}], [no])
  932. AS_IF(
  933. [test x"${CXX_BINARY}" == x"no"],
  934. [have_CXX_compiler=no],
  935. [have_CXX_compiler=yes]
  936. )
  937. test "${enable_backend_prometheus_remote_write}" = "yes" -a "${have_libprotobuf}" != "yes" && \
  938. AC_MSG_ERROR([libprotobuf required but not found. try installing protobuf])
  939. test "${enable_backend_prometheus_remote_write}" = "yes" -a "${have_libsnappy}" != "yes" && \
  940. AC_MSG_ERROR([libsnappy required but not found. try installing snappy])
  941. test "${enable_backend_prometheus_remote_write}" = "yes" -a "${have_protoc}" != "yes" && \
  942. AC_MSG_ERROR([protoc compiler required but not found. try installing protobuf])
  943. test "${enable_backend_prometheus_remote_write}" = "yes" -a "${have_CXX_compiler}" != "yes" && \
  944. AC_MSG_ERROR([C++ compiler required but not found. try installing g++])
  945. AC_MSG_CHECKING([if prometheus remote write backend should be enabled])
  946. if test "${enable_backend_prometheus_remote_write}" != "no" -a "${have_libprotobuf}" = "yes" -a "${have_libsnappy}" = "yes" \
  947. -a "${have_protoc}" = "yes" -a "${have_CXX_compiler}" = "yes"; then
  948. enable_backend_prometheus_remote_write="yes"
  949. AC_DEFINE([ENABLE_PROMETHEUS_REMOTE_WRITE], [1], [Prometheus remote write API usability])
  950. OPTIONAL_PROMETHEUS_REMOTE_WRITE_CFLAGS="${PROTOBUF_CFLAGS} ${SNAPPY_CFLAGS} -Iexporting/prometheus/remote_write"
  951. CXX11FLAG="-std=c++11"
  952. OPTIONAL_PROMETHEUS_REMOTE_WRITE_LIBS="${PROTOBUF_LIBS} ${SNAPPY_LIBS}"
  953. else
  954. enable_backend_prometheus_remote_write="no"
  955. fi
  956. AC_MSG_RESULT([${enable_backend_prometheus_remote_write}])
  957. AM_CONDITIONAL([ENABLE_BACKEND_PROMETHEUS_REMOTE_WRITE], [test "${enable_backend_prometheus_remote_write}" = "yes"])
  958. # -----------------------------------------------------------------------------
  959. # MongoDB backend - libmongoc
  960. PKG_CHECK_MODULES(
  961. [LIBMONGOC],
  962. [libmongoc-1.0 >= 1.7],
  963. [have_libmongoc=yes],
  964. [have_libmongoc=no]
  965. )
  966. test "${enable_backend_mongodb}" = "yes" -a "${have_libmongoc}" != "yes" && \
  967. AC_MSG_ERROR([libmongoc required but not found. Try installing `mongoc`.])
  968. AC_MSG_CHECKING([if mongodb backend should be enabled])
  969. if test "${enable_backend_mongodb}" != "no" -a "${have_libmongoc}" = "yes"; then
  970. enable_backend_mongodb="yes"
  971. AC_DEFINE([HAVE_MONGOC], [1], [libmongoc usability])
  972. OPTIONAL_MONGOC_CFLAGS="${LIBMONGOC_CFLAGS}"
  973. OPTIONAL_MONGOC_LIBS="${LIBMONGOC_LIBS}"
  974. else
  975. enable_backend_mongodb="no"
  976. fi
  977. AC_MSG_RESULT([${enable_backend_mongodb}])
  978. AM_CONDITIONAL([ENABLE_BACKEND_MONGODB], [test "${enable_backend_mongodb}" = "yes"])
  979. # -----------------------------------------------------------------------------
  980. # check for setns() - cgroup-network
  981. AC_CHECK_FUNC([setns])
  982. AC_MSG_CHECKING([if cgroup-network can be enabled])
  983. if test "$ac_cv_func_setns" = "yes" ; then
  984. have_setns="yes"
  985. AC_DEFINE([HAVE_SETNS], [1], [Define 1 if you have setns() function])
  986. else
  987. have_setns="no"
  988. fi
  989. AC_MSG_RESULT([${have_setns}])
  990. AM_CONDITIONAL([ENABLE_PLUGIN_CGROUP_NETWORK], [test "${have_setns}" = "yes"])
  991. # -----------------------------------------------------------------------------
  992. # Link-Time-Optimization
  993. if test "${enable_lto}" != "no"; then
  994. opt="-flto"
  995. AX_CHECK_COMPILE_FLAG(${opt}, [have_lto=yes], [have_lto=no])
  996. fi
  997. if test "${have_lto}" = "yes"; then
  998. oCFLAGS="${CFLAGS}"
  999. CFLAGS="${CFLAGS} -flto"
  1000. ac_cv_c_lto_cross_compile="${enable_lto}"
  1001. test "${ac_cv_c_lto_cross_compile}" != "yes" && ac_cv_c_lto_cross_compile="no"
  1002. AC_C_LTO
  1003. CFLAGS="${oCFLAGS}"
  1004. test "${ac_cv_c_lto}" != "yes" && have_lto="no"
  1005. fi
  1006. test "${enable_lto}" = "yes" -a "${have_lto}" != "yes" && \
  1007. AC_MSG_ERROR([LTO is required but is not available.])
  1008. AC_MSG_CHECKING([if LTO should be enabled])
  1009. if test "${enable_lto}" != "no" -a "${have_lto}" = "yes"; then
  1010. enable_lto="yes"
  1011. CFLAGS="${CFLAGS} -flto"
  1012. else
  1013. enable_lto="no"
  1014. fi
  1015. AC_MSG_RESULT([${enable_lto}])
  1016. # -----------------------------------------------------------------------------
  1017. AM_CONDITIONAL([ENABLE_CXX_LINKER], [test "${enable_backend_kinesis}" = "yes" -o "${enable_backend_prometheus_remote_write}" = "yes"])
  1018. AC_DEFINE_UNQUOTED([NETDATA_USER], ["${with_user}"], [use this user to drop privileged])
  1019. varlibdir="${localstatedir}/lib/netdata"
  1020. registrydir="${localstatedir}/lib/netdata/registry"
  1021. cachedir="${localstatedir}/cache/netdata"
  1022. chartsdir="${libexecdir}/netdata/charts.d"
  1023. nodedir="${libexecdir}/netdata/node.d"
  1024. pythondir="${libexecdir}/netdata/python.d"
  1025. configdir="${sysconfdir}/netdata"
  1026. libconfigdir="${libdir}/netdata/conf.d"
  1027. logdir="${localstatedir}/log/netdata"
  1028. pluginsdir="${libexecdir}/netdata/plugins.d"
  1029. AC_SUBST([build_target])
  1030. AC_SUBST([varlibdir])
  1031. AC_SUBST([registrydir])
  1032. AC_SUBST([cachedir])
  1033. AC_SUBST([chartsdir])
  1034. AC_SUBST([nodedir])
  1035. AC_SUBST([pythondir])
  1036. AC_SUBST([configdir])
  1037. AC_SUBST([libconfigdir])
  1038. AC_SUBST([logdir])
  1039. AC_SUBST([pluginsdir])
  1040. AC_SUBST([webdir])
  1041. CFLAGS="${CFLAGS} ${OPTIONAL_MATH_CFLAGS} ${OPTIONAL_NFACCT_CFLAGS} ${OPTIONAL_ZLIB_CFLAGS} ${OPTIONAL_UUID_CFLAGS} \
  1042. ${OPTIONAL_LIBCAP_CFLAGS} ${OPTIONAL_IPMIMONITORING_CFLAGS} ${OPTIONAL_CUPS_CFLAGS} ${OPTIONAL_XENSTAT_FLAGS} \
  1043. ${OPTIONAL_KINESIS_CFLAGS} ${OPTIONAL_PROMETHEUS_REMOTE_WRITE_CFLAGS} ${OPTIONAL_MONGOC_CFLAGS} ${LWS_CFLAGS}"
  1044. CXXFLAGS="${CFLAGS} ${CXX11FLAG}"
  1045. CPPFLAGS="\
  1046. -DTARGET_OS=${build_target_id} \
  1047. -DVARLIB_DIR=\"\\\"${varlibdir}\\\"\" \
  1048. -DCACHE_DIR=\"\\\"${cachedir}\\\"\" \
  1049. -DCONFIG_DIR=\"\\\"${configdir}\\\"\" \
  1050. -DLIBCONFIG_DIR=\"\\\"${libconfigdir}\\\"\" \
  1051. -DLOG_DIR=\"\\\"${logdir}\\\"\" \
  1052. -DPLUGINS_DIR=\"\\\"${pluginsdir}\\\"\" \
  1053. -DRUN_DIR=\"\\\"${localstatedir}/run/netdata\\\"\" \
  1054. -DWEB_DIR=\"\\\"${webdir}\\\"\" \
  1055. "
  1056. AC_SUBST([OPTIONAL_MATH_CFLAGS])
  1057. AC_SUBST([OPTIONAL_MATH_LIBS])
  1058. AC_SUBST([OPTIONAL_UV_LIBS])
  1059. AC_SUBST([OPTIONAL_LZ4_LIBS])
  1060. AC_SUBST([OPTIONAL_JUDY_LIBS])
  1061. AC_SUBST([OPTIONAL_SSL_LIBS])
  1062. AC_SUBST([OPTIONAL_EBPF_LIBS])
  1063. AC_SUBST([OPTIONAL_JSONC_LIBS])
  1064. AC_SUBST([OPTIONAL_NFACCT_CFLAGS])
  1065. AC_SUBST([OPTIONAL_NFACCT_LIBS])
  1066. AC_SUBST([OPTIONAL_ZLIB_CFLAGS])
  1067. AC_SUBST([OPTIONAL_ZLIB_LIBS])
  1068. AC_SUBST([OPTIONAL_UUID_CFLAGS])
  1069. AC_SUBST([OPTIONAL_UUID_LIBS])
  1070. AC_SUBST([OPTIONAL_MQTT_LIBS])
  1071. AC_SUBST([OPTIONAL_LIBCAP_CFLAGS])
  1072. AC_SUBST([OPTIONAL_LIBCAP_LIBS])
  1073. AC_SUBST([OPTIONAL_IPMIMONITORING_CFLAGS])
  1074. AC_SUBST([OPTIONAL_IPMIMONITORING_LIBS])
  1075. AC_SUBST([OPTIONAL_CUPS_CFLAGS])
  1076. AC_SUBST([OPTIONAL_CUPS_LIBS])
  1077. AC_SUBST([OPTIONAL_XENSTAT_CFLAGS])
  1078. AC_SUBST([OPTIONAL_XENSTAT_LIBS])
  1079. AC_SUBST([OPTIONAL_KINESIS_CFLAGS])
  1080. AC_SUBST([OPTIONAL_KINESIS_LIBS])
  1081. AC_SUBST([OPTIONAL_PROMETHEUS_REMOTE_WRITE_CFLAGS])
  1082. AC_SUBST([OPTIONAL_PROMETHEUS_REMOTE_WRITE_LIBS])
  1083. AC_SUBST([OPTIONAL_MONGOC_CFLAGS])
  1084. AC_SUBST([OPTIONAL_MONGOC_LIBS])
  1085. # -----------------------------------------------------------------------------
  1086. # Check if cmocka is available - needed for unit testing
  1087. AC_ARG_ENABLE(
  1088. [unit-tests],
  1089. [AS_HELP_STRING([--disable-unit-tests],
  1090. [Disables building and running the unit tests suite])],
  1091. [],
  1092. [enable_unit_tests="yes"]
  1093. )
  1094. PKG_CHECK_MODULES(
  1095. [CMOCKA],
  1096. [cmocka],
  1097. [have_cmocka="yes"],
  1098. [AC_MSG_NOTICE([CMocka not found on the system. Unit tests disabled])]
  1099. )
  1100. AM_CONDITIONAL([ENABLE_UNITTESTS], [test "${enable_unit_tests}" = "yes" -a "${have_cmocka}" = "yes" ])
  1101. AC_SUBST([ENABLE_UNITTESTS])
  1102. TEST_CFLAGS="${CFLAGS} ${CMOCKA_CFLAGS}"
  1103. TEST_LIBS="${CMOCKA_LIBS}"
  1104. AC_SUBST([TEST_CFLAGS])
  1105. AC_SUBST([TEST_LIBS])
  1106. AC_CONFIG_FILES([
  1107. Makefile
  1108. netdata.spec
  1109. backends/graphite/Makefile
  1110. backends/json/Makefile
  1111. backends/Makefile
  1112. backends/opentsdb/Makefile
  1113. backends/prometheus/Makefile
  1114. backends/prometheus/remote_write/Makefile
  1115. backends/aws_kinesis/Makefile
  1116. backends/mongodb/Makefile
  1117. collectors/Makefile
  1118. collectors/apps.plugin/Makefile
  1119. collectors/cgroups.plugin/Makefile
  1120. collectors/charts.d.plugin/Makefile
  1121. collectors/checks.plugin/Makefile
  1122. collectors/diskspace.plugin/Makefile
  1123. collectors/fping.plugin/Makefile
  1124. collectors/ioping.plugin/Makefile
  1125. collectors/freebsd.plugin/Makefile
  1126. collectors/freeipmi.plugin/Makefile
  1127. collectors/cups.plugin/Makefile
  1128. collectors/idlejitter.plugin/Makefile
  1129. collectors/macos.plugin/Makefile
  1130. collectors/nfacct.plugin/Makefile
  1131. collectors/node.d.plugin/Makefile
  1132. collectors/plugins.d/Makefile
  1133. collectors/proc.plugin/Makefile
  1134. collectors/python.d.plugin/Makefile
  1135. collectors/slabinfo.plugin/Makefile
  1136. collectors/statsd.plugin/Makefile
  1137. collectors/ebpf_process.plugin/Makefile
  1138. collectors/tc.plugin/Makefile
  1139. collectors/xenstat.plugin/Makefile
  1140. collectors/perf.plugin/Makefile
  1141. daemon/Makefile
  1142. database/Makefile
  1143. database/engine/Makefile
  1144. diagrams/Makefile
  1145. exporting/Makefile
  1146. exporting/graphite/Makefile
  1147. exporting/json/Makefile
  1148. exporting/opentsdb/Makefile
  1149. exporting/prometheus/Makefile
  1150. exporting/prometheus/remote_write/Makefile
  1151. exporting/aws_kinesis/Makefile
  1152. exporting/mongodb/Makefile
  1153. exporting/tests/Makefile
  1154. health/Makefile
  1155. health/notifications/Makefile
  1156. libnetdata/Makefile
  1157. libnetdata/tests/Makefile
  1158. libnetdata/adaptive_resortable_list/Makefile
  1159. libnetdata/avl/Makefile
  1160. libnetdata/buffer/Makefile
  1161. libnetdata/clocks/Makefile
  1162. libnetdata/config/Makefile
  1163. libnetdata/dictionary/Makefile
  1164. libnetdata/ebpf/Makefile
  1165. libnetdata/eval/Makefile
  1166. libnetdata/locks/Makefile
  1167. libnetdata/log/Makefile
  1168. libnetdata/popen/Makefile
  1169. libnetdata/procfile/Makefile
  1170. libnetdata/simple_pattern/Makefile
  1171. libnetdata/socket/Makefile
  1172. libnetdata/statistical/Makefile
  1173. libnetdata/storage_number/Makefile
  1174. libnetdata/storage_number/tests/Makefile
  1175. libnetdata/threads/Makefile
  1176. libnetdata/url/Makefile
  1177. libnetdata/json/Makefile
  1178. libnetdata/health/Makefile
  1179. registry/Makefile
  1180. streaming/Makefile
  1181. system/Makefile
  1182. tests/Makefile
  1183. web/Makefile
  1184. web/api/Makefile
  1185. web/api/badges/Makefile
  1186. web/api/exporters/Makefile
  1187. web/api/exporters/shell/Makefile
  1188. web/api/exporters/prometheus/Makefile
  1189. web/api/formatters/Makefile
  1190. web/api/formatters/csv/Makefile
  1191. web/api/formatters/json/Makefile
  1192. web/api/formatters/ssv/Makefile
  1193. web/api/formatters/value/Makefile
  1194. web/api/queries/Makefile
  1195. web/api/queries/average/Makefile
  1196. web/api/queries/des/Makefile
  1197. web/api/queries/incremental_sum/Makefile
  1198. web/api/queries/max/Makefile
  1199. web/api/queries/median/Makefile
  1200. web/api/queries/min/Makefile
  1201. web/api/queries/ses/Makefile
  1202. web/api/queries/stddev/Makefile
  1203. web/api/queries/sum/Makefile
  1204. web/api/health/Makefile
  1205. web/gui/Makefile
  1206. web/server/Makefile
  1207. web/server/static/Makefile
  1208. claim/Makefile
  1209. aclk/Makefile
  1210. ])
  1211. AC_OUTPUT
  1212. test "${with_math}" != "yes" && AC_MSG_WARN([You are building without math. math allows accurate calculations. It should be enabled.]) || :
  1213. test "${with_zlib}" != "yes" && AC_MSG_WARN([You are building without zlib. zlib allows netdata to transfer a lot less data with web clients. It should be enabled.]) || :