configure.ac 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977
  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. AM_PROG_CC_C_O
  34. AC_PROG_CXX
  35. AC_PROG_INSTALL
  36. PKG_PROG_PKG_CONFIG
  37. AC_USE_SYSTEM_EXTENSIONS
  38. # -----------------------------------------------------------------------------
  39. # configurable options
  40. AC_ARG_ENABLE(
  41. [plugin-nfacct],
  42. [AS_HELP_STRING([--enable-plugin-nfacct], [enable nfacct plugin @<:@default autodetect@:>@])],
  43. ,
  44. [enable_plugin_nfacct="detect"]
  45. )
  46. AC_ARG_ENABLE(
  47. [plugin-freeipmi],
  48. [AS_HELP_STRING([--enable-plugin-freeipmi], [enable freeipmi plugin @<:@default autodetect@:>@])],
  49. ,
  50. [enable_plugin_freeipmi="detect"]
  51. )
  52. AC_ARG_ENABLE(
  53. [plugin-cups],
  54. [AS_HELP_STRING([--enable-plugin-cups], [enable cups plugin @<:@default autodetect@:>@])],
  55. ,
  56. [enable_plugin_cups="detect"]
  57. )
  58. AC_ARG_ENABLE(
  59. [plugin-xenstat],
  60. [AS_HELP_STRING([--enable-plugin-xenstat], [enable xenstat plugin @<:@default autodetect@:>@])],
  61. ,
  62. [enable_plugin_xenstat="detect"]
  63. )
  64. AC_ARG_ENABLE(
  65. [backend-kinesis],
  66. [AS_HELP_STRING([--enable-backend-xenstat], [enable kinesis backend @<:@default autodetect@:>@])],
  67. ,
  68. [enable_backend_kinesis="detect"]
  69. )
  70. AC_ARG_ENABLE(
  71. [pedantic],
  72. [AS_HELP_STRING([--enable-pedantic], [enable pedantic compiler warnings @<:@default disabled@:>@])],
  73. ,
  74. [enable_pedantic="no"]
  75. )
  76. AC_ARG_ENABLE(
  77. [accept4],
  78. [AS_HELP_STRING([--disable-accept4], [System does not have accept4 @<:@default autodetect@:>@])],
  79. ,
  80. [enable_accept4="detect"]
  81. )
  82. AC_ARG_WITH(
  83. [webdir],
  84. [AS_HELP_STRING([--with-webdir], [location of webdir @<:@PKGDATADIR/web@:>@])],
  85. [webdir="${withval}"],
  86. [webdir="\$(pkgdatadir)/web"]
  87. )
  88. AC_ARG_WITH(
  89. [libcap],
  90. [AS_HELP_STRING([--with-libcap], [build with libcap @<:@default autodetect@:>@])],
  91. ,
  92. [with_libcap="detect"]
  93. )
  94. AC_ARG_WITH(
  95. [zlib],
  96. [AS_HELP_STRING([--without-zlib], [build without zlib @<:@default enabled@:>@])],
  97. ,
  98. [with_zlib="yes"]
  99. )
  100. AC_ARG_WITH(
  101. [math],
  102. [AS_HELP_STRING([--without-math], [build without math @<:@default enabled@:>@])],
  103. ,
  104. [with_math="yes"]
  105. )
  106. AC_ARG_WITH(
  107. [user],
  108. [AS_HELP_STRING([--with-user], [use this user to drop privilege @<:@default nobody@:>@])],
  109. ,
  110. [with_user="nobody"]
  111. )
  112. AC_ARG_ENABLE(
  113. [x86-sse],
  114. [AS_HELP_STRING([--disable-x86-sse], [SSE/SS2 optimizations on x86 @<:@default enabled@:>@])],
  115. ,
  116. [enable_x86_sse="yes"]
  117. )
  118. AC_ARG_ENABLE(
  119. [lto],
  120. [AS_HELP_STRING([--disable-lto], [Link Time Optimizations @<:@default autodetect@:>@])],
  121. ,
  122. [enable_lto="detect"]
  123. )
  124. AC_ARG_ENABLE(
  125. [dbengine],
  126. [AS_HELP_STRING([--disable-dbengine], [disable netdata dbengine @<:@default autodetect@:>@])],
  127. ,
  128. [enable_dbengine="detect"]
  129. )
  130. # -----------------------------------------------------------------------------
  131. # netdata required checks
  132. # fails on centos6
  133. #AX_CHECK_ENABLE_DEBUG()
  134. AX_GCC_FUNC_ATTRIBUTE([returns_nonnull])
  135. AX_GCC_FUNC_ATTRIBUTE([malloc])
  136. AX_GCC_FUNC_ATTRIBUTE([noreturn])
  137. AX_GCC_FUNC_ATTRIBUTE([noinline])
  138. AX_GCC_FUNC_ATTRIBUTE([format])
  139. AX_GCC_FUNC_ATTRIBUTE([warn_unused_result])
  140. AC_CHECK_TYPES([struct timespec, clockid_t], [], [], [[#include <time.h>]])
  141. AC_SEARCH_LIBS([clock_gettime], [rt posix4])
  142. AC_CHECK_FUNCS([clock_gettime])
  143. AC_CHECK_FUNCS([sched_setscheduler sched_getscheduler sched_getparam sched_get_priority_min sched_get_priority_max getpriority setpriority nice])
  144. AC_CHECK_FUNCS([recvmmsg])
  145. AC_TYPE_INT8_T
  146. AC_TYPE_INT16_T
  147. AC_TYPE_INT32_T
  148. AC_TYPE_INT64_T
  149. AC_TYPE_UINT8_T
  150. AC_TYPE_UINT16_T
  151. AC_TYPE_UINT32_T
  152. AC_TYPE_UINT64_T
  153. AC_C_INLINE
  154. AC_FUNC_STRERROR_R
  155. AC_C__GENERIC
  156. AC_C___ATOMIC
  157. # AC_C_STMT_EXPR
  158. AC_CHECK_SIZEOF([void *])
  159. AC_CANONICAL_HOST
  160. AC_HEADER_MAJOR
  161. AC_HEADER_RESOLV
  162. AC_CHECK_HEADERS_ONCE([sys/prctl.h])
  163. AC_CHECK_HEADERS_ONCE([sys/vfs.h])
  164. AC_CHECK_HEADERS_ONCE([sys/statfs.h])
  165. AC_CHECK_HEADERS_ONCE([sys/statvfs.h])
  166. AC_CHECK_HEADERS_ONCE([sys/mount.h])
  167. if test "${enable_accept4}" != "no"; then
  168. AC_CHECK_FUNCS_ONCE(accept4)
  169. fi
  170. # -----------------------------------------------------------------------------
  171. # operating system detection
  172. AC_MSG_CHECKING([operating system])
  173. case "$host_os" in
  174. freebsd*)
  175. build_target=freebsd
  176. build_target_id=2
  177. CFLAGS="${CFLAGS} -I/usr/local/include -L/usr/local/lib"
  178. ;;
  179. darwin*)
  180. build_target=macos
  181. build_target_id=3
  182. LDFLAGS="${LDFLAGS} -framework CoreFoundation -framework IOKit"
  183. ;;
  184. *)
  185. build_target=linux
  186. build_target_id=1
  187. ;;
  188. esac
  189. AM_CONDITIONAL([FREEBSD], [test "${build_target}" = "freebsd"])
  190. AM_CONDITIONAL([MACOS], [test "${build_target}" = "macos"])
  191. AM_CONDITIONAL([LINUX], [test "${build_target}" = "linux"])
  192. AC_MSG_RESULT([${build_target} with id ${build_target_id}])
  193. # -----------------------------------------------------------------------------
  194. # pthreads
  195. ACX_PTHREAD(, [AC_MSG_ERROR([Cannot initialize pthread environment])])
  196. LIBS="${PTHREAD_LIBS} ${LIBS}"
  197. CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}"
  198. CC="${PTHREAD_CC}"
  199. # -----------------------------------------------------------------------------
  200. # libm
  201. AC_ARG_VAR([MATH_CFLAGS], [C compiler flags for math])
  202. AC_ARG_VAR([MATH_LIBS], [linker flags for math])
  203. if test -z "${MATH_LIBS}"; then
  204. AC_CHECK_LIB(
  205. [m],
  206. [sin],
  207. [MATH_LIBS="-lm"]
  208. )
  209. fi
  210. test "${with_math}" = "yes" -a -z "${MATH_LIBS}" && AC_MSG_ERROR([math required but not found])
  211. AC_MSG_CHECKING([if libm should be used])
  212. if test "${with_math}" != "no" -a ! -z "${MATH_LIBS}"; then
  213. with_math="yes"
  214. AC_DEFINE([STORAGE_WITH_MATH], [1], [math usability])
  215. OPTIONAL_MATH_CFLAGS="${MATH_CFLAGS}"
  216. OPTIONAL_MATH_LIBS="${MATH_LIBS}"
  217. else
  218. with_math="no"
  219. fi
  220. AC_MSG_RESULT([${with_math}])
  221. # -----------------------------------------------------------------------------
  222. # libuv multi-platform support library with a focus on asynchronous I/O
  223. # TODO: check version, uv_fs_scandir_next only available in version >= 1.0
  224. AC_CHECK_LIB(
  225. [uv],
  226. [uv_fs_scandir_next],
  227. [UV_LIBS="-luv"]
  228. )
  229. OPTIONAL_UV_CLFAGS="${UV_CFLAGS}"
  230. OPTIONAL_UV_LIBS="${UV_LIBS}"
  231. # -----------------------------------------------------------------------------
  232. # lz4 Extremely Fast Compression algorithm
  233. AC_CHECK_LIB(
  234. [lz4],
  235. [LZ4_decompress_safe],
  236. [LZ4_LIBS="-llz4"]
  237. )
  238. OPTIONAL_LZ4_CLFAGS="${LZ4_CFLAGS}"
  239. OPTIONAL_LZ4_LIBS="${LZ4_LIBS}"
  240. # -----------------------------------------------------------------------------
  241. # Judy General purpose dynamic array
  242. AC_CHECK_LIB(
  243. [Judy],
  244. [JudyLIns],
  245. [JUDY_LIBS="-lJudy"]
  246. )
  247. OPTIONAL_JUDY_CLFAGS="${JUDY_CFLAGS}"
  248. OPTIONAL_JUDY_LIBS="${JUDY_LIBS}"
  249. # -----------------------------------------------------------------------------
  250. # zlib
  251. PKG_CHECK_MODULES(
  252. [ZLIB],
  253. [zlib],
  254. [have_zlib=yes],
  255. [have_zlib=no]
  256. )
  257. test "${with_zlib}" = "yes" -a "${have_zlib}" != "yes" && AC_MSG_ERROR([zlib required but not found. Try installing 'zlib1g-dev' or 'zlib-devel'.])
  258. AC_MSG_CHECKING([if zlib should be used])
  259. if test "${with_zlib}" != "no" -a "${have_zlib}" = "yes"; then
  260. with_zlib="yes"
  261. AC_DEFINE([NETDATA_WITH_ZLIB], [1], [zlib usability])
  262. OPTIONAL_ZLIB_CFLAGS="${ZLIB_CFLAGS}"
  263. OPTIONAL_ZLIB_LIBS="${ZLIB_LIBS}"
  264. else
  265. with_zlib="no"
  266. fi
  267. AC_MSG_RESULT([${with_zlib}])
  268. # -----------------------------------------------------------------------------
  269. # libuuid
  270. PKG_CHECK_MODULES(
  271. [UUID],
  272. [uuid],
  273. [have_uuid=yes],
  274. [AC_MSG_ERROR([libuuid required but not found. Try installing 'uuid-dev' or 'libuuid-devel'.])]
  275. )
  276. AC_DEFINE([NETDATA_WITH_UUID], [1], [uuid usability])
  277. OPTIONAL_UUID_CFLAGS="${UUID_CFLAGS}"
  278. OPTIONAL_UUID_LIBS="${UUID_LIBS}"
  279. # -----------------------------------------------------------------------------
  280. # OpenSSL Cryptography and SSL/TLS Toolkit
  281. AC_CHECK_LIB(
  282. [crypto],
  283. [SHA256_Init],
  284. [SSL_LIBS="-lcrypto -lssl"]
  285. )
  286. OPTIONAL_SSL_CLFAGS="${SSL_CFLAGS}"
  287. OPTIONAL_SSL_LIBS="${SSL_LIBS}"
  288. # -----------------------------------------------------------------------------
  289. # DB engine
  290. test "${enable_dbengine}" = "yes" -a -z "${UV_LIBS}" && \
  291. AC_MSG_ERROR([libuv required but not found. Try installing 'libuv1-dev' or 'libuv-devel'.])
  292. test "${enable_dbengine}" = "yes" -a -z "${LZ4_LIBS}" && \
  293. AC_MSG_ERROR([liblz4 required but not found. Try installing 'liblz4-dev' or 'lz4-devel'.])
  294. test "${enable_dbengine}" = "yes" -a -z "${JUDY_LIBS}" && \
  295. AC_MSG_ERROR([libJudy required but not found. Try installing 'libjudy-dev' or 'Judy-devel'.])
  296. test "${enable_dbengine}" = "yes" -a -z "${SSL_LIBS}" && \
  297. AC_MSG_ERROR([OpenSSL required but not found. Try installing 'libssl-dev' or 'openssl-devel'.])
  298. AC_MSG_CHECKING([if netdata dbengine should be used])
  299. if test "${enable_dbengine}" != "no" -a "${UV_LIBS}" -a "${LZ4_LIBS}" -a "${JUDY_LIBS}" -a "${SSL_LIBS}"; then
  300. enable_dbengine="yes"
  301. AC_DEFINE([ENABLE_DBENGINE], [1], [netdata dbengine usability])
  302. else
  303. enable_dbengine="no"
  304. fi
  305. AC_MSG_RESULT([${enable_dbengine}])
  306. AM_CONDITIONAL([ENABLE_DBENGINE], [test "${enable_dbengine}" = "yes"])
  307. # -----------------------------------------------------------------------------
  308. # compiler options
  309. AC_ARG_VAR([SSE_CANDIDATE], [C compiler flags for SSE])
  310. AS_CASE([$host_cpu],
  311. [i?86], [SSE_CANDIDATE="yes"]
  312. )
  313. AC_SUBST([SSE_CANDIDATE])
  314. if test "${SSE_CANDIDATE}" = "yes" -a "${enable_x86_sse}" = "yes"; then
  315. opt="-msse2 -mfpmath=sse"
  316. AX_CHECK_COMPILE_FLAG(${opt}, [CFLAGS="${CFLAGS} ${opt}"], [])
  317. fi
  318. if test "${GCC}" = "yes"; then
  319. AC_DEFINE_UNQUOTED([likely(x)], [__builtin_expect(!!(x), 1)], [gcc branch optimization])
  320. AC_DEFINE_UNQUOTED([unlikely(x)], [__builtin_expect(!!(x), 0)], [gcc branch optimization])
  321. else
  322. AC_DEFINE_UNQUOTED([likely(x)], [(x)], [gcc branch optimization])
  323. AC_DEFINE_UNQUOTED([unlikely(x)], [(x)], [gcc branch optimization])
  324. fi
  325. if test "${enable_pedantic}" = "yes"; then
  326. enable_strict="yes"
  327. CFLAGS="${CFLAGS} -pedantic -Wall -Wextra -Wno-long-long"
  328. fi
  329. # -----------------------------------------------------------------------------
  330. # memory allocation library
  331. AC_MSG_CHECKING([for memory allocator])
  332. TS_CHECK_JEMALLOC
  333. if test "$has_jemalloc" = "1"; then
  334. AC_DEFINE([ENABLE_JEMALLOC], [1], [compile and link with jemalloc])
  335. AC_MSG_RESULT([jemalloc])
  336. else
  337. TS_CHECK_TCMALLOC
  338. if test "$has_tcmalloc" = "1"; then
  339. AC_DEFINE([ENABLE_TCMALLOC], [1], [compile and link with tcmalloc])
  340. AC_MSG_RESULT([tcmalloc])
  341. else
  342. AC_MSG_RESULT([system])
  343. AC_C_MALLOPT
  344. AC_C_MALLINFO
  345. fi
  346. fi
  347. # -----------------------------------------------------------------------------
  348. # libcap
  349. PKG_CHECK_MODULES(
  350. [LIBCAP],
  351. [libcap],
  352. [AC_CHECK_LIB([cap], [cap_get_proc, cap_set_proc],
  353. [AC_CHECK_HEADER(
  354. [sys/capability.h],
  355. [have_libcap=yes],
  356. [have_libcap=no]
  357. )],
  358. [have_libcap=no]
  359. )],
  360. [have_libcap=no]
  361. )
  362. test "${with_libcap}" = "yes" -a "${have_libcap}" != "yes" && AC_MSG_ERROR([libcap required but not found.])
  363. AC_MSG_CHECKING([if libcap should be used])
  364. if test "${with_libcap}" != "no" -a "${have_libcap}" = "yes"; then
  365. with_libcap="yes"
  366. AC_DEFINE([HAVE_CAPABILITY], [1], [libcap usability])
  367. OPTIONAL_LIBCAP_CFLAGS="${LIBCAP_CFLAGS}"
  368. OPTIONAL_LIBCAP_LIBS="${LIBCAP_LIBS}"
  369. else
  370. with_libcap="no"
  371. fi
  372. AC_MSG_RESULT([${with_libcap}])
  373. AM_CONDITIONAL([ENABLE_CAPABILITY], [test "${with_libcap}" = "yes"])
  374. # -----------------------------------------------------------------------------
  375. # apps.plugin
  376. AC_MSG_CHECKING([if apps.plugin should be enabled])
  377. if test "${build_target}" != "macos"; then
  378. enable_plugin_apps="yes"
  379. else
  380. enable_plugin_apps="no"
  381. fi
  382. AC_MSG_RESULT([${enable_plugin_apps}])
  383. AM_CONDITIONAL([ENABLE_PLUGIN_APPS], [test "${enable_plugin_apps}" = "yes"])
  384. # -----------------------------------------------------------------------------
  385. # freeipmi.plugin - libipmimonitoring
  386. PKG_CHECK_MODULES(
  387. [IPMIMONITORING],
  388. [libipmimonitoring],
  389. [AC_CHECK_LIB([ipmimonitoring], [
  390. ipmi_monitoring_sensor_readings_by_record_id,
  391. ipmi_monitoring_sensor_readings_by_sensor_type,
  392. ipmi_monitoring_sensor_read_sensor_number,
  393. ipmi_monitoring_sensor_read_sensor_name,
  394. ipmi_monitoring_sensor_read_sensor_state,
  395. ipmi_monitoring_sensor_read_sensor_units,
  396. ipmi_monitoring_sensor_iterator_next,
  397. ipmi_monitoring_ctx_sensor_config_file,
  398. ipmi_monitoring_ctx_sdr_cache_directory,
  399. ipmi_monitoring_ctx_errormsg,
  400. ipmi_monitoring_ctx_create
  401. ],
  402. [AC_CHECK_HEADER(
  403. [ipmi_monitoring.h],
  404. [AC_CHECK_HEADER(
  405. [ipmi_monitoring_bitmasks.h],
  406. [have_ipmimonitoring=yes],
  407. [have_ipmimonitoring=no]
  408. )],
  409. [have_ipmimonitoring=no]
  410. )],
  411. [have_ipmimonitoring=no]
  412. )],
  413. [have_ipmimonitoring=no]
  414. )
  415. test "${enable_plugin_freeipmi}" = "yes" -a "${have_ipmimonitoring}" != "yes" && \
  416. AC_MSG_ERROR([ipmimonitoring required but not found. Try installing 'libipmimonitoring-dev' or 'libipmimonitoring-devel'])
  417. AC_MSG_CHECKING([if freeipmi.plugin should be enabled])
  418. if test "${enable_plugin_freeipmi}" != "no" -a "${have_ipmimonitoring}" = "yes"; then
  419. enable_plugin_freeipmi="yes"
  420. AC_DEFINE([HAVE_FREEIPMI], [1], [ipmimonitoring usability])
  421. OPTIONAL_IPMIMONITORING_CFLAGS="${IPMIMONITORING_CFLAGS}"
  422. OPTIONAL_IPMIMONITORING_LIBS="${IPMIMONITORING_LIBS}"
  423. else
  424. enable_plugin_freeipmi="no"
  425. fi
  426. AC_MSG_RESULT([${enable_plugin_freeipmi}])
  427. AM_CONDITIONAL([ENABLE_PLUGIN_FREEIPMI], [test "${enable_plugin_freeipmi}" = "yes"])
  428. # -----------------------------------------------------------------------------
  429. # cups.plugin - libcups
  430. # Only check most recently added method of cups
  431. AC_CHECK_LIB([cups], [httpConnect2],
  432. [AC_CHECK_HEADER(
  433. [cups/cups.h],
  434. [have_cups=yes],
  435. [have_cups=no]
  436. )],
  437. [have_cups=no]
  438. )
  439. test "${enable_plugin_cups}" = "yes" -a "${have_cups}" != "yes" && \
  440. AC_MSG_ERROR([cups required but not found. Try installing 'cups'])
  441. AC_ARG_WITH([cups-config],
  442. [AS_HELP_STRING([--with-cups-config=path], [Specify path to cups-config executable.])],
  443. [with_cups_config="$withval"],
  444. [with_cups_config=system]
  445. )
  446. AS_IF([test "x$with_cups_config" != "xsystem"], [
  447. CUPSCONFIG=$with_cups_config
  448. ], [
  449. AC_PATH_TOOL(CUPSCONFIG, [cups-config])
  450. AS_IF([test -z "$CUPSCONFIG"], [
  451. have_cups=no
  452. ])
  453. ])
  454. AC_MSG_CHECKING([if cups.plugin should be enabled])
  455. if test "${enable_plugin_cups}" != "no" -a "${have_cups}" = "yes"; then
  456. enable_plugin_cups="yes"
  457. AC_DEFINE([HAVE_CUPS], [1], [cups usability])
  458. CUPS_CFLAGS="${CUPS_CFLAGS} `$CUPSCONFIG --cflags`"
  459. CUPS_LIBS="${CUPS_LIBS} `$CUPSCONFIG --libs`"
  460. OPTIONAL_CUPS_CFLAGS="${CUPS_CFLAGS}"
  461. OPTIONAL_CUPS_LIBS="${CUPS_LIBS}"
  462. else
  463. enable_plugin_cups="no"
  464. fi
  465. AC_MSG_RESULT([${enable_plugin_cups}])
  466. AM_CONDITIONAL([ENABLE_PLUGIN_CUPS], [test "${enable_plugin_cups}" = "yes"])
  467. # -----------------------------------------------------------------------------
  468. # nfacct.plugin - libmnl, libnetfilter_acct
  469. AC_CHECK_HEADERS_ONCE([linux/netfilter/nfnetlink_conntrack.h])
  470. PKG_CHECK_MODULES(
  471. [NFACCT],
  472. [libnetfilter_acct],
  473. [AC_CHECK_LIB(
  474. [netfilter_acct],
  475. [nfacct_alloc],
  476. [have_libnetfilter_acct=yes],
  477. [have_libnetfilter_acct=no]
  478. )],
  479. [have_libnetfilter_acct=no]
  480. )
  481. PKG_CHECK_MODULES(
  482. [LIBMNL],
  483. [libmnl],
  484. [AC_CHECK_LIB(
  485. [mnl],
  486. [mnl_socket_open],
  487. [have_libmnl=yes],
  488. [have_libmnl=no]
  489. )],
  490. [have_libmnl=no]
  491. )
  492. test "${enable_plugin_nfacct}" = "yes" -a "${have_libnetfilter_acct}" != "yes" && \
  493. AC_MSG_ERROR([netfilter_acct required but not found])
  494. test "${enable_plugin_nfacct}" = "yes" -a "${have_libmnl}" != "yes" && \
  495. AC_MSG_ERROR([libmnl required but not found. Try installing 'libmnl-dev' or 'libmnl-devel'])
  496. AC_MSG_CHECKING([if nfacct.plugin should be enabled])
  497. if test "${enable_plugin_nfacct}" != "no" -a "${have_libnetfilter_acct}" = "yes" -a "${have_libmnl}" = "yes"; then
  498. enable_plugin_nfacct="yes"
  499. AC_DEFINE([HAVE_LIBMNL], [1], [libmnl usability])
  500. AC_DEFINE([HAVE_LIBNETFILTER_ACCT], [1], [libnetfilter_acct usability])
  501. OPTIONAL_NFACCT_CFLAGS="${NFACCT_CFLAGS} ${LIBMNL_CFLAGS}"
  502. OPTIONAL_NFACCT_LIBS="${NFACCT_LIBS} ${LIBMNL_LIBS}"
  503. else
  504. enable_plugin_nfacct="no"
  505. fi
  506. AC_MSG_RESULT([${enable_plugin_nfacct}])
  507. AM_CONDITIONAL([ENABLE_PLUGIN_NFACCT], [test "${enable_plugin_nfacct}" = "yes"])
  508. # -----------------------------------------------------------------------------
  509. # xenstat.plugin - libxenstat
  510. PKG_CHECK_MODULES(
  511. [YAJL],
  512. [yajl],
  513. [AC_CHECK_LIB(
  514. [yajl],
  515. [yajl_tree_get],
  516. [have_libyajl=yes],
  517. [have_libyajl=no]
  518. )],
  519. [have_libyajl=no]
  520. )
  521. AC_CHECK_LIB(
  522. [xenstat],
  523. [xenstat_init],
  524. [AC_CHECK_HEADER(
  525. [xenstat.h],
  526. [have_libxenstat=yes],
  527. [have_libxenstat=no]
  528. )],
  529. [have_libxenstat=no],
  530. [-lyajl]
  531. )
  532. PKG_CHECK_MODULES(
  533. [XENLIGHT],
  534. [xenlight],
  535. [AC_CHECK_LIB(
  536. [xenlight],
  537. [libxl_domain_info],
  538. [AC_CHECK_HEADER(
  539. [libxl.h],
  540. [have_libxenlight=yes],
  541. [have_libxenlight=no]
  542. )],
  543. [have_libxenlight=no]
  544. )],
  545. [have_libxenlight=no]
  546. )
  547. test "${enable_plugin_xenstat}" = "yes" -a "${have_libxenstat}" != "yes" && \
  548. AC_MSG_ERROR([libxenstat required but not found. try installing 'xen-dom0-libs-devel'])
  549. test "${enable_plugin_xenstat}" = "yes" -a "${have_libxenlight}" != "yes" && \
  550. AC_MSG_ERROR([libxenlight required but not found. try installing 'xen-dom0-libs-devel'])
  551. test "${enable_plugin_xenstat}" = "yes" -a "${have_libyajl}" != "yes" && \
  552. AC_MSG_ERROR([libyajl required but not found. Try installing 'yajl-devel'])
  553. AC_MSG_CHECKING([if xenstat.plugin should be enabled])
  554. if test "${enable_plugin_xenstat}" != "no" -a "${have_libxenstat}" = "yes" -a "${have_libxenlight}" = "yes" -a "${have_libyajl}" = "yes"; then
  555. enable_plugin_xenstat="yes"
  556. AC_DEFINE([HAVE_LIBXENSTAT], [1], [libxenstat usability])
  557. AC_DEFINE([HAVE_LIBXENLIGHT], [1], [libxenlight usability])
  558. AC_DEFINE([HAVE_LIBYAJL], [1], [libyajl usability])
  559. OPTIONAL_XENSTAT_CFLAGS="${XENLIGHT_CFLAGS} ${YAJL_CFLAGS}"
  560. OPTIONAL_XENSTAT_LIBS="-lxenstat ${XENLIGHT_LIBS} ${YAJL_LIBS}"
  561. else
  562. enable_plugin_xenstat="no"
  563. fi
  564. AC_MSG_RESULT([${enable_plugin_xenstat}])
  565. AM_CONDITIONAL([ENABLE_PLUGIN_XENSTAT], [test "${enable_plugin_xenstat}" = "yes"])
  566. # -----------------------------------------------------------------------------
  567. # AWS Kinesis backend - libaws-cpp-sdk-kinesis, libaws-cpp-sdk-core, libssl, libcrypto, libcurl
  568. PKG_CHECK_MODULES(
  569. [LIBCRYPTO],
  570. [libcrypto],
  571. [AC_CHECK_LIB(
  572. [crypto],
  573. [CRYPTO_new_ex_data],
  574. [have_libcrypto=yes],
  575. [have_libcrypto=no]
  576. )],
  577. [have_libcrypto=no]
  578. )
  579. PKG_CHECK_MODULES(
  580. [LIBSSL],
  581. [libssl],
  582. [AC_CHECK_LIB(
  583. [ssl],
  584. [SSL_connect],
  585. [have_libssl=yes],
  586. [have_libssl=no]
  587. )],
  588. [have_libssl=no]
  589. )
  590. PKG_CHECK_MODULES(
  591. [LIBCURL],
  592. [libcurl],
  593. [AC_CHECK_LIB(
  594. [curl],
  595. [curl_easy_init],
  596. [have_libcurl=yes],
  597. [have_libcurl=no]
  598. )],
  599. [have_libcurl=no]
  600. )
  601. AC_CHECK_LIB(
  602. [aws-cpp-sdk-core],
  603. [cJSON_free],
  604. [have_libaws_cpp_sdk_core=yes],
  605. [have_libaws_cpp_sdk_core=no],
  606. [${LIBCRYPTO_LIBS} ${LIBSSL_LIBS} ${LIBCURL_LIBS}]
  607. )
  608. AC_MSG_CHECKING([for Aws::Kinesis::Model::PutRecordRequest in -laws-cpp-sdk-kinesis])
  609. if test "${have_libaws_cpp_sdk_core}" = "yes" -a "${have_libcrypto}" = "yes" -a "${have_libssl}" = "yes" -a "${have_libcurl}" = "yes"; then
  610. AC_LANG_SAVE
  611. AC_LANG_CPLUSPLUS
  612. save_LIBS="${LIBS}"
  613. LIBS="-laws-cpp-sdk-kinesis -laws-cpp-sdk-core ${LIBCRYPTO_LIBS} ${LIBSSL_LIBS} ${LIBCURL_LIBS}"
  614. save_CXXFLAGS="${CXXFLAGS}"
  615. CXXFLAGS="${CXXFLAGS} -std=c++11"
  616. AC_TRY_LINK(
  617. [
  618. #include <aws/core/Aws.h>
  619. #include <aws/core/client/ClientConfiguration.h>
  620. #include <aws/core/auth/AWSCredentials.h>
  621. #include <aws/core/utils/Outcome.h>
  622. #include <aws/kinesis/KinesisClient.h>
  623. #include <aws/kinesis/model/PutRecordRequest.h>
  624. ],
  625. [Aws::Kinesis::Model::PutRecordRequest request;],
  626. [have_libaws_cpp_sdk_kinesis=yes],
  627. [have_libaws_cpp_sdk_kinesis=no]
  628. )
  629. LIBS="${save_LIBS}"
  630. CXXFLAGS="${save_CXXFLAGS}"
  631. AC_LANG_RESTORE
  632. else
  633. have_libaws_cpp_sdk_kinesis=no
  634. fi
  635. AC_MSG_RESULT([${have_libaws_cpp_sdk_kinesis}])
  636. test "${enable_backend_kinesis}" = "yes" -a "${have_libaws_cpp_sdk_kinesis}" != "yes" && \
  637. AC_MSG_ERROR([libaws-cpp-sdk-kinesis required but not found. try installing AWS C++ SDK])
  638. test "${enable_backend_kinesis}" = "yes" -a "${have_libaws_cpp_sdk_core}" != "yes" && \
  639. AC_MSG_ERROR([libaws-cpp-sdk-core required but not found. try installing AWS C++ SDK])
  640. test "${enable_backend_kinesis}" = "yes" -a "${have_libcurl}" != "yes" && \
  641. AC_MSG_ERROR([libcurl required but not found])
  642. test "${enable_backend_kinesis}" = "yes" -a "${have_libssl}" != "yes" && \
  643. AC_MSG_ERROR([libssl required but not found])
  644. test "${enable_backend_kinesis}" = "yes" -a "${have_libcrypto}" != "yes" && \
  645. AC_MSG_ERROR([libcrypto required but not found])
  646. AC_MSG_CHECKING([if kinesis backend should be enabled])
  647. if test "${enable_backend_kinesis}" != "no" -a "${have_libaws_cpp_sdk_kinesis}" = "yes" -a "${have_libaws_cpp_sdk_core}" = "yes" \
  648. -a "${have_libcurl}" = "yes" -a "${have_libssl}" = "yes" -a "${have_libcrypto}" = "yes"; then
  649. enable_backend_kinesis="yes"
  650. AC_DEFINE([HAVE_KINESIS], [1], [libaws-cpp-sdk-kinesis usability])
  651. OPTIONAL_KINESIS_CFLAGS="${LIBCRYPTO_CFLAGS} ${LIBSSL_CFLAGS} ${LIBCURL_CFLAGS}"
  652. CXX11FLAG="-std=c++11"
  653. OPTIONAL_KINESIS_LIBS="-laws-cpp-sdk-kinesis -laws-cpp-sdk-core ${LIBCRYPTO_LIBS} ${LIBSSL_LIBS} ${LIBCURL_LIBS}"
  654. else
  655. enable_backend_kinesis="no"
  656. fi
  657. AC_MSG_RESULT([${enable_backend_kinesis}])
  658. AM_CONDITIONAL([ENABLE_BACKEND_KINESIS], [test "${enable_backend_kinesis}" = "yes"])
  659. # -----------------------------------------------------------------------------
  660. # check for setns() - cgroup-network
  661. AC_CHECK_FUNC([setns])
  662. AC_MSG_CHECKING([if cgroup-network can be enabled])
  663. if test "$ac_cv_func_setns" = "yes" ; then
  664. have_setns="yes"
  665. AC_DEFINE([HAVE_SETNS], [1], [Define 1 if you have setns() function])
  666. else
  667. have_setns="no"
  668. fi
  669. AC_MSG_RESULT([${have_setns}])
  670. AM_CONDITIONAL([ENABLE_PLUGIN_CGROUP_NETWORK], [test "${have_setns}" = "yes"])
  671. # -----------------------------------------------------------------------------
  672. # Link-Time-Optimization
  673. if test "${enable_lto}" != "no"; then
  674. opt="-flto"
  675. AX_CHECK_COMPILE_FLAG(${opt}, [have_lto=yes], [have_lto=no])
  676. fi
  677. if test "${have_lto}" = "yes"; then
  678. oCFLAGS="${CFLAGS}"
  679. CFLAGS="${CFLAGS} -flto ${OPTIONAL_MATH_CFLAGS} ${OPTIONAL_NFACCT_CFLAGS} ${OPTIONAL_ZLIB_CFLAGS} ${OPTIONAL_UUID_CFLAGS} ${OPTIONAL_LIBCAP_CFLAGS} ${OPTIONAL_IPMIMONITORING_CFLAGS} ${OPTIONAL_CUPS_CFLAGS} ${OPTIONAL_XENSTAT_FLAGS} ${OPTIONAL_KINESIS_CFLAGS}"
  680. ac_cv_c_lto_cross_compile="${enable_lto}"
  681. test "${ac_cv_c_lto_cross_compile}" != "yes" && ac_cv_c_lto_cross_compile="no"
  682. AC_C_LTO
  683. CFLAGS="${oCFLAGS}"
  684. test "${ac_cv_c_lto}" != "yes" && have_lto="no"
  685. fi
  686. test "${enable_lto}" = "yes" -a "${have_lto}" != "yes" && \
  687. AC_MSG_ERROR([LTO is required but is not available.])
  688. AC_MSG_CHECKING([if LTO should be enabled])
  689. if test "${enable_lto}" != "no" -a "${have_lto}" = "yes"; then
  690. enable_lto="yes"
  691. CFLAGS="${CFLAGS} -flto"
  692. else
  693. enable_lto="no"
  694. fi
  695. AC_MSG_RESULT([${enable_lto}])
  696. # -----------------------------------------------------------------------------
  697. AC_DEFINE_UNQUOTED([NETDATA_USER], ["${with_user}"], [use this user to drop privileged])
  698. varlibdir="${localstatedir}/lib/netdata"
  699. registrydir="${localstatedir}/lib/netdata/registry"
  700. cachedir="${localstatedir}/cache/netdata"
  701. chartsdir="${libexecdir}/netdata/charts.d"
  702. nodedir="${libexecdir}/netdata/node.d"
  703. pythondir="${libexecdir}/netdata/python.d"
  704. configdir="${sysconfdir}/netdata"
  705. libconfigdir="${libdir}/netdata/conf.d"
  706. logdir="${localstatedir}/log/netdata"
  707. pluginsdir="${libexecdir}/netdata/plugins.d"
  708. AC_SUBST([build_target])
  709. AC_SUBST([varlibdir])
  710. AC_SUBST([registrydir])
  711. AC_SUBST([cachedir])
  712. AC_SUBST([chartsdir])
  713. AC_SUBST([nodedir])
  714. AC_SUBST([pythondir])
  715. AC_SUBST([configdir])
  716. AC_SUBST([libconfigdir])
  717. AC_SUBST([logdir])
  718. AC_SUBST([pluginsdir])
  719. AC_SUBST([webdir])
  720. CXXFLAGS="${CFLAGS} ${CXX11FLAG}"
  721. CPPFLAGS="\
  722. -DTARGET_OS=${build_target_id} \
  723. -DVARLIB_DIR=\"\\\"${varlibdir}\\\"\" \
  724. -DCACHE_DIR=\"\\\"${cachedir}\\\"\" \
  725. -DCONFIG_DIR=\"\\\"${configdir}\\\"\" \
  726. -DLIBCONFIG_DIR=\"\\\"${libconfigdir}\\\"\" \
  727. -DLOG_DIR=\"\\\"${logdir}\\\"\" \
  728. -DPLUGINS_DIR=\"\\\"${pluginsdir}\\\"\" \
  729. -DRUN_DIR=\"\\\"${localstatedir}/run/netdata\\\"\" \
  730. -DWEB_DIR=\"\\\"${webdir}\\\"\" \
  731. "
  732. AC_SUBST([OPTIONAL_MATH_CFLAGS])
  733. AC_SUBST([OPTIONAL_MATH_LIBS])
  734. AC_SUBST([OPTIONAL_RT_CLFAGS])
  735. AC_SUBST([OPTIONAL_UV_LIBS])
  736. AC_SUBST([OPTIONAL_LZ4_LIBS])
  737. AC_SUBST([OPTIONAL_JUDY_LIBS])
  738. AC_SUBST([OPTIONAL_SSL_LIBS])
  739. AC_SUBST([OPTIONAL_NFACCT_CLFAGS])
  740. AC_SUBST([OPTIONAL_NFACCT_LIBS])
  741. AC_SUBST([OPTIONAL_ZLIB_CFLAGS])
  742. AC_SUBST([OPTIONAL_ZLIB_LIBS])
  743. AC_SUBST([OPTIONAL_UUID_CFLAGS])
  744. AC_SUBST([OPTIONAL_UUID_LIBS])
  745. AC_SUBST([OPTIONAL_LIBCAP_CFLAGS])
  746. AC_SUBST([OPTIONAL_LIBCAP_LIBS])
  747. AC_SUBST([OPTIONAL_IPMIMONITORING_CFLAGS])
  748. AC_SUBST([OPTIONAL_IPMIMONITORING_LIBS])
  749. AC_SUBST([OPTIONAL_CUPS_CFLAGS])
  750. AC_SUBST([OPTIONAL_CUPS_LIBS])
  751. AC_SUBST([OPTIONAL_XENSTAT_CFLAGS])
  752. AC_SUBST([OPTIONAL_XENSTAT_LIBS])
  753. AC_SUBST([OPTIONAL_KINESIS_CFLAGS])
  754. AC_SUBST([OPTIONAL_KINESIS_LIBS])
  755. AC_CONFIG_FILES([
  756. Makefile
  757. netdata.spec
  758. backends/graphite/Makefile
  759. backends/json/Makefile
  760. backends/Makefile
  761. backends/opentsdb/Makefile
  762. backends/prometheus/Makefile
  763. backends/aws_kinesis/Makefile
  764. collectors/Makefile
  765. collectors/apps.plugin/Makefile
  766. collectors/cgroups.plugin/Makefile
  767. collectors/charts.d.plugin/Makefile
  768. collectors/checks.plugin/Makefile
  769. collectors/diskspace.plugin/Makefile
  770. collectors/fping.plugin/Makefile
  771. collectors/ioping.plugin/Makefile
  772. collectors/freebsd.plugin/Makefile
  773. collectors/freeipmi.plugin/Makefile
  774. collectors/cups.plugin/Makefile
  775. collectors/idlejitter.plugin/Makefile
  776. collectors/macos.plugin/Makefile
  777. collectors/nfacct.plugin/Makefile
  778. collectors/node.d.plugin/Makefile
  779. collectors/plugins.d/Makefile
  780. collectors/proc.plugin/Makefile
  781. collectors/python.d.plugin/Makefile
  782. collectors/statsd.plugin/Makefile
  783. collectors/tc.plugin/Makefile
  784. collectors/xenstat.plugin/Makefile
  785. daemon/Makefile
  786. database/Makefile
  787. database/engine/Makefile
  788. diagrams/Makefile
  789. health/Makefile
  790. health/notifications/Makefile
  791. libnetdata/Makefile
  792. libnetdata/adaptive_resortable_list/Makefile
  793. libnetdata/avl/Makefile
  794. libnetdata/buffer/Makefile
  795. libnetdata/clocks/Makefile
  796. libnetdata/config/Makefile
  797. libnetdata/dictionary/Makefile
  798. libnetdata/eval/Makefile
  799. libnetdata/locks/Makefile
  800. libnetdata/log/Makefile
  801. libnetdata/popen/Makefile
  802. libnetdata/procfile/Makefile
  803. libnetdata/simple_pattern/Makefile
  804. libnetdata/socket/Makefile
  805. libnetdata/statistical/Makefile
  806. libnetdata/storage_number/Makefile
  807. libnetdata/threads/Makefile
  808. libnetdata/url/Makefile
  809. registry/Makefile
  810. streaming/Makefile
  811. system/Makefile
  812. tests/Makefile
  813. web/Makefile
  814. web/api/Makefile
  815. web/api/badges/Makefile
  816. web/api/exporters/Makefile
  817. web/api/exporters/shell/Makefile
  818. web/api/exporters/prometheus/Makefile
  819. web/api/formatters/Makefile
  820. web/api/formatters/csv/Makefile
  821. web/api/formatters/json/Makefile
  822. web/api/formatters/ssv/Makefile
  823. web/api/formatters/value/Makefile
  824. web/api/queries/Makefile
  825. web/api/queries/average/Makefile
  826. web/api/queries/des/Makefile
  827. web/api/queries/incremental_sum/Makefile
  828. web/api/queries/max/Makefile
  829. web/api/queries/median/Makefile
  830. web/api/queries/min/Makefile
  831. web/api/queries/ses/Makefile
  832. web/api/queries/stddev/Makefile
  833. web/api/queries/sum/Makefile
  834. web/api/health/Makefile
  835. web/gui/Makefile
  836. web/server/Makefile
  837. web/server/static/Makefile
  838. ])
  839. AC_OUTPUT
  840. test "${with_math}" != "yes" && AC_MSG_WARN([You are building without math. math allows accurate calculations. It should be enabled.]) || :
  841. 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.]) || :