configure.ac 43 KB

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