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