configure.ac 57 KB

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