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