configure.ac 58 KB

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