configure.ac 41 KB

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