configure.ac 59 KB

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