Bumped version to 4.5.4; Updated ChangeLog.
[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         CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
71 fi
72
73 #
74 # Checks for header files.
75 #
76 AC_HEADER_STDC
77 AC_HEADER_SYS_WAIT
78 AC_HEADER_DIRENT
79 AC_HEADER_STDBOOL
80
81 AC_CHECK_HEADERS(stdio.h stdint.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h sys/ioctl.h endian.h sys/isa_defs.h)
82
83 # For ping library
84 AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
85 [#if HAVE_STDINT_H
86 # include <stdint.h>
87 #endif
88 #if HAVE_SYS_TYPES_H
89 # include <sys/types.h>
90 #endif
91 ])
92 AC_CHECK_HEADERS(netinet/in.h, [], [],
93 [#if HAVE_STDINT_H
94 # include <stdint.h>
95 #endif
96 #if HAVE_SYS_TYPES_H
97 # include <sys/types.h>
98 #endif
99 #if HAVE_NETINET_IN_SYSTM_H
100 # include <netinet/in_systm.h>
101 #endif
102 ])
103 AC_CHECK_HEADERS(netinet/ip.h, [], [],
104 [#if HAVE_STDINT_H
105 # include <stdint.h>
106 #endif
107 #if HAVE_SYS_TYPES_H
108 # include <sys/types.h>
109 #endif
110 #if HAVE_NETINET_IN_SYSTM_H
111 # include <netinet/in_systm.h>
112 #endif
113 #if HAVE_NETINET_IN_H
114 # include <netinet/in.h>
115 #endif
116 ])
117 AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [],
118 [#if HAVE_STDINT_H
119 # include <stdint.h>
120 #endif
121 #if HAVE_SYS_TYPES_H
122 # include <sys/types.h>
123 #endif
124 #if HAVE_NETINET_IN_SYSTM_H
125 # include <netinet/in_systm.h>
126 #endif
127 #if HAVE_NETINET_IN_H
128 # include <netinet/in.h>
129 #endif
130 #if HAVE_NETINET_IP_H
131 # include <netinet/ip.h>
132 #endif
133 ])
134 AC_CHECK_HEADERS(netinet/ip_var.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/ip6.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 ])
165 AC_CHECK_HEADERS(netinet/icmp6.h, [], [],
166 [#if HAVE_STDINT_H
167 # include <stdint.h>
168 #endif
169 #if HAVE_SYS_TYPES_H
170 # include <sys/types.h>
171 #endif
172 #if HAVE_NETINET_IN_SYSTM_H
173 # include <netinet/in_systm.h>
174 #endif
175 #if HAVE_NETINET_IN_H
176 # include <netinet/in.h>
177 #endif
178 #if HAVE_NETINET_IP6_H
179 # include <netinet/ip6.h>
180 #endif
181 ])
182 AC_CHECK_HEADERS(netinet/tcp.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_IP_H
196 # include <netinet/ip.h>
197 #endif
198 ])
199 AC_CHECK_HEADERS(netinet/udp.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
217 # For cpu modules
218 AC_CHECK_HEADERS(sys/dkstat.h)
219 if test "x$ac_system" = "xDarwin"
220 then
221         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)
222         AC_CHECK_HEADERS(CoreFoundation/CoreFoundation.h IOKit/IOKitLib.h IOKit/IOTypes.h IOKit/ps/IOPSKeys.h IOKit/IOBSD.h IOKit/storage/IOBlockStorageDriver.h)
223 fi
224 AC_CHECK_HEADERS(sys/sysctl.h, [], [],
225 [
226 #if HAVE_SYS_TYPES_H
227 #  include <sys/types.h>
228 #endif
229 #if HAVE_SYS_PARAM_H
230 # include <sys/param.h>
231 #endif
232 ])
233
234 # For hddtemp module
235 AC_CHECK_HEADERS(linux/major.h libgen.h)
236
237 # For the battery plugin
238 AC_CHECK_HEADERS(IOKit/ps/IOPowerSources.h, [], [],
239 [
240 #if HAVE_IOKIT_IOKITLIB_H
241 #  include <IOKit/IOKitLib.h>
242 #endif
243 #if HAVE_IOKIT_IOTYPES_H
244 #  include <IOKit/IOTypes.h>
245 #endif
246 ])
247
248 # For the swap module
249 have_sys_swap_h="yes"
250 AC_CHECK_HEADERS(sys/swap.h vm/anon.h, [], [have_sys_swap_h="no"],
251 [
252 #if HAVE_SYS_TYPES_H
253 #  include <sys/types.h>
254 #endif
255 #if HAVE_SYS_PARAM_H
256 # include <sys/param.h>
257 #endif
258 ])
259
260 if test "x$have_sys_swap_h$ac_system" = "xnoSolaris"
261 then
262         hint_64=""
263         if test "x$GCC" = "xyes"
264         then
265                 hint_64="CFLAGS='-m64'"
266         else
267                 hint_64="CFLAGS='-xarch=v9'"
268         fi
269         AC_MSG_NOTICE([Solaris detected and sys/swap.h not usable. Try building a 64-bit binary ($hint_64 ./configure).])
270 fi
271
272 # For load module
273 # For the processes plugin
274 # For users module
275 AC_CHECK_HEADERS(sys/loadavg.h linux/config.h utmp.h utmpx.h)
276
277 # For interface plugin
278 AC_CHECK_HEADERS(ifaddrs.h)
279 AC_CHECK_HEADERS(net/if.h, [], [],
280 [
281 #if HAVE_SYS_TYPES_H
282 #  include <sys/types.h>
283 #endif
284 #if HAVE_SYS_SOCKET_H
285 #  include <sys/socket.h>
286 #endif
287 ])
288 AC_CHECK_HEADERS(linux/if.h, [], [],
289 [
290 #if HAVE_SYS_TYPES_H
291 #  include <sys/types.h>
292 #endif
293 #if HAVE_SYS_SOCKET_H
294 #  include <sys/socket.h>
295 #endif
296 ])
297 AC_CHECK_HEADERS(linux/netdevice.h, [], [],
298 [
299 #if HAVE_SYS_TYPES_H
300 #  include <sys/types.h>
301 #endif
302 #if HAVE_SYS_SOCKET_H
303 #  include <sys/socket.h>
304 #endif
305 #if HAVE_LINUX_IF_H
306 # include <linux/if.h>
307 #endif
308 ])
309
310 # For ipvs module
311 have_net_ip_vs_h="no"
312 have_ip_vs_h="no"
313 if test "x$ac_system" = "xLinux"
314 then
315         SAVE_CFLAGS=$CFLAGS
316         CFLAGS="$CFLAGS $KERNEL_CFLAGS"
317
318         AC_CHECK_HEADERS(net/ip_vs.h, [have_net_ip_vs_h="yes"])
319         AC_CHECK_HEADERS(ip_vs.h, [have_ip_vs_h="yes"])
320
321         CFLAGS=$SAVE_CFLAGS
322 fi
323
324 # For quota module
325 AC_CHECK_HEADERS(sys/ucred.h, [], [],
326 [
327 #if HAVE_SYS_TYPES_H
328 #  include <sys/types.h>
329 #endif
330 #if HAVE_SYS_PARAM_H
331 # include <sys/param.h>
332 #endif
333 ])
334
335 # For mount interface
336 AC_CHECK_HEADERS(sys/mount.h, [], [],
337 [
338 #if HAVE_SYS_TYPES_H
339 #  include <sys/types.h>
340 #endif
341 #if HAVE_SYS_PARAM_H
342 # include <sys/param.h>
343 #endif
344 ])
345
346 # For the email plugin
347 AC_CHECK_HEADERS(linux/un.h, [], [],
348 [
349 #if HAVE_SYS_SOCKET_H
350 #       include <sys/socket.h>
351 #endif
352 ])
353
354 AC_CHECK_HEADERS(pwd.h grp.h sys/un.h ctype.h limits.h sys/quota.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)
355
356 # For the dns plugin
357 AC_CHECK_HEADERS(arpa/nameser.h)
358 AC_CHECK_HEADERS(arpa/nameser_compat.h, [], [],
359 [
360 #if HAVE_ARPA_NAMESER_H
361 # include <arpa/nameser.h>
362 #endif
363 ])
364
365 AC_CHECK_HEADERS(net/if_arp.h, [], [],
366 [#if HAVE_SYS_SOCKET_H
367 # include <sys/socket.h>
368 #endif
369 ])
370 AC_CHECK_HEADERS(net/ppp_defs.h)
371 AC_CHECK_HEADERS(net/if_ppp.h, [], [],
372 [#if HAVE_NET_PPP_DEFS_H
373 # include <net/ppp_defs.h>
374 #endif
375 ])
376 AC_CHECK_HEADERS(netinet/if_ether.h, [], [],
377 [#if HAVE_STDINT_H
378 # include <stdint.h>
379 #endif
380 #if HAVE_SYS_TYPES_H
381 # include <sys/types.h>
382 #endif
383 #if HAVE_SYS_SOCKET_H
384 # include <sys/socket.h>
385 #endif
386 #if HAVE_NET_IF_H
387 # include <net/if.h>
388 #endif
389 #if HAVE_NETINET_IN_H
390 # include <netinet/in.h>
391 #endif
392 ])
393
394 # For the multimeter plugin
395 have_termios_h="no"
396 AC_CHECK_HEADERS(termios.h, [have_termios_h="yes"])
397
398 #
399 # Checks for typedefs, structures, and compiler characteristics.
400 #
401 AC_C_CONST
402 AC_TYPE_PID_T
403 AC_TYPE_SIZE_T
404 AC_TYPE_UID_T
405 AC_HEADER_TIME
406
407 #
408 # Checks for library functions.
409 #
410 AC_PROG_GCC_TRADITIONAL
411 AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog closelog)
412
413 AC_FUNC_STRERROR_R
414
415 AC_CACHE_CHECK([for strtok_r],
416   [c_cv_have_strtok_r_default],
417   AC_LINK_IFELSE(
418     AC_LANG_PROGRAM(
419     [[[[
420 #include <stdlib.h>
421 #include <stdio.h>
422 #include <string.h>
423     ]]]],
424     [[[[
425       char buffer[] = "foo,bar,baz";
426       char *token;
427       char *dummy;
428       char *saveptr;
429
430       dummy = buffer;
431       saveptr = NULL;
432       while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
433       {
434         dummy = NULL;
435         printf ("token = %s;\n", token);
436       }
437     ]]]]),
438     [c_cv_have_strtok_r_default="yes"],
439     [c_cv_have_strtok_r_default="no"]
440   )
441 )
442
443 if test "x$c_cv_have_strtok_r_default" = "xno"
444 then
445   SAVE_CFLAGS="$CFLAGS"
446   CFLAGS="$CFLAGS -D_REENTRANT=1"
447
448   AC_CACHE_CHECK([if strtok_r needs _REENTRANT],
449     [c_cv_have_strtok_r_reentrant],
450     AC_LINK_IFELSE(
451       AC_LANG_PROGRAM(
452       [[[[
453 #include <stdlib.h>
454 #include <stdio.h>
455 #include <string.h>
456       ]]]],
457       [[[[
458         char buffer[] = "foo,bar,baz";
459         char *token;
460         char *dummy;
461         char *saveptr;
462
463         dummy = buffer;
464         saveptr = NULL;
465         while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
466         {
467           dummy = NULL;
468           printf ("token = %s;\n", token);
469         }
470       ]]]]),
471       [c_cv_have_strtok_r_reentrant="yes"],
472       [AC_MSG_FAILURE([strtok_r isn't available. Please file a bugreport!])]
473     )
474   )
475 fi
476
477 AC_CHECK_FUNCS(getpwnam_r getgrnam_r setgroups regcomp regerror regexec regfree)
478
479 socket_needs_socket="no"
480 AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [socket_needs_socket="yes"], AC_MSG_ERROR(cannot find socket)))
481 AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
482
483 nanosleep_needs_rt="no"
484 AC_CHECK_FUNCS(nanosleep, [], AC_CHECK_LIB(rt, nanosleep, [nanosleep_needs_rt="yes"], AC_MSG_ERROR(cannot find nanosleep)))
485 AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes")
486
487 AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
488 AC_CHECK_FUNCS(host_statistics, [have_host_statistics="yes"], [have_host_statistics="no"])
489 AC_CHECK_FUNCS(processor_info, [have_processor_info="yes"], [have_processor_info="no"])
490 AC_CHECK_FUNCS(thread_info, [have_thread_info="yes"], [have_thread_info="no"])
491 AC_CHECK_FUNCS(statfs, [have_statfs="yes"], [have_statfs="no"])
492 AC_CHECK_FUNCS(statvfs, [have_statvfs="yes"], [have_statvfs="no"])
493 AC_CHECK_FUNCS(getifaddrs, [have_getifaddrs="yes"], [have_getifaddrs="no"])
494 AC_CHECK_FUNCS(syslog, [have_syslog="yes"], [have_syslog="no"])
495 AC_CHECK_FUNCS(getutent, [have_getutent="yes"], [have_getutent="no"])
496 AC_CHECK_FUNCS(getutxent, [have_getutxent="yes"], [have_getutxent="no"])
497
498 # For load module
499 AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
500
501 # Check for NAN
502 AC_ARG_WITH(nan-emulation, [AS_HELP_STRING([--with-nan-emulation], [use emulated NAN. For crosscompiling only.])],
503 [
504  if test "x$withval" = "xno"; then
505          nan_type="none"
506  else if test "x$withval" = "xyes"; then
507          nan_type="zero"
508  else
509          nan_type="$withval"
510  fi; fi
511 ],
512 [nan_type="none"])
513 if test "x$nan_type" = "xnone"; then
514   AC_CACHE_CHECK([whether NAN is defined by default],
515     [c_cv_have_nan_default],
516     AC_COMPILE_IFELSE(
517       AC_LANG_PROGRAM(
518       [[
519 #include <stdlib.h>
520 #include <math.h>
521 static float foo = NAN;
522       ]],
523       [[
524        if (isnan (foo))
525         return 0;
526        else
527         return 1;
528       ]]),
529       [c_cv_have_nan_default="yes"],
530       [c_cv_have_nan_default="no"]
531     )
532   )
533   if test "x$c_cv_have_nan_default" = "xyes"
534   then
535     nan_type="default"
536   fi
537 fi
538 if test "x$nan_type" = "xnone"; then
539   AC_CACHE_CHECK([whether NAN is defined by __USE_ISOC99],
540     [c_cv_have_nan_isoc],
541     AC_COMPILE_IFELSE(
542       AC_LANG_PROGRAM(
543       [[
544 #include <stdlib.h>
545 #define __USE_ISOC99 1
546 #include <math.h>
547 static float foo = NAN;
548       ]],
549       [[
550        if (isnan (foo))
551         return 0;
552        else
553         return 1;
554       ]]),
555       [c_cv_have_nan_isoc="yes"],
556       [c_cv_have_nan_isoc="no"]
557     )
558   )
559   if test "x$c_cv_have_nan_isoc" = "xyes"
560   then
561     nan_type="isoc99"
562   fi
563 fi
564 if test "x$nan_type" = "xnone"; then
565   AC_CACHE_CHECK([whether NAN can be defined by 0/0],
566     [c_cv_have_nan_zero],
567     AC_RUN_IFELSE(
568       AC_LANG_PROGRAM(
569       [[
570 #include <stdlib.h>
571 #include <math.h>
572 #ifdef NAN
573 # undef NAN
574 #endif
575 #define NAN (0.0 / 0.0)
576 #ifndef isnan
577 # define isnan(f) ((f) != (f))
578 #endif
579 static float foo = NAN;
580       ]],
581       [[
582        if (isnan (foo))
583         return 0;
584        else
585         return 1;
586       ]]),
587       [c_cv_have_nan_zero="yes"],
588       [c_cv_have_nan_zero="no"]
589     )
590   )
591   if test "x$c_cv_have_nan_zero" = "xyes"
592   then
593     nan_type="zero"
594   fi
595 fi
596
597 if test "x$nan_type" = "xdefault"; then
598   AC_DEFINE(NAN_STATIC_DEFAULT, 1,
599     [Define if NAN is defined by default and can initialize static variables.])
600 else if test "x$nan_type" = "xisoc99"; then
601   AC_DEFINE(NAN_STATIC_ISOC, 1,
602     [Define if NAN is defined by __USE_ISOC99 and can initialize static variables.])
603 else if test "x$nan_type" = "xzero"; then
604   AC_DEFINE(NAN_ZERO_ZERO, 1,
605     [Define if NAN can be defined as (0.0 / 0.0)])
606 else
607   AC_MSG_ERROR([Didn't find out how to statically initialize variables to NAN. Sorry.])
608 fi; fi; fi
609
610 AC_ARG_WITH(fp-layout, [AS_HELP_STRING([--with-fp-layout], [set the memory layout of doubles. For crosscompiling only.])],
611 [
612  if test "x$withval" = "xnothing"; then
613         fp_layout_type="nothing"
614  else if test "x$withval" = "xendianflip"; then
615         fp_layout_type="endianflip"
616  else if test "x$withval" = "xintswap"; then
617         fp_layout_type="intswap"
618  else
619         AC_MSG_ERROR([Invalid argument for --with-fp-layout. Valid arguments are: nothing, endianflip, intswap]);
620 fi; fi; fi
621 ],
622 [fp_layout_type="unknown"])
623
624 if test "x$fp_layout_type" = "xunknown"; then
625   AC_CACHE_CHECK([if doubles are stored in x86 representation],
626     [c_cv_fp_layout_need_nothing],
627     AC_RUN_IFELSE(
628       AC_LANG_PROGRAM(
629       [[[[
630 #include <stdlib.h>
631 #include <stdio.h>
632 #include <stdint.h>
633 #include <string.h>
634       ]]]],
635       [[[[
636         uint64_t i0;
637         uint64_t i1;
638         uint8_t c[8];
639         double d;
640
641         d = 8.642135e130; 
642         memcpy ((void *) &i0, (void *) &d, 8);
643
644         i1 = i0;
645         memcpy ((void *) c, (void *) &i1, 8);
646
647         if ((c[0] == 0x2f) && (c[1] == 0x25)
648                         && (c[2] == 0xc0) && (c[3] == 0xc7)
649                         && (c[4] == 0x43) && (c[5] == 0x2b)
650                         && (c[6] == 0x1f) && (c[7] == 0x5b))
651                 return (0);
652         else
653                 return (1);
654       ]]]]),
655       [c_cv_fp_layout_need_nothing="yes"],
656       [c_cv_fp_layout_need_nothing="no"]
657     )
658   )
659   if test "x$c_cv_fp_layout_need_nothing" = "xyes"; then
660     fp_layout_type="nothing"
661   fi
662 fi
663 if test "x$fp_layout_type" = "xunknown"; then
664   AC_CACHE_CHECK([if endianflip converts to x86 representation],
665     [c_cv_fp_layout_need_endianflip],
666     AC_RUN_IFELSE(
667       AC_LANG_PROGRAM(
668       [[[[
669 #include <stdlib.h>
670 #include <stdio.h>
671 #include <stdint.h>
672 #include <string.h>
673 #define endianflip(A) ((((uint64_t)(A) & 0xff00000000000000LL) >> 56) | \
674                        (((uint64_t)(A) & 0x00ff000000000000LL) >> 40) | \
675                        (((uint64_t)(A) & 0x0000ff0000000000LL) >> 24) | \
676                        (((uint64_t)(A) & 0x000000ff00000000LL) >> 8)  | \
677                        (((uint64_t)(A) & 0x00000000ff000000LL) << 8)  | \
678                        (((uint64_t)(A) & 0x0000000000ff0000LL) << 24) | \
679                        (((uint64_t)(A) & 0x000000000000ff00LL) << 40) | \
680                        (((uint64_t)(A) & 0x00000000000000ffLL) << 56))
681       ]]]],
682       [[[[
683         uint64_t i0;
684         uint64_t i1;
685         uint8_t c[8];
686         double d;
687
688         d = 8.642135e130; 
689         memcpy ((void *) &i0, (void *) &d, 8);
690
691         i1 = endianflip (i0);
692         memcpy ((void *) c, (void *) &i1, 8);
693
694         if ((c[0] == 0x2f) && (c[1] == 0x25)
695                         && (c[2] == 0xc0) && (c[3] == 0xc7)
696                         && (c[4] == 0x43) && (c[5] == 0x2b)
697                         && (c[6] == 0x1f) && (c[7] == 0x5b))
698                 return (0);
699         else
700                 return (1);
701       ]]]]),
702       [c_cv_fp_layout_need_endianflip="yes"],
703       [c_cv_fp_layout_need_endianflip="no"]
704     )
705   )
706   if test "x$c_cv_fp_layout_need_endianflip" = "xyes"; then
707     fp_layout_type="endianflip"
708   fi
709 fi
710 if test "x$fp_layout_type" = "xunknown"; then
711   AC_CACHE_CHECK([if intswap converts to x86 representation],
712     [c_cv_fp_layout_need_intswap],
713     AC_RUN_IFELSE(
714       AC_LANG_PROGRAM(
715       [[[[
716 #include <stdlib.h>
717 #include <stdio.h>
718 #include <stdint.h>
719 #include <string.h>
720 #define intswap(A)    ((((uint64_t)(A) & 0xffffffff00000000LL) >> 32) | \
721                        (((uint64_t)(A) & 0x00000000ffffffffLL) << 32))
722       ]]]],
723       [[[[
724         uint64_t i0;
725         uint64_t i1;
726         uint8_t c[8];
727         double d;
728
729         d = 8.642135e130; 
730         memcpy ((void *) &i0, (void *) &d, 8);
731
732         i1 = intswap (i0);
733         memcpy ((void *) c, (void *) &i1, 8);
734
735         if ((c[0] == 0x2f) && (c[1] == 0x25)
736                         && (c[2] == 0xc0) && (c[3] == 0xc7)
737                         && (c[4] == 0x43) && (c[5] == 0x2b)
738                         && (c[6] == 0x1f) && (c[7] == 0x5b))
739                 return (0);
740         else
741                 return (1);
742       ]]]]),
743       [c_cv_fp_layout_need_intswap="yes"],
744       [c_cv_fp_layout_need_intswap="no"]
745     )
746   )
747   if test "x$c_cv_fp_layout_need_intswap" = "xyes"; then
748     fp_layout_type="intswap"
749   fi
750 fi
751
752 if test "x$fp_layout_type" = "xnothing"; then
753   AC_DEFINE(FP_LAYOUT_NEED_NOTHING, 1,
754   [Define if doubles are stored in x86 representation.])
755 else if test "x$fp_layout_type" = "xendianflip"; then
756   AC_DEFINE(FP_LAYOUT_NEED_ENDIANFLIP, 1,
757   [Define if endianflip is needed to convert to x86 representation.])
758 else if test "x$fp_layout_type" = "xintswap"; then
759   AC_DEFINE(FP_LAYOUT_NEED_INTSWAP, 1,
760   [Define if intswap is needed to convert to x86 representation.])
761 else
762   AC_MSG_ERROR([Didn't find out how doubles are stored in memory. Sorry.])
763 fi; fi; fi
764
765 have_getfsstat="no"
766 AC_CHECK_FUNCS(getfsstat, [have_getfsstat="yes"])
767 have_getvfsstat="no"
768 AC_CHECK_FUNCS(getvfsstat, [have_getvfsstat="yes"])
769 have_listmntent="no"
770 AC_CHECK_FUNCS(listmntent, [have_listmntent="yes"])
771
772 have_getmntent="no"
773 AC_CHECK_FUNCS(getmntent, [have_getmntent="c"])
774 if test "x$have_getmntent" = "xno"; then
775         AC_CHECK_LIB(sun, getmntent, [have_getmntent="sun"])
776 fi
777 if test "x$have_getmntent" = "xno"; then
778         AC_CHECK_LIB(seq, getmntent, [have_getmntent="seq"])
779 fi
780 if test "x$have_getmntent" = "xno"; then
781         AC_CHECK_LIB(gen, getmntent, [have_getmntent="gen"])
782 fi
783
784 if test "x$have_getmntent" = "xc"; then
785         AC_CACHE_CHECK([whether getmntent takes one argument],
786                 [c_cv_have_one_getmntent],
787                 AC_COMPILE_IFELSE(
788                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
789 #include "$srcdir/src/utils_mount.h"]],
790                                 [[
791                                  FILE *fh;
792                                  struct mntent *me;
793                                  fh = setmntent ("/etc/mtab", "r");
794                                  me = getmntent (fh);
795                                 ]]
796                         ),
797                         [c_cv_have_one_getmntent="yes"],
798                         [c_cv_have_one_getmntent="no"]
799                 )
800         )
801         AC_CACHE_CHECK([whether getmntent takes two arguments],
802                 [c_cv_have_two_getmntent],
803                 AC_COMPILE_IFELSE(
804                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
805 #include "$srcdir/src/utils_mount.h"]],
806                                 [[
807                                  FILE *fh;
808                                  struct mnttab mt;
809                                  int status;
810                                  fh = fopen ("/etc/mnttab", "r");
811                                  status = getmntent (fh, &mt);
812                                 ]]
813                         ),
814                         [c_cv_have_two_getmntent="yes"],
815                         [c_cv_have_two_getmntent="no"]
816                 )
817         )
818 fi
819
820 # Check for different versions of `getmntent' here..
821
822 if test "x$have_getmntent" = "xc"; then
823         if test "x$c_cv_have_one_getmntent" = "xyes"; then
824                 AC_DEFINE(HAVE_ONE_GETMNTENT, 1,
825                           [Define if the function getmntent exists and takes one argument.])
826         fi
827         if test "x$c_cv_have_two_getmntent" = "xyes"; then
828                 AC_DEFINE(HAVE_TWO_GETMNTENT, 1,
829                           [Define if the function getmntent exists and takes two arguments.])
830         fi
831 fi
832 if test "x$have_getmntent" = "xsun"; then
833         AC_DEFINE(HAVE_SUN_GETMNTENT, 1,
834                   [Define if the function getmntent exists. It's the version from libsun.])
835 fi
836 if test "x$have_getmntent" = "xseq"; then
837         AC_DEFINE(HAVE_SEQ_GETMNTENT, 1,
838                   [Define if the function getmntent exists. It's the version from libseq.])
839 fi
840 if test "x$have_getmntent" = "xgen"; then
841         AC_DEFINE(HAVE_GEN_GETMNTENT, 1,
842                   [Define if the function getmntent exists. It's the version from libgen.])
843 fi
844
845 # Check for structures
846 AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
847         [AC_DEFINE(HAVE_STRUCT_IF_DATA, 1, [Define if struct if_data exists and is usable.])],
848         [],
849         [
850         #include <sys/types.h>
851         #include <sys/socket.h>
852         #include <net/if.h>
853         ])
854 AC_CHECK_MEMBERS([struct net_device_stats.rx_bytes, struct net_device_stats.tx_packets, struct net_device_stats.rx_errors],
855         [AC_DEFINE(HAVE_STRUCT_NET_DEVICE_STATS, 1, [Define if struct net_device_stats exists and is usable.])],
856         [],
857         [
858         #include <sys/types.h>
859         #include <sys/socket.h>
860         #include <linux/if.h>
861         #include <linux/netdevice.h>
862         ])
863
864 AC_CHECK_MEMBERS([struct kinfo_proc.ki_pid, struct kinfo_proc.ki_rssize, struct kinfo_proc.ki_rusage],
865         [
866                 AC_DEFINE(HAVE_STRUCT_KINFO_PROC_FREEBSD, 1,
867                         [Define if struct kinfo_proc exists in the FreeBSD variant.])
868                 have_struct_kinfo_proc_freebsd="yes"
869         ],
870         [
871                 have_struct_kinfo_proc_freebsd="no"
872         ],
873         [
874 #include <kvm.h>
875 #include <sys/param.h>
876 #include <sys/sysctl.h>
877 #include <sys/user.h>
878         ])
879
880 AC_CHECK_MEMBERS([struct kinfo_proc.kp_proc, struct kinfo_proc.kp_eproc],
881         [
882                 AC_DEFINE(HAVE_STRUCT_KINFO_PROC_OPENBSD, 1,
883                         [Define if struct kinfo_proc exists in the OpenBSD variant.])
884                 have_struct_kinfo_proc_openbsd="yes"
885         ],
886         [
887                 have_struct_kinfo_proc_openbsd="no"
888         ],
889         [
890 #include <sys/param.h>
891 #include <sys/sysctl.h>
892 #include <kvm.h>
893         ])
894
895 AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
896 [#if HAVE_STDINT_H
897 # include <stdint.h>
898 #endif
899 #if HAVE_SYS_TYPES_H
900 # include <sys/types.h>
901 #endif
902 #if HAVE_NETINET_IN_SYSTM_H
903 # include <netinet/in_systm.h>
904 #endif
905 #if HAVE_NETINET_IN_H
906 # include <netinet/in.h>
907 #endif
908 #if HAVE_NETINET_IP_H
909 # include <netinet/ip.h>
910 #endif
911 #if HAVE_NETINET_UDP_H
912 # include <netinet/udp.h>
913 #endif
914 ])
915 AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source], [], [],
916 [#if HAVE_STDINT_H
917 # include <stdint.h>
918 #endif
919 #if HAVE_SYS_TYPES_H
920 # include <sys/types.h>
921 #endif
922 #if HAVE_NETINET_IN_SYSTM_H
923 # include <netinet/in_systm.h>
924 #endif
925 #if HAVE_NETINET_IN_H
926 # include <netinet/in.h>
927 #endif
928 #if HAVE_NETINET_IP_H
929 # include <netinet/ip.h>
930 #endif
931 #if HAVE_NETINET_UDP_H
932 # include <netinet/udp.h>
933 #endif
934 ])
935
936 AC_CHECK_MEMBERS([kstat_io_t.nwritten, kstat_io_t.writes, kstat_io_t.nwrites, kstat_io_t.wtime],
937         [],
938         [],
939         [
940 #if HAVE_KSTAT_H
941 # include <kstat.h>
942 #endif
943         ])
944
945 #
946 # Checks for libraries begin here
947 #
948 with_libresolv="yes"
949 AC_CHECK_LIB(resolv, res_search,
950 [
951         AC_DEFINE(HAVE_LIBRESOLV, 1, [Define to 1 if you have the 'resolv' library (-lresolv).])
952 ],
953 [with_libresolv="no"])
954 AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")
955
956 dnl Check for HAL (hardware abstraction library)
957 with_libhal="yes"
958 AC_CHECK_LIB(hal,libhal_device_property_exists,
959              [AC_DEFINE(HAVE_LIBHAL, 1, [Define to 1 if you have 'hal' library])],
960              [with_libhal="no"])
961 if test "x$with_libhal" = "xyes"; then
962         if test "x$PKG_CONFIG" != "x"; then
963                 BUILD_WITH_LIBHAL_CFLAGS="`pkg-config --cflags hal`"
964                 BUILD_WITH_LIBHAL_LIBS="`pkg-config --libs hal`"
965                 AC_SUBST(BUILD_WITH_LIBHAL_CFLAGS)
966                 AC_SUBST(BUILD_WITH_LIBHAL_LIBS)
967         fi
968 fi
969
970 m4_divert_once([HELP_WITH], [
971 collectd additional packages:])
972
973 # AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
974 librrd_cflags=""
975 librrd_ldflags=""
976 librrd_threadsafe="yes"
977 AC_ARG_WITH(rrdtool, [AS_HELP_STRING([--with-rrdtool@<:@=PREFIX@:>@], [Path to rrdtool.])],
978 [       if test "x$withval" != "xno" && test "x$withval" != "xyes"
979         then
980                 librrd_cflags="-I$withval/include"
981                 librrd_ldflags="-L$withval/lib"
982                 with_rrdtool="yes"
983         else
984                 with_rrdtool="$withval"
985         fi
986 ], [with_rrdtool="yes"])
987 if test "x$with_rrdtool" = "xyes"
988 then
989         SAVE_CPPFLAGS="$CPPFLAGS"
990         SAVE_LDFLAGS="$LDFLAGS"
991
992         CPPFLAGS="$CPPFLAGS $librrd_cflags"
993         LDFLAGS="$LDFLAGS $librrd_ldflags"
994
995         AC_CHECK_HEADERS(rrd.h,, [with_rrdtool="no (rrd.h not found)"])
996
997         CPPFLAGS="$SAVE_CPPFLAGS"
998         LDFLAGS="$SAVE_LDFLAGS"
999 fi
1000 if test "x$with_rrdtool" = "xyes"
1001 then
1002         SAVE_CPPFLAGS="$CPPFLAGS"
1003         SAVE_LDFLAGS="$LDFLAGS"
1004
1005         CPPFLAGS="$CPPFLAGS $librrd_cflags"
1006         LDFLAGS="$LDFLAGS $librrd_ldflags"
1007
1008         AC_CHECK_LIB(rrd_th, rrd_update_r,
1009         [with_rrdtool="yes"
1010          librrd_ldflags="$librrd_ldflags -lrrd_th -lm"
1011         ],
1012         [librrd_threadsafe="no"
1013          AC_CHECK_LIB(rrd, rrd_update,
1014          [with_rrdtool="yes"
1015           librrd_ldflags="$librrd_ldflags -lrrd -lm"
1016          ],
1017          [with_rrdtool="no (symbol 'rrd_update' not found)"],
1018          [-lm])
1019         ],
1020         [-lm])
1021
1022         CPPFLAGS="$SAVE_CPPFLAGS"
1023         LDFLAGS="$SAVE_LDFLAGS"
1024 fi
1025 if test "x$with_rrdtool" = "xyes"
1026 then
1027         BUILD_WITH_LIBRRD_CFLAGS="$librrd_cflags"
1028         BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
1029         AC_SUBST(BUILD_WITH_LIBRRD_CFLAGS)
1030         AC_SUBST(BUILD_WITH_LIBRRD_LDFLAGS)
1031 fi
1032 if test "x$librrd_threadsafe" = "xyes"
1033 then
1034         AC_DEFINE(HAVE_THREADSAFE_LIBRRD, 1, [Define to 1 if you have the threadsafe rrd library (-lrrd_th).])
1035 fi
1036
1037 AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
1038 [       if test "x$withval" != "xno" \
1039                 && test "x$withval" != "xyes"
1040         then
1041                 LDFLAGS="$LDFLAGS -L$withval/lib"
1042                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1043                 with_libpthread="yes"
1044         else
1045                 if test "x$withval" = "xno"
1046                 then
1047                         with_libpthread="no (disabled)"
1048                 fi
1049         fi
1050 ], [with_libpthread="yes"])
1051 if test "x$with_libpthread" = "xyes"
1052 then
1053         AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
1054 fi
1055 if test "x$with_libpthread" = "xyes"
1056 then
1057         AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
1058 fi
1059 if test "x$with_libpthread" = "xyes"
1060 then
1061         collect_pthread=1
1062 else
1063         collect_pthread=0
1064 fi
1065 AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
1066         [Wether or not to use pthread (POSIX threads) library])
1067 AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
1068
1069 if test "x$ac_system" = "xSolaris"
1070 then
1071         with_kstat="yes"
1072         with_devinfo="yes"
1073 else
1074         with_kstat="no (Solaris only)"
1075         with_devinfo="no (Solaris only)"
1076 fi
1077
1078 if test "x$with_kstat" = "xyes"
1079 then
1080         AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
1081 fi
1082 if test "x$with_kstat" = "xyes"
1083 then
1084         AC_CHECK_LIB(devinfo, di_init, [with_devinfo="yes"], [with_devinfo="no (not found)"], [])
1085         AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
1086 fi
1087 if test "x$with_kstat" = "xyes"
1088 then
1089         AC_DEFINE(HAVE_LIBKSTAT, 1,
1090                   [Define to 1 if you have the 'kstat' library (-lkstat)])
1091 fi
1092 AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
1093 AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
1094
1095 ### BEGIN of check for libcurl ###
1096 with_curl_config="curl-config"
1097 with_curl_cflags=""
1098 with_curl_libs=""
1099 AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
1100 [
1101         if test "x$withval" = "xno"
1102         then
1103                 with_libcurl="no"
1104         else if test "x$withval" = "xyes"
1105         then
1106                 with_libcurl="yes"
1107         else
1108                 if test -f "$withval" && test -x "$withval"
1109                 then
1110                         with_curl_config="$withval"
1111                         with_libcurl="yes"
1112                 else if test -x "$withval/bin/curl-config"
1113                 then
1114                         with_curl_config="$withval/bin/curl-config"
1115                         with_libcurl="yes"
1116                 fi; fi
1117                 with_libcurl="yes"
1118         fi; fi
1119 ],
1120 [
1121         with_libcurl="yes"
1122 ])
1123 if test "x$with_libcurl" = "xyes"
1124 then
1125         with_curl_cflags=`$with_curl_config --cflags 2>/dev/null`
1126         curl_config_status=$?
1127
1128         if test $curl_config_status -ne 0
1129         then
1130                 with_libcurl="no ($with_curl_config failed)"
1131         else
1132                 SAVE_CPPFLAGS="$CPPFLAGS"
1133                 CPPFLAGS="$CPPFLAGS $with_curl_cflags"
1134
1135                 AC_CHECK_HEADERS(curl/curl.h, [], [with_libcurl="no (curl/curl.h not found)"], [])
1136
1137                 CPPFLAGS="$SAVE_CPPFLAGS"
1138         fi
1139 fi
1140 if test "x$with_libcurl" = "xyes"
1141 then
1142         with_curl_libs=`$with_curl_config --libs 2>/dev/null`
1143         curl_config_status=$?
1144
1145         if test $curl_config_status -ne 0
1146         then
1147                 with_libcurl="no ($with_curl_config failed)"
1148         else
1149                 AC_CHECK_LIB(curl, curl_easy_init,
1150                  [with_libcurl="yes"],
1151                  [with_libcurl="no (symbol 'curl_easy_init' not found)"],
1152                  [$with_curl_libs])
1153         fi
1154 fi
1155 if test "x$with_libcurl" = "xyes"
1156 then
1157         BUILD_WITH_LIBCURL_CFLAGS="$with_curl_cflags"
1158         BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
1159         AC_SUBST(BUILD_WITH_LIBCURL_CFLAGS)
1160         AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
1161 fi
1162 AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
1163 ### END of check for libcurl ###
1164
1165 with_libiokit="no"
1166 AC_CHECK_LIB(IOKit, IOServiceGetMatchingServices,
1167 [
1168         with_libiokit="yes"
1169 ], 
1170 [
1171         with_libiokit="no"
1172 ])
1173 AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
1174
1175 with_libstatgrab_cflags=""
1176 with_libstatgrab_ldflags=""
1177 AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
1178 [
1179         if test "x$withval" != "xno" \
1180                 && test "x$withval" != "xyes"
1181         then
1182                 with_libstatgrab_cflags="-I$withval/include"
1183                 with_libstatgrab_ldflags="-L$withval/lib"
1184                 with_libstatgrab="yes"
1185         else
1186                 with_libstatgrab="$withval"
1187         fi
1188 ],
1189 [
1190         if test "x$ac_system" = "xunknown"
1191         then
1192                 with_libstatgrab="yes"
1193         else
1194                 with_libstatgrab="no"
1195         fi
1196 ])
1197 with_libstatgrab_pkg_config="yes"
1198 if test "x$with_libstatgrab" = "xyes" \
1199   && test "x$PKG_CONFIG" != "x"
1200 then
1201   AC_MSG_CHECKING([pkg-config for libstatgrab])
1202   temp_result="found"
1203   $PKG_CONFIG --exists libstatgrab 2>/dev/null
1204   if test "$?" != "0"
1205   then
1206     with_libstatgrab_pkg_config="no"
1207     temp_result="not found"
1208   fi
1209   AC_MSG_RESULT([$temp_result])
1210 else
1211   AC_MSG_NOTICE([pkg-config not available, trying to guess flags for the statgrab library.])
1212   with_libstatgrab_pkg_config="no"
1213   with_libstatgrab_ldflags="$with_libstatgrab_ldflags -lstatgrab"
1214 fi
1215
1216 if test "x$with_libstatgrab" = "xyes" \
1217   && test "x$with_libstatgrab_pkg_config" = "xyes" \
1218   && test "x$with_libstatgrab_cflags" = "x"
1219 then
1220   AC_MSG_CHECKING([for libstatgrab CFLAGS])
1221   temp_result="`$PKG_CONFIG --cflags libstatgrab`"
1222   if test "$?" = "0"
1223   then
1224     with_libstatgrab_cflags="$temp_result"
1225   else
1226     with_libstatgrab="no ($PKG_CONFIG --cflags libstatgrab failed)"
1227     temp_result="$PKG_CONFIG --cflags libstatgrab failed"
1228   fi
1229   AC_MSG_RESULT([$temp_result])
1230 fi
1231
1232 if test "x$with_libstatgrab" = "xyes" \
1233   && test "x$with_libstatgrab_pkg_config" = "xyes" \
1234   && test "x$with_libstatgrab_ldflags" = "x"
1235 then
1236   AC_MSG_CHECKING([for libstatgrab LDFLAGS])
1237   temp_result="`$PKG_CONFIG --libs libstatgrab`"
1238   if test "$?" = "0"
1239   then
1240     with_libstatgrab_ldflags="$temp_result"
1241   else
1242     with_libstatgrab="no ($PKG_CONFIG --libs libstatgrab failed)"
1243     temp_result="$PKG_CONFIG --libs libstatgrab failed"
1244   fi
1245   AC_MSG_RESULT([$temp_result])
1246 fi
1247
1248 if test "x$with_libstatgrab" = "xyes"
1249 then
1250   SAVE_CPPFLAGS="$CPPFLAGS"
1251   CPPFLAGS="$CPPFLAGS $with_libstatgrab_cflags"
1252
1253   AC_CHECK_HEADERS(statgrab.h,
1254                    [with_libstatgrab="yes"],
1255                    [with_libstatgrab="no (statgrab.h not found)"])
1256
1257   CPPFLAGS="$SAVE_CPPFLAGS"
1258 fi
1259
1260 if test "x$with_libstatgrab" = "xyes"
1261 then
1262   SAVE_CFLAGS="$CFLAGS"
1263   SAVE_LDFLAGS="$LDFLAGS"
1264
1265   CFLAGS="$CFLAGS $with_libstatgrab_cflags"
1266   LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
1267
1268   AC_CHECK_LIB(statgrab, sg_init,
1269                [with_libstatgrab="yes"],
1270                [with_libstatgrab="no (symbol sg_init not found)"])
1271
1272   CFLAGS="$SAVE_CFLAGS"
1273   LDFLAGS="$SAVE_LDFLAGS"
1274 fi
1275
1276 AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
1277 if test "x$with_libstatgrab" = "xyes"
1278 then
1279   AC_DEFINE(HAVE_LIBSTATGRAB, 1, [Define to 1 if you have the 'statgrab' library (-lstatgrab)])
1280   BUILD_WITH_LIBSTATGRAB_CFLAGS="$with_libstatgrab_cflags"
1281   BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
1282   AC_SUBST(BUILD_WITH_LIBSTATGRAB_CFLAGS)
1283   AC_SUBST(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
1284 fi
1285
1286 with_libkvm="no"
1287 AC_CHECK_LIB(kvm, kvm_getprocs, [with_kvm_getprocs="yes"], [with_kvm_getprocs="no"])
1288 if test "x$with_kvm_getprocs" = "xyes"
1289 then
1290         AC_DEFINE(HAVE_LIBKVM_GETPROCS, 1,
1291                   [Define to 1 if you have the 'kvm' library with the 'kvm_getprocs' symbol (-lkvm)])
1292         with_libkvm="yes"
1293 fi
1294 AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETPROCS, test "x$with_kvm_getprocs" = "xyes")
1295
1296 AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_kvm_getswapinfo="yes"], [with_kvm_getswapinfo="no"])
1297 if test "x$with_kvm_getswapinfo" = "xyes"
1298 then
1299         AC_DEFINE(HAVE_LIBKVM_GETSWAPINFO, 1,
1300                   [Define to 1 if you have the 'kvm' library with the 'kvm_getswapinfo' symbol (-lkvm)])
1301         with_libkvm="yes"
1302 fi
1303 AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETSWAPINFO, test "x$with_kvm_getswapinfo" = "xyes")
1304
1305 AC_CHECK_LIB(kvm, kvm_nlist, [with_kvm_nlist="yes"], [with_kvm_nlist="no"])
1306 if test "x$with_kvm_nlist" = "xyes"
1307 then
1308         AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
1309                   [Define to 1 if you have the 'kvm' library with the 'kvm_nlist' symbol (-lkvm)])
1310         with_libkvm="yes"
1311 fi
1312 AM_CONDITIONAL(BUILD_WITH_LIBKVM_NLIST, test "x$with_kvm_nlist" = "xyes")
1313
1314 AC_CHECK_LIB(kvm, kvm_openfiles, [with_kvm_openfiles="yes"], [with_kvm_openfiles="no"])
1315 if test "x$with_kvm_openfiles" = "xyes"
1316 then
1317         AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
1318                   [Define to 1 if you have the 'kvm' library with the 'kvm_openfiles' symbol (-lkvm)])
1319         with_libkvm="yes"
1320 fi
1321 AM_CONDITIONAL(BUILD_WITH_LIBKVM_OPENFILES, test "x$with_kvm_openfiles" = "xyes")
1322
1323 with_sensors_cflags=""
1324 with_sensors_ldflags=""
1325 AC_ARG_WITH(lm-sensors, [AS_HELP_STRING([--with-lm-sensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
1326 [
1327         if test "x$withval" = "xno"
1328         then
1329                 with_lm_sensors="no"
1330         else
1331                 with_lm_sensors="yes"
1332                 if test "x$withval" != "xyes"
1333                 then
1334                         with_sensors_cflags="-I$withval/include"
1335                         with_sensors_ldflags="-L$withval/lib"
1336                         with_lm_sensors="yes"
1337                 fi
1338         fi
1339 ],
1340 [
1341         if test "x$ac_system" = "xLinux"
1342         then
1343                 with_lm_sensors="yes"
1344         else
1345                 with_lm_sensors="no (Linux only library)"
1346         fi
1347 ])
1348 if test "x$with_lm_sensors" = "xyes"
1349 then
1350         SAVE_CPPFLAGS="$CPPFLAGS"
1351         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
1352
1353 #       AC_CHECK_HEADERS(sensors/sensors.h,
1354 #       [
1355 #               AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
1356 #       ],
1357 #       [with_lm_sensors="no (sensors/sensors.h not found)"])
1358         AC_CHECK_HEADERS(sensors/sensors.h, [], [with_lm_sensors="no (sensors/sensors.h not found)"])
1359
1360         CPPFLAGS="$SAVE_CPPFLAGS"
1361 fi
1362 if test "x$with_lm_sensors" = "xyes"
1363 then
1364         SAVE_CPPFLAGS="$CPPFLAGS"
1365         SAVE_LDFLAGS="$LDFLAGS"
1366         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
1367         LDFLAGS="$LDFLAGS $with_sensors_ldflags"
1368
1369         AC_CHECK_LIB(sensors, sensors_init,
1370         [
1371                 AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
1372         ],
1373         [with_lm_sensors="no (libsensors not found)"])
1374
1375         CPPFLAGS="$SAVE_CPPFLAGS"
1376         LDFLAGS="$SAVE_LDFLAGS"
1377 fi
1378 if test "x$with_lm_sensors" = "xyes"
1379 then
1380         BUILD_WITH_LIBSENSORS_CFLAGS="$with_sensors_cflags"
1381         BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
1382         AC_SUBST(BUILD_WITH_LIBSENSORS_CFLAGS)
1383         AC_SUBST(BUILD_WITH_LIBSENSORS_LDFLAGS)
1384 fi
1385 AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_lm_sensors" = "xyes")
1386
1387 with_mysql_config="mysql_config"
1388 with_mysql_cflags=""
1389 with_mysql_libs=""
1390 AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
1391 [
1392         if test "x$withval" = "xno"
1393         then
1394                 with_libmysql="no"
1395         else if test "x$withval" = "xyes"
1396         then
1397                 with_libmysql="yes"
1398         else
1399                 if test -f "$withval" && test -x "$withval";
1400                 then
1401                         with_mysql_config="$withval"
1402                 else if test -x "$withval/bin/mysql_config"
1403                 then
1404                         with_mysql_config="$withval/bin/mysql_config"
1405                 fi; fi
1406                 with_libmysql="yes"
1407         fi; fi
1408 ],
1409 [
1410         with_libmysql="yes"
1411 ])
1412 if test "x$with_libmysql" = "xyes"
1413 then
1414         with_mysql_cflags=`$with_mysql_config --cflags 2>/dev/null`
1415         mysql_config_status=$?
1416
1417         if test $mysql_config_status -ne 0
1418         then
1419                 with_libmysql="no ($with_mysql_config failed)"
1420         else
1421                 SAVE_CPPFLAGS="$CPPFLAGS"
1422                 CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
1423
1424                 have_mysql_h="no"
1425                 have_mysql_mysql_h="no"
1426                 AC_CHECK_HEADERS(mysql.h, [have_mysql_h="yes"])
1427
1428                 if test "x$have_mysql_h" = "xno"
1429                 then
1430                         AC_CHECK_HEADERS(mysql/mysql.h, [have_mysql_mysql_h="yes"])
1431                 fi
1432
1433                 if test "x$have_mysql_h$have_mysql_mysql_h" = "xnono"
1434                 then
1435                         with_libmysql="no (mysql.h not found)"
1436                 fi
1437
1438                 CPPFLAGS="$SAVE_CPPFLAGS"
1439         fi
1440 fi
1441 if test "x$with_libmysql" = "xyes"
1442 then
1443         with_mysql_libs=`$with_mysql_config --libs 2>/dev/null`
1444         mysql_config_status=$?
1445
1446         if test $mysql_config_status -ne 0
1447         then
1448                 with_libmysql="no ($with_mysql_config failed)"
1449         else
1450                 AC_CHECK_LIB(mysqlclient, mysql_init,
1451                  [with_libmysql="yes"],
1452                  [with_libmysql="no (symbol 'mysql_init' not found)"],
1453                  [$with_mysql_libs])
1454
1455                 AC_CHECK_LIB(mysqlclient, mysql_get_server_version,
1456                  [with_libmysql="yes"],
1457                  [with_libmysql="no (symbol 'mysql_get_server_version' not found)"],
1458                  [$with_mysql_libs])
1459         fi
1460 fi
1461 if test "x$with_libmysql" = "xyes"
1462 then
1463         BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
1464         BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
1465         AC_SUBST(BUILD_WITH_LIBMYSQL_CFLAGS)
1466         AC_SUBST(BUILD_WITH_LIBMYSQL_LIBS)
1467 fi
1468 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
1469
1470 with_own_liboconfig="no"
1471 liboconfig_LDFLAGS="$LDFLAGS"
1472 liboconfig_CPPFLAGS="$CPPFLAGS"
1473 AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
1474 [
1475         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1476         then
1477                 if test -d "$withval/lib"
1478                 then
1479                         liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
1480                 fi
1481                 if test -d "$withval/include"
1482                 then
1483                         liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
1484                 fi
1485         fi
1486         if test "x$withval" = "xno"
1487         then
1488                 AC_MSG_ERROR("liboconfig is required")
1489         fi
1490 ],
1491 [
1492         with_liboconfig="yes"
1493 ])
1494
1495 save_LDFLAGS="$LDFLAGS"
1496 save_CPPFLAGS="$CPPFLAGS"
1497 LDFLAGS="$liboconfig_LDFLAGS"
1498 CPPFLAGS="$liboconfig_CPPFLAGS"
1499 AC_CHECK_LIB(oconfig, oconfig_parse_fh,
1500 [
1501         with_liboconfig="yes"
1502         with_own_liboconfig="no"
1503 ],
1504 [
1505         with_liboconfig="yes"
1506         with_own_liboconfig="yes"
1507         LDFLAGS="$save_LDFLAGS"
1508         CPPFLAGS="$save_CPPFLAGS"
1509 ])
1510
1511 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
1512 if test "x$with_own_liboconfig" = "xyes"
1513 then
1514         with_liboconfig="yes (shipped version)"
1515 fi
1516
1517 #with_liboping="yes"
1518 with_own_liboping="no"
1519 liboping_LDFLAGS="$LDFLAGS"
1520 liboping_CPPFLAGS="$CPPFLAGS"
1521 AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
1522 [
1523         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1524         then
1525                 if test -d "$withval/lib"
1526                 then
1527                         liboping_LDFLAGS="$LDFLAGS -L$withval/lib"
1528                 fi
1529                 if test -d "$withval/include"
1530                 then
1531                         liboping_CPPFLAGS="$CPPFLAGS -I$withval/include"
1532                 fi
1533         fi
1534         if test "x$withval" = "xno"
1535         then
1536                 with_liboping="no"
1537                 with_own_liboping="no"
1538         else if test "x$withval" = "xyes"
1539         then
1540                 with_liboping="yes"
1541         fi; fi
1542 ],
1543 [
1544         with_liboping="yes"
1545 ])
1546
1547 if test "x$with_liboping" = "xyes"
1548 then
1549         save_LDFLAGS="$LDFLAGS"
1550         save_CPPFLAGS="$CPPFLAGS"
1551         LDFLAGS="$liboping_LDFLAGS"
1552         CPPFLAGS="$liboping_CPPFLAGS"
1553         AC_CHECK_LIB(oping, ping_construct,
1554         [
1555                 with_liboping="yes"
1556                 with_own_liboping="no"
1557         ],
1558         [
1559                 with_liboping="yes"
1560                 with_own_liboping="yes"
1561                 LDFLAGS="$save_LDFLAGS"
1562                 CPPFLAGS="$save_CPPFLAGS"
1563         ])
1564 fi
1565 AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
1566 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOPING, test "x$with_own_liboping" = "xyes")
1567
1568 with_libowcapi_cppflags=""
1569 with_libowcapi_libs="-lowcapi"
1570 AC_ARG_WITH(libowcapi, [AS_HELP_STRING([--with-libowcapi@<:@=PREFIX@:>@], [Path to libowcapi.])],
1571 [
1572         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1573         then
1574                 with_libowcapi_cppflags="-I$withval/include"
1575                 with_libowcapi_libs="-L$withval/lib -lowcapi"
1576                 with_libowcapi="yes"
1577         else
1578                 with_libowcapi="$withval"
1579         fi
1580 ],
1581 [
1582         with_libowcapi="yes"
1583 ])
1584 if test "x$with_libowcapi" = "xyes"
1585 then
1586         SAVE_CPPFLAGS="$CPPFLAGS"
1587         CPPFLAGS="$with_libowcapi_cppflags"
1588         
1589         AC_CHECK_HEADERS(owcapi.h, [with_libowcapi="yes"], [with_libowcapi="no (owcapi.h not found)"])
1590
1591         CPPFLAGS="$SAVE_CPPFLAGS"
1592 fi
1593 if test "x$with_libowcapi" = "xyes"
1594 then
1595         SAVE_LDFLAGS="$LDFLAGS"
1596         SAVE_CPPFLAGS="$CPPFLAGS"
1597         LDFLAGS="$with_libowcapi_libs"
1598         CPPFLAGS="$with_libowcapi_cppflags"
1599         
1600         AC_CHECK_LIB(owcapi, OW_get, [with_libowcapi="yes"], [with_libowcapi="no (libowcapi not found)"])
1601
1602         LDFLAGS="$SAVE_LDFLAGS"
1603         CPPFLAGS="$SAVE_CPPFLAGS"
1604 fi
1605 if test "x$with_libowcapi" = "xyes"
1606 then
1607         BUILD_WITH_LIBOWCAPI_CPPFLAGS="$with_libowcapi_cppflags"
1608         BUILD_WITH_LIBOWCAPI_LIBS="$with_libowcapi_libs"
1609         AC_SUBST(BUILD_WITH_LIBOWCAPI_CPPFLAGS)
1610         AC_SUBST(BUILD_WITH_LIBOWCAPI_LIBS)
1611 fi
1612
1613
1614 AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
1615 [
1616         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1617         then
1618                 LDFLAGS="$LDFLAGS -L$withval/lib"
1619                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1620                 with_libpcap="yes"
1621         else
1622                 with_libpcap="$withval"
1623         fi
1624 ],
1625 [
1626         with_libpcap="yes"
1627 ])
1628 if test "x$with_libpcap" = "xyes"
1629 then
1630         AC_CHECK_LIB(pcap, pcap_open_live,
1631         [
1632                 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
1633         ], [with_libpcap="no (libpcap not found)"])
1634 fi
1635 if test "x$with_libpcap" = "xyes"
1636 then
1637         AC_CHECK_HEADERS(pcap.h,
1638         [
1639                 AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
1640         ], [with_libpcap="no (pcap.h not found)"])
1641 fi
1642 if test "x$with_libpcap" = "xyes"
1643 then
1644         collect_libpcap=1
1645 else
1646         collect_libpcap=0
1647 fi
1648 AC_DEFINE_UNQUOTED(COLLECT_LIBPCAP, [$collect_libpcap],
1649         [Wether or not to use the pcap library])
1650 AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
1651
1652 AC_ARG_WITH(libesmtp, [AS_HELP_STRING([--with-libesmtp@<:@=PREFIX@:>@], [Path to libesmtp.])],
1653 [
1654         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1655         then
1656                 LDFLAGS="$LDFLAGS -L$withval/lib"
1657                 CPPFLAGS="$CPPFLAGS -I$withval/include -D_THREAD_SAFE"
1658                 with_libesmtp="yes"
1659         else
1660                 with_libesmtp="$withval"
1661         fi
1662 ],
1663 [
1664         with_libesmtp="yes"
1665 ])
1666 if test "x$with_libesmtp" = "xyes"
1667 then
1668         AC_CHECK_LIB(esmtp, smtp_create_session,
1669         [
1670                 AC_DEFINE(HAVE_LIBESMTP, 1, [Define to 1 if you have the esmtp library (-lesmtp).])
1671         ], [with_libesmtp="no (libesmtp not found)"])
1672 fi
1673 if test "x$with_libesmtp" = "xyes"
1674 then
1675         AC_CHECK_HEADERS(libesmtp.h,
1676         [
1677                 AC_DEFINE(HAVE_LIBESMTP_H, 1, [Define to 1 if you have the <libesmtp.h> header file.])
1678         ], [with_libesmtp="no (libesmtp.h not found)"])
1679 fi
1680 if test "x$with_libesmtp" = "xyes"
1681 then
1682         collect_libesmtp=1
1683 else
1684         collect_libesmtp=0
1685 fi
1686 AC_DEFINE_UNQUOTED(COLLECT_LIBESMTP, [$collect_libesmtp],
1687         [Wether or not to use the esmtp library])
1688 AM_CONDITIONAL(BUILD_WITH_LIBESMTP, test "x$with_libesmtp" = "xyes")
1689
1690 perl_interpreter="perl"
1691 AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
1692 [
1693         if test -x "$withval"
1694         then
1695                 perl_interpreter="$withval"
1696                 with_libperl="yes"
1697         else if test "x$withval" != "xno" && test "x$withval" != "xyes"
1698         then
1699                 LDFLAGS="$LDFLAGS -L$withval/lib"
1700                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1701                 perl_interpreter="$withval/bin/perl"
1702                 with_libperl="yes"
1703         else
1704                 with_libperl="$withval"
1705         fi; fi
1706 ],
1707 [
1708         with_libperl="yes"
1709 ])
1710
1711 AC_MSG_CHECKING([for perl])
1712 perl_interpreter=`which "$perl_interpreter" 2> /dev/null`
1713 if test -x "$perl_interpreter"
1714 then
1715         AC_MSG_RESULT([yes ($perl_interpreter)])
1716 else
1717         perl_interpreter=""
1718         AC_MSG_RESULT([no])
1719 fi
1720
1721 AC_SUBST(PERL, "$perl_interpreter")
1722
1723 if test "x$with_libperl" = "xyes" \
1724         && test -n "$perl_interpreter"
1725 then
1726   SAVE_CFLAGS=$CFLAGS
1727   SAVE_LDFLAGS=$LDFLAGS
1728 dnl ARCHFLAGS="" -> disable multi -arch on OSX (see Config_heavy.pl:fetch_string)
1729   PERL_CFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ccopts`
1730   PERL_LDFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ldopts`
1731   CFLAGS="$CFLAGS $PERL_CFLAGS"
1732   LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
1733
1734   AC_CACHE_CHECK([for libperl],
1735     [c_cv_have_libperl],
1736     AC_LINK_IFELSE(
1737       AC_LANG_PROGRAM(
1738       [[
1739 #define PERL_NO_GET_CONTEXT
1740 #include <EXTERN.h>
1741 #include <perl.h>
1742 #include <XSUB.h>
1743       ]],
1744       [[
1745        dTHX;
1746        load_module (PERL_LOADMOD_NOIMPORT,
1747                          newSVpv ("Collectd::Plugin::FooBar", 24),
1748                          Nullsv);
1749       ]]),
1750       [c_cv_have_libperl="yes"],
1751       [c_cv_have_libperl="no"]
1752     )
1753   )
1754
1755   if test "x$c_cv_have_libperl" = "xyes"
1756   then
1757           AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
1758           AC_SUBST(PERL_CFLAGS)
1759           AC_SUBST(PERL_LDFLAGS)
1760   else
1761           with_libperl="no"
1762   fi
1763
1764   CFLAGS=$SAVE_CFLAGS
1765   LDFLAGS=$SAVE_LDFLAGS
1766 else if test -z "$perl_interpreter"; then
1767   with_libperl="no (no perl interpreter found)"
1768   c_cv_have_libperl="no"
1769 fi; fi
1770 AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")
1771
1772 if test "x$with_libperl" = "xyes"
1773 then
1774         SAVE_CFLAGS=$CFLAGS
1775         SAVE_LDFLAGS=$LDFLAGS
1776         CFLAGS="$CFLAGS $PERL_CFLAGS"
1777         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
1778
1779         AC_CACHE_CHECK([if perl supports ithreads],
1780                 [c_cv_have_perl_ithreads],
1781                 AC_LINK_IFELSE(
1782                         AC_LANG_PROGRAM(
1783                         [[
1784 #include <EXTERN.h>
1785 #include <perl.h>
1786 #include <XSUB.h>
1787
1788 #if !defined(USE_ITHREADS)
1789 # error "Perl does not support ithreads!"
1790 #endif /* !defined(USE_ITHREADS) */
1791                         ]],
1792                         [[ ]]),
1793                         [c_cv_have_perl_ithreads="yes"],
1794                         [c_cv_have_perl_ithreads="no"]
1795                 )
1796         )
1797
1798         if test "x$c_cv_have_perl_ithreads" = "xyes"
1799         then
1800                 AC_DEFINE(HAVE_PERL_ITHREADS, 1, [Define if Perl supports ithreads.])
1801         fi
1802
1803         CFLAGS=$SAVE_CFLAGS
1804         LDFLAGS=$SAVE_LDFLAGS
1805 fi
1806
1807 with_own_libiptc="no"
1808 AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
1809 [
1810         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1811         then
1812                 LDFLAGS="$LDFLAGS -L$withval/lib"
1813                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1814                 with_libiptc="yes"
1815         else
1816                 with_libiptc="$withval"
1817         fi
1818 ],
1819 [
1820         if test "x$ac_system" = "xLinux"
1821         then
1822                 with_libiptc="yes"
1823         else
1824                 with_libiptc="no (Linux only)"
1825         fi
1826 ])
1827 if test "x$with_libiptc" = "xyes"
1828 then
1829         AC_CHECK_LIB(iptc, iptc_init,
1830         [
1831                 AC_DEFINE(HAVE_LIBIPTC, 1, [Define to 1 if you have the iptc library (-liptc).])
1832         ],
1833         [
1834                 with_libiptc="yes"
1835                 with_own_libiptc="yes"
1836         ])
1837 fi
1838 if test "x$with_libiptc" = "xyes" -a "x$with_own_libiptc" != "xyes"
1839 then
1840         AC_CHECK_HEADERS(libiptc/libiptc.h,
1841         [
1842                 AC_DEFINE(HAVE_LIBIPTC_LIBIPTC_H, 1, [Define to 1 if you have the <libiptc/libiptc.h> header file.])
1843         ],
1844         [
1845                 with_libiptc="yes"
1846                 with_own_libiptc="yes"
1847         ])
1848 fi
1849 if test "x$with_libiptc" = "xyes"
1850 then
1851         SAVE_CFLAGS=$CFLAGS
1852         CFLAGS="$CFLAGS $KERNEL_CFLAGS"
1853
1854         AC_CHECK_HEADERS(linux/netfilter_ipv4/ip_tables.h linux/netfilter_ipv6/ip6_tables.h, [],
1855         [
1856                 with_libiptc="no (Linux iptables headers not found - check KERNEL_DIR)"
1857                 with_own_libiptc="no"
1858         ],
1859         [
1860 #include "$srcdir/src/libiptc/ipt_kernel_headers.h"
1861         ])
1862
1863         CFLAGS=$SAVE_CFLAGS
1864 fi
1865 AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
1866 AM_CONDITIONAL(BUILD_WITH_OWN_LIBIPTC, test "x$with_own_libiptc" = "xyes")
1867 if test "x$with_own_libiptc" = "xyes"
1868 then
1869         AC_DEFINE(OWN_LIBIPTC, 1, [Define to 1 if we use the shipped iptc library.])
1870 fi
1871
1872 with_snmp_config="net-snmp-config"
1873 with_snmp_cflags=""
1874 with_snmp_libs=""
1875 AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
1876 [
1877         if test "x$withval" = "xno"
1878         then
1879                 with_libnetsnmp="no"
1880         else if test "x$withval" = "xyes"
1881         then
1882                 with_libnetsnmp="yes"
1883         else
1884                 if test -x "$withval"
1885                 then
1886                         with_snmp_config="$withval"
1887                         with_libnetsnmp="yes"
1888                 else
1889                         with_snmp_config="$withval/bin/net-snmp-config"
1890                         with_libnetsnmp="yes"
1891                 fi
1892         fi; fi
1893 ],
1894 [with_libnetsnmp="yes"])
1895 if test "x$with_libnetsnmp" = "xyes"
1896 then
1897         with_snmp_cflags=`$with_snmp_config --cflags 2>/dev/null`
1898         snmp_config_status=$?
1899
1900         if test $snmp_config_status -ne 0
1901         then
1902                 with_libnetsnmp="no ($with_snmp_config failed)"
1903         else
1904                 SAVE_CPPFLAGS="$CPPFLAGS"
1905                 CPPFLAGS="$CPPFLAGS $with_snmp_cflags"
1906                 
1907                 AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
1908
1909                 CPPFLAGS="$SAVE_CPPFLAGS"
1910         fi
1911 fi
1912 if test "x$with_libnetsnmp" = "xyes"
1913 then
1914         with_snmp_libs=`$with_snmp_config --libs 2>/dev/null`
1915         snmp_config_status=$?
1916
1917         if test $snmp_config_status -ne 0
1918         then
1919                 with_libnetsnmp="no ($with_snmp_config failed)"
1920         else
1921                 AC_CHECK_LIB(netsnmp, init_snmp,
1922                 [with_libnetsnmp="yes"],
1923                 [with_libnetsnmp="no (libnetsnmp not found)"],
1924                 [$with_snmp_libs])
1925         fi
1926 fi
1927 if test "x$with_libnetsnmp" = "xyes"
1928 then
1929         BUILD_WITH_LIBSNMP_CFLAGS="$with_snmp_cflags"
1930         BUILD_WITH_LIBSNMP_LIBS="$with_snmp_libs"
1931         AC_SUBST(BUILD_WITH_LIBSNMP_CFLAGS)
1932         AC_SUBST(BUILD_WITH_LIBSNMP_LIBS)
1933 fi
1934 AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")
1935
1936 PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
1937                 [with_libnotify="yes"],
1938                 [with_libnotify="no ($LIBNOTIFY_PKG_ERRORS)"])
1939
1940 with_libupsclient_config=""
1941 with_libupsclient_cflags=""
1942 with_libupsclient_libs=""
1943 AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
1944 [
1945         if test "x$withval" = "xno"
1946         then
1947                 with_libupsclient="no"
1948         else if test "x$withval" = "xyes"
1949         then
1950                 with_libupsclient="use_pkgconfig"
1951         else
1952                 if test -x "$withval"
1953                 then
1954                         with_libupsclient_config="$withval"
1955                         with_libupsclient="use_libupsclient_config"
1956                 else if test -x "$withval/bin/libupsclient-config"
1957                 then
1958                         with_libupsclient_config="$withval/bin/net-snmp-config"
1959                         with_libupsclient="use_libupsclient_config"
1960                 else
1961                         AC_MSG_NOTICE([Not checking for libupsclient: Manually configured])
1962                         with_libupsclient_cflags="-I$withval/include"
1963                         with_libupsclient_libs="-L$withval/lib -lupsclient"
1964                         with_libupsclient="yes"
1965                 fi; fi
1966         fi; fi
1967 ],
1968 [with_libupsclient="use_pkgconfig"])
1969
1970 # configure using libupsclient-config
1971 if test "x$with_libupsclient" = "xuse_libupsclient_config"
1972 then
1973         AC_MSG_NOTICE([Checking for libupsclient using $with_libupsclient_config])
1974         with_libupsclient_cflags="`$with_libupsclient_config --cflags`"
1975         if test $? -ne 0
1976         then
1977                 with_libupsclient="no ($with_libupsclient_config failed)"
1978         fi
1979         with_libupsclient_libs="`$with_libupsclient_config --libs`"
1980         if test $? -ne 0
1981         then
1982                 with_libupsclient="no ($with_libupsclient_config failed)"
1983         fi
1984 fi
1985 if test "x$with_libupsclient" = "xuse_libupsclient_config"
1986 then
1987         with_libupsclient="yes"
1988 fi
1989
1990 # configure using pkg-config
1991 if test "x$with_libupsclient" = "xuse_pkgconfig"
1992 then
1993         if test "x$PKG_CONFIG" = "x"
1994         then
1995                 with_libupsclient="no (Don't have pkg-config)"
1996         fi
1997 fi
1998 if test "x$with_libupsclient" = "xuse_pkgconfig"
1999 then
2000         AC_MSG_NOTICE([Checking for libupsclient using $PKG_CONFIG])
2001         $PKG_CONFIG --exists 'libupsclient' 2>/dev/null
2002         if test $? -ne 0
2003         then
2004                 with_libupsclient="no (pkg-config doesn't know library)"
2005         fi
2006 fi
2007 if test "x$with_libupsclient" = "xuse_pkgconfig"
2008 then
2009         with_libupsclient_cflags="`$PKG_CONFIG --cflags 'libupsclient'`"
2010         if test $? -ne 0
2011         then
2012                 with_libupsclient="no ($PKG_CONFIG failed)"
2013         fi
2014         with_libupsclient_libs="`$PKG_CONFIG --libs 'libupsclient'`"
2015         if test $? -ne 0
2016         then
2017                 with_libupsclient="no ($PKG_CONFIG failed)"
2018         fi
2019 fi
2020 if test "x$with_libupsclient" = "xuse_pkgconfig"
2021 then
2022         with_libupsclient="yes"
2023 fi
2024
2025 # with_libupsclient_cflags and with_libupsclient_libs are set up now, let's do
2026 # the actual checks.
2027 if test "x$with_libupsclient" = "xyes"
2028 then
2029         SAVE_CPPFLAGS="$CPPFLAGS"
2030         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
2031
2032         AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])
2033
2034         CPPFLAGS="$SAVE_CPPFLAGS"
2035 fi
2036 if test "x$with_libupsclient" = "xyes"
2037 then
2038         SAVE_CPPFLAGS="$CPPFLAGS"
2039         SAVE_LDFLAGS="$LDFLAGS"
2040
2041         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
2042         LDFLAGS="$LDFLAGS $with_libupsclient_libs"
2043
2044         AC_CHECK_LIB(upsclient, upscli_connect,
2045                      [with_libupsclient="yes"],
2046                      [with_libupsclient="no (symbol upscli_connect not found)"])
2047
2048         CPPFLAGS="$SAVE_CPPFLAGS"
2049         LDFLAGS="$SAVE_LDFLAGS"
2050 fi
2051 if test "x$with_libupsclient" = "xyes"
2052 then
2053         SAVE_CPPFLAGS="$CPPFLAGS"
2054         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
2055
2056         AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [],
2057 [#include <stdlib.h>
2058 #include <stdio.h>
2059 #include <upsclient.h>])
2060
2061         CPPFLAGS="$SAVE_CPPFLAGS"
2062 fi
2063 if test "x$with_libupsclient" = "xyes"
2064 then
2065         BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_libupsclient_cflags"
2066         BUILD_WITH_LIBUPSCLIENT_LIBS="$with_libupsclient_libs"
2067         AC_SUBST(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
2068         AC_SUBST(BUILD_WITH_LIBUPSCLIENT_LIBS)
2069 fi
2070
2071 ### BEGIN of check for libxmms ###
2072 with_xmms_config="xmms-config"
2073 with_xmms_cflags=""
2074 with_xmms_libs=""
2075 AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
2076 [
2077         if test "x$withval" != "xno" \
2078                 && test "x$withval" != "xyes"
2079         then
2080                 if test -f "$withval" && test -x "$withval";
2081                 then
2082                         with_xmms_config="$withval"
2083                 else if test -x "$withval/bin/xmms-config"
2084                 then
2085                         with_xmms_config="$withval/bin/xmms-config"
2086                 fi; fi
2087                 with_libxmms="yes"
2088         else if test "x$withval" = "xno"
2089         then
2090                 with_libxmms="no"
2091         else
2092                 with_libxmms="yes"
2093         fi; fi
2094 ],
2095 [
2096         with_libxmms="yes"
2097 ])
2098 if test "x$with_libxmms" = "xyes"
2099 then
2100         with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
2101         xmms_config_status=$?
2102
2103         if test $xmms_config_status -ne 0
2104         then
2105                 with_libxmms="no"
2106         fi
2107 fi
2108 if test "x$with_libxmms" = "xyes"
2109 then
2110         with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
2111         xmms_config_status=$?
2112
2113         if test $xmms_config_status -ne 0
2114         then
2115                 with_libxmms="no"
2116         fi
2117 fi
2118 if test "x$with_libxmms" = "xyes"
2119 then
2120         AC_CHECK_LIB(xmms, xmms_remote_get_info,
2121         [
2122                 BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
2123                 BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
2124                 AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
2125                 AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
2126         ],
2127         [
2128                 with_libxmms="no"
2129         ],
2130         [$with_xmms_libs])
2131 fi
2132 with_libxmms_numeric=0
2133 if test "x$with_libxmms" = "xyes"
2134 then
2135         with_libxmms_numeric=1
2136 fi
2137 AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
2138 AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
2139 ### END of check for libxmms ###
2140
2141 with_libnetlink_cflags=""
2142 with_libnetlink_libs="-lnetlink"
2143 AC_ARG_WITH(libnetlink, [AS_HELP_STRING([--with-libnetlink@<:@=PREFIX@:>@], [Path to libnetlink.])],
2144 [
2145  echo "libnetlink: withval = $withval"
2146  if test "x$withval" = "xyes"
2147  then
2148          with_libnetlink="yes"
2149  else if test "x$withval" = "xno"
2150  then
2151          with_libnetlink="no"
2152  else
2153          if test -d "$withval/include"
2154          then
2155                  with_libnetlink_cflags="-I$withval/include"
2156                  with_libnetlink_libs="-L$withval/lib -lnetlink"
2157                  with_libnetlink="yes"
2158          else
2159                  AC_MSG_ERROR("no such directory: $withval/include")
2160          fi
2161  fi; fi
2162 ],
2163 [
2164  if test "x$ac_system" = "xLinux"
2165  then
2166          with_libnetlink="yes"
2167  else
2168          with_libnetlink="no (Linux only library)"
2169  fi
2170 ])
2171 if test "x$with_libnetlink" = "xyes"
2172 then
2173         SAVE_CFLAGS=$CFLAGS
2174         CFLAGS="$CFLAGS $with_libnetlink_cflags"
2175
2176         with_libnetlink="no (libnetlink.h not found)"
2177
2178         AC_CHECK_HEADERS(libnetlink.h iproute/libnetlink.h linux/libnetlink.h,
2179         [
2180          with_libnetlink="yes"
2181          break
2182         ], [],
2183 [#include <stdio.h>
2184 #include <sys/types.h>
2185 #include <asm/types.h>
2186 #include <sys/socket.h>
2187 #include <linux/netlink.h>
2188 #include <linux/rtnetlink.h>])
2189         AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
2190 [#include <stdio.h>
2191 #include <sys/types.h>
2192 #include <asm/types.h>
2193 #include <sys/socket.h>])
2194
2195         AC_COMPILE_IFELSE(
2196 [#include <stdio.h>
2197 #include <sys/types.h>
2198 #include <asm/types.h>
2199 #include <sys/socket.h>
2200 #include <linux/netlink.h>
2201 #include <linux/rtnetlink.h>
2202
2203 int main (void)
2204 {
2205         int retval = TCA_STATS2;
2206         return (retval);
2207 }],
2208         [AC_DEFINE([HAVE_TCA_STATS2], 1, [True if the enum-member TCA_STATS2 exists])]
2209         []);
2210
2211         AC_COMPILE_IFELSE(
2212 [#include <stdio.h>
2213 #include <sys/types.h>
2214 #include <asm/types.h>
2215 #include <sys/socket.h>
2216 #include <linux/netlink.h>
2217 #include <linux/rtnetlink.h>
2218
2219 int main (void)
2220 {
2221         int retval = TCA_STATS;
2222         return (retval);
2223 }],
2224         [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
2225         []);
2226
2227         CFLAGS="$SAVE_CFLAGS"
2228 fi
2229 if test "x$with_libnetlink" = "xyes"
2230 then
2231         AC_CHECK_LIB(netlink, rtnl_open,
2232                      [with_libnetlink="yes"],
2233                      [with_libnetlink="no (symbol 'rtnl_open' not found)"],
2234                      [$with_libnetlink_libs])
2235 fi
2236 if test "x$with_libnetlink" = "xyes"
2237 then
2238         BUILD_WITH_LIBNETLINK_CFLAGS="$with_libnetlink_cflags"
2239         BUILD_WITH_LIBNETLINK_LIBS="$with_libnetlink_libs"
2240         AC_SUBST(BUILD_WITH_LIBNETLINK_CFLAGS)
2241         AC_SUBST(BUILD_WITH_LIBNETLINK_LIBS)
2242 fi
2243 AM_CONDITIONAL(BUILD_WITH_LIBNETLINK, test "x$with_libnetlink" = "xyes")
2244
2245 with_libopenipmipthread="yes"
2246 with_libopenipmipthread_cflags=""
2247 with_libopenipmipthread_libs=""
2248
2249 AC_MSG_CHECKING([for pkg-config])
2250 temp_result="no"
2251 if test "x$PKG_CONFIG" = "x"
2252 then
2253         with_libopenipmipthread="no"
2254         temp_result="no"
2255 else
2256         temp_result="$PKG_CONFIG"
2257 fi
2258 AC_MSG_RESULT([$temp_result])
2259
2260 if test "x$with_libopenipmipthread" = "xyes"
2261 then
2262         AC_MSG_CHECKING([for libOpenIPMIpthread])
2263         $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
2264         if test "$?" != "0"
2265         then
2266                 with_libopenipmipthread="no ($PKG_CONFIG doesn't know OpenIPMIpthread)"
2267         fi
2268         AC_MSG_RESULT([$with_libopenipmipthread])
2269 fi
2270
2271 if test "x$with_libopenipmipthread" = "xyes"
2272 then
2273         AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS])
2274         temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`"
2275         if test "$?" = "0"
2276         then
2277                 with_libopenipmipthread_cflags="$temp_result"
2278         else
2279                 with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)"
2280                 temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed"
2281         fi
2282         AC_MSG_RESULT([$temp_result])
2283 fi
2284
2285 if test "x$with_libopenipmipthread" = "xyes"
2286 then
2287         AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS])
2288         temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`"
2289         if test "$?" = "0"
2290         then
2291                 with_libopenipmipthread_ldflags="$temp_result"
2292         else
2293                 with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)"
2294                 temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed"
2295         fi
2296         AC_MSG_RESULT([$temp_result])
2297 fi
2298
2299 if test "x$with_libopenipmipthread" = "xyes"
2300 then
2301         SAVE_CPPFLAGS="$CPPFLAGS"
2302         CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags"
2303
2304         AC_CHECK_HEADERS(OpenIPMI/ipmi_smi.h,
2305                          [with_libopenipmipthread="yes"],
2306                          [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"],
2307 [#include <OpenIPMI/ipmiif.h>
2308 #include <OpenIPMI/ipmi_err.h>
2309 #include <OpenIPMI/ipmi_posix.h>
2310 #include <OpenIPMI/ipmi_conn.h>
2311 ])
2312
2313         CPPFLAGS="$SAVE_CPPFLAGS"
2314 fi
2315
2316 if test "x$with_libopenipmipthread" = "xyes"
2317 then
2318         BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags"
2319         BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags"
2320         AC_SUBST(BUILD_WITH_OPENIPMI_CFLAGS)
2321         AC_SUBST(BUILD_WITH_OPENIPMI_LIBS)
2322 fi
2323
2324 dnl Check for libpq.
2325 with_pg_config="pg_config"
2326 with_libpq_includedir=""
2327 with_libpq_libdir=""
2328 with_libpq_cppflags=""
2329 with_libpq_ldflags=""
2330 AC_ARG_WITH(libpq, [AS_HELP_STRING([--with-libpq@<:@=PREFIX@:>@],
2331         [Path to libpq.])],
2332 [
2333         if test "x$withval" = "xno"
2334         then
2335                 with_libpq="no"
2336         else if test "x$withval" = "xyes"
2337         then
2338                 with_libpq="yes"
2339         else
2340                 if test -f "$withval" && test -x "$withval";
2341                 then
2342                         with_pg_config="$withval"
2343                 else if test -x "$withval/bin/pg_config"
2344                 then
2345                         with_pg_config="$withval/bin/pg_config"
2346                 fi; fi
2347                 with_libpq="yes"
2348         fi; fi
2349 ],
2350 [
2351         with_libpq="yes"
2352 ])
2353 if test "x$with_libpq" = "xyes"
2354 then
2355         with_libpq_includedir=`$with_pg_config --includedir 2> /dev/null`
2356         pg_config_status=$?
2357
2358         if test $pg_config_status -eq 0
2359         then
2360                 if test -n "$with_libpq_includedir"; then
2361                         for dir in $with_libpq_includedir; do
2362                                 with_libpq_cppflags="$with_libpq_cppflags -I$dir"
2363                         done
2364                 fi
2365         else
2366                 AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
2367         fi
2368
2369         SAVE_CPPFLAGS="$CPPFLAGS"
2370         CPPFLAGS="$CPPFLAGS $with_libpq_cppflags"
2371
2372         AC_CHECK_HEADERS(libpq-fe.h, [],
2373                 [with_libpq="no (libpq-fe.h not found)"], [])
2374
2375         CPPFLAGS="$SAVE_CPPFLAGS"
2376 fi
2377 if test "x$with_libpq" = "xyes"
2378 then
2379         with_libpq_libdir=`$with_pg_config --libdir 2> /dev/null`
2380         pg_config_status=$?
2381
2382         if test $pg_config_status -eq 0
2383         then
2384                 if test -n "$with_libpq_libdir"; then
2385                         for dir in $with_libpq_libdir; do
2386                                 with_libpq_ldflags="$with_libpq_ldflags -L$dir"
2387                         done
2388                 fi
2389         else
2390                 AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
2391         fi
2392
2393         SAVE_LDFLAGS="$LDFLAGS"
2394         LDFLAGS="$LDFLAGS $with_libpq_ldflags"
2395
2396         AC_CHECK_LIB(pq, PQconnectdb,
2397                 [with_libpq="yes"],
2398                 [with_libpq="no (symbol 'PQconnectdb' not found)"])
2399
2400         LDFLAGS="$SAVE_LDFLAGS"
2401 fi
2402 if test "x$with_libpq" = "xyes"
2403 then
2404         BUILD_WITH_LIBPQ_CPPFLAGS="$with_libpq_cppflags"
2405         BUILD_WITH_LIBPQ_LDFLAGS="$with_libpq_ldflags"
2406         AC_SUBST(BUILD_WITH_LIBPQ_CPPFLAGS)
2407         AC_SUBST(BUILD_WITH_LIBPQ_LDFLAGS)
2408 fi
2409 AM_CONDITIONAL(BUILD_WITH_LIBPQ, test "x$with_libpq" = "xyes")
2410
2411 dnl Check for libvirt and libxml2 libraries.
2412 with_libxml2="no (pkg-config isn't available)"
2413 with_libxml2_cflags=""
2414 with_libxml2_ldflags=""
2415 with_libvirt="no (pkg-config isn't available)"
2416 with_libvirt_cflags=""
2417 with_libvirt_ldflags=""
2418 if test "x$PKG_CONFIG" != "x"
2419 then
2420         pkg-config --exists 'libxml-2.0' 2>/dev/null
2421         if test "$?" = "0"
2422         then
2423                 with_libxml2="yes"
2424         else
2425                 with_libxml2="no (pkg-config doesn't know library)"
2426         fi
2427
2428         pkg-config --exists libvirt 2>/dev/null
2429         if test "$?" = "0"
2430         then
2431                 with_libvirt="yes"
2432         else
2433                 with_libvirt="no (pkg-config doesn't know library)"
2434         fi
2435 fi
2436 if test "x$with_libxml2" = "xyes"
2437 then
2438         with_libxml2_cflags="`pkg-config --cflags libxml-2.0`"
2439         if test $? -ne 0
2440         then
2441                 with_libxml2="no"
2442         fi
2443         with_libxml2_ldflags="`pkg-config --libs libxml-2.0`"
2444         if test $? -ne 0
2445         then
2446                 with_libxml2="no"
2447         fi
2448 fi
2449 if test "x$with_libxml2" = "xyes"
2450 then
2451         SAVE_CPPFLAGS="$CPPFLAGS"
2452         CPPFLAGS="$CPPFLAGS $with_libxml2_cflags"
2453
2454         AC_CHECK_HEADERS(libxml/parser.h, [],
2455                       [with_libxml2="no (libxml/parser.h not found)"])
2456
2457         CPPFLAGS="$SAVE_CPPFLAGS"
2458 fi
2459 if test "x$with_libxml2" = "xyes"
2460 then
2461         SAVE_CFLAGS="$CFLAGS"
2462         SAVE_LDFLAGS="$LDFLAGS"
2463
2464         CFLAGS="$CFLAGS $with_libxml2_cflags"
2465         LDFLAGS="$LDFLAGS $with_libxml2_ldflags"
2466
2467         AC_CHECK_LIB(xml2, xmlXPathEval,
2468                      [with_libxml2="yes"],
2469                      [with_libxml2="no (symbol xmlXPathEval not found)"])
2470
2471         CFLAGS="$SAVE_CFLAGS"
2472         LDFLAGS="$SAVE_LDFLAGS"
2473 fi
2474 dnl Add the right compiler flags and libraries.
2475 if test "x$with_libxml2" = "xyes"; then
2476         BUILD_WITH_LIBXML2_CFLAGS="$with_libxml2_cflags"
2477         BUILD_WITH_LIBXML2_LIBS="$with_libxml2_ldflags"
2478         AC_SUBST(BUILD_WITH_LIBXML2_CFLAGS)
2479         AC_SUBST(BUILD_WITH_LIBXML2_LIBS)
2480 fi
2481 if test "x$with_libvirt" = "xyes"
2482 then
2483         with_libvirt_cflags="`pkg-config --cflags libvirt`"
2484         if test $? -ne 0
2485         then
2486                 with_libvirt="no"
2487         fi
2488         with_libvirt_ldflags="`pkg-config --libs libvirt`"
2489         if test $? -ne 0
2490         then
2491                 with_libvirt="no"
2492         fi
2493 fi
2494 if test "x$with_libvirt" = "xyes"
2495 then
2496         SAVE_CPPFLAGS="$CPPFLAGS"
2497         CPPFLAGS="$CPPFLAGS $with_libvirt_cflags"
2498
2499         AC_CHECK_HEADERS(libvirt/libvirt.h, [],
2500                       [with_libvirt="no (libvirt/libvirt.h not found)"])
2501
2502         CPPFLAGS="$SAVE_CPPFLAGS"
2503 fi
2504 if test "x$with_libvirt" = "xyes"
2505 then
2506         SAVE_CFLAGS="$CFLAGS"
2507         SAVE_LDFLAGS="$LDFLAGS"
2508
2509         CFLAGS="$CFLAGS $with_libvirt_cflags"
2510         LDFLAGS="$LDFLAGS $with_libvirt_ldflags"
2511
2512         AC_CHECK_LIB(virt, virDomainBlockStats,
2513                      [with_libvirt="yes"],
2514                      [with_libvirt="no (symbol virDomainBlockStats not found)"])
2515
2516         CFLAGS="$SAVE_CFLAGS"
2517         LDFLAGS="$SAVE_LDFLAGS"
2518 fi
2519 dnl Add the right compiler flags and libraries.
2520 if test "x$with_libvirt" = "xyes"; then
2521         BUILD_WITH_LIBVIRT_CFLAGS="$with_libvirt_cflags"
2522         BUILD_WITH_LIBVIRT_LIBS="$with_libvirt_ldflags"
2523         AC_SUBST(BUILD_WITH_LIBVIRT_CFLAGS)
2524         AC_SUBST(BUILD_WITH_LIBVIRT_LIBS)
2525 fi
2526
2527 dnl End of check for libvirt and libxml2 libraries.
2528
2529 # Check for enabled/disabled features
2530 #
2531
2532 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
2533 # ------------------------------------------------------------
2534 dnl
2535 m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
2536 dnl
2537 AC_DEFUN(
2538         [AC_COLLECTD],
2539         [
2540         m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
2541         m4_if(
2542                 [$2],
2543                 [enable],
2544                 [dnl
2545                 m4_define([EnDis],[disabled])dnl
2546                 m4_define([YesNo],[no])dnl
2547                 ],dnl
2548                 [m4_if(
2549                         [$2],
2550                         [disable],
2551                         [dnl
2552                         m4_define([EnDis],[enabled])dnl
2553                         m4_define([YesNo],[yes])dnl
2554                         ],
2555                         [dnl
2556                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
2557                         ]dnl
2558                 )]dnl
2559         )dnl
2560         m4_if([$3], [feature], [],
2561                 [m4_if(
2562                         [$3], [module], [],
2563                         [dnl
2564                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
2565                         ]dnl
2566                 )]dnl
2567         )dnl
2568         AC_ARG_ENABLE(
2569                 [$1],
2570                 AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
2571                 [],
2572                 enable_$1='[YesNo]'dnl
2573         )# AC_ARG_ENABLE
2574 if test "x$enable_$1" = "xno"
2575 then
2576         collectd_$1=0
2577 else
2578         if test "x$enable_$1" = "xyes"
2579         then
2580                 collectd_$1=1
2581         else
2582                 AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
2583                 collectd_$1=1
2584                 enable_$1='yes'
2585         fi
2586 fi
2587         AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
2588         AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
2589         ]dnl
2590 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
2591
2592 # AC_PLUGIN(name, default, info)
2593 # ------------------------------------------------------------
2594 dnl
2595 AC_DEFUN(
2596   [AC_PLUGIN],
2597   [
2598     enable_plugin="no"
2599     AC_ARG_ENABLE([$1], AC_HELP_STRING([--enable-$1], [$3]),
2600     [
2601      if test "x$enableval" = "xyes"
2602      then
2603              enable_plugin="yes"
2604      else
2605              enable_plugin="no"
2606      fi
2607     ],
2608     [
2609      if test "x$2" = "xyes"
2610      then
2611              enable_plugin="yes"
2612      else
2613              enable_plugin="no"
2614      fi
2615     ])
2616     if test "x$enable_plugin" = "xyes"
2617     then
2618             if test "x$2" = "xyes"
2619             then
2620                     AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
2621             else # User passed "yes" but dependency checking yielded "no" => Dependency problem.
2622                     dependency_error="yes"
2623                     enable_plugin="no (dependency error)"
2624             fi
2625     fi
2626     AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), test "x$enable_plugin" = "xyes")
2627     enable_$1="$enable_plugin"
2628   ]
2629 )# AC_PLUGIN(name, default, info)
2630
2631 m4_divert_once([HELP_ENABLE], [
2632 collectd features:])
2633 # FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
2634 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
2635 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
2636 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
2637
2638 dependency_error="no"
2639 plugin_ascent="no"
2640 plugin_battery="no"
2641 plugin_cpu="no"
2642 plugin_cpufreq="no"
2643 plugin_df="no"
2644 plugin_disk="no"
2645 plugin_entropy="no"
2646 plugin_interface="no"
2647 plugin_ipmi="no"
2648 plugin_ipvs="no"
2649 plugin_irq="no"
2650 plugin_libvirt="no"
2651 plugin_load="no"
2652 plugin_memory="no"
2653 plugin_multimeter="no"
2654 plugin_nfs="no"
2655 plugin_perl="no"
2656 plugin_processes="no"
2657 plugin_serial="no"
2658 plugin_swap="no"
2659 plugin_tape="no"
2660 plugin_tcpconns="no"
2661 plugin_thermal="no"
2662 plugin_users="no"
2663 plugin_vmem="no"
2664 plugin_vserver="no"
2665 plugin_wireless="no"
2666
2667 # Linux
2668 if test "x$ac_system" = "xLinux"
2669 then
2670         plugin_battery="yes"
2671         plugin_cpu="yes"
2672         plugin_cpufreq="yes"
2673         plugin_disk="yes"
2674         plugin_entropy="yes"
2675         plugin_interface="yes"
2676         plugin_irq="yes"
2677         plugin_load="yes"
2678         plugin_memory="yes"
2679         plugin_nfs="yes"
2680         plugin_processes="yes"
2681         plugin_serial="yes"
2682         plugin_swap="yes"
2683         plugin_tcpconns="yes"
2684         plugin_thermal="yes"
2685         plugin_vmem="yes"
2686         plugin_vserver="yes"
2687         plugin_wireless="yes"
2688
2689         if test "x$have_net_ip_vs_h" = "xyes" -o "x$have_ip_vs_h" = "xyes"
2690         then
2691                 plugin_ipvs="yes"
2692         fi
2693 fi
2694
2695 if test "x$ac_system" = "xOpenBSD"
2696 then
2697         plugin_tcpconns="yes"
2698 fi
2699
2700 # Mac OS X devices
2701 if test "x$with_libiokit" = "xyes"
2702 then
2703         plugin_battery="yes"
2704         plugin_disk="yes"
2705 fi
2706
2707 # Solaris
2708 if test "x$with_devinfo$with_kstat" = "xyesyes"
2709 then
2710         plugin_cpu="yes"
2711         plugin_disk="yes"
2712         plugin_interface="yes"
2713         plugin_memory="yes"
2714         plugin_tape="yes"
2715 fi
2716
2717 if test "x$have_sys_swap_h$with_kstat$ac_system" = "xyesyesSolaris"
2718 then
2719         plugin_swap="yes"
2720 fi
2721
2722 # libstatgrab
2723 if test "x$with_libstatgrab" = "xyes"
2724 then
2725         plugin_cpu="yes"
2726         plugin_disk="yes"
2727         plugin_interface="yes"
2728         plugin_load="yes"
2729         plugin_memory="yes"
2730         plugin_swap="yes"
2731         plugin_users="yes"
2732 fi
2733
2734 if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
2735 then
2736         plugin_ascent="yes"
2737 fi
2738
2739 if test "x$with_libopenipmipthread" = "xyes"
2740 then
2741         plugin_ipmi="yes"
2742 fi
2743
2744 if test "x$have_processor_info" = "xyes"
2745 then
2746         plugin_cpu="yes"
2747 fi
2748 if test "x$have_sysctlbyname" = "xyes"
2749 then
2750         plugin_cpu="yes"
2751         plugin_memory="yes"
2752         plugin_tcpconns="yes"
2753 fi
2754
2755 # Df plugin: Check if we know how to determine mount points first.
2756 #if test "x$have_listmntent" = "xyes"; then
2757 #       plugin_df="yes"
2758 #fi
2759 if test "x$have_getvfsstat" = "xyes" || test "x$have_getfsstat" = "xyes"
2760 then
2761         plugin_df="yes"
2762 fi
2763 if test "x$c_cv_have_two_getmntent" = "xyes" || test "x$have_getmntent" = "xgen" || test "x$have_getmntent" = "xsun"
2764 then
2765         plugin_df="yes"
2766 fi
2767 #if test "x$have_getmntent" = "xseq"
2768 #then
2769 #       plugin_df="yes"
2770 #fi
2771 if test "x$c_cv_have_one_getmntent" = "xyes"
2772 then
2773         plugin_df="yes"
2774 fi
2775
2776 # Df plugin: Check if we have either `statfs' or `statvfs' second.
2777 if test "x$plugin_df" = "xyes"
2778 then
2779         plugin_df="no"
2780         if test "x$have_statfs" = "xyes"
2781         then
2782                 plugin_df="yes"
2783         fi
2784         if test "x$have_statvfs" = "xyes"
2785         then
2786                 plugin_df="yes"
2787         fi
2788 fi
2789
2790 if test "x$have_getifaddrs" = "xyes"
2791 then
2792         plugin_interface="yes"
2793 fi
2794
2795 if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes"
2796 then
2797         plugin_libvirt="yes"
2798 fi
2799
2800 if test "x$have_getloadavg" = "xyes"
2801 then
2802         plugin_load="yes"
2803 fi
2804
2805 if test "x$c_cv_have_libperl$c_cv_have_perl_ithreads" = "xyesyes"
2806 then
2807         plugin_perl="yes"
2808 fi
2809
2810 # Mac OS X memory interface
2811 if test "x$have_host_statistics" = "xyes"
2812 then
2813         plugin_memory="yes"
2814 fi
2815
2816 if test "x$have_termios_h" = "xyes"
2817 then
2818         plugin_multimeter="yes"
2819 fi
2820
2821 if test "x$have_thread_info" = "xyes"
2822 then
2823         plugin_processes="yes"
2824 fi
2825
2826 if test "x$with_kvm_getprocs" = "xyes" && test "x$have_struct_kinfo_proc_freebsd" = "xyes"
2827 then
2828         plugin_processes="yes"
2829 fi
2830
2831 if test "x$with_kvm_getswapinfo" = "xyes"
2832 then
2833         plugin_swap="yes"
2834 fi
2835
2836 if test "x$with_kvm_openfiles$with_kvm_nlist" = "xyesyes"
2837 then
2838         plugin_tcpconns="yes"
2839 fi
2840
2841 if test "x$have_getutent" = "xyes"
2842 then
2843         plugin_users="yes"
2844 fi
2845 if test "x$have_getutxent" = "xyes"
2846 then
2847         plugin_users="yes"
2848 fi
2849
2850 # FIXME: sysctl for swap plugin
2851
2852 m4_divert_once([HELP_ENABLE], [
2853 collectd plugins:])
2854
2855 AC_PLUGIN([apache],      [$with_libcurl],      [Apache httpd statistics])
2856 AC_PLUGIN([apcups],      [yes],                [Statistics of UPSes by APC])
2857 AC_PLUGIN([apple_sensors], [$with_libiokit],   [Apple's hardware sensors])
2858 AC_PLUGIN([ascent],      [$plugin_ascent],     [AscentEmu player statistics])
2859 AC_PLUGIN([battery],     [$plugin_battery],    [Battery statistics])
2860 AC_PLUGIN([cpu],         [$plugin_cpu],        [CPU usage statistics])
2861 AC_PLUGIN([cpufreq],     [$plugin_cpufreq],    [CPU frequency statistics])
2862 AC_PLUGIN([csv],         [yes],                [CSV output plugin])
2863 AC_PLUGIN([notify_desktop], [$with_libnotify], [Desktop notifications])
2864 AC_PLUGIN([df],          [$plugin_df],         [Filesystem usage statistics])
2865 AC_PLUGIN([disk],        [$plugin_disk],       [Disk usage statistics])
2866 AC_PLUGIN([dns],         [$with_libpcap],      [DNS traffic analysis])
2867 AC_PLUGIN([email],       [yes],                [EMail statistics])
2868 AC_PLUGIN([entropy],     [$plugin_entropy],    [Entropy statistics])
2869 AC_PLUGIN([exec],        [yes],                [Execution of external programs])
2870 AC_PLUGIN([filecount],   [yes],                [Count files in directories])
2871 AC_PLUGIN([hddtemp],     [yes],                [Query hddtempd])
2872 AC_PLUGIN([interface],   [$plugin_interface],  [Interface traffic statistics])
2873 AC_PLUGIN([iptables],    [$with_libiptc],      [IPTables rule counters])
2874 AC_PLUGIN([ipmi],        [$plugin_ipmi],       [IPMI sensor statistics])
2875 AC_PLUGIN([ipvs],        [$plugin_ipvs],       [IPVS connection statistics])
2876 AC_PLUGIN([irq],         [$plugin_irq],        [IRQ statistics])
2877 AC_PLUGIN([libvirt],     [$plugin_libvirt],    [Virtual machine statistics])
2878 AC_PLUGIN([load],        [$plugin_load],       [System load])
2879 AC_PLUGIN([logfile],     [yes],                [File logging plugin])
2880 AC_PLUGIN([mbmon],       [yes],                [Query mbmond])
2881 AC_PLUGIN([memcached],   [yes],                [memcached statistics])
2882 AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
2883 AC_PLUGIN([multimeter],  [$plugin_multimeter], [Read multimeter values])
2884 AC_PLUGIN([mysql],       [$with_libmysql],     [MySQL statistics])
2885 AC_PLUGIN([netlink],     [$with_libnetlink],   [Enhanced Linux network statistics])
2886 AC_PLUGIN([network],     [yes],                [Network communication plugin])
2887 AC_PLUGIN([nfs],         [$plugin_nfs],        [NFS statistics])
2888 AC_PLUGIN([nginx],       [$with_libcurl],      [nginx statistics])
2889 AC_PLUGIN([notify_email], [$with_libesmtp],    [Email notifier])
2890 AC_PLUGIN([ntpd],        [yes],                [NTPd statistics])
2891 AC_PLUGIN([nut],         [$with_libupsclient], [Network UPS tools statistics])
2892 AC_PLUGIN([onewire],     [$with_libowcapi],    [OneWire sensor statistics])
2893 AC_PLUGIN([perl],        [$plugin_perl],       [Embed a Perl interpreter])
2894 AC_PLUGIN([ping],        [$with_liboping],     [Network latency statistics])
2895 AC_PLUGIN([postgresql],  [$with_libpq],        [PostgreSQL database statistics])
2896 AC_PLUGIN([powerdns],    [yes],                [PowerDNS statistics])
2897 AC_PLUGIN([processes],   [$plugin_processes],  [Process statistics])
2898 AC_PLUGIN([rrdtool],     [$with_rrdtool],      [RRDTool output plugin])
2899 AC_PLUGIN([sensors],     [$with_lm_sensors],   [lm_sensors statistics])
2900 AC_PLUGIN([serial],      [$plugin_serial],     [serial port traffic])
2901 AC_PLUGIN([snmp],        [$with_libnetsnmp],   [SNMP querying plugin])
2902 AC_PLUGIN([swap],        [$plugin_swap],       [Swap usage statistics])
2903 AC_PLUGIN([syslog],      [$have_syslog],       [Syslog logging plugin])
2904 AC_PLUGIN([tail],        [yes],                [Parsing of logfiles])
2905 AC_PLUGIN([tape],        [$plugin_tape],       [Tape drive statistics])
2906 AC_PLUGIN([tcpconns],    [$plugin_tcpconns],   [TCP connection statistics])
2907 AC_PLUGIN([teamspeak2],  [yes],                [TeamSpeak2 server statistics])
2908 AC_PLUGIN([thermal],     [$plugin_thermal],    [Linux ACPI thermal zone statistics])
2909 AC_PLUGIN([unixsock],    [yes],                [Unixsock communication plugin])
2910 AC_PLUGIN([users],       [$plugin_users],      [User statistics])
2911 AC_PLUGIN([uuid],        [yes],                [UUID as hostname plugin])
2912 AC_PLUGIN([vmem],        [$plugin_vmem],       [Virtual memory statistics])
2913 AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
2914 AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
2915 AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
2916
2917 dnl ip_vs.h
2918 if test "x$ac_system" = "xLinux" \
2919         && test "x$have_net_ip_vs_h$have_ip_vs_h" = "xnono"
2920 then
2921         enable_ipvs="$enable_ipvs (ip_vs.h not found)"
2922 fi
2923
2924 dnl Perl bindings
2925 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
2926 [
2927         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2928         then
2929                 PERL_BINDINGS_OPTIONS="$withval"
2930                 with_perl_bindings="yes"
2931         else
2932                 PERL_BINDINGS_OPTIONS=""
2933                 with_perl_bindings="$withval"
2934         fi
2935 ],
2936 [
2937         PERL_BINDINGS_OPTIONS=""
2938         if test -n "$perl_interpreter"
2939         then
2940                 with_perl_bindings="yes"
2941         else
2942                 with_perl_bindings="no (no perl interpreter found)"
2943         fi
2944 ])
2945 if test "x$with_perl_bindings" = "xyes"
2946 then
2947         PERL_BINDINGS="perl"
2948 else
2949         PERL_BINDINGS=""
2950 fi
2951 AC_SUBST(PERL_BINDINGS)
2952 AC_SUBST(PERL_BINDINGS_OPTIONS)
2953
2954 AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/libiptc/Makefile src/liboconfig/Makefile src/liboping/Makefile bindings/Makefile)
2955
2956 if test "x$with_rrdtool" = "xyes" \
2957         && test "x$librrd_threadsafe" != "xyes"
2958 then
2959         with_rrdtool="yes (warning: librrd is not thread-safe)"
2960 fi
2961
2962 if test "x$with_liboping" = "xyes" \
2963         && test "x$with_own_liboping" = "xyes"
2964 then
2965         with_liboping="yes (shipped version)"
2966 fi
2967
2968 if test "x$with_libiptc" = "xyes" -a "x$with_own_libiptc" = "xyes"
2969 then
2970         with_libiptc="yes (shipped version)"
2971 fi
2972
2973 if test "x$with_libperl" = "xyes"
2974 then
2975         with_libperl="yes (version `$perl_interpreter -MConfig -e 'print $Config{version};'`)"
2976 else
2977         enable_perl="no (needs libperl)"
2978 fi
2979
2980 if test "x$with_perl_bindings" = "xyes" \
2981         && test "x$PERL_BINDINGS_OPTIONS" != "x"
2982 then
2983         with_perl_bindings="yes ($PERL_BINDINGS_OPTIONS)"
2984 fi
2985
2986 cat <<EOF;
2987
2988 Configuration:
2989   Libraries:
2990     libcurl . . . . . . . $with_libcurl
2991     libesmtp  . . . . . . $with_libesmtp
2992     libiokit  . . . . . . $with_libiokit
2993     libiptc . . . . . . . $with_libiptc
2994     libkstat  . . . . . . $with_kstat
2995     libkvm  . . . . . . . $with_libkvm
2996     libmysql  . . . . . . $with_libmysql
2997     libnetlink  . . . . . $with_libnetlink
2998     libnetsnmp  . . . . . $with_libnetsnmp
2999     libnotify . . . . . . $with_libnotify
3000     liboconfig  . . . . . $with_liboconfig
3001     libopenipmi . . . . . $with_libopenipmipthread
3002     liboping  . . . . . . $with_liboping
3003     libpcap . . . . . . . $with_libpcap
3004     libperl . . . . . . . $with_libperl
3005     libpthread  . . . . . $with_libpthread
3006     libpq . . . . . . . . $with_libpq
3007     librrd  . . . . . . . $with_rrdtool
3008     libsensors  . . . . . $with_lm_sensors
3009     libstatgrab . . . . . $with_libstatgrab
3010     libupsclient  . . . . $with_libupsclient
3011     libvirt . . . . . . . $with_libvirt
3012     libxml2 . . . . . . . $with_libxml2
3013     libxmms . . . . . . . $with_libxmms
3014
3015   Features:
3016     daemon mode . . . . . $enable_daemon
3017     debug . . . . . . . . $enable_debug
3018
3019   Bindings:
3020     perl  . . . . . . . . $with_perl_bindings
3021
3022   Modules:
3023     apache  . . . . . . . $enable_apache
3024     apcups  . . . . . . . $enable_apcups
3025     apple_sensors . . . . $enable_apple_sensors
3026     ascent  . . . . . . . $enable_ascent
3027     battery . . . . . . . $enable_battery
3028     cpu . . . . . . . . . $enable_cpu
3029     cpufreq . . . . . . . $enable_cpufreq
3030     csv . . . . . . . . . $enable_csv
3031     df  . . . . . . . . . $enable_df
3032     disk  . . . . . . . . $enable_disk
3033     dns . . . . . . . . . $enable_dns
3034     email . . . . . . . . $enable_email
3035     entropy . . . . . . . $enable_entropy
3036     exec  . . . . . . . . $enable_exec
3037     filecount . . . . . . $enable_filecount
3038     hddtemp . . . . . . . $enable_hddtemp
3039     interface . . . . . . $enable_interface
3040     iptables  . . . . . . $enable_iptables
3041     ipmi  . . . . . . . . $enable_ipmi
3042     ipvs  . . . . . . . . $enable_ipvs
3043     irq . . . . . . . . . $enable_irq
3044     libvirt . . . . . . . $enable_libvirt
3045     load  . . . . . . . . $enable_load
3046     logfile . . . . . . . $enable_logfile
3047     mbmon . . . . . . . . $enable_mbmon
3048     memcached . . . . . . $enable_memcached
3049     memory  . . . . . . . $enable_memory
3050     multimeter  . . . . . $enable_multimeter
3051     mysql . . . . . . . . $enable_mysql
3052     netlink . . . . . . . $enable_netlink
3053     network . . . . . . . $enable_network
3054     nfs . . . . . . . . . $enable_nfs
3055     nginx . . . . . . . . $enable_nginx
3056     notify_desktop  . . . $enable_notify_desktop
3057     notify_email  . . . . $enable_notify_email
3058     ntpd  . . . . . . . . $enable_ntpd
3059     nut . . . . . . . . . $enable_nut
3060     onewire . . . . . . . $enable_onewire
3061     perl  . . . . . . . . $enable_perl
3062     ping  . . . . . . . . $enable_ping
3063     postgresql  . . . . . $enable_postgresql
3064     powerdns  . . . . . . $enable_powerdns
3065     processes . . . . . . $enable_processes
3066     rrdtool . . . . . . . $enable_rrdtool
3067     sensors . . . . . . . $enable_sensors
3068     serial  . . . . . . . $enable_serial
3069     snmp  . . . . . . . . $enable_snmp
3070     swap  . . . . . . . . $enable_swap
3071     syslog  . . . . . . . $enable_syslog
3072     tail  . . . . . . . . $enable_tail
3073     tape  . . . . . . . . $enable_tape
3074     tcpconns  . . . . . . $enable_tcpconns
3075     teamspeak2  . . . . . $enable_teamspeak2
3076     thermal . . . . . . . $enable_thermal
3077     unixsock  . . . . . . $enable_unixsock
3078     users . . . . . . . . $enable_users
3079     uuid  . . . . . . . . $enable_uuid
3080     vmem  . . . . . . . . $enable_vmem
3081     vserver . . . . . . . $enable_vserver
3082     wireless  . . . . . . $enable_wireless
3083     xmms  . . . . . . . . $enable_xmms
3084
3085 EOF
3086
3087 if test "x$dependency_error" = "xyes"; then
3088         AC_MSG_ERROR("Some plugins are missing dependencies - see above summary for details")
3089 fi