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