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