configure.ac 60 KB

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