configure.ac 59 KB

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