]> arthur.barton.de Git - netdata.git/blob - configure.ac
added allmetrics API call to return JSON data; fixes #1910
[netdata.git] / configure.ac
1 #
2 # Copyright (C) 2015 Alon Bar-Lev <alon.barlev@gmail.com>
3 #
4 AC_PREREQ(2.60)
5
6 define([VERSION_MAJOR], [1])
7 define([VERSION_MINOR], [5])
8 define([VERSION_FIX], [1])
9 define([VERSION_NUMBER], VERSION_MAJOR[.]VERSION_MINOR[.]VERSION_FIX)
10 define([VERSION_SUFFIX], [_rolling])
11
12 dnl Set to "1" for a first RPM release of a new version
13 PACKAGE_RPM_RELEASE="0.0.$(echo VERSION_SUFFIX | sed s/^_//)"
14
15 # We do not use m4_esyscmd_s to support older autoconf.
16 define([VERSION_STRING], m4_esyscmd(git describe 2>/dev/null | sed 's/^v//' | tr -d '\n'))
17 m4_ifval(VERSION_STRING, [], [define([VERSION_STRING], VERSION_NUMBER)])
18
19 AC_INIT([netdata], VERSION_STRING[]VERSION_SUFFIX)
20
21 AM_MAINTAINER_MODE([disable])
22 if test x"$USE_MAINTAINER_MODE" = xyes; then
23 AC_MSG_NOTICE(***************** MAINTAINER MODE *****************)
24 PACKAGE_BUILT_DATE=$(date '+%d %b %Y')
25 fi
26
27 PACKAGE_RPM_VERSION="VERSION_NUMBER"
28 AC_SUBST([PACKAGE_RPM_VERSION])
29 AC_SUBST([PACKAGE_RPM_RELEASE])
30
31
32 # -----------------------------------------------------------------------------
33 # autoconf initialization
34
35 AC_CONFIG_AUX_DIR([.])
36 AC_CONFIG_HEADERS([config.h])
37 AC_CONFIG_MACRO_DIR([m4])
38 AC_CONFIG_SRCDIR([src/main.c])
39 AM_INIT_AUTOMAKE
40 AC_CANONICAL_HOST
41 AC_PROG_CC
42 AC_PROG_INSTALL
43 PKG_PROG_PKG_CONFIG
44 AC_USE_SYSTEM_EXTENSIONS
45
46
47 # -----------------------------------------------------------------------------
48 # configurable options
49
50 AC_ARG_ENABLE(
51     [plugin-nfacct],
52     [AS_HELP_STRING([--enable-plugin-nfacct], [enable nfacct plugin, requires root])],
53     ,
54     [enable_plugin_nfacct="no"]
55 )
56 AC_ARG_ENABLE(
57     [plugin-freeipmi],
58     [AS_HELP_STRING([--enable-plugin-freeipmi], [freeipmi plugin, requires root])],
59     ,
60     [enable_plugin_freeipmi="detect"]
61 )
62 AC_ARG_ENABLE(
63     [pedantic],
64     [AS_HELP_STRING([--enable-pedantic], [enable pedantic compiler warnings])],
65     ,
66     [enable_pedantic="no"]
67 )
68 AC_ARG_WITH(
69     [webdir],
70     [AS_HELP_STRING([--with-webdir], [location of webdir @<:@PKGDATADIR/web@:>@])],
71     [webdir="${withval}"],
72     [webdir="\$(pkgdatadir)/web"]
73 )
74 AC_ARG_WITH(
75     [libcap],
76     [AS_HELP_STRING([--with-libcap], [build with libcap])],
77     ,
78     [with_libcap="detect"]
79 )
80 AC_ARG_WITH(
81     [zlib],
82     [AS_HELP_STRING([--with-zlib], [build with zlib])],
83     ,
84     [with_zlib="yes"]
85 )
86 AC_ARG_WITH(
87     [math],
88     [AS_HELP_STRING([--with-math], [build with math])],
89     ,
90     [with_math="yes"]
91 )
92 AC_ARG_WITH(
93     [user],
94     [AS_HELP_STRING([--with-user], [use this user to drop privilege])],
95     ,
96     [with_user="nobody"]
97 )
98 AC_ARG_ENABLE(
99     [x86-sse],
100     [AS_HELP_STRING([--disable-x86-sse], [SSE/SS2 optimizations on x86 @<:@default enabled@:>@])],
101     ,
102     [enable_x86_sse="yes"]
103 )
104
105
106 # -----------------------------------------------------------------------------
107 # netdata required checks
108
109 # fails on centos6
110 #AX_CHECK_ENABLE_DEBUG()
111
112 AX_GCC_FUNC_ATTRIBUTE([returns_nonnull])
113 AX_GCC_FUNC_ATTRIBUTE([malloc])
114 AX_GCC_FUNC_ATTRIBUTE([noreturn])
115 AX_GCC_FUNC_ATTRIBUTE([format])
116 AX_GCC_FUNC_ATTRIBUTE([warn_unused_result])
117
118 AC_CHECK_FUNCS_ONCE(accept4)
119 AC_CHECK_TYPES([struct timespec, clockid_t], [], [], [[#include <time.h>]])
120 AC_SEARCH_LIBS([clock_gettime], [rt posix4])
121 AC_CHECK_FUNCS([clock_gettime])
122 AC_CHECK_FUNCS([sched_setscheduler sched_get_priority_min sched_get_priority_max nice])
123
124 AC_TYPE_INT8_T
125 AC_TYPE_INT16_T
126 AC_TYPE_INT32_T
127 AC_TYPE_INT64_T
128 AC_TYPE_UINT8_T
129 AC_TYPE_UINT16_T
130 AC_TYPE_UINT32_T
131 AC_TYPE_UINT64_T
132 AC_C_INLINE
133 AC_FUNC_STRERROR_R
134 AC_C__GENERIC
135 AC_C___ATOMIC
136 # AC_C_STMT_EXPR
137 AC_CHECK_SIZEOF([void *])
138 AC_CANONICAL_HOST
139 AC_HEADER_MAJOR
140 AC_HEADER_RESOLV
141
142 AC_CHECK_HEADERS_ONCE([sys/prctl.h])
143
144
145 # -----------------------------------------------------------------------------
146 # operating system detection
147
148 case "$host_os" in
149 freebsd*)
150     build_target=freebsd
151     ;;
152 darwin*)
153     build_target=macos
154     LDFLAGS="${LDFLAGS} -framework CoreFoundation -framework IOKit"
155     ;;
156 *)
157     build_target=linux
158     ;;
159 esac
160
161 AM_CONDITIONAL([FREEBSD], [test "${build_target}" = "freebsd"])
162 AM_CONDITIONAL([MACOS], [test "${build_target}" = "macos"])
163 AM_CONDITIONAL([LINUX], [test "${build_target}" = "linux"])
164
165
166 # -----------------------------------------------------------------------------
167 # compiler options
168
169 AC_ARG_VAR([SSE_CANDIDATE], [C compiler flags for SSE])
170 AS_CASE([$host_cpu],
171     [i?86], [SSE_CANDIDATE="yes"]
172 )
173 AC_SUBST([SSE_CANDIDATE])
174 if test "${SSE_CANDIDATE}" = "yes" -a "${enable_x86_sse}" = "yes"; then
175     opt="-msse2 -mfpmath=sse"
176     AX_CHECK_COMPILE_FLAG($opt, [CFLAGS="$CFLAGS $opt"], [])
177 fi
178
179 if test "${GCC}" = "yes"; then
180     AC_DEFINE_UNQUOTED([likely(x)], [__builtin_expect(!!(x), 1)], [gcc branch optimization])
181     AC_DEFINE_UNQUOTED([unlikely(x)], [__builtin_expect(!!(x), 0)], [gcc branch optimization])
182 else
183     AC_DEFINE_UNQUOTED([likely(x)], [(x)], [gcc branch optimization])
184     AC_DEFINE_UNQUOTED([unlikely(x)], [(x)], [gcc branch optimization])
185 fi
186
187 if test "${enable_pedantic}" = "yes"; then
188     enable_strict="yes"
189     CFLAGS="${CFLAGS} -pedantic -Wall -Wextra -Wno-long-long"
190 fi
191
192
193 # -----------------------------------------------------------------------------
194 # pthreads
195
196 ACX_PTHREAD(, [AC_MSG_ERROR([Cannot initialize pthread environment])])
197 LIBS="${PTHREAD_LIBS} ${LIBS}"
198 CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}"
199 CC="${PTHREAD_CC}"
200
201
202 # -----------------------------------------------------------------------------
203 # memory allocation library
204
205 AC_MSG_CHECKING([for memory allocator])
206 TS_CHECK_JEMALLOC
207 if test "$has_jemalloc" = "1"; then
208     AC_DEFINE([ENABLE_JEMALLOC], [1], [compile and link with jemalloc])
209     AC_MSG_RESULT([jemalloc])
210 else
211     TS_CHECK_TCMALLOC
212     if test "$has_tcmalloc" = "1"; then
213         AC_DEFINE([ENABLE_TCMALLOC], [1], [compile and link with tcmalloc])
214         AC_MSG_RESULT([tcmalloc])
215     else
216         AC_MSG_RESULT([system])
217         AC_C_MALLOPT
218         AC_C_MALLINFO
219     fi
220 fi
221
222
223 # -----------------------------------------------------------------------------
224 # libm
225
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
237 AC_MSG_CHECKING([if libm should be used])
238 if test "${with_math}" != "no" -a ! -z "${MATH_LIBS}"; then
239     with_math="yes"
240     AC_DEFINE([STORAGE_WITH_MATH], [1], [math usability])
241     OPTIONAL_MATH_CFLAGS="${MATH_CFLAGS}"
242     OPTIONAL_MATH_LIBS="${MATH_LIBS}"
243 else
244     with_math="no"
245 fi
246 AC_MSG_RESULT([${with_math}])
247
248
249 # -----------------------------------------------------------------------------
250 # zlib
251
252 PKG_CHECK_MODULES(
253     [ZLIB],
254     [zlib],
255     [have_zlib=yes],
256     [have_zlib=no]
257 )
258 test "${with_zlib}" = "yes" -a "${have_zlib}" != "yes" && AC_MSG_ERROR([zlib required but not found. Try installing 'zlib1g-dev' or 'zlib-devel'.])
259
260 AC_MSG_CHECKING([if zlib should be used])
261 if test "${with_zlib}" != "no" -a "${have_zlib}" = "yes"; then
262     with_zlib="yes"
263     AC_DEFINE([NETDATA_WITH_ZLIB], [1], [zlib usability])
264     OPTIONAL_ZLIB_CLFAGS="${ZLIB_CFLAGS}"
265     OPTIONAL_ZLIB_LIBS="${ZLIB_LIBS}"
266 else
267     with_zlib="no"
268 fi
269 AC_MSG_RESULT([${with_zlib}])
270
271
272 # -----------------------------------------------------------------------------
273 # libuuid
274
275 PKG_CHECK_MODULES(
276     [UUID],
277     [uuid],
278     [have_uuid=yes],
279     [AC_MSG_ERROR([libuuid required but not found. Try installing 'uuid-dev' or 'libuuid-devel'.])]
280 )
281 AC_DEFINE([NETDATA_WITH_UUID], [1], [uuid usability])
282 OPTIONAL_UUID_CLFAGS="${UUID_CFLAGS}"
283 OPTIONAL_UUID_LIBS="${UUID_LIBS}"
284
285
286 # -----------------------------------------------------------------------------
287 # libcap
288
289 PKG_CHECK_MODULES(
290     [LIBCAP],
291     [libcap],
292     [AC_CHECK_LIB([cap], [cap_get_proc, cap_set_proc],
293         [AC_CHECK_HEADER(
294             [sys/capability.h],
295             [have_libcap=yes],
296             [have_libcap=no]
297         )],
298         [have_libcap=no]
299     )],
300     [have_libcap=no]
301 )
302 test "${with_libcap}" = "yes" -a "${have_libcap}" != "yes" && AC_MSG_ERROR([libcap required but not found.])
303
304 AC_MSG_CHECKING([if libcap should be used])
305 if test "${with_libcap}" != "no" -a "${have_libcap}" = "yes"; then
306     with_libcap="yes"
307     AC_DEFINE([HAVE_CAPABILITY], [1], [libcap usability])
308     OPTIONAL_LIBCAP_CLFAGS="${LIBCAP_CFLAGS}"
309     OPTIONAL_LIBCAP_LIBS="${LIBCAP_LIBS}"
310 else
311     with_libcap="no"
312 fi
313 AC_MSG_RESULT([${with_libcap}])
314 AM_CONDITIONAL([ENABLE_CAPABILITY], [test "${with_libcap}" = "yes"])
315
316
317 # -----------------------------------------------------------------------------
318 # apps.plugin
319
320 AC_MSG_CHECKING([if apps.plugin should be enabled])
321 if test "${build_target}" != "macos"; then
322     enable_plugin_apps="yes"
323 else
324     enable_plugin_apps="no"
325 fi
326 AC_MSG_RESULT([${enable_plugin_apps}])
327 AM_CONDITIONAL([ENABLE_PLUGIN_APPS], [test "${enable_plugin_apps}" = "yes"])
328
329
330 # -----------------------------------------------------------------------------
331 # freeipmi.plugin - libipmimonitoring
332
333 PKG_CHECK_MODULES(
334     [IPMIMONITORING],
335     [libipmimonitoring],
336     [have_ipmimonitoring=yes],
337     [have_ipmimonitoring=no]
338 )
339 test "${enable_plugin_freeipmi}" = "yes" -a "${have_ipmimonitoring}" != "yes" && \
340     AC_MSG_ERROR([ipmimonitoring required but not found. Try installing 'libipmimonitoring-dev' or 'libipmimonitoring-devel'])
341
342 AC_MSG_CHECKING([if freeipmi.plugin should be enabled])
343 if test "${enable_plugin_freeipmi}" != "no" -a "${have_ipmimonitoring}" = "yes"; then
344     enable_plugin_freeipmi="yes"
345     AC_DEFINE([HAVE_FREEIPMI], [1], [ipmimonitoring usability])
346     OPTIONAL_IPMIMONITORING_CLFAGS="${IPMIMONITORING_CFLAGS}"
347     OPTIONAL_IPMIMONITORING_LIBS="${IPMIMONITORING_LIBS}"
348 else
349     enable_plugin_freeipmi="no"
350 fi
351 AC_MSG_RESULT([${enable_plugin_freeipmi}])
352 AM_CONDITIONAL([ENABLE_PLUGIN_FREEIPMI], [test "${enable_plugin_freeipmi}" = "yes"])
353
354
355 # -----------------------------------------------------------------------------
356 # nfacct.plugin - libmnl, libnetfilter_acct
357
358 PKG_CHECK_MODULES(
359     [NFACCT],
360     [libnetfilter_acct],
361     [have_libnetfilter_acct=yes],
362     [have_libnetfilter_acct=no]
363 )
364 PKG_CHECK_MODULES(
365     [LIBMNL],
366     [libmnl],
367     [have_libmnl=yes],
368     [have_libmnl=no]
369 )
370
371 test "${enable_plugin_nfacct}" = "yes" -a "${have_libnetfilter_acct}" != "yes" && \
372     AC_MSG_ERROR([netfilter_acct required but not found])
373
374 test "${enable_plugin_nfacct}" = "yes" -a "${have_libmnl}" != "yes" && \
375     AC_MSG_ERROR([libmnl required but not found. Try installing 'libmnl-dev' or 'libmnl-devel'])
376
377 AC_MSG_CHECKING([if nfacct.plugin should be enabled])
378 if test "${enable_plugin_nfacct}" != "no" -a "${have_libnetfilter_acct}" = "yes" -a "${have_libmnl}" = "yes"; then
379     enable_plugin_nfacct="yes"
380     AC_DEFINE([INTERNAL_PLUGIN_NFACCT], [1], [nfacct plugin usability])
381     OPTIONAL_NFACCT_CLFAGS="${NFACCT_CFLAGS} ${LIBMNL_CFLAGS}"
382     OPTIONAL_NFACCT_LIBS="${NFACCT_LIBS} ${LIBMNL_LIBS}"
383 else
384     enable_plugin_nfacct="no"
385 fi
386 AC_MSG_RESULT([${enable_plugin_nfacct}])
387 AM_CONDITIONAL([ENABLE_PLUGIN_NFACCT], [test "${enable_plugin_nfacct}" = "yes"])
388
389
390 # -----------------------------------------------------------------------------
391
392 AC_DEFINE_UNQUOTED([NETDATA_USER], ["${with_user}"], [use this user to drop privileged])
393
394 AC_SUBST([varlibdir], ["\$(localstatedir)/lib/netdata"])
395 AC_SUBST([registrydir], ["\$(localstatedir)/lib/netdata/registry"])
396 AC_SUBST([cachedir], ["\$(localstatedir)/cache/netdata"])
397 AC_SUBST([chartsdir], ["\$(libexecdir)/netdata/charts.d"])
398 AC_SUBST([nodedir], ["\$(libexecdir)/netdata/node.d"])
399 AC_SUBST([pythondir], ["\$(libexecdir)/netdata/python.d"])
400 AC_SUBST([configdir], ["\$(sysconfdir)/netdata"])
401 AC_SUBST([logdir], ["\$(localstatedir)/log/netdata"])
402 AC_SUBST([pluginsdir], ["\$(libexecdir)/netdata/plugins.d"])
403 AC_SUBST([webdir])
404
405 AC_SUBST([OPTIONAL_MATH_CLFAGS])
406 AC_SUBST([OPTIONAL_MATH_LIBS])
407 AC_SUBST([OPTIONAL_NFACCT_CLFAGS])
408 AC_SUBST([OPTIONAL_NFACCT_LIBS])
409 AC_SUBST([OPTIONAL_ZLIB_CLFAGS])
410 AC_SUBST([OPTIONAL_ZLIB_LIBS])
411 AC_SUBST([OPTIONAL_UUID_CLFAGS])
412 AC_SUBST([OPTIONAL_UUID_LIBS])
413 AC_SUBST([OPTIONAL_LIBCAP_CFLAGS])
414 AC_SUBST([OPTIONAL_LIBCAP_LIBS])
415 AC_SUBST([OPTIONAL_IPMIMONITORING_CFLAGS])
416 AC_SUBST([OPTIONAL_IPMIMONITORING_LIBS])
417
418 AC_CONFIG_FILES([
419     Makefile
420     charts.d/Makefile
421     conf.d/Makefile
422     netdata.spec
423     python.d/Makefile
424     node.d/Makefile
425     plugins.d/Makefile
426     src/Makefile
427     system/Makefile
428     web/Makefile
429     contrib/Makefile
430 ])
431 AC_OUTPUT
432
433 test "${with_math}" != "yes" && AC_MSG_WARN([You are building without math. math allows accurate calculations. It should be enabled.]) || :
434 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.]) || :