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