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