configure.ac 58 KB

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