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