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