@cryptotaxi247 / netdata-1 / commits / 4f037c08a

configure.ac re-organization

Costa Tsaousis (ktsaou) committed Mar 4, 2017 at 12:47 UTC 4f037c08aafd59717c9038c4c5496828ad3ae4a5
2 files changed +176 -99
configure.ac
+172 -97
@@ -28,14 +28,9 @@ PACKAGE_RPM_VERSION="VERSION_NUMBER"
28 AC_SUBST([PACKAGE_RPM_VERSION])
29 AC_SUBST([PACKAGE_RPM_RELEASE])
30
31 -# fails on centos6
32 -#AX_CHECK_ENABLE_DEBUG()
31
34 -AX_GCC_FUNC_ATTRIBUTE(returns_nonnull)
35 -AX_GCC_FUNC_ATTRIBUTE(malloc)
36 -AX_GCC_FUNC_ATTRIBUTE(noreturn)
37 -AX_GCC_FUNC_ATTRIBUTE(format)
38 -AX_GCC_FUNC_ATTRIBUTE(warn_unused_result)
32 +# -----------------------------------------------------------------------------
33 +# autoconf initialization
34
35 AC_CONFIG_AUX_DIR([.])
36 AC_CONFIG_HEADERS([config.h])
@@ -47,29 +42,10 @@ AC_PROG_CC
42 AC_PROG_INSTALL
43 PKG_PROG_PKG_CONFIG
44 AC_USE_SYSTEM_EXTENSIONS
50 -AC_CHECK_FUNCS_ONCE(accept4)
51 -AC_CHECK_TYPES([struct timespec, clockid_t], [], [], [[#include <time.h>]])
52 -AC_SEARCH_LIBS([clock_gettime], [rt posix4])
53 -AC_CHECK_FUNCS([clock_gettime])
54 -AC_CHECK_FUNCS([sched_setscheduler sched_get_priority_min sched_get_priority_max nice])
45
56 -# Check system type
57 -case "$host_os" in
58 -freebsd*)
59 - build_target=freebsd
60 - ;;
61 -darwin*)
62 - build_target=macos
63 - LDFLAGS="${LDFLAGS} -framework CoreFoundation -framework IOKit"
64 - ;;
65 -*)
66 - build_target=linux
67 - ;;
68 -esac
46
70 -AM_CONDITIONAL([FREEBSD], [test x$build_target = xfreebsd])
71 -AM_CONDITIONAL([MACOS], [test x$build_target = xmacos])
72 -AM_CONDITIONAL([LINUX], [test x$build_target = xlinux])
47 +# -----------------------------------------------------------------------------
48 +# configurable options
49
50 AC_ARG_ENABLE(
51 [plugin-nfacct],
@@ -95,6 +71,12 @@ AC_ARG_WITH(
71 [webdir="${withval}"],
72 [webdir="\$(pkgdatadir)/web"]
73 )
74 +AC_ARG_WITH(
75 + [cap],
76 + [AS_HELP_STRING([--with-cap], [build with libcap])],
77 + ,
78 + [with_cap="detect"]
79 +)
80 AC_ARG_WITH(
81 [zlib],
82 [AS_HELP_STRING([--with-zlib], [build with zlib])],
@@ -120,23 +102,24 @@ AC_ARG_ENABLE(
102 [enable_x86_sse="yes"]
103 )
104
123 -ACX_PTHREAD(, [AC_MSG_ERROR([Cannot initialize pthread environment])])
124 -LIBS="${PTHREAD_LIBS} ${LIBS}"
125 -CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}"
126 -CC="${PTHREAD_CC}"
105
128 -TS_CHECK_JEMALLOC
129 -if test "$has_jemalloc" = "1"; then
130 - AC_DEFINE([ENABLE_JEMALLOC], [1], [compile and link with jemalloc])
131 -else
132 - TS_CHECK_TCMALLOC
133 - if test "$has_tcmalloc" = "1"; then
134 - AC_DEFINE([ENABLE_TCMALLOC], [1], [compile and link with tcmalloc])
135 - else
136 - AC_C_MALLOPT
137 - AC_C_MALLINFO
138 - fi
139 -fi
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
@@ -155,18 +138,33 @@ 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
160 -AC_CHECK_LIB([cap], [cap_get_proc, cap_set_proc],
161 - [AC_CHECK_HEADER(
162 - [sys/capability.h],
163 - [
164 - CAP_LIBS=-lcap
165 - AC_DEFINE([HAVE_CAPABILITY], [1], [libcap usability])
166 - ]
167 - )]
168 -)
169 -OPTIONAL_CAP_LIBS="${CAP_LIBS}"
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 x$build_target = xfreebsd])
162 +AM_CONDITIONAL([MACOS], [test x$build_target = xmacos])
163 +AM_CONDITIONAL([LINUX], [test x$build_target = xlinux])
164 +
165 +
166 +# -----------------------------------------------------------------------------
167 +# compiler options
168
169 AC_ARG_VAR([SSE_CANDIDATE], [C compiler flags for SSE])
170 AS_CASE([$host_cpu],
@@ -178,6 +176,49 @@ if test "${SSE_CANDIDATE}" = "yes" -a "${enable_x86_sse}" = "yes"; then
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 +TS_CHECK_JEMALLOC
206 +if test "$has_jemalloc" = "1"; then
207 + AC_DEFINE([ENABLE_JEMALLOC], [1], [compile and link with jemalloc])
208 +else
209 + TS_CHECK_TCMALLOC
210 + if test "$has_tcmalloc" = "1"; then
211 + AC_DEFINE([ENABLE_TCMALLOC], [1], [compile and link with tcmalloc])
212 + else
213 + AC_C_MALLOPT
214 + AC_C_MALLINFO
215 + fi
216 +fi
217 +
218 +
219 +# -----------------------------------------------------------------------------
220 +# libm
221 +
222 AC_ARG_VAR([MATH_CFLAGS], [C compiler flags for math])
223 AC_ARG_VAR([MATH_LIBS], [linker flags for math])
224 if test -z "${MATH_LIBS}"; then
@@ -188,32 +229,93 @@ if test -z "${MATH_LIBS}"; then
229 )
230 fi
231
232 +if test "${with_math}" = "yes"; then
233 + test -z "${MATH_LIBS}" && AC_MSG_ERROR([math required but not found])
234 + AC_DEFINE([STORAGE_WITH_MATH], [1], [math settings])
235 + OPTIONAL_MATH_CFLAGS="${MATH_CFLAGS}"
236 + OPTIONAL_MATH_LIBS="${MATH_LIBS}"
237 +fi
238 +
239 +
240 +# -----------------------------------------------------------------------------
241 +# zlib
242 +
243 +if test "${with_zlib}" = "yes"; then
244 + PKG_CHECK_MODULES(
245 + [ZLIB],
246 + [zlib],
247 + )
248 + test -z "${ZLIB_LIBS}" && AC_MSG_ERROR([zlib required but not found. Try installing 'zlib1g-dev' or 'zlib-devel'.])
249 + AC_DEFINE([NETDATA_WITH_ZLIB], [1], [zlib settings])
250 + OPTIONAL_ZLIB_CLFAGS="${ZLIB_CFLAGS}"
251 + OPTIONAL_ZLIB_LIBS="${ZLIB_LIBS}"
252 +fi
253 +
254 +
255 +# -----------------------------------------------------------------------------
256 +# libuuid
257 +
258 PKG_CHECK_MODULES(
259 [UUID],
260 [uuid],
261 + [have_uuid=yes],
262 + [have_uuid=no]
263 )
195 -test -z "${UUID_LIBS}" && AC_MSG_ERROR([libuuid required but not found. Try installing 'uuid-dev' or 'libuuid-devel'.])
196 -AC_DEFINE([NETDATA_WITH_UUID], [1], [uuid settings])
264 +test "${have_uuid}" = "no" && AC_MSG_ERROR([libuuid required but not found. Try installing 'uuid-dev' or 'libuuid-devel'.])
265 +AC_DEFINE([NETDATA_WITH_UUID], [1], [uuid usability])
266 OPTIONAL_UUID_CLFAGS="${UUID_CFLAGS}"
267 OPTIONAL_UUID_LIBS="${UUID_LIBS}"
268
200 -if test ! "${enable_plugin_freeipmi}" = "no"; then
269 +
270 +# -----------------------------------------------------------------------------
271 +# libcap
272 +
273 +if test "${with_cap}" != "no"; then
274 + PKG_CHECK_MODULES(
275 + [CAP],
276 + [libcap],
277 + [have_cap=yes],
278 + [have_cap=no]
279 + )
280 +fi
281 +test "${have_cap}" = "no" -a "${with_cap}" = "yes" && AC_MSG_ERROR([libcap required but not found.])
282 +if test "${have_cap}" = "yes"; then
283 + AC_DEFINE([HAVE_CAPABILITY], [1], [libcap usability])
284 + OPTIONAL_CAP_CLFAGS="${CAP_CFLAGS}"
285 + OPTIONAL_CAP_LIBS="${CAP_LIBS}"
286 +fi
287 +AM_CONDITIONAL([ENABLE_CAPABILITY], [test "${have_cap}" = "yes"])
288 +
289 +
290 +# -----------------------------------------------------------------------------
291 +# apps.plugin
292 +
293 +AM_CONDITIONAL([ENABLE_PLUGIN_APPS], [test "${build_target}" != "macos"])
294 +
295 +
296 +# -----------------------------------------------------------------------------
297 +# freeipmi.plugin - libipmimonitoring
298 +
299 +if test "${enable_plugin_freeipmi}" != "no"; then
300 PKG_CHECK_MODULES(
301 [IPMIMONITORING],
302 [libipmimonitoring],
204 - ,
205 - :
303 + [have_ipmimonitoring=yes],
304 + [have_ipmimonitoring=no]
305 )
207 - if test ! -z "${IPMIMONITORING_LIBS}"; then
208 - enable_plugin_freeipmi="yes"
209 - AC_DEFINE([HAVE_FREEIPMI], [1], [ipmimonitoring usability])
210 - OPTIONAL_IPMIMONITORING_CLFAGS="${IPMIMONITORING_CFLAGS}"
211 - OPTIONAL_IPMIMONITORING_LIBS="${IPMIMONITORING_LIBS}"
212 - elif test "${enable_plugin_freeipmi}" = "yes"; then
213 - AC_MSG_ERROR([ipmimonitoring required but not found. Try installing 'libipmimonitoring-dev' or 'libipmimonitoring-devel'])
214 - fi
306 fi
216 -AM_CONDITIONAL([FREEIPMI], [test x$enable_plugin_freeipmi = xyes])
307 +test "${have_ipmimonitoring}" = "no" -a "${enable_plugin_freeipmi}" = "yes" && \
308 + AC_MSG_ERROR([ipmimonitoring required but not found. Try installing 'libipmimonitoring-dev' or 'libipmimonitoring-devel'])
309 +if test "${have_ipmimonitoring}" = "yes"; then
310 + AC_DEFINE([HAVE_FREEIPMI], [1], [ipmimonitoring usability])
311 + OPTIONAL_IPMIMONITORING_CLFAGS="${IPMIMONITORING_CFLAGS}"
312 + OPTIONAL_IPMIMONITORING_LIBS="${IPMIMONITORING_LIBS}"
313 +fi
314 +AM_CONDITIONAL([ENABLE_PLUGIN_FREEIPMI], [test "${have_ipmimonitoring}" = "yes"])
315 +
316 +
317 +# -----------------------------------------------------------------------------
318 +# nfacct.plugin - libmnl, libnetfilter_acct
319
320 if test "${enable_plugin_nfacct}" = "yes"; then
321 PKG_CHECK_MODULES(
@@ -231,36 +333,8 @@ if test "${enable_plugin_nfacct}" = "yes"; then
333 OPTIONAL_NFACCT_LIBS="${NFACCT_LIBS} ${LIBMNL_LIBS}"
334 fi
335
234 -if test "${with_zlib}" = "yes"; then
235 - PKG_CHECK_MODULES(
236 - [ZLIB],
237 - [zlib],
238 - )
239 - test -z "${ZLIB_LIBS}" && AC_MSG_ERROR([zlib required but not found. Try installing 'zlib1g-dev' or 'zlib-devel'.])
240 - AC_DEFINE([NETDATA_WITH_ZLIB], [1], [zlib settings])
241 - OPTIONAL_ZLIB_CLFAGS="${ZLIB_CFLAGS}"
242 - OPTIONAL_ZLIB_LIBS="${ZLIB_LIBS}"
243 -fi
244 -
245 -if test "${with_math}" = "yes"; then
246 - test -z "${MATH_LIBS}" && AC_MSG_ERROR([math required but not found])
247 - AC_DEFINE([STORAGE_WITH_MATH], [1], [math settings])
248 - OPTIONAL_MATH_CFLAGS="${MATH_CFLAGS}"
249 - OPTIONAL_MATH_LIBS="${MATH_LIBS}"
250 -fi
336
252 -if test "${GCC}" = "yes"; then
253 - AC_DEFINE_UNQUOTED([likely(x)], [__builtin_expect(!!(x), 1)], [gcc branch optimization])
254 - AC_DEFINE_UNQUOTED([unlikely(x)], [__builtin_expect(!!(x), 0)], [gcc branch optimization])
255 -else
256 - AC_DEFINE_UNQUOTED([likely(x)], [(x)], [gcc branch optimization])
257 - AC_DEFINE_UNQUOTED([unlikely(x)], [(x)], [gcc branch optimization])
258 -fi
259 -
260 -if test "${enable_pedantic}" = "yes"; then
261 - enable_strict="yes"
262 - CFLAGS="${CFLAGS} -pedantic -Wall -Wextra -Wno-long-long"
263 -fi
337 +# -----------------------------------------------------------------------------
338
339 AC_DEFINE_UNQUOTED([NETDATA_USER], ["${with_user}"], [use this user to drop privileged])
340
@@ -283,6 +357,7 @@ AC_SUBST([OPTIONAL_ZLIB_CLFAGS])
357 AC_SUBST([OPTIONAL_ZLIB_LIBS])
358 AC_SUBST([OPTIONAL_UUID_CLFAGS])
359 AC_SUBST([OPTIONAL_UUID_LIBS])
360 +AC_SUBST([OPTIONAL_CAP_CFLAGS])
361 AC_SUBST([OPTIONAL_CAP_LIBS])
362 AC_SUBST([OPTIONAL_IPMIMONITORING_CFLAGS])
363 AC_SUBST([OPTIONAL_IPMIMONITORING_LIBS])
src/Makefile.am
+4 -2
@@ -26,10 +26,12 @@ dist_varlib_DATA = .keep
26 dist_registry_DATA = .keep
27 dist_log_DATA = .keep
28 plugins_PROGRAMS =
29 -if !MACOS
29 +
30 +if ENABLE_PLUGIN_APPS
31 plugins_PROGRAMS += apps.plugin
32 endif
32 -if FREEIPMI
33 +
34 +if ENABLE_PLUGIN_FREEIPMI
35 plugins_PROGRAMS += freeipmi.plugin
36 endif
37