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