Build system: Put Java class files into a .jar file.
[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 JAR="$JAR"
1558 AC_ARG_WITH(java, [AS_HELP_STRING([--with-java@<:@=PREFIX@:>@], [Path to Java home.])],
1559 [
1560         if test "x$withval" = "xno"
1561         then
1562                 with_java="no"
1563         else if test "x$withval" = "xyes"
1564         then
1565                 with_java="yes"
1566         else
1567                 with_java_home="$withval"
1568                 with_java="yes"
1569         fi; fi
1570 ],
1571 [with_java="yes"])
1572 if test "x$with_java" = "xyes"
1573 then
1574         if test -d "$with_java_home"
1575         then
1576                 AC_MSG_CHECKING([for jni.h])
1577                 TMPDIR=`find "$with_java_home" -name jni.h -type f -exec 'dirname' '{}' ';' | head -n 1`
1578                 if test "x$TMPDIR" != "x"
1579                 then
1580                         AC_MSG_RESULT([found in $TMPDIR])
1581                         JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPDIR"
1582                 else
1583                         AC_MSG_RESULT([not found])
1584                 fi
1585
1586                 AC_MSG_CHECKING([for jni_md.h])
1587                 TMPDIR=`find "$with_java_home" -name jni_md.h -type f -exec 'dirname' '{}' ';' | head -n 1`
1588                 if test "x$TMPDIR" != "x"
1589                 then
1590                         AC_MSG_RESULT([found in $TMPDIR])
1591                         JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPDIR"
1592                 else
1593                         AC_MSG_RESULT([not found])
1594                 fi
1595
1596                 AC_MSG_CHECKING([for libjvm.so])
1597                 TMPDIR=`find "$with_java_home" -name libjvm.so -type f -exec 'dirname' '{}' ';' | head -n 1`
1598                 if test "x$TMPDIR" != "x"
1599                 then
1600                         AC_MSG_RESULT([found in $TMPDIR])
1601                         JAVA_LDFLAGS="$JAVA_LDFLAGS -L$TMPDIR -Wl,-rpath -Wl,$TMPDIR"
1602                 else
1603                         AC_MSG_RESULT([not found])
1604                 fi
1605
1606                 if test "x$JAVAC" = "x"
1607                 then
1608                         AC_MSG_CHECKING([for javac])
1609                         TMPDIR=`find "$with_java_home" -name javac -type f | head -n 1`
1610                         if test "x$TMPDIR" != "x"
1611                         then
1612                                 JAVAC="$TMPDIR"
1613                                 AC_MSG_RESULT([$JAVAC])
1614                         else
1615                                 AC_MSG_RESULT([not found])
1616                         fi
1617                 fi
1618                 if test "x$JAR" = "x"
1619                 then
1620                         AC_MSG_CHECKING([for jar])
1621                         TMPDIR=`find "$with_java_home" -name jar -type f | head -n 1`
1622                         if test "x$TMPDIR" != "x"
1623                         then
1624                                 JAR="$TMPDIR"
1625                                 AC_MSG_RESULT([$JAR])
1626                         else
1627                                 AC_MSG_RESULT([not found])
1628                         fi
1629                 fi
1630         else if test "x$with_java_home" != "x"
1631         then
1632                 AC_MSG_WARN([JAVA_HOME: No such directory: $with_java_home])
1633         fi; fi
1634 fi
1635
1636 if test "x$JAVA_CPPFLAGS" != "x"
1637 then
1638         AC_MSG_NOTICE([Building with JAVA_CPPFLAGS set to: $JAVA_CPPFLAGS])
1639 fi
1640 if test "x$JAVA_CFLAGS" != "x"
1641 then
1642         AC_MSG_NOTICE([Building with JAVA_CFLAGS set to: $JAVA_CFLAGS])
1643 fi
1644 if test "x$JAVA_LDFLAGS" != "x"
1645 then
1646         AC_MSG_NOTICE([Building with JAVA_LDFLAGS set to: $JAVA_LDFLAGS])
1647 fi
1648 if test "x$JAVAC" = "x"
1649 then
1650         with_javac_path="$PATH"
1651         if test "x$with_java_home" != "x"
1652         then
1653                 with_javac_path="$with_java_home:with_javac_path"
1654                 if test -d "$with_java_home/bin"
1655                 then
1656                         with_javac_path="$with_java_home/bin:with_javac_path"
1657                 fi
1658         fi
1659
1660         AC_PATH_PROG(JAVAC, javac, [], "$with_javac_path")
1661 fi
1662 if test "x$JAVAC" = "x"
1663 then
1664         with_java="no (javac not found)"
1665 fi
1666 if test "x$JAR" = "x"
1667 then
1668         with_jar_path="$PATH"
1669         if test "x$with_java_home" != "x"
1670         then
1671                 with_jar_path="$with_java_home:with_jar_path"
1672                 if test -d "$with_java_home/bin"
1673                 then
1674                         with_jar_path="$with_jar_home/bin:with_jar_path"
1675                 fi
1676         fi
1677
1678         AC_PATH_PROG(JAR, jar, [], "$with_jar_path")
1679 fi
1680 if test "x$JAR" = "x"
1681 then
1682         with_java="no (jar not found)"
1683 fi
1684
1685 SAVE_CPPFLAGS="$CPPFLAGS"
1686 SAVE_CFLAGS="$CFLAGS"
1687 SAVE_LDFLAGS="$LDFLAGS"
1688 CPPFLAGS="$CPPFLAGS $JAVA_CPPFLAGS"
1689 CFLAGS="$CFLAGS $JAVA_CFLAGS"
1690 LDFLAGS="$LDFLAGS $JAVA_LDFLAGS"
1691
1692 if test "x$with_java" = "xyes"
1693 then
1694         AC_CHECK_HEADERS(jni.h, [], [with_java="no (jni.h not found)"])
1695 fi
1696 if test "x$with_java" = "xyes"
1697 then
1698         AC_CHECK_LIB(jvm, JNI_CreateJavaVM,
1699         [with_java="yes"],
1700         [with_java="no (libjvm not found)"],
1701         [$JAVA_LIBS])
1702 fi
1703 if test "x$with_java" = "xyes"
1704 then
1705         JAVA_LIBS="$JAVA_LIBS -ljvm"
1706         AC_MSG_NOTICE([Building with JAVA_LIBS set to: $JAVA_LIBS])
1707 fi
1708
1709 CPPFLAGS="$SAVE_CPPFLAGS"
1710 CFLAGS="$SAVE_CFLAGS"
1711 LDFLAGS="$SAVE_LDFLAGS"
1712
1713 AC_SUBST(JAVA_CPPFLAGS)
1714 AC_SUBST(JAVA_CFLAGS)
1715 AC_SUBST(JAVA_LDFLAGS)
1716 AC_SUBST(JAVA_LIBS)
1717 AM_CONDITIONAL(BUILD_WITH_JAVA, test "x$with_java" = "xyes")
1718 # }}}
1719
1720 # --with-libmemcached {{{
1721 with_libmemcached_cppflags=""
1722 with_libmemcached_ldflags=""
1723 AC_ARG_WITH(libmemcached, [AS_HELP_STRING([--with-libmemcached@<:@=PREFIX@:>@], [Path to libmemcached.])],
1724 [
1725         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1726         then
1727                 with_libmemcached_cppflags="-I$withval/include"
1728                 with_libmemcached_ldflags="-L$withval/lib"
1729                 with_libmemcached="yes"
1730         else
1731                 with_libmemcached="$withval"
1732         fi
1733 ],
1734 [
1735         with_libmemcached="yes"
1736 ])
1737 if test "x$with_libmemcached" = "xyes"
1738 then
1739         SAVE_CPPFLAGS="$CPPFLAGS"
1740         CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
1741
1742         AC_CHECK_HEADERS(libmemcached/memcached.h, [with_libmemcached="yes"], [with_libmemcached="no (libmemcached/memcached.h not found)"])
1743
1744         CPPFLAGS="$SAVE_CPPFLAGS"
1745 fi
1746 if test "x$with_libmemcached" = "xyes"
1747 then
1748         SAVE_CPPFLAGS="$CPPFLAGS"
1749         SAVE_LDFLAGS="$LDFLAGS"
1750         CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
1751         LDFLAGS="$LDFLAGS $with_libmemcached_ldflags"
1752
1753         AC_CHECK_LIB(memcached, memcached_create, [with_libmemcached="yes"], [with_libmemcached="no (Symbol 'memcached_create' not found)"])
1754
1755         CPPFLAGS="$SAVE_CPPFLAGS"
1756         LDFLAGS="$SAVE_LDFLAGS"
1757 fi
1758 if test "x$with_libmemcached" = "xyes"
1759 then
1760         BUILD_WITH_LIBMEMCACHED_CPPFLAGS="$with_libmemcached_cppflags"
1761         BUILD_WITH_LIBMEMCACHED_LDFLAGS="$with_libmemcached_ldflags"
1762         BUILD_WITH_LIBMEMCACHED_LIBS="-lmemcached"
1763         AC_SUBST(BUILD_WITH_LIBMEMCACHED_CPPFLAGS)
1764         AC_SUBST(BUILD_WITH_LIBMEMCACHED_LDFLAGS)
1765         AC_SUBST(BUILD_WITH_LIBMEMCACHED_LIBS)
1766         AC_DEFINE(HAVE_LIBMEMCACHED, 1, [Define if libmemcached is present and usable.])
1767 fi
1768 AM_CONDITIONAL(BUILD_WITH_LIBMEMCACHED, test "x$with_libmemcached" = "xyes")
1769 # }}}
1770
1771 # --with-libmysql {{{
1772 with_mysql_config="mysql_config"
1773 with_mysql_cflags=""
1774 with_mysql_libs=""
1775 AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
1776 [
1777         if test "x$withval" = "xno"
1778         then
1779                 with_libmysql="no"
1780         else if test "x$withval" = "xyes"
1781         then
1782                 with_libmysql="yes"
1783         else
1784                 if test -f "$withval" && test -x "$withval";
1785                 then
1786                         with_mysql_config="$withval"
1787                 else if test -x "$withval/bin/mysql_config"
1788                 then
1789                         with_mysql_config="$withval/bin/mysql_config"
1790                 fi; fi
1791                 with_libmysql="yes"
1792         fi; fi
1793 ],
1794 [
1795         with_libmysql="yes"
1796 ])
1797 if test "x$with_libmysql" = "xyes"
1798 then
1799         with_mysql_cflags=`$with_mysql_config --cflags 2>/dev/null`
1800         mysql_config_status=$?
1801
1802         if test $mysql_config_status -ne 0
1803         then
1804                 with_libmysql="no ($with_mysql_config failed)"
1805         else
1806                 SAVE_CPPFLAGS="$CPPFLAGS"
1807                 CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
1808
1809                 have_mysql_h="no"
1810                 have_mysql_mysql_h="no"
1811                 AC_CHECK_HEADERS(mysql.h, [have_mysql_h="yes"])
1812
1813                 if test "x$have_mysql_h" = "xno"
1814                 then
1815                         AC_CHECK_HEADERS(mysql/mysql.h, [have_mysql_mysql_h="yes"])
1816                 fi
1817
1818                 if test "x$have_mysql_h$have_mysql_mysql_h" = "xnono"
1819                 then
1820                         with_libmysql="no (mysql.h not found)"
1821                 fi
1822
1823                 CPPFLAGS="$SAVE_CPPFLAGS"
1824         fi
1825 fi
1826 if test "x$with_libmysql" = "xyes"
1827 then
1828         with_mysql_libs=`$with_mysql_config --libs 2>/dev/null`
1829         mysql_config_status=$?
1830
1831         if test $mysql_config_status -ne 0
1832         then
1833                 with_libmysql="no ($with_mysql_config failed)"
1834         else
1835                 AC_CHECK_LIB(mysqlclient, mysql_init,
1836                  [with_libmysql="yes"],
1837                  [with_libmysql="no (symbol 'mysql_init' not found)"],
1838                  [$with_mysql_libs])
1839
1840                 AC_CHECK_LIB(mysqlclient, mysql_get_server_version,
1841                  [with_libmysql="yes"],
1842                  [with_libmysql="no (symbol 'mysql_get_server_version' not found)"],
1843                  [$with_mysql_libs])
1844         fi
1845 fi
1846 if test "x$with_libmysql" = "xyes"
1847 then
1848         BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
1849         BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
1850         AC_SUBST(BUILD_WITH_LIBMYSQL_CFLAGS)
1851         AC_SUBST(BUILD_WITH_LIBMYSQL_LIBS)
1852 fi
1853 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
1854 # }}}
1855
1856 # --with-libnetlink {{{
1857 with_libnetlink_cflags=""
1858 with_libnetlink_libs="-lnetlink"
1859 AC_ARG_WITH(libnetlink, [AS_HELP_STRING([--with-libnetlink@<:@=PREFIX@:>@], [Path to libnetlink.])],
1860 [
1861  echo "libnetlink: withval = $withval"
1862  if test "x$withval" = "xyes"
1863  then
1864          with_libnetlink="yes"
1865  else if test "x$withval" = "xno"
1866  then
1867          with_libnetlink="no"
1868  else
1869          if test -d "$withval/include"
1870          then
1871                  with_libnetlink_cflags="-I$withval/include"
1872                  with_libnetlink_libs="-L$withval/lib -lnetlink"
1873                  with_libnetlink="yes"
1874          else
1875                  AC_MSG_ERROR("no such directory: $withval/include")
1876          fi
1877  fi; fi
1878 ],
1879 [
1880  if test "x$ac_system" = "xLinux"
1881  then
1882          with_libnetlink="yes"
1883  else
1884          with_libnetlink="no (Linux only library)"
1885  fi
1886 ])
1887 if test "x$with_libnetlink" = "xyes"
1888 then
1889         SAVE_CFLAGS="$CFLAGS"
1890         CFLAGS="$CFLAGS $with_libnetlink_cflags"
1891
1892         with_libnetlink="no (libnetlink.h not found)"
1893
1894         AC_CHECK_HEADERS(libnetlink.h iproute/libnetlink.h linux/libnetlink.h,
1895         [
1896          with_libnetlink="yes"
1897          break
1898         ], [],
1899 [#include <stdio.h>
1900 #include <sys/types.h>
1901 #include <asm/types.h>
1902 #include <sys/socket.h>
1903 #include <linux/netlink.h>
1904 #include <linux/rtnetlink.h>])
1905         AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
1906 [#include <stdio.h>
1907 #include <sys/types.h>
1908 #include <asm/types.h>
1909 #include <sys/socket.h>])
1910
1911         AC_COMPILE_IFELSE(
1912 [#include <stdio.h>
1913 #include <sys/types.h>
1914 #include <asm/types.h>
1915 #include <sys/socket.h>
1916 #include <linux/netlink.h>
1917 #include <linux/rtnetlink.h>
1918
1919 int main (void)
1920 {
1921         int retval = TCA_STATS2;
1922         return (retval);
1923 }],
1924         [AC_DEFINE([HAVE_TCA_STATS2], 1, [True if the enum-member TCA_STATS2 exists])]
1925         []);
1926
1927         AC_COMPILE_IFELSE(
1928 [#include <stdio.h>
1929 #include <sys/types.h>
1930 #include <asm/types.h>
1931 #include <sys/socket.h>
1932 #include <linux/netlink.h>
1933 #include <linux/rtnetlink.h>
1934
1935 int main (void)
1936 {
1937         int retval = TCA_STATS;
1938         return (retval);
1939 }],
1940         [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
1941         []);
1942
1943         CFLAGS="$SAVE_CFLAGS"
1944 fi
1945 if test "x$with_libnetlink" = "xyes"
1946 then
1947         AC_CHECK_LIB(netlink, rtnl_open,
1948                      [with_libnetlink="yes"],
1949                      [with_libnetlink="no (symbol 'rtnl_open' not found)"],
1950                      [$with_libnetlink_libs])
1951 fi
1952 if test "x$with_libnetlink" = "xyes"
1953 then
1954         BUILD_WITH_LIBNETLINK_CFLAGS="$with_libnetlink_cflags"
1955         BUILD_WITH_LIBNETLINK_LIBS="$with_libnetlink_libs"
1956         AC_SUBST(BUILD_WITH_LIBNETLINK_CFLAGS)
1957         AC_SUBST(BUILD_WITH_LIBNETLINK_LIBS)
1958 fi
1959 AM_CONDITIONAL(BUILD_WITH_LIBNETLINK, test "x$with_libnetlink" = "xyes")
1960 # }}}
1961
1962 # --with-libnetsnmp {{{
1963 with_snmp_config="net-snmp-config"
1964 with_snmp_cflags=""
1965 with_snmp_libs=""
1966 AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
1967 [
1968         if test "x$withval" = "xno"
1969         then
1970                 with_libnetsnmp="no"
1971         else if test "x$withval" = "xyes"
1972         then
1973                 with_libnetsnmp="yes"
1974         else
1975                 if test -x "$withval"
1976                 then
1977                         with_snmp_config="$withval"
1978                         with_libnetsnmp="yes"
1979                 else
1980                         with_snmp_config="$withval/bin/net-snmp-config"
1981                         with_libnetsnmp="yes"
1982                 fi
1983         fi; fi
1984 ],
1985 [with_libnetsnmp="yes"])
1986 if test "x$with_libnetsnmp" = "xyes"
1987 then
1988         with_snmp_cflags=`$with_snmp_config --cflags 2>/dev/null`
1989         snmp_config_status=$?
1990
1991         if test $snmp_config_status -ne 0
1992         then
1993                 with_libnetsnmp="no ($with_snmp_config failed)"
1994         else
1995                 SAVE_CPPFLAGS="$CPPFLAGS"
1996                 CPPFLAGS="$CPPFLAGS $with_snmp_cflags"
1997                 
1998                 AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
1999
2000                 CPPFLAGS="$SAVE_CPPFLAGS"
2001         fi
2002 fi
2003 if test "x$with_libnetsnmp" = "xyes"
2004 then
2005         with_snmp_libs=`$with_snmp_config --libs 2>/dev/null`
2006         snmp_config_status=$?
2007
2008         if test $snmp_config_status -ne 0
2009         then
2010                 with_libnetsnmp="no ($with_snmp_config failed)"
2011         else
2012                 AC_CHECK_LIB(netsnmp, init_snmp,
2013                 [with_libnetsnmp="yes"],
2014                 [with_libnetsnmp="no (libnetsnmp not found)"],
2015                 [$with_snmp_libs])
2016         fi
2017 fi
2018 if test "x$with_libnetsnmp" = "xyes"
2019 then
2020         BUILD_WITH_LIBSNMP_CFLAGS="$with_snmp_cflags"
2021         BUILD_WITH_LIBSNMP_LIBS="$with_snmp_libs"
2022         AC_SUBST(BUILD_WITH_LIBSNMP_CFLAGS)
2023         AC_SUBST(BUILD_WITH_LIBSNMP_LIBS)
2024 fi
2025 AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")
2026 # }}}
2027
2028 # --with-liboconfig {{{
2029 with_own_liboconfig="no"
2030 liboconfig_LDFLAGS="$LDFLAGS"
2031 liboconfig_CPPFLAGS="$CPPFLAGS"
2032 AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
2033 [
2034         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2035         then
2036                 if test -d "$withval/lib"
2037                 then
2038                         liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
2039                 fi
2040                 if test -d "$withval/include"
2041                 then
2042                         liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
2043                 fi
2044         fi
2045         if test "x$withval" = "xno"
2046         then
2047                 AC_MSG_ERROR("liboconfig is required")
2048         fi
2049 ],
2050 [
2051         with_liboconfig="yes"
2052 ])
2053
2054 save_LDFLAGS="$LDFLAGS"
2055 save_CPPFLAGS="$CPPFLAGS"
2056 LDFLAGS="$liboconfig_LDFLAGS"
2057 CPPFLAGS="$liboconfig_CPPFLAGS"
2058 AC_CHECK_LIB(oconfig, oconfig_parse_fh,
2059 [
2060         with_liboconfig="yes"
2061         with_own_liboconfig="no"
2062 ],
2063 [
2064         with_liboconfig="yes"
2065         with_own_liboconfig="yes"
2066         LDFLAGS="$save_LDFLAGS"
2067         CPPFLAGS="$save_CPPFLAGS"
2068 ])
2069
2070 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
2071 if test "x$with_own_liboconfig" = "xyes"
2072 then
2073         with_liboconfig="yes (shipped version)"
2074 fi
2075 # }}}
2076
2077 # --with-liboping {{{
2078 AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
2079 [
2080  if test "x$withval" = "xyes"
2081  then
2082          with_liboping="yes"
2083  else if test "x$withval" = "xno"
2084  then
2085          with_liboping="no"
2086  else
2087          with_liboping="yes"
2088          LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS -I$withval/include"
2089          LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS -L$withval/lib"
2090  fi; fi
2091 ],
2092 [with_liboping="yes"])
2093
2094 SAVE_CPPFLAGS="$CPPFLAGS"
2095 SAVE_LDFLAGS="$LDFLAGS"
2096
2097 CPPFLAGS="$CPPFLAGS $LIBOPING_CPPFLAGS"
2098 LDFLAGS="$LDFLAGS $LIBOPING_LDFLAGS"
2099
2100 if test "x$with_liboping" = "xyes"
2101 then
2102         if test "x$LIBOPING_CPPFLAGS" != "x"
2103         then
2104                 AC_MSG_NOTICE([liboping CPPFLAGS: $LIBOPING_CPPFLAGS])
2105         fi
2106         AC_CHECK_HEADERS(oping.h,
2107         [with_liboping="yes"],
2108         [with_liboping="no ('oping.h' not found)"])
2109 fi
2110 if test "x$with_liboping" = "xyes"
2111 then
2112         if test "x$LIBOPING_LDFLAGS" != "x"
2113         then
2114                 AC_MSG_NOTICE([liboping LDFLAGS: $LIBOPING_LDFLAGS])
2115         fi
2116         AC_CHECK_LIB(oping, ping_construct,
2117         [with_liboping="yes"],
2118         [with_liboping="no (symbol 'ping_construct' not found)"])
2119 fi
2120
2121 CPPFLAGS="$SAVE_CPPFLAGS"
2122 LDFLAGS="$SAVE_LDFLAGS"
2123
2124 if test "x$with_liboping" = "xyes"
2125 then
2126         BUILD_WITH_LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS"
2127         BUILD_WITH_LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS"
2128         AC_SUBST(BUILD_WITH_LIBOPING_CPPFLAGS)
2129         AC_SUBST(BUILD_WITH_LIBOPING_LDFLAGS)
2130 fi
2131 AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
2132 # }}}
2133
2134 # --with-oracle {{{
2135 with_oracle_cppflags=""
2136 with_oracle_libs=""
2137 AC_ARG_WITH(oracle, [AS_HELP_STRING([--with-oracle@<:@=ORACLE_HOME@:>@], [Path to Oracle.])],
2138 [
2139         if test "x$withval" = "xyes"
2140         then
2141                 if test "x$ORACLE_HOME" = "x"
2142                 then
2143                         AC_MSG_WARN([Use of the Oracle library has been forced, but the environment variable ORACLE_HOME is not set.])
2144                 fi
2145                 with_oracle="yes"
2146         else if test "x$withval" = "xno"
2147         then
2148                 with_oracle="no"
2149         else
2150                 with_oracle="yes"
2151                 ORACLE_HOME="$withval"
2152         fi; fi
2153 ],
2154 [
2155         if test "x$ORACLE_HOME" = "x"
2156         then
2157                 with_oracle="no (ORACLE_HOME is not set)"
2158         else
2159                 with_oracle="yes"
2160         fi
2161 ])
2162 if test "x$ORACLE_HOME" != "x"
2163 then
2164         with_oracle_cppflags="-I$ORACLE_HOME/rdbms/public"
2165
2166         if test -e "$ORACLE_HOME/lib/ldflags"
2167         then
2168                 with_oracle_libs=`cat "$ORACLE_HOME/lib/ldflags"`
2169         fi
2170         #with_oracle_libs="-L$ORACLE_HOME/lib $with_oracle_libs -lclntsh"
2171         with_oracle_libs="-L$ORACLE_HOME/lib -lclntsh"
2172 fi
2173 if test "x$with_oracle" = "xyes"
2174 then
2175         SAVE_CPPFLAGS="$CPPFLAGS"
2176         CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
2177
2178         AC_CHECK_HEADERS(oci.h, [with_oracle="yes"], [with_oracle="no (oci.h not found)"])
2179
2180         CPPFLAGS="$SAVE_CPPFLAGS"
2181 fi
2182 if test "x$with_oracle" = "xyes"
2183 then
2184         SAVE_CPPFLAGS="$CPPFLAGS"
2185         SAVE_LDFLAGS="$LDFLAGS"
2186         CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
2187         LDFLAGS="$LDFLAGS $with_oracle_libs"
2188
2189         AC_CHECK_FUNC(OCIEnvCreate, [with_oracle="yes"], [with_oracle="no (Symbol 'OCIEnvCreate' not found)"])
2190
2191         CPPFLAGS="$SAVE_CPPFLAGS"
2192         LDFLAGS="$SAVE_LDFLAGS"
2193 fi
2194 if test "x$with_oracle" = "xyes"
2195 then
2196         BUILD_WITH_ORACLE_CFLAGS="$with_oracle_cppflags"
2197         BUILD_WITH_ORACLE_LIBS="$with_oracle_libs"
2198         AC_SUBST(BUILD_WITH_ORACLE_CFLAGS)
2199         AC_SUBST(BUILD_WITH_ORACLE_LIBS)
2200 fi
2201 # }}}
2202
2203 # --with-libowcapi {{{
2204 with_libowcapi_cppflags=""
2205 with_libowcapi_libs="-lowcapi"
2206 AC_ARG_WITH(libowcapi, [AS_HELP_STRING([--with-libowcapi@<:@=PREFIX@:>@], [Path to libowcapi.])],
2207 [
2208         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2209         then
2210                 with_libowcapi_cppflags="-I$withval/include"
2211                 with_libowcapi_libs="-L$withval/lib -lowcapi"
2212                 with_libowcapi="yes"
2213         else
2214                 with_libowcapi="$withval"
2215         fi
2216 ],
2217 [
2218         with_libowcapi="yes"
2219 ])
2220 if test "x$with_libowcapi" = "xyes"
2221 then
2222         SAVE_CPPFLAGS="$CPPFLAGS"
2223         CPPFLAGS="$with_libowcapi_cppflags"
2224         
2225         AC_CHECK_HEADERS(owcapi.h, [with_libowcapi="yes"], [with_libowcapi="no (owcapi.h not found)"])
2226
2227         CPPFLAGS="$SAVE_CPPFLAGS"
2228 fi
2229 if test "x$with_libowcapi" = "xyes"
2230 then
2231         SAVE_LDFLAGS="$LDFLAGS"
2232         SAVE_CPPFLAGS="$CPPFLAGS"
2233         LDFLAGS="$with_libowcapi_libs"
2234         CPPFLAGS="$with_libowcapi_cppflags"
2235         
2236         AC_CHECK_LIB(owcapi, OW_get, [with_libowcapi="yes"], [with_libowcapi="no (libowcapi not found)"])
2237
2238         LDFLAGS="$SAVE_LDFLAGS"
2239         CPPFLAGS="$SAVE_CPPFLAGS"
2240 fi
2241 if test "x$with_libowcapi" = "xyes"
2242 then
2243         BUILD_WITH_LIBOWCAPI_CPPFLAGS="$with_libowcapi_cppflags"
2244         BUILD_WITH_LIBOWCAPI_LIBS="$with_libowcapi_libs"
2245         AC_SUBST(BUILD_WITH_LIBOWCAPI_CPPFLAGS)
2246         AC_SUBST(BUILD_WITH_LIBOWCAPI_LIBS)
2247 fi
2248 # }}}
2249
2250 # --with-libpcap {{{
2251 AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
2252 [
2253         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2254         then
2255                 LDFLAGS="$LDFLAGS -L$withval/lib"
2256                 CPPFLAGS="$CPPFLAGS -I$withval/include"
2257                 with_libpcap="yes"
2258         else
2259                 with_libpcap="$withval"
2260         fi
2261 ],
2262 [
2263         with_libpcap="yes"
2264 ])
2265 if test "x$with_libpcap" = "xyes"
2266 then
2267         AC_CHECK_LIB(pcap, pcap_open_live,
2268         [
2269                 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
2270         ], [with_libpcap="no (libpcap not found)"])
2271 fi
2272 if test "x$with_libpcap" = "xyes"
2273 then
2274         AC_CHECK_HEADERS(pcap.h,
2275         [
2276                 AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
2277         ], [with_libpcap="no (pcap.h not found)"])
2278 fi
2279 if test "x$with_libpcap" = "xyes"
2280 then
2281         collect_libpcap=1
2282 else
2283         collect_libpcap=0
2284 fi
2285 AC_DEFINE_UNQUOTED(COLLECT_LIBPCAP, [$collect_libpcap],
2286         [Wether or not to use the pcap library])
2287 AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
2288 # }}}
2289
2290 # --with-libperl {{{
2291 perl_interpreter="perl"
2292 AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
2293 [
2294         if test -x "$withval"
2295         then
2296                 perl_interpreter="$withval"
2297                 with_libperl="yes"
2298         else if test "x$withval" != "xno" && test "x$withval" != "xyes"
2299         then
2300                 LDFLAGS="$LDFLAGS -L$withval/lib"
2301                 CPPFLAGS="$CPPFLAGS -I$withval/include"
2302                 perl_interpreter="$withval/bin/perl"
2303                 with_libperl="yes"
2304         else
2305                 with_libperl="$withval"
2306         fi; fi
2307 ],
2308 [
2309         with_libperl="yes"
2310 ])
2311
2312 AC_MSG_CHECKING([for perl])
2313 perl_interpreter=`which "$perl_interpreter" 2> /dev/null`
2314 if test -x "$perl_interpreter"
2315 then
2316         AC_MSG_RESULT([yes ($perl_interpreter)])
2317 else
2318         perl_interpreter=""
2319         AC_MSG_RESULT([no])
2320 fi
2321
2322 AC_SUBST(PERL, "$perl_interpreter")
2323
2324 if test "x$with_libperl" = "xyes" \
2325         && test -n "$perl_interpreter"
2326 then
2327   SAVE_CFLAGS="$CFLAGS"
2328   SAVE_LDFLAGS="$LDFLAGS"
2329 dnl ARCHFLAGS="" -> disable multi -arch on OSX (see Config_heavy.pl:fetch_string)
2330   PERL_CFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ccopts`
2331   PERL_LDFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ldopts`
2332   CFLAGS="$CFLAGS $PERL_CFLAGS"
2333   LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
2334
2335   AC_CACHE_CHECK([for libperl],
2336     [c_cv_have_libperl],
2337     AC_LINK_IFELSE(
2338       AC_LANG_PROGRAM(
2339       [[
2340 #define PERL_NO_GET_CONTEXT
2341 #include <EXTERN.h>
2342 #include <perl.h>
2343 #include <XSUB.h>
2344       ]],
2345       [[
2346        dTHX;
2347        load_module (PERL_LOADMOD_NOIMPORT,
2348                          newSVpv ("Collectd::Plugin::FooBar", 24),
2349                          Nullsv);
2350       ]]),
2351       [c_cv_have_libperl="yes"],
2352       [c_cv_have_libperl="no"]
2353     )
2354   )
2355
2356   if test "x$c_cv_have_libperl" = "xyes"
2357   then
2358           AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
2359           AC_SUBST(PERL_CFLAGS)
2360           AC_SUBST(PERL_LDFLAGS)
2361   else
2362           with_libperl="no"
2363   fi
2364
2365   CFLAGS="$SAVE_CFLAGS"
2366   LDFLAGS="$SAVE_LDFLAGS"
2367 else if test -z "$perl_interpreter"; then
2368   with_libperl="no (no perl interpreter found)"
2369   c_cv_have_libperl="no"
2370 fi; fi
2371 AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")
2372
2373 if test "x$with_libperl" = "xyes"
2374 then
2375         SAVE_CFLAGS="$CFLAGS"
2376         SAVE_LDFLAGS="$LDFLAGS"
2377         CFLAGS="$CFLAGS $PERL_CFLAGS"
2378         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
2379
2380         AC_CACHE_CHECK([if perl supports ithreads],
2381                 [c_cv_have_perl_ithreads],
2382                 AC_LINK_IFELSE(
2383                         AC_LANG_PROGRAM(
2384                         [[
2385 #include <EXTERN.h>
2386 #include <perl.h>
2387 #include <XSUB.h>
2388
2389 #if !defined(USE_ITHREADS)
2390 # error "Perl does not support ithreads!"
2391 #endif /* !defined(USE_ITHREADS) */
2392                         ]],
2393                         [[ ]]),
2394                         [c_cv_have_perl_ithreads="yes"],
2395                         [c_cv_have_perl_ithreads="no"]
2396                 )
2397         )
2398
2399         if test "x$c_cv_have_perl_ithreads" = "xyes"
2400         then
2401                 AC_DEFINE(HAVE_PERL_ITHREADS, 1, [Define if Perl supports ithreads.])
2402         fi
2403
2404         CFLAGS="$SAVE_CFLAGS"
2405         LDFLAGS="$SAVE_LDFLAGS"
2406 fi
2407
2408 if test "x$with_libperl" = "xyes"
2409 then
2410         SAVE_CFLAGS="$CFLAGS"
2411         SAVE_LDFLAGS="$LDFLAGS"
2412         # trigger an error if Perl_load_module*() uses __attribute__nonnull__(3)
2413         # (see issues #41 and #42)
2414         CFLAGS="$CFLAGS $PERL_CFLAGS -Wall -Werror"
2415         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
2416
2417         AC_CACHE_CHECK([for broken Perl_load_module()],
2418                 [c_cv_have_broken_perl_load_module],
2419                 AC_LINK_IFELSE(
2420                         AC_LANG_PROGRAM(
2421                         [[
2422 #define PERL_NO_GET_CONTEXT
2423 #include <EXTERN.h>
2424 #include <perl.h>
2425 #include <XSUB.h>
2426                         ]],
2427                         [[
2428                          dTHX;
2429                          load_module (PERL_LOADMOD_NOIMPORT,
2430                              newSVpv ("Collectd::Plugin::FooBar", 24),
2431                              Nullsv);
2432                         ]]),
2433                         [c_cv_have_broken_perl_load_module="no"],
2434                         [c_cv_have_broken_perl_load_module="yes"]
2435                 )
2436         )
2437
2438         CFLAGS="$SAVE_CFLAGS"
2439         LDFLAGS="$SAVE_LDFLAGS"
2440 fi
2441 AM_CONDITIONAL(HAVE_BROKEN_PERL_LOAD_MODULE,
2442                 test "x$c_cv_have_broken_perl_load_module" = "xyes")
2443
2444 if test "x$with_libperl" = "xyes"
2445 then
2446         SAVE_CFLAGS="$CFLAGS"
2447         SAVE_LDFLAGS="$LDFLAGS"
2448         CFLAGS="$CFLAGS $PERL_CFLAGS"
2449         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
2450
2451         AC_CHECK_MEMBER(
2452                 [struct mgvtbl.svt_local],
2453                 [have_struct_mgvtbl_svt_local="yes"],
2454                 [have_struct_mgvtbl_svt_local="no"],
2455                 [
2456 #include <EXTERN.h>
2457 #include <perl.h>
2458 #include <XSUB.h>
2459                 ])
2460
2461         if test "x$have_struct_mgvtbl_svt_local" = "xyes"
2462         then
2463                 AC_DEFINE(HAVE_PERL_STRUCT_MGVTBL_SVT_LOCAL, 1,
2464                                   [Define if Perl's struct mgvtbl has member svt_local.])
2465         fi
2466
2467         CFLAGS="$SAVE_CFLAGS"
2468         LDFLAGS="$SAVE_LDFLAGS"
2469 fi
2470 # }}}
2471
2472 # --with-libpq {{{
2473 with_pg_config="pg_config"
2474 with_libpq_includedir=""
2475 with_libpq_libdir=""
2476 with_libpq_cppflags=""
2477 with_libpq_ldflags=""
2478 AC_ARG_WITH(libpq, [AS_HELP_STRING([--with-libpq@<:@=PREFIX@:>@],
2479         [Path to libpq.])],
2480 [
2481         if test "x$withval" = "xno"
2482         then
2483                 with_libpq="no"
2484         else if test "x$withval" = "xyes"
2485         then
2486                 with_libpq="yes"
2487         else
2488                 if test -f "$withval" && test -x "$withval";
2489                 then
2490                         with_pg_config="$withval"
2491                 else if test -x "$withval/bin/pg_config"
2492                 then
2493                         with_pg_config="$withval/bin/pg_config"
2494                 fi; fi
2495                 with_libpq="yes"
2496         fi; fi
2497 ],
2498 [
2499         with_libpq="yes"
2500 ])
2501 if test "x$with_libpq" = "xyes"
2502 then
2503         with_libpq_includedir=`$with_pg_config --includedir 2> /dev/null`
2504         pg_config_status=$?
2505
2506         if test $pg_config_status -eq 0
2507         then
2508                 if test -n "$with_libpq_includedir"; then
2509                         for dir in $with_libpq_includedir; do
2510                                 with_libpq_cppflags="$with_libpq_cppflags -I$dir"
2511                         done
2512                 fi
2513         else
2514                 AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
2515         fi
2516
2517         SAVE_CPPFLAGS="$CPPFLAGS"
2518         CPPFLAGS="$CPPFLAGS $with_libpq_cppflags"
2519
2520         AC_CHECK_HEADERS(libpq-fe.h, [],
2521                 [with_libpq="no (libpq-fe.h not found)"], [])
2522
2523         CPPFLAGS="$SAVE_CPPFLAGS"
2524 fi
2525 if test "x$with_libpq" = "xyes"
2526 then
2527         with_libpq_libdir=`$with_pg_config --libdir 2> /dev/null`
2528         pg_config_status=$?
2529
2530         if test $pg_config_status -eq 0
2531         then
2532                 if test -n "$with_libpq_libdir"; then
2533                         for dir in $with_libpq_libdir; do
2534                                 with_libpq_ldflags="$with_libpq_ldflags -L$dir"
2535                         done
2536                 fi
2537         else
2538                 AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
2539         fi
2540
2541         SAVE_LDFLAGS="$LDFLAGS"
2542         LDFLAGS="$LDFLAGS $with_libpq_ldflags"
2543
2544         AC_CHECK_LIB(pq, PQconnectdb,
2545                 [with_libpq="yes"],
2546                 [with_libpq="no (symbol 'PQconnectdb' not found)"])
2547
2548         AC_CHECK_LIB(pq, PQserverVersion,
2549                 [with_libpq="yes"],
2550                 [with_libpq="no (symbol 'PQserverVersion' not found)"])
2551
2552         LDFLAGS="$SAVE_LDFLAGS"
2553 fi
2554 if test "x$with_libpq" = "xyes"
2555 then
2556         BUILD_WITH_LIBPQ_CPPFLAGS="$with_libpq_cppflags"
2557         BUILD_WITH_LIBPQ_LDFLAGS="$with_libpq_ldflags"
2558         AC_SUBST(BUILD_WITH_LIBPQ_CPPFLAGS)
2559         AC_SUBST(BUILD_WITH_LIBPQ_LDFLAGS)
2560 fi
2561 AM_CONDITIONAL(BUILD_WITH_LIBPQ, test "x$with_libpq" = "xyes")
2562 # }}}
2563
2564 # --with-libpthread {{{
2565 AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
2566 [       if test "x$withval" != "xno" \
2567                 && test "x$withval" != "xyes"
2568         then
2569                 LDFLAGS="$LDFLAGS -L$withval/lib"
2570                 CPPFLAGS="$CPPFLAGS -I$withval/include"
2571                 with_libpthread="yes"
2572         else
2573                 if test "x$withval" = "xno"
2574                 then
2575                         with_libpthread="no (disabled)"
2576                 fi
2577         fi
2578 ], [with_libpthread="yes"])
2579 if test "x$with_libpthread" = "xyes"
2580 then
2581         AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
2582 fi
2583
2584 if test "x$with_libpthread" = "xyes"
2585 then
2586         AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
2587 fi
2588 if test "x$with_libpthread" = "xyes"
2589 then
2590         collect_pthread=1
2591 else
2592         collect_pthread=0
2593 fi
2594 AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
2595         [Wether or not to use pthread (POSIX threads) library])
2596 AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
2597 # }}}
2598
2599 # --with-librrd {{{
2600 # AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
2601 librrd_cflags=""
2602 librrd_ldflags=""
2603 librrd_threadsafe="yes"
2604 librrd_rrdc_update="no"
2605 AC_ARG_WITH(librrd, [AS_HELP_STRING([--with-librrd@<:@=PREFIX@:>@], [Path to rrdtool.])],
2606 [       if test "x$withval" != "xno" && test "x$withval" != "xyes"
2607         then
2608                 librrd_cflags="-I$withval/include"
2609                 librrd_ldflags="-L$withval/lib"
2610                 with_librrd="yes"
2611         else
2612                 with_librrd="$withval"
2613         fi
2614 ], [with_librrd="yes"])
2615 if test "x$with_librrd" = "xyes"
2616 then
2617         SAVE_CPPFLAGS="$CPPFLAGS"
2618         SAVE_LDFLAGS="$LDFLAGS"
2619
2620         CPPFLAGS="$CPPFLAGS $librrd_cflags"
2621         LDFLAGS="$LDFLAGS $librrd_ldflags"
2622
2623         AC_CHECK_HEADERS(rrd.h,, [with_librrd="no (rrd.h not found)"])
2624
2625         CPPFLAGS="$SAVE_CPPFLAGS"
2626         LDFLAGS="$SAVE_LDFLAGS"
2627 fi
2628 if test "x$with_librrd" = "xyes"
2629 then
2630         SAVE_CPPFLAGS="$CPPFLAGS"
2631         SAVE_LDFLAGS="$LDFLAGS"
2632
2633         CPPFLAGS="$CPPFLAGS $librrd_cflags"
2634         LDFLAGS="$LDFLAGS $librrd_ldflags"
2635
2636         AC_CHECK_LIB(rrd_th, rrd_update_r,
2637         [with_librrd="yes"
2638          librrd_ldflags="$librrd_ldflags -lrrd_th -lm"
2639         ],
2640         [librrd_threadsafe="no"
2641          AC_CHECK_LIB(rrd, rrd_update,
2642          [with_librrd="yes"
2643           librrd_ldflags="$librrd_ldflags -lrrd -lm"
2644          ],
2645          [with_librrd="no (symbol 'rrd_update' not found)"],
2646          [-lm])
2647         ],
2648         [-lm])
2649
2650         if test "x$librrd_threadsafe" = "xyes"
2651         then
2652                 AC_CHECK_LIB(rrd_th, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
2653         else
2654                 AC_CHECK_LIB(rrd, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
2655         fi
2656
2657         CPPFLAGS="$SAVE_CPPFLAGS"
2658         LDFLAGS="$SAVE_LDFLAGS"
2659 fi
2660 if test "x$with_librrd" = "xyes"
2661 then
2662         BUILD_WITH_LIBRRD_CFLAGS="$librrd_cflags"
2663         BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
2664         AC_SUBST(BUILD_WITH_LIBRRD_CFLAGS)
2665         AC_SUBST(BUILD_WITH_LIBRRD_LDFLAGS)
2666 fi
2667 if test "x$librrd_threadsafe" = "xyes"
2668 then
2669         AC_DEFINE(HAVE_THREADSAFE_LIBRRD, 1, [Define to 1 if you have the threadsafe rrd library (-lrrd_th).])
2670 fi
2671 # }}}
2672
2673 # --with-libsensors {{{
2674 with_sensors_cflags=""
2675 with_sensors_ldflags=""
2676 AC_ARG_WITH(libsensors, [AS_HELP_STRING([--with-libsensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
2677 [
2678         if test "x$withval" = "xno"
2679         then
2680                 with_libsensors="no"
2681         else
2682                 with_libsensors="yes"
2683                 if test "x$withval" != "xyes"
2684                 then
2685                         with_sensors_cflags="-I$withval/include"
2686                         with_sensors_ldflags="-L$withval/lib"
2687                         with_libsensors="yes"
2688                 fi
2689         fi
2690 ],
2691 [
2692         if test "x$ac_system" = "xLinux"
2693         then
2694                 with_libsensors="yes"
2695         else
2696                 with_libsensors="no (Linux only library)"
2697         fi
2698 ])
2699 if test "x$with_libsensors" = "xyes"
2700 then
2701         SAVE_CPPFLAGS="$CPPFLAGS"
2702         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
2703
2704 #       AC_CHECK_HEADERS(sensors/sensors.h,
2705 #       [
2706 #               AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
2707 #       ],
2708 #       [with_libsensors="no (sensors/sensors.h not found)"])
2709         AC_CHECK_HEADERS(sensors/sensors.h, [], [with_libsensors="no (sensors/sensors.h not found)"])
2710
2711         CPPFLAGS="$SAVE_CPPFLAGS"
2712 fi
2713 if test "x$with_libsensors" = "xyes"
2714 then
2715         SAVE_CPPFLAGS="$CPPFLAGS"
2716         SAVE_LDFLAGS="$LDFLAGS"
2717         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
2718         LDFLAGS="$LDFLAGS $with_sensors_ldflags"
2719
2720         AC_CHECK_LIB(sensors, sensors_init,
2721         [
2722                 AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
2723         ],
2724         [with_libsensors="no (libsensors not found)"])
2725
2726         CPPFLAGS="$SAVE_CPPFLAGS"
2727         LDFLAGS="$SAVE_LDFLAGS"
2728 fi
2729 if test "x$with_libsensors" = "xyes"
2730 then
2731         BUILD_WITH_LIBSENSORS_CFLAGS="$with_sensors_cflags"
2732         BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
2733         AC_SUBST(BUILD_WITH_LIBSENSORS_CFLAGS)
2734         AC_SUBST(BUILD_WITH_LIBSENSORS_LDFLAGS)
2735 fi
2736 AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_libsensors" = "xyes")
2737 # }}}
2738
2739 # --with-libstatgrab {{{
2740 with_libstatgrab_cflags=""
2741 with_libstatgrab_ldflags=""
2742 AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
2743 [
2744  if test "x$withval" != "xno" \
2745    && test "x$withval" != "xyes"
2746  then
2747    with_libstatgrab_cflags="-I$withval/include"
2748    with_libstatgrab_ldflags="-L$withval/lib -lstatgrab"
2749    with_libstatgrab="yes"
2750    with_libstatgrab_pkg_config="no"
2751  else
2752    with_libstatgrab="$withval"
2753    with_libstatgrab_pkg_config="yes"
2754  fi
2755  ],
2756 [
2757  with_libstatgrab="yes"
2758  with_libstatgrab_pkg_config="yes"
2759 ])
2760
2761 if test "x$with_libstatgrab" = "xyes" \
2762   && test "x$with_libstatgrab_pkg_config" = "xyes"
2763 then
2764   if test "x$PKG_CONFIG" != "x"
2765   then
2766     AC_MSG_CHECKING([pkg-config for libstatgrab])
2767     temp_result="found"
2768     $PKG_CONFIG --exists libstatgrab 2>/dev/null
2769     if test "$?" != "0"
2770     then
2771       with_libstatgrab_pkg_config="no"
2772       with_libstatgrab="no ($PKG_CONFIG doesn't know libstatgrab)"
2773       temp_result="not found"
2774     fi
2775     AC_MSG_RESULT([$temp_result])
2776   else
2777     AC_MSG_NOTICE([pkg-config not available, trying to guess flags for the statgrab library.])
2778     with_libstatgrab_pkg_config="no"
2779     with_libstatgrab_ldflags="$with_libstatgrab_ldflags -lstatgrab"
2780   fi
2781 fi
2782
2783 if test "x$with_libstatgrab" = "xyes" \
2784   && test "x$with_libstatgrab_pkg_config" = "xyes" \
2785   && test "x$with_libstatgrab_cflags" = "x"
2786 then
2787   AC_MSG_CHECKING([for libstatgrab CFLAGS])
2788   temp_result="`$PKG_CONFIG --cflags libstatgrab`"
2789   if test "$?" = "0"
2790   then
2791     with_libstatgrab_cflags="$temp_result"
2792   else
2793     with_libstatgrab="no ($PKG_CONFIG --cflags libstatgrab failed)"
2794     temp_result="$PKG_CONFIG --cflags libstatgrab failed"
2795   fi
2796   AC_MSG_RESULT([$temp_result])
2797 fi
2798
2799 if test "x$with_libstatgrab" = "xyes" \
2800   && test "x$with_libstatgrab_pkg_config" = "xyes" \
2801   && test "x$with_libstatgrab_ldflags" = "x"
2802 then
2803   AC_MSG_CHECKING([for libstatgrab LDFLAGS])
2804   temp_result="`$PKG_CONFIG --libs libstatgrab`"
2805   if test "$?" = "0"
2806   then
2807     with_libstatgrab_ldflags="$temp_result"
2808   else
2809     with_libstatgrab="no ($PKG_CONFIG --libs libstatgrab failed)"
2810     temp_result="$PKG_CONFIG --libs libstatgrab failed"
2811   fi
2812   AC_MSG_RESULT([$temp_result])
2813 fi
2814
2815 if test "x$with_libstatgrab" = "xyes"
2816 then
2817   SAVE_CPPFLAGS="$CPPFLAGS"
2818   CPPFLAGS="$CPPFLAGS $with_libstatgrab_cflags"
2819
2820   AC_CHECK_HEADERS(statgrab.h,
2821                    [with_libstatgrab="yes"],
2822                    [with_libstatgrab="no (statgrab.h not found)"])
2823
2824   CPPFLAGS="$SAVE_CPPFLAGS"
2825 fi
2826
2827 if test "x$with_libstatgrab" = "xyes"
2828 then
2829   SAVE_CFLAGS="$CFLAGS"
2830   SAVE_LDFLAGS="$LDFLAGS"
2831
2832   CFLAGS="$CFLAGS $with_libstatgrab_cflags"
2833   LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
2834
2835   AC_CHECK_LIB(statgrab, sg_init,
2836                [with_libstatgrab="yes"],
2837                [with_libstatgrab="no (symbol sg_init not found)"])
2838
2839   CFLAGS="$SAVE_CFLAGS"
2840   LDFLAGS="$SAVE_LDFLAGS"
2841 fi
2842
2843 AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
2844 if test "x$with_libstatgrab" = "xyes"
2845 then
2846   AC_DEFINE(HAVE_LIBSTATGRAB, 1, [Define to 1 if you have the 'statgrab' library (-lstatgrab)])
2847   BUILD_WITH_LIBSTATGRAB_CFLAGS="$with_libstatgrab_cflags"
2848   BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
2849   AC_SUBST(BUILD_WITH_LIBSTATGRAB_CFLAGS)
2850   AC_SUBST(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
2851 fi
2852 # }}}
2853
2854 # --with-libtokyotyrant {{{
2855 with_libtokyotyrant_cppflags=""
2856 with_libtokyotyrant_ldflags=""
2857 with_libtokyotyrant_libs=""
2858 AC_ARG_WITH(libtokyotyrant, [AS_HELP_STRING([--with-libtokyotyrant@<:@=PREFIX@:>@], [Path to libtokyotyrant.])],
2859 [
2860   if test "x$withval" = "xno"
2861   then
2862     with_libtokyotyrant="no"
2863   else if test "x$withval" = "xyes"
2864   then
2865     with_libtokyotyrant="yes"
2866   else
2867     with_libtokyotyrant_cppflags="-I$withval/include"
2868     with_libtokyotyrant_ldflags="-L$withval/include"
2869     with_libtokyotyrant_libs="-ltokyotyrant"
2870     with_libtokyotyrant="yes"
2871   fi; fi
2872 ],
2873 [
2874   with_libtokyotyrant="yes"
2875 ])
2876
2877 if test "x$with_libtokyotyrant" = "xyes"
2878 then
2879   if $PKG_CONFIG --exists tokyotyrant
2880   then
2881     with_libtokyotyrant_cppflags="$with_libtokyotyrant_cppflags `$PKG_CONFIG --cflags tokyotyrant`"
2882     with_libtokyotyrant_ldflags="$with_libtokyotyrant_ldflags `pkg-config --libs-only-L tokyotyrant`"
2883     with_libtokyotyrant_libs="$with_libtokyotyrant_libs `pkg-config --libs-only-l tokyotyrant`"
2884   fi
2885 fi
2886
2887 SAVE_CPPFLAGS="$CPPFLAGS"
2888 SAVE_LDFLAGS="$LDFLAGS"
2889 CPPFLAGS="$CPPFLAGS $with_libtokyotyrant_cppflags"
2890 LDFLAGS="$LDFLAGS $with_libtokyotyrant_ldflags"
2891
2892 if test "x$with_libtokyotyrant" = "xyes"
2893 then
2894   AC_CHECK_HEADERS(tcrdb.h,
2895   [
2896           AC_DEFINE(HAVE_TCRDB_H, 1,
2897                     [Define to 1 if you have the <tcrdb.h> header file.])
2898   ], [with_libtokyotyrant="no (tcrdb.h not found)"])
2899 fi
2900
2901 if test "x$with_libtokyotyrant" = "xyes"
2902 then
2903   AC_CHECK_LIB(tokyotyrant, tcrdbrnum,
2904   [
2905           AC_DEFINE(HAVE_LIBTOKYOTYRANT, 1,
2906                     [Define to 1 if you have the tokyotyrant library (-ltokyotyrant).])
2907   ],
2908   [with_libtokyotyrant="no (symbol tcrdbrnum not found)"],
2909   [$with_libtokyotyrant_libs])
2910 fi
2911
2912 CPPFLAGS="$SAVE_CPPFLAGS"
2913 LDFLAGS="$SAVE_LDFLAGS"
2914
2915 if test "x$with_libtokyotyrant" = "xyes"
2916 then 
2917   BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS="$with_libtokyotyrant_cppflags"
2918   BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS="$with_libtokyotyrant_ldflags"
2919   BUILD_WITH_LIBTOKYOTYRANT_LIBS="$with_libtokyotyrant_libs"
2920   AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS)
2921   AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS)
2922   AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_LIBS)
2923 fi
2924 AM_CONDITIONAL(BUILD_WITH_LIBTOKYOTYRANT, test "x$with_libtokyotyrant" = "xyes")
2925 # }}}
2926
2927 # --with-libupsclient {{{
2928 with_libupsclient_config=""
2929 with_libupsclient_cflags=""
2930 with_libupsclient_libs=""
2931 AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
2932 [
2933         if test "x$withval" = "xno"
2934         then
2935                 with_libupsclient="no"
2936         else if test "x$withval" = "xyes"
2937         then
2938                 with_libupsclient="use_pkgconfig"
2939         else
2940                 if test -x "$withval"
2941                 then
2942                         with_libupsclient_config="$withval"
2943                         with_libupsclient="use_libupsclient_config"
2944                 else if test -x "$withval/bin/libupsclient-config"
2945                 then
2946                         with_libupsclient_config="$withval/bin/libupsclient-config"
2947                         with_libupsclient="use_libupsclient_config"
2948                 else
2949                         AC_MSG_NOTICE([Not checking for libupsclient: Manually configured])
2950                         with_libupsclient_cflags="-I$withval/include"
2951                         with_libupsclient_libs="-L$withval/lib -lupsclient"
2952                         with_libupsclient="yes"
2953                 fi; fi
2954         fi; fi
2955 ],
2956 [with_libupsclient="use_pkgconfig"])
2957
2958 # configure using libupsclient-config
2959 if test "x$with_libupsclient" = "xuse_libupsclient_config"
2960 then
2961         AC_MSG_NOTICE([Checking for libupsclient using $with_libupsclient_config])
2962         with_libupsclient_cflags="`$with_libupsclient_config --cflags`"
2963         if test $? -ne 0
2964         then
2965                 with_libupsclient="no ($with_libupsclient_config failed)"
2966         fi
2967         with_libupsclient_libs="`$with_libupsclient_config --libs`"
2968         if test $? -ne 0
2969         then
2970                 with_libupsclient="no ($with_libupsclient_config failed)"
2971         fi
2972 fi
2973 if test "x$with_libupsclient" = "xuse_libupsclient_config"
2974 then
2975         with_libupsclient="yes"
2976 fi
2977
2978 # configure using pkg-config
2979 if test "x$with_libupsclient" = "xuse_pkgconfig"
2980 then
2981         if test "x$PKG_CONFIG" = "x"
2982         then
2983                 with_libupsclient="no (Don't have pkg-config)"
2984         fi
2985 fi
2986 if test "x$with_libupsclient" = "xuse_pkgconfig"
2987 then
2988         AC_MSG_NOTICE([Checking for libupsclient using $PKG_CONFIG])
2989         $PKG_CONFIG --exists 'libupsclient' 2>/dev/null
2990         if test $? -ne 0
2991         then
2992                 with_libupsclient="no (pkg-config doesn't know library)"
2993         fi
2994 fi
2995 if test "x$with_libupsclient" = "xuse_pkgconfig"
2996 then
2997         with_libupsclient_cflags="`$PKG_CONFIG --cflags 'libupsclient'`"
2998         if test $? -ne 0
2999         then
3000                 with_libupsclient="no ($PKG_CONFIG failed)"
3001         fi
3002         with_libupsclient_libs="`$PKG_CONFIG --libs 'libupsclient'`"
3003         if test $? -ne 0
3004         then
3005                 with_libupsclient="no ($PKG_CONFIG failed)"
3006         fi
3007 fi
3008 if test "x$with_libupsclient" = "xuse_pkgconfig"
3009 then
3010         with_libupsclient="yes"
3011 fi
3012
3013 # with_libupsclient_cflags and with_libupsclient_libs are set up now, let's do
3014 # the actual checks.
3015 if test "x$with_libupsclient" = "xyes"
3016 then
3017         SAVE_CPPFLAGS="$CPPFLAGS"
3018         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
3019
3020         AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])
3021
3022         CPPFLAGS="$SAVE_CPPFLAGS"
3023 fi
3024 if test "x$with_libupsclient" = "xyes"
3025 then
3026         SAVE_CPPFLAGS="$CPPFLAGS"
3027         SAVE_LDFLAGS="$LDFLAGS"
3028
3029         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
3030         LDFLAGS="$LDFLAGS $with_libupsclient_libs"
3031
3032         AC_CHECK_LIB(upsclient, upscli_connect,
3033                      [with_libupsclient="yes"],
3034                      [with_libupsclient="no (symbol upscli_connect not found)"])
3035
3036         CPPFLAGS="$SAVE_CPPFLAGS"
3037         LDFLAGS="$SAVE_LDFLAGS"
3038 fi
3039 if test "x$with_libupsclient" = "xyes"
3040 then
3041         SAVE_CPPFLAGS="$CPPFLAGS"
3042         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
3043
3044         AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [],
3045 [#include <stdlib.h>
3046 #include <stdio.h>
3047 #include <upsclient.h>])
3048
3049         CPPFLAGS="$SAVE_CPPFLAGS"
3050 fi
3051 if test "x$with_libupsclient" = "xyes"
3052 then
3053         BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_libupsclient_cflags"
3054         BUILD_WITH_LIBUPSCLIENT_LIBS="$with_libupsclient_libs"
3055         AC_SUBST(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
3056         AC_SUBST(BUILD_WITH_LIBUPSCLIENT_LIBS)
3057 fi
3058 # }}}
3059
3060 # --with-libxmms {{{
3061 with_xmms_config="xmms-config"
3062 with_xmms_cflags=""
3063 with_xmms_libs=""
3064 AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
3065 [
3066         if test "x$withval" != "xno" \
3067                 && test "x$withval" != "xyes"
3068         then
3069                 if test -f "$withval" && test -x "$withval";
3070                 then
3071                         with_xmms_config="$withval"
3072                 else if test -x "$withval/bin/xmms-config"
3073                 then
3074                         with_xmms_config="$withval/bin/xmms-config"
3075                 fi; fi
3076                 with_libxmms="yes"
3077         else if test "x$withval" = "xno"
3078         then
3079                 with_libxmms="no"
3080         else
3081                 with_libxmms="yes"
3082         fi; fi
3083 ],
3084 [
3085         with_libxmms="yes"
3086 ])
3087 if test "x$with_libxmms" = "xyes"
3088 then
3089         with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
3090         xmms_config_status=$?
3091
3092         if test $xmms_config_status -ne 0
3093         then
3094                 with_libxmms="no"
3095         fi
3096 fi
3097 if test "x$with_libxmms" = "xyes"
3098 then
3099         with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
3100         xmms_config_status=$?
3101
3102         if test $xmms_config_status -ne 0
3103         then
3104                 with_libxmms="no"
3105         fi
3106 fi
3107 if test "x$with_libxmms" = "xyes"
3108 then
3109         AC_CHECK_LIB(xmms, xmms_remote_get_info,
3110         [
3111                 BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
3112                 BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
3113                 AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
3114                 AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
3115         ],
3116         [
3117                 with_libxmms="no"
3118         ],
3119         [$with_xmms_libs])
3120 fi
3121 with_libxmms_numeric=0
3122 if test "x$with_libxmms" = "xyes"
3123 then
3124         with_libxmms_numeric=1
3125 fi
3126 AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
3127 AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
3128 # }}}
3129
3130 # --with-libyajl {{{
3131 with_libyajl_cppflags=""
3132 with_libyajl_ldflags=""
3133 AC_ARG_WITH(libyajl, [AS_HELP_STRING([--with-libyajl@<:@=PREFIX@:>@], [Path to libyajl.])],
3134 [
3135         if test "x$withval" != "xno" && test "x$withval" != "xyes"
3136         then
3137                 with_libyajl_cppflags="-I$withval/include"
3138                 with_libyajl_ldflags="-L$withval/lib"
3139                 with_libyajl="yes"
3140         else
3141                 with_libyajl="$withval"
3142         fi
3143 ],
3144 [
3145         with_libyajl="yes"
3146 ])
3147 if test "x$with_libyajl" = "xyes"
3148 then
3149         SAVE_CPPFLAGS="$CPPFLAGS"
3150         CPPFLAGS="$CPPFLAGS $with_libyajl_cppflags"
3151
3152         AC_CHECK_HEADERS(yajl/yajl_parse.h, [with_libyajl="yes"], [with_libyajl="no (yajl/yajl_parse.h not found)"])
3153
3154         CPPFLAGS="$SAVE_CPPFLAGS"
3155 fi
3156 if test "x$with_libyajl" = "xyes"
3157 then
3158         SAVE_CPPFLAGS="$CPPFLAGS"
3159         SAVE_LDFLAGS="$LDFLAGS"
3160         CPPFLAGS="$CPPFLAGS $with_libyajl_cppflags"
3161         LDFLAGS="$LDFLAGS $with_libyajl_ldflags"
3162
3163         AC_CHECK_LIB(yajl, yajl_alloc, [with_libyajl="yes"], [with_libyajl="no (Symbol 'yajl_alloc' not found)"])
3164
3165         CPPFLAGS="$SAVE_CPPFLAGS"
3166         LDFLAGS="$SAVE_LDFLAGS"
3167 fi
3168 if test "x$with_libyajl" = "xyes"
3169 then
3170         BUILD_WITH_LIBYAJL_CPPFLAGS="$with_libyajl_cppflags"
3171         BUILD_WITH_LIBYAJL_LDFLAGS="$with_libyajl_ldflags"
3172         BUILD_WITH_LIBYAJL_LIBS="-lyajl"
3173         AC_SUBST(BUILD_WITH_LIBYAJL_CPPFLAGS)
3174         AC_SUBST(BUILD_WITH_LIBYAJL_LDFLAGS)
3175         AC_SUBST(BUILD_WITH_LIBYAJL_LIBS)
3176         AC_DEFINE(HAVE_LIBYAJL, 1, [Define if libyajl is present and usable.])
3177 fi
3178 AM_CONDITIONAL(BUILD_WITH_LIBYAJL, test "x$with_libyajl" = "xyes")
3179 # }}}
3180
3181 # pkg-config --exists 'libxml-2.0'; pkg-config --exists libvirt {{{
3182 with_libxml2="no (pkg-config isn't available)"
3183 with_libxml2_cflags=""
3184 with_libxml2_ldflags=""
3185 with_libvirt="no (pkg-config isn't available)"
3186 with_libvirt_cflags=""
3187 with_libvirt_ldflags=""
3188 if test "x$PKG_CONFIG" != "x"
3189 then
3190         pkg-config --exists 'libxml-2.0' 2>/dev/null
3191         if test "$?" = "0"
3192         then
3193                 with_libxml2="yes"
3194         else
3195                 with_libxml2="no (pkg-config doesn't know library)"
3196         fi
3197
3198         pkg-config --exists libvirt 2>/dev/null
3199         if test "$?" = "0"
3200         then
3201                 with_libvirt="yes"
3202         else
3203                 with_libvirt="no (pkg-config doesn't know library)"
3204         fi
3205 fi
3206 if test "x$with_libxml2" = "xyes"
3207 then
3208         with_libxml2_cflags="`pkg-config --cflags libxml-2.0`"
3209         if test $? -ne 0
3210         then
3211                 with_libxml2="no"
3212         fi
3213         with_libxml2_ldflags="`pkg-config --libs libxml-2.0`"
3214         if test $? -ne 0
3215         then
3216                 with_libxml2="no"
3217         fi
3218 fi
3219 if test "x$with_libxml2" = "xyes"
3220 then
3221         SAVE_CPPFLAGS="$CPPFLAGS"
3222         CPPFLAGS="$CPPFLAGS $with_libxml2_cflags"
3223
3224         AC_CHECK_HEADERS(libxml/parser.h, [],
3225                       [with_libxml2="no (libxml/parser.h not found)"])
3226
3227         CPPFLAGS="$SAVE_CPPFLAGS"
3228 fi
3229 if test "x$with_libxml2" = "xyes"
3230 then
3231         SAVE_CFLAGS="$CFLAGS"
3232         SAVE_LDFLAGS="$LDFLAGS"
3233
3234         CFLAGS="$CFLAGS $with_libxml2_cflags"
3235         LDFLAGS="$LDFLAGS $with_libxml2_ldflags"
3236
3237         AC_CHECK_LIB(xml2, xmlXPathEval,
3238                      [with_libxml2="yes"],
3239                      [with_libxml2="no (symbol xmlXPathEval not found)"])
3240
3241         CFLAGS="$SAVE_CFLAGS"
3242         LDFLAGS="$SAVE_LDFLAGS"
3243 fi
3244 dnl Add the right compiler flags and libraries.
3245 if test "x$with_libxml2" = "xyes"; then
3246         BUILD_WITH_LIBXML2_CFLAGS="$with_libxml2_cflags"
3247         BUILD_WITH_LIBXML2_LIBS="$with_libxml2_ldflags"
3248         AC_SUBST(BUILD_WITH_LIBXML2_CFLAGS)
3249         AC_SUBST(BUILD_WITH_LIBXML2_LIBS)
3250 fi
3251 if test "x$with_libvirt" = "xyes"
3252 then
3253         with_libvirt_cflags="`pkg-config --cflags libvirt`"
3254         if test $? -ne 0
3255         then
3256                 with_libvirt="no"
3257         fi
3258         with_libvirt_ldflags="`pkg-config --libs libvirt`"
3259         if test $? -ne 0
3260         then
3261                 with_libvirt="no"
3262         fi
3263 fi
3264 if test "x$with_libvirt" = "xyes"
3265 then
3266         SAVE_CPPFLAGS="$CPPFLAGS"
3267         CPPFLAGS="$CPPFLAGS $with_libvirt_cflags"
3268
3269         AC_CHECK_HEADERS(libvirt/libvirt.h, [],
3270                       [with_libvirt="no (libvirt/libvirt.h not found)"])
3271
3272         CPPFLAGS="$SAVE_CPPFLAGS"
3273 fi
3274 if test "x$with_libvirt" = "xyes"
3275 then
3276         SAVE_CFLAGS="$CFLAGS"
3277         SAVE_LDFLAGS="$LDFLAGS"
3278
3279         CFLAGS="$CFLAGS $with_libvirt_cflags"
3280         LDFLAGS="$LDFLAGS $with_libvirt_ldflags"
3281
3282         AC_CHECK_LIB(virt, virDomainBlockStats,
3283                      [with_libvirt="yes"],
3284                      [with_libvirt="no (symbol virDomainBlockStats not found)"])
3285
3286         CFLAGS="$SAVE_CFLAGS"
3287         LDFLAGS="$SAVE_LDFLAGS"
3288 fi
3289 dnl Add the right compiler flags and libraries.
3290 if test "x$with_libvirt" = "xyes"; then
3291         BUILD_WITH_LIBVIRT_CFLAGS="$with_libvirt_cflags"
3292         BUILD_WITH_LIBVIRT_LIBS="$with_libvirt_ldflags"
3293         AC_SUBST(BUILD_WITH_LIBVIRT_CFLAGS)
3294         AC_SUBST(BUILD_WITH_LIBVIRT_LIBS)
3295 fi
3296 # }}}
3297
3298 # $PKG_CONFIG --exists OpenIPMIpthread {{{
3299 with_libopenipmipthread="yes"
3300 with_libopenipmipthread_cflags=""
3301 with_libopenipmipthread_libs=""
3302
3303 AC_MSG_CHECKING([for pkg-config])
3304 temp_result="no"
3305 if test "x$PKG_CONFIG" = "x"
3306 then
3307         with_libopenipmipthread="no"
3308         temp_result="no"
3309 else
3310         temp_result="$PKG_CONFIG"
3311 fi
3312 AC_MSG_RESULT([$temp_result])
3313
3314 if test "x$with_libopenipmipthread" = "xyes"
3315 then
3316         AC_MSG_CHECKING([for libOpenIPMIpthread])
3317         $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
3318         if test "$?" != "0"
3319         then
3320                 with_libopenipmipthread="no ($PKG_CONFIG doesn't know OpenIPMIpthread)"
3321         fi
3322         AC_MSG_RESULT([$with_libopenipmipthread])
3323 fi
3324
3325 if test "x$with_libopenipmipthread" = "xyes"
3326 then
3327         AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS])
3328         temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`"
3329         if test "$?" = "0"
3330         then
3331                 with_libopenipmipthread_cflags="$temp_result"
3332         else
3333                 with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)"
3334                 temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed"
3335         fi
3336         AC_MSG_RESULT([$temp_result])
3337 fi
3338
3339 if test "x$with_libopenipmipthread" = "xyes"
3340 then
3341         AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS])
3342         temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`"
3343         if test "$?" = "0"
3344         then
3345                 with_libopenipmipthread_ldflags="$temp_result"
3346         else
3347                 with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)"
3348                 temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed"
3349         fi
3350         AC_MSG_RESULT([$temp_result])
3351 fi
3352
3353 if test "x$with_libopenipmipthread" = "xyes"
3354 then
3355         SAVE_CPPFLAGS="$CPPFLAGS"
3356         CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags"
3357
3358         AC_CHECK_HEADERS(OpenIPMI/ipmi_smi.h,
3359                          [with_libopenipmipthread="yes"],
3360                          [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"],
3361 [#include <OpenIPMI/ipmiif.h>
3362 #include <OpenIPMI/ipmi_err.h>
3363 #include <OpenIPMI/ipmi_posix.h>
3364 #include <OpenIPMI/ipmi_conn.h>
3365 ])
3366
3367         CPPFLAGS="$SAVE_CPPFLAGS"
3368 fi
3369
3370 if test "x$with_libopenipmipthread" = "xyes"
3371 then
3372         BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags"
3373         BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags"
3374         AC_SUBST(BUILD_WITH_OPENIPMI_CFLAGS)
3375         AC_SUBST(BUILD_WITH_OPENIPMI_LIBS)
3376 fi
3377 # }}}
3378
3379 PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
3380                 [with_libnotify="yes"],
3381                 [with_libnotify="no ($LIBNOTIFY_PKG_ERRORS)"])
3382
3383 # Check for enabled/disabled features
3384 #
3385
3386 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
3387 # ------------------------------------------------------------
3388 dnl
3389 m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
3390 dnl
3391 AC_DEFUN(
3392         [AC_COLLECTD],
3393         [
3394         m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
3395         m4_if(
3396                 [$2],
3397                 [enable],
3398                 [dnl
3399                 m4_define([EnDis],[disabled])dnl
3400                 m4_define([YesNo],[no])dnl
3401                 ],dnl
3402                 [m4_if(
3403                         [$2],
3404                         [disable],
3405                         [dnl
3406                         m4_define([EnDis],[enabled])dnl
3407                         m4_define([YesNo],[yes])dnl
3408                         ],
3409                         [dnl
3410                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
3411                         ]dnl
3412                 )]dnl
3413         )dnl
3414         m4_if([$3], [feature], [],
3415                 [m4_if(
3416                         [$3], [module], [],
3417                         [dnl
3418                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
3419                         ]dnl
3420                 )]dnl
3421         )dnl
3422         AC_ARG_ENABLE(
3423                 [$1],
3424                 AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
3425                 [],
3426                 enable_$1='[YesNo]'dnl
3427         )# AC_ARG_ENABLE
3428 if test "x$enable_$1" = "xno"
3429 then
3430         collectd_$1=0
3431 else
3432         if test "x$enable_$1" = "xyes"
3433         then
3434                 collectd_$1=1
3435         else
3436                 AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
3437                 collectd_$1=1
3438                 enable_$1='yes'
3439         fi
3440 fi
3441         AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
3442         AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
3443         ]dnl
3444 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
3445
3446 # AC_PLUGIN(name, default, info)
3447 # ------------------------------------------------------------
3448 dnl
3449 AC_DEFUN(
3450   [AC_PLUGIN],
3451   [
3452     enable_plugin="no"
3453     force="no"
3454     AC_ARG_ENABLE([$1], AC_HELP_STRING([--enable-$1], [$3]),
3455     [
3456      if test "x$enableval" = "xyes"
3457      then
3458              enable_plugin="yes"
3459      else if test "x$enableval" = "xforce"
3460      then
3461              enable_plugin="yes"
3462              force="yes"
3463      else
3464              enable_plugin="no"
3465      fi; fi
3466     ],
3467     [
3468          if test "x$enable_all_plugins" = "xauto"
3469          then
3470              if test "x$2" = "xyes"
3471              then
3472                      enable_plugin="yes"
3473              else
3474                      enable_plugin="no"
3475              fi
3476          else
3477              enable_plugin="$enable_all_plugins"
3478          fi
3479     ])
3480     if test "x$enable_plugin" = "xyes"
3481     then
3482             if test "x$2" = "xyes" || test "x$force" = "xyes"
3483             then
3484                     AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
3485                     if test "x$2" != "xyes"
3486                     then
3487                             dependency_warning="yes"
3488                     fi
3489             else # User passed "yes" but dependency checking yielded "no" => Dependency problem.
3490                     dependency_error="yes"
3491                     enable_plugin="no (dependency error)"
3492             fi
3493     fi
3494     AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), test "x$enable_plugin" = "xyes")
3495     enable_$1="$enable_plugin"
3496   ]
3497 )# AC_PLUGIN(name, default, info)
3498
3499 m4_divert_once([HELP_ENABLE], [
3500 collectd features:])
3501 # FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
3502 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
3503 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
3504 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
3505
3506 dependency_warning="no"
3507 dependency_error="no"
3508
3509 plugin_ascent="no"
3510 plugin_battery="no"
3511 plugin_bind="no"
3512 plugin_conntrack="no"
3513 plugin_cpu="no"
3514 plugin_cpufreq="no"
3515 plugin_curl_json="no"
3516 plugin_df="no"
3517 plugin_disk="no"
3518 plugin_entropy="no"
3519 plugin_interface="no"
3520 plugin_ipmi="no"
3521 plugin_ipvs="no"
3522 plugin_irq="no"
3523 plugin_libvirt="no"
3524 plugin_load="no"
3525 plugin_memory="no"
3526 plugin_multimeter="no"
3527 plugin_nfs="no"
3528 plugin_fscache="no"
3529 plugin_perl="no"
3530 plugin_processes="no"
3531 plugin_protocols="no"
3532 plugin_serial="no"
3533 plugin_swap="no"
3534 plugin_tape="no"
3535 plugin_tcpconns="no"
3536 plugin_ted="no"
3537 plugin_thermal="no"
3538 plugin_users="no"
3539 plugin_uptime="no"
3540 plugin_vmem="no"
3541 plugin_vserver="no"
3542 plugin_wireless="no"
3543 plugin_zfs_arc="no"
3544
3545 # Linux
3546 if test "x$ac_system" = "xLinux"
3547 then
3548         plugin_battery="yes"
3549         plugin_conntrack="yes"
3550         plugin_cpu="yes"
3551         plugin_cpufreq="yes"
3552         plugin_disk="yes"
3553         plugin_entropy="yes"
3554         plugin_interface="yes"
3555         plugin_irq="yes"
3556         plugin_load="yes"
3557         plugin_memory="yes"
3558         plugin_nfs="yes"
3559         plugin_fscache="yes"
3560         plugin_processes="yes"
3561         plugin_protocols="yes"
3562         plugin_serial="yes"
3563         plugin_swap="yes"
3564         plugin_tcpconns="yes"
3565         plugin_thermal="yes"
3566         plugin_uptime="yes"
3567         plugin_vmem="yes"
3568         plugin_vserver="yes"
3569         plugin_wireless="yes"
3570
3571         if test "x$have_net_ip_vs_h" = "xyes" -o "x$have_ip_vs_h" = "xyes"
3572         then
3573                 plugin_ipvs="yes"
3574         fi
3575 fi
3576
3577 if test "x$ac_system" = "xOpenBSD"
3578 then
3579         plugin_tcpconns="yes"
3580 fi
3581
3582 # Mac OS X devices
3583 if test "x$with_libiokit" = "xyes"
3584 then
3585         plugin_battery="yes"
3586         plugin_disk="yes"
3587 fi
3588
3589 # Solaris
3590 if test "x$with_kstat" = "xyes"
3591 then
3592         plugin_uptime="yes"
3593         plugin_zfs_arc="yes"
3594 fi
3595
3596 if test "x$with_devinfo$with_kstat" = "xyesyes"
3597 then
3598         plugin_cpu="yes"
3599         plugin_disk="yes"
3600         plugin_interface="yes"
3601         plugin_memory="yes"
3602         plugin_tape="yes"
3603 fi
3604
3605 if test "x$have_sys_swap_h$with_kstat$ac_system" = "xyesyesSolaris"
3606 then
3607         plugin_swap="yes"
3608 fi
3609
3610 # libstatgrab
3611 if test "x$with_libstatgrab" = "xyes"
3612 then
3613         plugin_cpu="yes"
3614         plugin_disk="yes"
3615         plugin_interface="yes"
3616         plugin_load="yes"
3617         plugin_memory="yes"
3618         plugin_swap="yes"
3619         plugin_users="yes"
3620 fi
3621
3622 if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
3623 then
3624         plugin_ascent="yes"
3625         plugin_bind="yes"
3626 fi
3627
3628 if test "x$with_libopenipmipthread" = "xyes"
3629 then
3630         plugin_ipmi="yes"
3631 fi
3632
3633 if test "x$with_libcurl" = "xyes" && test "x$with_libyajl" = "xyes"
3634 then
3635         plugin_curl_json="yes"
3636 fi
3637
3638 if test "x$have_processor_info" = "xyes"
3639 then
3640         plugin_cpu="yes"
3641 fi
3642 if test "x$have_sysctl" = "xyes"
3643 then
3644         plugin_cpu="yes"
3645         plugin_memory="yes"
3646         plugin_swap="yes"
3647         plugin_uptime="yes"
3648 fi
3649 if test "x$have_sysctlbyname" = "xyes"
3650 then
3651         plugin_cpu="yes"
3652         plugin_memory="yes"
3653         plugin_tcpconns="yes"
3654 fi
3655
3656 # Df plugin: Check if we know how to determine mount points first.
3657 #if test "x$have_listmntent" = "xyes"; then
3658 #       plugin_df="yes"
3659 #fi
3660 if test "x$have_getvfsstat" = "xyes" || test "x$have_getfsstat" = "xyes"
3661 then
3662         plugin_df="yes"
3663 fi
3664 if test "x$c_cv_have_two_getmntent" = "xyes" || test "x$have_getmntent" = "xgen" || test "x$have_getmntent" = "xsun"
3665 then
3666         plugin_df="yes"
3667 fi
3668 #if test "x$have_getmntent" = "xseq"
3669 #then
3670 #       plugin_df="yes"
3671 #fi
3672 if test "x$c_cv_have_one_getmntent" = "xyes"
3673 then
3674         plugin_df="yes"
3675 fi
3676
3677 # Df plugin: Check if we have either `statfs' or `statvfs' second.
3678 if test "x$plugin_df" = "xyes"
3679 then
3680         plugin_df="no"
3681         if test "x$have_statfs" = "xyes"
3682         then
3683                 plugin_df="yes"
3684         fi
3685         if test "x$have_statvfs" = "xyes"
3686         then
3687                 plugin_df="yes"
3688         fi
3689 fi
3690
3691 if test "x$have_getifaddrs" = "xyes"
3692 then
3693         plugin_interface="yes"
3694 fi
3695
3696 if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes"
3697 then
3698         plugin_libvirt="yes"
3699 fi
3700
3701 if test "x$have_getloadavg" = "xyes"
3702 then
3703         plugin_load="yes"
3704 fi
3705
3706 if test "x$c_cv_have_libperl$c_cv_have_perl_ithreads" = "xyesyes"
3707 then
3708         plugin_perl="yes"
3709 fi
3710
3711 # Mac OS X memory interface
3712 if test "x$have_host_statistics" = "xyes"
3713 then
3714         plugin_memory="yes"
3715 fi
3716
3717 if test "x$have_termios_h" = "xyes"
3718 then
3719         plugin_multimeter="yes"
3720         plugin_ted="yes"
3721 fi
3722
3723 if test "x$have_thread_info" = "xyes"
3724 then
3725         plugin_processes="yes"
3726 fi
3727
3728 if test "x$with_kvm_getprocs" = "xyes" && test "x$have_struct_kinfo_proc_freebsd" = "xyes"
3729 then
3730         plugin_processes="yes"
3731 fi
3732
3733 if test "x$with_kvm_getswapinfo" = "xyes"
3734 then
3735         plugin_swap="yes"
3736 fi
3737
3738 if test "x$have_swapctl" = "xyes"
3739 then
3740         plugin_swap="yes"
3741 fi
3742
3743 if test "x$with_kvm_openfiles$with_kvm_nlist" = "xyesyes"
3744 then
3745         plugin_tcpconns="yes"
3746 fi
3747
3748 if test "x$have_getutent" = "xyes"
3749 then
3750         plugin_users="yes"
3751 fi
3752 if test "x$have_getutxent" = "xyes"
3753 then
3754         plugin_users="yes"
3755 fi
3756
3757 m4_divert_once([HELP_ENABLE], [
3758 collectd plugins:])
3759
3760 AC_ARG_ENABLE([all-plugins],
3761                 AC_HELP_STRING([--enable-all-plugins],
3762                                 [enable all plugins (auto by def)]),
3763                 [
3764                  if test "x$enableval" = "xyes"
3765                  then
3766                          enable_all_plugins="yes"
3767                  else if test "x$enableval" = "xauto"
3768                  then
3769                          enable_all_plugins="auto"
3770                  else
3771                          enable_all_plugins="no"
3772                  fi; fi
3773                 ],
3774                 [enable_all_plugins="auto"])
3775
3776 m4_divert_once([HELP_ENABLE], [])
3777
3778 AC_PLUGIN([apache],      [$with_libcurl],      [Apache httpd statistics])
3779 AC_PLUGIN([apcups],      [yes],                [Statistics of UPSes by APC])
3780 AC_PLUGIN([apple_sensors], [$with_libiokit],   [Apple's hardware sensors])
3781 AC_PLUGIN([ascent],      [$plugin_ascent],     [AscentEmu player statistics])
3782 AC_PLUGIN([battery],     [$plugin_battery],    [Battery statistics])
3783 AC_PLUGIN([bind],        [$plugin_bind],       [ISC Bind nameserver statistics])
3784 AC_PLUGIN([conntrack],   [$plugin_conntrack],  [nf_conntrack statistics])
3785 AC_PLUGIN([cpufreq],     [$plugin_cpufreq],    [CPU frequency statistics])
3786 AC_PLUGIN([cpu],         [$plugin_cpu],        [CPU usage statistics])
3787 AC_PLUGIN([csv],         [yes],                [CSV output plugin])
3788 AC_PLUGIN([curl],        [$with_libcurl],      [CURL generic web statistics])
3789 AC_PLUGIN([curl_json],   [$plugin_curl_json],    [CouchDB statistics])
3790 AC_PLUGIN([dbi],         [$with_libdbi],       [General database statistics])
3791 AC_PLUGIN([df],          [$plugin_df],         [Filesystem usage statistics])
3792 AC_PLUGIN([disk],        [$plugin_disk],       [Disk usage statistics])
3793 AC_PLUGIN([dns],         [$with_libpcap],      [DNS traffic analysis])
3794 AC_PLUGIN([email],       [yes],                [EMail statistics])
3795 AC_PLUGIN([entropy],     [$plugin_entropy],    [Entropy statistics])
3796 AC_PLUGIN([exec],        [yes],                [Execution of external programs])
3797 AC_PLUGIN([filecount],   [yes],                [Count files in directories])
3798 AC_PLUGIN([fscache],     [$plugin_fscache],    [fscache statistics])
3799 AC_PLUGIN([gmond],       [$with_libganglia],   [Ganglia plugin])
3800 AC_PLUGIN([hddtemp],     [yes],                [Query hddtempd])
3801 AC_PLUGIN([interface],   [$plugin_interface],  [Interface traffic statistics])
3802 AC_PLUGIN([ipmi],        [$plugin_ipmi],       [IPMI sensor statistics])
3803 AC_PLUGIN([iptables],    [$with_libiptc],      [IPTables rule counters])
3804 AC_PLUGIN([ipvs],        [$plugin_ipvs],       [IPVS connection statistics])
3805 AC_PLUGIN([irq],         [$plugin_irq],        [IRQ statistics])
3806 AC_PLUGIN([java],        [$with_java],         [Embed the Java Virtual Machine])
3807 AC_PLUGIN([libvirt],     [$plugin_libvirt],    [Virtual machine statistics])
3808 AC_PLUGIN([load],        [$plugin_load],       [System load])
3809 AC_PLUGIN([logfile],     [yes],                [File logging plugin])
3810 AC_PLUGIN([madwifi],     [$have_linux_wireless_h], [Madwifi wireless statistics])
3811 AC_PLUGIN([match_empty_counter], [yes],        [The empty counter match])
3812 AC_PLUGIN([match_regex], [yes],                [The regex match])
3813 AC_PLUGIN([match_timediff], [yes],             [The timediff match])
3814 AC_PLUGIN([match_value], [yes],                [The value match])
3815 AC_PLUGIN([mbmon],       [yes],                [Query mbmond])
3816 AC_PLUGIN([memcachec],   [$with_libmemcached], [memcachec statistics])
3817 AC_PLUGIN([memcached],   [yes],                [memcached statistics])
3818 AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
3819 AC_PLUGIN([multimeter],  [$plugin_multimeter], [Read multimeter values])
3820 AC_PLUGIN([mysql],       [$with_libmysql],     [MySQL statistics])
3821 AC_PLUGIN([netlink],     [$with_libnetlink],   [Enhanced Linux network statistics])
3822 AC_PLUGIN([network],     [yes],                [Network communication plugin])
3823 AC_PLUGIN([nfs],         [$plugin_nfs],        [NFS statistics])
3824 AC_PLUGIN([nginx],       [$with_libcurl],      [nginx statistics])
3825 AC_PLUGIN([notify_desktop], [$with_libnotify], [Desktop notifications])
3826 AC_PLUGIN([notify_email], [$with_libesmtp],    [Email notifier])
3827 AC_PLUGIN([ntpd],        [yes],                [NTPd statistics])
3828 AC_PLUGIN([nut],         [$with_libupsclient], [Network UPS tools statistics])
3829 AC_PLUGIN([olsrd],       [yes],                [olsrd statistics])
3830 AC_PLUGIN([onewire],     [$with_libowcapi],    [OneWire sensor statistics])
3831 AC_PLUGIN([openvpn],     [yes],                [OpenVPN client statistics])
3832 AC_PLUGIN([oracle],      [$with_oracle],       [Oracle plugin])
3833 AC_PLUGIN([perl],        [$plugin_perl],       [Embed a Perl interpreter])
3834 AC_PLUGIN([ping],        [$with_liboping],     [Network latency statistics])
3835 AC_PLUGIN([postgresql],  [$with_libpq],        [PostgreSQL database statistics])
3836 AC_PLUGIN([powerdns],    [yes],                [PowerDNS statistics])
3837 AC_PLUGIN([processes],   [$plugin_processes],  [Process statistics])
3838 AC_PLUGIN([protocols],   [$plugin_protocols],  [Protocol (IP, TCP, ...) statistics])
3839 AC_PLUGIN([rrdcached],   [$librrd_rrdc_update], [RRDTool output plugin])
3840 AC_PLUGIN([rrdtool],     [$with_librrd],       [RRDTool output plugin])
3841 AC_PLUGIN([sensors],     [$with_libsensors],   [lm_sensors statistics])
3842 AC_PLUGIN([serial],      [$plugin_serial],     [serial port traffic])
3843 AC_PLUGIN([snmp],        [$with_libnetsnmp],   [SNMP querying plugin])
3844 AC_PLUGIN([swap],        [$plugin_swap],       [Swap usage statistics])
3845 AC_PLUGIN([syslog],      [$have_syslog],       [Syslog logging plugin])
3846 AC_PLUGIN([table],       [yes],                [Parsing of tabular data])
3847 AC_PLUGIN([tail],        [yes],                [Parsing of logfiles])
3848 AC_PLUGIN([tape],        [$plugin_tape],       [Tape drive statistics])
3849 AC_PLUGIN([target_notification], [yes],        [The notification target])
3850 AC_PLUGIN([target_replace], [yes],             [The replace target])
3851 AC_PLUGIN([target_set],  [yes],                [The set target])
3852 AC_PLUGIN([tcpconns],    [$plugin_tcpconns],   [TCP connection statistics])
3853 AC_PLUGIN([teamspeak2],  [yes],                [TeamSpeak2 server statistics])
3854 AC_PLUGIN([ted],         [$plugin_ted],        [Read The Energy Detective values])
3855 AC_PLUGIN([thermal],     [$plugin_thermal],    [Linux ACPI thermal zone statistics])
3856 AC_PLUGIN([tokyotyrant], [$with_libtokyotyrant],  [TokyoTyrant database statistics])
3857 AC_PLUGIN([unixsock],    [yes],                [Unixsock communication plugin])
3858 AC_PLUGIN([uptime],      [$plugin_uptime],     [Uptime statistics])
3859 AC_PLUGIN([users],       [$plugin_users],      [User statistics])
3860 AC_PLUGIN([uuid],        [yes],                [UUID as hostname plugin])
3861 AC_PLUGIN([vmem],        [$plugin_vmem],       [Virtual memory statistics])
3862 AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
3863 AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
3864 AC_PLUGIN([write_http],  [$with_libcurl],      [HTTP output plugin])
3865 AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
3866 AC_PLUGIN([zfs_arc],     [$plugin_zfs_arc],    [ZFS ARC statistics])
3867
3868 dnl Default configuration file
3869 # Load either syslog or logfile
3870 LOAD_PLUGIN_SYSLOG=""
3871 LOAD_PLUGIN_LOGFILE=""
3872
3873 AC_MSG_CHECKING([which default log plugin to load])
3874 default_log_plugin="none"
3875 if test "x$enable_syslog" = "xyes"
3876 then
3877         default_log_plugin="syslog"
3878 else
3879         LOAD_PLUGIN_SYSLOG="##"
3880 fi
3881
3882 if test "x$enable_logfile" = "xyes"
3883 then
3884         if test "x$default_log_plugin" = "xnone"
3885         then
3886                 default_log_plugin="logfile"
3887         else
3888                 LOAD_PLUGIN_LOGFILE="#"
3889         fi
3890 else
3891         LOAD_PLUGIN_LOGFILE="##"
3892 fi
3893 AC_MSG_RESULT([$default_log_plugin])
3894
3895 AC_SUBST(LOAD_PLUGIN_SYSLOG)
3896 AC_SUBST(LOAD_PLUGIN_LOGFILE)
3897
3898 DEFAULT_LOG_LEVEL="info"
3899 if test "x$enable_debug" = "xyes"
3900 then
3901         DEFAULT_LOG_LEVEL="debug"
3902 fi
3903 AC_SUBST(DEFAULT_LOG_LEVEL)
3904
3905 # Load only one of rrdtool, network, csv in the default config.
3906 LOAD_PLUGIN_RRDTOOL=""
3907 LOAD_PLUGIN_NETWORK=""
3908 LOAD_PLUGIN_CSV=""
3909
3910 AC_MSG_CHECKING([which default write plugin to load])
3911 default_write_plugin="none"
3912 if test "x$enable_rrdtool" = "xyes"
3913 then
3914         default_write_plugin="rrdtool"
3915 else
3916         LOAD_PLUGIN_RRDTOOL="##"
3917 fi
3918
3919 if test "x$enable_network" = "xyes"
3920 then
3921         if test "x$default_write_plugin" = "xnone"
3922         then
3923                 default_write_plugin="network"
3924         else
3925                 LOAD_PLUGIN_NETWORK="#"
3926         fi
3927 else
3928         LOAD_PLUGIN_NETWORK="##"
3929 fi
3930
3931 if test "x$enable_csv" = "xyes"
3932 then
3933         if test "x$default_write_plugin" = "xnone"
3934         then
3935                 default_write_plugin="csv"
3936         else
3937                 LOAD_PLUGIN_CSV="#"
3938         fi
3939 else
3940         LOAD_PLUGIN_CSV="##"
3941 fi
3942 AC_MSG_RESULT([$default_write_plugin])
3943
3944 AC_SUBST(LOAD_PLUGIN_RRDTOOL)
3945 AC_SUBST(LOAD_PLUGIN_NETWORK)
3946 AC_SUBST(LOAD_PLUGIN_CSV)
3947
3948 dnl ip_vs.h
3949 if test "x$ac_system" = "xLinux" \
3950         && test "x$have_net_ip_vs_h$have_ip_vs_h" = "xnono"
3951 then
3952         enable_ipvs="$enable_ipvs (ip_vs.h not found)"
3953 fi
3954
3955 dnl Perl bindings
3956 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
3957 [
3958         if test "x$withval" != "xno" && test "x$withval" != "xyes"
3959         then
3960                 PERL_BINDINGS_OPTIONS="$withval"
3961                 with_perl_bindings="yes"
3962         else
3963                 PERL_BINDINGS_OPTIONS=""
3964                 with_perl_bindings="$withval"
3965         fi
3966 ],
3967 [
3968         PERL_BINDINGS_OPTIONS=""
3969         if test -n "$perl_interpreter"
3970         then
3971                 with_perl_bindings="yes"
3972         else
3973                 with_perl_bindings="no (no perl interpreter found)"
3974         fi
3975 ])
3976 if test "x$with_perl_bindings" = "xyes"
3977 then
3978         PERL_BINDINGS="perl"
3979 else
3980         PERL_BINDINGS=""
3981 fi
3982 AC_SUBST(PERL_BINDINGS)
3983 AC_SUBST(PERL_BINDINGS_OPTIONS)
3984
3985 dnl libcollectdclient
3986 LCC_VERSION_MAJOR=`echo $PACKAGE_VERSION | cut -d'.' -f1`
3987 LCC_VERSION_MINOR=`echo $PACKAGE_VERSION | cut -d'.' -f2`
3988 LCC_VERSION_PATCH=`echo $PACKAGE_VERSION | cut -d'.' -f3`
3989
3990 LCC_VERSION_EXTRA=`echo $PACKAGE_VERSION | cut -d'.' -f4-`
3991
3992 LCC_VERSION_STRING="$LCC_VERSION_MAJOR.$LCC_VERSION_MINOR.$LCC_VERSION_PATCH"
3993
3994 AC_SUBST(LCC_VERSION_MAJOR)
3995 AC_SUBST(LCC_VERSION_MINOR)
3996 AC_SUBST(LCC_VERSION_PATCH)
3997 AC_SUBST(LCC_VERSION_EXTRA)
3998 AC_SUBST(LCC_VERSION_STRING)
3999
4000 AC_CONFIG_FILES(src/libcollectdclient/lcc_features.h)
4001
4002 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)
4003
4004 if test "x$with_librrd" = "xyes" \
4005         && test "x$librrd_threadsafe" != "xyes"
4006 then
4007         with_librrd="yes (warning: librrd is not thread-safe)"
4008 fi
4009
4010 if test "x$with_libiptc" = "xyes" -a "x$with_own_libiptc" = "xyes"
4011 then
4012         with_libiptc="yes (shipped version)"
4013 fi
4014
4015 if test "x$with_libperl" = "xyes"
4016 then
4017         with_libperl="yes (version `$perl_interpreter -MConfig -e 'print $Config{version};'`)"
4018 else
4019         enable_perl="no (needs libperl)"
4020 fi
4021
4022 if test "x$enable_perl" = "xno" && test "x$c_cv_have_perl_ithreads" = "xno"
4023 then
4024         enable_perl="no (libperl doesn't support ithreads)"
4025 fi
4026
4027 if test "x$with_perl_bindings" = "xyes" \
4028         && test "x$PERL_BINDINGS_OPTIONS" != "x"
4029 then
4030         with_perl_bindings="yes ($PERL_BINDINGS_OPTIONS)"
4031 fi
4032
4033 cat <<EOF;
4034
4035 Configuration:
4036   Libraries:
4037     libcurl . . . . . . . $with_libcurl
4038     libdbi  . . . . . . . $with_libdbi
4039     libesmtp  . . . . . . $with_libesmtp
4040     libganglia  . . . . . $with_libganglia
4041     libgcrypt . . . . . . $with_libgcrypt
4042     libiokit  . . . . . . $with_libiokit
4043     libiptc . . . . . . . $with_libiptc
4044     libjvm  . . . . . . . $with_java
4045     libkstat  . . . . . . $with_kstat
4046     libkvm  . . . . . . . $with_libkvm
4047     libmemcached  . . . . $with_libmemcached
4048     libmysql  . . . . . . $with_libmysql
4049     libnetlink  . . . . . $with_libnetlink
4050     libnetsnmp  . . . . . $with_libnetsnmp
4051     libnotify . . . . . . $with_libnotify
4052     liboconfig  . . . . . $with_liboconfig
4053     libopenipmi . . . . . $with_libopenipmipthread
4054     liboping  . . . . . . $with_liboping
4055     libpcap . . . . . . . $with_libpcap
4056     libperl . . . . . . . $with_libperl
4057     libpq . . . . . . . . $with_libpq
4058     libpthread  . . . . . $with_libpthread
4059     librrd  . . . . . . . $with_librrd
4060     libsensors  . . . . . $with_libsensors
4061     libstatgrab . . . . . $with_libstatgrab
4062     libtokyotyrant  . . . $with_libtokyotyrant
4063     libupsclient  . . . . $with_libupsclient
4064     libvirt . . . . . . . $with_libvirt
4065     libxml2 . . . . . . . $with_libxml2
4066     libxmms . . . . . . . $with_libxmms
4067     libyajl . . . . . . . $with_libyajl
4068     oracle  . . . . . . . $with_oracle
4069
4070   Features:
4071     daemon mode . . . . . $enable_daemon
4072     debug . . . . . . . . $enable_debug
4073
4074   Bindings:
4075     perl  . . . . . . . . $with_perl_bindings
4076
4077   Modules:
4078     apache  . . . . . . . $enable_apache
4079     apcups  . . . . . . . $enable_apcups
4080     apple_sensors . . . . $enable_apple_sensors
4081     ascent  . . . . . . . $enable_ascent
4082     battery . . . . . . . $enable_battery
4083     bind  . . . . . . . . $enable_bind
4084     conntrack . . . . . . $enable_conntrack
4085     cpu . . . . . . . . . $enable_cpu
4086     cpufreq . . . . . . . $enable_cpufreq
4087     csv . . . . . . . . . $enable_csv
4088     curl  . . . . . . . . $enable_curl
4089     curl_json . . . . . . $enable_curl_json
4090     dbi . . . . . . . . . $enable_dbi
4091     df  . . . . . . . . . $enable_df
4092     disk  . . . . . . . . $enable_disk
4093     dns . . . . . . . . . $enable_dns
4094     email . . . . . . . . $enable_email
4095     entropy . . . . . . . $enable_entropy
4096     exec  . . . . . . . . $enable_exec
4097     filecount . . . . . . $enable_filecount
4098     fscache . . . . . . . $enable_fscache
4099     gmond . . . . . . . . $enable_gmond
4100     hddtemp . . . . . . . $enable_hddtemp
4101     interface . . . . . . $enable_interface
4102     ipmi  . . . . . . . . $enable_ipmi
4103     iptables  . . . . . . $enable_iptables
4104     ipvs  . . . . . . . . $enable_ipvs
4105     irq . . . . . . . . . $enable_irq
4106     java  . . . . . . . . $enable_java
4107     libvirt . . . . . . . $enable_libvirt
4108     load  . . . . . . . . $enable_load
4109     logfile . . . . . . . $enable_logfile
4110     madwifi . . . . . . . $enable_madwifi
4111     match_empty_counter . $enable_match_empty_counter
4112     match_regex . . . . . $enable_match_regex
4113     match_timediff  . . . $enable_match_timediff
4114     match_value . . . . . $enable_match_value
4115     mbmon . . . . . . . . $enable_mbmon
4116     memcachec . . . . . . $enable_memcachec
4117     memcached . . . . . . $enable_memcached
4118     memory  . . . . . . . $enable_memory
4119     multimeter  . . . . . $enable_multimeter
4120     mysql . . . . . . . . $enable_mysql
4121     netlink . . . . . . . $enable_netlink
4122     network . . . . . . . $enable_network
4123     nfs . . . . . . . . . $enable_nfs
4124     nginx . . . . . . . . $enable_nginx
4125     notify_desktop  . . . $enable_notify_desktop
4126     notify_email  . . . . $enable_notify_email
4127     ntpd  . . . . . . . . $enable_ntpd
4128     nut . . . . . . . . . $enable_nut
4129     olsrd . . . . . . . . $enable_olsrd
4130     onewire . . . . . . . $enable_onewire
4131     openvpn . . . . . . . $enable_openvpn
4132     oracle  . . . . . . . $enable_oracle
4133     perl  . . . . . . . . $enable_perl
4134     ping  . . . . . . . . $enable_ping
4135     postgresql  . . . . . $enable_postgresql
4136     powerdns  . . . . . . $enable_powerdns
4137     processes . . . . . . $enable_processes
4138     protocols . . . . . . $enable_protocols
4139     rrdcached . . . . . . $enable_rrdcached
4140     rrdtool . . . . . . . $enable_rrdtool
4141     sensors . . . . . . . $enable_sensors
4142     serial  . . . . . . . $enable_serial
4143     snmp  . . . . . . . . $enable_snmp
4144     swap  . . . . . . . . $enable_swap
4145     syslog  . . . . . . . $enable_syslog
4146     table . . . . . . . . $enable_table
4147     tail  . . . . . . . . $enable_tail
4148     tape  . . . . . . . . $enable_tape
4149     target_notification . $enable_target_notification
4150     target_replace  . . . $enable_target_replace
4151     target_set  . . . . . $enable_target_set
4152     tcpconns  . . . . . . $enable_tcpconns
4153     teamspeak2  . . . . . $enable_teamspeak2
4154     ted . . . . . . . . . $enable_ted
4155     thermal . . . . . . . $enable_thermal
4156     tokyotyrant . . . . . $enable_tokyotyrant
4157     unixsock  . . . . . . $enable_unixsock
4158     uptime  . . . . . . . $enable_uptime
4159     users . . . . . . . . $enable_users
4160     uuid  . . . . . . . . $enable_uuid
4161     vmem  . . . . . . . . $enable_vmem
4162     vserver . . . . . . . $enable_vserver
4163     wireless  . . . . . . $enable_wireless
4164     write_http  . . . . . $enable_write_http
4165     xmms  . . . . . . . . $enable_xmms
4166     zfs_arc . . . . . . . $enable_zfs_arc
4167
4168 EOF
4169
4170 if test "x$dependency_error" = "xyes"; then
4171         AC_MSG_ERROR("Some plugins are missing dependencies - see the summary above for details")
4172 fi
4173
4174 if test "x$dependency_warning" = "xyes"; then
4175         AC_MSG_WARN("Some plugins seem to have missing dependencies but have been enabled forcibly - see the summary above for details")
4176 fi
4177
4178 # vim: set fdm=marker :