configure.ac 58 KB

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