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