configure.ac 59 KB

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