configure.ac 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765
  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_INSTALL
  35. PKG_PROG_PKG_CONFIG
  36. AC_USE_SYSTEM_EXTENSIONS
  37. # -----------------------------------------------------------------------------
  38. # configurable options
  39. AC_ARG_ENABLE(
  40. [plugin-nfacct],
  41. [AS_HELP_STRING([--enable-plugin-nfacct], [enable nfacct plugin @<:@default autodetect@:>@])],
  42. ,
  43. [enable_plugin_nfacct="detect"]
  44. )
  45. AC_ARG_ENABLE(
  46. [plugin-freeipmi],
  47. [AS_HELP_STRING([--enable-plugin-freeipmi], [enable freeipmi plugin @<:@default autodetect@:>@])],
  48. ,
  49. [enable_plugin_freeipmi="detect"]
  50. )
  51. AC_ARG_ENABLE(
  52. [plugin-cups],
  53. [AS_HELP_STRING([--enable-plugin-cups], [enable cups plugin @<:@default autodetect@:>@])],
  54. ,
  55. [enable_plugin_cups="detect"]
  56. )
  57. AC_ARG_ENABLE(
  58. [plugin-xenstat],
  59. [AS_HELP_STRING([--enable-plugin-xenstat], [enable xenstat plugin @<:@default autodetect@:>@])],
  60. ,
  61. [enable_plugin_xenstat="detect"]
  62. )
  63. AC_ARG_ENABLE(
  64. [pedantic],
  65. [AS_HELP_STRING([--enable-pedantic], [enable pedantic compiler warnings @<:@default disabled@:>@])],
  66. ,
  67. [enable_pedantic="no"]
  68. )
  69. AC_ARG_ENABLE(
  70. [accept4],
  71. [AS_HELP_STRING([--disable-accept4], [System does not have accept4 @<:@default autodetect@:>@])],
  72. ,
  73. [enable_accept4="detect"]
  74. )
  75. AC_ARG_WITH(
  76. [webdir],
  77. [AS_HELP_STRING([--with-webdir], [location of webdir @<:@PKGDATADIR/web@:>@])],
  78. [webdir="${withval}"],
  79. [webdir="\$(pkgdatadir)/web"]
  80. )
  81. AC_ARG_WITH(
  82. [libcap],
  83. [AS_HELP_STRING([--with-libcap], [build with libcap @<:@default autodetect@:>@])],
  84. ,
  85. [with_libcap="detect"]
  86. )
  87. AC_ARG_WITH(
  88. [zlib],
  89. [AS_HELP_STRING([--without-zlib], [build without zlib @<:@default enabled@:>@])],
  90. ,
  91. [with_zlib="yes"]
  92. )
  93. AC_ARG_WITH(
  94. [math],
  95. [AS_HELP_STRING([--without-math], [build without math @<:@default enabled@:>@])],
  96. ,
  97. [with_math="yes"]
  98. )
  99. AC_ARG_WITH(
  100. [user],
  101. [AS_HELP_STRING([--with-user], [use this user to drop privilege @<:@default nobody@:>@])],
  102. ,
  103. [with_user="nobody"]
  104. )
  105. AC_ARG_ENABLE(
  106. [x86-sse],
  107. [AS_HELP_STRING([--disable-x86-sse], [SSE/SS2 optimizations on x86 @<:@default enabled@:>@])],
  108. ,
  109. [enable_x86_sse="yes"]
  110. )
  111. AC_ARG_ENABLE(
  112. [lto],
  113. [AS_HELP_STRING([--disable-lto], [Link Time Optimizations @<:@default autodetect@:>@])],
  114. ,
  115. [enable_lto="detect"]
  116. )
  117. # -----------------------------------------------------------------------------
  118. # netdata required checks
  119. # fails on centos6
  120. #AX_CHECK_ENABLE_DEBUG()
  121. AX_GCC_FUNC_ATTRIBUTE([returns_nonnull])
  122. AX_GCC_FUNC_ATTRIBUTE([malloc])
  123. AX_GCC_FUNC_ATTRIBUTE([noreturn])
  124. AX_GCC_FUNC_ATTRIBUTE([noinline])
  125. AX_GCC_FUNC_ATTRIBUTE([format])
  126. AX_GCC_FUNC_ATTRIBUTE([warn_unused_result])
  127. AC_CHECK_TYPES([struct timespec, clockid_t], [], [], [[#include <time.h>]])
  128. AC_SEARCH_LIBS([clock_gettime], [rt posix4])
  129. AC_CHECK_FUNCS([clock_gettime])
  130. AC_CHECK_FUNCS([sched_setscheduler sched_getscheduler sched_getparam sched_get_priority_min sched_get_priority_max getpriority setpriority nice])
  131. AC_CHECK_FUNCS([recvmmsg])
  132. AC_TYPE_INT8_T
  133. AC_TYPE_INT16_T
  134. AC_TYPE_INT32_T
  135. AC_TYPE_INT64_T
  136. AC_TYPE_UINT8_T
  137. AC_TYPE_UINT16_T
  138. AC_TYPE_UINT32_T
  139. AC_TYPE_UINT64_T
  140. AC_C_INLINE
  141. AC_FUNC_STRERROR_R
  142. AC_C__GENERIC
  143. AC_C___ATOMIC
  144. # AC_C_STMT_EXPR
  145. AC_CHECK_SIZEOF([void *])
  146. AC_CANONICAL_HOST
  147. AC_HEADER_MAJOR
  148. AC_HEADER_RESOLV
  149. AC_CHECK_HEADERS_ONCE([sys/prctl.h])
  150. AC_CHECK_HEADERS_ONCE([sys/vfs.h])
  151. AC_CHECK_HEADERS_ONCE([sys/statfs.h])
  152. AC_CHECK_HEADERS_ONCE([sys/statvfs.h])
  153. AC_CHECK_HEADERS_ONCE([sys/mount.h])
  154. if test "${enable_accept4}" != "no"; then
  155. AC_CHECK_FUNCS_ONCE(accept4)
  156. fi
  157. # -----------------------------------------------------------------------------
  158. # operating system detection
  159. AC_MSG_CHECKING([operating system])
  160. case "$host_os" in
  161. freebsd*)
  162. build_target=freebsd
  163. build_target_id=2
  164. CFLAGS="${CFLAGS} -I/usr/local/include"
  165. ;;
  166. darwin*)
  167. build_target=macos
  168. build_target_id=3
  169. LDFLAGS="${LDFLAGS} -framework CoreFoundation -framework IOKit"
  170. ;;
  171. *)
  172. build_target=linux
  173. build_target_id=1
  174. ;;
  175. esac
  176. AM_CONDITIONAL([FREEBSD], [test "${build_target}" = "freebsd"])
  177. AM_CONDITIONAL([MACOS], [test "${build_target}" = "macos"])
  178. AM_CONDITIONAL([LINUX], [test "${build_target}" = "linux"])
  179. AC_MSG_RESULT([${build_target} with id ${build_target_id}])
  180. # -----------------------------------------------------------------------------
  181. # pthreads
  182. ACX_PTHREAD(, [AC_MSG_ERROR([Cannot initialize pthread environment])])
  183. LIBS="${PTHREAD_LIBS} ${LIBS}"
  184. CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}"
  185. CC="${PTHREAD_CC}"
  186. # -----------------------------------------------------------------------------
  187. # libm
  188. AC_ARG_VAR([MATH_CFLAGS], [C compiler flags for math])
  189. AC_ARG_VAR([MATH_LIBS], [linker flags for math])
  190. if test -z "${MATH_LIBS}"; then
  191. AC_CHECK_LIB(
  192. [m],
  193. [sin],
  194. [MATH_LIBS="-lm"]
  195. )
  196. fi
  197. test "${with_math}" = "yes" -a -z "${MATH_LIBS}" && AC_MSG_ERROR([math required but not found])
  198. AC_MSG_CHECKING([if libm should be used])
  199. if test "${with_math}" != "no" -a ! -z "${MATH_LIBS}"; then
  200. with_math="yes"
  201. AC_DEFINE([STORAGE_WITH_MATH], [1], [math usability])
  202. OPTIONAL_MATH_CFLAGS="${MATH_CFLAGS}"
  203. OPTIONAL_MATH_LIBS="${MATH_LIBS}"
  204. else
  205. with_math="no"
  206. fi
  207. AC_MSG_RESULT([${with_math}])
  208. # -----------------------------------------------------------------------------
  209. # zlib
  210. PKG_CHECK_MODULES(
  211. [ZLIB],
  212. [zlib],
  213. [have_zlib=yes],
  214. [have_zlib=no]
  215. )
  216. test "${with_zlib}" = "yes" -a "${have_zlib}" != "yes" && AC_MSG_ERROR([zlib required but not found. Try installing 'zlib1g-dev' or 'zlib-devel'.])
  217. AC_MSG_CHECKING([if zlib should be used])
  218. if test "${with_zlib}" != "no" -a "${have_zlib}" = "yes"; then
  219. with_zlib="yes"
  220. AC_DEFINE([NETDATA_WITH_ZLIB], [1], [zlib usability])
  221. OPTIONAL_ZLIB_CLFAGS="${ZLIB_CFLAGS}"
  222. OPTIONAL_ZLIB_LIBS="${ZLIB_LIBS}"
  223. else
  224. with_zlib="no"
  225. fi
  226. AC_MSG_RESULT([${with_zlib}])
  227. # -----------------------------------------------------------------------------
  228. # libuuid
  229. PKG_CHECK_MODULES(
  230. [UUID],
  231. [uuid],
  232. [have_uuid=yes],
  233. [AC_MSG_ERROR([libuuid required but not found. Try installing 'uuid-dev' or 'libuuid-devel'.])]
  234. )
  235. AC_DEFINE([NETDATA_WITH_UUID], [1], [uuid usability])
  236. OPTIONAL_UUID_CLFAGS="${UUID_CFLAGS}"
  237. OPTIONAL_UUID_LIBS="${UUID_LIBS}"
  238. # -----------------------------------------------------------------------------
  239. # compiler options
  240. AC_ARG_VAR([SSE_CANDIDATE], [C compiler flags for SSE])
  241. AS_CASE([$host_cpu],
  242. [i?86], [SSE_CANDIDATE="yes"]
  243. )
  244. AC_SUBST([SSE_CANDIDATE])
  245. if test "${SSE_CANDIDATE}" = "yes" -a "${enable_x86_sse}" = "yes"; then
  246. opt="-msse2 -mfpmath=sse"
  247. AX_CHECK_COMPILE_FLAG(${opt}, [CFLAGS="${CFLAGS} ${opt}"], [])
  248. fi
  249. if test "${GCC}" = "yes"; then
  250. AC_DEFINE_UNQUOTED([likely(x)], [__builtin_expect(!!(x), 1)], [gcc branch optimization])
  251. AC_DEFINE_UNQUOTED([unlikely(x)], [__builtin_expect(!!(x), 0)], [gcc branch optimization])
  252. else
  253. AC_DEFINE_UNQUOTED([likely(x)], [(x)], [gcc branch optimization])
  254. AC_DEFINE_UNQUOTED([unlikely(x)], [(x)], [gcc branch optimization])
  255. fi
  256. if test "${enable_pedantic}" = "yes"; then
  257. enable_strict="yes"
  258. CFLAGS="${CFLAGS} -pedantic -Wall -Wextra -Wno-long-long"
  259. fi
  260. # -----------------------------------------------------------------------------
  261. # memory allocation library
  262. AC_MSG_CHECKING([for memory allocator])
  263. TS_CHECK_JEMALLOC
  264. if test "$has_jemalloc" = "1"; then
  265. AC_DEFINE([ENABLE_JEMALLOC], [1], [compile and link with jemalloc])
  266. AC_MSG_RESULT([jemalloc])
  267. else
  268. TS_CHECK_TCMALLOC
  269. if test "$has_tcmalloc" = "1"; then
  270. AC_DEFINE([ENABLE_TCMALLOC], [1], [compile and link with tcmalloc])
  271. AC_MSG_RESULT([tcmalloc])
  272. else
  273. AC_MSG_RESULT([system])
  274. AC_C_MALLOPT
  275. AC_C_MALLINFO
  276. fi
  277. fi
  278. # -----------------------------------------------------------------------------
  279. # libcap
  280. PKG_CHECK_MODULES(
  281. [LIBCAP],
  282. [libcap],
  283. [AC_CHECK_LIB([cap], [cap_get_proc, cap_set_proc],
  284. [AC_CHECK_HEADER(
  285. [sys/capability.h],
  286. [have_libcap=yes],
  287. [have_libcap=no]
  288. )],
  289. [have_libcap=no]
  290. )],
  291. [have_libcap=no]
  292. )
  293. test "${with_libcap}" = "yes" -a "${have_libcap}" != "yes" && AC_MSG_ERROR([libcap required but not found.])
  294. AC_MSG_CHECKING([if libcap should be used])
  295. if test "${with_libcap}" != "no" -a "${have_libcap}" = "yes"; then
  296. with_libcap="yes"
  297. AC_DEFINE([HAVE_CAPABILITY], [1], [libcap usability])
  298. OPTIONAL_LIBCAP_CLFAGS="${LIBCAP_CFLAGS}"
  299. OPTIONAL_LIBCAP_LIBS="${LIBCAP_LIBS}"
  300. else
  301. with_libcap="no"
  302. fi
  303. AC_MSG_RESULT([${with_libcap}])
  304. AM_CONDITIONAL([ENABLE_CAPABILITY], [test "${with_libcap}" = "yes"])
  305. # -----------------------------------------------------------------------------
  306. # apps.plugin
  307. AC_MSG_CHECKING([if apps.plugin should be enabled])
  308. if test "${build_target}" != "macos"; then
  309. enable_plugin_apps="yes"
  310. else
  311. enable_plugin_apps="no"
  312. fi
  313. AC_MSG_RESULT([${enable_plugin_apps}])
  314. AM_CONDITIONAL([ENABLE_PLUGIN_APPS], [test "${enable_plugin_apps}" = "yes"])
  315. # -----------------------------------------------------------------------------
  316. # freeipmi.plugin - libipmimonitoring
  317. PKG_CHECK_MODULES(
  318. [IPMIMONITORING],
  319. [libipmimonitoring],
  320. [AC_CHECK_LIB([ipmimonitoring], [
  321. ipmi_monitoring_sensor_readings_by_record_id,
  322. ipmi_monitoring_sensor_readings_by_sensor_type,
  323. ipmi_monitoring_sensor_read_sensor_number,
  324. ipmi_monitoring_sensor_read_sensor_name,
  325. ipmi_monitoring_sensor_read_sensor_state,
  326. ipmi_monitoring_sensor_read_sensor_units,
  327. ipmi_monitoring_sensor_iterator_next,
  328. ipmi_monitoring_ctx_sensor_config_file,
  329. ipmi_monitoring_ctx_sdr_cache_directory,
  330. ipmi_monitoring_ctx_errormsg,
  331. ipmi_monitoring_ctx_create
  332. ],
  333. [AC_CHECK_HEADER(
  334. [ipmi_monitoring.h],
  335. [AC_CHECK_HEADER(
  336. [ipmi_monitoring_bitmasks.h],
  337. [have_ipmimonitoring=yes],
  338. [have_ipmimonitoring=no]
  339. )],
  340. [have_ipmimonitoring=no]
  341. )],
  342. [have_ipmimonitoring=no]
  343. )],
  344. [have_ipmimonitoring=no]
  345. )
  346. test "${enable_plugin_freeipmi}" = "yes" -a "${have_ipmimonitoring}" != "yes" && \
  347. AC_MSG_ERROR([ipmimonitoring required but not found. Try installing 'libipmimonitoring-dev' or 'libipmimonitoring-devel'])
  348. AC_MSG_CHECKING([if freeipmi.plugin should be enabled])
  349. if test "${enable_plugin_freeipmi}" != "no" -a "${have_ipmimonitoring}" = "yes"; then
  350. enable_plugin_freeipmi="yes"
  351. AC_DEFINE([HAVE_FREEIPMI], [1], [ipmimonitoring usability])
  352. OPTIONAL_IPMIMONITORING_CLFAGS="${IPMIMONITORING_CFLAGS}"
  353. OPTIONAL_IPMIMONITORING_LIBS="${IPMIMONITORING_LIBS}"
  354. else
  355. enable_plugin_freeipmi="no"
  356. fi
  357. AC_MSG_RESULT([${enable_plugin_freeipmi}])
  358. AM_CONDITIONAL([ENABLE_PLUGIN_FREEIPMI], [test "${enable_plugin_freeipmi}" = "yes"])
  359. # -----------------------------------------------------------------------------
  360. # cups.plugin - libcups
  361. # Only check most recently added method of cups
  362. AC_CHECK_LIB([cups], [httpConnect2],
  363. [AC_CHECK_HEADER(
  364. [cups/cups.h],
  365. [have_cups=yes],
  366. [have_cups=no]
  367. )],
  368. [have_cups=no]
  369. )
  370. test "${enable_plugin_cups}" = "yes" -a "${have_cups}" != "yes" && \
  371. AC_MSG_ERROR([cups required but not found. Try installing 'cups'])
  372. AC_ARG_WITH([cups-config],
  373. [AS_HELP_STRING([--with-cups-config=path], [Specify path to cups-config executable.])],
  374. [with_cups_config="$withval"],
  375. [with_cups_config=system]
  376. )
  377. AS_IF([test "x$with_cups_config" != "xsystem"], [
  378. CUPSCONFIG=$with_cups_config
  379. ], [
  380. AC_PATH_TOOL(CUPSCONFIG, [cups-config])
  381. AS_IF([test -z "$CUPSCONFIG"], [
  382. have_cups=no
  383. ])
  384. ])
  385. AC_MSG_CHECKING([if cups.plugin should be enabled])
  386. if test "${enable_plugin_cups}" != "no" -a "${have_cups}" = "yes"; then
  387. enable_plugin_cups="yes"
  388. AC_DEFINE([HAVE_CUPS], [1], [cups usability])
  389. CUPS_CFLAGS="${CUPS_CFLAGS} `$CUPSCONFIG --cflags`"
  390. CUPS_LIBS="${CUPS_LIBS} `$CUPSCONFIG --libs`"
  391. OPTIONAL_CUPS_CLFAGS="${CUPS_CFLAGS}"
  392. OPTIONAL_CUPS_LIBS="${CUPS_LIBS}"
  393. else
  394. enable_plugin_cups="no"
  395. fi
  396. AC_MSG_RESULT([${enable_plugin_cups}])
  397. AM_CONDITIONAL([ENABLE_PLUGIN_CUPS], [test "${enable_plugin_cups}" = "yes"])
  398. # -----------------------------------------------------------------------------
  399. # nfacct.plugin - libmnl, libnetfilter_acct
  400. AC_CHECK_HEADERS_ONCE([linux/netfilter/nfnetlink_conntrack.h])
  401. PKG_CHECK_MODULES(
  402. [NFACCT],
  403. [libnetfilter_acct],
  404. [AC_CHECK_LIB(
  405. [netfilter_acct],
  406. [nfacct_alloc],
  407. [have_libnetfilter_acct=yes],
  408. [have_libnetfilter_acct=no]
  409. )],
  410. [have_libnetfilter_acct=no]
  411. )
  412. PKG_CHECK_MODULES(
  413. [LIBMNL],
  414. [libmnl],
  415. [AC_CHECK_LIB(
  416. [mnl],
  417. [mnl_socket_open],
  418. [have_libmnl=yes],
  419. [have_libmnl=no]
  420. )],
  421. [have_libmnl=no]
  422. )
  423. test "${enable_plugin_nfacct}" = "yes" -a "${have_libnetfilter_acct}" != "yes" && \
  424. AC_MSG_ERROR([netfilter_acct required but not found])
  425. test "${enable_plugin_nfacct}" = "yes" -a "${have_libmnl}" != "yes" && \
  426. AC_MSG_ERROR([libmnl required but not found. Try installing 'libmnl-dev' or 'libmnl-devel'])
  427. AC_MSG_CHECKING([if nfacct.plugin should be enabled])
  428. if test "${enable_plugin_nfacct}" != "no" -a "${have_libnetfilter_acct}" = "yes" -a "${have_libmnl}" = "yes"; then
  429. enable_plugin_nfacct="yes"
  430. AC_DEFINE([HAVE_LIBMNL], [1], [libmnl usability])
  431. AC_DEFINE([HAVE_LIBNETFILTER_ACCT], [1], [libnetfilter_acct usability])
  432. OPTIONAL_NFACCT_CLFAGS="${NFACCT_CFLAGS} ${LIBMNL_CFLAGS}"
  433. OPTIONAL_NFACCT_LIBS="${NFACCT_LIBS} ${LIBMNL_LIBS}"
  434. else
  435. enable_plugin_nfacct="no"
  436. fi
  437. AC_MSG_RESULT([${enable_plugin_nfacct}])
  438. AM_CONDITIONAL([ENABLE_PLUGIN_NFACCT], [test "${enable_plugin_nfacct}" = "yes"])
  439. # -----------------------------------------------------------------------------
  440. # xenstat.plugin - libxenstat
  441. PKG_CHECK_MODULES(
  442. [YAJL],
  443. [yajl],
  444. [AC_CHECK_LIB(
  445. [yajl],
  446. [yajl_tree_get],
  447. [have_libyajl=yes],
  448. [have_libyajl=no]
  449. )],
  450. [have_libyajl=no]
  451. )
  452. AC_CHECK_LIB(
  453. [xenstat],
  454. [xenstat_init],
  455. [AC_CHECK_HEADER(
  456. [xenstat.h],
  457. [have_libxenstat=yes],
  458. [have_libxenstat=no]
  459. )],
  460. [have_libxenstat=no],
  461. [-lyajl]
  462. )
  463. PKG_CHECK_MODULES(
  464. [XENLIGHT],
  465. [xenlight],
  466. [AC_CHECK_LIB(
  467. [xenlight],
  468. [libxl_domain_info],
  469. [AC_CHECK_HEADER(
  470. [libxl.h],
  471. [have_libxenlight=yes],
  472. [have_libxenlight=no]
  473. )],
  474. [have_libxenlight=no]
  475. )],
  476. [have_libxenlight=no]
  477. )
  478. test "${enable_plugin_xenstat}" = "yes" -a "${have_libxenstat}" != "yes" && \
  479. AC_MSG_ERROR([libxenstat required but not found. try installing 'xen-dom0-libs-devel'])
  480. test "${enable_plugin_xenstat}" = "yes" -a "${have_libxenlight}" != "yes" && \
  481. AC_MSG_ERROR([libxenlight required but not found. try installing 'xen-dom0-libs-devel'])
  482. test "${enable_plugin_xenstat}" = "yes" -a "${have_libyajl}" != "yes" && \
  483. AC_MSG_ERROR([libyajl required but not found. Try installing 'yajl-devel'])
  484. AC_MSG_CHECKING([if xenstat.plugin should be enabled])
  485. if test "${enable_plugin_xenstat}" != "no" -a "${have_libxenstat}" = "yes" -a "${have_libxenlight}" = "yes" -a "${have_libyajl}" = "yes"; then
  486. enable_plugin_xenstat="yes"
  487. AC_DEFINE([HAVE_LIBXENSTAT], [1], [libxenstat usability])
  488. AC_DEFINE([HAVE_LIBXENLIGHT], [1], [libxenlight usability])
  489. AC_DEFINE([HAVE_LIBYAJL], [1], [libyajl usability])
  490. OPTIONAL_XENSTAT_CLFAGS="${XENLIGHT_CFLAGS} ${YAJL_CFLAGS}"
  491. OPTIONAL_XENSTAT_LIBS="-lxenstat ${XENLIGHT_LIBS} ${YAJL_LIBS}"
  492. else
  493. enable_plugin_xenstat="no"
  494. fi
  495. AC_MSG_RESULT([${enable_plugin_xenstat}])
  496. AM_CONDITIONAL([ENABLE_PLUGIN_XENSTAT], [test "${enable_plugin_xenstat}" = "yes"])
  497. # -----------------------------------------------------------------------------
  498. # check for setns() - cgroup-network
  499. AC_CHECK_FUNC([setns])
  500. AC_MSG_CHECKING([if cgroup-network can be enabled])
  501. if test "$ac_cv_func_setns" = "yes" ; then
  502. have_setns="yes"
  503. AC_DEFINE([HAVE_SETNS], [1], [Define 1 if you have setns() function])
  504. else
  505. have_setns="no"
  506. fi
  507. AC_MSG_RESULT([${have_setns}])
  508. AM_CONDITIONAL([ENABLE_PLUGIN_CGROUP_NETWORK], [test "${have_setns}" = "yes"])
  509. # -----------------------------------------------------------------------------
  510. # Link-Time-Optimization
  511. if test "${enable_lto}" != "no"; then
  512. opt="-flto"
  513. AX_CHECK_COMPILE_FLAG(${opt}, [have_lto=yes], [have_lto=no])
  514. fi
  515. if test "${have_lto}" = "yes"; then
  516. oCFLAGS="${CFLAGS}"
  517. CFLAGS="${CFLAGS} -flto ${OPTIONAL_MATH_CLFAGS} ${OPTIONAL_NFACCT_CLFAGS} ${OPTIONAL_ZLIB_CLFAGS} ${OPTIONAL_UUID_CLFAGS} ${OPTIONAL_LIBCAP_CFLAGS} ${OPTIONAL_IPMIMONITORING_CFLAGS} ${OPTIONAL_CUPS_CLFAGS} ${OPTIONAL_XENSTAT_FLAGS}"
  518. ac_cv_c_lto_cross_compile="${enable_lto}"
  519. test "${ac_cv_c_lto_cross_compile}" != "yes" && ac_cv_c_lto_cross_compile="no"
  520. AC_C_LTO
  521. CFLAGS="${oCFLAGS}"
  522. test "${ac_cv_c_lto}" != "yes" && have_lto="no"
  523. fi
  524. test "${enable_lto}" = "yes" -a "${have_lto}" != "yes" && \
  525. AC_MSG_ERROR([LTO is required but is not available.])
  526. AC_MSG_CHECKING([if LTO should be enabled])
  527. if test "${enable_lto}" != "no" -a "${have_lto}" = "yes"; then
  528. enable_lto="yes"
  529. CFLAGS="${CFLAGS} -flto"
  530. else
  531. enable_lto="no"
  532. fi
  533. AC_MSG_RESULT([${enable_lto}])
  534. # -----------------------------------------------------------------------------
  535. AC_DEFINE_UNQUOTED([NETDATA_USER], ["${with_user}"], [use this user to drop privileged])
  536. varlibdir="${localstatedir}/lib/netdata"
  537. registrydir="${localstatedir}/lib/netdata/registry"
  538. cachedir="${localstatedir}/cache/netdata"
  539. chartsdir="${libexecdir}/netdata/charts.d"
  540. nodedir="${libexecdir}/netdata/node.d"
  541. pythondir="${libexecdir}/netdata/python.d"
  542. configdir="${sysconfdir}/netdata"
  543. libconfigdir="${libdir}/netdata/conf.d"
  544. logdir="${localstatedir}/log/netdata"
  545. pluginsdir="${libexecdir}/netdata/plugins.d"
  546. AC_SUBST([build_target])
  547. AC_SUBST([varlibdir])
  548. AC_SUBST([registrydir])
  549. AC_SUBST([cachedir])
  550. AC_SUBST([chartsdir])
  551. AC_SUBST([nodedir])
  552. AC_SUBST([pythondir])
  553. AC_SUBST([configdir])
  554. AC_SUBST([libconfigdir])
  555. AC_SUBST([logdir])
  556. AC_SUBST([pluginsdir])
  557. AC_SUBST([webdir])
  558. CPPFLAGS="\
  559. -DTARGET_OS=${build_target_id} \
  560. -DVARLIB_DIR=\"\\\"${varlibdir}\\\"\" \
  561. -DCACHE_DIR=\"\\\"${cachedir}\\\"\" \
  562. -DCONFIG_DIR=\"\\\"${configdir}\\\"\" \
  563. -DLIBCONFIG_DIR=\"\\\"${libconfigdir}\\\"\" \
  564. -DLOG_DIR=\"\\\"${logdir}\\\"\" \
  565. -DPLUGINS_DIR=\"\\\"${pluginsdir}\\\"\" \
  566. -DRUN_DIR=\"\\\"${localstatedir}/run/netdata\\\"\" \
  567. -DWEB_DIR=\"\\\"${webdir}\\\"\" \
  568. "
  569. AC_SUBST([OPTIONAL_MATH_CLFAGS])
  570. AC_SUBST([OPTIONAL_MATH_LIBS])
  571. AC_SUBST([OPTIONAL_NFACCT_CLFAGS])
  572. AC_SUBST([OPTIONAL_NFACCT_LIBS])
  573. AC_SUBST([OPTIONAL_ZLIB_CLFAGS])
  574. AC_SUBST([OPTIONAL_ZLIB_LIBS])
  575. AC_SUBST([OPTIONAL_UUID_CLFAGS])
  576. AC_SUBST([OPTIONAL_UUID_LIBS])
  577. AC_SUBST([OPTIONAL_LIBCAP_CFLAGS])
  578. AC_SUBST([OPTIONAL_LIBCAP_LIBS])
  579. AC_SUBST([OPTIONAL_IPMIMONITORING_CFLAGS])
  580. AC_SUBST([OPTIONAL_IPMIMONITORING_LIBS])
  581. AC_SUBST([OPTIONAL_CUPS_CFLAGS])
  582. AC_SUBST([OPTIONAL_CUPS_LIBS])
  583. AC_SUBST([OPTIONAL_XENSTAT_CFLAGS])
  584. AC_SUBST([OPTIONAL_XENSTAT_LIBS])
  585. AC_CONFIG_FILES([
  586. Makefile
  587. netdata.spec
  588. backends/graphite/Makefile
  589. backends/json/Makefile
  590. backends/Makefile
  591. backends/opentsdb/Makefile
  592. backends/prometheus/Makefile
  593. collectors/Makefile
  594. collectors/apps.plugin/Makefile
  595. collectors/cgroups.plugin/Makefile
  596. collectors/charts.d.plugin/Makefile
  597. collectors/checks.plugin/Makefile
  598. collectors/diskspace.plugin/Makefile
  599. collectors/fping.plugin/Makefile
  600. collectors/ioping.plugin/Makefile
  601. collectors/freebsd.plugin/Makefile
  602. collectors/freeipmi.plugin/Makefile
  603. collectors/cups.plugin/Makefile
  604. collectors/idlejitter.plugin/Makefile
  605. collectors/macos.plugin/Makefile
  606. collectors/nfacct.plugin/Makefile
  607. collectors/node.d.plugin/Makefile
  608. collectors/plugins.d/Makefile
  609. collectors/proc.plugin/Makefile
  610. collectors/python.d.plugin/Makefile
  611. collectors/statsd.plugin/Makefile
  612. collectors/tc.plugin/Makefile
  613. collectors/xenstat.plugin/Makefile
  614. daemon/Makefile
  615. database/Makefile
  616. diagrams/Makefile
  617. health/Makefile
  618. health/notifications/Makefile
  619. libnetdata/Makefile
  620. libnetdata/adaptive_resortable_list/Makefile
  621. libnetdata/avl/Makefile
  622. libnetdata/buffer/Makefile
  623. libnetdata/clocks/Makefile
  624. libnetdata/config/Makefile
  625. libnetdata/dictionary/Makefile
  626. libnetdata/eval/Makefile
  627. libnetdata/locks/Makefile
  628. libnetdata/log/Makefile
  629. libnetdata/popen/Makefile
  630. libnetdata/procfile/Makefile
  631. libnetdata/simple_pattern/Makefile
  632. libnetdata/socket/Makefile
  633. libnetdata/statistical/Makefile
  634. libnetdata/storage_number/Makefile
  635. libnetdata/threads/Makefile
  636. libnetdata/url/Makefile
  637. registry/Makefile
  638. streaming/Makefile
  639. system/Makefile
  640. tests/Makefile
  641. web/Makefile
  642. web/api/Makefile
  643. web/api/badges/Makefile
  644. web/api/exporters/Makefile
  645. web/api/exporters/shell/Makefile
  646. web/api/exporters/prometheus/Makefile
  647. web/api/formatters/Makefile
  648. web/api/formatters/csv/Makefile
  649. web/api/formatters/json/Makefile
  650. web/api/formatters/ssv/Makefile
  651. web/api/formatters/value/Makefile
  652. web/api/queries/Makefile
  653. web/api/queries/average/Makefile
  654. web/api/queries/des/Makefile
  655. web/api/queries/incremental_sum/Makefile
  656. web/api/queries/max/Makefile
  657. web/api/queries/median/Makefile
  658. web/api/queries/min/Makefile
  659. web/api/queries/ses/Makefile
  660. web/api/queries/stddev/Makefile
  661. web/api/queries/sum/Makefile
  662. web/api/health/Makefile
  663. web/gui/Makefile
  664. web/server/Makefile
  665. web/server/static/Makefile
  666. ])
  667. AC_OUTPUT
  668. test "${with_math}" != "yes" && AC_MSG_WARN([You are building without math. math allows accurate calculations. It should be enabled.]) || :
  669. 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.]) || :