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