configure.ac 58 KB

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