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