configure.ac 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807
  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. [exporting-pubsub],
  73. [AS_HELP_STRING([--enable-exporting-pubsub], [enable pubsub exporting connector @<:@default autodetect@:>@])],
  74. ,
  75. [enable_exporting_pubsub="detect"]
  76. )
  77. AC_ARG_ENABLE(
  78. [backend-prometheus-remote-write],
  79. [AS_HELP_STRING([--enable-backend-prometheus-remote-write], [enable prometheus remote write backend @<:@default autodetect@:>@])],
  80. ,
  81. [enable_backend_prometheus_remote_write="detect"]
  82. )
  83. AC_ARG_ENABLE(
  84. [backend-mongodb],
  85. [AS_HELP_STRING([--enable-backend-mongodb], [enable mongodb backend @<:@default autodetect@:>@])],
  86. ,
  87. [enable_backend_mongodb="detect"]
  88. )
  89. AC_ARG_ENABLE(
  90. [pedantic],
  91. [AS_HELP_STRING([--enable-pedantic], [enable pedantic compiler warnings @<:@default disabled@:>@])],
  92. ,
  93. [enable_pedantic="no"]
  94. )
  95. AC_ARG_ENABLE(
  96. [accept4],
  97. [AS_HELP_STRING([--disable-accept4], [System does not have accept4 @<:@default autodetect@:>@])],
  98. ,
  99. [enable_accept4="detect"]
  100. )
  101. AC_ARG_WITH(
  102. [webdir],
  103. [AS_HELP_STRING([--with-webdir], [location of webdir @<:@PKGDATADIR/web@:>@])],
  104. [webdir="${withval}"],
  105. [webdir="\$(pkgdatadir)/web"]
  106. )
  107. AC_ARG_WITH(
  108. [libcap],
  109. [AS_HELP_STRING([--with-libcap], [build with libcap @<:@default autodetect@:>@])],
  110. ,
  111. [with_libcap="detect"]
  112. )
  113. AC_ARG_WITH(
  114. [zlib],
  115. [AS_HELP_STRING([--without-zlib], [build without zlib @<:@default enabled@:>@])],
  116. ,
  117. [with_zlib="yes"]
  118. )
  119. AC_ARG_WITH(
  120. [math],
  121. [AS_HELP_STRING([--without-math], [build without math @<:@default enabled@:>@])],
  122. ,
  123. [with_math="yes"]
  124. )
  125. AC_ARG_WITH(
  126. [user],
  127. [AS_HELP_STRING([--with-user], [use this user to drop privilege @<:@default nobody@:>@])],
  128. ,
  129. [with_user="nobody"]
  130. )
  131. AC_ARG_ENABLE(
  132. [x86-sse],
  133. [AS_HELP_STRING([--disable-x86-sse], [SSE/SS2 optimizations on x86 @<:@default enabled@:>@])],
  134. ,
  135. [enable_x86_sse="yes"]
  136. )
  137. AC_ARG_ENABLE(
  138. [lto],
  139. [AS_HELP_STRING([--enable-lto], [Link Time Optimizations @<:@default disabled@:>@])],
  140. ,
  141. [enable_lto="no"]
  142. )
  143. AC_ARG_ENABLE(
  144. [https],
  145. [AS_HELP_STRING([--enable-https], [Enable SSL support @<:@default autodetect@:>@])],
  146. ,
  147. [enable_https="detect"]
  148. )
  149. AC_ARG_ENABLE(
  150. [compression],
  151. [AS_HELP_STRING([--enable-compression], [Enable LZ4 compression support @<:@default autodetect@:>@])],
  152. ,
  153. [enable_compression="detect"]
  154. )
  155. AC_ARG_ENABLE(
  156. [dbengine],
  157. [AS_HELP_STRING([--disable-dbengine], [disable netdata dbengine @<:@default autodetect@:>@])],
  158. ,
  159. [enable_dbengine="detect"]
  160. )
  161. AC_ARG_ENABLE(
  162. [jsonc],
  163. [AS_HELP_STRING([--enable-jsonc], [Enable JSON-C support @<:@default autodetect@:>@])],
  164. ,
  165. [enable_jsonc="detect"]
  166. )
  167. AC_ARG_ENABLE(
  168. [ebpf],
  169. [AS_HELP_STRING([--disable-ebpf], [Disable eBPF support @<:@default autodetect@:>@])],
  170. ,
  171. [enable_ebpf="detect"]
  172. )
  173. AC_ARG_WITH(
  174. [bundled-lws],
  175. [AS_HELP_STRING([--with-bundled-lws], [Use the bundled version of libwebsockets library @<:@default use system library@:>@])],
  176. [with_bundled_lws="yes"], [with_bundled_lws="no"]
  177. )
  178. AC_ARG_WITH(
  179. [bundled-protobuf],
  180. [AS_HELP_STRING([--with-bundled-protobuf],
  181. [Uses the bundled version of Google Protocol Buffers @<:@default bundled if present@:>@])],
  182. [with_bundled_protobuf="$withval"],
  183. [with_bundled_protobuf="detect"]
  184. )
  185. AC_ARG_ENABLE(
  186. [ml],
  187. [AS_HELP_STRING([--enable-ml], [Enable anomaly detection @<:@default autodetect@:>@])],
  188. ,
  189. [enable_ml="detect"]
  190. )
  191. AC_ARG_ENABLE(
  192. [ml_tests],
  193. [AS_HELP_STRING([--enable-ml-tests], [Enable anomaly detection tests @<:@no@:>@])],
  194. [enable_ml_tests="yes"],
  195. [enable_ml_tests="no"]
  196. )
  197. # -----------------------------------------------------------------------------
  198. # Enforce building with C99, bail early if we can't.
  199. test "${ac_cv_prog_cc_c99}" = "no" && AC_MSG_ERROR([Netdata requires a compiler that supports C99 to build])
  200. # -----------------------------------------------------------------------------
  201. # Check if cloud is enabled and if the functionality is available
  202. AC_ARG_ENABLE(
  203. [cloud],
  204. [AS_HELP_STRING([--disable-cloud],
  205. [Disables all cloud functionality])],
  206. [ enable_cloud="$enableval" ],
  207. [ enable_cloud="detect" ]
  208. )
  209. AC_ARG_WITH(
  210. [new-cloud-protocol],
  211. [AS_HELP_STRING([--with-new-cloud-protocol],
  212. [Requires New Cloud Protocol support to be built])],
  213. [new_cloud_protocol="$withval"],
  214. [new_cloud_protocol="detect"]
  215. )
  216. if test "${enable_cloud}" = "no"; then
  217. AC_DEFINE([DISABLE_CLOUD], [1], [disable netdata cloud functionality])
  218. fi
  219. # -----------------------------------------------------------------------------
  220. # netdata required checks
  221. # fails on centos6
  222. #AX_CHECK_ENABLE_DEBUG()
  223. AX_GCC_FUNC_ATTRIBUTE([returns_nonnull])
  224. AX_GCC_FUNC_ATTRIBUTE([malloc])
  225. AX_GCC_FUNC_ATTRIBUTE([noreturn])
  226. AX_GCC_FUNC_ATTRIBUTE([noinline])
  227. AX_GCC_FUNC_ATTRIBUTE([format])
  228. AX_GCC_FUNC_ATTRIBUTE([warn_unused_result])
  229. AC_CHECK_TYPES([struct timespec, clockid_t], [], [], [[#include <time.h>]])
  230. AC_SEARCH_LIBS([clock_gettime], [rt posix4])
  231. AC_CHECK_FUNCS([clock_gettime])
  232. AC_CHECK_FUNCS([sched_setscheduler sched_getscheduler sched_getparam sched_get_priority_min sched_get_priority_max getpriority setpriority nice])
  233. AC_CHECK_FUNCS([recvmmsg])
  234. AC_TYPE_INT8_T
  235. AC_TYPE_INT16_T
  236. AC_TYPE_INT32_T
  237. AC_TYPE_INT64_T
  238. AC_TYPE_UINT8_T
  239. AC_TYPE_UINT16_T
  240. AC_TYPE_UINT32_T
  241. AC_TYPE_UINT64_T
  242. AC_C_INLINE
  243. AC_FUNC_STRERROR_R
  244. AC_C__GENERIC
  245. AC_C___ATOMIC
  246. # AC_C_STMT_EXPR
  247. AC_CHECK_SIZEOF([void *])
  248. AC_CANONICAL_HOST
  249. AC_HEADER_MAJOR
  250. AC_HEADER_RESOLV
  251. AC_CHECK_HEADERS_ONCE([sys/prctl.h])
  252. AC_CHECK_HEADERS_ONCE([sys/vfs.h])
  253. AC_CHECK_HEADERS_ONCE([sys/statfs.h])
  254. AC_CHECK_HEADERS_ONCE([linux/magic.h])
  255. AC_CHECK_HEADERS_ONCE([sys/statvfs.h])
  256. AC_CHECK_HEADERS_ONCE([sys/mount.h])
  257. if test "${enable_accept4}" != "no"; then
  258. AC_CHECK_FUNCS_ONCE(accept4)
  259. fi
  260. # -----------------------------------------------------------------------------
  261. # operating system detection
  262. AC_MSG_CHECKING([operating system])
  263. case "$host_os" in
  264. freebsd*)
  265. build_target=freebsd
  266. CFLAGS="${CFLAGS} -I/usr/local/include -L/usr/local/lib"
  267. ;;
  268. darwin*)
  269. build_target=macos
  270. LDFLAGS="${LDFLAGS} -framework CoreFoundation -framework IOKit"
  271. ;;
  272. *)
  273. build_target=linux
  274. ;;
  275. esac
  276. AM_CONDITIONAL([FREEBSD], [test "${build_target}" = "freebsd"])
  277. AM_CONDITIONAL([MACOS], [test "${build_target}" = "macos"])
  278. AM_CONDITIONAL([LINUX], [test "${build_target}" = "linux"])
  279. AC_MSG_RESULT([Host OS: ${build_target}])
  280. # -----------------------------------------------------------------------------
  281. # pthreads
  282. ACX_PTHREAD(, [AC_MSG_ERROR([Cannot initialize pthread environment])])
  283. LIBS="${PTHREAD_LIBS} ${LIBS}"
  284. CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}"
  285. CC="${PTHREAD_CC}"
  286. AC_CHECK_LIB(
  287. [pthread],
  288. [pthread_getname_np],
  289. [AC_DEFINE([HAVE_PTHREAD_GETNAME_NP], [1], [Is set if pthread_getname_np is available])]
  290. )
  291. # -----------------------------------------------------------------------------
  292. # libm
  293. AC_ARG_VAR([MATH_CFLAGS], [C compiler flags for math])
  294. AC_ARG_VAR([MATH_LIBS], [linker flags for math])
  295. if test -z "${MATH_LIBS}"; then
  296. AC_CHECK_LIB(
  297. [m],
  298. [sin],
  299. [MATH_LIBS="-lm"]
  300. )
  301. fi
  302. test "${with_math}" = "yes" -a -z "${MATH_LIBS}" && AC_MSG_ERROR([math required but not found])
  303. AC_MSG_CHECKING([if libm should be used])
  304. if test "${with_math}" != "no" -a ! -z "${MATH_LIBS}"; then
  305. with_math="yes"
  306. AC_DEFINE([STORAGE_WITH_MATH], [1], [math usability])
  307. OPTIONAL_MATH_CFLAGS="${MATH_CFLAGS}"
  308. OPTIONAL_MATH_LIBS="${MATH_LIBS}"
  309. else
  310. with_math="no"
  311. fi
  312. AC_MSG_RESULT([${with_math}])
  313. # -----------------------------------------------------------------------------
  314. # libuv multi-platform support library with a focus on asynchronous I/O
  315. # TODO: check version, uv_fs_scandir_next only available in version >= 1.0
  316. AC_CHECK_LIB(
  317. [uv],
  318. [uv_fs_scandir_next],
  319. [UV_LIBS="-luv"]
  320. )
  321. test -z "${UV_LIBS}" && \
  322. AC_MSG_ERROR([libuv required but not found. Try installing 'libuv1-dev' or 'libuv-devel'.])
  323. OPTIONAL_UV_CFLAGS="${UV_CFLAGS}"
  324. OPTIONAL_UV_LIBS="${UV_LIBS}"
  325. # -----------------------------------------------------------------------------
  326. # lz4 Extremely Fast Compression algorithm
  327. AC_CHECK_LIB(
  328. [lz4],
  329. [LZ4_initStream],
  330. [LZ4_LIBS_FAST="-llz4"]
  331. )
  332. AC_CHECK_LIB(
  333. [lz4],
  334. [LZ4_compress_default],
  335. [LZ4_LIBS="-llz4"]
  336. )
  337. # -----------------------------------------------------------------------------
  338. # zlib
  339. PKG_CHECK_MODULES(
  340. [ZLIB],
  341. [zlib],
  342. [have_zlib=yes],
  343. [have_zlib=no]
  344. )
  345. test "${with_zlib}" = "yes" -a "${have_zlib}" != "yes" && AC_MSG_ERROR([zlib required but not found. Try installing 'zlib1g-dev' or 'zlib-devel'.])
  346. AC_MSG_CHECKING([if zlib should be used])
  347. if test "${with_zlib}" != "no" -a "${have_zlib}" = "yes"; then
  348. with_zlib="yes"
  349. AC_DEFINE([NETDATA_WITH_ZLIB], [1], [zlib usability])
  350. OPTIONAL_ZLIB_CFLAGS="${ZLIB_CFLAGS}"
  351. OPTIONAL_ZLIB_LIBS="${ZLIB_LIBS}"
  352. else
  353. with_zlib="no"
  354. fi
  355. AC_MSG_RESULT([${with_zlib}])
  356. # -----------------------------------------------------------------------------
  357. # libuuid
  358. PKG_CHECK_MODULES(
  359. [UUID],
  360. [uuid],
  361. [have_uuid=yes],
  362. [AC_MSG_ERROR([libuuid required but not found. Try installing 'uuid-dev' or 'libuuid-devel'.])]
  363. )
  364. AC_DEFINE([NETDATA_WITH_UUID], [1], [uuid usability])
  365. OPTIONAL_UUID_CFLAGS="${UUID_CFLAGS}"
  366. OPTIONAL_UUID_LIBS="${UUID_LIBS}"
  367. # -----------------------------------------------------------------------------
  368. # OpenSSL Cryptography and SSL/TLS Toolkit
  369. AC_CHECK_LIB(
  370. [crypto],
  371. [SHA256_Init],
  372. [SSL_LIBS="-lcrypto -lssl"]
  373. )
  374. AC_CHECK_LIB(
  375. [crypto],
  376. [X509_VERIFY_PARAM_set1_host],
  377. [ssl_host_validation="yes"],
  378. [ssl_host_validation="no"]
  379. )
  380. test -z "${SSL_LIBS}" || \
  381. AC_DEFINE([HAVE_CRYPTO], [1], [libcrypto availability])
  382. if test "${ssl_host_validation}" = "no"; then
  383. AC_DEFINE([HAVE_X509_VERIFY_PARAM_set1_host], [0], [ssl host validation])
  384. AC_MSG_WARN([DISABLING SSL HOSTNAME VALIDATION BECAUSE IT IS NOT AVAILABLE ON THIS SYSTEM.])
  385. else
  386. AC_DEFINE([HAVE_X509_VERIFY_PARAM_set1_host], [1], [ssl host validation])
  387. fi
  388. # -----------------------------------------------------------------------------
  389. # JSON-C library
  390. PKG_CHECK_MODULES([JSON],[json-c],AC_CHECK_LIB(
  391. [json-c],
  392. [json_object_get_type],
  393. [JSONC_LIBS="-ljson-c"]),AC_CHECK_LIB(
  394. [json],
  395. [json_object_get_type],
  396. [JSONC_LIBS="-ljson"])
  397. )
  398. OPTIONAL_JSONC_LIBS="${JSONC_LIBS}"
  399. # -----------------------------------------------------------------------------
  400. # DB engine and HTTPS
  401. test "${enable_dbengine}" = "yes" -a -z "${LZ4_LIBS}" && \
  402. AC_MSG_ERROR([liblz4 required but not found. Try installing 'liblz4-dev' or 'lz4-devel'.])
  403. AC_ARG_WITH([bundled-libJudy],
  404. [AS_HELP_STRING([--with-bundled-libJudy],[Use the bundled version of Judy library (default is system-library)])],
  405. [
  406. AC_MSG_CHECKING(for libJudy in $withval)
  407. if test -f "externaldeps/libJudy/libJudy.a" -a -f "externaldeps/libJudy/Judy.h"; then
  408. LIBS_BACKUP="${LIBS}"
  409. LIBS="externaldeps/libJudy/libJudy.a"
  410. AC_LINK_IFELSE([AC_LANG_SOURCE([[#include "externaldeps/libJudy/Judy.h"
  411. int main (int argc, char **argv) {
  412. Pvoid_t PJLArray = (Pvoid_t) NULL;
  413. Word_t * PValue;
  414. Word_t Index;
  415. JLI(PValue, PJLArray, Index);
  416. }]])],
  417. [HAVE_libJudy_a="yes"],
  418. [HAVE_libJudy_a="no"])
  419. LIBS="${LIBS_BACKUP}"
  420. JUDY_LIBS="\$(abs_top_srcdir)/externaldeps/libJudy/libJudy.a"
  421. JUDY_CFLAGS="-I \$(abs_top_srcdir)/externaldeps/libJudy"
  422. AC_MSG_RESULT([$HAVE_libJudy_a])
  423. else
  424. libjudy_dir=""
  425. HAVE_libJudy_a="no"
  426. AC_MSG_RESULT([$HAVE_libJudy_a])
  427. fi
  428. ],
  429. [HAVE_libJudy_a="no"])
  430. if test "${HAVE_libJudy_a}" = "no"; then
  431. AC_CHECK_LIB(
  432. [Judy],
  433. [JudyLIns],
  434. [JUDY_LIBS="-lJudy"]
  435. )
  436. fi
  437. test "${enable_dbengine}" = "yes" -a -z "${JUDY_LIBS}" && \
  438. AC_MSG_ERROR([libJudy required but not found. Try installing 'libjudy-dev' or 'Judy-devel'.])
  439. test "${enable_https}" = "yes" -a -z "${SSL_LIBS}" && \
  440. AC_MSG_ERROR([OpenSSL required for HTTPS but not found. Try installing 'libssl-dev' or 'openssl-devel'.])
  441. test "${enable_dbengine}" = "yes" -a -z "${SSL_LIBS}" && \
  442. AC_MSG_ERROR([OpenSSL required for DBENGINE but not found. Try installing 'libssl-dev' or 'openssl-devel'.])
  443. AC_MSG_CHECKING([if netdata dbengine should be used])
  444. if test "${enable_dbengine}" != "no" -a "${UV_LIBS}" -a "${LZ4_LIBS}" -a "${JUDY_LIBS}" -a "${SSL_LIBS}"; then
  445. enable_dbengine="yes"
  446. AC_DEFINE([ENABLE_DBENGINE], [1], [netdata dbengine usability])
  447. OPTIONAL_LZ4_CFLAGS="${LZ4_CFLAGS}"
  448. OPTIONAL_LZ4_LIBS="${LZ4_LIBS}"
  449. OPTIONAL_JUDY_CFLAGS="${JUDY_CFLAGS}"
  450. OPTIONAL_JUDY_LIBS="${JUDY_LIBS}"
  451. OPTIONAL_SSL_CFLAGS="${SSL_CFLAGS}"
  452. OPTIONAL_SSL_LIBS="${SSL_LIBS}"
  453. else
  454. enable_dbengine="no"
  455. fi
  456. AC_MSG_RESULT([${enable_dbengine}])
  457. AM_CONDITIONAL([ENABLE_DBENGINE], [test "${enable_dbengine}" = "yes"])
  458. AC_MSG_CHECKING([if netdata https should be used])
  459. if test "${enable_https}" != "no" -a "${SSL_LIBS}"; then
  460. enable_https="yes"
  461. AC_DEFINE([ENABLE_HTTPS], [1], [netdata HTTPS usability])
  462. OPTIONAL_SSL_CFLAGS="${SSL_CFLAGS}"
  463. OPTIONAL_SSL_LIBS="${SSL_LIBS}"
  464. else
  465. enable_https="no"
  466. fi
  467. AC_MSG_RESULT([${enable_https}])
  468. AM_CONDITIONAL([ENABLE_HTTPS], [test "${enable_https}" = "yes"])
  469. AC_MSG_CHECKING([if netdata compression should be used])
  470. if test "${enable_compression}" != "no"; then
  471. if test "${LZ4_LIBS_FAST}"; then
  472. LIBS_BKP="${LIBS}"
  473. LIBS="${LZ4_LIBS_FAST}"
  474. AC_TRY_LINK(
  475. [ #include <lz4.h> ],
  476. [
  477. LZ4_stream_t* stream = LZ4_initStream(NULL, 0);
  478. ],
  479. [ enable_compression="yes"],
  480. [ enable_compression="no" ]
  481. )
  482. LIBS="${LIBS_BKP}"
  483. if test "${enable_compression}" == "yes"; then
  484. OPTIONAL_LZ4_LIBS="${LZ4_LIBS_FAST}"
  485. AC_DEFINE([ENABLE_COMPRESSION], [1], [netdata compression usability])
  486. fi
  487. else
  488. if test "${enable_compression}" == "yes"; then
  489. AC_MSG_ERROR([liblz4 with version >= 1.9.0 required to enable_compression. Try installing the required version of 'liblz4-dev' or 'liblz4-devel'.])
  490. enable_compression="no"
  491. fi
  492. enable_compression="no"
  493. fi
  494. else
  495. enable_compression="no"
  496. fi
  497. AC_MSG_RESULT([${enable_compression}])
  498. AM_CONDITIONAL([ENABLE_COMPRESSION], [test "${enable_compression}" = "yes"])
  499. # -----------------------------------------------------------------------------
  500. # JSON-C
  501. if test "${enable_jsonc}" != "no" -a -z "${JSONC_LIBS}"; then
  502. # Try and detect manual static build presence (from netdata-installer.sh)
  503. AC_MSG_CHECKING([if statically built json-c is present])
  504. HAVE_libjson_c_a="no"
  505. if test -f "externaldeps/jsonc/libjson-c.a"; then
  506. LIBS_BKP="${LIBS}"
  507. LIBS="externaldeps/jsonc/libjson-c.a"
  508. AC_LINK_IFELSE([AC_LANG_SOURCE([[#include "externaldeps/jsonc/json-c/json.h"
  509. int main (int argc, char **argv) {
  510. struct json_object *jobj;
  511. char *str = "{ \"msg-type\": \"random\" }";
  512. jobj = json_tokener_parse(str);
  513. json_object_get_type(jobj);
  514. }]])],
  515. [HAVE_libjson_c_a="yes"],
  516. [HAVE_libjson_c_a="no"])
  517. LIBS="${LIBS_BKP}"
  518. fi
  519. if test "${HAVE_libjson_c_a}" = "yes"; then
  520. AC_DEFINE([LINK_STATIC_JSONC], [1], [static json-c should be used])
  521. JSONC_LIBS="static"
  522. OPTIONAL_JSONC_STATIC_CFLAGS="-I \$(abs_top_srcdir)/externaldeps/jsonc"
  523. fi
  524. AC_MSG_RESULT([${HAVE_libjson_c_a}])
  525. fi
  526. AM_CONDITIONAL([LINK_STATIC_JSONC], [test "${JSONC_LIBS}" = "static"])
  527. test "${enable_jsonc}" = "yes" -a -z "${JSONC_LIBS}" && \
  528. AC_MSG_ERROR([JSON-C required but not found. Try installing 'libjson-c-dev' or 'json-c'.])
  529. AC_MSG_CHECKING([if json-c should be used])
  530. if test "${enable_jsonc}" != "no" -a "${JSONC_LIBS}"; then
  531. enable_jsonc="yes"
  532. AC_DEFINE([ENABLE_JSONC], [1], [netdata json-c usability])
  533. else
  534. enable_jsonc="no"
  535. fi
  536. AC_MSG_RESULT([${enable_jsonc}])
  537. AM_CONDITIONAL([ENABLE_JSONC], [test "${enable_jsonc}" = "yes"])
  538. # -----------------------------------------------------------------------------
  539. # compiler options
  540. AC_ARG_VAR([SSE_CANDIDATE], [C compiler flags for SSE])
  541. AS_CASE([$host_cpu],
  542. [i?86], [SSE_CANDIDATE="yes"]
  543. )
  544. AC_SUBST([SSE_CANDIDATE])
  545. if test "${SSE_CANDIDATE}" = "yes" -a "${enable_x86_sse}" = "yes"; then
  546. opt="-msse2 -mfpmath=sse"
  547. AX_CHECK_COMPILE_FLAG(${opt}, [CFLAGS="${CFLAGS} ${opt}"], [])
  548. fi
  549. if test "${GCC}" = "yes"; then
  550. AC_DEFINE_UNQUOTED([likely(x)], [__builtin_expect(!!(x), 1)], [gcc branch optimization])
  551. AC_DEFINE_UNQUOTED([unlikely(x)], [__builtin_expect(!!(x), 0)], [gcc branch optimization])
  552. else
  553. AC_DEFINE_UNQUOTED([likely(x)], [(x)], [gcc branch optimization])
  554. AC_DEFINE_UNQUOTED([unlikely(x)], [(x)], [gcc branch optimization])
  555. fi
  556. if test "${GCC}" = "yes"; then
  557. AC_DEFINE([__always_unused], [__attribute__((unused))], [gcc unused attribute])
  558. AC_DEFINE([__maybe_unused], [__attribute__((unused))], [gcc unused attribute])
  559. else
  560. AC_DEFINE([__always_unused], [], [dummy unused attribute])
  561. AC_DEFINE([__maybe_unused], [], [dummy unused attribute])
  562. fi
  563. if test "${enable_pedantic}" = "yes"; then
  564. enable_strict="yes"
  565. CFLAGS="${CFLAGS} -pedantic -Wall -Wextra -Wno-long-long"
  566. fi
  567. # -----------------------------------------------------------------------------
  568. # memory allocation library
  569. AC_MSG_CHECKING([for memory allocator])
  570. TS_CHECK_JEMALLOC
  571. if test "$has_jemalloc" = "1"; then
  572. AC_DEFINE([ENABLE_JEMALLOC], [1], [compile and link with jemalloc])
  573. AC_MSG_RESULT([jemalloc])
  574. else
  575. TS_CHECK_TCMALLOC
  576. if test "$has_tcmalloc" = "1"; then
  577. AC_DEFINE([ENABLE_TCMALLOC], [1], [compile and link with tcmalloc])
  578. AC_MSG_RESULT([tcmalloc])
  579. else
  580. AC_MSG_RESULT([system])
  581. AC_C_MALLOPT
  582. AC_C_MALLINFO
  583. fi
  584. fi
  585. # -----------------------------------------------------------------------------
  586. # libcap
  587. PKG_CHECK_MODULES(
  588. [LIBCAP],
  589. [libcap],
  590. [AC_CHECK_LIB([cap], [cap_get_proc, cap_set_proc],
  591. [AC_CHECK_HEADER(
  592. [sys/capability.h],
  593. [have_libcap=yes],
  594. [have_libcap=no]
  595. )],
  596. [have_libcap=no]
  597. )],
  598. [have_libcap=no]
  599. )
  600. test "${with_libcap}" = "yes" -a "${have_libcap}" != "yes" && AC_MSG_ERROR([libcap required but not found.])
  601. AC_MSG_CHECKING([if libcap should be used])
  602. if test "${with_libcap}" != "no" -a "${have_libcap}" = "yes"; then
  603. with_libcap="yes"
  604. AC_DEFINE([HAVE_CAPABILITY], [1], [libcap usability])
  605. OPTIONAL_LIBCAP_CFLAGS="${LIBCAP_CFLAGS}"
  606. OPTIONAL_LIBCAP_LIBS="${LIBCAP_LIBS}"
  607. else
  608. with_libcap="no"
  609. fi
  610. AC_MSG_RESULT([${with_libcap}])
  611. AM_CONDITIONAL([ENABLE_CAPABILITY], [test "${with_libcap}" = "yes"])
  612. # -----------------------------------------------------------------------------
  613. # ACLK
  614. bundled_proto_avail="no"
  615. if test "${with_bundled_protobuf}" != "no"; then
  616. AC_MSG_CHECKING([is bundled protobuf available])
  617. if test -f "externaldeps/protobuf/src/protoc"; then
  618. bundled_proto_avail="yes"
  619. fi
  620. AC_MSG_RESULT([${bundled_proto_avail}])
  621. if test "${with_bundled_protobuf}" == "yes" -a "${bundled_proto_avail}" != "yes"; then
  622. AC_MSG_ERROR([Bundled protobuf requested using --with-bundled-protobuf but it cannot be used/found])
  623. fi
  624. if test "${with_bundled_protobuf}" == "detect" -a "${bundled_proto_avail}" == "yes"; then
  625. with_bundled_protobuf="yes"
  626. fi
  627. fi
  628. if test "${with_bundled_protobuf}" != "yes"; then
  629. PKG_CHECK_MODULES(
  630. [PROTOBUF],
  631. [protobuf >= 3],
  632. [have_libprotobuf=yes],
  633. [have_libprotobuf=no]
  634. )
  635. AC_PATH_PROG([PROTOC], [protoc], [no])
  636. AS_IF(
  637. [test x"${PROTOC}" == x"no"],
  638. [have_protoc=no],
  639. [have_protoc=yes]
  640. )
  641. else
  642. AC_MSG_NOTICE([using bundled protobuf])
  643. AC_DEFINE([BUNDLED_PROTOBUF], [1], [Using a bundled copy of protobuf])
  644. PROTOC="\$(abs_top_srcdir)/externaldeps/protobuf/src/protoc"
  645. PROTOBUF_CFLAGS="-I \$(abs_top_srcdir)/externaldeps/protobuf/src"
  646. PROTOBUF_LIBS="\$(abs_top_srcdir)/externaldeps/protobuf/src/.libs/libprotobuf.a"
  647. have_libprotobuf="yes"
  648. have_protoc="yes"
  649. fi
  650. AC_PATH_PROG([CXX_BINARY], [${CXX}], [no])
  651. AS_IF(
  652. [test x"${CXX_BINARY}" == x"no"],
  653. [have_CXX_compiler=no],
  654. [have_CXX_compiler=yes]
  655. )
  656. if test "${have_libprotobuf}" == "yes" && test "${have_CXX_compiler}" == "yes"; then
  657. AC_DEFINE([HAVE_PROTOBUF], [1], [Protobuf is available])
  658. fi
  659. AC_MSG_CHECKING([if Cloud functionality should be enabled])
  660. AC_MSG_RESULT([${enable_cloud}])
  661. if test "$enable_cloud" != "no"; then
  662. AC_MSG_NOTICE([Checking if ACLK Next Generation can be built])
  663. can_enable_ng="yes"
  664. AC_MSG_CHECKING([if git submodules present for ACLK Next Generation])
  665. if test -f "mqtt_websockets/src/mqtt_wss_client.c"; then
  666. AC_MSG_RESULT([yes])
  667. else
  668. AC_MSG_RESULT([no])
  669. can_enable_ng="no"
  670. fi
  671. AC_MSG_CHECKING([if SSL available for ACLK Next Generation])
  672. if test -n "${SSL_LIBS}"; then
  673. AC_MSG_RESULT([yes])
  674. OPTIONAL_SSL_CFLAGS="${SSL_CFLAGS}"
  675. OPTIONAL_SSL_LIBS="${SSL_LIBS}"
  676. else
  677. AC_MSG_RESULT([no])
  678. fi
  679. AC_MSG_CHECKING([if JSON-C available for ACLK Next Generation])
  680. if test "$enable_jsonc" != "yes"; then
  681. AC_MSG_RESULT([no])
  682. can_enable_ng="no"
  683. else
  684. AC_MSG_RESULT([yes])
  685. fi
  686. AC_MSG_CHECKING([ACLK Next Generation can be built])
  687. AC_MSG_RESULT([${can_enable_ng}])
  688. if test "$can_enable_ng" = "no" -a "$enable_cloud" = "yes"; then
  689. AC_MSG_ERROR([You have requested --with-cloud but ACLK can't be built. See reasons in lines above])
  690. fi
  691. if test "$can_enable_ng" = "yes"; then
  692. enable_aclk="yes"
  693. AC_DEFINE([ENABLE_ACLK], [1], [netdata ACLK])
  694. OPTIONAL_ACLK_CFLAGS="-I \$(abs_top_srcdir)/mqtt_websockets/src/include -I \$(abs_top_srcdir)/mqtt_websockets/c-rbuf/include -I \$(abs_top_srcdir)/mqtt_websockets/MQTT-C/include"
  695. fi
  696. if test "$new_cloud_protocol" != "no"; then
  697. can_build_new_cloud_protocol="yes"
  698. AC_MSG_CHECKING([if protobuf available for New Cloud Protocol])
  699. if test "${have_libprotobuf}" != "yes"; then
  700. AC_MSG_RESULT([no])
  701. can_build_new_cloud_protocol="no"
  702. else
  703. AC_MSG_RESULT([yes])
  704. fi
  705. AC_MSG_CHECKING([if protoc available for New Cloud Protocol])
  706. if test "${have_protoc}" != "yes"; then
  707. AC_MSG_RESULT([no])
  708. can_build_new_cloud_protocol="no"
  709. else
  710. AC_MSG_RESULT([yes])
  711. fi
  712. AC_MSG_CHECKING([if C++ compiler available for New Cloud Protocol])
  713. if test "${have_CXX_compiler}" != "yes"; then
  714. AC_MSG_RESULT([no])
  715. can_build_new_cloud_protocol="no"
  716. else
  717. AC_MSG_RESULT([yes])
  718. fi
  719. AC_MSG_CHECKING([ACLK Next Generation can support New Cloud protocol])
  720. AC_MSG_RESULT([${can_build_new_cloud_protocol}])
  721. if test "$new_cloud_protocol" = "yes" -a "$can_build_new_cloud_protocol" != "yes"; then
  722. AC_MSG_ERROR([Requested new cloud protocol support but it can't be build])
  723. fi
  724. if test "$can_build_new_cloud_protocol" = "yes"; then
  725. new_cloud_protocol="yes"
  726. AC_DEFINE([ENABLE_NEW_CLOUD_PROTOCOL], [1], [New protobuf based Netdata Cloud Protocol Support])
  727. OPTIONAL_ACLK_CFLAGS="${OPTIONAL_ACLK_CFLAGS} -I \$(abs_top_srcdir)/aclk/aclk-schemas"
  728. OPTIONAL_PROTOBUF_CFLAGS="${PROTOBUF_CFLAGS}"
  729. CXX11FLAG="-std=c++11"
  730. OPTIONAL_PROTOBUF_LIBS="${PROTOBUF_LIBS}"
  731. fi
  732. fi
  733. fi
  734. if test "$enable_cloud" = "yes" -a "$enable_aclk" != "yes"; then
  735. AC_MSG_ERROR([ACLK can't be built but --enable-cloud was requested])
  736. fi
  737. AC_SUBST([enable_cloud])
  738. AC_SUBST([enable_aclk])
  739. AM_CONDITIONAL([ENABLE_ACLK], [test "${enable_aclk}" = "yes"])
  740. AM_CONDITIONAL([ENABLE_NEW_CLOUD_PROTOCOL], [test "${can_build_new_cloud_protocol}" = "yes"])
  741. # -----------------------------------------------------------------------------
  742. # apps.plugin
  743. AC_MSG_CHECKING([if apps.plugin should be enabled])
  744. if test "${build_target}" != "macos"; then
  745. AC_DEFINE([ENABLE_APPS_PLUGIN], [1], [apps.plugin])
  746. enable_plugin_apps="yes"
  747. else
  748. enable_plugin_apps="no"
  749. fi
  750. AC_MSG_RESULT([${enable_plugin_apps}])
  751. AM_CONDITIONAL([ENABLE_PLUGIN_APPS], [test "${enable_plugin_apps}" = "yes"])
  752. # -----------------------------------------------------------------------------
  753. # freeipmi.plugin - libipmimonitoring
  754. PKG_CHECK_MODULES(
  755. [IPMIMONITORING],
  756. [libipmimonitoring],
  757. [AC_CHECK_LIB([ipmimonitoring], [
  758. ipmi_monitoring_sensor_readings_by_record_id,
  759. ipmi_monitoring_sensor_readings_by_sensor_type,
  760. ipmi_monitoring_sensor_read_sensor_number,
  761. ipmi_monitoring_sensor_read_sensor_name,
  762. ipmi_monitoring_sensor_read_sensor_state,
  763. ipmi_monitoring_sensor_read_sensor_units,
  764. ipmi_monitoring_sensor_iterator_next,
  765. ipmi_monitoring_ctx_sensor_config_file,
  766. ipmi_monitoring_ctx_sdr_cache_directory,
  767. ipmi_monitoring_ctx_errormsg,
  768. ipmi_monitoring_ctx_create
  769. ],
  770. [AC_CHECK_HEADER(
  771. [ipmi_monitoring.h],
  772. [AC_CHECK_HEADER(
  773. [ipmi_monitoring_bitmasks.h],
  774. [have_ipmimonitoring=yes],
  775. [have_ipmimonitoring=no]
  776. )],
  777. [have_ipmimonitoring=no]
  778. )],
  779. [have_ipmimonitoring=no]
  780. )],
  781. [have_ipmimonitoring=no]
  782. )
  783. test "${enable_plugin_freeipmi}" = "yes" -a "${have_ipmimonitoring}" != "yes" && \
  784. AC_MSG_ERROR([ipmimonitoring required but not found. Try installing 'libipmimonitoring-dev' or 'libipmimonitoring-devel'])
  785. AC_MSG_CHECKING([if freeipmi.plugin should be enabled])
  786. if test "${enable_plugin_freeipmi}" != "no" -a "${have_ipmimonitoring}" = "yes"; then
  787. enable_plugin_freeipmi="yes"
  788. AC_DEFINE([HAVE_FREEIPMI], [1], [ipmimonitoring usability])
  789. OPTIONAL_IPMIMONITORING_CFLAGS="${IPMIMONITORING_CFLAGS}"
  790. OPTIONAL_IPMIMONITORING_LIBS="${IPMIMONITORING_LIBS}"
  791. else
  792. enable_plugin_freeipmi="no"
  793. fi
  794. AC_MSG_RESULT([${enable_plugin_freeipmi}])
  795. AM_CONDITIONAL([ENABLE_PLUGIN_FREEIPMI], [test "${enable_plugin_freeipmi}" = "yes"])
  796. # -----------------------------------------------------------------------------
  797. # cups.plugin - libcups
  798. # Only check most recently added method of cups
  799. AC_CHECK_LIB([cups], [httpConnect2],
  800. [AC_CHECK_HEADER(
  801. [cups/cups.h],
  802. [have_cups=yes],
  803. [have_cups=no]
  804. )],
  805. [have_cups=no]
  806. )
  807. test "${enable_plugin_cups}" = "yes" -a "${have_cups}" != "yes" && \
  808. AC_MSG_ERROR([cups required but not found. Try installing 'cups'])
  809. AC_ARG_WITH([cups-config],
  810. [AS_HELP_STRING([--with-cups-config=path], [Specify path to cups-config executable.])],
  811. [with_cups_config="$withval"],
  812. [with_cups_config=system]
  813. )
  814. AS_IF([test "x$with_cups_config" != "xsystem"], [
  815. CUPSCONFIG=$with_cups_config
  816. ], [
  817. AC_PATH_TOOL(CUPSCONFIG, [cups-config])
  818. AS_IF([test -z "$CUPSCONFIG"], [
  819. have_cups=no
  820. ])
  821. ])
  822. AC_MSG_CHECKING([if cups.plugin should be enabled])
  823. if test "${enable_plugin_cups}" != "no" -a "${have_cups}" = "yes"; then
  824. enable_plugin_cups="yes"
  825. AC_DEFINE([HAVE_CUPS], [1], [cups usability])
  826. CUPS_CFLAGS="${CUPS_CFLAGS} `$CUPSCONFIG --cflags`"
  827. CUPS_LIBS="${CUPS_LIBS} `$CUPSCONFIG --libs`"
  828. OPTIONAL_CUPS_CFLAGS="${CUPS_CFLAGS}"
  829. OPTIONAL_CUPS_LIBS="${CUPS_LIBS}"
  830. else
  831. enable_plugin_cups="no"
  832. fi
  833. AC_MSG_RESULT([${enable_plugin_cups}])
  834. AM_CONDITIONAL([ENABLE_PLUGIN_CUPS], [test "${enable_plugin_cups}" = "yes"])
  835. # -----------------------------------------------------------------------------
  836. # nfacct.plugin - libmnl, libnetfilter_acct
  837. AC_CHECK_HEADER(
  838. [linux/netfilter/nfnetlink_conntrack.h],
  839. [AC_CHECK_DECL(
  840. [CTA_STATS_MAX],
  841. [have_nfnetlink_conntrack=yes],
  842. [have_nfnetlink_conntrack=no],
  843. [#include <linux/netfilter/nfnetlink_conntrack.h>]
  844. )],
  845. [have_nfnetlink_conntrack=no]
  846. )
  847. PKG_CHECK_MODULES(
  848. [NFACCT],
  849. [libnetfilter_acct],
  850. [AC_CHECK_LIB(
  851. [netfilter_acct],
  852. [nfacct_alloc],
  853. [have_libnetfilter_acct=yes],
  854. [have_libnetfilter_acct=no]
  855. )],
  856. [have_libnetfilter_acct=no]
  857. )
  858. PKG_CHECK_MODULES(
  859. [LIBMNL],
  860. [libmnl],
  861. [AC_CHECK_LIB(
  862. [mnl],
  863. [mnl_socket_open],
  864. [have_libmnl=yes],
  865. [have_libmnl=no]
  866. )],
  867. [have_libmnl=no]
  868. )
  869. test "${enable_plugin_nfacct}" = "yes" -a "${have_nfnetlink_conntrack}" != "yes" && \
  870. AC_MSG_ERROR([nfnetlink_conntrack.h required but not found or too old])
  871. test "${enable_plugin_nfacct}" = "yes" -a "${have_libnetfilter_acct}" != "yes" && \
  872. AC_MSG_ERROR([netfilter_acct required but not found])
  873. test "${enable_plugin_nfacct}" = "yes" -a "${have_libmnl}" != "yes" && \
  874. AC_MSG_ERROR([libmnl required but not found. Try installing 'libmnl-dev' or 'libmnl-devel'])
  875. AC_MSG_CHECKING([if nfacct.plugin should be enabled])
  876. if test "${enable_plugin_nfacct}" != "no" -a "${have_libnetfilter_acct}" = "yes" \
  877. -a "${have_libmnl}" = "yes" \
  878. -a "${have_nfnetlink_conntrack}" = "yes"; then
  879. enable_plugin_nfacct="yes"
  880. AC_DEFINE([HAVE_NFACCT], [1], [netfilter accounting usability])
  881. OPTIONAL_NFACCT_CFLAGS="${NFACCT_CFLAGS} ${LIBMNL_CFLAGS}"
  882. OPTIONAL_NFACCT_LIBS="${NFACCT_LIBS} ${LIBMNL_LIBS}"
  883. else
  884. enable_plugin_nfacct="no"
  885. fi
  886. AC_MSG_RESULT([${enable_plugin_nfacct}])
  887. AM_CONDITIONAL([ENABLE_PLUGIN_NFACCT], [test "${enable_plugin_nfacct}" = "yes"])
  888. # -----------------------------------------------------------------------------
  889. # xenstat.plugin - libxenstat
  890. PKG_CHECK_MODULES(
  891. [YAJL],
  892. [yajl],
  893. [AC_CHECK_LIB(
  894. [yajl],
  895. [yajl_tree_get],
  896. [have_libyajl=yes],
  897. [have_libyajl=no]
  898. )],
  899. [have_libyajl=no]
  900. )
  901. AC_CHECK_LIB(
  902. [xenstat],
  903. [xenstat_init],
  904. [AC_CHECK_HEADER(
  905. [xenstat.h],
  906. [have_libxenstat=yes],
  907. [have_libxenstat=no]
  908. )],
  909. [have_libxenstat=no],
  910. [-lyajl]
  911. )
  912. PKG_CHECK_MODULES(
  913. [XENLIGHT],
  914. [xenlight],
  915. [AC_CHECK_LIB(
  916. [xenlight],
  917. [libxl_domain_info],
  918. [AC_CHECK_HEADER(
  919. [libxl.h],
  920. [have_libxenlight=yes],
  921. [have_libxenlight=no]
  922. )],
  923. [have_libxenlight=no]
  924. )],
  925. [have_libxenlight=no]
  926. )
  927. test "${enable_plugin_xenstat}" = "yes" -a "${have_libxenstat}" != "yes" && \
  928. AC_MSG_ERROR([libxenstat required but not found. try installing 'xen-dom0-libs-devel'])
  929. test "${enable_plugin_xenstat}" = "yes" -a "${have_libxenlight}" != "yes" && \
  930. AC_MSG_ERROR([libxenlight required but not found. try installing 'xen-dom0-libs-devel'])
  931. test "${enable_plugin_xenstat}" = "yes" -a "${have_libyajl}" != "yes" && \
  932. AC_MSG_ERROR([libyajl required but not found. Try installing 'yajl-devel'])
  933. AC_MSG_CHECKING([if xenstat.plugin should be enabled])
  934. if test "${enable_plugin_xenstat}" != "no" -a "${have_libxenstat}" = "yes" -a "${have_libxenlight}" = "yes" -a "${have_libyajl}" = "yes"; then
  935. enable_plugin_xenstat="yes"
  936. AC_DEFINE([HAVE_LIBXENSTAT], [1], [libxenstat usability])
  937. OPTIONAL_XENSTAT_CFLAGS="${XENLIGHT_CFLAGS} ${YAJL_CFLAGS}"
  938. OPTIONAL_XENSTAT_LIBS="-lxenstat ${XENLIGHT_LIBS} ${YAJL_LIBS}"
  939. else
  940. enable_plugin_xenstat="no"
  941. fi
  942. AC_MSG_RESULT([${enable_plugin_xenstat}])
  943. AM_CONDITIONAL([ENABLE_PLUGIN_XENSTAT], [test "${enable_plugin_xenstat}" = "yes"])
  944. if test "${enable_plugin_xenstat}" == "yes"; then
  945. AC_MSG_CHECKING([for xenstat_vbd_error in -lxenstat])
  946. AC_TRY_LINK(
  947. [ #include <xenstat.h> ],
  948. [
  949. xenstat_vbd * vbd;
  950. int out = xenstat_vbd_error(vbd);
  951. ],
  952. [
  953. have_xenstat_vbd_error=yes
  954. AC_DEFINE([HAVE_XENSTAT_VBD_ERROR], [1], [xenstat_vbd_error usability])
  955. ],
  956. [ have_xenstat_vbd_error=no ]
  957. )
  958. AC_MSG_RESULT([${have_xenstat_vbd_error}])
  959. fi
  960. # -----------------------------------------------------------------------------
  961. # perf.plugin
  962. AC_CHECK_HEADER(
  963. [linux/perf_event.h],
  964. [AC_CHECK_DECL(
  965. [PERF_COUNT_HW_REF_CPU_CYCLES],
  966. [have_perf_event=yes],
  967. [have_perf_event=no],
  968. [#include <linux/perf_event.h>]
  969. )],
  970. [have_perf_event=no]
  971. )
  972. AC_MSG_CHECKING([if perf.plugin should be enabled])
  973. if test "${build_target}" == "linux" -a "${have_perf_event}" = "yes"; then
  974. AC_DEFINE([ENABLE_PERF_PLUGIN], [1], [perf.plugin])
  975. enable_plugin_perf="yes"
  976. else
  977. enable_plugin_perf="no"
  978. fi
  979. AC_MSG_RESULT([${enable_plugin_perf}])
  980. AM_CONDITIONAL([ENABLE_PLUGIN_PERF], [test "${enable_plugin_perf}" = "yes"])
  981. # -----------------------------------------------------------------------------
  982. # gtest/gmock
  983. AC_MSG_CHECKING([if gtest and gmock can be found])
  984. PKG_CHECK_MODULES([GTEST], [gtest], [have_gtest=yes], [have_gtest=no])
  985. PKG_CHECK_MODULES([GMOCK], [gmock], [have_gmock=yes], [have_gmock=no])
  986. if test "${have_gtest}" = "yes" -a "${have_gmock}" = "yes"; then
  987. OPTIONAL_GTEST_CFLAGS="${GTEST_CFLAGS} ${GMOCK_CFLAGS}"
  988. OPTIONAL_GTEST_LIBS="${GTEST_LIBS} ${GMOCK_LIBS}"
  989. have_gtest="yes"
  990. else
  991. have_gtest="no"
  992. fi
  993. # -----------------------------------------------------------------------------
  994. # ml - anomaly detection
  995. # Check if uuid is available. Fail if ML was explicitly requested.
  996. if test "${enable_ml}" = "yes" -a "${have_uuid}" != "yes"; then
  997. AC_MSG_ERROR([You have explicitly requested --enable-ml functionality but libuuid can not be found."])
  998. fi
  999. # Check if submodules have not been fetched. Fail if ML was explicitly requested.
  1000. AC_MSG_CHECKING([if git submodules are present for machine learning functionality])
  1001. if test -f "ml/kmeans/dlib/dlib/all/source.cpp" -a -f "ml/json/single_include/nlohmann/json.hpp"; then
  1002. AC_MSG_RESULT([yes])
  1003. have_ml_submodules="yes"
  1004. else
  1005. AC_MSG_RESULT([no])
  1006. have_ml_submodules="no"
  1007. fi
  1008. if test "${enable_ml}" = "yes" -a "${have_ml_submodules}" = "no"; then
  1009. AC_MSG_ERROR([You have explicitly requested --enable-ml functionality but it cannot be built because the required git submodules are missing.])
  1010. fi
  1011. # Check if C++ toolchain does not support C++11. Fail if ML was explicitly requested.
  1012. AC_LANG_PUSH([C++])
  1013. AX_CHECK_COMPILE_FLAG([-std=c++11], [have_cxx11=yes], [have_cxx11=no])
  1014. AC_LANG_POP([C++])
  1015. # PPC64LE needs -std=gnu++11 in order to build dlib. However, the rest of
  1016. # the agent's components use and have been tested only with -std=c++11.
  1017. # Skip ML compilation on that CPU until we reorganize and test the C++ flags.
  1018. if test "${host_cpu}" = "powerpc64le"; then
  1019. have_cxx11="no"
  1020. fi
  1021. if test "${enable_ml}" = "yes" -a "${have_cxx11}" = "no"; then
  1022. AC_MSG_ERROR([You have explicitly requested --enable-ml functionality but it cannot be built without a C++11 toolchain.])
  1023. else
  1024. CXX11FLAG="$CXX11FLAG -std=c++11"
  1025. fi
  1026. # Decide if we should build ML
  1027. if test "${enable_ml}" != "no" -a "${have_ml_submodules}" = "yes" -a "${have_cxx11}" = "yes" -a "${have_uuid}" = "yes"; then
  1028. build_ml="yes"
  1029. else
  1030. build_ml="no"
  1031. fi
  1032. AM_CONDITIONAL([ENABLE_ML], [test "${build_ml}" = "yes"])
  1033. if test "${build_ml}" = "yes"; then
  1034. AC_DEFINE([ENABLE_ML], [1], [anomaly detection usability])
  1035. OPTIONAL_ML_CFLAGS="-DDLIB_NO_GUI_SUPPORT -I \$(abs_top_srcdir)/ml/kmeans/dlib"
  1036. OPTIONAL_ML_LIBS=""
  1037. fi
  1038. # Decide if we should build ML tests.
  1039. if test "${build_ml}" = "yes" -a "${enable_ml_tests}" = "yes" -a "${have_gtest}" = "yes"; then
  1040. build_ml_tests="yes"
  1041. else
  1042. build_ml_tests="no"
  1043. fi
  1044. AM_CONDITIONAL([ENABLE_ML_TESTS], [test "${build_ml_tests}" = "yes"])
  1045. if test "${build_ml_tests}" = "yes"; then
  1046. AC_DEFINE([ENABLE_ML_TESTS], [1], [anomaly detection tests])
  1047. OPTIONAL_ML_TESTS_CFLAGS="${OPTIONAL_GTEST_CFLAGS}"
  1048. OPTIONAL_ML_TESTS_LIBS="${OPTIONAL_GTEST_LIBS}"
  1049. fi
  1050. # -----------------------------------------------------------------------------
  1051. # ebpf.plugin
  1052. if test "${build_target}" = "linux" -a "${enable_ebpf}" != "no"; then
  1053. PKG_CHECK_MODULES(
  1054. [LIBELF],
  1055. [libelf],
  1056. [have_libelf=yes],
  1057. [have_libelf=no]
  1058. )
  1059. AC_CHECK_TYPE(
  1060. [struct bpf_prog_info],
  1061. [have_bpf=yes],
  1062. [have_bpf=no],
  1063. [#include <linux/bpf.h>]
  1064. )
  1065. AC_CHECK_FILE(
  1066. externaldeps/libbpf/libbpf.a,
  1067. [have_libbpf=yes],
  1068. [have_libbpf=no]
  1069. )
  1070. AC_MSG_CHECKING([if ebpf.plugin should be enabled])
  1071. if test "${have_libelf}" = "yes" -a \
  1072. "${have_bpf}" = "yes" -a \
  1073. "${have_libbpf}" = "yes"; then
  1074. OPTIONAL_BPF_CFLAGS="${LIBELF_CFLAGS} -I \$(abs_top_srcdir)/externaldeps/libbpf/include"
  1075. OPTIONAL_BPF_LIBS="\$(abs_top_srcdir)/externaldeps/libbpf/libbpf.a ${LIBELF_LIBS}"
  1076. AC_DEFINE([HAVE_LIBBPF], [1], [libbpf usability])
  1077. enable_ebpf="yes"
  1078. else
  1079. enable_ebpf="no"
  1080. fi
  1081. else
  1082. enable_ebpf="no"
  1083. fi
  1084. AC_MSG_RESULT([${enable_ebpf}])
  1085. AM_CONDITIONAL([ENABLE_PLUGIN_EBPF], [test "${enable_ebpf}" = "yes"])
  1086. # -----------------------------------------------------------------------------
  1087. # slabinfo.plugin
  1088. AC_MSG_CHECKING([if slabinfo.plugin should be enabled])
  1089. if test "${build_target}" == "linux"; then
  1090. AC_DEFINE([ENABLE_SLABINFO], [1], [slabinfo plugin])
  1091. enable_plugin_slabinfo="yes"
  1092. else
  1093. enable_plugin_slabinfo="no"
  1094. fi
  1095. AC_MSG_RESULT([${enable_plugin_slabinfo}])
  1096. AM_CONDITIONAL([ENABLE_PLUGIN_SLABINFO], [test "${enable_plugin_slabinfo}" = "yes"])
  1097. # -----------------------------------------------------------------------------
  1098. # AWS Kinesis backend - libaws-cpp-sdk-kinesis, libaws-cpp-sdk-core, libssl, libcrypto, libcurl
  1099. PKG_CHECK_MODULES(
  1100. [LIBCRYPTO],
  1101. [libcrypto],
  1102. [AC_CHECK_LIB(
  1103. [crypto],
  1104. [CRYPTO_new_ex_data],
  1105. [have_libcrypto=yes],
  1106. [have_libcrypto=no]
  1107. )],
  1108. [have_libcrypto=no]
  1109. )
  1110. PKG_CHECK_MODULES(
  1111. [LIBSSL],
  1112. [libssl],
  1113. [AC_CHECK_LIB(
  1114. [ssl],
  1115. [SSL_connect],
  1116. [have_libssl=yes],
  1117. [have_libssl=no]
  1118. )],
  1119. [have_libssl=no]
  1120. )
  1121. PKG_CHECK_MODULES(
  1122. [LIBCURL],
  1123. [libcurl],
  1124. [AC_CHECK_LIB(
  1125. [curl],
  1126. [curl_easy_init],
  1127. [have_libcurl=yes],
  1128. [have_libcurl=no]
  1129. )],
  1130. [have_libcurl=no]
  1131. )
  1132. PKG_CHECK_MODULES(
  1133. [AWS_CPP_SDK_CORE],
  1134. [aws-cpp-sdk-core],
  1135. [have_libaws_cpp_sdk_core=yes],
  1136. [have_libaws_cpp_sdk_core=no]
  1137. )
  1138. PKG_CHECK_MODULES(
  1139. [AWS_CPP_SDK_KINESIS],
  1140. [aws-cpp-sdk-kinesis],
  1141. [have_libaws_cpp_sdk_kinesis=yes],
  1142. [have_libaws_cpp_sdk_kinesis=no]
  1143. )
  1144. test "${enable_backend_kinesis}" = "yes" -a "${have_libaws_cpp_sdk_kinesis}" != "yes" && \
  1145. AC_MSG_ERROR([libaws-cpp-sdk-kinesis required but not found. try installing AWS C++ SDK])
  1146. test "${enable_backend_kinesis}" = "yes" -a "${have_libaws_cpp_sdk_core}" != "yes" && \
  1147. AC_MSG_ERROR([libaws-cpp-sdk-core required but not found. try installing AWS C++ SDK])
  1148. test "${enable_backend_kinesis}" = "yes" -a "${have_libcurl}" != "yes" && \
  1149. AC_MSG_ERROR([libcurl required but not found])
  1150. test "${enable_backend_kinesis}" = "yes" -a "${have_libssl}" != "yes" && \
  1151. AC_MSG_ERROR([libssl required but not found])
  1152. test "${enable_backend_kinesis}" = "yes" -a "${have_libcrypto}" != "yes" && \
  1153. AC_MSG_ERROR([libcrypto required but not found])
  1154. AC_MSG_CHECKING([if kinesis backend should be enabled])
  1155. if test "${enable_backend_kinesis}" != "no" -a "${have_libaws_cpp_sdk_kinesis}" = "yes" \
  1156. -a "${have_libaws_cpp_sdk_core}" = "yes" \
  1157. -a "${have_libcurl}" = "yes" \
  1158. -a "${have_libssl}" = "yes" \
  1159. -a "${have_libcrypto}" = "yes"; then
  1160. enable_backend_kinesis="yes"
  1161. AC_DEFINE([HAVE_KINESIS], [1], [libaws-cpp-sdk-kinesis usability])
  1162. OPTIONAL_KINESIS_CFLAGS="${LIBCRYPTO_CFLAGS} ${LIBSSL_CFLAGS} ${LIBCURL_CFLAGS}"
  1163. CXX11FLAG="${AWS_CPP_SDK_KINESIS_CFLAGS} ${AWS_CPP_SDK_CORE_CFLAGS}"
  1164. OPTIONAL_KINESIS_LIBS="${AWS_CPP_SDK_KINESIS_LIBS} ${AWS_CPP_SDK_CORE_LIBS} \
  1165. ${LIBCRYPTO_LIBS} ${LIBSSL_LIBS} ${LIBCURL_LIBS}"
  1166. else
  1167. enable_backend_kinesis="no"
  1168. fi
  1169. AC_MSG_RESULT([${enable_backend_kinesis}])
  1170. AM_CONDITIONAL([ENABLE_BACKEND_KINESIS], [test "${enable_backend_kinesis}" = "yes"])
  1171. # -----------------------------------------------------------------------------
  1172. # Pub/Sub exporting connector - googleapis
  1173. PKG_CHECK_MODULES(
  1174. [GRPC],
  1175. [grpc],
  1176. [have_libgrpc=yes],
  1177. [have_libgrpc=no]
  1178. )
  1179. if test "${enable_exporting_pubsub}" != "no"; then
  1180. PKG_CHECK_MODULES(
  1181. [PUBSUB],
  1182. [google_cloud_cpp_pubsub_protos],
  1183. [have_pubsub_protos=yes],
  1184. [have_pubsub_protos=no]
  1185. )
  1186. fi
  1187. AC_PATH_PROG([CXX_BINARY], [${CXX}], [no])
  1188. AS_IF(
  1189. [test x"${CXX_BINARY}" == x"no"],
  1190. [have_CXX_compiler=no],
  1191. [have_CXX_compiler=yes]
  1192. )
  1193. test "${enable_pubsub}" = "yes" -a "${have_grpc}" != "yes" && \
  1194. AC_MSG_ERROR([libgrpc required but not found. try installing grpc])
  1195. test "${enable_pubsub}" = "yes" -a "${have_pubsub_protos}" != "yes" && \
  1196. AC_MSG_ERROR([libgoogleapis_cpp_pubsub_protos required but not found. try installing googleapis])
  1197. test "${enable_backend_prometheus_remote_write}" = "yes" -a "${have_CXX_compiler}" != "yes" && \
  1198. AC_MSG_ERROR([C++ compiler required but not found. try installing g++])
  1199. AC_MSG_CHECKING([if pubsub exporting connector should be enabled])
  1200. if test "${enable_exporting_pubsub}" != "no" -a "${have_pubsub_protos}" = "yes" -a "${have_CXX_compiler}" = "yes"; then
  1201. enable_exporting_pubsub="yes"
  1202. AC_DEFINE([ENABLE_EXPORTING_PUBSUB], [1], [Pub/Sub API usability])
  1203. OPTIONAL_PUBSUB_CFLAGS="${GRPC_CFLAGS} ${PUBSUB_CFLAGS}"
  1204. CXX11FLAG="-std=c++11"
  1205. OPTIONAL_PUBSUB_LIBS="${GRPC_LIBS} ${PUBSUB_LIBS}"
  1206. else
  1207. enable_pubsub="no"
  1208. fi
  1209. AC_MSG_RESULT([${enable_exporting_pubsub}])
  1210. AM_CONDITIONAL([ENABLE_EXPORTING_PUBSUB], [test "${enable_exporting_pubsub}" = "yes"])
  1211. # -----------------------------------------------------------------------------
  1212. # Prometheus remote write backend - libprotobuf, libsnappy, protoc
  1213. AC_MSG_CHECKING([for snappy::RawCompress in -lsnappy])
  1214. AC_LANG_SAVE
  1215. AC_LANG_CPLUSPLUS
  1216. save_LIBS="${LIBS}"
  1217. LIBS="-lsnappy"
  1218. save_CXXFLAGS="${CXXFLAGS}"
  1219. CXXFLAGS="${CXXFLAGS} -std=c++11"
  1220. AC_TRY_LINK(
  1221. [
  1222. #include <stdlib.h>
  1223. #include <snappy.h>
  1224. ],
  1225. [
  1226. const char *input = "test";
  1227. size_t compressed_length;
  1228. char *buffer = (char *)malloc(5 * sizeof(char));
  1229. snappy::RawCompress(input, 4, buffer, &compressed_length);
  1230. free(buffer);
  1231. ],
  1232. [
  1233. have_libsnappy=yes
  1234. SNAPPY_CFLAGS=""
  1235. SNAPPY_LIBS="-lsnappy"
  1236. ],
  1237. [have_libsnappy=no]
  1238. )
  1239. LIBS="${save_LIBS}"
  1240. CXXFLAGS="${save_CXXFLAGS}"
  1241. AC_LANG_RESTORE
  1242. AC_MSG_RESULT([${have_libsnappy}])
  1243. test "${enable_backend_prometheus_remote_write}" = "yes" -a "${have_libprotobuf}" != "yes" && \
  1244. AC_MSG_ERROR([libprotobuf required but not found. try installing protobuf])
  1245. test "${enable_backend_prometheus_remote_write}" = "yes" -a "${have_libsnappy}" != "yes" && \
  1246. AC_MSG_ERROR([libsnappy required but not found. try installing snappy])
  1247. test "${enable_backend_prometheus_remote_write}" = "yes" -a "${have_protoc}" != "yes" && \
  1248. AC_MSG_ERROR([protoc compiler required but not found. try installing protobuf])
  1249. test "${enable_backend_prometheus_remote_write}" = "yes" -a "${have_CXX_compiler}" != "yes" && \
  1250. AC_MSG_ERROR([C++ compiler required but not found. try installing g++])
  1251. AC_MSG_CHECKING([if prometheus remote write backend should be enabled])
  1252. if test "${enable_backend_prometheus_remote_write}" != "no" -a "${have_libprotobuf}" = "yes" -a "${have_libsnappy}" = "yes" \
  1253. -a "${have_protoc}" = "yes" -a "${have_CXX_compiler}" = "yes"; then
  1254. enable_backend_prometheus_remote_write="yes"
  1255. AC_DEFINE([ENABLE_PROMETHEUS_REMOTE_WRITE], [1], [Prometheus remote write API usability])
  1256. OPTIONAL_PROMETHEUS_REMOTE_WRITE_CFLAGS="${SNAPPY_CFLAGS} -I \$(abs_top_srcdir)/exporting/prometheus/remote_write"
  1257. CXX11FLAG="-std=c++11"
  1258. OPTIONAL_PROMETHEUS_REMOTE_WRITE_LIBS="${SNAPPY_LIBS}"
  1259. OPTIONAL_PROTOBUF_CFLAGS="${PROTOBUF_CFLAGS}"
  1260. OPTIONAL_PROTOBUF_LIBS="${PROTOBUF_LIBS}"
  1261. else
  1262. enable_backend_prometheus_remote_write="no"
  1263. fi
  1264. AC_MSG_RESULT([${enable_backend_prometheus_remote_write}])
  1265. AM_CONDITIONAL([ENABLE_BACKEND_PROMETHEUS_REMOTE_WRITE], [test "${enable_backend_prometheus_remote_write}" = "yes"])
  1266. # -----------------------------------------------------------------------------
  1267. # MongoDB backend - libmongoc
  1268. PKG_CHECK_MODULES(
  1269. [LIBMONGOC],
  1270. [libmongoc-1.0 >= 1.7],
  1271. [have_libmongoc=yes],
  1272. [have_libmongoc=no]
  1273. )
  1274. test "${enable_backend_mongodb}" = "yes" -a "${have_libmongoc}" != "yes" && \
  1275. AC_MSG_ERROR([libmongoc required but not found. Try installing `mongoc`.])
  1276. AC_MSG_CHECKING([if mongodb backend should be enabled])
  1277. if test "${enable_backend_mongodb}" != "no" -a "${have_libmongoc}" = "yes"; then
  1278. enable_backend_mongodb="yes"
  1279. AC_DEFINE([HAVE_MONGOC], [1], [libmongoc usability])
  1280. OPTIONAL_MONGOC_CFLAGS="${LIBMONGOC_CFLAGS}"
  1281. OPTIONAL_MONGOC_LIBS="${LIBMONGOC_LIBS}"
  1282. else
  1283. enable_backend_mongodb="no"
  1284. fi
  1285. AC_MSG_RESULT([${enable_backend_mongodb}])
  1286. AM_CONDITIONAL([ENABLE_BACKEND_MONGODB], [test "${enable_backend_mongodb}" = "yes"])
  1287. # -----------------------------------------------------------------------------
  1288. # check for setns() - cgroup-network
  1289. AC_CHECK_FUNC([setns])
  1290. AC_MSG_CHECKING([if cgroup-network can be enabled])
  1291. if test "$ac_cv_func_setns" = "yes" ; then
  1292. have_setns="yes"
  1293. AC_DEFINE([HAVE_SETNS], [1], [Define 1 if you have setns() function])
  1294. else
  1295. have_setns="no"
  1296. fi
  1297. AC_MSG_RESULT([${have_setns}])
  1298. AM_CONDITIONAL([ENABLE_PLUGIN_CGROUP_NETWORK], [test "${have_setns}" = "yes"])
  1299. # -----------------------------------------------------------------------------
  1300. # Link-Time-Optimization
  1301. if test "${enable_lto}" != "no"; then
  1302. opt="-flto"
  1303. AX_CHECK_COMPILE_FLAG(${opt}, [have_lto=yes], [have_lto=no])
  1304. fi
  1305. if test "${have_lto}" = "yes"; then
  1306. oCFLAGS="${CFLAGS}"
  1307. CFLAGS="${CFLAGS} -flto"
  1308. ac_cv_c_lto_cross_compile="${enable_lto}"
  1309. test "${ac_cv_c_lto_cross_compile}" != "yes" && ac_cv_c_lto_cross_compile="no"
  1310. AC_C_LTO
  1311. CFLAGS="${oCFLAGS}"
  1312. test "${ac_cv_c_lto}" != "yes" && have_lto="no"
  1313. fi
  1314. test "${enable_lto}" = "yes" -a "${have_lto}" != "yes" && \
  1315. AC_MSG_ERROR([LTO is required but is not available.])
  1316. AC_MSG_CHECKING([if LTO should be enabled])
  1317. if test "${enable_lto}" != "no" -a "${have_lto}" = "yes"; then
  1318. enable_lto="yes"
  1319. CFLAGS="${CFLAGS} -flto"
  1320. else
  1321. enable_lto="no"
  1322. fi
  1323. AC_MSG_RESULT([${enable_lto}])
  1324. # -----------------------------------------------------------------------------
  1325. if test "${enable_backend_kinesis}" = "yes" -o \
  1326. "${enable_exporting_pubsub}" = "yes" -o \
  1327. "${enable_backend_prometheus_remote_write}" = "yes" -o \
  1328. "${new_cloud_protocol}" = "yes" -o \
  1329. "${build_ml}" = "yes"; then
  1330. enable_cxx_linker="yes"
  1331. # Try to unconditionally link with -latomic. If the compiler can satisfy
  1332. # all the atomic ops with builtins then, the library will be left unused.
  1333. # Otherwise, some ops will be covered by the compiler's intrinsics and some
  1334. # will be picked up by the linker from -latomic. In the later case, if
  1335. # -latomic is not available there will be a build failure, which would
  1336. # have happened either way before this change.
  1337. AC_LANG_PUSH([C++])
  1338. AC_MSG_CHECKING(whether we can use -latomic)
  1339. OLD_LIBS="${LIBS}"
  1340. LIBS="-latomic"
  1341. AC_LINK_IFELSE([AC_LANG_SOURCE([[
  1342. #include <atomic>
  1343. #include <cstdint>
  1344. std::atomic<std::int64_t> v;
  1345. int main() {
  1346. return v;
  1347. }
  1348. ]])], CAN_USE_LIBATOMIC=yes, CAN_USE_LIBATOMIC=no)
  1349. LIBS="${OLD_LIBS}"
  1350. AC_MSG_RESULT($CAN_USE_LIBATOMIC)
  1351. if test "x$CAN_USE_LIBATOMIC" = xyes; then
  1352. OPTIONAL_ATOMIC_LIBS="-latomic"
  1353. fi
  1354. AC_SUBST([OPTIONAL_ATOMIC_LIBS])
  1355. AC_LANG_POP([C++])
  1356. fi
  1357. AM_CONDITIONAL([ENABLE_CXX_LINKER], [test "${enable_cxx_linker}" = "yes"])
  1358. AC_DEFINE_UNQUOTED([NETDATA_USER], ["${with_user}"], [use this user to drop privileged])
  1359. varlibdir="${localstatedir}/lib/netdata"
  1360. registrydir="${localstatedir}/lib/netdata/registry"
  1361. cachedir="${localstatedir}/cache/netdata"
  1362. chartsdir="${libexecdir}/netdata/charts.d"
  1363. nodedir="${libexecdir}/netdata/node.d"
  1364. pythondir="${libexecdir}/netdata/python.d"
  1365. configdir="${sysconfdir}/netdata"
  1366. libconfigdir="${libdir}/netdata/conf.d"
  1367. logdir="${localstatedir}/log/netdata"
  1368. pluginsdir="${libexecdir}/netdata/plugins.d"
  1369. AC_SUBST([varlibdir])
  1370. AC_SUBST([registrydir])
  1371. AC_SUBST([cachedir])
  1372. AC_SUBST([chartsdir])
  1373. AC_SUBST([nodedir])
  1374. AC_SUBST([pythondir])
  1375. AC_SUBST([configdir])
  1376. AC_SUBST([libconfigdir])
  1377. AC_SUBST([logdir])
  1378. AC_SUBST([pluginsdir])
  1379. AC_SUBST([webdir])
  1380. CFLAGS="${CFLAGS} ${OPTIONAL_PROTOBUF_CFLAGS} ${OPTIONAL_MATH_CFLAGS} ${OPTIONAL_NFACCT_CFLAGS} ${OPTIONAL_ZLIB_CFLAGS} ${OPTIONAL_UUID_CFLAGS} \
  1381. ${OPTIONAL_LIBCAP_CFLAGS} ${OPTIONAL_IPMIMONITORING_CFLAGS} ${OPTIONAL_CUPS_CFLAGS} ${OPTIONAL_XENSTAT_FLAGS} \
  1382. ${OPTIONAL_KINESIS_CFLAGS} ${OPTIONAL_PUBSUB_CFLAGS} ${OPTIONAL_PROMETHEUS_REMOTE_WRITE_CFLAGS} \
  1383. ${OPTIONAL_MONGOC_CFLAGS} ${LWS_CFLAGS} ${OPTIONAL_JSONC_STATIC_CFLAGS} ${OPTIONAL_BPF_CFLAGS} ${OPTIONAL_JUDY_CFLAGS} \
  1384. ${OPTIONAL_ACLK_CFLAGS} ${OPTIONAL_ML_CFLAGS} ${OPTIONAL_ML_TESTS_CFLAGS}"
  1385. CXXFLAGS="${CFLAGS} ${CXX11FLAG}"
  1386. CPPFLAGS="\
  1387. -DVARLIB_DIR=\"\\\"${varlibdir}\\\"\" \
  1388. -DCACHE_DIR=\"\\\"${cachedir}\\\"\" \
  1389. -DCONFIG_DIR=\"\\\"${configdir}\\\"\" \
  1390. -DLIBCONFIG_DIR=\"\\\"${libconfigdir}\\\"\" \
  1391. -DLOG_DIR=\"\\\"${logdir}\\\"\" \
  1392. -DPLUGINS_DIR=\"\\\"${pluginsdir}\\\"\" \
  1393. -DRUN_DIR=\"\\\"${localstatedir}/run/netdata\\\"\" \
  1394. -DWEB_DIR=\"\\\"${webdir}\\\"\" \
  1395. "
  1396. AC_SUBST([OPTIONAL_MATH_CFLAGS])
  1397. AC_SUBST([OPTIONAL_MATH_LIBS])
  1398. AC_SUBST([OPTIONAL_UV_LIBS])
  1399. AC_SUBST([OPTIONAL_LZ4_LIBS])
  1400. AC_SUBST([OPTIONAL_JUDY_CFLAGS])
  1401. AC_SUBST([OPTIONAL_JUDY_LIBS])
  1402. AC_SUBST([OPTIONAL_SSL_LIBS])
  1403. AC_SUBST([OPTIONAL_JSONC_LIBS])
  1404. AC_SUBST([OPTIONAL_NFACCT_CFLAGS])
  1405. AC_SUBST([OPTIONAL_NFACCT_LIBS])
  1406. AC_SUBST([OPTIONAL_ZLIB_CFLAGS])
  1407. AC_SUBST([OPTIONAL_ZLIB_LIBS])
  1408. AC_SUBST([OPTIONAL_UUID_CFLAGS])
  1409. AC_SUBST([OPTIONAL_UUID_LIBS])
  1410. AC_SUBST([OPTIONAL_BPF_CFLAGS])
  1411. AC_SUBST([OPTIONAL_BPF_LIBS])
  1412. AC_SUBST([OPTIONAL_MQTT_LIBS])
  1413. AC_SUBST([OPTIONAL_LIBCAP_CFLAGS])
  1414. AC_SUBST([OPTIONAL_LIBCAP_LIBS])
  1415. AC_SUBST([OPTIONAL_IPMIMONITORING_CFLAGS])
  1416. AC_SUBST([OPTIONAL_IPMIMONITORING_LIBS])
  1417. AC_SUBST([OPTIONAL_CUPS_CFLAGS])
  1418. AC_SUBST([OPTIONAL_CUPS_LIBS])
  1419. AC_SUBST([OPTIONAL_XENSTAT_CFLAGS])
  1420. AC_SUBST([OPTIONAL_XENSTAT_LIBS])
  1421. AC_SUBST([OPTIONAL_KINESIS_CFLAGS])
  1422. AC_SUBST([OPTIONAL_KINESIS_LIBS])
  1423. AC_SUBST([OPTIONAL_PUBSUB_CFLAGS])
  1424. AC_SUBST([OPTIONAL_PUBSUB_LIBS])
  1425. AC_SUBST([OPTIONAL_PROMETHEUS_REMOTE_WRITE_CFLAGS])
  1426. AC_SUBST([OPTIONAL_PROMETHEUS_REMOTE_WRITE_LIBS])
  1427. AC_SUBST([OPTIONAL_MONGOC_CFLAGS])
  1428. AC_SUBST([OPTIONAL_MONGOC_LIBS])
  1429. AC_SUBST([OPTIONAL_LWS_LIBS])
  1430. AC_SUBST([OPTIONAL_ACLK_CFLAGS])
  1431. AC_SUBST([OPTIONAL_PROTOBUF_CFLAGS])
  1432. AC_SUBST([OPTIONAL_PROTOBUF_LIBS])
  1433. AC_SUBST([OPTIONAL_GTEST_CFLAGS])
  1434. AC_SUBST([OPTIONAL_GTEST_LIBS])
  1435. AC_SUBST([OPTIONAL_ML_CFLAGS])
  1436. AC_SUBST([OPTIONAL_ML_LIBS])
  1437. AC_SUBST([OPTIONAL_ML_TESTS_CFLAGS])
  1438. AC_SUBST([OPTIONAL_ML_TESTS_LIBS])
  1439. # -----------------------------------------------------------------------------
  1440. # Check if cmocka is available - needed for unit testing
  1441. AC_ARG_ENABLE(
  1442. [unit-tests],
  1443. [AS_HELP_STRING([--disable-unit-tests],
  1444. [Disables building and running the unit tests suite])],
  1445. [],
  1446. [enable_unit_tests="yes"]
  1447. )
  1448. PKG_CHECK_MODULES(
  1449. [CMOCKA],
  1450. [cmocka],
  1451. [have_cmocka="yes"],
  1452. [AC_MSG_NOTICE([CMocka not found on the system. Unit tests disabled])]
  1453. )
  1454. AM_CONDITIONAL([ENABLE_UNITTESTS], [test "${enable_unit_tests}" = "yes" -a "${have_cmocka}" = "yes" ])
  1455. AC_SUBST([ENABLE_UNITTESTS])
  1456. TEST_CFLAGS="${CFLAGS} ${CMOCKA_CFLAGS}"
  1457. TEST_LIBS="${CMOCKA_LIBS}"
  1458. AC_SUBST([TEST_CFLAGS])
  1459. AC_SUBST([TEST_LIBS])
  1460. # -----------------------------------------------------------------------------
  1461. # save configure options for build info
  1462. AC_DEFINE_UNQUOTED(
  1463. [CONFIGURE_COMMAND],
  1464. ["$ac_configure_args"],
  1465. [options passed to configure script]
  1466. )
  1467. AC_CONFIG_FILES([
  1468. Makefile
  1469. netdata.spec
  1470. backends/graphite/Makefile
  1471. backends/json/Makefile
  1472. backends/Makefile
  1473. backends/opentsdb/Makefile
  1474. backends/prometheus/Makefile
  1475. backends/prometheus/remote_write/Makefile
  1476. backends/aws_kinesis/Makefile
  1477. backends/mongodb/Makefile
  1478. collectors/Makefile
  1479. collectors/apps.plugin/Makefile
  1480. collectors/cgroups.plugin/Makefile
  1481. collectors/charts.d.plugin/Makefile
  1482. collectors/checks.plugin/Makefile
  1483. collectors/diskspace.plugin/Makefile
  1484. collectors/timex.plugin/Makefile
  1485. collectors/fping.plugin/Makefile
  1486. collectors/ioping.plugin/Makefile
  1487. collectors/freebsd.plugin/Makefile
  1488. collectors/freeipmi.plugin/Makefile
  1489. collectors/cups.plugin/Makefile
  1490. collectors/idlejitter.plugin/Makefile
  1491. collectors/macos.plugin/Makefile
  1492. collectors/nfacct.plugin/Makefile
  1493. collectors/node.d.plugin/Makefile
  1494. collectors/plugins.d/Makefile
  1495. collectors/proc.plugin/Makefile
  1496. collectors/python.d.plugin/Makefile
  1497. collectors/slabinfo.plugin/Makefile
  1498. collectors/statsd.plugin/Makefile
  1499. collectors/ebpf.plugin/Makefile
  1500. collectors/tc.plugin/Makefile
  1501. collectors/xenstat.plugin/Makefile
  1502. collectors/perf.plugin/Makefile
  1503. daemon/Makefile
  1504. database/Makefile
  1505. database/engine/Makefile
  1506. database/engine/metadata_log/Makefile
  1507. diagrams/Makefile
  1508. exporting/Makefile
  1509. exporting/graphite/Makefile
  1510. exporting/json/Makefile
  1511. exporting/opentsdb/Makefile
  1512. exporting/prometheus/Makefile
  1513. exporting/prometheus/remote_write/Makefile
  1514. exporting/aws_kinesis/Makefile
  1515. exporting/pubsub/Makefile
  1516. exporting/mongodb/Makefile
  1517. exporting/tests/Makefile
  1518. health/Makefile
  1519. health/notifications/Makefile
  1520. ml/Makefile
  1521. ml/kmeans/Makefile
  1522. libnetdata/Makefile
  1523. libnetdata/tests/Makefile
  1524. libnetdata/adaptive_resortable_list/Makefile
  1525. libnetdata/avl/Makefile
  1526. libnetdata/buffer/Makefile
  1527. libnetdata/clocks/Makefile
  1528. libnetdata/completion/Makefile
  1529. libnetdata/config/Makefile
  1530. libnetdata/dictionary/Makefile
  1531. libnetdata/ebpf/Makefile
  1532. libnetdata/eval/Makefile
  1533. libnetdata/locks/Makefile
  1534. libnetdata/log/Makefile
  1535. libnetdata/popen/Makefile
  1536. libnetdata/procfile/Makefile
  1537. libnetdata/simple_pattern/Makefile
  1538. libnetdata/socket/Makefile
  1539. libnetdata/statistical/Makefile
  1540. libnetdata/storage_number/Makefile
  1541. libnetdata/storage_number/tests/Makefile
  1542. libnetdata/threads/Makefile
  1543. libnetdata/url/Makefile
  1544. libnetdata/json/Makefile
  1545. libnetdata/health/Makefile
  1546. registry/Makefile
  1547. streaming/Makefile
  1548. system/Makefile
  1549. tests/Makefile
  1550. web/Makefile
  1551. web/api/Makefile
  1552. web/api/badges/Makefile
  1553. web/api/exporters/Makefile
  1554. web/api/exporters/shell/Makefile
  1555. web/api/exporters/prometheus/Makefile
  1556. web/api/formatters/Makefile
  1557. web/api/formatters/csv/Makefile
  1558. web/api/formatters/json/Makefile
  1559. web/api/formatters/ssv/Makefile
  1560. web/api/formatters/value/Makefile
  1561. web/api/queries/Makefile
  1562. web/api/queries/average/Makefile
  1563. web/api/queries/des/Makefile
  1564. web/api/queries/incremental_sum/Makefile
  1565. web/api/queries/max/Makefile
  1566. web/api/queries/median/Makefile
  1567. web/api/queries/min/Makefile
  1568. web/api/queries/ses/Makefile
  1569. web/api/queries/stddev/Makefile
  1570. web/api/queries/sum/Makefile
  1571. web/api/health/Makefile
  1572. web/gui/Makefile
  1573. web/gui/dashboard/Makefile
  1574. web/server/Makefile
  1575. web/server/static/Makefile
  1576. claim/Makefile
  1577. spawn/Makefile
  1578. parser/Makefile
  1579. ])
  1580. AC_OUTPUT
  1581. test "${with_math}" != "yes" && AC_MSG_WARN([You are building without math. math allows accurate calculations. It should be enabled.]) || :
  1582. 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.]) || :