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