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