Build system: Further improve libiptc handling.
[collectd.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(collectd, m4_esyscmd(./version-gen.sh))
3 AC_CONFIG_SRCDIR(src/collectd.c)
4 AC_CONFIG_HEADERS(src/config.h)
5
6 m4_ifdef([LT_PACKAGE_VERSION],
7         # libtool >= 2.2
8         [
9          LT_CONFIG_LTDL_DIR([libltdl])
10          LT_INIT([dlopen])
11          LTDL_INIT([convenience])
12         ]
13 ,
14         # libtool <= 1.5
15         [
16          AC_LIBLTDL_CONVENIENCE
17          AC_SUBST(LTDLINCL)
18          AC_SUBST(LIBLTDL)
19          AC_LIBTOOL_DLOPEN
20          AC_CONFIG_SUBDIRS(libltdl)
21         ]
22 )
23
24 AM_INIT_AUTOMAKE(dist-bzip2)
25 AC_LANG(C)
26
27 AC_PREFIX_DEFAULT("/opt/collectd")
28
29 AC_SYS_LARGEFILE
30
31 #
32 # Checks for programs.
33 #
34 AC_PROG_CC
35 AC_PROG_CPP
36 AC_PROG_INSTALL
37 AC_PROG_LN_S
38 AC_PROG_MAKE_SET
39 AM_PROG_CC_C_O
40 AM_CONDITIONAL(COMPILER_IS_GCC, test "x$GCC" = "xyes")
41
42 AC_DISABLE_STATIC
43 AC_PROG_LIBTOOL
44 AC_PROG_LEX
45 AC_PROG_YACC
46 PKG_PROG_PKG_CONFIG
47
48 AC_MSG_CHECKING([for kernel type ($host_os)])
49 case $host_os in
50         *linux*)
51         AC_DEFINE([KERNEL_LINUX], 1, [True if program is to be compiled for a Linux kernel])
52         ac_system="Linux"
53         ;;
54         *solaris*)
55         AC_DEFINE([KERNEL_SOLARIS], 1, [True if program is to be compiled for a Solaris kernel])
56         ac_system="Solaris"
57         ;;
58         *darwin*)
59         ac_system="Darwin"
60         ;;
61         *openbsd*)
62         ac_system="OpenBSD"
63         ;;
64         *)
65         ac_system="unknown"
66 esac
67 AC_MSG_RESULT([$ac_system])
68
69 if test "x$ac_system" = "xLinux"
70 then
71         AC_ARG_VAR([KERNEL_DIR], [path to Linux kernel sources])
72         if test -z "$KERNEL_DIR"
73         then
74                 KERNEL_DIR="/lib/modules/`uname -r`/source"
75         fi
76
77         KERNEL_CFLAGS="-I$KERNEL_DIR/include"
78         AC_SUBST(KERNEL_CFLAGS)
79 fi
80
81 if test "x$ac_system" = "xSolaris"
82 then
83         AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [Define to enforce POSIX thread semantics under Solaris.])
84 fi
85
86 # Where to install .pc files.
87 pkgconfigdir="${libdir}/pkgconfig"
88 AC_SUBST(pkgconfigdir)
89
90 # Check for standards compliance mode
91 AC_ARG_ENABLE(standards,
92               AS_HELP_STRING([--enable-standards], [Enable standards compliance mode]),
93               [enable_standards="$enableval"],
94               [enable_standards="no"])
95 if test "x$enable_standards" = "xyes"
96 then
97         AC_DEFINE(_ISOC99_SOURCE,        1, [Define to enforce ISO C99 compliance.])
98         AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Define to enforce POSIX.1-2001 compliance.])
99         AC_DEFINE(_XOPEN_SOURCE,       600, [Define to enforce X/Open 6 (XSI) compliance.])
100         AC_DEFINE(_REENTRANT,            1, [Define to enable reentrancy interfaces.])
101 fi
102 AM_CONDITIONAL(BUILD_FEATURE_STANDARDS, test "x$enable_standards" = "xyes")
103
104 #
105 # Checks for header files.
106 #
107 AC_HEADER_STDC
108 AC_HEADER_SYS_WAIT
109 AC_HEADER_DIRENT
110 AC_HEADER_STDBOOL
111
112 AC_CHECK_HEADERS(stdio.h stdint.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h sys/ioctl.h endian.h sys/isa_defs.h)
113
114 # For ping library
115 AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
116 [#if HAVE_STDINT_H
117 # include <stdint.h>
118 #endif
119 #if HAVE_SYS_TYPES_H
120 # include <sys/types.h>
121 #endif
122 ])
123 AC_CHECK_HEADERS(netinet/in.h, [], [],
124 [#if HAVE_STDINT_H
125 # include <stdint.h>
126 #endif
127 #if HAVE_SYS_TYPES_H
128 # include <sys/types.h>
129 #endif
130 #if HAVE_NETINET_IN_SYSTM_H
131 # include <netinet/in_systm.h>
132 #endif
133 ])
134 AC_CHECK_HEADERS(netinet/ip.h, [], [],
135 [#if HAVE_STDINT_H
136 # include <stdint.h>
137 #endif
138 #if HAVE_SYS_TYPES_H
139 # include <sys/types.h>
140 #endif
141 #if HAVE_NETINET_IN_SYSTM_H
142 # include <netinet/in_systm.h>
143 #endif
144 #if HAVE_NETINET_IN_H
145 # include <netinet/in.h>
146 #endif
147 ])
148 AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [],
149 [#if HAVE_STDINT_H
150 # include <stdint.h>
151 #endif
152 #if HAVE_SYS_TYPES_H
153 # include <sys/types.h>
154 #endif
155 #if HAVE_NETINET_IN_SYSTM_H
156 # include <netinet/in_systm.h>
157 #endif
158 #if HAVE_NETINET_IN_H
159 # include <netinet/in.h>
160 #endif
161 #if HAVE_NETINET_IP_H
162 # include <netinet/ip.h>
163 #endif
164 ])
165 AC_CHECK_HEADERS(netinet/ip_var.h, [], [],
166 [#if HAVE_STDINT_H
167 # include <stdint.h>
168 #endif
169 #if HAVE_SYS_TYPES_H
170 # include <sys/types.h>
171 #endif
172 #if HAVE_NETINET_IN_SYSTM_H
173 # include <netinet/in_systm.h>
174 #endif
175 #if HAVE_NETINET_IN_H
176 # include <netinet/in.h>
177 #endif
178 #if HAVE_NETINET_IP_H
179 # include <netinet/ip.h>
180 #endif
181 ])
182 AC_CHECK_HEADERS(netinet/ip6.h, [], [],
183 [#if HAVE_STDINT_H
184 # include <stdint.h>
185 #endif
186 #if HAVE_SYS_TYPES_H
187 # include <sys/types.h>
188 #endif
189 #if HAVE_NETINET_IN_SYSTM_H
190 # include <netinet/in_systm.h>
191 #endif
192 #if HAVE_NETINET_IN_H
193 # include <netinet/in.h>
194 #endif
195 ])
196 AC_CHECK_HEADERS(netinet/icmp6.h, [], [],
197 [#if HAVE_STDINT_H
198 # include <stdint.h>
199 #endif
200 #if HAVE_SYS_TYPES_H
201 # include <sys/types.h>
202 #endif
203 #if HAVE_NETINET_IN_SYSTM_H
204 # include <netinet/in_systm.h>
205 #endif
206 #if HAVE_NETINET_IN_H
207 # include <netinet/in.h>
208 #endif
209 #if HAVE_NETINET_IP6_H
210 # include <netinet/ip6.h>
211 #endif
212 ])
213 AC_CHECK_HEADERS(netinet/tcp.h, [], [],
214 [#if HAVE_STDINT_H
215 # include <stdint.h>
216 #endif
217 #if HAVE_SYS_TYPES_H
218 # include <sys/types.h>
219 #endif
220 #if HAVE_NETINET_IN_SYSTM_H
221 # include <netinet/in_systm.h>
222 #endif
223 #if HAVE_NETINET_IN_H
224 # include <netinet/in.h>
225 #endif
226 #if HAVE_NETINET_IP_H
227 # include <netinet/ip.h>
228 #endif
229 ])
230 AC_CHECK_HEADERS(netinet/udp.h, [], [],
231 [#if HAVE_STDINT_H
232 # include <stdint.h>
233 #endif
234 #if HAVE_SYS_TYPES_H
235 # include <sys/types.h>
236 #endif
237 #if HAVE_NETINET_IN_SYSTM_H
238 # include <netinet/in_systm.h>
239 #endif
240 #if HAVE_NETINET_IN_H
241 # include <netinet/in.h>
242 #endif
243 #if HAVE_NETINET_IP_H
244 # include <netinet/ip.h>
245 #endif
246 ])
247
248 # For cpu modules
249 AC_CHECK_HEADERS(sys/dkstat.h)
250 if test "x$ac_system" = "xDarwin"
251 then
252         AC_CHECK_HEADERS(mach/mach_init.h mach/host_priv.h mach/mach_error.h mach/mach_host.h mach/mach_port.h mach/mach_types.h mach/message.h mach/processor_set.h mach/processor.h mach/processor_info.h mach/task.h mach/thread_act.h mach/vm_region.h mach/vm_map.h mach/vm_prot.h mach/vm_statistics.h mach/kern_return.h)
253         AC_CHECK_HEADERS(CoreFoundation/CoreFoundation.h IOKit/IOKitLib.h IOKit/IOTypes.h IOKit/ps/IOPSKeys.h IOKit/IOBSD.h IOKit/storage/IOBlockStorageDriver.h)
254 fi
255 AC_CHECK_HEADERS(sys/sysctl.h, [], [],
256 [
257 #if HAVE_SYS_TYPES_H
258 #  include <sys/types.h>
259 #endif
260 #if HAVE_SYS_PARAM_H
261 # include <sys/param.h>
262 #endif
263 ])
264
265 # For hddtemp module
266 AC_CHECK_HEADERS(linux/major.h libgen.h)
267
268 # For the battery plugin
269 AC_CHECK_HEADERS(IOKit/ps/IOPowerSources.h, [], [],
270 [
271 #if HAVE_IOKIT_IOKITLIB_H
272 #  include <IOKit/IOKitLib.h>
273 #endif
274 #if HAVE_IOKIT_IOTYPES_H
275 #  include <IOKit/IOTypes.h>
276 #endif
277 ])
278
279 # For the swap module
280 have_sys_swap_h="yes"
281 AC_CHECK_HEADERS(sys/swap.h vm/anon.h, [], [have_sys_swap_h="no"],
282 [
283 #undef _FILE_OFFSET_BITS
284 #undef _LARGEFILE64_SOURCE
285 #if HAVE_SYS_TYPES_H
286 #  include <sys/types.h>
287 #endif
288 #if HAVE_SYS_PARAM_H
289 # include <sys/param.h>
290 #endif
291 ])
292
293 if test "x$have_sys_swap_h$ac_system" = "xnoSolaris"
294 then
295         hint_64=""
296         if test "x$GCC" = "xyes"
297         then
298                 hint_64="CFLAGS='-m64'"
299         else
300                 hint_64="CFLAGS='-xarch=v9'"
301         fi
302         AC_MSG_NOTICE([Solaris detected and sys/swap.h not usable. Try building a 64-bit binary ($hint_64 ./configure).])
303 fi
304
305 # For load module
306 # For the processes plugin
307 # For users module
308 AC_CHECK_HEADERS(sys/loadavg.h linux/config.h utmp.h utmpx.h)
309
310 # For interface plugin
311 AC_CHECK_HEADERS(ifaddrs.h)
312 AC_CHECK_HEADERS(net/if.h, [], [],
313 [
314 #if HAVE_SYS_TYPES_H
315 #  include <sys/types.h>
316 #endif
317 #if HAVE_SYS_SOCKET_H
318 #  include <sys/socket.h>
319 #endif
320 ])
321 AC_CHECK_HEADERS(linux/if.h, [], [],
322 [
323 #if HAVE_SYS_TYPES_H
324 #  include <sys/types.h>
325 #endif
326 #if HAVE_SYS_SOCKET_H
327 #  include <sys/socket.h>
328 #endif
329 ])
330 AC_CHECK_HEADERS(linux/netdevice.h, [], [],
331 [
332 #if HAVE_SYS_TYPES_H
333 #  include <sys/types.h>
334 #endif
335 #if HAVE_SYS_SOCKET_H
336 #  include <sys/socket.h>
337 #endif
338 #if HAVE_LINUX_IF_H
339 # include <linux/if.h>
340 #endif
341 ])
342
343 # For ipvs module
344 have_net_ip_vs_h="no"
345 have_ip_vs_h="no"
346 if test "x$ac_system" = "xLinux"
347 then
348         SAVE_CFLAGS="$CFLAGS"
349         CFLAGS="$CFLAGS $KERNEL_CFLAGS"
350
351         AC_CHECK_HEADERS(net/ip_vs.h, [have_net_ip_vs_h="yes"])
352         AC_CHECK_HEADERS(ip_vs.h, [have_ip_vs_h="yes"])
353
354         CFLAGS="$SAVE_CFLAGS"
355 fi
356
357 # For quota module
358 AC_CHECK_HEADERS(sys/ucred.h, [], [],
359 [
360 #if HAVE_SYS_TYPES_H
361 #  include <sys/types.h>
362 #endif
363 #if HAVE_SYS_PARAM_H
364 # include <sys/param.h>
365 #endif
366 ])
367
368 # For mount interface
369 AC_CHECK_HEADERS(sys/mount.h, [], [],
370 [
371 #if HAVE_SYS_TYPES_H
372 #  include <sys/types.h>
373 #endif
374 #if HAVE_SYS_PARAM_H
375 # include <sys/param.h>
376 #endif
377 ])
378
379 # For the email plugin
380 AC_CHECK_HEADERS(linux/un.h, [], [],
381 [
382 #if HAVE_SYS_SOCKET_H
383 #       include <sys/socket.h>
384 #endif
385 ])
386
387 AC_CHECK_HEADERS(pwd.h grp.h sys/un.h ctype.h limits.h xfs/xqm.h fs_info.h fshelp.h paths.h mntent.h mnttab.h sys/fstyp.h sys/fs_types.h sys/mntent.h sys/mnttab.h sys/statfs.h sys/statvfs.h sys/vfs.h sys/vfstab.h kvm.h wordexp.h)
388
389 # For the dns plugin
390 AC_CHECK_HEADERS(arpa/nameser.h)
391 AC_CHECK_HEADERS(arpa/nameser_compat.h, [], [],
392 [
393 #if HAVE_ARPA_NAMESER_H
394 # include <arpa/nameser.h>
395 #endif
396 ])
397
398 AC_CHECK_HEADERS(net/if_arp.h, [], [],
399 [#if HAVE_SYS_SOCKET_H
400 # include <sys/socket.h>
401 #endif
402 ])
403 AC_CHECK_HEADERS(net/ppp_defs.h)
404 AC_CHECK_HEADERS(net/if_ppp.h, [], [],
405 [#if HAVE_NET_PPP_DEFS_H
406 # include <net/ppp_defs.h>
407 #endif
408 ])
409 AC_CHECK_HEADERS(netinet/if_ether.h, [], [],
410 [#if HAVE_STDINT_H
411 # include <stdint.h>
412 #endif
413 #if HAVE_SYS_TYPES_H
414 # include <sys/types.h>
415 #endif
416 #if HAVE_SYS_SOCKET_H
417 # include <sys/socket.h>
418 #endif
419 #if HAVE_NET_IF_H
420 # include <net/if.h>
421 #endif
422 #if HAVE_NETINET_IN_H
423 # include <netinet/in.h>
424 #endif
425 ])
426
427 # For the multimeter plugin
428 have_termios_h="no"
429 AC_CHECK_HEADERS(termios.h, [have_termios_h="yes"])
430
431 #
432 # Checks for typedefs, structures, and compiler characteristics.
433 #
434 AC_C_CONST
435 AC_TYPE_PID_T
436 AC_TYPE_SIZE_T
437 AC_TYPE_UID_T
438 AC_HEADER_TIME
439
440 #
441 # Checks for library functions.
442 #
443 AC_PROG_GCC_TRADITIONAL
444 AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog closelog sysconf)
445
446 AC_FUNC_STRERROR_R
447
448 AC_CACHE_CHECK([for strtok_r],
449   [c_cv_have_strtok_r_default],
450   AC_LINK_IFELSE(
451     AC_LANG_PROGRAM(
452     [[[[
453 #include <stdlib.h>
454 #include <stdio.h>
455 #include <string.h>
456     ]]]],
457     [[[[
458       char buffer[] = "foo,bar,baz";
459       char *token;
460       char *dummy;
461       char *saveptr;
462
463       dummy = buffer;
464       saveptr = NULL;
465       while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
466       {
467         dummy = NULL;
468         printf ("token = %s;\n", token);
469       }
470     ]]]]),
471     [c_cv_have_strtok_r_default="yes"],
472     [c_cv_have_strtok_r_default="no"]
473   )
474 )
475
476 if test "x$c_cv_have_strtok_r_default" = "xno"
477 then
478   SAVE_CFLAGS="$CFLAGS"
479   CFLAGS="$CFLAGS -D_REENTRANT=1"
480
481   AC_CACHE_CHECK([if strtok_r needs _REENTRANT],
482     [c_cv_have_strtok_r_reentrant],
483     AC_LINK_IFELSE(
484       AC_LANG_PROGRAM(
485       [[[[
486 #include <stdlib.h>
487 #include <stdio.h>
488 #include <string.h>
489       ]]]],
490       [[[[
491         char buffer[] = "foo,bar,baz";
492         char *token;
493         char *dummy;
494         char *saveptr;
495
496         dummy = buffer;
497         saveptr = NULL;
498         while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
499         {
500           dummy = NULL;
501           printf ("token = %s;\n", token);
502         }
503       ]]]]),
504       [c_cv_have_strtok_r_reentrant="yes"],
505       [AC_MSG_FAILURE([strtok_r isn't available. Please file a bugreport!])]
506     )
507   )
508 fi
509
510 AC_CHECK_FUNCS(getpwnam_r getgrnam_r setgroups regcomp regerror regexec regfree)
511
512 socket_needs_socket="no"
513 AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [socket_needs_socket="yes"], AC_MSG_ERROR(cannot find socket)))
514 AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
515
516 nanosleep_needs_rt="no"
517 AC_CHECK_FUNCS(nanosleep, [], AC_CHECK_LIB(rt, nanosleep, [nanosleep_needs_rt="yes"], AC_MSG_ERROR(cannot find nanosleep)))
518 AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes")
519
520 AC_CHECK_FUNCS(sysctl, [have_sysctl="yes"], [have_sysctl="no"])
521 AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
522 AC_CHECK_FUNCS(host_statistics, [have_host_statistics="yes"], [have_host_statistics="no"])
523 AC_CHECK_FUNCS(processor_info, [have_processor_info="yes"], [have_processor_info="no"])
524 AC_CHECK_FUNCS(thread_info, [have_thread_info="yes"], [have_thread_info="no"])
525 AC_CHECK_FUNCS(statfs, [have_statfs="yes"], [have_statfs="no"])
526 AC_CHECK_FUNCS(statvfs, [have_statvfs="yes"], [have_statvfs="no"])
527 AC_CHECK_FUNCS(getifaddrs, [have_getifaddrs="yes"], [have_getifaddrs="no"])
528 AC_CHECK_FUNCS(syslog, [have_syslog="yes"], [have_syslog="no"])
529 AC_CHECK_FUNCS(getutent, [have_getutent="yes"], [have_getutent="no"])
530 AC_CHECK_FUNCS(getutxent, [have_getutxent="yes"], [have_getutxent="no"])
531 AC_CHECK_FUNCS(swapctl, [have_swapctl="yes"], [have_swapctl="no"])
532
533 # For load module
534 AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
535
536 # Check for NAN
537 AC_ARG_WITH(nan-emulation, [AS_HELP_STRING([--with-nan-emulation], [use emulated NAN. For crosscompiling only.])],
538 [
539  if test "x$withval" = "xno"; then
540          nan_type="none"
541  else if test "x$withval" = "xyes"; then
542          nan_type="zero"
543  else
544          nan_type="$withval"
545  fi; fi
546 ],
547 [nan_type="none"])
548 if test "x$nan_type" = "xnone"; then
549   AC_CACHE_CHECK([whether NAN is defined by default],
550     [c_cv_have_nan_default],
551     AC_COMPILE_IFELSE(
552       AC_LANG_PROGRAM(
553       [[
554 #include <stdlib.h>
555 #include <math.h>
556 static float foo = NAN;
557       ]],
558       [[
559        if (isnan (foo))
560         return 0;
561        else
562         return 1;
563       ]]),
564       [c_cv_have_nan_default="yes"],
565       [c_cv_have_nan_default="no"]
566     )
567   )
568   if test "x$c_cv_have_nan_default" = "xyes"
569   then
570     nan_type="default"
571   fi
572 fi
573 if test "x$nan_type" = "xnone"; then
574   AC_CACHE_CHECK([whether NAN is defined by __USE_ISOC99],
575     [c_cv_have_nan_isoc],
576     AC_COMPILE_IFELSE(
577       AC_LANG_PROGRAM(
578       [[
579 #include <stdlib.h>
580 #define __USE_ISOC99 1
581 #include <math.h>
582 static float foo = NAN;
583       ]],
584       [[
585        if (isnan (foo))
586         return 0;
587        else
588         return 1;
589       ]]),
590       [c_cv_have_nan_isoc="yes"],
591       [c_cv_have_nan_isoc="no"]
592     )
593   )
594   if test "x$c_cv_have_nan_isoc" = "xyes"
595   then
596     nan_type="isoc99"
597   fi
598 fi
599 if test "x$nan_type" = "xnone"; then
600   AC_CACHE_CHECK([whether NAN can be defined by 0/0],
601     [c_cv_have_nan_zero],
602     AC_RUN_IFELSE(
603       AC_LANG_PROGRAM(
604       [[
605 #include <stdlib.h>
606 #include <math.h>
607 #ifdef NAN
608 # undef NAN
609 #endif
610 #define NAN (0.0 / 0.0)
611 #ifndef isnan
612 # define isnan(f) ((f) != (f))
613 #endif
614 static float foo = NAN;
615       ]],
616       [[
617        if (isnan (foo))
618         return 0;
619        else
620         return 1;
621       ]]),
622       [c_cv_have_nan_zero="yes"],
623       [c_cv_have_nan_zero="no"]
624     )
625   )
626   if test "x$c_cv_have_nan_zero" = "xyes"
627   then
628     nan_type="zero"
629   fi
630 fi
631
632 if test "x$nan_type" = "xdefault"; then
633   AC_DEFINE(NAN_STATIC_DEFAULT, 1,
634     [Define if NAN is defined by default and can initialize static variables.])
635 else if test "x$nan_type" = "xisoc99"; then
636   AC_DEFINE(NAN_STATIC_ISOC, 1,
637     [Define if NAN is defined by __USE_ISOC99 and can initialize static variables.])
638 else if test "x$nan_type" = "xzero"; then
639   AC_DEFINE(NAN_ZERO_ZERO, 1,
640     [Define if NAN can be defined as (0.0 / 0.0)])
641 else
642   AC_MSG_ERROR([Didn't find out how to statically initialize variables to NAN. Sorry.])
643 fi; fi; fi
644
645 AC_ARG_WITH(fp-layout, [AS_HELP_STRING([--with-fp-layout], [set the memory layout of doubles. For crosscompiling only.])],
646 [
647  if test "x$withval" = "xnothing"; then
648         fp_layout_type="nothing"
649  else if test "x$withval" = "xendianflip"; then
650         fp_layout_type="endianflip"
651  else if test "x$withval" = "xintswap"; then
652         fp_layout_type="intswap"
653  else
654         AC_MSG_ERROR([Invalid argument for --with-fp-layout. Valid arguments are: nothing, endianflip, intswap]);
655 fi; fi; fi
656 ],
657 [fp_layout_type="unknown"])
658
659 if test "x$fp_layout_type" = "xunknown"; then
660   AC_CACHE_CHECK([if doubles are stored in x86 representation],
661     [c_cv_fp_layout_need_nothing],
662     AC_RUN_IFELSE(
663       AC_LANG_PROGRAM(
664       [[[[
665 #include <stdlib.h>
666 #include <stdio.h>
667 #include <string.h>
668 #if HAVE_STDINT_H
669 # include <stdint.h>
670 #endif
671 #if HAVE_STDBOOL_H
672 # include <stdbool.h>
673 #endif
674       ]]]],
675       [[[[
676         uint64_t i0;
677         uint64_t i1;
678         uint8_t c[8];
679         double d;
680
681         d = 8.642135e130; 
682         memcpy ((void *) &i0, (void *) &d, 8);
683
684         i1 = i0;
685         memcpy ((void *) c, (void *) &i1, 8);
686
687         if ((c[0] == 0x2f) && (c[1] == 0x25)
688                         && (c[2] == 0xc0) && (c[3] == 0xc7)
689                         && (c[4] == 0x43) && (c[5] == 0x2b)
690                         && (c[6] == 0x1f) && (c[7] == 0x5b))
691                 return (0);
692         else
693                 return (1);
694       ]]]]),
695       [c_cv_fp_layout_need_nothing="yes"],
696       [c_cv_fp_layout_need_nothing="no"]
697     )
698   )
699   if test "x$c_cv_fp_layout_need_nothing" = "xyes"; then
700     fp_layout_type="nothing"
701   fi
702 fi
703 if test "x$fp_layout_type" = "xunknown"; then
704   AC_CACHE_CHECK([if endianflip converts to x86 representation],
705     [c_cv_fp_layout_need_endianflip],
706     AC_RUN_IFELSE(
707       AC_LANG_PROGRAM(
708       [[[[
709 #include <stdlib.h>
710 #include <stdio.h>
711 #include <string.h>
712 #if HAVE_STDINT_H
713 # include <stdint.h>
714 #endif
715 #if HAVE_STDBOOL_H
716 # include <stdbool.h>
717 #endif
718 #define endianflip(A) ((((uint64_t)(A) & 0xff00000000000000LL) >> 56) | \
719                        (((uint64_t)(A) & 0x00ff000000000000LL) >> 40) | \
720                        (((uint64_t)(A) & 0x0000ff0000000000LL) >> 24) | \
721                        (((uint64_t)(A) & 0x000000ff00000000LL) >> 8)  | \
722                        (((uint64_t)(A) & 0x00000000ff000000LL) << 8)  | \
723                        (((uint64_t)(A) & 0x0000000000ff0000LL) << 24) | \
724                        (((uint64_t)(A) & 0x000000000000ff00LL) << 40) | \
725                        (((uint64_t)(A) & 0x00000000000000ffLL) << 56))
726       ]]]],
727       [[[[
728         uint64_t i0;
729         uint64_t i1;
730         uint8_t c[8];
731         double d;
732
733         d = 8.642135e130; 
734         memcpy ((void *) &i0, (void *) &d, 8);
735
736         i1 = endianflip (i0);
737         memcpy ((void *) c, (void *) &i1, 8);
738
739         if ((c[0] == 0x2f) && (c[1] == 0x25)
740                         && (c[2] == 0xc0) && (c[3] == 0xc7)
741                         && (c[4] == 0x43) && (c[5] == 0x2b)
742                         && (c[6] == 0x1f) && (c[7] == 0x5b))
743                 return (0);
744         else
745                 return (1);
746       ]]]]),
747       [c_cv_fp_layout_need_endianflip="yes"],
748       [c_cv_fp_layout_need_endianflip="no"]
749     )
750   )
751   if test "x$c_cv_fp_layout_need_endianflip" = "xyes"; then
752     fp_layout_type="endianflip"
753   fi
754 fi
755 if test "x$fp_layout_type" = "xunknown"; then
756   AC_CACHE_CHECK([if intswap converts to x86 representation],
757     [c_cv_fp_layout_need_intswap],
758     AC_RUN_IFELSE(
759       AC_LANG_PROGRAM(
760       [[[[
761 #include <stdlib.h>
762 #include <stdio.h>
763 #include <string.h>
764 #if HAVE_STDINT_H
765 # include <stdint.h>
766 #endif
767 #if HAVE_STDBOOL_H
768 # include <stdbool.h>
769 #endif
770 #define intswap(A)    ((((uint64_t)(A) & 0xffffffff00000000LL) >> 32) | \
771                        (((uint64_t)(A) & 0x00000000ffffffffLL) << 32))
772       ]]]],
773       [[[[
774         uint64_t i0;
775         uint64_t i1;
776         uint8_t c[8];
777         double d;
778
779         d = 8.642135e130; 
780         memcpy ((void *) &i0, (void *) &d, 8);
781
782         i1 = intswap (i0);
783         memcpy ((void *) c, (void *) &i1, 8);
784
785         if ((c[0] == 0x2f) && (c[1] == 0x25)
786                         && (c[2] == 0xc0) && (c[3] == 0xc7)
787                         && (c[4] == 0x43) && (c[5] == 0x2b)
788                         && (c[6] == 0x1f) && (c[7] == 0x5b))
789                 return (0);
790         else
791                 return (1);
792       ]]]]),
793       [c_cv_fp_layout_need_intswap="yes"],
794       [c_cv_fp_layout_need_intswap="no"]
795     )
796   )
797   if test "x$c_cv_fp_layout_need_intswap" = "xyes"; then
798     fp_layout_type="intswap"
799   fi
800 fi
801
802 if test "x$fp_layout_type" = "xnothing"; then
803   AC_DEFINE(FP_LAYOUT_NEED_NOTHING, 1,
804   [Define if doubles are stored in x86 representation.])
805 else if test "x$fp_layout_type" = "xendianflip"; then
806   AC_DEFINE(FP_LAYOUT_NEED_ENDIANFLIP, 1,
807   [Define if endianflip is needed to convert to x86 representation.])
808 else if test "x$fp_layout_type" = "xintswap"; then
809   AC_DEFINE(FP_LAYOUT_NEED_INTSWAP, 1,
810   [Define if intswap is needed to convert to x86 representation.])
811 else
812   AC_MSG_ERROR([Didn't find out how doubles are stored in memory. Sorry.])
813 fi; fi; fi
814
815 have_getfsstat="no"
816 AC_CHECK_FUNCS(getfsstat, [have_getfsstat="yes"])
817 have_getvfsstat="no"
818 AC_CHECK_FUNCS(getvfsstat, [have_getvfsstat="yes"])
819 have_listmntent="no"
820 AC_CHECK_FUNCS(listmntent, [have_listmntent="yes"])
821
822 have_getmntent="no"
823 AC_CHECK_FUNCS(getmntent, [have_getmntent="c"])
824 if test "x$have_getmntent" = "xno"; then
825         AC_CHECK_LIB(sun, getmntent, [have_getmntent="sun"])
826 fi
827 if test "x$have_getmntent" = "xno"; then
828         AC_CHECK_LIB(seq, getmntent, [have_getmntent="seq"])
829 fi
830 if test "x$have_getmntent" = "xno"; then
831         AC_CHECK_LIB(gen, getmntent, [have_getmntent="gen"])
832 fi
833
834 if test "x$have_getmntent" = "xc"; then
835         AC_CACHE_CHECK([whether getmntent takes one argument],
836                 [c_cv_have_one_getmntent],
837                 AC_COMPILE_IFELSE(
838                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
839 #include "$srcdir/src/utils_mount.h"]],
840                                 [[
841                                  FILE *fh;
842                                  struct mntent *me;
843                                  fh = setmntent ("/etc/mtab", "r");
844                                  me = getmntent (fh);
845                                 ]]
846                         ),
847                         [c_cv_have_one_getmntent="yes"],
848                         [c_cv_have_one_getmntent="no"]
849                 )
850         )
851         AC_CACHE_CHECK([whether getmntent takes two arguments],
852                 [c_cv_have_two_getmntent],
853                 AC_COMPILE_IFELSE(
854                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
855 #include "$srcdir/src/utils_mount.h"]],
856                                 [[
857                                  FILE *fh;
858                                  struct mnttab mt;
859                                  int status;
860                                  fh = fopen ("/etc/mnttab", "r");
861                                  status = getmntent (fh, &mt);
862                                 ]]
863                         ),
864                         [c_cv_have_two_getmntent="yes"],
865                         [c_cv_have_two_getmntent="no"]
866                 )
867         )
868 fi
869
870 # Check for different versions of `getmntent' here..
871
872 if test "x$have_getmntent" = "xc"; then
873         if test "x$c_cv_have_one_getmntent" = "xyes"; then
874                 AC_DEFINE(HAVE_ONE_GETMNTENT, 1,
875                           [Define if the function getmntent exists and takes one argument.])
876         fi
877         if test "x$c_cv_have_two_getmntent" = "xyes"; then
878                 AC_DEFINE(HAVE_TWO_GETMNTENT, 1,
879                           [Define if the function getmntent exists and takes two arguments.])
880         fi
881 fi
882 if test "x$have_getmntent" = "xsun"; then
883         AC_DEFINE(HAVE_SUN_GETMNTENT, 1,
884                   [Define if the function getmntent exists. It's the version from libsun.])
885 fi
886 if test "x$have_getmntent" = "xseq"; then
887         AC_DEFINE(HAVE_SEQ_GETMNTENT, 1,
888                   [Define if the function getmntent exists. It's the version from libseq.])
889 fi
890 if test "x$have_getmntent" = "xgen"; then
891         AC_DEFINE(HAVE_GEN_GETMNTENT, 1,
892                   [Define if the function getmntent exists. It's the version from libgen.])
893 fi
894
895 # Check for structures
896 AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
897         [AC_DEFINE(HAVE_STRUCT_IF_DATA, 1, [Define if struct if_data exists and is usable.])],
898         [],
899         [
900         #include <sys/types.h>
901         #include <sys/socket.h>
902         #include <net/if.h>
903         ])
904 AC_CHECK_MEMBERS([struct net_device_stats.rx_bytes, struct net_device_stats.tx_packets, struct net_device_stats.rx_errors],
905         [AC_DEFINE(HAVE_STRUCT_NET_DEVICE_STATS, 1, [Define if struct net_device_stats exists and is usable.])],
906         [],
907         [
908         #include <sys/types.h>
909         #include <sys/socket.h>
910         #include <linux/if.h>
911         #include <linux/netdevice.h>
912         ])
913
914 AC_CHECK_MEMBERS([struct kinfo_proc.ki_pid, struct kinfo_proc.ki_rssize, struct kinfo_proc.ki_rusage],
915         [
916                 AC_DEFINE(HAVE_STRUCT_KINFO_PROC_FREEBSD, 1,
917                         [Define if struct kinfo_proc exists in the FreeBSD variant.])
918                 have_struct_kinfo_proc_freebsd="yes"
919         ],
920         [
921                 have_struct_kinfo_proc_freebsd="no"
922         ],
923         [
924 #include <kvm.h>
925 #include <sys/param.h>
926 #include <sys/sysctl.h>
927 #include <sys/user.h>
928         ])
929
930 AC_CHECK_MEMBERS([struct kinfo_proc.kp_proc, struct kinfo_proc.kp_eproc],
931         [
932                 AC_DEFINE(HAVE_STRUCT_KINFO_PROC_OPENBSD, 1,
933                         [Define if struct kinfo_proc exists in the OpenBSD variant.])
934                 have_struct_kinfo_proc_openbsd="yes"
935         ],
936         [
937                 have_struct_kinfo_proc_openbsd="no"
938         ],
939         [
940 #include <sys/param.h>
941 #include <sys/sysctl.h>
942 #include <kvm.h>
943         ])
944
945 AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
946 [#define _BSD_SOURCE
947 #if HAVE_STDINT_H
948 # include <stdint.h>
949 #endif
950 #if HAVE_SYS_TYPES_H
951 # include <sys/types.h>
952 #endif
953 #if HAVE_NETINET_IN_SYSTM_H
954 # include <netinet/in_systm.h>
955 #endif
956 #if HAVE_NETINET_IN_H
957 # include <netinet/in.h>
958 #endif
959 #if HAVE_NETINET_IP_H
960 # include <netinet/ip.h>
961 #endif
962 #if HAVE_NETINET_UDP_H
963 # include <netinet/udp.h>
964 #endif
965 ])
966 AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source], [], [],
967 [#define _BSD_SOURCE
968 #if HAVE_STDINT_H
969 # include <stdint.h>
970 #endif
971 #if HAVE_SYS_TYPES_H
972 # include <sys/types.h>
973 #endif
974 #if HAVE_NETINET_IN_SYSTM_H
975 # include <netinet/in_systm.h>
976 #endif
977 #if HAVE_NETINET_IN_H
978 # include <netinet/in.h>
979 #endif
980 #if HAVE_NETINET_IP_H
981 # include <netinet/ip.h>
982 #endif
983 #if HAVE_NETINET_UDP_H
984 # include <netinet/udp.h>
985 #endif
986 ])
987
988 AC_CHECK_MEMBERS([kstat_io_t.nwritten, kstat_io_t.writes, kstat_io_t.nwrites, kstat_io_t.wtime],
989         [],
990         [],
991         [
992 #if HAVE_KSTAT_H
993 # include <kstat.h>
994 #endif
995         ])
996
997 #
998 # Checks for libraries begin here
999 #
1000 with_libresolv="yes"
1001 AC_CHECK_LIB(resolv, res_search,
1002 [
1003         AC_DEFINE(HAVE_LIBRESOLV, 1, [Define to 1 if you have the 'resolv' library (-lresolv).])
1004 ],
1005 [with_libresolv="no"])
1006 AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")
1007
1008 dnl Check for HAL (hardware abstraction library)
1009 with_libhal="yes"
1010 AC_CHECK_LIB(hal,libhal_device_property_exists,
1011              [AC_DEFINE(HAVE_LIBHAL, 1, [Define to 1 if you have 'hal' library])],
1012              [with_libhal="no"])
1013 if test "x$with_libhal" = "xyes"; then
1014         if test "x$PKG_CONFIG" != "x"; then
1015                 BUILD_WITH_LIBHAL_CFLAGS="`pkg-config --cflags hal`"
1016                 BUILD_WITH_LIBHAL_LIBS="`pkg-config --libs hal`"
1017                 AC_SUBST(BUILD_WITH_LIBHAL_CFLAGS)
1018                 AC_SUBST(BUILD_WITH_LIBHAL_LIBS)
1019         fi
1020 fi
1021
1022 m4_divert_once([HELP_WITH], [
1023 collectd additional packages:])
1024
1025 if test "x$ac_system" = "xSolaris"
1026 then
1027         with_kstat="yes"
1028         with_devinfo="yes"
1029 else
1030         with_kstat="no (Solaris only)"
1031         with_devinfo="no (Solaris only)"
1032 fi
1033
1034 if test "x$with_kstat" = "xyes"
1035 then
1036         AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
1037 fi
1038 if test "x$with_kstat" = "xyes"
1039 then
1040         AC_CHECK_LIB(devinfo, di_init, [with_devinfo="yes"], [with_devinfo="no (not found)"], [])
1041         AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
1042 fi
1043 if test "x$with_kstat" = "xyes"
1044 then
1045         AC_DEFINE(HAVE_LIBKSTAT, 1,
1046                   [Define to 1 if you have the 'kstat' library (-lkstat)])
1047 fi
1048 AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
1049 AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
1050
1051 with_libiokit="no"
1052 AC_CHECK_LIB(IOKit, IOServiceGetMatchingServices,
1053 [
1054         with_libiokit="yes"
1055 ], 
1056 [
1057         with_libiokit="no"
1058 ])
1059 AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
1060
1061 with_libkvm="no"
1062 AC_CHECK_LIB(kvm, kvm_getprocs, [with_kvm_getprocs="yes"], [with_kvm_getprocs="no"])
1063 if test "x$with_kvm_getprocs" = "xyes"
1064 then
1065         AC_DEFINE(HAVE_LIBKVM_GETPROCS, 1,
1066                   [Define to 1 if you have the 'kvm' library with the 'kvm_getprocs' symbol (-lkvm)])
1067         with_libkvm="yes"
1068 fi
1069 AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETPROCS, test "x$with_kvm_getprocs" = "xyes")
1070
1071 AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_kvm_getswapinfo="yes"], [with_kvm_getswapinfo="no"])
1072 if test "x$with_kvm_getswapinfo" = "xyes"
1073 then
1074         AC_DEFINE(HAVE_LIBKVM_GETSWAPINFO, 1,
1075                   [Define to 1 if you have the 'kvm' library with the 'kvm_getswapinfo' symbol (-lkvm)])
1076         with_libkvm="yes"
1077 fi
1078 AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETSWAPINFO, test "x$with_kvm_getswapinfo" = "xyes")
1079
1080 AC_CHECK_LIB(kvm, kvm_nlist, [with_kvm_nlist="yes"], [with_kvm_nlist="no"])
1081 if test "x$with_kvm_nlist" = "xyes"
1082 then
1083         AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
1084                   [Define to 1 if you have the 'kvm' library with the 'kvm_nlist' symbol (-lkvm)])
1085         with_libkvm="yes"
1086 fi
1087 AM_CONDITIONAL(BUILD_WITH_LIBKVM_NLIST, test "x$with_kvm_nlist" = "xyes")
1088
1089 AC_CHECK_LIB(kvm, kvm_openfiles, [with_kvm_openfiles="yes"], [with_kvm_openfiles="no"])
1090 if test "x$with_kvm_openfiles" = "xyes"
1091 then
1092         AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
1093                   [Define to 1 if you have the 'kvm' library with the 'kvm_openfiles' symbol (-lkvm)])
1094         with_libkvm="yes"
1095 fi
1096 AM_CONDITIONAL(BUILD_WITH_LIBKVM_OPENFILES, test "x$with_kvm_openfiles" = "xyes")
1097
1098 # --with-libcurl {{{
1099 with_curl_config="curl-config"
1100 with_curl_cflags=""
1101 with_curl_libs=""
1102 AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
1103 [
1104         if test "x$withval" = "xno"
1105         then
1106                 with_libcurl="no"
1107         else if test "x$withval" = "xyes"
1108         then
1109                 with_libcurl="yes"
1110         else
1111                 if test -f "$withval" && test -x "$withval"
1112                 then
1113                         with_curl_config="$withval"
1114                         with_libcurl="yes"
1115                 else if test -x "$withval/bin/curl-config"
1116                 then
1117                         with_curl_config="$withval/bin/curl-config"
1118                         with_libcurl="yes"
1119                 fi; fi
1120                 with_libcurl="yes"
1121         fi; fi
1122 ],
1123 [
1124         with_libcurl="yes"
1125 ])
1126 if test "x$with_libcurl" = "xyes"
1127 then
1128         with_curl_cflags=`$with_curl_config --cflags 2>/dev/null`
1129         curl_config_status=$?
1130
1131         if test $curl_config_status -ne 0
1132         then
1133                 with_libcurl="no ($with_curl_config failed)"
1134         else
1135                 SAVE_CPPFLAGS="$CPPFLAGS"
1136                 CPPFLAGS="$CPPFLAGS $with_curl_cflags"
1137
1138                 AC_CHECK_HEADERS(curl/curl.h, [], [with_libcurl="no (curl/curl.h not found)"], [])
1139
1140                 CPPFLAGS="$SAVE_CPPFLAGS"
1141         fi
1142 fi
1143 if test "x$with_libcurl" = "xyes"
1144 then
1145         with_curl_libs=`$with_curl_config --libs 2>/dev/null`
1146         curl_config_status=$?
1147
1148         if test $curl_config_status -ne 0
1149         then
1150                 with_libcurl="no ($with_curl_config failed)"
1151         else
1152                 AC_CHECK_LIB(curl, curl_easy_init,
1153                  [with_libcurl="yes"],
1154                  [with_libcurl="no (symbol 'curl_easy_init' not found)"],
1155                  [$with_curl_libs])
1156         fi
1157 fi
1158 if test "x$with_libcurl" = "xyes"
1159 then
1160         BUILD_WITH_LIBCURL_CFLAGS="$with_curl_cflags"
1161         BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
1162         AC_SUBST(BUILD_WITH_LIBCURL_CFLAGS)
1163         AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
1164 fi
1165 AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
1166 # }}}
1167
1168 # --with-libdbi {{{
1169 with_libdbi_cppflags=""
1170 with_libdbi_ldflags=""
1171 AC_ARG_WITH(libdbi, [AS_HELP_STRING([--with-libdbi@<:@=PREFIX@:>@], [Path to libdbi.])],
1172 [
1173         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1174         then
1175                 with_libdbi_cppflags="-I$withval/include"
1176                 with_libdbi_ldflags="-L$withval/lib"
1177                 with_libdbi="yes"
1178         else
1179                 with_libdbi="$withval"
1180         fi
1181 ],
1182 [
1183         with_libdbi="yes"
1184 ])
1185 if test "x$with_libdbi" = "xyes"
1186 then
1187         SAVE_CPPFLAGS="$CPPFLAGS"
1188         CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
1189
1190         AC_CHECK_HEADERS(dbi/dbi.h, [with_libdbi="yes"], [with_libdbi="no (dbi/dbi.h not found)"])
1191
1192         CPPFLAGS="$SAVE_CPPFLAGS"
1193 fi
1194 if test "x$with_libdbi" = "xyes"
1195 then
1196         SAVE_CPPFLAGS="$CPPFLAGS"
1197         SAVE_LDFLAGS="$LDFLAGS"
1198         CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
1199         LDFLAGS="$LDFLAGS $with_libdbi_ldflags"
1200
1201         AC_CHECK_LIB(dbi, dbi_initialize, [with_libdbi="yes"], [with_libdbi="no (Symbol 'dbi_initialize' not found)"])
1202
1203         CPPFLAGS="$SAVE_CPPFLAGS"
1204         LDFLAGS="$SAVE_LDFLAGS"
1205 fi
1206 if test "x$with_libdbi" = "xyes"
1207 then
1208         BUILD_WITH_LIBDBI_CPPFLAGS="$with_libdbi_cppflags"
1209         BUILD_WITH_LIBDBI_LDFLAGS="$with_libdbi_ldflags"
1210         BUILD_WITH_LIBDBI_LIBS="-ldbi"
1211         AC_SUBST(BUILD_WITH_LIBDBI_CPPFLAGS)
1212         AC_SUBST(BUILD_WITH_LIBDBI_LDFLAGS)
1213         AC_SUBST(BUILD_WITH_LIBDBI_LIBS)
1214 fi
1215 AM_CONDITIONAL(BUILD_WITH_LIBDBI, test "x$with_libdbi" = "xyes")
1216 # }}}
1217
1218 # --with-libesmtp {{{
1219 AC_ARG_WITH(libesmtp, [AS_HELP_STRING([--with-libesmtp@<:@=PREFIX@:>@], [Path to libesmtp.])],
1220 [
1221         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1222         then
1223                 LDFLAGS="$LDFLAGS -L$withval/lib"
1224                 CPPFLAGS="$CPPFLAGS -I$withval/include -D_THREAD_SAFE"
1225                 with_libesmtp="yes"
1226         else
1227                 with_libesmtp="$withval"
1228         fi
1229 ],
1230 [
1231         with_libesmtp="yes"
1232 ])
1233 if test "x$with_libesmtp" = "xyes"
1234 then
1235         AC_CHECK_LIB(esmtp, smtp_create_session,
1236         [
1237                 AC_DEFINE(HAVE_LIBESMTP, 1, [Define to 1 if you have the esmtp library (-lesmtp).])
1238         ], [with_libesmtp="no (libesmtp not found)"])
1239 fi
1240 if test "x$with_libesmtp" = "xyes"
1241 then
1242         AC_CHECK_HEADERS(libesmtp.h,
1243         [
1244                 AC_DEFINE(HAVE_LIBESMTP_H, 1, [Define to 1 if you have the <libesmtp.h> header file.])
1245         ], [with_libesmtp="no (libesmtp.h not found)"])
1246 fi
1247 if test "x$with_libesmtp" = "xyes"
1248 then
1249         collect_libesmtp=1
1250 else
1251         collect_libesmtp=0
1252 fi
1253 AC_DEFINE_UNQUOTED(COLLECT_LIBESMTP, [$collect_libesmtp],
1254         [Wether or not to use the esmtp library])
1255 AM_CONDITIONAL(BUILD_WITH_LIBESMTP, test "x$with_libesmtp" = "xyes")
1256 # }}}
1257
1258 # --with-libganglia {{{
1259 AC_ARG_WITH(libganglia, [AS_HELP_STRING([--with-libganglia@<:@=PREFIX@:>@], [Path to libganglia.])],
1260 [
1261  if test -f "$withval" && test -x "$withval"
1262  then
1263          with_libganglia_config="$withval"
1264          with_libganglia="yes"
1265  else if test -f "$withval/bin/ganglia-config" && test -x "$withval/bin/ganglia-config"
1266  then
1267          with_libganglia_config="$withval/bin/ganglia-config"
1268          with_libganglia="yes"
1269  else if test -d "$withval"
1270  then
1271          GANGLIA_CPPFLAGS="-I$withval/include"
1272          GANGLIA_LDFLAGS="-L$withval/lib"
1273          with_libganglia="yes"
1274  else
1275          with_libganglia_config="ganglia-config"
1276          with_libganglia="$withval"
1277  fi; fi; fi
1278 ],
1279 [
1280  with_libganglia_config="ganglia-config"
1281  with_libganglia="yes"
1282 ])
1283
1284 if test "x$with_libganglia" = "xyes" && test "x$with_libganglia_config" != "x"
1285 then
1286         if test "x$GANGLIA_CPPFLAGS" = "x"
1287         then
1288                 GANGLIA_CPPFLAGS=`"$with_libganglia_config" --cflags 2>/dev/null`
1289         fi
1290
1291         if test "x$GANGLIA_LDFLAGS" = "x"
1292         then
1293                 GANGLIA_LDFLAGS=`"$with_libganglia_config" --ldflags 2>/dev/null`
1294         fi
1295
1296         if test "x$GANGLIA_LIBS" = "x"
1297         then
1298                 GANGLIA_LIBS=`"$with_libganglia_config" --libs 2>/dev/null`
1299         fi
1300 fi
1301
1302 SAVE_CPPFLAGS="$CPPFLAGS"
1303 SAVE_LDFLAGS="$LDFLAGS"
1304 CPPFLAGS="$CPPFLAGS $GANGLIA_CPPFLAGS"
1305 LDFLAGS="$LDFLAGS $GANGLIA_LDFLAGS"
1306
1307 if test "x$with_libganglia" = "xyes"
1308 then
1309         AC_CHECK_HEADERS(gm_protocol.h,
1310         [
1311                 AC_DEFINE(HAVE_GM_PROTOCOL_H, 1,
1312                           [Define to 1 if you have the <gm_protocol.h> header file.])
1313         ], [with_libganglia="no (gm_protocol.h not found)"])
1314 fi
1315
1316 if test "x$with_libganglia" = "xyes"
1317 then
1318         AC_CHECK_LIB(ganglia, xdr_Ganglia_value_msg,
1319         [
1320                 AC_DEFINE(HAVE_LIBGANGLIA, 1,
1321                           [Define to 1 if you have the ganglia library (-lganglia).])
1322         ], [with_libganglia="no (symbol xdr_Ganglia_value_msg not found)"])
1323 fi
1324
1325 CPPFLAGS="$SAVE_CPPFLAGS"
1326 LDFLAGS="$SAVE_LDFLAGS"
1327
1328 AC_SUBST(GANGLIA_CPPFLAGS)
1329 AC_SUBST(GANGLIA_LDFLAGS)
1330 AC_SUBST(GANGLIA_LIBS)
1331 AM_CONDITIONAL(BUILD_WITH_LIBGANGLIA, test "x$with_libganglia" = "xyes")
1332 # }}}
1333
1334 # --with-libgcrypt {{{
1335 GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS"
1336 GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS"
1337 GCRYPT_LIBS="$GCRYPT_LIBS"
1338 AC_ARG_WITH(libgcrypt, [AS_HELP_STRING([--with-libgcrypt@<:@=PREFIX@:>@], [Path to libgcrypt.])],
1339 [
1340  if test -f "$withval" && test -x "$withval"
1341  then
1342          with_libgcrypt_config="$withval"
1343          with_libgcrypt="yes"
1344  else if test -f "$withval/bin/gcrypt-config" && test -x "$withval/bin/gcrypt-config"
1345  then
1346          with_libgcrypt_config="$withval/bin/gcrypt-config"
1347          with_libgcrypt="yes"
1348  else if test -d "$withval"
1349  then
1350          GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS -I$withval/include"
1351          GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS -L$withval/lib"
1352          with_libgcrypt="yes"
1353  else
1354          with_libgcrypt_config="gcrypt-config"
1355          with_libgcrypt="$withval"
1356  fi; fi; fi
1357 ],
1358 [
1359  with_libgcrypt_config="libgcrypt-config"
1360  with_libgcrypt="yes"
1361 ])
1362
1363 if test "x$with_libgcrypt" = "xyes" && test "x$with_libgcrypt_config" != "x"
1364 then
1365         if test "x$GCRYPT_CPPFLAGS" = "x"
1366         then
1367                 GCRYPT_CPPFLAGS=`"$with_libgcrypt_config" --cflags 2>/dev/null`
1368         fi
1369
1370         if test "x$GCRYPT_LDFLAGS" = "x"
1371         then
1372                 gcrypt_exec_prefix=`"$with_libgcrypt_config" --exec-prefix 2>/dev/null`
1373                 GCRYPT_LDFLAGS="-L$gcrypt_exec_prefix/lib"
1374         fi
1375
1376         if test "x$GCRYPT_LIBS" = "x"
1377         then
1378                 GCRYPT_LIBS=`"$with_libgcrypt_config" --libs 2>/dev/null`
1379         fi
1380 fi
1381
1382 SAVE_CPPFLAGS="$CPPFLAGS"
1383 SAVE_LDFLAGS="$LDFLAGS"
1384 CPPFLAGS="$CPPFLAGS $GCRYPT_CPPFLAGS"
1385 LDFLAGS="$LDFLAGS $GCRYPT_LDFLAGS"
1386
1387 if test "x$with_libgcrypt" = "xyes"
1388 then
1389         if test "x$GCRYPT_CPPFLAGS" != "x"
1390         then
1391                 AC_MSG_NOTICE([gcrypt CPPFLAGS: $GCRYPT_CPPFLAGS])
1392         fi
1393         AC_CHECK_HEADERS(gcrypt.h,
1394                 [with_libgcrypt="yes"],
1395                 [with_libgcrypt="no (gcrypt.h not found)"])
1396 fi
1397
1398 if test "x$with_libgcrypt" = "xyes"
1399 then
1400         if test "x$GCRYPT_LDFLAGS" != "x"
1401         then
1402                 AC_MSG_NOTICE([gcrypt LDFLAGS: $GCRYPT_LDFLAGS])
1403         fi
1404         AC_CHECK_LIB(gcrypt, gcry_md_hash_buffer,
1405                 [with_libgcrypt="yes"],
1406                 [with_libgcrypt="no (symbol gcry_md_hash_buffer not found)"])
1407
1408         if test "$with_libgcrypt" != "no"; then
1409                 AM_PATH_LIBGCRYPT(1:1.2.0,,with_libgcrypt="no (version 1.2.0+ required)")
1410         fi
1411 fi
1412
1413 CPPFLAGS="$SAVE_CPPFLAGS"
1414 LDFLAGS="$SAVE_LDFLAGS"
1415
1416 if test "x$with_libgcrypt" = "xyes"
1417 then
1418         AC_DEFINE(HAVE_LIBGCRYPT, 1, [Define to 1 if you have the gcrypt library (-lgcrypt).])
1419 fi
1420
1421 AC_SUBST(GCRYPT_CPPFLAGS)
1422 AC_SUBST(GCRYPT_LDFLAGS)
1423 AC_SUBST(GCRYPT_LIBS)
1424 AM_CONDITIONAL(BUILD_WITH_LIBGCRYPT, test "x$with_libgcrypt" = "xyes")
1425 # }}}
1426
1427 # --with-libiptc {{{
1428 with_own_libiptc="no"
1429 AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
1430 [
1431         if test "x$withval" = "xshipped"
1432         then
1433                 with_own_libiptc="yes"
1434                 with_libiptc="yes"
1435         else if test "x$withval" != "xno" && test "x$withval" != "xyes"
1436         then
1437                 LIBIPTC_CPPFLAGS="$LIBIPTC_CPPFLAGS -I$withval/include"
1438                 LIBIPTC_LDFLAGS="$LIBIPTC_LDFLAGS -L$withval/lib"
1439                 with_libiptc="yes"
1440         else
1441                 with_libiptc="$withval"
1442         fi; fi
1443 ],
1444 [
1445         if test "x$ac_system" = "xLinux"
1446         then
1447                 with_libiptc="yes"
1448         else
1449                 with_libiptc="no (Linux only)"
1450         fi
1451 ])
1452 SAVE_CPPFLAGS="$CPPFLAGS"
1453 SAVE_LDFLAGS="$LDFLAGS"
1454 CPPFLAGS="$CPPFLAGS $LIBIPTC_CPPFLAGS"
1455 LDFLAGS="$LDFLAGS $LIBIPTC_LDFLAGS"
1456 if test "x$with_libiptc" = "xyes"
1457 then
1458         AC_CHECK_HEADERS(linux/netfilter_ipv4/ip_tables.h linux/netfilter_ipv6/ip6_tables.h, [],
1459         [
1460                 with_libiptc="no (Linux iptables headers not found)"
1461                 with_own_libiptc="no"
1462         ],
1463         [
1464 #include "$srcdir/src/owniptc/ipt_kernel_headers.h"
1465         ])
1466
1467 fi
1468 if test "x$with_libiptc" = "xyes" && test "x$with_own_libiptc" = "xno"
1469 then
1470         AC_CHECK_HEADERS(libiptc/libiptc.h,
1471         [
1472                 AC_DEFINE(HAVE_LIBIPTC_LIBIPTC_H, 1, [Define to 1 if you have the <libiptc/libiptc.h> header file.])
1473         ],
1474         [
1475                 with_libiptc="yes"
1476                 with_own_libiptc="yes"
1477         ])
1478 fi
1479 if test "x$with_libiptc" = "xyes" && test "x$with_own_libiptc" = "xno"
1480 then
1481         AC_CHECK_TYPES([iptc_handle_t, ip6tc_handle_t], [], [],
1482         [
1483 #if OWN_LIBIPTC
1484 # include "$srcdir/src/owniptc/libiptc.h"
1485 # include "$srcdir/src/owniptc/libip6tc.h"
1486 #else
1487 # include <libiptc/libiptc.h>
1488 # include <libiptc/libip6tc.h>
1489 #endif
1490         ])
1491 fi
1492 if test "x$with_libiptc" = "xyes" && test "x$with_own_libiptc" = "xno"
1493 then
1494         AC_CHECK_LIB(iptc, iptc_init,
1495         [
1496                 AC_DEFINE(HAVE_LIBIPTC, 1, [Define to 1 if you have the iptc library (-liptc).])
1497         ],
1498         [
1499                 with_libiptc="yes"
1500                 with_own_libiptc="yes"
1501         ])
1502 fi
1503 AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
1504 AM_CONDITIONAL(BUILD_WITH_OWN_LIBIPTC, test "x$with_own_libiptc" = "xyes")
1505 if test "x$with_libiptc" = "xyes"
1506 then
1507         BUILD_WITH_LIBIPTC_CPPFLAGS="$LIBIPTC_CPPFLAGS"
1508         BUILD_WITH_LIBIPTC_LDFLAGS="$LIBIPTC_LDFLAGS"
1509         AC_SUBST(BUILD_WITH_LIBIPTC_CPPFLAGS)
1510         AC_SUBST(BUILD_WITH_LIBIPTC_LDFLAGS)
1511 fi
1512 if test "x$with_own_libiptc" = "xyes"
1513 then
1514         AC_DEFINE(OWN_LIBIPTC, 1, [Define to 1 if we use the shipped iptc library.])
1515 fi
1516 CPPFLAGS="$SAVE_CPPFLAGS"
1517 LDFLAGS="$SAVE_LDFLAGS"
1518 # }}}
1519
1520 # --with-java {{{
1521 with_java_home="$JAVA_HOME"
1522 with_java_vmtype="client"
1523 with_java_cflags=""
1524 with_java_libs=""
1525 JAVAC="$JAVAC"
1526 AC_ARG_WITH(java, [AS_HELP_STRING([--with-java@<:@=PREFIX@:>@], [Path to Java home.])],
1527 [
1528         if test "x$withval" = "xno"
1529         then
1530                 with_java="no"
1531         else if test "x$withval" = "xyes"
1532         then
1533                 with_java="yes"
1534         else
1535                 with_java_home="$withval"
1536                 with_java="yes"
1537         fi; fi
1538 ],
1539 [with_java="yes"])
1540 if test "x$with_java" = "xyes"
1541 then
1542         if test -d "$with_java_home"
1543         then
1544                 AC_MSG_CHECKING([for jni.h])
1545                 TMPDIR=`find -L "$with_java_home" -name jni.h -type f -exec 'dirname' '{}' ';' | head -n 1`
1546                 if test "x$TMPDIR" != "x"
1547                 then
1548                         AC_MSG_RESULT([found in $TMPDIR])
1549                         JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPDIR"
1550                 else
1551                         AC_MSG_RESULT([not found])
1552                 fi
1553
1554                 AC_MSG_CHECKING([for jni_md.h])
1555                 TMPDIR=`find -L "$with_java_home" -name jni_md.h -type f -exec 'dirname' '{}' ';' | head -n 1`
1556                 if test "x$TMPDIR" != "x"
1557                 then
1558                         AC_MSG_RESULT([found in $TMPDIR])
1559                         JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPDIR"
1560                 else
1561                         AC_MSG_RESULT([not found])
1562                 fi
1563
1564                 AC_MSG_CHECKING([for libjvm.so])
1565                 TMPDIR=`find -L "$with_java_home" -name libjvm.so -type f -exec 'dirname' '{}' ';' | head -n 1`
1566                 if test "x$TMPDIR" != "x"
1567                 then
1568                         AC_MSG_RESULT([found in $TMPDIR])
1569                         JAVA_LDFLAGS="$JAVA_LDFLAGS -L$TMPDIR -Wl,-rpath -Wl,$TMPDIR"
1570                 else
1571                         AC_MSG_RESULT([not found])
1572                 fi
1573
1574                 if test "x$JAVAC" = "x"
1575                 then
1576                         AC_MSG_CHECKING([for javac])
1577                         TMPDIR=`find -L "$with_java_home" -name javac -type f | head -n 1`
1578                         if test "x$TMPDIR" != "x"
1579                         then
1580                                 JAVAC="$TMPDIR"
1581                                 AC_MSG_RESULT([$JAVAC])
1582                         else
1583                                 AC_MSG_RESULT([not found])
1584                         fi
1585                 fi
1586         else if test "x$with_java_home" != "x"
1587         then
1588                 AC_MSG_WARN([JAVA_HOME: No such directory: $with_java_home])
1589         fi; fi
1590 fi
1591
1592 if test "x$JAVA_CPPFLAGS" != "x"
1593 then
1594         AC_MSG_NOTICE([Building with JAVA_CPPFLAGS set to: $JAVA_CPPFLAGS])
1595 fi
1596 if test "x$JAVA_CFLAGS" != "x"
1597 then
1598         AC_MSG_NOTICE([Building with JAVA_CFLAGS set to: $JAVA_CFLAGS])
1599 fi
1600 if test "x$JAVA_LDFLAGS" != "x"
1601 then
1602         AC_MSG_NOTICE([Building with JAVA_LDFLAGS set to: $JAVA_LDFLAGS])
1603 fi
1604 if test "x$JAVAC" = "x"
1605 then
1606         with_javac_path="$PATH"
1607         if test "x$with_java_home" != "x"
1608         then
1609                 with_javac_path="$with_java_home:with_javac_path"
1610                 if test -d "$with_java_home/bin"
1611                 then
1612                         with_javac_path="$with_java_home/bin:with_javac_path"
1613                 fi
1614         fi
1615
1616         AC_PATH_PROG(JAVAC, javac, [], "$with_javac_path")
1617 fi
1618 if test "x$JAVAC" = "x"
1619 then
1620         with_java="no (javac not found)"
1621 fi
1622
1623 SAVE_CPPFLAGS="$CPPFLAGS"
1624 SAVE_CFLAGS="$CFLAGS"
1625 SAVE_LDFLAGS="$LDFLAGS"
1626 CPPFLAGS="$CPPFLAGS $JAVA_CPPFLAGS"
1627 CFLAGS="$CFLAGS $JAVA_CFLAGS"
1628 LDFLAGS="$LDFLAGS $JAVA_LDFLAGS"
1629
1630 if test "x$with_java" = "xyes"
1631 then
1632         AC_CHECK_HEADERS(jni.h, [], [with_java="no (jni.h not found)"])
1633 fi
1634 if test "x$with_java" = "xyes"
1635 then
1636         AC_CHECK_LIB(jvm, JNI_CreateJavaVM,
1637         [with_java="yes"],
1638         [with_java="no (libjvm not found)"],
1639         [$JAVA_LIBS])
1640 fi
1641 if test "x$with_java" = "xyes"
1642 then
1643         JAVA_LIBS="$JAVA_LIBS -ljvm"
1644         AC_MSG_NOTICE([Building with JAVA_LIBS set to: $JAVA_LIBS])
1645 fi
1646
1647 CPPFLAGS="$SAVE_CPPFLAGS"
1648 CFLAGS="$SAVE_CFLAGS"
1649 LDFLAGS="$SAVE_LDFLAGS"
1650
1651 AC_SUBST(JAVA_CPPFLAGS)
1652 AC_SUBST(JAVA_CFLAGS)
1653 AC_SUBST(JAVA_LDFLAGS)
1654 AC_SUBST(JAVA_LIBS)
1655 AM_CONDITIONAL(BUILD_WITH_JAVA, test "x$with_java" = "xyes")
1656 # }}}
1657
1658 # --with-libmemcached {{{
1659 with_libmemcached_cppflags=""
1660 with_libmemcached_ldflags=""
1661 AC_ARG_WITH(libmemcached, [AS_HELP_STRING([--with-libmemcached@<:@=PREFIX@:>@], [Path to libmemcached.])],
1662 [
1663         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1664         then
1665                 with_libmemcached_cppflags="-I$withval/include"
1666                 with_libmemcached_ldflags="-L$withval/lib"
1667                 with_libmemcached="yes"
1668         else
1669                 with_libmemcached="$withval"
1670         fi
1671 ],
1672 [
1673         with_libmemcached="yes"
1674 ])
1675 if test "x$with_libmemcached" = "xyes"
1676 then
1677         SAVE_CPPFLAGS="$CPPFLAGS"
1678         CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
1679
1680         AC_CHECK_HEADERS(libmemcached/memcached.h, [with_libmemcached="yes"], [with_libmemcached="no (libmemcached/memcached.h not found)"])
1681
1682         CPPFLAGS="$SAVE_CPPFLAGS"
1683 fi
1684 if test "x$with_libmemcached" = "xyes"
1685 then
1686         SAVE_CPPFLAGS="$CPPFLAGS"
1687         SAVE_LDFLAGS="$LDFLAGS"
1688         CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
1689         LDFLAGS="$LDFLAGS $with_libmemcached_ldflags"
1690
1691         AC_CHECK_LIB(memcached, memcached_create, [with_libmemcached="yes"], [with_libmemcached="no (Symbol 'memcached_create' not found)"])
1692
1693         CPPFLAGS="$SAVE_CPPFLAGS"
1694         LDFLAGS="$SAVE_LDFLAGS"
1695 fi
1696 if test "x$with_libmemcached" = "xyes"
1697 then
1698         BUILD_WITH_LIBMEMCACHED_CPPFLAGS="$with_libmemcached_cppflags"
1699         BUILD_WITH_LIBMEMCACHED_LDFLAGS="$with_libmemcached_ldflags"
1700         BUILD_WITH_LIBMEMCACHED_LIBS="-lmemcached"
1701         AC_SUBST(BUILD_WITH_LIBMEMCACHED_CPPFLAGS)
1702         AC_SUBST(BUILD_WITH_LIBMEMCACHED_LDFLAGS)
1703         AC_SUBST(BUILD_WITH_LIBMEMCACHED_LIBS)
1704         AC_DEFINE(HAVE_LIBMEMCACHED, 1, [Define if libmemcached is present and usable.])
1705 fi
1706 AM_CONDITIONAL(BUILD_WITH_LIBMEMCACHED, test "x$with_libmemcached" = "xyes")
1707 # }}}
1708
1709 # --with-libmysql {{{
1710 with_mysql_config="mysql_config"
1711 with_mysql_cflags=""
1712 with_mysql_libs=""
1713 AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
1714 [
1715         if test "x$withval" = "xno"
1716         then
1717                 with_libmysql="no"
1718         else if test "x$withval" = "xyes"
1719         then
1720                 with_libmysql="yes"
1721         else
1722                 if test -f "$withval" && test -x "$withval";
1723                 then
1724                         with_mysql_config="$withval"
1725                 else if test -x "$withval/bin/mysql_config"
1726                 then
1727                         with_mysql_config="$withval/bin/mysql_config"
1728                 fi; fi
1729                 with_libmysql="yes"
1730         fi; fi
1731 ],
1732 [
1733         with_libmysql="yes"
1734 ])
1735 if test "x$with_libmysql" = "xyes"
1736 then
1737         with_mysql_cflags=`$with_mysql_config --cflags 2>/dev/null`
1738         mysql_config_status=$?
1739
1740         if test $mysql_config_status -ne 0
1741         then
1742                 with_libmysql="no ($with_mysql_config failed)"
1743         else
1744                 SAVE_CPPFLAGS="$CPPFLAGS"
1745                 CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
1746
1747                 have_mysql_h="no"
1748                 have_mysql_mysql_h="no"
1749                 AC_CHECK_HEADERS(mysql.h, [have_mysql_h="yes"])
1750
1751                 if test "x$have_mysql_h" = "xno"
1752                 then
1753                         AC_CHECK_HEADERS(mysql/mysql.h, [have_mysql_mysql_h="yes"])
1754                 fi
1755
1756                 if test "x$have_mysql_h$have_mysql_mysql_h" = "xnono"
1757                 then
1758                         with_libmysql="no (mysql.h not found)"
1759                 fi
1760
1761                 CPPFLAGS="$SAVE_CPPFLAGS"
1762         fi
1763 fi
1764 if test "x$with_libmysql" = "xyes"
1765 then
1766         with_mysql_libs=`$with_mysql_config --libs 2>/dev/null`
1767         mysql_config_status=$?
1768
1769         if test $mysql_config_status -ne 0
1770         then
1771                 with_libmysql="no ($with_mysql_config failed)"
1772         else
1773                 AC_CHECK_LIB(mysqlclient, mysql_init,
1774                  [with_libmysql="yes"],
1775                  [with_libmysql="no (symbol 'mysql_init' not found)"],
1776                  [$with_mysql_libs])
1777
1778                 AC_CHECK_LIB(mysqlclient, mysql_get_server_version,
1779                  [with_libmysql="yes"],
1780                  [with_libmysql="no (symbol 'mysql_get_server_version' not found)"],
1781                  [$with_mysql_libs])
1782         fi
1783 fi
1784 if test "x$with_libmysql" = "xyes"
1785 then
1786         BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
1787         BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
1788         AC_SUBST(BUILD_WITH_LIBMYSQL_CFLAGS)
1789         AC_SUBST(BUILD_WITH_LIBMYSQL_LIBS)
1790 fi
1791 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
1792 # }}}
1793
1794 # --with-libnetlink {{{
1795 with_libnetlink_cflags=""
1796 with_libnetlink_libs="-lnetlink"
1797 AC_ARG_WITH(libnetlink, [AS_HELP_STRING([--with-libnetlink@<:@=PREFIX@:>@], [Path to libnetlink.])],
1798 [
1799  echo "libnetlink: withval = $withval"
1800  if test "x$withval" = "xyes"
1801  then
1802          with_libnetlink="yes"
1803  else if test "x$withval" = "xno"
1804  then
1805          with_libnetlink="no"
1806  else
1807          if test -d "$withval/include"
1808          then
1809                  with_libnetlink_cflags="-I$withval/include"
1810                  with_libnetlink_libs="-L$withval/lib -lnetlink"
1811                  with_libnetlink="yes"
1812          else
1813                  AC_MSG_ERROR("no such directory: $withval/include")
1814          fi
1815  fi; fi
1816 ],
1817 [
1818  if test "x$ac_system" = "xLinux"
1819  then
1820          with_libnetlink="yes"
1821  else
1822          with_libnetlink="no (Linux only library)"
1823  fi
1824 ])
1825 if test "x$with_libnetlink" = "xyes"
1826 then
1827         SAVE_CFLAGS="$CFLAGS"
1828         CFLAGS="$CFLAGS $with_libnetlink_cflags"
1829
1830         with_libnetlink="no (libnetlink.h not found)"
1831
1832         AC_CHECK_HEADERS(libnetlink.h iproute/libnetlink.h linux/libnetlink.h,
1833         [
1834          with_libnetlink="yes"
1835          break
1836         ], [],
1837 [#include <stdio.h>
1838 #include <sys/types.h>
1839 #include <asm/types.h>
1840 #include <sys/socket.h>
1841 #include <linux/netlink.h>
1842 #include <linux/rtnetlink.h>])
1843         AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
1844 [#include <stdio.h>
1845 #include <sys/types.h>
1846 #include <asm/types.h>
1847 #include <sys/socket.h>])
1848
1849         AC_COMPILE_IFELSE(
1850 [#include <stdio.h>
1851 #include <sys/types.h>
1852 #include <asm/types.h>
1853 #include <sys/socket.h>
1854 #include <linux/netlink.h>
1855 #include <linux/rtnetlink.h>
1856
1857 int main (void)
1858 {
1859         int retval = TCA_STATS2;
1860         return (retval);
1861 }],
1862         [AC_DEFINE([HAVE_TCA_STATS2], 1, [True if the enum-member TCA_STATS2 exists])]
1863         []);
1864
1865         AC_COMPILE_IFELSE(
1866 [#include <stdio.h>
1867 #include <sys/types.h>
1868 #include <asm/types.h>
1869 #include <sys/socket.h>
1870 #include <linux/netlink.h>
1871 #include <linux/rtnetlink.h>
1872
1873 int main (void)
1874 {
1875         int retval = TCA_STATS;
1876         return (retval);
1877 }],
1878         [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
1879         []);
1880
1881         CFLAGS="$SAVE_CFLAGS"
1882 fi
1883 if test "x$with_libnetlink" = "xyes"
1884 then
1885         AC_CHECK_LIB(netlink, rtnl_open,
1886                      [with_libnetlink="yes"],
1887                      [with_libnetlink="no (symbol 'rtnl_open' not found)"],
1888                      [$with_libnetlink_libs])
1889 fi
1890 if test "x$with_libnetlink" = "xyes"
1891 then
1892         BUILD_WITH_LIBNETLINK_CFLAGS="$with_libnetlink_cflags"
1893         BUILD_WITH_LIBNETLINK_LIBS="$with_libnetlink_libs"
1894         AC_SUBST(BUILD_WITH_LIBNETLINK_CFLAGS)
1895         AC_SUBST(BUILD_WITH_LIBNETLINK_LIBS)
1896 fi
1897 AM_CONDITIONAL(BUILD_WITH_LIBNETLINK, test "x$with_libnetlink" = "xyes")
1898 # }}}
1899
1900 # --with-libnetsnmp {{{
1901 with_snmp_config="net-snmp-config"
1902 with_snmp_cflags=""
1903 with_snmp_libs=""
1904 AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
1905 [
1906         if test "x$withval" = "xno"
1907         then
1908                 with_libnetsnmp="no"
1909         else if test "x$withval" = "xyes"
1910         then
1911                 with_libnetsnmp="yes"
1912         else
1913                 if test -x "$withval"
1914                 then
1915                         with_snmp_config="$withval"
1916                         with_libnetsnmp="yes"
1917                 else
1918                         with_snmp_config="$withval/bin/net-snmp-config"
1919                         with_libnetsnmp="yes"
1920                 fi
1921         fi; fi
1922 ],
1923 [with_libnetsnmp="yes"])
1924 if test "x$with_libnetsnmp" = "xyes"
1925 then
1926         with_snmp_cflags=`$with_snmp_config --cflags 2>/dev/null`
1927         snmp_config_status=$?
1928
1929         if test $snmp_config_status -ne 0
1930         then
1931                 with_libnetsnmp="no ($with_snmp_config failed)"
1932         else
1933                 SAVE_CPPFLAGS="$CPPFLAGS"
1934                 CPPFLAGS="$CPPFLAGS $with_snmp_cflags"
1935                 
1936                 AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
1937
1938                 CPPFLAGS="$SAVE_CPPFLAGS"
1939         fi
1940 fi
1941 if test "x$with_libnetsnmp" = "xyes"
1942 then
1943         with_snmp_libs=`$with_snmp_config --libs 2>/dev/null`
1944         snmp_config_status=$?
1945
1946         if test $snmp_config_status -ne 0
1947         then
1948                 with_libnetsnmp="no ($with_snmp_config failed)"
1949         else
1950                 AC_CHECK_LIB(netsnmp, init_snmp,
1951                 [with_libnetsnmp="yes"],
1952                 [with_libnetsnmp="no (libnetsnmp not found)"],
1953                 [$with_snmp_libs])
1954         fi
1955 fi
1956 if test "x$with_libnetsnmp" = "xyes"
1957 then
1958         BUILD_WITH_LIBSNMP_CFLAGS="$with_snmp_cflags"
1959         BUILD_WITH_LIBSNMP_LIBS="$with_snmp_libs"
1960         AC_SUBST(BUILD_WITH_LIBSNMP_CFLAGS)
1961         AC_SUBST(BUILD_WITH_LIBSNMP_LIBS)
1962 fi
1963 AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")
1964 # }}}
1965
1966 # --with-liboconfig {{{
1967 with_own_liboconfig="no"
1968 liboconfig_LDFLAGS="$LDFLAGS"
1969 liboconfig_CPPFLAGS="$CPPFLAGS"
1970 AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
1971 [
1972         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1973         then
1974                 if test -d "$withval/lib"
1975                 then
1976                         liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
1977                 fi
1978                 if test -d "$withval/include"
1979                 then
1980                         liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
1981                 fi
1982         fi
1983         if test "x$withval" = "xno"
1984         then
1985                 AC_MSG_ERROR("liboconfig is required")
1986         fi
1987 ],
1988 [
1989         with_liboconfig="yes"
1990 ])
1991
1992 save_LDFLAGS="$LDFLAGS"
1993 save_CPPFLAGS="$CPPFLAGS"
1994 LDFLAGS="$liboconfig_LDFLAGS"
1995 CPPFLAGS="$liboconfig_CPPFLAGS"
1996 AC_CHECK_LIB(oconfig, oconfig_parse_fh,
1997 [
1998         with_liboconfig="yes"
1999         with_own_liboconfig="no"
2000 ],
2001 [
2002         with_liboconfig="yes"
2003         with_own_liboconfig="yes"
2004         LDFLAGS="$save_LDFLAGS"
2005         CPPFLAGS="$save_CPPFLAGS"
2006 ])
2007
2008 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
2009 if test "x$with_own_liboconfig" = "xyes"
2010 then
2011         with_liboconfig="yes (shipped version)"
2012 fi
2013 # }}}
2014
2015 # --with-liboping {{{
2016 AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
2017 [
2018  if test "x$withval" = "xyes"
2019  then
2020          with_liboping="yes"
2021  else if test "x$withval" = "xno"
2022  then
2023          with_liboping="no"
2024  else
2025          with_liboping="yes"
2026          LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS -I$withval/include"
2027          LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS -L$withval/lib"
2028  fi; fi
2029 ],
2030 [with_liboping="yes"])
2031
2032 SAVE_CPPFLAGS="$CPPFLAGS"
2033 SAVE_LDFLAGS="$LDFLAGS"
2034
2035 CPPFLAGS="$CPPFLAGS $LIBOPING_CPPFLAGS"
2036 LDFLAGS="$LDFLAGS $LIBOPING_LDFLAGS"
2037
2038 if test "x$with_liboping" = "xyes"
2039 then
2040         if test "x$LIBOPING_CPPFLAGS" != "x"
2041         then
2042                 AC_MSG_NOTICE([liboping CPPFLAGS: $LIBOPING_CPPFLAGS])
2043         fi
2044         AC_CHECK_HEADERS(oping.h,
2045         [with_liboping="yes"],
2046         [with_liboping="no ('oping.h' not found)"])
2047 fi
2048 if test "x$with_liboping" = "xyes"
2049 then
2050         if test "x$LIBOPING_LDFLAGS" != "x"
2051         then
2052                 AC_MSG_NOTICE([liboping LDFLAGS: $LIBOPING_LDFLAGS])
2053         fi
2054         AC_CHECK_LIB(oping, ping_construct,
2055         [with_liboping="yes"],
2056         [with_liboping="no (symbol 'ping_construct' not found)"])
2057 fi
2058
2059 CPPFLAGS="$SAVE_CPPFLAGS"
2060 LDFLAGS="$SAVE_LDFLAGS"
2061
2062 if test "x$with_liboping" = "xyes"
2063 then
2064         BUILD_WITH_LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS"
2065         BUILD_WITH_LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS"
2066         AC_SUBST(BUILD_WITH_LIBOPING_CPPFLAGS)
2067         AC_SUBST(BUILD_WITH_LIBOPING_LDFLAGS)
2068 fi
2069 AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
2070 # }}}
2071
2072 # --with-oracle {{{
2073 with_oracle_cppflags=""
2074 with_oracle_libs=""
2075 AC_ARG_WITH(oracle, [AS_HELP_STRING([--with-oracle@<:@=ORACLE_HOME@:>@], [Path to Oracle.])],
2076 [
2077         if test "x$withval" = "xyes"
2078         then
2079                 if test "x$ORACLE_HOME" = "x"
2080                 then
2081                         AC_MSG_WARN([Use of the Oracle library has been forced, but the environment variable ORACLE_HOME is not set.])
2082                 fi
2083                 with_oracle="yes"
2084         else if test "x$withval" = "xno"
2085         then
2086                 with_oracle="no"
2087         else
2088                 with_oracle="yes"
2089                 ORACLE_HOME="$withval"
2090         fi; fi
2091 ],
2092 [
2093         if test "x$ORACLE_HOME" = "x"
2094         then
2095                 with_oracle="no (ORACLE_HOME is not set)"
2096         else
2097                 with_oracle="yes"
2098         fi
2099 ])
2100 if test "x$ORACLE_HOME" != "x"
2101 then
2102         with_oracle_cppflags="-I$ORACLE_HOME/rdbms/public"
2103
2104         if test -e "$ORACLE_HOME/lib/ldflags"
2105         then
2106                 with_oracle_libs=`cat "$ORACLE_HOME/lib/ldflags"`
2107         fi
2108         #with_oracle_libs="-L$ORACLE_HOME/lib $with_oracle_libs -lclntsh"
2109         with_oracle_libs="-L$ORACLE_HOME/lib -lclntsh"
2110 fi
2111 if test "x$with_oracle" = "xyes"
2112 then
2113         SAVE_CPPFLAGS="$CPPFLAGS"
2114         CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
2115
2116         AC_CHECK_HEADERS(oci.h, [with_oracle="yes"], [with_oracle="no (oci.h not found)"])
2117
2118         CPPFLAGS="$SAVE_CPPFLAGS"
2119 fi
2120 if test "x$with_oracle" = "xyes"
2121 then
2122         SAVE_CPPFLAGS="$CPPFLAGS"
2123         SAVE_LDFLAGS="$LDFLAGS"
2124         CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
2125         LDFLAGS="$LDFLAGS $with_oracle_libs"
2126
2127         AC_CHECK_FUNC(OCIEnvCreate, [with_oracle="yes"], [with_oracle="no (Symbol 'OCIEnvCreate' not found)"])
2128
2129         CPPFLAGS="$SAVE_CPPFLAGS"
2130         LDFLAGS="$SAVE_LDFLAGS"
2131 fi
2132 if test "x$with_oracle" = "xyes"
2133 then
2134         BUILD_WITH_ORACLE_CFLAGS="$with_oracle_cppflags"
2135         BUILD_WITH_ORACLE_LIBS="$with_oracle_libs"
2136         AC_SUBST(BUILD_WITH_ORACLE_CFLAGS)
2137         AC_SUBST(BUILD_WITH_ORACLE_LIBS)
2138 fi
2139 # }}}
2140
2141 # --with-libowcapi {{{
2142 with_libowcapi_cppflags=""
2143 with_libowcapi_libs="-lowcapi"
2144 AC_ARG_WITH(libowcapi, [AS_HELP_STRING([--with-libowcapi@<:@=PREFIX@:>@], [Path to libowcapi.])],
2145 [
2146         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2147         then
2148                 with_libowcapi_cppflags="-I$withval/include"
2149                 with_libowcapi_libs="-L$withval/lib -lowcapi"
2150                 with_libowcapi="yes"
2151         else
2152                 with_libowcapi="$withval"
2153         fi
2154 ],
2155 [
2156         with_libowcapi="yes"
2157 ])
2158 if test "x$with_libowcapi" = "xyes"
2159 then
2160         SAVE_CPPFLAGS="$CPPFLAGS"
2161         CPPFLAGS="$with_libowcapi_cppflags"
2162         
2163         AC_CHECK_HEADERS(owcapi.h, [with_libowcapi="yes"], [with_libowcapi="no (owcapi.h not found)"])
2164
2165         CPPFLAGS="$SAVE_CPPFLAGS"
2166 fi
2167 if test "x$with_libowcapi" = "xyes"
2168 then
2169         SAVE_LDFLAGS="$LDFLAGS"
2170         SAVE_CPPFLAGS="$CPPFLAGS"
2171         LDFLAGS="$with_libowcapi_libs"
2172         CPPFLAGS="$with_libowcapi_cppflags"
2173         
2174         AC_CHECK_LIB(owcapi, OW_get, [with_libowcapi="yes"], [with_libowcapi="no (libowcapi not found)"])
2175
2176         LDFLAGS="$SAVE_LDFLAGS"
2177         CPPFLAGS="$SAVE_CPPFLAGS"
2178 fi
2179 if test "x$with_libowcapi" = "xyes"
2180 then
2181         BUILD_WITH_LIBOWCAPI_CPPFLAGS="$with_libowcapi_cppflags"
2182         BUILD_WITH_LIBOWCAPI_LIBS="$with_libowcapi_libs"
2183         AC_SUBST(BUILD_WITH_LIBOWCAPI_CPPFLAGS)
2184         AC_SUBST(BUILD_WITH_LIBOWCAPI_LIBS)
2185 fi
2186 # }}}
2187
2188 # --with-libpcap {{{
2189 AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
2190 [
2191         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2192         then
2193                 LDFLAGS="$LDFLAGS -L$withval/lib"
2194                 CPPFLAGS="$CPPFLAGS -I$withval/include"
2195                 with_libpcap="yes"
2196         else
2197                 with_libpcap="$withval"
2198         fi
2199 ],
2200 [
2201         with_libpcap="yes"
2202 ])
2203 if test "x$with_libpcap" = "xyes"
2204 then
2205         AC_CHECK_LIB(pcap, pcap_open_live,
2206         [
2207                 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
2208         ], [with_libpcap="no (libpcap not found)"])
2209 fi
2210 if test "x$with_libpcap" = "xyes"
2211 then
2212         AC_CHECK_HEADERS(pcap.h,
2213         [
2214                 AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
2215         ], [with_libpcap="no (pcap.h not found)"])
2216 fi
2217 if test "x$with_libpcap" = "xyes"
2218 then
2219         collect_libpcap=1
2220 else
2221         collect_libpcap=0
2222 fi
2223 AC_DEFINE_UNQUOTED(COLLECT_LIBPCAP, [$collect_libpcap],
2224         [Wether or not to use the pcap library])
2225 AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
2226 # }}}
2227
2228 # --with-libperl {{{
2229 perl_interpreter="perl"
2230 AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
2231 [
2232         if test -x "$withval"
2233         then
2234                 perl_interpreter="$withval"
2235                 with_libperl="yes"
2236         else if test "x$withval" != "xno" && test "x$withval" != "xyes"
2237         then
2238                 LDFLAGS="$LDFLAGS -L$withval/lib"
2239                 CPPFLAGS="$CPPFLAGS -I$withval/include"
2240                 perl_interpreter="$withval/bin/perl"
2241                 with_libperl="yes"
2242         else
2243                 with_libperl="$withval"
2244         fi; fi
2245 ],
2246 [
2247         with_libperl="yes"
2248 ])
2249
2250 AC_MSG_CHECKING([for perl])
2251 perl_interpreter=`which "$perl_interpreter" 2> /dev/null`
2252 if test -x "$perl_interpreter"
2253 then
2254         AC_MSG_RESULT([yes ($perl_interpreter)])
2255 else
2256         perl_interpreter=""
2257         AC_MSG_RESULT([no])
2258 fi
2259
2260 AC_SUBST(PERL, "$perl_interpreter")
2261
2262 if test "x$with_libperl" = "xyes" \
2263         && test -n "$perl_interpreter"
2264 then
2265   SAVE_CFLAGS="$CFLAGS"
2266   SAVE_LDFLAGS="$LDFLAGS"
2267 dnl ARCHFLAGS="" -> disable multi -arch on OSX (see Config_heavy.pl:fetch_string)
2268   PERL_CFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ccopts`
2269   PERL_LDFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ldopts`
2270   CFLAGS="$CFLAGS $PERL_CFLAGS"
2271   LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
2272
2273   AC_CACHE_CHECK([for libperl],
2274     [c_cv_have_libperl],
2275     AC_LINK_IFELSE(
2276       AC_LANG_PROGRAM(
2277       [[
2278 #define PERL_NO_GET_CONTEXT
2279 #include <EXTERN.h>
2280 #include <perl.h>
2281 #include <XSUB.h>
2282       ]],
2283       [[
2284        dTHX;
2285        load_module (PERL_LOADMOD_NOIMPORT,
2286                          newSVpv ("Collectd::Plugin::FooBar", 24),
2287                          Nullsv);
2288       ]]),
2289       [c_cv_have_libperl="yes"],
2290       [c_cv_have_libperl="no"]
2291     )
2292   )
2293
2294   if test "x$c_cv_have_libperl" = "xyes"
2295   then
2296           AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
2297           AC_SUBST(PERL_CFLAGS)
2298           AC_SUBST(PERL_LDFLAGS)
2299   else
2300           with_libperl="no"
2301   fi
2302
2303   CFLAGS="$SAVE_CFLAGS"
2304   LDFLAGS="$SAVE_LDFLAGS"
2305 else if test -z "$perl_interpreter"; then
2306   with_libperl="no (no perl interpreter found)"
2307   c_cv_have_libperl="no"
2308 fi; fi
2309 AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")
2310
2311 if test "x$with_libperl" = "xyes"
2312 then
2313         SAVE_CFLAGS="$CFLAGS"
2314         SAVE_LDFLAGS="$LDFLAGS"
2315         CFLAGS="$CFLAGS $PERL_CFLAGS"
2316         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
2317
2318         AC_CACHE_CHECK([if perl supports ithreads],
2319                 [c_cv_have_perl_ithreads],
2320                 AC_LINK_IFELSE(
2321                         AC_LANG_PROGRAM(
2322                         [[
2323 #include <EXTERN.h>
2324 #include <perl.h>
2325 #include <XSUB.h>
2326
2327 #if !defined(USE_ITHREADS)
2328 # error "Perl does not support ithreads!"
2329 #endif /* !defined(USE_ITHREADS) */
2330                         ]],
2331                         [[ ]]),
2332                         [c_cv_have_perl_ithreads="yes"],
2333                         [c_cv_have_perl_ithreads="no"]
2334                 )
2335         )
2336
2337         if test "x$c_cv_have_perl_ithreads" = "xyes"
2338         then
2339                 AC_DEFINE(HAVE_PERL_ITHREADS, 1, [Define if Perl supports ithreads.])
2340         fi
2341
2342         CFLAGS="$SAVE_CFLAGS"
2343         LDFLAGS="$SAVE_LDFLAGS"
2344 fi
2345
2346 if test "x$with_libperl" = "xyes"
2347 then
2348         SAVE_CFLAGS="$CFLAGS"
2349         SAVE_LDFLAGS="$LDFLAGS"
2350         # trigger an error if Perl_load_module*() uses __attribute__nonnull__(3)
2351         # (see issues #41 and #42)
2352         CFLAGS="$CFLAGS $PERL_CFLAGS -Wall -Werror"
2353         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
2354
2355         AC_CACHE_CHECK([for broken Perl_load_module()],
2356                 [c_cv_have_broken_perl_load_module],
2357                 AC_LINK_IFELSE(
2358                         AC_LANG_PROGRAM(
2359                         [[
2360 #define PERL_NO_GET_CONTEXT
2361 #include <EXTERN.h>
2362 #include <perl.h>
2363 #include <XSUB.h>
2364                         ]],
2365                         [[
2366                          dTHX;
2367                          load_module (PERL_LOADMOD_NOIMPORT,
2368                              newSVpv ("Collectd::Plugin::FooBar", 24),
2369                              Nullsv);
2370                         ]]),
2371                         [c_cv_have_broken_perl_load_module="no"],
2372                         [c_cv_have_broken_perl_load_module="yes"]
2373                 )
2374         )
2375
2376         CFLAGS="$SAVE_CFLAGS"
2377         LDFLAGS="$SAVE_LDFLAGS"
2378 fi
2379 AM_CONDITIONAL(HAVE_BROKEN_PERL_LOAD_MODULE,
2380                 test "x$c_cv_have_broken_perl_load_module" = "xyes")
2381
2382 if test "x$with_libperl" = "xyes"
2383 then
2384         SAVE_CFLAGS="$CFLAGS"
2385         SAVE_LDFLAGS="$LDFLAGS"
2386         CFLAGS="$CFLAGS $PERL_CFLAGS"
2387         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
2388
2389         AC_CHECK_MEMBER(
2390                 [struct mgvtbl.svt_local],
2391                 [have_struct_mgvtbl_svt_local="yes"],
2392                 [have_struct_mgvtbl_svt_local="no"],
2393                 [
2394 #include <EXTERN.h>
2395 #include <perl.h>
2396 #include <XSUB.h>
2397                 ])
2398
2399         if test "x$have_struct_mgvtbl_svt_local" = "xyes"
2400         then
2401                 AC_DEFINE(HAVE_PERL_STRUCT_MGVTBL_SVT_LOCAL, 1,
2402                                   [Define if Perl's struct mgvtbl has member svt_local.])
2403         fi
2404
2405         CFLAGS="$SAVE_CFLAGS"
2406         LDFLAGS="$SAVE_LDFLAGS"
2407 fi
2408 # }}}
2409
2410 # --with-libpq {{{
2411 with_pg_config="pg_config"
2412 with_libpq_includedir=""
2413 with_libpq_libdir=""
2414 with_libpq_cppflags=""
2415 with_libpq_ldflags=""
2416 AC_ARG_WITH(libpq, [AS_HELP_STRING([--with-libpq@<:@=PREFIX@:>@],
2417         [Path to libpq.])],
2418 [
2419         if test "x$withval" = "xno"
2420         then
2421                 with_libpq="no"
2422         else if test "x$withval" = "xyes"
2423         then
2424                 with_libpq="yes"
2425         else
2426                 if test -f "$withval" && test -x "$withval";
2427                 then
2428                         with_pg_config="$withval"
2429                 else if test -x "$withval/bin/pg_config"
2430                 then
2431                         with_pg_config="$withval/bin/pg_config"
2432                 fi; fi
2433                 with_libpq="yes"
2434         fi; fi
2435 ],
2436 [
2437         with_libpq="yes"
2438 ])
2439 if test "x$with_libpq" = "xyes"
2440 then
2441         with_libpq_includedir=`$with_pg_config --includedir 2> /dev/null`
2442         pg_config_status=$?
2443
2444         if test $pg_config_status -eq 0
2445         then
2446                 if test -n "$with_libpq_includedir"; then
2447                         for dir in $with_libpq_includedir; do
2448                                 with_libpq_cppflags="$with_libpq_cppflags -I$dir"
2449                         done
2450                 fi
2451         else
2452                 AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
2453         fi
2454
2455         SAVE_CPPFLAGS="$CPPFLAGS"
2456         CPPFLAGS="$CPPFLAGS $with_libpq_cppflags"
2457
2458         AC_CHECK_HEADERS(libpq-fe.h, [],
2459                 [with_libpq="no (libpq-fe.h not found)"], [])
2460
2461         CPPFLAGS="$SAVE_CPPFLAGS"
2462 fi
2463 if test "x$with_libpq" = "xyes"
2464 then
2465         with_libpq_libdir=`$with_pg_config --libdir 2> /dev/null`
2466         pg_config_status=$?
2467
2468         if test $pg_config_status -eq 0
2469         then
2470                 if test -n "$with_libpq_libdir"; then
2471                         for dir in $with_libpq_libdir; do
2472                                 with_libpq_ldflags="$with_libpq_ldflags -L$dir"
2473                         done
2474                 fi
2475         else
2476                 AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
2477         fi
2478
2479         SAVE_LDFLAGS="$LDFLAGS"
2480         LDFLAGS="$LDFLAGS $with_libpq_ldflags"
2481
2482         AC_CHECK_LIB(pq, PQconnectdb,
2483                 [with_libpq="yes"],
2484                 [with_libpq="no (symbol 'PQconnectdb' not found)"])
2485
2486         AC_CHECK_LIB(pq, PQserverVersion,
2487                 [with_libpq="yes"],
2488                 [with_libpq="no (symbol 'PQserverVersion' not found)"])
2489
2490         LDFLAGS="$SAVE_LDFLAGS"
2491 fi
2492 if test "x$with_libpq" = "xyes"
2493 then
2494         BUILD_WITH_LIBPQ_CPPFLAGS="$with_libpq_cppflags"
2495         BUILD_WITH_LIBPQ_LDFLAGS="$with_libpq_ldflags"
2496         AC_SUBST(BUILD_WITH_LIBPQ_CPPFLAGS)
2497         AC_SUBST(BUILD_WITH_LIBPQ_LDFLAGS)
2498 fi
2499 AM_CONDITIONAL(BUILD_WITH_LIBPQ, test "x$with_libpq" = "xyes")
2500 # }}}
2501
2502 # --with-libpthread {{{
2503 AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
2504 [       if test "x$withval" != "xno" \
2505                 && test "x$withval" != "xyes"
2506         then
2507                 LDFLAGS="$LDFLAGS -L$withval/lib"
2508                 CPPFLAGS="$CPPFLAGS -I$withval/include"
2509                 with_libpthread="yes"
2510         else
2511                 if test "x$withval" = "xno"
2512                 then
2513                         with_libpthread="no (disabled)"
2514                 fi
2515         fi
2516 ], [with_libpthread="yes"])
2517 if test "x$with_libpthread" = "xyes"
2518 then
2519         AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
2520 fi
2521
2522 if test "x$with_libpthread" = "xyes"
2523 then
2524         AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
2525 fi
2526 if test "x$with_libpthread" = "xyes"
2527 then
2528         collect_pthread=1
2529 else
2530         collect_pthread=0
2531 fi
2532 AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
2533         [Wether or not to use pthread (POSIX threads) library])
2534 AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
2535 # }}}
2536
2537 # --with-librrd {{{
2538 # AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
2539 librrd_cflags=""
2540 librrd_ldflags=""
2541 librrd_threadsafe="yes"
2542 librrd_rrdc_update="no"
2543 AC_ARG_WITH(librrd, [AS_HELP_STRING([--with-librrd@<:@=PREFIX@:>@], [Path to rrdtool.])],
2544 [       if test "x$withval" != "xno" && test "x$withval" != "xyes"
2545         then
2546                 librrd_cflags="-I$withval/include"
2547                 librrd_ldflags="-L$withval/lib"
2548                 with_librrd="yes"
2549         else
2550                 with_librrd="$withval"
2551         fi
2552 ], [with_librrd="yes"])
2553 if test "x$with_librrd" = "xyes"
2554 then
2555         SAVE_CPPFLAGS="$CPPFLAGS"
2556         SAVE_LDFLAGS="$LDFLAGS"
2557
2558         CPPFLAGS="$CPPFLAGS $librrd_cflags"
2559         LDFLAGS="$LDFLAGS $librrd_ldflags"
2560
2561         AC_CHECK_HEADERS(rrd.h,, [with_librrd="no (rrd.h not found)"])
2562
2563         CPPFLAGS="$SAVE_CPPFLAGS"
2564         LDFLAGS="$SAVE_LDFLAGS"
2565 fi
2566 if test "x$with_librrd" = "xyes"
2567 then
2568         SAVE_CPPFLAGS="$CPPFLAGS"
2569         SAVE_LDFLAGS="$LDFLAGS"
2570
2571         CPPFLAGS="$CPPFLAGS $librrd_cflags"
2572         LDFLAGS="$LDFLAGS $librrd_ldflags"
2573
2574         AC_CHECK_LIB(rrd_th, rrd_update_r,
2575         [with_librrd="yes"
2576          librrd_ldflags="$librrd_ldflags -lrrd_th -lm"
2577         ],
2578         [librrd_threadsafe="no"
2579          AC_CHECK_LIB(rrd, rrd_update,
2580          [with_librrd="yes"
2581           librrd_ldflags="$librrd_ldflags -lrrd -lm"
2582          ],
2583          [with_librrd="no (symbol 'rrd_update' not found)"],
2584          [-lm])
2585         ],
2586         [-lm])
2587
2588         if test "x$librrd_threadsafe" = "xyes"
2589         then
2590                 AC_CHECK_LIB(rrd_th, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
2591         else
2592                 AC_CHECK_LIB(rrd, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
2593         fi
2594
2595         CPPFLAGS="$SAVE_CPPFLAGS"
2596         LDFLAGS="$SAVE_LDFLAGS"
2597 fi
2598 if test "x$with_librrd" = "xyes"
2599 then
2600         BUILD_WITH_LIBRRD_CFLAGS="$librrd_cflags"
2601         BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
2602         AC_SUBST(BUILD_WITH_LIBRRD_CFLAGS)
2603         AC_SUBST(BUILD_WITH_LIBRRD_LDFLAGS)
2604 fi
2605 if test "x$librrd_threadsafe" = "xyes"
2606 then
2607         AC_DEFINE(HAVE_THREADSAFE_LIBRRD, 1, [Define to 1 if you have the threadsafe rrd library (-lrrd_th).])
2608 fi
2609 # }}}
2610
2611 # --with-libsensors {{{
2612 with_sensors_cflags=""
2613 with_sensors_ldflags=""
2614 AC_ARG_WITH(libsensors, [AS_HELP_STRING([--with-libsensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
2615 [
2616         if test "x$withval" = "xno"
2617         then
2618                 with_libsensors="no"
2619         else
2620                 with_libsensors="yes"
2621                 if test "x$withval" != "xyes"
2622                 then
2623                         with_sensors_cflags="-I$withval/include"
2624                         with_sensors_ldflags="-L$withval/lib"
2625                         with_libsensors="yes"
2626                 fi
2627         fi
2628 ],
2629 [
2630         if test "x$ac_system" = "xLinux"
2631         then
2632                 with_libsensors="yes"
2633         else
2634                 with_libsensors="no (Linux only library)"
2635         fi
2636 ])
2637 if test "x$with_libsensors" = "xyes"
2638 then
2639         SAVE_CPPFLAGS="$CPPFLAGS"
2640         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
2641
2642 #       AC_CHECK_HEADERS(sensors/sensors.h,
2643 #       [
2644 #               AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
2645 #       ],
2646 #       [with_libsensors="no (sensors/sensors.h not found)"])
2647         AC_CHECK_HEADERS(sensors/sensors.h, [], [with_libsensors="no (sensors/sensors.h not found)"])
2648
2649         CPPFLAGS="$SAVE_CPPFLAGS"
2650 fi
2651 if test "x$with_libsensors" = "xyes"
2652 then
2653         SAVE_CPPFLAGS="$CPPFLAGS"
2654         SAVE_LDFLAGS="$LDFLAGS"
2655         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
2656         LDFLAGS="$LDFLAGS $with_sensors_ldflags"
2657
2658         AC_CHECK_LIB(sensors, sensors_init,
2659         [
2660                 AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
2661         ],
2662         [with_libsensors="no (libsensors not found)"])
2663
2664         CPPFLAGS="$SAVE_CPPFLAGS"
2665         LDFLAGS="$SAVE_LDFLAGS"
2666 fi
2667 if test "x$with_libsensors" = "xyes"
2668 then
2669         BUILD_WITH_LIBSENSORS_CFLAGS="$with_sensors_cflags"
2670         BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
2671         AC_SUBST(BUILD_WITH_LIBSENSORS_CFLAGS)
2672         AC_SUBST(BUILD_WITH_LIBSENSORS_LDFLAGS)
2673 fi
2674 AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_libsensors" = "xyes")
2675 # }}}
2676
2677 # --with-libstatgrab {{{
2678 with_libstatgrab_cflags=""
2679 with_libstatgrab_ldflags=""
2680 AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
2681 [
2682  if test "x$withval" != "xno" \
2683    && test "x$withval" != "xyes"
2684  then
2685    with_libstatgrab_cflags="-I$withval/include"
2686    with_libstatgrab_ldflags="-L$withval/lib -lstatgrab"
2687    with_libstatgrab="yes"
2688    with_libstatgrab_pkg_config="no"
2689  else
2690    with_libstatgrab="$withval"
2691    with_libstatgrab_pkg_config="yes"
2692  fi
2693  ],
2694 [
2695  with_libstatgrab="yes"
2696  with_libstatgrab_pkg_config="yes"
2697 ])
2698
2699 if test "x$with_libstatgrab" = "xyes" \
2700   && test "x$with_libstatgrab_pkg_config" = "xyes"
2701 then
2702   if test "x$PKG_CONFIG" != "x"
2703   then
2704     AC_MSG_CHECKING([pkg-config for libstatgrab])
2705     temp_result="found"
2706     $PKG_CONFIG --exists libstatgrab 2>/dev/null
2707     if test "$?" != "0"
2708     then
2709       with_libstatgrab_pkg_config="no"
2710       with_libstatgrab="no ($PKG_CONFIG doesn't know libstatgrab)"
2711       temp_result="not found"
2712     fi
2713     AC_MSG_RESULT([$temp_result])
2714   else
2715     AC_MSG_NOTICE([pkg-config not available, trying to guess flags for the statgrab library.])
2716     with_libstatgrab_pkg_config="no"
2717     with_libstatgrab_ldflags="$with_libstatgrab_ldflags -lstatgrab"
2718   fi
2719 fi
2720
2721 if test "x$with_libstatgrab" = "xyes" \
2722   && test "x$with_libstatgrab_pkg_config" = "xyes" \
2723   && test "x$with_libstatgrab_cflags" = "x"
2724 then
2725   AC_MSG_CHECKING([for libstatgrab CFLAGS])
2726   temp_result="`$PKG_CONFIG --cflags libstatgrab`"
2727   if test "$?" = "0"
2728   then
2729     with_libstatgrab_cflags="$temp_result"
2730   else
2731     with_libstatgrab="no ($PKG_CONFIG --cflags libstatgrab failed)"
2732     temp_result="$PKG_CONFIG --cflags libstatgrab failed"
2733   fi
2734   AC_MSG_RESULT([$temp_result])
2735 fi
2736
2737 if test "x$with_libstatgrab" = "xyes" \
2738   && test "x$with_libstatgrab_pkg_config" = "xyes" \
2739   && test "x$with_libstatgrab_ldflags" = "x"
2740 then
2741   AC_MSG_CHECKING([for libstatgrab LDFLAGS])
2742   temp_result="`$PKG_CONFIG --libs libstatgrab`"
2743   if test "$?" = "0"
2744   then
2745     with_libstatgrab_ldflags="$temp_result"
2746   else
2747     with_libstatgrab="no ($PKG_CONFIG --libs libstatgrab failed)"
2748     temp_result="$PKG_CONFIG --libs libstatgrab failed"
2749   fi
2750   AC_MSG_RESULT([$temp_result])
2751 fi
2752
2753 if test "x$with_libstatgrab" = "xyes"
2754 then
2755   SAVE_CPPFLAGS="$CPPFLAGS"
2756   CPPFLAGS="$CPPFLAGS $with_libstatgrab_cflags"
2757
2758   AC_CHECK_HEADERS(statgrab.h,
2759                    [with_libstatgrab="yes"],
2760                    [with_libstatgrab="no (statgrab.h not found)"])
2761
2762   CPPFLAGS="$SAVE_CPPFLAGS"
2763 fi
2764
2765 if test "x$with_libstatgrab" = "xyes"
2766 then
2767   SAVE_CFLAGS="$CFLAGS"
2768   SAVE_LDFLAGS="$LDFLAGS"
2769
2770   CFLAGS="$CFLAGS $with_libstatgrab_cflags"
2771   LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
2772
2773   AC_CHECK_LIB(statgrab, sg_init,
2774                [with_libstatgrab="yes"],
2775                [with_libstatgrab="no (symbol sg_init not found)"])
2776
2777   CFLAGS="$SAVE_CFLAGS"
2778   LDFLAGS="$SAVE_LDFLAGS"
2779 fi
2780
2781 AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
2782 if test "x$with_libstatgrab" = "xyes"
2783 then
2784   AC_DEFINE(HAVE_LIBSTATGRAB, 1, [Define to 1 if you have the 'statgrab' library (-lstatgrab)])
2785   BUILD_WITH_LIBSTATGRAB_CFLAGS="$with_libstatgrab_cflags"
2786   BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
2787   AC_SUBST(BUILD_WITH_LIBSTATGRAB_CFLAGS)
2788   AC_SUBST(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
2789 fi
2790 # }}}
2791
2792 # --with-libupsclient {{{
2793 with_libupsclient_config=""
2794 with_libupsclient_cflags=""
2795 with_libupsclient_libs=""
2796 AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
2797 [
2798         if test "x$withval" = "xno"
2799         then
2800                 with_libupsclient="no"
2801         else if test "x$withval" = "xyes"
2802         then
2803                 with_libupsclient="use_pkgconfig"
2804         else
2805                 if test -x "$withval"
2806                 then
2807                         with_libupsclient_config="$withval"
2808                         with_libupsclient="use_libupsclient_config"
2809                 else if test -x "$withval/bin/libupsclient-config"
2810                 then
2811                         with_libupsclient_config="$withval/bin/net-snmp-config"
2812                         with_libupsclient="use_libupsclient_config"
2813                 else
2814                         AC_MSG_NOTICE([Not checking for libupsclient: Manually configured])
2815                         with_libupsclient_cflags="-I$withval/include"
2816                         with_libupsclient_libs="-L$withval/lib -lupsclient"
2817                         with_libupsclient="yes"
2818                 fi; fi
2819         fi; fi
2820 ],
2821 [with_libupsclient="use_pkgconfig"])
2822
2823 # configure using libupsclient-config
2824 if test "x$with_libupsclient" = "xuse_libupsclient_config"
2825 then
2826         AC_MSG_NOTICE([Checking for libupsclient using $with_libupsclient_config])
2827         with_libupsclient_cflags="`$with_libupsclient_config --cflags`"
2828         if test $? -ne 0
2829         then
2830                 with_libupsclient="no ($with_libupsclient_config failed)"
2831         fi
2832         with_libupsclient_libs="`$with_libupsclient_config --libs`"
2833         if test $? -ne 0
2834         then
2835                 with_libupsclient="no ($with_libupsclient_config failed)"
2836         fi
2837 fi
2838 if test "x$with_libupsclient" = "xuse_libupsclient_config"
2839 then
2840         with_libupsclient="yes"
2841 fi
2842
2843 # configure using pkg-config
2844 if test "x$with_libupsclient" = "xuse_pkgconfig"
2845 then
2846         if test "x$PKG_CONFIG" = "x"
2847         then
2848                 with_libupsclient="no (Don't have pkg-config)"
2849         fi
2850 fi
2851 if test "x$with_libupsclient" = "xuse_pkgconfig"
2852 then
2853         AC_MSG_NOTICE([Checking for libupsclient using $PKG_CONFIG])
2854         $PKG_CONFIG --exists 'libupsclient' 2>/dev/null
2855         if test $? -ne 0
2856         then
2857                 with_libupsclient="no (pkg-config doesn't know library)"
2858         fi
2859 fi
2860 if test "x$with_libupsclient" = "xuse_pkgconfig"
2861 then
2862         with_libupsclient_cflags="`$PKG_CONFIG --cflags 'libupsclient'`"
2863         if test $? -ne 0
2864         then
2865                 with_libupsclient="no ($PKG_CONFIG failed)"
2866         fi
2867         with_libupsclient_libs="`$PKG_CONFIG --libs 'libupsclient'`"
2868         if test $? -ne 0
2869         then
2870                 with_libupsclient="no ($PKG_CONFIG failed)"
2871         fi
2872 fi
2873 if test "x$with_libupsclient" = "xuse_pkgconfig"
2874 then
2875         with_libupsclient="yes"
2876 fi
2877
2878 # with_libupsclient_cflags and with_libupsclient_libs are set up now, let's do
2879 # the actual checks.
2880 if test "x$with_libupsclient" = "xyes"
2881 then
2882         SAVE_CPPFLAGS="$CPPFLAGS"
2883         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
2884
2885         AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])
2886
2887         CPPFLAGS="$SAVE_CPPFLAGS"
2888 fi
2889 if test "x$with_libupsclient" = "xyes"
2890 then
2891         SAVE_CPPFLAGS="$CPPFLAGS"
2892         SAVE_LDFLAGS="$LDFLAGS"
2893
2894         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
2895         LDFLAGS="$LDFLAGS $with_libupsclient_libs"
2896
2897         AC_CHECK_LIB(upsclient, upscli_connect,
2898                      [with_libupsclient="yes"],
2899                      [with_libupsclient="no (symbol upscli_connect not found)"])
2900
2901         CPPFLAGS="$SAVE_CPPFLAGS"
2902         LDFLAGS="$SAVE_LDFLAGS"
2903 fi
2904 if test "x$with_libupsclient" = "xyes"
2905 then
2906         SAVE_CPPFLAGS="$CPPFLAGS"
2907         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
2908
2909         AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [],
2910 [#include <stdlib.h>
2911 #include <stdio.h>
2912 #include <upsclient.h>])
2913
2914         CPPFLAGS="$SAVE_CPPFLAGS"
2915 fi
2916 if test "x$with_libupsclient" = "xyes"
2917 then
2918         BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_libupsclient_cflags"
2919         BUILD_WITH_LIBUPSCLIENT_LIBS="$with_libupsclient_libs"
2920         AC_SUBST(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
2921         AC_SUBST(BUILD_WITH_LIBUPSCLIENT_LIBS)
2922 fi
2923 # }}}
2924
2925 # --with-libxmms {{{
2926 with_xmms_config="xmms-config"
2927 with_xmms_cflags=""
2928 with_xmms_libs=""
2929 AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
2930 [
2931         if test "x$withval" != "xno" \
2932                 && test "x$withval" != "xyes"
2933         then
2934                 if test -f "$withval" && test -x "$withval";
2935                 then
2936                         with_xmms_config="$withval"
2937                 else if test -x "$withval/bin/xmms-config"
2938                 then
2939                         with_xmms_config="$withval/bin/xmms-config"
2940                 fi; fi
2941                 with_libxmms="yes"
2942         else if test "x$withval" = "xno"
2943         then
2944                 with_libxmms="no"
2945         else
2946                 with_libxmms="yes"
2947         fi; fi
2948 ],
2949 [
2950         with_libxmms="yes"
2951 ])
2952 if test "x$with_libxmms" = "xyes"
2953 then
2954         with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
2955         xmms_config_status=$?
2956
2957         if test $xmms_config_status -ne 0
2958         then
2959                 with_libxmms="no"
2960         fi
2961 fi
2962 if test "x$with_libxmms" = "xyes"
2963 then
2964         with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
2965         xmms_config_status=$?
2966
2967         if test $xmms_config_status -ne 0
2968         then
2969                 with_libxmms="no"
2970         fi
2971 fi
2972 if test "x$with_libxmms" = "xyes"
2973 then
2974         AC_CHECK_LIB(xmms, xmms_remote_get_info,
2975         [
2976                 BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
2977                 BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
2978                 AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
2979                 AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
2980         ],
2981         [
2982                 with_libxmms="no"
2983         ],
2984         [$with_xmms_libs])
2985 fi
2986 with_libxmms_numeric=0
2987 if test "x$with_libxmms" = "xyes"
2988 then
2989         with_libxmms_numeric=1
2990 fi
2991 AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
2992 AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
2993 # }}}
2994
2995 # pkg-config --exists 'libxml-2.0'; pkg-config --exists libvirt {{{
2996 with_libxml2="no (pkg-config isn't available)"
2997 with_libxml2_cflags=""
2998 with_libxml2_ldflags=""
2999 with_libvirt="no (pkg-config isn't available)"
3000 with_libvirt_cflags=""
3001 with_libvirt_ldflags=""
3002 if test "x$PKG_CONFIG" != "x"
3003 then
3004         pkg-config --exists 'libxml-2.0' 2>/dev/null
3005         if test "$?" = "0"
3006         then
3007                 with_libxml2="yes"
3008         else
3009                 with_libxml2="no (pkg-config doesn't know library)"
3010         fi
3011
3012         pkg-config --exists libvirt 2>/dev/null
3013         if test "$?" = "0"
3014         then
3015                 with_libvirt="yes"
3016         else
3017                 with_libvirt="no (pkg-config doesn't know library)"
3018         fi
3019 fi
3020 if test "x$with_libxml2" = "xyes"
3021 then
3022         with_libxml2_cflags="`pkg-config --cflags libxml-2.0`"
3023         if test $? -ne 0
3024         then
3025                 with_libxml2="no"
3026         fi
3027         with_libxml2_ldflags="`pkg-config --libs libxml-2.0`"
3028         if test $? -ne 0
3029         then
3030                 with_libxml2="no"
3031         fi
3032 fi
3033 if test "x$with_libxml2" = "xyes"
3034 then
3035         SAVE_CPPFLAGS="$CPPFLAGS"
3036         CPPFLAGS="$CPPFLAGS $with_libxml2_cflags"
3037
3038         AC_CHECK_HEADERS(libxml/parser.h, [],
3039                       [with_libxml2="no (libxml/parser.h not found)"])
3040
3041         CPPFLAGS="$SAVE_CPPFLAGS"
3042 fi
3043 if test "x$with_libxml2" = "xyes"
3044 then
3045         SAVE_CFLAGS="$CFLAGS"
3046         SAVE_LDFLAGS="$LDFLAGS"
3047
3048         CFLAGS="$CFLAGS $with_libxml2_cflags"
3049         LDFLAGS="$LDFLAGS $with_libxml2_ldflags"
3050
3051         AC_CHECK_LIB(xml2, xmlXPathEval,
3052                      [with_libxml2="yes"],
3053                      [with_libxml2="no (symbol xmlXPathEval not found)"])
3054
3055         CFLAGS="$SAVE_CFLAGS"
3056         LDFLAGS="$SAVE_LDFLAGS"
3057 fi
3058 dnl Add the right compiler flags and libraries.
3059 if test "x$with_libxml2" = "xyes"; then
3060         BUILD_WITH_LIBXML2_CFLAGS="$with_libxml2_cflags"
3061         BUILD_WITH_LIBXML2_LIBS="$with_libxml2_ldflags"
3062         AC_SUBST(BUILD_WITH_LIBXML2_CFLAGS)
3063         AC_SUBST(BUILD_WITH_LIBXML2_LIBS)
3064 fi
3065 if test "x$with_libvirt" = "xyes"
3066 then
3067         with_libvirt_cflags="`pkg-config --cflags libvirt`"
3068         if test $? -ne 0
3069         then
3070                 with_libvirt="no"
3071         fi
3072         with_libvirt_ldflags="`pkg-config --libs libvirt`"
3073         if test $? -ne 0
3074         then
3075                 with_libvirt="no"
3076         fi
3077 fi
3078 if test "x$with_libvirt" = "xyes"
3079 then
3080         SAVE_CPPFLAGS="$CPPFLAGS"
3081         CPPFLAGS="$CPPFLAGS $with_libvirt_cflags"
3082
3083         AC_CHECK_HEADERS(libvirt/libvirt.h, [],
3084                       [with_libvirt="no (libvirt/libvirt.h not found)"])
3085
3086         CPPFLAGS="$SAVE_CPPFLAGS"
3087 fi
3088 if test "x$with_libvirt" = "xyes"
3089 then
3090         SAVE_CFLAGS="$CFLAGS"
3091         SAVE_LDFLAGS="$LDFLAGS"
3092
3093         CFLAGS="$CFLAGS $with_libvirt_cflags"
3094         LDFLAGS="$LDFLAGS $with_libvirt_ldflags"
3095
3096         AC_CHECK_LIB(virt, virDomainBlockStats,
3097                      [with_libvirt="yes"],
3098                      [with_libvirt="no (symbol virDomainBlockStats not found)"])
3099
3100         CFLAGS="$SAVE_CFLAGS"
3101         LDFLAGS="$SAVE_LDFLAGS"
3102 fi
3103 dnl Add the right compiler flags and libraries.
3104 if test "x$with_libvirt" = "xyes"; then
3105         BUILD_WITH_LIBVIRT_CFLAGS="$with_libvirt_cflags"
3106         BUILD_WITH_LIBVIRT_LIBS="$with_libvirt_ldflags"
3107         AC_SUBST(BUILD_WITH_LIBVIRT_CFLAGS)
3108         AC_SUBST(BUILD_WITH_LIBVIRT_LIBS)
3109 fi
3110 # }}}
3111
3112 # $PKG_CONFIG --exists OpenIPMIpthread {{{
3113 with_libopenipmipthread="yes"
3114 with_libopenipmipthread_cflags=""
3115 with_libopenipmipthread_libs=""
3116
3117 AC_MSG_CHECKING([for pkg-config])
3118 temp_result="no"
3119 if test "x$PKG_CONFIG" = "x"
3120 then
3121         with_libopenipmipthread="no"
3122         temp_result="no"
3123 else
3124         temp_result="$PKG_CONFIG"
3125 fi
3126 AC_MSG_RESULT([$temp_result])
3127
3128 if test "x$with_libopenipmipthread" = "xyes"
3129 then
3130         AC_MSG_CHECKING([for libOpenIPMIpthread])
3131         $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
3132         if test "$?" != "0"
3133         then
3134                 with_libopenipmipthread="no ($PKG_CONFIG doesn't know OpenIPMIpthread)"
3135         fi
3136         AC_MSG_RESULT([$with_libopenipmipthread])
3137 fi
3138
3139 if test "x$with_libopenipmipthread" = "xyes"
3140 then
3141         AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS])
3142         temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`"
3143         if test "$?" = "0"
3144         then
3145                 with_libopenipmipthread_cflags="$temp_result"
3146         else
3147                 with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)"
3148                 temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed"
3149         fi
3150         AC_MSG_RESULT([$temp_result])
3151 fi
3152
3153 if test "x$with_libopenipmipthread" = "xyes"
3154 then
3155         AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS])
3156         temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`"
3157         if test "$?" = "0"
3158         then
3159                 with_libopenipmipthread_ldflags="$temp_result"
3160         else
3161                 with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)"
3162                 temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed"
3163         fi
3164         AC_MSG_RESULT([$temp_result])
3165 fi
3166
3167 if test "x$with_libopenipmipthread" = "xyes"
3168 then
3169         SAVE_CPPFLAGS="$CPPFLAGS"
3170         CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags"
3171
3172         AC_CHECK_HEADERS(OpenIPMI/ipmi_smi.h,
3173                          [with_libopenipmipthread="yes"],
3174                          [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"],
3175 [#include <OpenIPMI/ipmiif.h>
3176 #include <OpenIPMI/ipmi_err.h>
3177 #include <OpenIPMI/ipmi_posix.h>
3178 #include <OpenIPMI/ipmi_conn.h>
3179 ])
3180
3181         CPPFLAGS="$SAVE_CPPFLAGS"
3182 fi
3183
3184 if test "x$with_libopenipmipthread" = "xyes"
3185 then
3186         BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags"
3187         BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags"
3188         AC_SUBST(BUILD_WITH_OPENIPMI_CFLAGS)
3189         AC_SUBST(BUILD_WITH_OPENIPMI_LIBS)
3190 fi
3191 # }}}
3192
3193 PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
3194                 [with_libnotify="yes"],
3195                 [with_libnotify="no ($LIBNOTIFY_PKG_ERRORS)"])
3196
3197 # Check for enabled/disabled features
3198 #
3199
3200 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
3201 # ------------------------------------------------------------
3202 dnl
3203 m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
3204 dnl
3205 AC_DEFUN(
3206         [AC_COLLECTD],
3207         [
3208         m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
3209         m4_if(
3210                 [$2],
3211                 [enable],
3212                 [dnl
3213                 m4_define([EnDis],[disabled])dnl
3214                 m4_define([YesNo],[no])dnl
3215                 ],dnl
3216                 [m4_if(
3217                         [$2],
3218                         [disable],
3219                         [dnl
3220                         m4_define([EnDis],[enabled])dnl
3221                         m4_define([YesNo],[yes])dnl
3222                         ],
3223                         [dnl
3224                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
3225                         ]dnl
3226                 )]dnl
3227         )dnl
3228         m4_if([$3], [feature], [],
3229                 [m4_if(
3230                         [$3], [module], [],
3231                         [dnl
3232                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
3233                         ]dnl
3234                 )]dnl
3235         )dnl
3236         AC_ARG_ENABLE(
3237                 [$1],
3238                 AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
3239                 [],
3240                 enable_$1='[YesNo]'dnl
3241         )# AC_ARG_ENABLE
3242 if test "x$enable_$1" = "xno"
3243 then
3244         collectd_$1=0
3245 else
3246         if test "x$enable_$1" = "xyes"
3247         then
3248                 collectd_$1=1
3249         else
3250                 AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
3251                 collectd_$1=1
3252                 enable_$1='yes'
3253         fi
3254 fi
3255         AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
3256         AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
3257         ]dnl
3258 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
3259
3260 # AC_PLUGIN(name, default, info)
3261 # ------------------------------------------------------------
3262 dnl
3263 AC_DEFUN(
3264   [AC_PLUGIN],
3265   [
3266     enable_plugin="no"
3267     force="no"
3268     AC_ARG_ENABLE([$1], AC_HELP_STRING([--enable-$1], [$3]),
3269     [
3270      if test "x$enableval" = "xyes"
3271      then
3272              enable_plugin="yes"
3273      else if test "x$enableval" = "xforce"
3274      then
3275              enable_plugin="yes"
3276              force="yes"
3277      else
3278              enable_plugin="no"
3279      fi; fi
3280     ],
3281     [
3282          if test "x$enable_all_plugins" = "xauto"
3283          then
3284              if test "x$2" = "xyes"
3285              then
3286                      enable_plugin="yes"
3287              else
3288                      enable_plugin="no"
3289              fi
3290          else
3291              enable_plugin="$enable_all_plugins"
3292          fi
3293     ])
3294     if test "x$enable_plugin" = "xyes"
3295     then
3296             if test "x$2" = "xyes" || test "x$force" = "xyes"
3297             then
3298                     AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
3299                     if test "x$2" != "xyes"
3300                     then
3301                             dependency_warning="yes"
3302                     fi
3303             else # User passed "yes" but dependency checking yielded "no" => Dependency problem.
3304                     dependency_error="yes"
3305                     enable_plugin="no (dependency error)"
3306             fi
3307     fi
3308     AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), test "x$enable_plugin" = "xyes")
3309     enable_$1="$enable_plugin"
3310   ]
3311 )# AC_PLUGIN(name, default, info)
3312
3313 m4_divert_once([HELP_ENABLE], [
3314 collectd features:])
3315 # FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
3316 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
3317 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
3318 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
3319
3320 dependency_warning="no"
3321 dependency_error="no"
3322
3323 plugin_ascent="no"
3324 plugin_battery="no"
3325 plugin_bind="no"
3326 plugin_conntrack="no"
3327 plugin_cpu="no"
3328 plugin_cpufreq="no"
3329 plugin_df="no"
3330 plugin_disk="no"
3331 plugin_entropy="no"
3332 plugin_interface="no"
3333 plugin_ipmi="no"
3334 plugin_ipvs="no"
3335 plugin_irq="no"
3336 plugin_libvirt="no"
3337 plugin_load="no"
3338 plugin_memory="no"
3339 plugin_multimeter="no"
3340 plugin_nfs="no"
3341 plugin_fscache="no"
3342 plugin_perl="no"
3343 plugin_processes="no"
3344 plugin_protocols="no"
3345 plugin_serial="no"
3346 plugin_swap="no"
3347 plugin_tape="no"
3348 plugin_tcpconns="no"
3349 plugin_ted="no"
3350 plugin_thermal="no"
3351 plugin_users="no"
3352 plugin_uptime="no"
3353 plugin_vmem="no"
3354 plugin_vserver="no"
3355 plugin_wireless="no"
3356
3357 # Linux
3358 if test "x$ac_system" = "xLinux"
3359 then
3360         plugin_battery="yes"
3361         plugin_conntrack="yes"
3362         plugin_cpu="yes"
3363         plugin_cpufreq="yes"
3364         plugin_disk="yes"
3365         plugin_entropy="yes"
3366         plugin_interface="yes"
3367         plugin_irq="yes"
3368         plugin_load="yes"
3369         plugin_memory="yes"
3370         plugin_nfs="yes"
3371         plugin_fscache="yes"
3372         plugin_processes="yes"
3373         plugin_protocols="yes"
3374         plugin_serial="yes"
3375         plugin_swap="yes"
3376         plugin_tcpconns="yes"
3377         plugin_thermal="yes"
3378         plugin_uptime="yes"
3379         plugin_vmem="yes"
3380         plugin_vserver="yes"
3381         plugin_wireless="yes"
3382
3383         if test "x$have_net_ip_vs_h" = "xyes" -o "x$have_ip_vs_h" = "xyes"
3384         then
3385                 plugin_ipvs="yes"
3386         fi
3387 fi
3388
3389 if test "x$ac_system" = "xOpenBSD"
3390 then
3391         plugin_tcpconns="yes"
3392 fi
3393
3394 # Mac OS X devices
3395 if test "x$with_libiokit" = "xyes"
3396 then
3397         plugin_battery="yes"
3398         plugin_disk="yes"
3399 fi
3400
3401 # Solaris
3402 if test "x$with_kstat" = "xyes"
3403 then
3404         plugin_uptime="yes"
3405 fi
3406
3407 if test "x$with_devinfo$with_kstat" = "xyesyes"
3408 then
3409         plugin_cpu="yes"
3410         plugin_disk="yes"
3411         plugin_interface="yes"
3412         plugin_memory="yes"
3413         plugin_tape="yes"
3414 fi
3415
3416 if test "x$have_sys_swap_h$with_kstat$ac_system" = "xyesyesSolaris"
3417 then
3418         plugin_swap="yes"
3419 fi
3420
3421 # libstatgrab
3422 if test "x$with_libstatgrab" = "xyes"
3423 then
3424         plugin_cpu="yes"
3425         plugin_disk="yes"
3426         plugin_interface="yes"
3427         plugin_load="yes"
3428         plugin_memory="yes"
3429         plugin_swap="yes"
3430         plugin_users="yes"
3431 fi
3432
3433 if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
3434 then
3435         plugin_ascent="yes"
3436         plugin_bind="yes"
3437 fi
3438
3439 if test "x$with_libopenipmipthread" = "xyes"
3440 then
3441         plugin_ipmi="yes"
3442 fi
3443
3444 if test "x$have_processor_info" = "xyes"
3445 then
3446         plugin_cpu="yes"
3447 fi
3448 if test "x$have_sysctl" = "xyes"
3449 then
3450         plugin_cpu="yes"
3451         plugin_memory="yes"
3452         plugin_swap="yes"
3453         plugin_uptime="yes"
3454 fi
3455 if test "x$have_sysctlbyname" = "xyes"
3456 then
3457         plugin_cpu="yes"
3458         plugin_memory="yes"
3459         plugin_tcpconns="yes"
3460 fi
3461
3462 # Df plugin: Check if we know how to determine mount points first.
3463 #if test "x$have_listmntent" = "xyes"; then
3464 #       plugin_df="yes"
3465 #fi
3466 if test "x$have_getvfsstat" = "xyes" || test "x$have_getfsstat" = "xyes"
3467 then
3468         plugin_df="yes"
3469 fi
3470 if test "x$c_cv_have_two_getmntent" = "xyes" || test "x$have_getmntent" = "xgen" || test "x$have_getmntent" = "xsun"
3471 then
3472         plugin_df="yes"
3473 fi
3474 #if test "x$have_getmntent" = "xseq"
3475 #then
3476 #       plugin_df="yes"
3477 #fi
3478 if test "x$c_cv_have_one_getmntent" = "xyes"
3479 then
3480         plugin_df="yes"
3481 fi
3482
3483 # Df plugin: Check if we have either `statfs' or `statvfs' second.
3484 if test "x$plugin_df" = "xyes"
3485 then
3486         plugin_df="no"
3487         if test "x$have_statfs" = "xyes"
3488         then
3489                 plugin_df="yes"
3490         fi
3491         if test "x$have_statvfs" = "xyes"
3492         then
3493                 plugin_df="yes"
3494         fi
3495 fi
3496
3497 if test "x$have_getifaddrs" = "xyes"
3498 then
3499         plugin_interface="yes"
3500 fi
3501
3502 if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes"
3503 then
3504         plugin_libvirt="yes"
3505 fi
3506
3507 if test "x$have_getloadavg" = "xyes"
3508 then
3509         plugin_load="yes"
3510 fi
3511
3512 if test "x$c_cv_have_libperl$c_cv_have_perl_ithreads" = "xyesyes"
3513 then
3514         plugin_perl="yes"
3515 fi
3516
3517 # Mac OS X memory interface
3518 if test "x$have_host_statistics" = "xyes"
3519 then
3520         plugin_memory="yes"
3521 fi
3522
3523 if test "x$have_termios_h" = "xyes"
3524 then
3525         plugin_multimeter="yes"
3526         plugin_ted="yes"
3527 fi
3528
3529 if test "x$have_thread_info" = "xyes"
3530 then
3531         plugin_processes="yes"
3532 fi
3533
3534 if test "x$with_kvm_getprocs" = "xyes" && test "x$have_struct_kinfo_proc_freebsd" = "xyes"
3535 then
3536         plugin_processes="yes"
3537 fi
3538
3539 if test "x$with_kvm_getswapinfo" = "xyes"
3540 then
3541         plugin_swap="yes"
3542 fi
3543
3544 if test "x$have_swapctl" = "xyes"
3545 then
3546         plugin_swap="yes"
3547 fi
3548
3549 if test "x$with_kvm_openfiles$with_kvm_nlist" = "xyesyes"
3550 then
3551         plugin_tcpconns="yes"
3552 fi
3553
3554 if test "x$have_getutent" = "xyes"
3555 then
3556         plugin_users="yes"
3557 fi
3558 if test "x$have_getutxent" = "xyes"
3559 then
3560         plugin_users="yes"
3561 fi
3562
3563 m4_divert_once([HELP_ENABLE], [
3564 collectd plugins:])
3565
3566 AC_ARG_ENABLE([all-plugins],
3567                 AC_HELP_STRING([--enable-all-plugins],
3568                                 [enable all plugins (auto by def)]),
3569                 [
3570                  if test "x$enableval" = "xyes"
3571                  then
3572                          enable_all_plugins="yes"
3573                  else if test "x$enableval" = "xauto"
3574                  then
3575                          enable_all_plugins="auto"
3576                  else
3577                          enable_all_plugins="no"
3578                  fi; fi
3579                 ],
3580                 [enable_all_plugins="auto"])
3581
3582 m4_divert_once([HELP_ENABLE], [])
3583
3584 AC_PLUGIN([apache],      [$with_libcurl],      [Apache httpd statistics])
3585 AC_PLUGIN([apcups],      [yes],                [Statistics of UPSes by APC])
3586 AC_PLUGIN([apple_sensors], [$with_libiokit],   [Apple's hardware sensors])
3587 AC_PLUGIN([ascent],      [$plugin_ascent],     [AscentEmu player statistics])
3588 AC_PLUGIN([battery],     [$plugin_battery],    [Battery statistics])
3589 AC_PLUGIN([bind],        [$plugin_bind],       [ISC Bind nameserver statistics])
3590 AC_PLUGIN([conntrack],   [$plugin_conntrack],  [nf_conntrack statistics])
3591 AC_PLUGIN([cpufreq],     [$plugin_cpufreq],    [CPU frequency statistics])
3592 AC_PLUGIN([cpu],         [$plugin_cpu],        [CPU usage statistics])
3593 AC_PLUGIN([csv],         [yes],                [CSV output plugin])
3594 AC_PLUGIN([curl],        [$with_libcurl],      [CURL generic web statistics])
3595 AC_PLUGIN([dbi],         [$with_libdbi],       [General database statistics])
3596 AC_PLUGIN([df],          [$plugin_df],         [Filesystem usage statistics])
3597 AC_PLUGIN([disk],        [$plugin_disk],       [Disk usage statistics])
3598 AC_PLUGIN([dns],         [$with_libpcap],      [DNS traffic analysis])
3599 AC_PLUGIN([email],       [yes],                [EMail statistics])
3600 AC_PLUGIN([entropy],     [$plugin_entropy],    [Entropy statistics])
3601 AC_PLUGIN([exec],        [yes],                [Execution of external programs])
3602 AC_PLUGIN([filecount],   [yes],                [Count files in directories])
3603 AC_PLUGIN([fscache],     [$plugin_fscache],    [fscache statistics])
3604 AC_PLUGIN([gmond],       [$with_libganglia],   [Ganglia plugin])
3605 AC_PLUGIN([hddtemp],     [yes],                [Query hddtempd])
3606 AC_PLUGIN([interface],   [$plugin_interface],  [Interface traffic statistics])
3607 AC_PLUGIN([ipmi],        [$plugin_ipmi],       [IPMI sensor statistics])
3608 AC_PLUGIN([iptables],    [$with_libiptc],      [IPTables rule counters])
3609 AC_PLUGIN([ipvs],        [$plugin_ipvs],       [IPVS connection statistics])
3610 AC_PLUGIN([irq],         [$plugin_irq],        [IRQ statistics])
3611 AC_PLUGIN([java],        [$with_java],         [Embed the Java Virtual Machine])
3612 AC_PLUGIN([libvirt],     [$plugin_libvirt],    [Virtual machine statistics])
3613 AC_PLUGIN([load],        [$plugin_load],       [System load])
3614 AC_PLUGIN([logfile],     [yes],                [File logging plugin])
3615 AC_PLUGIN([match_regex], [yes],                [The regex match])
3616 AC_PLUGIN([match_timediff], [yes],             [The timediff match])
3617 AC_PLUGIN([match_value], [yes],                [The value match])
3618 AC_PLUGIN([mbmon],       [yes],                [Query mbmond])
3619 AC_PLUGIN([memcachec],   [$with_libmemcached], [memcachec statistics])
3620 AC_PLUGIN([memcached],   [yes],                [memcached statistics])
3621 AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
3622 AC_PLUGIN([multimeter],  [$plugin_multimeter], [Read multimeter values])
3623 AC_PLUGIN([mysql],       [$with_libmysql],     [MySQL statistics])
3624 AC_PLUGIN([netlink],     [$with_libnetlink],   [Enhanced Linux network statistics])
3625 AC_PLUGIN([network],     [yes],                [Network communication plugin])
3626 AC_PLUGIN([nfs],         [$plugin_nfs],        [NFS statistics])
3627 AC_PLUGIN([nginx],       [$with_libcurl],      [nginx statistics])
3628 AC_PLUGIN([notify_desktop], [$with_libnotify], [Desktop notifications])
3629 AC_PLUGIN([notify_email], [$with_libesmtp],    [Email notifier])
3630 AC_PLUGIN([ntpd],        [yes],                [NTPd statistics])
3631 AC_PLUGIN([nut],         [$with_libupsclient], [Network UPS tools statistics])
3632 AC_PLUGIN([onewire],     [$with_libowcapi],    [OneWire sensor statistics])
3633 AC_PLUGIN([openvpn],     [yes],                [OpenVPN client statistics])
3634 AC_PLUGIN([oracle],      [$with_oracle],       [Oracle plugin])
3635 AC_PLUGIN([perl],        [$plugin_perl],       [Embed a Perl interpreter])
3636 AC_PLUGIN([ping],        [$with_liboping],     [Network latency statistics])
3637 AC_PLUGIN([postgresql],  [$with_libpq],        [PostgreSQL database statistics])
3638 AC_PLUGIN([powerdns],    [yes],                [PowerDNS statistics])
3639 AC_PLUGIN([processes],   [$plugin_processes],  [Process statistics])
3640 AC_PLUGIN([protocols],   [$plugin_protocols],  [Protocol (IP, TCP, ...) statistics])
3641 AC_PLUGIN([rrdcached],   [$librrd_rrdc_update], [RRDTool output plugin])
3642 AC_PLUGIN([rrdtool],     [$with_librrd],       [RRDTool output plugin])
3643 AC_PLUGIN([sensors],     [$with_libsensors],   [lm_sensors statistics])
3644 AC_PLUGIN([serial],      [$plugin_serial],     [serial port traffic])
3645 AC_PLUGIN([snmp],        [$with_libnetsnmp],   [SNMP querying plugin])
3646 AC_PLUGIN([swap],        [$plugin_swap],       [Swap usage statistics])
3647 AC_PLUGIN([syslog],      [$have_syslog],       [Syslog logging plugin])
3648 AC_PLUGIN([table],       [yes],                [Parsing of tabular data])
3649 AC_PLUGIN([tail],        [yes],                [Parsing of logfiles])
3650 AC_PLUGIN([tape],        [$plugin_tape],       [Tape drive statistics])
3651 AC_PLUGIN([target_notification], [yes],        [The notification target])
3652 AC_PLUGIN([target_replace], [yes],             [The replace target])
3653 AC_PLUGIN([target_set],  [yes],                [The set target])
3654 AC_PLUGIN([tcpconns],    [$plugin_tcpconns],   [TCP connection statistics])
3655 AC_PLUGIN([teamspeak2],  [yes],                [TeamSpeak2 server statistics])
3656 AC_PLUGIN([ted],         [$plugin_ted],        [Read The Energy Detective values])
3657 AC_PLUGIN([thermal],     [$plugin_thermal],    [Linux ACPI thermal zone statistics])
3658 AC_PLUGIN([unixsock],    [yes],                [Unixsock communication plugin])
3659 AC_PLUGIN([uptime],      [$plugin_uptime],     [Uptime statistics])
3660 AC_PLUGIN([users],       [$plugin_users],      [User statistics])
3661 AC_PLUGIN([uuid],        [yes],                [UUID as hostname plugin])
3662 AC_PLUGIN([vmem],        [$plugin_vmem],       [Virtual memory statistics])
3663 AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
3664 AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
3665 AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
3666
3667 dnl Default configuration file
3668 # Load either syslog or logfile
3669 LOAD_PLUGIN_SYSLOG=""
3670 LOAD_PLUGIN_LOGFILE=""
3671
3672 AC_MSG_CHECKING([which default log plugin to load])
3673 default_log_plugin="none"
3674 if test "x$enable_syslog" = "xyes"
3675 then
3676         default_log_plugin="syslog"
3677 else
3678         LOAD_PLUGIN_SYSLOG="##"
3679 fi
3680
3681 if test "x$enable_logfile" = "xyes"
3682 then
3683         if test "x$default_log_plugin" = "xnone"
3684         then
3685                 default_log_plugin="logfile"
3686         else
3687                 LOAD_PLUGIN_LOGFILE="#"
3688         fi
3689 else
3690         LOAD_PLUGIN_LOGFILE="##"
3691 fi
3692 AC_MSG_RESULT([$default_log_plugin])
3693
3694 AC_SUBST(LOAD_PLUGIN_SYSLOG)
3695 AC_SUBST(LOAD_PLUGIN_LOGFILE)
3696
3697 DEFAULT_LOG_LEVEL="info"
3698 if test "x$enable_debug" = "xyes"
3699 then
3700         DEFAULT_LOG_LEVEL="debug"
3701 fi
3702 AC_SUBST(DEFAULT_LOG_LEVEL)
3703
3704 # Load only one of rrdtool, network, csv in the default config.
3705 LOAD_PLUGIN_RRDTOOL=""
3706 LOAD_PLUGIN_NETWORK=""
3707 LOAD_PLUGIN_CSV=""
3708
3709 AC_MSG_CHECKING([which default write plugin to load])
3710 default_write_plugin="none"
3711 if test "x$enable_rrdtool" = "xyes"
3712 then
3713         default_write_plugin="rrdtool"
3714 else
3715         LOAD_PLUGIN_RRDTOOL="##"
3716 fi
3717
3718 if test "x$enable_network" = "xyes"
3719 then
3720         if test "x$default_write_plugin" = "xnone"
3721         then
3722                 default_write_plugin="network"
3723         else
3724                 LOAD_PLUGIN_NETWORK="#"
3725         fi
3726 else
3727         LOAD_PLUGIN_NETWORK="##"
3728 fi
3729
3730 if test "x$enable_csv" = "xyes"
3731 then
3732         if test "x$default_write_plugin" = "xnone"
3733         then
3734                 default_write_plugin="csv"
3735         else
3736                 LOAD_PLUGIN_CSV="#"
3737         fi
3738 else
3739         LOAD_PLUGIN_CSV="##"
3740 fi
3741 AC_MSG_RESULT([$default_write_plugin])
3742
3743 AC_SUBST(LOAD_PLUGIN_RRDTOOL)
3744 AC_SUBST(LOAD_PLUGIN_NETWORK)
3745 AC_SUBST(LOAD_PLUGIN_CSV)
3746
3747 dnl ip_vs.h
3748 if test "x$ac_system" = "xLinux" \
3749         && test "x$have_net_ip_vs_h$have_ip_vs_h" = "xnono"
3750 then
3751         enable_ipvs="$enable_ipvs (ip_vs.h not found)"
3752 fi
3753
3754 dnl Perl bindings
3755 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
3756 [
3757         if test "x$withval" != "xno" && test "x$withval" != "xyes"
3758         then
3759                 PERL_BINDINGS_OPTIONS="$withval"
3760                 with_perl_bindings="yes"
3761         else
3762                 PERL_BINDINGS_OPTIONS=""
3763                 with_perl_bindings="$withval"
3764         fi
3765 ],
3766 [
3767         PERL_BINDINGS_OPTIONS=""
3768         if test -n "$perl_interpreter"
3769         then
3770                 with_perl_bindings="yes"
3771         else
3772                 with_perl_bindings="no (no perl interpreter found)"
3773         fi
3774 ])
3775 if test "x$with_perl_bindings" = "xyes"
3776 then
3777         PERL_BINDINGS="perl"
3778 else
3779         PERL_BINDINGS=""
3780 fi
3781 AC_SUBST(PERL_BINDINGS)
3782 AC_SUBST(PERL_BINDINGS_OPTIONS)
3783
3784 dnl libcollectdclient
3785 LCC_VERSION_MAJOR=`echo $PACKAGE_VERSION | cut -d'.' -f1`
3786 LCC_VERSION_MINOR=`echo $PACKAGE_VERSION | cut -d'.' -f2`
3787 LCC_VERSION_PATCH=`echo $PACKAGE_VERSION | cut -d'.' -f3`
3788
3789 LCC_VERSION_EXTRA=`echo $PACKAGE_VERSION | cut -d'.' -f4-`
3790
3791 LCC_VERSION_STRING="$LCC_VERSION_MAJOR.$LCC_VERSION_MINOR.$LCC_VERSION_PATCH"
3792
3793 AC_SUBST(LCC_VERSION_MAJOR)
3794 AC_SUBST(LCC_VERSION_MINOR)
3795 AC_SUBST(LCC_VERSION_PATCH)
3796 AC_SUBST(LCC_VERSION_EXTRA)
3797 AC_SUBST(LCC_VERSION_STRING)
3798
3799 AC_CONFIG_FILES(src/libcollectdclient/lcc_features.h)
3800
3801 AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/owniptc/Makefile src/libcollectdclient/Makefile src/libcollectdclient/libcollectdclient.pc src/liboconfig/Makefile bindings/Makefile bindings/java/Makefile)
3802
3803 if test "x$with_librrd" = "xyes" \
3804         && test "x$librrd_threadsafe" != "xyes"
3805 then
3806         with_librrd="yes (warning: librrd is not thread-safe)"
3807 fi
3808
3809 if test "x$with_libiptc" = "xyes" -a "x$with_own_libiptc" = "xyes"
3810 then
3811         with_libiptc="yes (shipped version)"
3812 fi
3813
3814 if test "x$with_libperl" = "xyes"
3815 then
3816         with_libperl="yes (version `$perl_interpreter -MConfig -e 'print $Config{version};'`)"
3817 else
3818         enable_perl="no (needs libperl)"
3819 fi
3820
3821 if test "x$enable_perl" = "xno" && test "x$c_cv_have_perl_ithreads" = "xno"
3822 then
3823         enable_perl="no (libperl doesn't support ithreads)"
3824 fi
3825
3826 if test "x$with_perl_bindings" = "xyes" \
3827         && test "x$PERL_BINDINGS_OPTIONS" != "x"
3828 then
3829         with_perl_bindings="yes ($PERL_BINDINGS_OPTIONS)"
3830 fi
3831
3832 cat <<EOF;
3833
3834 Configuration:
3835   Libraries:
3836     libcurl . . . . . . . $with_libcurl
3837     libdbi  . . . . . . . $with_libdbi
3838     libesmtp  . . . . . . $with_libesmtp
3839     libganglia  . . . . . $with_libganglia
3840     libgcrypt . . . . . . $with_libgcrypt
3841     libiokit  . . . . . . $with_libiokit
3842     libiptc . . . . . . . $with_libiptc
3843     libjvm  . . . . . . . $with_java
3844     libkstat  . . . . . . $with_kstat
3845     libkvm  . . . . . . . $with_libkvm
3846     libmemcached  . . . . $with_libmemcached
3847     libmysql  . . . . . . $with_libmysql
3848     libnetlink  . . . . . $with_libnetlink
3849     libnetsnmp  . . . . . $with_libnetsnmp
3850     libnotify . . . . . . $with_libnotify
3851     liboconfig  . . . . . $with_liboconfig
3852     libopenipmi . . . . . $with_libopenipmipthread
3853     liboping  . . . . . . $with_liboping
3854     libpcap . . . . . . . $with_libpcap
3855     libperl . . . . . . . $with_libperl
3856     libpq . . . . . . . . $with_libpq
3857     libpthread  . . . . . $with_libpthread
3858     librrd  . . . . . . . $with_librrd
3859     libsensors  . . . . . $with_libsensors
3860     libstatgrab . . . . . $with_libstatgrab
3861     libupsclient  . . . . $with_libupsclient
3862     libvirt . . . . . . . $with_libvirt
3863     libxml2 . . . . . . . $with_libxml2
3864     libxmms . . . . . . . $with_libxmms
3865     oracle  . . . . . . . $with_oracle
3866
3867   Features:
3868     daemon mode . . . . . $enable_daemon
3869     debug . . . . . . . . $enable_debug
3870
3871   Bindings:
3872     perl  . . . . . . . . $with_perl_bindings
3873
3874   Modules:
3875     apache  . . . . . . . $enable_apache
3876     apcups  . . . . . . . $enable_apcups
3877     apple_sensors . . . . $enable_apple_sensors
3878     ascent  . . . . . . . $enable_ascent
3879     battery . . . . . . . $enable_battery
3880     bind  . . . . . . . . $enable_bind
3881     conntrack . . . . . . $enable_conntrack
3882     cpu . . . . . . . . . $enable_cpu
3883     cpufreq . . . . . . . $enable_cpufreq
3884     csv . . . . . . . . . $enable_csv
3885     curl  . . . . . . . . $enable_curl
3886     dbi . . . . . . . . . $enable_dbi
3887     df  . . . . . . . . . $enable_df
3888     disk  . . . . . . . . $enable_disk
3889     dns . . . . . . . . . $enable_dns
3890     email . . . . . . . . $enable_email
3891     entropy . . . . . . . $enable_entropy
3892     exec  . . . . . . . . $enable_exec
3893     filecount . . . . . . $enable_filecount
3894     fscache . . . . . . . $enable_fscache
3895     gmond . . . . . . . . $enable_gmond
3896     hddtemp . . . . . . . $enable_hddtemp
3897     interface . . . . . . $enable_interface
3898     ipmi  . . . . . . . . $enable_ipmi
3899     iptables  . . . . . . $enable_iptables
3900     ipvs  . . . . . . . . $enable_ipvs
3901     irq . . . . . . . . . $enable_irq
3902     java  . . . . . . . . $enable_java
3903     libvirt . . . . . . . $enable_libvirt
3904     load  . . . . . . . . $enable_load
3905     logfile . . . . . . . $enable_logfile
3906     match_regex . . . . . $enable_match_regex
3907     match_timediff  . . . $enable_match_timediff
3908     match_value . . . . . $enable_match_value
3909     mbmon . . . . . . . . $enable_mbmon
3910     memcachec . . . . . . $enable_memcachec
3911     memcached . . . . . . $enable_memcached
3912     memory  . . . . . . . $enable_memory
3913     multimeter  . . . . . $enable_multimeter
3914     mysql . . . . . . . . $enable_mysql
3915     netlink . . . . . . . $enable_netlink
3916     network . . . . . . . $enable_network
3917     nfs . . . . . . . . . $enable_nfs
3918     nginx . . . . . . . . $enable_nginx
3919     notify_desktop  . . . $enable_notify_desktop
3920     notify_email  . . . . $enable_notify_email
3921     ntpd  . . . . . . . . $enable_ntpd
3922     nut . . . . . . . . . $enable_nut
3923     onewire . . . . . . . $enable_onewire
3924     openvpn . . . . . . . $enable_openvpn
3925     oracle  . . . . . . . $enable_oracle
3926     perl  . . . . . . . . $enable_perl
3927     ping  . . . . . . . . $enable_ping
3928     postgresql  . . . . . $enable_postgresql
3929     powerdns  . . . . . . $enable_powerdns
3930     processes . . . . . . $enable_processes
3931     protocols . . . . . . $enable_protocols
3932     rrdcached . . . . . . $enable_rrdcached
3933     rrdtool . . . . . . . $enable_rrdtool
3934     sensors . . . . . . . $enable_sensors
3935     serial  . . . . . . . $enable_serial
3936     snmp  . . . . . . . . $enable_snmp
3937     swap  . . . . . . . . $enable_swap
3938     syslog  . . . . . . . $enable_syslog
3939     table . . . . . . . . $enable_table
3940     tail  . . . . . . . . $enable_tail
3941     tape  . . . . . . . . $enable_tape
3942     target_notification . $enable_target_notification
3943     target_replace  . . . $enable_target_replace
3944     target_set  . . . . . $enable_target_set
3945     tcpconns  . . . . . . $enable_tcpconns
3946     teamspeak2  . . . . . $enable_teamspeak2
3947     ted . . . . . . . . . $enable_ted
3948     thermal . . . . . . . $enable_thermal
3949     unixsock  . . . . . . $enable_unixsock
3950     uptime  . . . . . . . $enable_uptime
3951     users . . . . . . . . $enable_users
3952     uuid  . . . . . . . . $enable_uuid
3953     vmem  . . . . . . . . $enable_vmem
3954     vserver . . . . . . . $enable_vserver
3955     wireless  . . . . . . $enable_wireless
3956     xmms  . . . . . . . . $enable_xmms
3957
3958 EOF
3959
3960 if test "x$dependency_error" = "xyes"; then
3961         AC_MSG_ERROR("Some plugins are missing dependencies - see the summary above for details")
3962 fi
3963
3964 if test "x$dependency_warning" = "xyes"; then
3965         AC_MSG_WARN("Some plugins seem to have missing dependencies but have been enabled forcibly - see the summary above for details")
3966 fi
3967
3968 # vim: set fdm=marker :