configure.ac 58 KB

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