configure.ac 40 KB

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