configure.ac 57 KB

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