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