configure.ac 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438
  1. #
  2. # Copyright (C) 2015 Alon Bar-Lev <alon.barlev@gmail.com>
  3. # SPDX-License-Identifier: GPL-3.0-or-later
  4. #
  5. AC_PREREQ(2.60)
  6. # We do not use m4_esyscmd_s to support older autoconf.
  7. define([VERSION_STRING], m4_esyscmd([git describe 2>/dev/null | tr -d '\n']))
  8. define([VERSION_FROM_FILE], m4_esyscmd([cat packaging/version | tr -d '\n']))
  9. m4_ifval(VERSION_STRING, [], [define([VERSION_STRING], VERSION_FROM_FILE)])
  10. AC_INIT([netdata], VERSION_STRING[])
  11. AM_MAINTAINER_MODE([disable])
  12. if test x"$USE_MAINTAINER_MODE" = xyes; then
  13. AC_MSG_NOTICE(***************** MAINTAINER MODE *****************)
  14. fi
  15. PACKAGE_RPM_VERSION="VERSION_STRING"
  16. AC_SUBST([PACKAGE_RPM_VERSION])
  17. # -----------------------------------------------------------------------------
  18. # autoconf initialization
  19. AC_CONFIG_AUX_DIR([.])
  20. AC_CONFIG_HEADERS([config.h])
  21. AC_CONFIG_MACRO_DIR([build/m4])
  22. AC_CONFIG_SRCDIR([daemon/main.c])
  23. define([AUTOMATE_INIT_OPTIONS], [tar-pax subdir-objects])
  24. m4_ifdef([AM_SILENT_RULES], [
  25. define([AUTOMATE_INIT_OPTIONS], [tar-pax silent-rules subdir-objects])
  26. ])
  27. AM_INIT_AUTOMAKE(AUTOMATE_INIT_OPTIONS)
  28. m4_ifdef([AM_SILENT_RULES], [
  29. AM_SILENT_RULES([yes])
  30. ])
  31. AC_CANONICAL_HOST
  32. AC_PROG_CC
  33. AC_PROG_CC_C99
  34. AM_PROG_CC_C_O
  35. AC_PROG_CXX
  36. AC_PROG_INSTALL
  37. PKG_PROG_PKG_CONFIG
  38. AC_USE_SYSTEM_EXTENSIONS
  39. # -----------------------------------------------------------------------------
  40. # configurable options
  41. AC_ARG_ENABLE(
  42. [plugin-nfacct],
  43. [AS_HELP_STRING([--enable-plugin-nfacct], [enable nfacct plugin @<:@default autodetect@:>@])],
  44. ,
  45. [enable_plugin_nfacct="detect"]
  46. )
  47. AC_ARG_ENABLE(
  48. [plugin-freeipmi],
  49. [AS_HELP_STRING([--enable-plugin-freeipmi], [enable freeipmi plugin @<:@default autodetect@:>@])],
  50. ,
  51. [enable_plugin_freeipmi="detect"]
  52. )
  53. AC_ARG_ENABLE(
  54. [plugin-cups],
  55. [AS_HELP_STRING([--enable-plugin-cups], [enable cups plugin @<:@default autodetect@:>@])],
  56. ,
  57. [enable_plugin_cups="detect"]
  58. )
  59. AC_ARG_ENABLE(
  60. [plugin-xenstat],
  61. [AS_HELP_STRING([--enable-plugin-xenstat], [enable xenstat plugin @<:@default autodetect@:>@])],
  62. ,
  63. [enable_plugin_xenstat="detect"]
  64. )
  65. AC_ARG_ENABLE(
  66. [backend-kinesis],
  67. [AS_HELP_STRING([--enable-backend-kinesis], [enable kinesis backend @<:@default autodetect@:>@])],
  68. ,
  69. [enable_backend_kinesis="detect"]
  70. )
  71. AC_ARG_ENABLE(
  72. [backend-prometheus-remote-write],
  73. [AS_HELP_STRING([--enable-backend-prometheus-remote-write], [enable prometheus remote write backend @<:@default autodetect@:>@])],
  74. ,
  75. [enable_backend_prometheus_remote_write="detect"]
  76. )
  77. AC_ARG_ENABLE(
  78. [backend-mongodb],
  79. [AS_HELP_STRING([--enable-backend-mongodb], [enable mongodb backend @<:@default autodetect@:>@])],
  80. ,
  81. [enable_backend_mongodb="detect"]
  82. )
  83. AC_ARG_ENABLE(
  84. [pedantic],
  85. [AS_HELP_STRING([--enable-pedantic], [enable pedantic compiler warnings @<:@default disabled@:>@])],
  86. ,
  87. [enable_pedantic="no"]
  88. )
  89. AC_ARG_ENABLE(
  90. [accept4],
  91. [AS_HELP_STRING([--disable-accept4], [System does not have accept4 @<:@default autodetect@:>@])],
  92. ,
  93. [enable_accept4="detect"]
  94. )
  95. AC_ARG_WITH(
  96. [webdir],
  97. [AS_HELP_STRING([--with-webdir], [location of webdir @<:@PKGDATADIR/web@:>@])],
  98. [webdir="${withval}"],
  99. [webdir="\$(pkgdatadir)/web"]
  100. )
  101. AC_ARG_WITH(
  102. [libcap],
  103. [AS_HELP_STRING([--with-libcap], [build with libcap @<:@default autodetect@:>@])],
  104. ,
  105. [with_libcap="detect"]
  106. )
  107. AC_ARG_WITH(
  108. [zlib],
  109. [AS_HELP_STRING([--without-zlib], [build without zlib @<:@default enabled@:>@])],
  110. ,
  111. [with_zlib="yes"]
  112. )
  113. AC_ARG_WITH(
  114. [math],
  115. [AS_HELP_STRING([--without-math], [build without math @<:@default enabled@:>@])],
  116. ,
  117. [with_math="yes"]
  118. )
  119. AC_ARG_WITH(
  120. [user],
  121. [AS_HELP_STRING([--with-user], [use this user to drop privilege @<:@default nobody@:>@])],
  122. ,
  123. [with_user="nobody"]
  124. )
  125. AC_ARG_ENABLE(
  126. [x86-sse],
  127. [AS_HELP_STRING([--disable-x86-sse], [SSE/SS2 optimizations on x86 @<:@default enabled@:>@])],
  128. ,
  129. [enable_x86_sse="yes"]
  130. )
  131. AC_ARG_ENABLE(
  132. [lto],
  133. [AS_HELP_STRING([--disable-lto], [Link Time Optimizations @<:@default autodetect@:>@])],
  134. ,
  135. [enable_lto="detect"]
  136. )
  137. AC_ARG_ENABLE(
  138. [https],
  139. [AS_HELP_STRING([--enable-https], [Enable SSL support @<:@default autodetect@:>@])],
  140. ,
  141. [enable_https="detect"]
  142. )
  143. AC_ARG_ENABLE(
  144. [dbengine],
  145. [AS_HELP_STRING([--disable-dbengine], [disable netdata dbengine @<:@default autodetect@:>@])],
  146. ,
  147. [enable_dbengine="detect"]
  148. )
  149. AC_ARG_ENABLE(
  150. [jsonc],
  151. [AS_HELP_STRING([--enable-jsonc], [Enable JSON-C support @<:@default autodetect@:>@])],
  152. ,
  153. [enable_jsonc="detect"]
  154. )
  155. # -----------------------------------------------------------------------------
  156. # Check if cloud is enabled and if the functionality is available
  157. AC_ARG_ENABLE(
  158. [cloud],
  159. [AS_HELP_STRING([--disable-cloud],
  160. [Disables all cloud functionality])],
  161. [ enable_cloud="$enableval" ],
  162. [ enable_cloud="detect" ]
  163. )
  164. if test "${enable_cloud}" = "no"; then
  165. AC_DEFINE([DISABLE_CLOUD], [1], [disable netdata cloud functionality])
  166. fi
  167. # -----------------------------------------------------------------------------
  168. # netdata required checks
  169. # fails on centos6
  170. #AX_CHECK_ENABLE_DEBUG()
  171. AX_GCC_FUNC_ATTRIBUTE([returns_nonnull])
  172. AX_GCC_FUNC_ATTRIBUTE([malloc])
  173. AX_GCC_FUNC_ATTRIBUTE([noreturn])
  174. AX_GCC_FUNC_ATTRIBUTE([noinline])
  175. AX_GCC_FUNC_ATTRIBUTE([format])
  176. AX_GCC_FUNC_ATTRIBUTE([warn_unused_result])
  177. AC_CHECK_TYPES([struct timespec, clockid_t], [], [], [[#include <time.h>]])
  178. AC_SEARCH_LIBS([clock_gettime], [rt posix4])
  179. AC_CHECK_FUNCS([clock_gettime])
  180. AC_CHECK_FUNCS([sched_setscheduler sched_getscheduler sched_getparam sched_get_priority_min sched_get_priority_max getpriority setpriority nice])
  181. AC_CHECK_FUNCS([recvmmsg])
  182. AC_TYPE_INT8_T
  183. AC_TYPE_INT16_T
  184. AC_TYPE_INT32_T
  185. AC_TYPE_INT64_T
  186. AC_TYPE_UINT8_T
  187. AC_TYPE_UINT16_T
  188. AC_TYPE_UINT32_T
  189. AC_TYPE_UINT64_T
  190. AC_C_INLINE
  191. AC_FUNC_STRERROR_R
  192. AC_C__GENERIC
  193. AC_C___ATOMIC
  194. # AC_C_STMT_EXPR
  195. AC_CHECK_SIZEOF([void *])
  196. AC_CANONICAL_HOST
  197. AC_HEADER_MAJOR
  198. AC_HEADER_RESOLV
  199. AC_CHECK_HEADERS_ONCE([sys/prctl.h])
  200. AC_CHECK_HEADERS_ONCE([sys/vfs.h])
  201. AC_CHECK_HEADERS_ONCE([sys/statfs.h])
  202. AC_CHECK_HEADERS_ONCE([sys/statvfs.h])
  203. AC_CHECK_HEADERS_ONCE([sys/mount.h])
  204. if test "${enable_accept4}" != "no"; then
  205. AC_CHECK_FUNCS_ONCE(accept4)
  206. fi
  207. # -----------------------------------------------------------------------------
  208. # operating system detection
  209. AC_MSG_CHECKING([operating system])
  210. case "$host_os" in
  211. freebsd*)
  212. build_target=freebsd
  213. build_target_id=2
  214. CFLAGS="${CFLAGS} -I/usr/local/include -L/usr/local/lib"
  215. ;;
  216. darwin*)
  217. build_target=macos
  218. build_target_id=3
  219. LDFLAGS="${LDFLAGS} -framework CoreFoundation -framework IOKit"
  220. ;;
  221. *)
  222. build_target=linux
  223. build_target_id=1
  224. ;;
  225. esac
  226. AM_CONDITIONAL([FREEBSD], [test "${build_target}" = "freebsd"])
  227. AM_CONDITIONAL([MACOS], [test "${build_target}" = "macos"])
  228. AM_CONDITIONAL([LINUX], [test "${build_target}" = "linux"])
  229. AC_MSG_RESULT([${build_target} with id ${build_target_id}])
  230. # -----------------------------------------------------------------------------
  231. # pthreads
  232. ACX_PTHREAD(, [AC_MSG_ERROR([Cannot initialize pthread environment])])
  233. LIBS="${PTHREAD_LIBS} ${LIBS}"
  234. CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}"
  235. CC="${PTHREAD_CC}"
  236. # -----------------------------------------------------------------------------
  237. # libm
  238. AC_ARG_VAR([MATH_CFLAGS], [C compiler flags for math])
  239. AC_ARG_VAR([MATH_LIBS], [linker flags for math])
  240. if test -z "${MATH_LIBS}"; then
  241. AC_CHECK_LIB(
  242. [m],
  243. [sin],
  244. [MATH_LIBS="-lm"]
  245. )
  246. fi
  247. test "${with_math}" = "yes" -a -z "${MATH_LIBS}" && AC_MSG_ERROR([math required but not found])
  248. AC_MSG_CHECKING([if libm should be used])
  249. if test "${with_math}" != "no" -a ! -z "${MATH_LIBS}"; then
  250. with_math="yes"
  251. AC_DEFINE([STORAGE_WITH_MATH], [1], [math usability])
  252. OPTIONAL_MATH_CFLAGS="${MATH_CFLAGS}"
  253. OPTIONAL_MATH_LIBS="${MATH_LIBS}"
  254. else
  255. with_math="no"
  256. fi
  257. AC_MSG_RESULT([${with_math}])
  258. # -----------------------------------------------------------------------------
  259. # libuv multi-platform support library with a focus on asynchronous I/O
  260. # TODO: check version, uv_fs_scandir_next only available in version >= 1.0
  261. AC_CHECK_LIB(
  262. [uv],
  263. [uv_fs_scandir_next],
  264. [UV_LIBS="-luv"]
  265. )
  266. test -z "${UV_LIBS}" && \
  267. AC_MSG_ERROR([libuv required but not found. Try installing 'libuv1-dev' or 'libuv-devel'.])
  268. OPTIONAL_UV_CFLAGS="${UV_CFLAGS}"
  269. OPTIONAL_UV_LIBS="${UV_LIBS}"
  270. # -----------------------------------------------------------------------------
  271. # lz4 Extremely Fast Compression algorithm
  272. AC_CHECK_LIB(
  273. [lz4],
  274. [LZ4_compress_default],
  275. [LZ4_LIBS="-llz4"]
  276. )
  277. # -----------------------------------------------------------------------------
  278. # Judy General purpose dynamic array
  279. AC_CHECK_LIB(
  280. [Judy],
  281. [JudyLIns],
  282. [JUDY_LIBS="-lJudy"]
  283. )
  284. # -----------------------------------------------------------------------------
  285. # zlib
  286. PKG_CHECK_MODULES(
  287. [ZLIB],
  288. [zlib],
  289. [have_zlib=yes],
  290. [have_zlib=no]
  291. )
  292. test "${with_zlib}" = "yes" -a "${have_zlib}" != "yes" && AC_MSG_ERROR([zlib required but not found. Try installing 'zlib1g-dev' or 'zlib-devel'.])
  293. AC_MSG_CHECKING([if zlib should be used])
  294. if test "${with_zlib}" != "no" -a "${have_zlib}" = "yes"; then
  295. with_zlib="yes"
  296. AC_DEFINE([NETDATA_WITH_ZLIB], [1], [zlib usability])
  297. OPTIONAL_ZLIB_CFLAGS="${ZLIB_CFLAGS}"
  298. OPTIONAL_ZLIB_LIBS="${ZLIB_LIBS}"
  299. else
  300. with_zlib="no"
  301. fi
  302. AC_MSG_RESULT([${with_zlib}])
  303. # -----------------------------------------------------------------------------
  304. # libuuid
  305. PKG_CHECK_MODULES(
  306. [UUID],
  307. [uuid],
  308. [have_uuid=yes],
  309. [AC_MSG_ERROR([libuuid required but not found. Try installing 'uuid-dev' or 'libuuid-devel'.])]
  310. )
  311. AC_DEFINE([NETDATA_WITH_UUID], [1], [uuid usability])
  312. OPTIONAL_UUID_CFLAGS="${UUID_CFLAGS}"
  313. OPTIONAL_UUID_LIBS="${UUID_LIBS}"
  314. # -----------------------------------------------------------------------------
  315. # OpenSSL Cryptography and SSL/TLS Toolkit
  316. AC_CHECK_LIB(
  317. [crypto],
  318. [SHA256_Init],
  319. [SSL_LIBS="-lcrypto -lssl"]
  320. )
  321. # -----------------------------------------------------------------------------
  322. # JSON-C library
  323. PKG_CHECK_MODULES([JSON],[json-c],AC_CHECK_LIB(
  324. [json-c],
  325. [json_object_get_type],
  326. [JSONC_LIBS="-ljson-c"]),AC_CHECK_LIB(
  327. [json],
  328. [json_object_get_type],
  329. [JSONC_LIBS="-ljson"])
  330. )
  331. OPTIONAL_JSONC_LIBS="${JSONC_LIBS}"
  332. # -----------------------------------------------------------------------------
  333. # VFS plugin libs
  334. AC_CHECK_LIB(
  335. [dl],
  336. [dlopen],
  337. [EBPF_LIBS="-ldl"]
  338. )
  339. OPTIONAL_EBPF_LIBS="${EBPF_LIBS}"
  340. # -----------------------------------------------------------------------------
  341. # DB engine and HTTPS
  342. test "${enable_dbengine}" = "yes" -a -z "${LZ4_LIBS}" && \
  343. AC_MSG_ERROR([liblz4 required but not found. Try installing 'liblz4-dev' or 'lz4-devel'.])
  344. test "${enable_dbengine}" = "yes" -a -z "${JUDY_LIBS}" && \
  345. AC_MSG_ERROR([libJudy required but not found. Try installing 'libjudy-dev' or 'Judy-devel'.])
  346. test "${enable_https}" = "yes" -a -z "${SSL_LIBS}" && \
  347. AC_MSG_ERROR([OpenSSL required for HTTPS but not found. Try installing 'libssl-dev' or 'openssl-devel'.])
  348. test "${enable_dbengine}" = "yes" -a -z "${SSL_LIBS}" && \
  349. AC_MSG_ERROR([OpenSSL required for DBENGINE but not found. Try installing 'libssl-dev' or 'openssl-devel'.])
  350. AC_MSG_CHECKING([if netdata dbengine should be used])
  351. if test "${enable_dbengine}" != "no" -a "${UV_LIBS}" -a "${LZ4_LIBS}" -a "${JUDY_LIBS}" -a "${SSL_LIBS}"; then
  352. enable_dbengine="yes"
  353. AC_DEFINE([ENABLE_DBENGINE], [1], [netdata dbengine usability])
  354. OPTIONAL_LZ4_CFLAGS="${LZ4_CFLAGS}"
  355. OPTIONAL_LZ4_LIBS="${LZ4_LIBS}"
  356. OPTIONAL_JUDY_CFLAGS="${JUDY_CFLAGS}"
  357. OPTIONAL_JUDY_LIBS="${JUDY_LIBS}"
  358. OPTIONAL_SSL_CFLAGS="${SSL_CFLAGS}"
  359. OPTIONAL_SSL_LIBS="${SSL_LIBS}"
  360. else
  361. enable_dbengine="no"
  362. fi
  363. AC_MSG_RESULT([${enable_dbengine}])
  364. AM_CONDITIONAL([ENABLE_DBENGINE], [test "${enable_dbengine}" = "yes"])
  365. AC_MSG_CHECKING([if netdata https should be used])
  366. if test "${enable_https}" != "no" -a "${SSL_LIBS}"; then
  367. enable_https="yes"
  368. AC_DEFINE([ENABLE_HTTPS], [1], [netdata HTTPS usability])
  369. OPTIONAL_SSL_CFLAGS="${SSL_CFLAGS}"
  370. OPTIONAL_SSL_LIBS="${SSL_LIBS}"
  371. else
  372. enable_https="no"
  373. fi
  374. AC_MSG_RESULT([${enable_https}])
  375. AM_CONDITIONAL([ENABLE_HTTPS], [test "${enable_https}" = "yes"])
  376. # -----------------------------------------------------------------------------
  377. # JSON-C
  378. if test "${enable_jsonc}" != "no" -a -z "${JSONC_LIBS}"; then
  379. # Try and detect manual static build presence (from netdata-installer.sh)
  380. AC_MSG_CHECKING([if statically built json-c is present])
  381. HAVE_libjson_c_a="no"
  382. if test -f "externaldeps/jsonc/libjson-c.a"; then
  383. LIBS_BKP="${LIBS}"
  384. LIBS="externaldeps/jsonc/libjson-c.a"
  385. AC_LINK_IFELSE([AC_LANG_SOURCE([[#include "externaldeps/jsonc/json-c/json.h"
  386. int main (int argc, char **argv) {
  387. struct json_object *jobj;
  388. char *str = "{ \"msg-type\": \"random\" }";
  389. jobj = json_tokener_parse(str);
  390. json_object_get_type(jobj);
  391. }]])],
  392. [HAVE_libjson_c_a="yes"],
  393. [HAVE_libjson_c_a="no"])
  394. LIBS="${LIBS_BKP}"
  395. fi
  396. if test "${HAVE_libjson_c_a}" = "yes"; then
  397. AC_DEFINE([LINK_STATIC_JSONC], [1], [static json-c should be used])
  398. JSONC_LIBS="static"
  399. OPTIONAL_JSONC_STATIC_CFLAGS="-I externaldeps/jsonc"
  400. fi
  401. AC_MSG_RESULT([${HAVE_libjson_c_a}])
  402. fi
  403. AM_CONDITIONAL([LINK_STATIC_JSONC], [test "${JSONC_LIBS}" = "static"])
  404. test "${enable_jsonc}" = "yes" -a -z "${JSONC_LIBS}" && \
  405. AC_MSG_ERROR([JSON-C required but not found. Try installing 'libjson-c-dev' or 'json-c'.])
  406. AC_MSG_CHECKING([if json-c should be used])
  407. if test "${enable_jsonc}" != "no" -a "${JSONC_LIBS}"; then
  408. enable_jsonc="yes"
  409. AC_DEFINE([ENABLE_JSONC], [1], [netdata json-c usability])
  410. else
  411. enable_jsonc="no"
  412. fi
  413. AC_MSG_RESULT([${enable_jsonc}])
  414. AM_CONDITIONAL([ENABLE_JSONC], [test "${enable_jsonc}" = "yes"])
  415. # -----------------------------------------------------------------------------
  416. # compiler options
  417. AC_ARG_VAR([SSE_CANDIDATE], [C compiler flags for SSE])
  418. AS_CASE([$host_cpu],
  419. [i?86], [SSE_CANDIDATE="yes"]
  420. )
  421. AC_SUBST([SSE_CANDIDATE])
  422. if test "${SSE_CANDIDATE}" = "yes" -a "${enable_x86_sse}" = "yes"; then
  423. opt="-msse2 -mfpmath=sse"
  424. AX_CHECK_COMPILE_FLAG(${opt}, [CFLAGS="${CFLAGS} ${opt}"], [])
  425. fi
  426. if test "${GCC}" = "yes"; then
  427. AC_DEFINE_UNQUOTED([likely(x)], [__builtin_expect(!!(x), 1)], [gcc branch optimization])
  428. AC_DEFINE_UNQUOTED([unlikely(x)], [__builtin_expect(!!(x), 0)], [gcc branch optimization])
  429. else
  430. AC_DEFINE_UNQUOTED([likely(x)], [(x)], [gcc branch optimization])
  431. AC_DEFINE_UNQUOTED([unlikely(x)], [(x)], [gcc branch optimization])
  432. fi
  433. if test "${GCC}" = "yes"; then
  434. AC_DEFINE([__always_unused], [__attribute__((unused))], [gcc unused attribute])
  435. AC_DEFINE([__maybe_unused], [__attribute__((unused))], [gcc unused attribute])
  436. else
  437. AC_DEFINE([__always_unused], [], [dummy unused attribute])
  438. AC_DEFINE([__maybe_unused], [], [dummy unused attribute])
  439. fi
  440. if test "${enable_pedantic}" = "yes"; then
  441. enable_strict="yes"
  442. CFLAGS="${CFLAGS} -pedantic -Wall -Wextra -Wno-long-long"
  443. fi
  444. # -----------------------------------------------------------------------------
  445. # memory allocation library
  446. AC_MSG_CHECKING([for memory allocator])
  447. TS_CHECK_JEMALLOC
  448. if test "$has_jemalloc" = "1"; then
  449. AC_DEFINE([ENABLE_JEMALLOC], [1], [compile and link with jemalloc])
  450. AC_MSG_RESULT([jemalloc])
  451. else
  452. TS_CHECK_TCMALLOC
  453. if test "$has_tcmalloc" = "1"; then
  454. AC_DEFINE([ENABLE_TCMALLOC], [1], [compile and link with tcmalloc])
  455. AC_MSG_RESULT([tcmalloc])
  456. else
  457. AC_MSG_RESULT([system])
  458. AC_C_MALLOPT
  459. AC_C_MALLINFO
  460. fi
  461. fi
  462. # -----------------------------------------------------------------------------
  463. # libcap
  464. PKG_CHECK_MODULES(
  465. [LIBCAP],
  466. [libcap],
  467. [AC_CHECK_LIB([cap], [cap_get_proc, cap_set_proc],
  468. [AC_CHECK_HEADER(
  469. [sys/capability.h],
  470. [have_libcap=yes],
  471. [have_libcap=no]
  472. )],
  473. [have_libcap=no]
  474. )],
  475. [have_libcap=no]
  476. )
  477. test "${with_libcap}" = "yes" -a "${have_libcap}" != "yes" && AC_MSG_ERROR([libcap required but not found.])
  478. AC_MSG_CHECKING([if libcap should be used])
  479. if test "${with_libcap}" != "no" -a "${have_libcap}" = "yes"; then
  480. with_libcap="yes"
  481. AC_DEFINE([HAVE_CAPABILITY], [1], [libcap usability])
  482. OPTIONAL_LIBCAP_CFLAGS="${LIBCAP_CFLAGS}"
  483. OPTIONAL_LIBCAP_LIBS="${LIBCAP_LIBS}"
  484. else
  485. with_libcap="no"
  486. fi
  487. AC_MSG_RESULT([${with_libcap}])
  488. AM_CONDITIONAL([ENABLE_CAPABILITY], [test "${with_libcap}" = "yes"])
  489. # -----------------------------------------------------------------------------
  490. # ACLK
  491. AC_MSG_CHECKING([if cloud functionality should be enabled])
  492. AC_MSG_RESULT([${enable_cloud}])
  493. if test "$enable_cloud" != "no"; then
  494. # just to have all messages that can fail ACLK build in one place
  495. # so it is easier to see why it can't be built
  496. if test -n "${SSL_LIBS}"; then
  497. OPTIONAL_SSL_CFLAGS="${SSL_CFLAGS}"
  498. OPTIONAL_SSL_LIBS="${SSL_LIBS}"
  499. else
  500. AC_MSG_WARN([OpenSSL required for agent-cloud-link but not found. Try installing 'libssl-dev' or 'openssl-devel'.])
  501. fi
  502. AC_MSG_CHECKING([if libmosquitto static lib is present (and builds)])
  503. if test -f "externaldeps/mosquitto/libmosquitto.a"; then
  504. LIBS_BKP="${LIBS}"
  505. LIBS="externaldeps/mosquitto/libmosquitto.a ${OPTIONAL_SSL_LIBS}"
  506. AC_LINK_IFELSE([AC_LANG_SOURCE([[#include "externaldeps/mosquitto/mosquitto.h"
  507. int main (int argc, char **argv) {
  508. int m,mm,r;
  509. mosquitto_lib_version(&m, &mm, &r);
  510. }]])],
  511. [HAVE_libmosquitto_a="yes"],
  512. [HAVE_libmosquitto_a="no"])
  513. LIBS="${LIBS_BKP}"
  514. else
  515. HAVE_libmosquitto_a="no"
  516. AC_DEFINE([ACLK_NO_LIBMOSQ], [1], [Libmosquitto.a was not found during build.])
  517. fi
  518. AC_MSG_RESULT([${HAVE_libmosquitto_a}])
  519. AC_MSG_CHECKING([if libwebsockets static lib is present])
  520. if test -f "externaldeps/libwebsockets/libwebsockets.a"; then
  521. LWS_CFLAGS="-I externaldeps/libwebsockets/include"
  522. HAVE_libwebsockets_a="yes"
  523. else
  524. HAVE_libwebsockets_a="no"
  525. AC_DEFINE([ACLK_NO_LWS], [1], [libwebsockets.a was not found during build.])
  526. fi
  527. AC_MSG_RESULT([${HAVE_libwebsockets_a}])
  528. if test "${build_target}" = "linux" -a "${enable_cloud}" != "no"; then
  529. if test "${have_libcap}" = "yes" -a "${with_libcap}" = "no"; then
  530. AC_MSG_ERROR([agent-cloud-link can't be built without libcap. Disable it by --disable-cloud or enable libcap])
  531. fi
  532. if test "${with_libcap}" = "yes"; then
  533. LWS_CFLAGS+=" ${LIBCAP_CFLAGS}"
  534. fi
  535. fi
  536. # next 2 lines are just to have info for ACLK dependencies in common place
  537. AC_MSG_CHECKING([if json-c available for ACLK])
  538. AC_MSG_RESULT([${enable_jsonc}])
  539. test "${enable_cloud}" = "yes" -a "${enable_jsonc}" = "no" && \
  540. AC_MSG_ERROR([You have asked for ACLK to be built but no json-c available. ACLK requires json-c])
  541. AC_MSG_CHECKING([if netdata agent-cloud-link can be enabled])
  542. if test "${HAVE_libmosquitto_a}" = "yes" -a "${HAVE_libwebsockets_a}" = "yes" -a -n "${SSL_LIBS}" -a "${enable_jsonc}" = "yes"; then
  543. can_enable_aclk="yes"
  544. else
  545. can_enable_aclk="no"
  546. fi
  547. AC_MSG_RESULT([${can_enable_aclk}])
  548. test "${enable_cloud}" = "yes" -a "${can_enable_aclk}" = "no" && \
  549. AC_MSG_ERROR([User required agent-cloud-link but it can't be built!])
  550. AC_MSG_CHECKING([if netdata agent-cloud-link should/will be enabled])
  551. if test "${enable_cloud}" = "detect"; then
  552. enable_aclk=$can_enable_aclk
  553. else
  554. enable_aclk=$enable_cloud
  555. fi
  556. AC_SUBST([can_enable_aclk])
  557. if test "${enable_aclk}" = "yes"; then
  558. AC_DEFINE([ENABLE_ACLK], [1], [netdata ACLK])
  559. fi
  560. AC_MSG_RESULT([${enable_aclk}])
  561. fi
  562. AC_SUBST([enable_cloud])
  563. AM_CONDITIONAL([ENABLE_ACLK], [test "${enable_aclk}" = "yes"])
  564. # -----------------------------------------------------------------------------
  565. # apps.plugin
  566. AC_MSG_CHECKING([if apps.plugin should be enabled])
  567. if test "${build_target}" != "macos"; then
  568. enable_plugin_apps="yes"
  569. else
  570. enable_plugin_apps="no"
  571. fi
  572. AC_MSG_RESULT([${enable_plugin_apps}])
  573. AM_CONDITIONAL([ENABLE_PLUGIN_APPS], [test "${enable_plugin_apps}" = "yes"])
  574. # -----------------------------------------------------------------------------
  575. # freeipmi.plugin - libipmimonitoring
  576. PKG_CHECK_MODULES(
  577. [IPMIMONITORING],
  578. [libipmimonitoring],
  579. [AC_CHECK_LIB([ipmimonitoring], [
  580. ipmi_monitoring_sensor_readings_by_record_id,
  581. ipmi_monitoring_sensor_readings_by_sensor_type,
  582. ipmi_monitoring_sensor_read_sensor_number,
  583. ipmi_monitoring_sensor_read_sensor_name,
  584. ipmi_monitoring_sensor_read_sensor_state,
  585. ipmi_monitoring_sensor_read_sensor_units,
  586. ipmi_monitoring_sensor_iterator_next,
  587. ipmi_monitoring_ctx_sensor_config_file,
  588. ipmi_monitoring_ctx_sdr_cache_directory,
  589. ipmi_monitoring_ctx_errormsg,
  590. ipmi_monitoring_ctx_create
  591. ],
  592. [AC_CHECK_HEADER(
  593. [ipmi_monitoring.h],
  594. [AC_CHECK_HEADER(
  595. [ipmi_monitoring_bitmasks.h],
  596. [have_ipmimonitoring=yes],
  597. [have_ipmimonitoring=no]
  598. )],
  599. [have_ipmimonitoring=no]
  600. )],
  601. [have_ipmimonitoring=no]
  602. )],
  603. [have_ipmimonitoring=no]
  604. )
  605. test "${enable_plugin_freeipmi}" = "yes" -a "${have_ipmimonitoring}" != "yes" && \
  606. AC_MSG_ERROR([ipmimonitoring required but not found. Try installing 'libipmimonitoring-dev' or 'libipmimonitoring-devel'])
  607. AC_MSG_CHECKING([if freeipmi.plugin should be enabled])
  608. if test "${enable_plugin_freeipmi}" != "no" -a "${have_ipmimonitoring}" = "yes"; then
  609. enable_plugin_freeipmi="yes"
  610. AC_DEFINE([HAVE_FREEIPMI], [1], [ipmimonitoring usability])
  611. OPTIONAL_IPMIMONITORING_CFLAGS="${IPMIMONITORING_CFLAGS}"
  612. OPTIONAL_IPMIMONITORING_LIBS="${IPMIMONITORING_LIBS}"
  613. else
  614. enable_plugin_freeipmi="no"
  615. fi
  616. AC_MSG_RESULT([${enable_plugin_freeipmi}])
  617. AM_CONDITIONAL([ENABLE_PLUGIN_FREEIPMI], [test "${enable_plugin_freeipmi}" = "yes"])
  618. # -----------------------------------------------------------------------------
  619. # cups.plugin - libcups
  620. # Only check most recently added method of cups
  621. AC_CHECK_LIB([cups], [httpConnect2],
  622. [AC_CHECK_HEADER(
  623. [cups/cups.h],
  624. [have_cups=yes],
  625. [have_cups=no]
  626. )],
  627. [have_cups=no]
  628. )
  629. test "${enable_plugin_cups}" = "yes" -a "${have_cups}" != "yes" && \
  630. AC_MSG_ERROR([cups required but not found. Try installing 'cups'])
  631. AC_ARG_WITH([cups-config],
  632. [AS_HELP_STRING([--with-cups-config=path], [Specify path to cups-config executable.])],
  633. [with_cups_config="$withval"],
  634. [with_cups_config=system]
  635. )
  636. AS_IF([test "x$with_cups_config" != "xsystem"], [
  637. CUPSCONFIG=$with_cups_config
  638. ], [
  639. AC_PATH_TOOL(CUPSCONFIG, [cups-config])
  640. AS_IF([test -z "$CUPSCONFIG"], [
  641. have_cups=no
  642. ])
  643. ])
  644. AC_MSG_CHECKING([if cups.plugin should be enabled])
  645. if test "${enable_plugin_cups}" != "no" -a "${have_cups}" = "yes"; then
  646. enable_plugin_cups="yes"
  647. AC_DEFINE([HAVE_CUPS], [1], [cups usability])
  648. CUPS_CFLAGS="${CUPS_CFLAGS} `$CUPSCONFIG --cflags`"
  649. CUPS_LIBS="${CUPS_LIBS} `$CUPSCONFIG --libs`"
  650. OPTIONAL_CUPS_CFLAGS="${CUPS_CFLAGS}"
  651. OPTIONAL_CUPS_LIBS="${CUPS_LIBS}"
  652. else
  653. enable_plugin_cups="no"
  654. fi
  655. AC_MSG_RESULT([${enable_plugin_cups}])
  656. AM_CONDITIONAL([ENABLE_PLUGIN_CUPS], [test "${enable_plugin_cups}" = "yes"])
  657. # -----------------------------------------------------------------------------
  658. # nfacct.plugin - libmnl, libnetfilter_acct
  659. AC_CHECK_HEADER(
  660. [linux/netfilter/nfnetlink_conntrack.h],
  661. [AC_CHECK_DECL(
  662. [CTA_STATS_MAX],
  663. [have_nfnetlink_conntrack=yes],
  664. [have_nfnetlink_conntrack=no],
  665. [#include <linux/netfilter/nfnetlink_conntrack.h>]
  666. )],
  667. [have_nfnetlink_conntrack=no]
  668. )
  669. PKG_CHECK_MODULES(
  670. [NFACCT],
  671. [libnetfilter_acct],
  672. [AC_CHECK_LIB(
  673. [netfilter_acct],
  674. [nfacct_alloc],
  675. [have_libnetfilter_acct=yes],
  676. [have_libnetfilter_acct=no]
  677. )],
  678. [have_libnetfilter_acct=no]
  679. )
  680. PKG_CHECK_MODULES(
  681. [LIBMNL],
  682. [libmnl],
  683. [AC_CHECK_LIB(
  684. [mnl],
  685. [mnl_socket_open],
  686. [have_libmnl=yes],
  687. [have_libmnl=no]
  688. )],
  689. [have_libmnl=no]
  690. )
  691. test "${enable_plugin_nfacct}" = "yes" -a "${have_nfnetlink_conntrack}" != "yes" && \
  692. AC_MSG_ERROR([nfnetlink_conntrack.h required but not found or too old])
  693. test "${enable_plugin_nfacct}" = "yes" -a "${have_libnetfilter_acct}" != "yes" && \
  694. AC_MSG_ERROR([netfilter_acct required but not found])
  695. test "${enable_plugin_nfacct}" = "yes" -a "${have_libmnl}" != "yes" && \
  696. AC_MSG_ERROR([libmnl required but not found. Try installing 'libmnl-dev' or 'libmnl-devel'])
  697. AC_MSG_CHECKING([if nfacct.plugin should be enabled])
  698. if test "${enable_plugin_nfacct}" != "no" -a "${have_libnetfilter_acct}" = "yes" \
  699. -a "${have_libmnl}" = "yes" \
  700. -a "${have_nfnetlink_conntrack}" = "yes"; then
  701. enable_plugin_nfacct="yes"
  702. AC_DEFINE([HAVE_LIBMNL], [1], [libmnl usability])
  703. AC_DEFINE([HAVE_LIBNETFILTER_ACCT], [1], [libnetfilter_acct usability])
  704. AC_DEFINE([HAVE_LINUX_NETFILTER_NFNETLINK_CONNTRACK_H], [1], [libnetfilter_nfnetlink_conntrack header usability])
  705. OPTIONAL_NFACCT_CFLAGS="${NFACCT_CFLAGS} ${LIBMNL_CFLAGS}"
  706. OPTIONAL_NFACCT_LIBS="${NFACCT_LIBS} ${LIBMNL_LIBS}"
  707. else
  708. enable_plugin_nfacct="no"
  709. fi
  710. AC_MSG_RESULT([${enable_plugin_nfacct}])
  711. AM_CONDITIONAL([ENABLE_PLUGIN_NFACCT], [test "${enable_plugin_nfacct}" = "yes"])
  712. # -----------------------------------------------------------------------------
  713. # xenstat.plugin - libxenstat
  714. PKG_CHECK_MODULES(
  715. [YAJL],
  716. [yajl],
  717. [AC_CHECK_LIB(
  718. [yajl],
  719. [yajl_tree_get],
  720. [have_libyajl=yes],
  721. [have_libyajl=no]
  722. )],
  723. [have_libyajl=no]
  724. )
  725. AC_CHECK_LIB(
  726. [xenstat],
  727. [xenstat_init],
  728. [AC_CHECK_HEADER(
  729. [xenstat.h],
  730. [have_libxenstat=yes],
  731. [have_libxenstat=no]
  732. )],
  733. [have_libxenstat=no],
  734. [-lyajl]
  735. )
  736. PKG_CHECK_MODULES(
  737. [XENLIGHT],
  738. [xenlight],
  739. [AC_CHECK_LIB(
  740. [xenlight],
  741. [libxl_domain_info],
  742. [AC_CHECK_HEADER(
  743. [libxl.h],
  744. [have_libxenlight=yes],
  745. [have_libxenlight=no]
  746. )],
  747. [have_libxenlight=no]
  748. )],
  749. [have_libxenlight=no]
  750. )
  751. test "${enable_plugin_xenstat}" = "yes" -a "${have_libxenstat}" != "yes" && \
  752. AC_MSG_ERROR([libxenstat required but not found. try installing 'xen-dom0-libs-devel'])
  753. test "${enable_plugin_xenstat}" = "yes" -a "${have_libxenlight}" != "yes" && \
  754. AC_MSG_ERROR([libxenlight required but not found. try installing 'xen-dom0-libs-devel'])
  755. test "${enable_plugin_xenstat}" = "yes" -a "${have_libyajl}" != "yes" && \
  756. AC_MSG_ERROR([libyajl required but not found. Try installing 'yajl-devel'])
  757. AC_MSG_CHECKING([if xenstat.plugin should be enabled])
  758. if test "${enable_plugin_xenstat}" != "no" -a "${have_libxenstat}" = "yes" -a "${have_libxenlight}" = "yes" -a "${have_libyajl}" = "yes"; then
  759. enable_plugin_xenstat="yes"
  760. AC_DEFINE([HAVE_LIBXENSTAT], [1], [libxenstat usability])
  761. AC_DEFINE([HAVE_LIBXENLIGHT], [1], [libxenlight usability])
  762. AC_DEFINE([HAVE_LIBYAJL], [1], [libyajl usability])
  763. OPTIONAL_XENSTAT_CFLAGS="${XENLIGHT_CFLAGS} ${YAJL_CFLAGS}"
  764. OPTIONAL_XENSTAT_LIBS="-lxenstat ${XENLIGHT_LIBS} ${YAJL_LIBS}"
  765. else
  766. enable_plugin_xenstat="no"
  767. fi
  768. AC_MSG_RESULT([${enable_plugin_xenstat}])
  769. AM_CONDITIONAL([ENABLE_PLUGIN_XENSTAT], [test "${enable_plugin_xenstat}" = "yes"])
  770. if test "${enable_plugin_xenstat}" == "yes"; then
  771. AC_MSG_CHECKING([for xenstat_vbd_error in -lxenstat])
  772. AC_TRY_LINK(
  773. [ #include <xenstat.h> ],
  774. [
  775. xenstat_vbd * vbd;
  776. int out = xenstat_vbd_error(vbd);
  777. ],
  778. [
  779. have_xenstat_vbd_error=yes
  780. AC_DEFINE([HAVE_XENSTAT_VBD_ERROR], [1], [xenstat_vbd_error usability])
  781. ],
  782. [ have_xenstat_vbd_error=no ]
  783. )
  784. AC_MSG_RESULT([${have_xenstat_vbd_error}])
  785. fi
  786. # -----------------------------------------------------------------------------
  787. # perf.plugin
  788. AC_CHECK_HEADER(
  789. [linux/perf_event.h],
  790. [AC_CHECK_DECL(
  791. [PERF_COUNT_HW_REF_CPU_CYCLES],
  792. [have_perf_event=yes],
  793. [have_perf_event=no],
  794. [#include <linux/perf_event.h>]
  795. )],
  796. [have_perf_event=no]
  797. )
  798. AC_MSG_CHECKING([if perf.plugin should be enabled])
  799. if test "${build_target}" == "linux" -a "${have_perf_event}" = "yes"; then
  800. enable_plugin_perf="yes"
  801. else
  802. enable_plugin_perf="no"
  803. fi
  804. AC_MSG_RESULT([${enable_plugin_perf}])
  805. AM_CONDITIONAL([ENABLE_PLUGIN_PERF], [test "${enable_plugin_perf}" = "yes"])
  806. # -----------------------------------------------------------------------------
  807. # ebpf_process.plugin
  808. AC_MSG_CHECKING([if ebpf_process.plugin should be enabled])
  809. if test "${build_target}" == "linux" -a "${EBPF_LIBS}"; then
  810. enable_vfs="yes"
  811. else
  812. enable_vfs="no"
  813. fi
  814. AC_MSG_RESULT([${enable_vfs}])
  815. AM_CONDITIONAL([ENABLE_PLUGIN_EBPF], [test "${enable_vfs}" = "yes"])
  816. # -----------------------------------------------------------------------------
  817. # slabinfo.plugin
  818. AC_MSG_CHECKING([if slabinfo.plugin should be enabled])
  819. if test "${build_target}" == "linux"; then
  820. enable_plugin_slabinfo="yes"
  821. else
  822. enable_plugin_slabinfo="no"
  823. fi
  824. AC_MSG_RESULT([${enable_plugin_slabinfo}])
  825. AM_CONDITIONAL([ENABLE_PLUGIN_SLABINFO], [test "${enable_plugin_slabinfo}" = "yes"])
  826. # -----------------------------------------------------------------------------
  827. # AWS Kinesis backend - libaws-cpp-sdk-kinesis, libaws-cpp-sdk-core, libssl, libcrypto, libcurl
  828. PKG_CHECK_MODULES(
  829. [LIBCRYPTO],
  830. [libcrypto],
  831. [AC_CHECK_LIB(
  832. [crypto],
  833. [CRYPTO_new_ex_data],
  834. [have_libcrypto=yes],
  835. [have_libcrypto=no]
  836. )],
  837. [have_libcrypto=no]
  838. )
  839. PKG_CHECK_MODULES(
  840. [LIBSSL],
  841. [libssl],
  842. [AC_CHECK_LIB(
  843. [ssl],
  844. [SSL_connect],
  845. [have_libssl=yes],
  846. [have_libssl=no]
  847. )],
  848. [have_libssl=no]
  849. )
  850. PKG_CHECK_MODULES(
  851. [LIBCURL],
  852. [libcurl],
  853. [AC_CHECK_LIB(
  854. [curl],
  855. [curl_easy_init],
  856. [have_libcurl=yes],
  857. [have_libcurl=no]
  858. )],
  859. [have_libcurl=no]
  860. )
  861. AC_CHECK_LIB(
  862. [aws-cpp-sdk-core],
  863. [cJSON_free],
  864. [have_libaws_cpp_sdk_core=yes],
  865. [have_libaws_cpp_sdk_core=no],
  866. [${LIBCRYPTO_LIBS} ${LIBSSL_LIBS} ${LIBCURL_LIBS}]
  867. )
  868. AC_MSG_CHECKING([for Aws::Kinesis::Model::PutRecordRequest in -laws-cpp-sdk-kinesis])
  869. if test "${have_libaws_cpp_sdk_core}" = "yes" -a "${have_libcrypto}" = "yes" -a "${have_libssl}" = "yes" -a "${have_libcurl}" = "yes"; then
  870. AC_LANG_SAVE
  871. AC_LANG_CPLUSPLUS
  872. save_LIBS="${LIBS}"
  873. LIBS="-laws-cpp-sdk-kinesis -laws-cpp-sdk-core ${LIBCRYPTO_LIBS} ${LIBSSL_LIBS} ${LIBCURL_LIBS}"
  874. save_CXXFLAGS="${CXXFLAGS}"
  875. CXXFLAGS="${CXXFLAGS} -std=c++11"
  876. AC_TRY_LINK(
  877. [
  878. #include <aws/core/Aws.h>
  879. #include <aws/core/client/ClientConfiguration.h>
  880. #include <aws/core/auth/AWSCredentials.h>
  881. #include <aws/core/utils/Outcome.h>
  882. #include <aws/kinesis/KinesisClient.h>
  883. #include <aws/kinesis/model/PutRecordRequest.h>
  884. ],
  885. [Aws::Kinesis::Model::PutRecordRequest request;],
  886. [have_libaws_cpp_sdk_kinesis=yes],
  887. [have_libaws_cpp_sdk_kinesis=no]
  888. )
  889. LIBS="${save_LIBS}"
  890. CXXFLAGS="${save_CXXFLAGS}"
  891. AC_LANG_RESTORE
  892. else
  893. have_libaws_cpp_sdk_kinesis=no
  894. fi
  895. AC_MSG_RESULT([${have_libaws_cpp_sdk_kinesis}])
  896. test "${enable_backend_kinesis}" = "yes" -a "${have_libaws_cpp_sdk_kinesis}" != "yes" && \
  897. AC_MSG_ERROR([libaws-cpp-sdk-kinesis required but not found. try installing AWS C++ SDK])
  898. test "${enable_backend_kinesis}" = "yes" -a "${have_libaws_cpp_sdk_core}" != "yes" && \
  899. AC_MSG_ERROR([libaws-cpp-sdk-core required but not found. try installing AWS C++ SDK])
  900. test "${enable_backend_kinesis}" = "yes" -a "${have_libcurl}" != "yes" && \
  901. AC_MSG_ERROR([libcurl required but not found])
  902. test "${enable_backend_kinesis}" = "yes" -a "${have_libssl}" != "yes" && \
  903. AC_MSG_ERROR([libssl required but not found])
  904. test "${enable_backend_kinesis}" = "yes" -a "${have_libcrypto}" != "yes" && \
  905. AC_MSG_ERROR([libcrypto required but not found])
  906. AC_MSG_CHECKING([if kinesis backend should be enabled])
  907. if test "${enable_backend_kinesis}" != "no" -a "${have_libaws_cpp_sdk_kinesis}" = "yes" -a "${have_libaws_cpp_sdk_core}" = "yes" \
  908. -a "${have_libcurl}" = "yes" -a "${have_libssl}" = "yes" -a "${have_libcrypto}" = "yes"; then
  909. enable_backend_kinesis="yes"
  910. AC_DEFINE([HAVE_KINESIS], [1], [libaws-cpp-sdk-kinesis usability])
  911. OPTIONAL_KINESIS_CFLAGS="${LIBCRYPTO_CFLAGS} ${LIBSSL_CFLAGS} ${LIBCURL_CFLAGS}"
  912. CXX11FLAG="-std=c++11"
  913. OPTIONAL_KINESIS_LIBS="-laws-cpp-sdk-kinesis -laws-cpp-sdk-core ${LIBCRYPTO_LIBS} ${LIBSSL_LIBS} ${LIBCURL_LIBS}"
  914. else
  915. enable_backend_kinesis="no"
  916. fi
  917. AC_MSG_RESULT([${enable_backend_kinesis}])
  918. AM_CONDITIONAL([ENABLE_BACKEND_KINESIS], [test "${enable_backend_kinesis}" = "yes"])
  919. # -----------------------------------------------------------------------------
  920. # Prometheus remote write backend - libprotobuf, libsnappy, protoc
  921. PKG_CHECK_MODULES(
  922. [PROTOBUF],
  923. [protobuf >= 3],
  924. [have_libprotobuf=yes],
  925. [have_libprotobuf=no]
  926. )
  927. AC_MSG_CHECKING([for snappy::RawCompress in -lsnappy])
  928. AC_LANG_SAVE
  929. AC_LANG_CPLUSPLUS
  930. save_LIBS="${LIBS}"
  931. LIBS="-lsnappy"
  932. save_CXXFLAGS="${CXXFLAGS}"
  933. CXXFLAGS="${CXXFLAGS} -std=c++11"
  934. AC_TRY_LINK(
  935. [
  936. #include <stdlib.h>
  937. #include <snappy.h>
  938. ],
  939. [
  940. const char *input = "test";
  941. size_t compressed_length;
  942. char *buffer = (char *)malloc(5 * sizeof(char));
  943. snappy::RawCompress(input, 4, buffer, &compressed_length);
  944. free(buffer);
  945. ],
  946. [
  947. have_libsnappy=yes
  948. SNAPPY_CFLAGS=""
  949. SNAPPY_LIBS="-lsnappy"
  950. ],
  951. [have_libsnappy=no]
  952. )
  953. LIBS="${save_LIBS}"
  954. CXXFLAGS="${save_CXXFLAGS}"
  955. AC_LANG_RESTORE
  956. AC_MSG_RESULT([${have_libsnappy}])
  957. AC_PATH_PROG([PROTOC], [protoc], [no])
  958. AS_IF(
  959. [test x"${PROTOC}" == x"no"],
  960. [have_protoc=no],
  961. [have_protoc=yes]
  962. )
  963. AC_PATH_PROG([CXX_BINARY], [${CXX}], [no])
  964. AS_IF(
  965. [test x"${CXX_BINARY}" == x"no"],
  966. [have_CXX_compiler=no],
  967. [have_CXX_compiler=yes]
  968. )
  969. test "${enable_backend_prometheus_remote_write}" = "yes" -a "${have_libprotobuf}" != "yes" && \
  970. AC_MSG_ERROR([libprotobuf required but not found. try installing protobuf])
  971. test "${enable_backend_prometheus_remote_write}" = "yes" -a "${have_libsnappy}" != "yes" && \
  972. AC_MSG_ERROR([libsnappy required but not found. try installing snappy])
  973. test "${enable_backend_prometheus_remote_write}" = "yes" -a "${have_protoc}" != "yes" && \
  974. AC_MSG_ERROR([protoc compiler required but not found. try installing protobuf])
  975. test "${enable_backend_prometheus_remote_write}" = "yes" -a "${have_CXX_compiler}" != "yes" && \
  976. AC_MSG_ERROR([C++ compiler required but not found. try installing g++])
  977. AC_MSG_CHECKING([if prometheus remote write backend should be enabled])
  978. if test "${enable_backend_prometheus_remote_write}" != "no" -a "${have_libprotobuf}" = "yes" -a "${have_libsnappy}" = "yes" \
  979. -a "${have_protoc}" = "yes" -a "${have_CXX_compiler}" = "yes"; then
  980. enable_backend_prometheus_remote_write="yes"
  981. AC_DEFINE([ENABLE_PROMETHEUS_REMOTE_WRITE], [1], [Prometheus remote write API usability])
  982. OPTIONAL_PROMETHEUS_REMOTE_WRITE_CFLAGS="${PROTOBUF_CFLAGS} ${SNAPPY_CFLAGS} -Iexporting/prometheus/remote_write"
  983. CXX11FLAG="-std=c++11"
  984. OPTIONAL_PROMETHEUS_REMOTE_WRITE_LIBS="${PROTOBUF_LIBS} ${SNAPPY_LIBS}"
  985. else
  986. enable_backend_prometheus_remote_write="no"
  987. fi
  988. AC_MSG_RESULT([${enable_backend_prometheus_remote_write}])
  989. AM_CONDITIONAL([ENABLE_BACKEND_PROMETHEUS_REMOTE_WRITE], [test "${enable_backend_prometheus_remote_write}" = "yes"])
  990. # -----------------------------------------------------------------------------
  991. # MongoDB backend - libmongoc
  992. PKG_CHECK_MODULES(
  993. [LIBMONGOC],
  994. [libmongoc-1.0 >= 1.7],
  995. [have_libmongoc=yes],
  996. [have_libmongoc=no]
  997. )
  998. test "${enable_backend_mongodb}" = "yes" -a "${have_libmongoc}" != "yes" && \
  999. AC_MSG_ERROR([libmongoc required but not found. Try installing `mongoc`.])
  1000. AC_MSG_CHECKING([if mongodb backend should be enabled])
  1001. if test "${enable_backend_mongodb}" != "no" -a "${have_libmongoc}" = "yes"; then
  1002. enable_backend_mongodb="yes"
  1003. AC_DEFINE([HAVE_MONGOC], [1], [libmongoc usability])
  1004. OPTIONAL_MONGOC_CFLAGS="${LIBMONGOC_CFLAGS}"
  1005. OPTIONAL_MONGOC_LIBS="${LIBMONGOC_LIBS}"
  1006. else
  1007. enable_backend_mongodb="no"
  1008. fi
  1009. AC_MSG_RESULT([${enable_backend_mongodb}])
  1010. AM_CONDITIONAL([ENABLE_BACKEND_MONGODB], [test "${enable_backend_mongodb}" = "yes"])
  1011. # -----------------------------------------------------------------------------
  1012. # check for setns() - cgroup-network
  1013. AC_CHECK_FUNC([setns])
  1014. AC_MSG_CHECKING([if cgroup-network can be enabled])
  1015. if test "$ac_cv_func_setns" = "yes" ; then
  1016. have_setns="yes"
  1017. AC_DEFINE([HAVE_SETNS], [1], [Define 1 if you have setns() function])
  1018. else
  1019. have_setns="no"
  1020. fi
  1021. AC_MSG_RESULT([${have_setns}])
  1022. AM_CONDITIONAL([ENABLE_PLUGIN_CGROUP_NETWORK], [test "${have_setns}" = "yes"])
  1023. # -----------------------------------------------------------------------------
  1024. # Link-Time-Optimization
  1025. if test "${enable_lto}" != "no"; then
  1026. opt="-flto"
  1027. AX_CHECK_COMPILE_FLAG(${opt}, [have_lto=yes], [have_lto=no])
  1028. fi
  1029. if test "${have_lto}" = "yes"; then
  1030. oCFLAGS="${CFLAGS}"
  1031. CFLAGS="${CFLAGS} -flto"
  1032. ac_cv_c_lto_cross_compile="${enable_lto}"
  1033. test "${ac_cv_c_lto_cross_compile}" != "yes" && ac_cv_c_lto_cross_compile="no"
  1034. AC_C_LTO
  1035. CFLAGS="${oCFLAGS}"
  1036. test "${ac_cv_c_lto}" != "yes" && have_lto="no"
  1037. fi
  1038. test "${enable_lto}" = "yes" -a "${have_lto}" != "yes" && \
  1039. AC_MSG_ERROR([LTO is required but is not available.])
  1040. AC_MSG_CHECKING([if LTO should be enabled])
  1041. if test "${enable_lto}" != "no" -a "${have_lto}" = "yes"; then
  1042. enable_lto="yes"
  1043. CFLAGS="${CFLAGS} -flto"
  1044. else
  1045. enable_lto="no"
  1046. fi
  1047. AC_MSG_RESULT([${enable_lto}])
  1048. # -----------------------------------------------------------------------------
  1049. AM_CONDITIONAL([ENABLE_CXX_LINKER], [test "${enable_backend_kinesis}" = "yes" -o "${enable_backend_prometheus_remote_write}" = "yes"])
  1050. AC_DEFINE_UNQUOTED([NETDATA_USER], ["${with_user}"], [use this user to drop privileged])
  1051. varlibdir="${localstatedir}/lib/netdata"
  1052. registrydir="${localstatedir}/lib/netdata/registry"
  1053. cachedir="${localstatedir}/cache/netdata"
  1054. chartsdir="${libexecdir}/netdata/charts.d"
  1055. nodedir="${libexecdir}/netdata/node.d"
  1056. pythondir="${libexecdir}/netdata/python.d"
  1057. configdir="${sysconfdir}/netdata"
  1058. libconfigdir="${libdir}/netdata/conf.d"
  1059. logdir="${localstatedir}/log/netdata"
  1060. pluginsdir="${libexecdir}/netdata/plugins.d"
  1061. AC_SUBST([build_target])
  1062. AC_SUBST([varlibdir])
  1063. AC_SUBST([registrydir])
  1064. AC_SUBST([cachedir])
  1065. AC_SUBST([chartsdir])
  1066. AC_SUBST([nodedir])
  1067. AC_SUBST([pythondir])
  1068. AC_SUBST([configdir])
  1069. AC_SUBST([libconfigdir])
  1070. AC_SUBST([logdir])
  1071. AC_SUBST([pluginsdir])
  1072. AC_SUBST([webdir])
  1073. CFLAGS="${CFLAGS} ${OPTIONAL_MATH_CFLAGS} ${OPTIONAL_NFACCT_CFLAGS} ${OPTIONAL_ZLIB_CFLAGS} ${OPTIONAL_UUID_CFLAGS} \
  1074. ${OPTIONAL_LIBCAP_CFLAGS} ${OPTIONAL_IPMIMONITORING_CFLAGS} ${OPTIONAL_CUPS_CFLAGS} ${OPTIONAL_XENSTAT_FLAGS} \
  1075. ${OPTIONAL_KINESIS_CFLAGS} ${OPTIONAL_PROMETHEUS_REMOTE_WRITE_CFLAGS} ${OPTIONAL_MONGOC_CFLAGS} ${LWS_CFLAGS} \
  1076. ${OPTIONAL_JSONC_STATIC_CFLAGS}"
  1077. CXXFLAGS="${CFLAGS} ${CXX11FLAG}"
  1078. CPPFLAGS="\
  1079. -DTARGET_OS=${build_target_id} \
  1080. -DVARLIB_DIR=\"\\\"${varlibdir}\\\"\" \
  1081. -DCACHE_DIR=\"\\\"${cachedir}\\\"\" \
  1082. -DCONFIG_DIR=\"\\\"${configdir}\\\"\" \
  1083. -DLIBCONFIG_DIR=\"\\\"${libconfigdir}\\\"\" \
  1084. -DLOG_DIR=\"\\\"${logdir}\\\"\" \
  1085. -DPLUGINS_DIR=\"\\\"${pluginsdir}\\\"\" \
  1086. -DRUN_DIR=\"\\\"${localstatedir}/run/netdata\\\"\" \
  1087. -DWEB_DIR=\"\\\"${webdir}\\\"\" \
  1088. "
  1089. AC_SUBST([OPTIONAL_MATH_CFLAGS])
  1090. AC_SUBST([OPTIONAL_MATH_LIBS])
  1091. AC_SUBST([OPTIONAL_UV_LIBS])
  1092. AC_SUBST([OPTIONAL_LZ4_LIBS])
  1093. AC_SUBST([OPTIONAL_JUDY_LIBS])
  1094. AC_SUBST([OPTIONAL_SSL_LIBS])
  1095. AC_SUBST([OPTIONAL_EBPF_LIBS])
  1096. AC_SUBST([OPTIONAL_JSONC_LIBS])
  1097. AC_SUBST([OPTIONAL_NFACCT_CFLAGS])
  1098. AC_SUBST([OPTIONAL_NFACCT_LIBS])
  1099. AC_SUBST([OPTIONAL_ZLIB_CFLAGS])
  1100. AC_SUBST([OPTIONAL_ZLIB_LIBS])
  1101. AC_SUBST([OPTIONAL_UUID_CFLAGS])
  1102. AC_SUBST([OPTIONAL_UUID_LIBS])
  1103. AC_SUBST([OPTIONAL_MQTT_LIBS])
  1104. AC_SUBST([OPTIONAL_LIBCAP_CFLAGS])
  1105. AC_SUBST([OPTIONAL_LIBCAP_LIBS])
  1106. AC_SUBST([OPTIONAL_IPMIMONITORING_CFLAGS])
  1107. AC_SUBST([OPTIONAL_IPMIMONITORING_LIBS])
  1108. AC_SUBST([OPTIONAL_CUPS_CFLAGS])
  1109. AC_SUBST([OPTIONAL_CUPS_LIBS])
  1110. AC_SUBST([OPTIONAL_XENSTAT_CFLAGS])
  1111. AC_SUBST([OPTIONAL_XENSTAT_LIBS])
  1112. AC_SUBST([OPTIONAL_KINESIS_CFLAGS])
  1113. AC_SUBST([OPTIONAL_KINESIS_LIBS])
  1114. AC_SUBST([OPTIONAL_PROMETHEUS_REMOTE_WRITE_CFLAGS])
  1115. AC_SUBST([OPTIONAL_PROMETHEUS_REMOTE_WRITE_LIBS])
  1116. AC_SUBST([OPTIONAL_MONGOC_CFLAGS])
  1117. AC_SUBST([OPTIONAL_MONGOC_LIBS])
  1118. # -----------------------------------------------------------------------------
  1119. # Check if cmocka is available - needed for unit testing
  1120. AC_ARG_ENABLE(
  1121. [unit-tests],
  1122. [AS_HELP_STRING([--disable-unit-tests],
  1123. [Disables building and running the unit tests suite])],
  1124. [],
  1125. [enable_unit_tests="yes"]
  1126. )
  1127. PKG_CHECK_MODULES(
  1128. [CMOCKA],
  1129. [cmocka],
  1130. [have_cmocka="yes"],
  1131. [AC_MSG_NOTICE([CMocka not found on the system. Unit tests disabled])]
  1132. )
  1133. AM_CONDITIONAL([ENABLE_UNITTESTS], [test "${enable_unit_tests}" = "yes" -a "${have_cmocka}" = "yes" ])
  1134. AC_SUBST([ENABLE_UNITTESTS])
  1135. TEST_CFLAGS="${CFLAGS} ${CMOCKA_CFLAGS}"
  1136. TEST_LIBS="${CMOCKA_LIBS}"
  1137. AC_SUBST([TEST_CFLAGS])
  1138. AC_SUBST([TEST_LIBS])
  1139. AC_CONFIG_FILES([
  1140. Makefile
  1141. netdata.spec
  1142. backends/graphite/Makefile
  1143. backends/json/Makefile
  1144. backends/Makefile
  1145. backends/opentsdb/Makefile
  1146. backends/prometheus/Makefile
  1147. backends/prometheus/remote_write/Makefile
  1148. backends/aws_kinesis/Makefile
  1149. backends/mongodb/Makefile
  1150. collectors/Makefile
  1151. collectors/apps.plugin/Makefile
  1152. collectors/cgroups.plugin/Makefile
  1153. collectors/charts.d.plugin/Makefile
  1154. collectors/checks.plugin/Makefile
  1155. collectors/diskspace.plugin/Makefile
  1156. collectors/fping.plugin/Makefile
  1157. collectors/ioping.plugin/Makefile
  1158. collectors/freebsd.plugin/Makefile
  1159. collectors/freeipmi.plugin/Makefile
  1160. collectors/cups.plugin/Makefile
  1161. collectors/idlejitter.plugin/Makefile
  1162. collectors/macos.plugin/Makefile
  1163. collectors/nfacct.plugin/Makefile
  1164. collectors/node.d.plugin/Makefile
  1165. collectors/plugins.d/Makefile
  1166. collectors/proc.plugin/Makefile
  1167. collectors/python.d.plugin/Makefile
  1168. collectors/slabinfo.plugin/Makefile
  1169. collectors/statsd.plugin/Makefile
  1170. collectors/ebpf_process.plugin/Makefile
  1171. collectors/tc.plugin/Makefile
  1172. collectors/xenstat.plugin/Makefile
  1173. collectors/perf.plugin/Makefile
  1174. daemon/Makefile
  1175. database/Makefile
  1176. database/engine/Makefile
  1177. diagrams/Makefile
  1178. exporting/Makefile
  1179. exporting/graphite/Makefile
  1180. exporting/json/Makefile
  1181. exporting/opentsdb/Makefile
  1182. exporting/prometheus/Makefile
  1183. exporting/prometheus/remote_write/Makefile
  1184. exporting/aws_kinesis/Makefile
  1185. exporting/mongodb/Makefile
  1186. exporting/tests/Makefile
  1187. health/Makefile
  1188. health/notifications/Makefile
  1189. libnetdata/Makefile
  1190. libnetdata/tests/Makefile
  1191. libnetdata/adaptive_resortable_list/Makefile
  1192. libnetdata/avl/Makefile
  1193. libnetdata/buffer/Makefile
  1194. libnetdata/clocks/Makefile
  1195. libnetdata/config/Makefile
  1196. libnetdata/dictionary/Makefile
  1197. libnetdata/ebpf/Makefile
  1198. libnetdata/eval/Makefile
  1199. libnetdata/locks/Makefile
  1200. libnetdata/log/Makefile
  1201. libnetdata/popen/Makefile
  1202. libnetdata/procfile/Makefile
  1203. libnetdata/simple_pattern/Makefile
  1204. libnetdata/socket/Makefile
  1205. libnetdata/statistical/Makefile
  1206. libnetdata/storage_number/Makefile
  1207. libnetdata/storage_number/tests/Makefile
  1208. libnetdata/threads/Makefile
  1209. libnetdata/url/Makefile
  1210. libnetdata/json/Makefile
  1211. libnetdata/health/Makefile
  1212. registry/Makefile
  1213. streaming/Makefile
  1214. system/Makefile
  1215. tests/Makefile
  1216. web/Makefile
  1217. web/api/Makefile
  1218. web/api/badges/Makefile
  1219. web/api/exporters/Makefile
  1220. web/api/exporters/shell/Makefile
  1221. web/api/exporters/prometheus/Makefile
  1222. web/api/formatters/Makefile
  1223. web/api/formatters/csv/Makefile
  1224. web/api/formatters/json/Makefile
  1225. web/api/formatters/ssv/Makefile
  1226. web/api/formatters/value/Makefile
  1227. web/api/queries/Makefile
  1228. web/api/queries/average/Makefile
  1229. web/api/queries/des/Makefile
  1230. web/api/queries/incremental_sum/Makefile
  1231. web/api/queries/max/Makefile
  1232. web/api/queries/median/Makefile
  1233. web/api/queries/min/Makefile
  1234. web/api/queries/ses/Makefile
  1235. web/api/queries/stddev/Makefile
  1236. web/api/queries/sum/Makefile
  1237. web/api/health/Makefile
  1238. web/gui/Makefile
  1239. web/server/Makefile
  1240. web/server/static/Makefile
  1241. claim/Makefile
  1242. aclk/Makefile
  1243. ])
  1244. AC_OUTPUT
  1245. test "${with_math}" != "yes" && AC_MSG_WARN([You are building without math. math allows accurate calculations. It should be enabled.]) || :
  1246. 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.]) || :