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