Merge branch 'collectd-4.5' into collectd-4.6
[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 AM_INIT_AUTOMAKE(dist-bzip2)
6 AC_LANG(C)
7
8 AC_PREFIX_DEFAULT("/opt/collectd")
9
10 AC_SYS_LARGEFILE
11
12 #
13 # Checks for programs.
14 #
15 AC_PROG_CC
16 AC_PROG_CPP
17 AC_PROG_INSTALL
18 AC_PROG_LN_S
19 AC_PROG_MAKE_SET
20 AM_PROG_CC_C_O
21 AM_CONDITIONAL(COMPILER_IS_GCC, test "x$GCC" = "xyes")
22
23 dnl configure libtool
24 AC_DISABLE_STATIC
25 AC_LIBLTDL_CONVENIENCE
26 AC_SUBST(LTDLINCL)
27 AC_SUBST(LIBLTDL)
28 AC_LIBTOOL_DLOPEN
29 AC_PROG_LIBTOOL
30 AC_PROG_LEX
31 AC_PROG_YACC
32 PKG_PROG_PKG_CONFIG
33 AC_CONFIG_SUBDIRS(libltdl)
34
35 AC_MSG_CHECKING([for kernel type ($host_os)])
36 case $host_os in
37         *linux*)
38         AC_DEFINE([KERNEL_LINUX], 1, [True if program is to be compiled for a Linux kernel])
39         ac_system="Linux"
40         ;;
41         *solaris*)
42         AC_DEFINE([KERNEL_SOLARIS], 1, [True if program is to be compiled for a Solaris kernel])
43         ac_system="Solaris"
44         ;;
45         *darwin*)
46         ac_system="Darwin"
47         ;;
48         *openbsd*)
49         ac_system="OpenBSD"
50         ;;
51         *)
52         ac_system="unknown"
53 esac
54 AC_MSG_RESULT([$ac_system])
55
56 if test "x$ac_system" = "xLinux"
57 then
58         AC_ARG_VAR([KERNEL_DIR], [path to Linux kernel sources])
59         if test -z "$KERNEL_DIR"
60         then
61                 KERNEL_DIR="/lib/modules/`uname -r`/source"
62         fi
63
64         KERNEL_CFLAGS="-I$KERNEL_DIR/include"
65         AC_SUBST(KERNEL_CFLAGS)
66 fi
67
68 if test "x$ac_system" = "xSolaris"
69 then
70         CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
71 fi
72
73 # Where to install .pc files.
74 pkgconfigdir="${libdir}/pkgconfig"
75 AC_SUBST(pkgconfigdir)
76
77 #
78 # Checks for header files.
79 #
80 AC_HEADER_STDC
81 AC_HEADER_SYS_WAIT
82 AC_HEADER_DIRENT
83
84 AC_CHECK_HEADERS(stdio.h stdint.h stdbool.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)
85
86 # For ping library
87 AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
88 [#if HAVE_STDINT_H
89 # include <stdint.h>
90 #endif
91 #if HAVE_SYS_TYPES_H
92 # include <sys/types.h>
93 #endif
94 ])
95 AC_CHECK_HEADERS(netinet/in.h, [], [],
96 [#if HAVE_STDINT_H
97 # include <stdint.h>
98 #endif
99 #if HAVE_SYS_TYPES_H
100 # include <sys/types.h>
101 #endif
102 #if HAVE_NETINET_IN_SYSTM_H
103 # include <netinet/in_systm.h>
104 #endif
105 ])
106 AC_CHECK_HEADERS(netinet/ip.h, [], [],
107 [#if HAVE_STDINT_H
108 # include <stdint.h>
109 #endif
110 #if HAVE_SYS_TYPES_H
111 # include <sys/types.h>
112 #endif
113 #if HAVE_NETINET_IN_SYSTM_H
114 # include <netinet/in_systm.h>
115 #endif
116 #if HAVE_NETINET_IN_H
117 # include <netinet/in.h>
118 #endif
119 ])
120 AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [],
121 [#if HAVE_STDINT_H
122 # include <stdint.h>
123 #endif
124 #if HAVE_SYS_TYPES_H
125 # include <sys/types.h>
126 #endif
127 #if HAVE_NETINET_IN_SYSTM_H
128 # include <netinet/in_systm.h>
129 #endif
130 #if HAVE_NETINET_IN_H
131 # include <netinet/in.h>
132 #endif
133 #if HAVE_NETINET_IP_H
134 # include <netinet/ip.h>
135 #endif
136 ])
137 AC_CHECK_HEADERS(netinet/ip_var.h, [], [],
138 [#if HAVE_STDINT_H
139 # include <stdint.h>
140 #endif
141 #if HAVE_SYS_TYPES_H
142 # include <sys/types.h>
143 #endif
144 #if HAVE_NETINET_IN_SYSTM_H
145 # include <netinet/in_systm.h>
146 #endif
147 #if HAVE_NETINET_IN_H
148 # include <netinet/in.h>
149 #endif
150 #if HAVE_NETINET_IP_H
151 # include <netinet/ip.h>
152 #endif
153 ])
154 AC_CHECK_HEADERS(netinet/ip6.h, [], [],
155 [#if HAVE_STDINT_H
156 # include <stdint.h>
157 #endif
158 #if HAVE_SYS_TYPES_H
159 # include <sys/types.h>
160 #endif
161 #if HAVE_NETINET_IN_SYSTM_H
162 # include <netinet/in_systm.h>
163 #endif
164 #if HAVE_NETINET_IN_H
165 # include <netinet/in.h>
166 #endif
167 ])
168 AC_CHECK_HEADERS(netinet/icmp6.h, [], [],
169 [#if HAVE_STDINT_H
170 # include <stdint.h>
171 #endif
172 #if HAVE_SYS_TYPES_H
173 # include <sys/types.h>
174 #endif
175 #if HAVE_NETINET_IN_SYSTM_H
176 # include <netinet/in_systm.h>
177 #endif
178 #if HAVE_NETINET_IN_H
179 # include <netinet/in.h>
180 #endif
181 #if HAVE_NETINET_IP6_H
182 # include <netinet/ip6.h>
183 #endif
184 ])
185 AC_CHECK_HEADERS(netinet/tcp.h, [], [],
186 [#if HAVE_STDINT_H
187 # include <stdint.h>
188 #endif
189 #if HAVE_SYS_TYPES_H
190 # include <sys/types.h>
191 #endif
192 #if HAVE_NETINET_IN_SYSTM_H
193 # include <netinet/in_systm.h>
194 #endif
195 #if HAVE_NETINET_IN_H
196 # include <netinet/in.h>
197 #endif
198 #if HAVE_NETINET_IP_H
199 # include <netinet/ip.h>
200 #endif
201 ])
202 AC_CHECK_HEADERS(netinet/udp.h, [], [],
203 [#if HAVE_STDINT_H
204 # include <stdint.h>
205 #endif
206 #if HAVE_SYS_TYPES_H
207 # include <sys/types.h>
208 #endif
209 #if HAVE_NETINET_IN_SYSTM_H
210 # include <netinet/in_systm.h>
211 #endif
212 #if HAVE_NETINET_IN_H
213 # include <netinet/in.h>
214 #endif
215 #if HAVE_NETINET_IP_H
216 # include <netinet/ip.h>
217 #endif
218 ])
219
220 # For cpu modules
221 AC_CHECK_HEADERS(sys/dkstat.h)
222 if test "x$ac_system" = "xDarwin"
223 then
224         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)
225         AC_CHECK_HEADERS(CoreFoundation/CoreFoundation.h IOKit/IOKitLib.h IOKit/IOTypes.h IOKit/ps/IOPSKeys.h IOKit/IOBSD.h IOKit/storage/IOBlockStorageDriver.h)
226 fi
227 AC_CHECK_HEADERS(sys/sysctl.h, [], [],
228 [
229 #if HAVE_SYS_TYPES_H
230 #  include <sys/types.h>
231 #endif
232 #if HAVE_SYS_PARAM_H
233 # include <sys/param.h>
234 #endif
235 ])
236
237 # For hddtemp module
238 AC_CHECK_HEADERS(linux/major.h libgen.h)
239
240 # For the battery plugin
241 AC_CHECK_HEADERS(IOKit/ps/IOPowerSources.h, [], [],
242 [
243 #if HAVE_IOKIT_IOKITLIB_H
244 #  include <IOKit/IOKitLib.h>
245 #endif
246 #if HAVE_IOKIT_IOTYPES_H
247 #  include <IOKit/IOTypes.h>
248 #endif
249 ])
250
251 # For the swap module
252 have_sys_swap_h="yes"
253 AC_CHECK_HEADERS(sys/swap.h, [], [have_sys_swap_h="no"],
254 [
255 #if HAVE_SYS_TYPES_H
256 #  include <sys/types.h>
257 #endif
258 #if HAVE_SYS_PARAM_H
259 # include <sys/param.h>
260 #endif
261 ])
262
263 if test "x$have_sys_swap_h$ac_system" = "xnoSolaris"
264 then
265         AC_MSG_NOTICE([Solaris detected and sys/swap.h not found: Try building a 64bit binary.])
266 fi
267
268 # For load module
269 # For the processes plugin
270 # For users module
271 AC_CHECK_HEADERS(sys/loadavg.h linux/config.h utmp.h utmpx.h)
272
273 # For interface plugin
274 AC_CHECK_HEADERS(ifaddrs.h)
275 AC_CHECK_HEADERS(net/if.h, [], [],
276 [
277 #if HAVE_SYS_TYPES_H
278 #  include <sys/types.h>
279 #endif
280 #if HAVE_SYS_SOCKET_H
281 #  include <sys/socket.h>
282 #endif
283 ])
284 AC_CHECK_HEADERS(linux/if.h, [], [],
285 [
286 #if HAVE_SYS_TYPES_H
287 #  include <sys/types.h>
288 #endif
289 #if HAVE_SYS_SOCKET_H
290 #  include <sys/socket.h>
291 #endif
292 ])
293 AC_CHECK_HEADERS(linux/netdevice.h, [], [],
294 [
295 #if HAVE_SYS_TYPES_H
296 #  include <sys/types.h>
297 #endif
298 #if HAVE_SYS_SOCKET_H
299 #  include <sys/socket.h>
300 #endif
301 #if HAVE_LINUX_IF_H
302 # include <linux/if.h>
303 #endif
304 ])
305
306 # For ipvs module
307 have_net_ip_vs_h="no"
308 have_ip_vs_h="no"
309 if test "x$ac_system" = "xLinux"
310 then
311         SAVE_CFLAGS=$CFLAGS
312         CFLAGS="$CFLAGS $KERNEL_CFLAGS"
313
314         AC_CHECK_HEADERS(net/ip_vs.h, [have_net_ip_vs_h="yes"])
315         AC_CHECK_HEADERS(ip_vs.h, [have_ip_vs_h="yes"])
316
317         CFLAGS=$SAVE_CFLAGS
318 fi
319
320 # For quota module
321 AC_CHECK_HEADERS(sys/ucred.h, [], [],
322 [
323 #if HAVE_SYS_TYPES_H
324 #  include <sys/types.h>
325 #endif
326 #if HAVE_SYS_PARAM_H
327 # include <sys/param.h>
328 #endif
329 ])
330
331 # For mount interface
332 AC_CHECK_HEADERS(sys/mount.h, [], [],
333 [
334 #if HAVE_SYS_TYPES_H
335 #  include <sys/types.h>
336 #endif
337 #if HAVE_SYS_PARAM_H
338 # include <sys/param.h>
339 #endif
340 ])
341
342 # For the email plugin
343 AC_CHECK_HEADERS(linux/un.h, [], [],
344 [
345 #if HAVE_SYS_SOCKET_H
346 #       include <sys/socket.h>
347 #endif
348 ])
349
350 AC_CHECK_HEADERS(pwd.h grp.h sys/un.h ctype.h limits.h sys/quota.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)
351
352 # For the dns plugin
353 AC_CHECK_HEADERS(arpa/nameser.h)
354 AC_CHECK_HEADERS(arpa/nameser_compat.h, [], [],
355 [
356 #if HAVE_ARPA_NAMESER_H
357 # include <arpa/nameser.h>
358 #endif
359 ])
360
361 AC_CHECK_HEADERS(net/if_arp.h, [], [],
362 [#if HAVE_SYS_SOCKET_H
363 # include <sys/socket.h>
364 #endif
365 ])
366 AC_CHECK_HEADERS(net/ppp_defs.h)
367 AC_CHECK_HEADERS(net/if_ppp.h, [], [],
368 [#if HAVE_NET_PPP_DEFS_H
369 # include <net/ppp_defs.h>
370 #endif
371 ])
372 AC_CHECK_HEADERS(netinet/if_ether.h, [], [],
373 [#if HAVE_STDINT_H
374 # include <stdint.h>
375 #endif
376 #if HAVE_SYS_TYPES_H
377 # include <sys/types.h>
378 #endif
379 #if HAVE_SYS_SOCKET_H
380 # include <sys/socket.h>
381 #endif
382 #if HAVE_NET_IF_H
383 # include <net/if.h>
384 #endif
385 #if HAVE_NETINET_IN_H
386 # include <netinet/in.h>
387 #endif
388 ])
389
390 # For the multimeter plugin
391 have_termios_h="no"
392 AC_CHECK_HEADERS(termios.h, [have_termios_h="yes"])
393
394 #
395 # Checks for typedefs, structures, and compiler characteristics.
396 #
397 AC_C_CONST
398 AC_TYPE_PID_T
399 AC_TYPE_SIZE_T
400 AC_TYPE_UID_T
401 AC_HEADER_TIME
402
403 #
404 # Checks for library functions.
405 #
406 AC_PROG_GCC_TRADITIONAL
407 AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog closelog sysconf)
408
409 AC_FUNC_STRERROR_R
410
411 AC_CACHE_CHECK([for strtok_r],
412   [c_cv_have_strtok_r_default],
413   AC_LINK_IFELSE(
414     AC_LANG_PROGRAM(
415     [[[[
416 #include <stdlib.h>
417 #include <stdio.h>
418 #include <string.h>
419     ]]]],
420     [[[[
421       char buffer[] = "foo,bar,baz";
422       char *token;
423       char *dummy;
424       char *saveptr;
425
426       dummy = buffer;
427       saveptr = NULL;
428       while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
429       {
430         dummy = NULL;
431         printf ("token = %s;\n", token);
432       }
433     ]]]]),
434     [c_cv_have_strtok_r_default="yes"],
435     [c_cv_have_strtok_r_default="no"]
436   )
437 )
438
439 if test "x$c_cv_have_strtok_r_default" = "xno"
440 then
441   SAVE_CFLAGS="$CFLAGS"
442   CFLAGS="$CFLAGS -D_REENTRANT=1"
443
444   AC_CACHE_CHECK([if strtok_r needs _REENTRANT],
445     [c_cv_have_strtok_r_reentrant],
446     AC_LINK_IFELSE(
447       AC_LANG_PROGRAM(
448       [[[[
449 #include <stdlib.h>
450 #include <stdio.h>
451 #include <string.h>
452       ]]]],
453       [[[[
454         char buffer[] = "foo,bar,baz";
455         char *token;
456         char *dummy;
457         char *saveptr;
458
459         dummy = buffer;
460         saveptr = NULL;
461         while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
462         {
463           dummy = NULL;
464           printf ("token = %s;\n", token);
465         }
466       ]]]]),
467       [c_cv_have_strtok_r_reentrant="yes"],
468       [AC_MSG_FAILURE([strtok_r isn't available. Please file a bugreport!])]
469     )
470   )
471 fi
472
473 AC_CHECK_FUNCS(getpwnam_r getgrnam_r setgroups regcomp regerror regexec regfree)
474
475 socket_needs_socket="no"
476 AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [socket_needs_socket="yes"], AC_MSG_ERROR(cannot find socket)))
477 AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
478
479 nanosleep_needs_rt="no"
480 AC_CHECK_FUNCS(nanosleep, [], AC_CHECK_LIB(rt, nanosleep, [nanosleep_needs_rt="yes"], AC_MSG_ERROR(cannot find nanosleep)))
481 AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes")
482
483 AC_CHECK_FUNCS(sysctl, [have_sysctl="yes"], [have_sysctl="no"])
484 AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
485 AC_CHECK_FUNCS(host_statistics, [have_host_statistics="yes"], [have_host_statistics="no"])
486 AC_CHECK_FUNCS(processor_info, [have_processor_info="yes"], [have_processor_info="no"])
487 AC_CHECK_FUNCS(thread_info, [have_thread_info="yes"], [have_thread_info="no"])
488 AC_CHECK_FUNCS(statfs, [have_statfs="yes"], [have_statfs="no"])
489 AC_CHECK_FUNCS(statvfs, [have_statvfs="yes"], [have_statvfs="no"])
490 AC_CHECK_FUNCS(getifaddrs, [have_getifaddrs="yes"], [have_getifaddrs="no"])
491 AC_CHECK_FUNCS(syslog, [have_syslog="yes"], [have_syslog="no"])
492 AC_CHECK_FUNCS(getutent, [have_getutent="yes"], [have_getutent="no"])
493 AC_CHECK_FUNCS(getutxent, [have_getutxent="yes"], [have_getutxent="no"])
494 AC_CHECK_FUNCS(swapctl, [have_swapctl="yes"], [have_swapctl="no"])
495
496 # For load module
497 AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
498
499 # Check for NAN
500 AC_ARG_WITH(nan-emulation, [AS_HELP_STRING([--with-nan-emulation], [use emulated NAN. For crosscompiling only.])],
501 [
502  if test "x$withval" = "xno"; then
503          nan_type="none"
504  else if test "x$withval" = "xyes"; then
505          nan_type="zero"
506  else
507          nan_type="$withval"
508  fi; fi
509 ],
510 [nan_type="none"])
511 if test "x$nan_type" = "xnone"; then
512   AC_CACHE_CHECK([whether NAN is defined by default],
513     [c_cv_have_nan_default],
514     AC_COMPILE_IFELSE(
515       AC_LANG_PROGRAM(
516       [[
517 #include <stdlib.h>
518 #include <math.h>
519 static float foo = NAN;
520       ]],
521       [[
522        if (isnan (foo))
523         return 0;
524        else
525         return 1;
526       ]]),
527       [c_cv_have_nan_default="yes"],
528       [c_cv_have_nan_default="no"]
529     )
530   )
531   if test "x$c_cv_have_nan_default" = "xyes"
532   then
533     nan_type="default"
534   fi
535 fi
536 if test "x$nan_type" = "xnone"; then
537   AC_CACHE_CHECK([whether NAN is defined by __USE_ISOC99],
538     [c_cv_have_nan_isoc],
539     AC_COMPILE_IFELSE(
540       AC_LANG_PROGRAM(
541       [[
542 #include <stdlib.h>
543 #define __USE_ISOC99 1
544 #include <math.h>
545 static float foo = NAN;
546       ]],
547       [[
548        if (isnan (foo))
549         return 0;
550        else
551         return 1;
552       ]]),
553       [c_cv_have_nan_isoc="yes"],
554       [c_cv_have_nan_isoc="no"]
555     )
556   )
557   if test "x$c_cv_have_nan_isoc" = "xyes"
558   then
559     nan_type="isoc99"
560   fi
561 fi
562 if test "x$nan_type" = "xnone"; then
563   AC_CACHE_CHECK([whether NAN can be defined by 0/0],
564     [c_cv_have_nan_zero],
565     AC_RUN_IFELSE(
566       AC_LANG_PROGRAM(
567       [[
568 #include <stdlib.h>
569 #include <math.h>
570 #ifdef NAN
571 # undef NAN
572 #endif
573 #define NAN (0.0 / 0.0)
574 #ifndef isnan
575 # define isnan(f) ((f) != (f))
576 #endif
577 static float foo = NAN;
578       ]],
579       [[
580        if (isnan (foo))
581         return 0;
582        else
583         return 1;
584       ]]),
585       [c_cv_have_nan_zero="yes"],
586       [c_cv_have_nan_zero="no"]
587     )
588   )
589   if test "x$c_cv_have_nan_zero" = "xyes"
590   then
591     nan_type="zero"
592   fi
593 fi
594
595 if test "x$nan_type" = "xdefault"; then
596   AC_DEFINE(NAN_STATIC_DEFAULT, 1,
597     [Define if NAN is defined by default and can initialize static variables.])
598 else if test "x$nan_type" = "xisoc99"; then
599   AC_DEFINE(NAN_STATIC_ISOC, 1,
600     [Define if NAN is defined by __USE_ISOC99 and can initialize static variables.])
601 else if test "x$nan_type" = "xzero"; then
602   AC_DEFINE(NAN_ZERO_ZERO, 1,
603     [Define if NAN can be defined as (0.0 / 0.0)])
604 else
605   AC_MSG_ERROR([Didn't find out how to statically initialize variables to NAN. Sorry.])
606 fi; fi; fi
607
608 AC_ARG_WITH(fp-layout, [AS_HELP_STRING([--with-fp-layout], [set the memory layout of doubles. For crosscompiling only.])],
609 [
610  if test "x$withval" = "xnothing"; then
611         fp_layout_type="nothing"
612  else if test "x$withval" = "xendianflip"; then
613         fp_layout_type="endianflip"
614  else if test "x$withval" = "xintswap"; then
615         fp_layout_type="intswap"
616  else
617         AC_MSG_ERROR([Invalid argument for --with-fp-layout. Valid arguments are: nothing, endianflip, intswap]);
618 fi; fi; fi
619 ],
620 [fp_layout_type="unknown"])
621
622 if test "x$fp_layout_type" = "xunknown"; then
623   AC_CACHE_CHECK([if doubles are stored in x86 representation],
624     [c_cv_fp_layout_need_nothing],
625     AC_RUN_IFELSE(
626       AC_LANG_PROGRAM(
627       [[[[
628 #include <stdlib.h>
629 #include <stdio.h>
630 #include <string.h>
631 #if HAVE_STDINT_H
632 # include <stdint.h>
633 #endif
634 #if HAVE_STDBOOL_H
635 # include <stdbool.h>
636 #endif
637       ]]]],
638       [[[[
639         uint64_t i0;
640         uint64_t i1;
641         uint8_t c[8];
642         double d;
643
644         d = 8.642135e130; 
645         memcpy ((void *) &i0, (void *) &d, 8);
646
647         i1 = i0;
648         memcpy ((void *) c, (void *) &i1, 8);
649
650         if ((c[0] == 0x2f) && (c[1] == 0x25)
651                         && (c[2] == 0xc0) && (c[3] == 0xc7)
652                         && (c[4] == 0x43) && (c[5] == 0x2b)
653                         && (c[6] == 0x1f) && (c[7] == 0x5b))
654                 return (0);
655         else
656                 return (1);
657       ]]]]),
658       [c_cv_fp_layout_need_nothing="yes"],
659       [c_cv_fp_layout_need_nothing="no"]
660     )
661   )
662   if test "x$c_cv_fp_layout_need_nothing" = "xyes"; then
663     fp_layout_type="nothing"
664   fi
665 fi
666 if test "x$fp_layout_type" = "xunknown"; then
667   AC_CACHE_CHECK([if endianflip converts to x86 representation],
668     [c_cv_fp_layout_need_endianflip],
669     AC_RUN_IFELSE(
670       AC_LANG_PROGRAM(
671       [[[[
672 #include <stdlib.h>
673 #include <stdio.h>
674 #include <string.h>
675 #if HAVE_STDINT_H
676 # include <stdint.h>
677 #endif
678 #if HAVE_STDBOOL_H
679 # include <stdbool.h>
680 #endif
681 #define endianflip(A) ((((uint64_t)(A) & 0xff00000000000000LL) >> 56) | \
682                        (((uint64_t)(A) & 0x00ff000000000000LL) >> 40) | \
683                        (((uint64_t)(A) & 0x0000ff0000000000LL) >> 24) | \
684                        (((uint64_t)(A) & 0x000000ff00000000LL) >> 8)  | \
685                        (((uint64_t)(A) & 0x00000000ff000000LL) << 8)  | \
686                        (((uint64_t)(A) & 0x0000000000ff0000LL) << 24) | \
687                        (((uint64_t)(A) & 0x000000000000ff00LL) << 40) | \
688                        (((uint64_t)(A) & 0x00000000000000ffLL) << 56))
689       ]]]],
690       [[[[
691         uint64_t i0;
692         uint64_t i1;
693         uint8_t c[8];
694         double d;
695
696         d = 8.642135e130; 
697         memcpy ((void *) &i0, (void *) &d, 8);
698
699         i1 = endianflip (i0);
700         memcpy ((void *) c, (void *) &i1, 8);
701
702         if ((c[0] == 0x2f) && (c[1] == 0x25)
703                         && (c[2] == 0xc0) && (c[3] == 0xc7)
704                         && (c[4] == 0x43) && (c[5] == 0x2b)
705                         && (c[6] == 0x1f) && (c[7] == 0x5b))
706                 return (0);
707         else
708                 return (1);
709       ]]]]),
710       [c_cv_fp_layout_need_endianflip="yes"],
711       [c_cv_fp_layout_need_endianflip="no"]
712     )
713   )
714   if test "x$c_cv_fp_layout_need_endianflip" = "xyes"; then
715     fp_layout_type="endianflip"
716   fi
717 fi
718 if test "x$fp_layout_type" = "xunknown"; then
719   AC_CACHE_CHECK([if intswap converts to x86 representation],
720     [c_cv_fp_layout_need_intswap],
721     AC_RUN_IFELSE(
722       AC_LANG_PROGRAM(
723       [[[[
724 #include <stdlib.h>
725 #include <stdio.h>
726 #include <string.h>
727 #if HAVE_STDINT_H
728 # include <stdint.h>
729 #endif
730 #if HAVE_STDBOOL_H
731 # include <stdbool.h>
732 #endif
733 #define intswap(A)    ((((uint64_t)(A) & 0xffffffff00000000LL) >> 32) | \
734                        (((uint64_t)(A) & 0x00000000ffffffffLL) << 32))
735       ]]]],
736       [[[[
737         uint64_t i0;
738         uint64_t i1;
739         uint8_t c[8];
740         double d;
741
742         d = 8.642135e130; 
743         memcpy ((void *) &i0, (void *) &d, 8);
744
745         i1 = intswap (i0);
746         memcpy ((void *) c, (void *) &i1, 8);
747
748         if ((c[0] == 0x2f) && (c[1] == 0x25)
749                         && (c[2] == 0xc0) && (c[3] == 0xc7)
750                         && (c[4] == 0x43) && (c[5] == 0x2b)
751                         && (c[6] == 0x1f) && (c[7] == 0x5b))
752                 return (0);
753         else
754                 return (1);
755       ]]]]),
756       [c_cv_fp_layout_need_intswap="yes"],
757       [c_cv_fp_layout_need_intswap="no"]
758     )
759   )
760   if test "x$c_cv_fp_layout_need_intswap" = "xyes"; then
761     fp_layout_type="intswap"
762   fi
763 fi
764
765 if test "x$fp_layout_type" = "xnothing"; then
766   AC_DEFINE(FP_LAYOUT_NEED_NOTHING, 1,
767   [Define if doubles are stored in x86 representation.])
768 else if test "x$fp_layout_type" = "xendianflip"; then
769   AC_DEFINE(FP_LAYOUT_NEED_ENDIANFLIP, 1,
770   [Define if endianflip is needed to convert to x86 representation.])
771 else if test "x$fp_layout_type" = "xintswap"; then
772   AC_DEFINE(FP_LAYOUT_NEED_INTSWAP, 1,
773   [Define if intswap is needed to convert to x86 representation.])
774 else
775   AC_MSG_ERROR([Didn't find out how doubles are stored in memory. Sorry.])
776 fi; fi; fi
777
778 have_getfsstat="no"
779 AC_CHECK_FUNCS(getfsstat, [have_getfsstat="yes"])
780 have_getvfsstat="no"
781 AC_CHECK_FUNCS(getvfsstat, [have_getvfsstat="yes"])
782 have_listmntent="no"
783 AC_CHECK_FUNCS(listmntent, [have_listmntent="yes"])
784
785 have_getmntent="no"
786 AC_CHECK_FUNCS(getmntent, [have_getmntent="c"])
787 if test "x$have_getmntent" = "xno"; then
788         AC_CHECK_LIB(sun, getmntent, [have_getmntent="sun"])
789 fi
790 if test "x$have_getmntent" = "xno"; then
791         AC_CHECK_LIB(seq, getmntent, [have_getmntent="seq"])
792 fi
793 if test "x$have_getmntent" = "xno"; then
794         AC_CHECK_LIB(gen, getmntent, [have_getmntent="gen"])
795 fi
796
797 if test "x$have_getmntent" = "xc"; then
798         AC_CACHE_CHECK([whether getmntent takes one argument],
799                 [c_cv_have_one_getmntent],
800                 AC_COMPILE_IFELSE(
801                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
802 #include "$srcdir/src/utils_mount.h"]],
803                                 [[
804                                  FILE *fh;
805                                  struct mntent *me;
806                                  fh = setmntent ("/etc/mtab", "r");
807                                  me = getmntent (fh);
808                                 ]]
809                         ),
810                         [c_cv_have_one_getmntent="yes"],
811                         [c_cv_have_one_getmntent="no"]
812                 )
813         )
814         AC_CACHE_CHECK([whether getmntent takes two arguments],
815                 [c_cv_have_two_getmntent],
816                 AC_COMPILE_IFELSE(
817                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
818 #include "$srcdir/src/utils_mount.h"]],
819                                 [[
820                                  FILE *fh;
821                                  struct mnttab mt;
822                                  int status;
823                                  fh = fopen ("/etc/mnttab", "r");
824                                  status = getmntent (fh, &mt);
825                                 ]]
826                         ),
827                         [c_cv_have_two_getmntent="yes"],
828                         [c_cv_have_two_getmntent="no"]
829                 )
830         )
831 fi
832
833 # Check for different versions of `getmntent' here..
834
835 if test "x$have_getmntent" = "xc"; then
836         if test "x$c_cv_have_one_getmntent" = "xyes"; then
837                 AC_DEFINE(HAVE_ONE_GETMNTENT, 1,
838                           [Define if the function getmntent exists and takes one argument.])
839         fi
840         if test "x$c_cv_have_two_getmntent" = "xyes"; then
841                 AC_DEFINE(HAVE_TWO_GETMNTENT, 1,
842                           [Define if the function getmntent exists and takes two arguments.])
843         fi
844 fi
845 if test "x$have_getmntent" = "xsun"; then
846         AC_DEFINE(HAVE_SUN_GETMNTENT, 1,
847                   [Define if the function getmntent exists. It's the version from libsun.])
848 fi
849 if test "x$have_getmntent" = "xseq"; then
850         AC_DEFINE(HAVE_SEQ_GETMNTENT, 1,
851                   [Define if the function getmntent exists. It's the version from libseq.])
852 fi
853 if test "x$have_getmntent" = "xgen"; then
854         AC_DEFINE(HAVE_GEN_GETMNTENT, 1,
855                   [Define if the function getmntent exists. It's the version from libgen.])
856 fi
857
858 # Check for structures
859 AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
860         [AC_DEFINE(HAVE_STRUCT_IF_DATA, 1, [Define if struct if_data exists and is usable.])],
861         [],
862         [
863         #include <sys/types.h>
864         #include <sys/socket.h>
865         #include <net/if.h>
866         ])
867 AC_CHECK_MEMBERS([struct net_device_stats.rx_bytes, struct net_device_stats.tx_packets, struct net_device_stats.rx_errors],
868         [AC_DEFINE(HAVE_STRUCT_NET_DEVICE_STATS, 1, [Define if struct net_device_stats exists and is usable.])],
869         [],
870         [
871         #include <sys/types.h>
872         #include <sys/socket.h>
873         #include <linux/if.h>
874         #include <linux/netdevice.h>
875         ])
876
877 AC_CHECK_MEMBERS([struct kinfo_proc.ki_pid, struct kinfo_proc.ki_rssize, struct kinfo_proc.ki_rusage],
878         [
879                 AC_DEFINE(HAVE_STRUCT_KINFO_PROC_FREEBSD, 1,
880                         [Define if struct kinfo_proc exists in the FreeBSD variant.])
881                 have_struct_kinfo_proc_freebsd="yes"
882         ],
883         [
884                 have_struct_kinfo_proc_freebsd="no"
885         ],
886         [
887 #include <kvm.h>
888 #include <sys/param.h>
889 #include <sys/sysctl.h>
890 #include <sys/user.h>
891         ])
892
893 AC_CHECK_MEMBERS([struct kinfo_proc.kp_proc, struct kinfo_proc.kp_eproc],
894         [
895                 AC_DEFINE(HAVE_STRUCT_KINFO_PROC_OPENBSD, 1,
896                         [Define if struct kinfo_proc exists in the OpenBSD variant.])
897                 have_struct_kinfo_proc_openbsd="yes"
898         ],
899         [
900                 have_struct_kinfo_proc_openbsd="no"
901         ],
902         [
903 #include <sys/param.h>
904 #include <sys/sysctl.h>
905 #include <kvm.h>
906         ])
907
908 AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
909 [#if HAVE_STDINT_H
910 # include <stdint.h>
911 #endif
912 #if HAVE_SYS_TYPES_H
913 # include <sys/types.h>
914 #endif
915 #if HAVE_NETINET_IN_SYSTM_H
916 # include <netinet/in_systm.h>
917 #endif
918 #if HAVE_NETINET_IN_H
919 # include <netinet/in.h>
920 #endif
921 #if HAVE_NETINET_IP_H
922 # include <netinet/ip.h>
923 #endif
924 #if HAVE_NETINET_UDP_H
925 # include <netinet/udp.h>
926 #endif
927 ])
928 AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source], [], [],
929 [#if HAVE_STDINT_H
930 # include <stdint.h>
931 #endif
932 #if HAVE_SYS_TYPES_H
933 # include <sys/types.h>
934 #endif
935 #if HAVE_NETINET_IN_SYSTM_H
936 # include <netinet/in_systm.h>
937 #endif
938 #if HAVE_NETINET_IN_H
939 # include <netinet/in.h>
940 #endif
941 #if HAVE_NETINET_IP_H
942 # include <netinet/ip.h>
943 #endif
944 #if HAVE_NETINET_UDP_H
945 # include <netinet/udp.h>
946 #endif
947 ])
948
949 AC_CHECK_MEMBERS([kstat_io_t.nwritten, kstat_io_t.writes, kstat_io_t.nwrites, kstat_io_t.wtime],
950         [],
951         [],
952         [
953 #if HAVE_KSTAT_H
954 # include <kstat.h>
955 #endif
956         ])
957
958 #
959 # Checks for libraries begin here
960 #
961 with_libresolv="yes"
962 AC_CHECK_LIB(resolv, res_search,
963 [
964         AC_DEFINE(HAVE_LIBRESOLV, 1, [Define to 1 if you have the 'resolv' library (-lresolv).])
965 ],
966 [with_libresolv="no"])
967 AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")
968
969 dnl Check for HAL (hardware abstraction library)
970 with_libhal="yes"
971 AC_CHECK_LIB(hal,libhal_device_property_exists,
972              [AC_DEFINE(HAVE_LIBHAL, 1, [Define to 1 if you have 'hal' library])],
973              [with_libhal="no"])
974 if test "x$with_libhal" = "xyes"; then
975         if test "x$PKG_CONFIG" != "x"; then
976                 BUILD_WITH_LIBHAL_CFLAGS="`pkg-config --cflags hal`"
977                 BUILD_WITH_LIBHAL_LIBS="`pkg-config --libs hal`"
978                 AC_SUBST(BUILD_WITH_LIBHAL_CFLAGS)
979                 AC_SUBST(BUILD_WITH_LIBHAL_LIBS)
980         fi
981 fi
982
983 m4_divert_once([HELP_WITH], [
984 collectd additional packages:])
985
986 if test "x$ac_system" = "xSolaris"
987 then
988         with_kstat="yes"
989         with_devinfo="yes"
990 else
991         with_kstat="no (Solaris only)"
992         with_devinfo="no (Solaris only)"
993 fi
994
995 if test "x$with_kstat" = "xyes"
996 then
997         AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
998 fi
999 if test "x$with_kstat" = "xyes"
1000 then
1001         AC_CHECK_LIB(devinfo, di_init, [with_devinfo="yes"], [with_devinfo="no (not found)"], [])
1002         AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
1003 fi
1004 if test "x$with_kstat" = "xyes"
1005 then
1006         AC_DEFINE(HAVE_LIBKSTAT, 1,
1007                   [Define to 1 if you have the 'kstat' library (-lkstat)])
1008 fi
1009 AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
1010 AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
1011
1012 with_libiokit="no"
1013 AC_CHECK_LIB(IOKit, IOServiceGetMatchingServices,
1014 [
1015         with_libiokit="yes"
1016 ], 
1017 [
1018         with_libiokit="no"
1019 ])
1020 AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
1021
1022 with_libkvm="no"
1023 AC_CHECK_LIB(kvm, kvm_getprocs, [with_kvm_getprocs="yes"], [with_kvm_getprocs="no"])
1024 if test "x$with_kvm_getprocs" = "xyes"
1025 then
1026         AC_DEFINE(HAVE_LIBKVM_GETPROCS, 1,
1027                   [Define to 1 if you have the 'kvm' library with the 'kvm_getprocs' symbol (-lkvm)])
1028         with_libkvm="yes"
1029 fi
1030 AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETPROCS, test "x$with_kvm_getprocs" = "xyes")
1031
1032 AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_kvm_getswapinfo="yes"], [with_kvm_getswapinfo="no"])
1033 if test "x$with_kvm_getswapinfo" = "xyes"
1034 then
1035         AC_DEFINE(HAVE_LIBKVM_GETSWAPINFO, 1,
1036                   [Define to 1 if you have the 'kvm' library with the 'kvm_getswapinfo' symbol (-lkvm)])
1037         with_libkvm="yes"
1038 fi
1039 AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETSWAPINFO, test "x$with_kvm_getswapinfo" = "xyes")
1040
1041 AC_CHECK_LIB(kvm, kvm_nlist, [with_kvm_nlist="yes"], [with_kvm_nlist="no"])
1042 if test "x$with_kvm_nlist" = "xyes"
1043 then
1044         AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
1045                   [Define to 1 if you have the 'kvm' library with the 'kvm_nlist' symbol (-lkvm)])
1046         with_libkvm="yes"
1047 fi
1048 AM_CONDITIONAL(BUILD_WITH_LIBKVM_NLIST, test "x$with_kvm_nlist" = "xyes")
1049
1050 AC_CHECK_LIB(kvm, kvm_openfiles, [with_kvm_openfiles="yes"], [with_kvm_openfiles="no"])
1051 if test "x$with_kvm_openfiles" = "xyes"
1052 then
1053         AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
1054                   [Define to 1 if you have the 'kvm' library with the 'kvm_openfiles' symbol (-lkvm)])
1055         with_libkvm="yes"
1056 fi
1057 AM_CONDITIONAL(BUILD_WITH_LIBKVM_OPENFILES, test "x$with_kvm_openfiles" = "xyes")
1058
1059 # --with-libcurl {{{
1060 with_curl_config="curl-config"
1061 with_curl_cflags=""
1062 with_curl_libs=""
1063 AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
1064 [
1065         if test "x$withval" = "xno"
1066         then
1067                 with_libcurl="no"
1068         else if test "x$withval" = "xyes"
1069         then
1070                 with_libcurl="yes"
1071         else
1072                 if test -f "$withval" && test -x "$withval"
1073                 then
1074                         with_curl_config="$withval"
1075                         with_libcurl="yes"
1076                 else if test -x "$withval/bin/curl-config"
1077                 then
1078                         with_curl_config="$withval/bin/curl-config"
1079                         with_libcurl="yes"
1080                 fi; fi
1081                 with_libcurl="yes"
1082         fi; fi
1083 ],
1084 [
1085         with_libcurl="yes"
1086 ])
1087 if test "x$with_libcurl" = "xyes"
1088 then
1089         with_curl_cflags=`$with_curl_config --cflags 2>/dev/null`
1090         curl_config_status=$?
1091
1092         if test $curl_config_status -ne 0
1093         then
1094                 with_libcurl="no ($with_curl_config failed)"
1095         else
1096                 SAVE_CPPFLAGS="$CPPFLAGS"
1097                 CPPFLAGS="$CPPFLAGS $with_curl_cflags"
1098
1099                 AC_CHECK_HEADERS(curl/curl.h, [], [with_libcurl="no (curl/curl.h not found)"], [])
1100
1101                 CPPFLAGS="$SAVE_CPPFLAGS"
1102         fi
1103 fi
1104 if test "x$with_libcurl" = "xyes"
1105 then
1106         with_curl_libs=`$with_curl_config --libs 2>/dev/null`
1107         curl_config_status=$?
1108
1109         if test $curl_config_status -ne 0
1110         then
1111                 with_libcurl="no ($with_curl_config failed)"
1112         else
1113                 AC_CHECK_LIB(curl, curl_easy_init,
1114                  [with_libcurl="yes"],
1115                  [with_libcurl="no (symbol 'curl_easy_init' not found)"],
1116                  [$with_curl_libs])
1117         fi
1118 fi
1119 if test "x$with_libcurl" = "xyes"
1120 then
1121         BUILD_WITH_LIBCURL_CFLAGS="$with_curl_cflags"
1122         BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
1123         AC_SUBST(BUILD_WITH_LIBCURL_CFLAGS)
1124         AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
1125 fi
1126 AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
1127 # }}}
1128
1129 # --with-libdbi {{{
1130 with_libdbi_cppflags=""
1131 with_libdbi_ldflags=""
1132 AC_ARG_WITH(libdbi, [AS_HELP_STRING([--with-libdbi@<:@=PREFIX@:>@], [Path to libdbi.])],
1133 [
1134         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1135         then
1136                 with_libdbi_cppflags="-I$withval/include"
1137                 with_libdbi_ldflags="-L$withval/lib"
1138                 with_libdbi="yes"
1139         else
1140                 with_libdbi="$withval"
1141         fi
1142 ],
1143 [
1144         with_libdbi="yes"
1145 ])
1146 if test "x$with_libdbi" = "xyes"
1147 then
1148         SAVE_CPPFLAGS="$CPPFLAGS"
1149         CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
1150
1151         AC_CHECK_HEADERS(dbi/dbi.h, [with_libdbi="yes"], [with_libdbi="no (dbi/dbi.h not found)"])
1152
1153         CPPFLAGS="$SAVE_CPPFLAGS"
1154 fi
1155 if test "x$with_libdbi" = "xyes"
1156 then
1157         SAVE_CPPFLAGS="$CPPFLAGS"
1158         SAVE_LDFLAGS="$LDFLAGS"
1159         CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
1160         LDFLAGS="$LDFLAGS $with_libdbi_ldflags"
1161
1162         AC_CHECK_LIB(dbi, dbi_initialize, [with_libdbi="yes"], [with_libdbi="no (Symbol 'dbi_initialize' not found)"])
1163
1164         CPPFLAGS="$SAVE_CPPFLAGS"
1165         LDFLAGS="$SAVE_LDFLAGS"
1166 fi
1167 if test "x$with_libdbi" = "xyes"
1168 then
1169         BUILD_WITH_LIBDBI_CPPFLAGS="$with_libdbi_cppflags"
1170         BUILD_WITH_LIBDBI_LDFLAGS="$with_libdbi_ldflags"
1171         BUILD_WITH_LIBDBI_LIBS="-ldbi"
1172         AC_SUBST(BUILD_WITH_LIBDBI_CPPFLAGS)
1173         AC_SUBST(BUILD_WITH_LIBDBI_LDFLAGS)
1174         AC_SUBST(BUILD_WITH_LIBDBI_LIBS)
1175 fi
1176 AM_CONDITIONAL(BUILD_WITH_LIBDBI, test "x$with_libdbi" = "xyes")
1177 # }}}
1178
1179 # --with-libesmtp {{{
1180 AC_ARG_WITH(libesmtp, [AS_HELP_STRING([--with-libesmtp@<:@=PREFIX@:>@], [Path to libesmtp.])],
1181 [
1182         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1183         then
1184                 LDFLAGS="$LDFLAGS -L$withval/lib"
1185                 CPPFLAGS="$CPPFLAGS -I$withval/include -D_THREAD_SAFE"
1186                 with_libesmtp="yes"
1187         else
1188                 with_libesmtp="$withval"
1189         fi
1190 ],
1191 [
1192         with_libesmtp="yes"
1193 ])
1194 if test "x$with_libesmtp" = "xyes"
1195 then
1196         AC_CHECK_LIB(esmtp, smtp_create_session,
1197         [
1198                 AC_DEFINE(HAVE_LIBESMTP, 1, [Define to 1 if you have the esmtp library (-lesmtp).])
1199         ], [with_libesmtp="no (libesmtp not found)"])
1200 fi
1201 if test "x$with_libesmtp" = "xyes"
1202 then
1203         AC_CHECK_HEADERS(libesmtp.h,
1204         [
1205                 AC_DEFINE(HAVE_LIBESMTP_H, 1, [Define to 1 if you have the <libesmtp.h> header file.])
1206         ], [with_libesmtp="no (libesmtp.h not found)"])
1207 fi
1208 if test "x$with_libesmtp" = "xyes"
1209 then
1210         collect_libesmtp=1
1211 else
1212         collect_libesmtp=0
1213 fi
1214 AC_DEFINE_UNQUOTED(COLLECT_LIBESMTP, [$collect_libesmtp],
1215         [Wether or not to use the esmtp library])
1216 AM_CONDITIONAL(BUILD_WITH_LIBESMTP, test "x$with_libesmtp" = "xyes")
1217 # }}}
1218
1219 # --with-libiptc {{{
1220 with_own_libiptc="no"
1221 AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
1222 [
1223         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1224         then
1225                 LDFLAGS="$LDFLAGS -L$withval/lib"
1226                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1227                 with_libiptc="yes"
1228         else
1229                 with_libiptc="$withval"
1230         fi
1231 ],
1232 [
1233         if test "x$ac_system" = "xLinux"
1234         then
1235                 with_libiptc="yes"
1236         else
1237                 with_libiptc="no (Linux only)"
1238         fi
1239 ])
1240 if test "x$with_libiptc" = "xyes"
1241 then
1242         AC_CHECK_LIB(iptc, iptc_init,
1243         [
1244                 AC_DEFINE(HAVE_LIBIPTC, 1, [Define to 1 if you have the iptc library (-liptc).])
1245         ],
1246         [
1247                 with_libiptc="yes"
1248                 with_own_libiptc="yes"
1249         ])
1250 fi
1251 if test "x$with_libiptc" = "xyes" -a "x$with_own_libiptc" != "xyes"
1252 then
1253         AC_CHECK_HEADERS(libiptc/libiptc.h,
1254         [
1255                 AC_DEFINE(HAVE_LIBIPTC_LIBIPTC_H, 1, [Define to 1 if you have the <libiptc/libiptc.h> header file.])
1256         ],
1257         [
1258                 with_libiptc="yes"
1259                 with_own_libiptc="yes"
1260         ])
1261 fi
1262 if test "x$with_libiptc" = "xyes"
1263 then
1264         SAVE_CFLAGS=$CFLAGS
1265         CFLAGS="$CFLAGS $KERNEL_CFLAGS"
1266
1267         AC_CHECK_HEADERS(linux/netfilter_ipv4/ip_tables.h linux/netfilter_ipv6/ip6_tables.h, [],
1268         [
1269                 with_libiptc="no (Linux iptables headers not found - check KERNEL_DIR)"
1270                 with_own_libiptc="no"
1271         ],
1272         [
1273 #include "$srcdir/src/libiptc/ipt_kernel_headers.h"
1274         ])
1275
1276         CFLAGS=$SAVE_CFLAGS
1277 fi
1278 AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
1279 AM_CONDITIONAL(BUILD_WITH_OWN_LIBIPTC, test "x$with_own_libiptc" = "xyes")
1280 if test "x$with_own_libiptc" = "xyes"
1281 then
1282         AC_DEFINE(OWN_LIBIPTC, 1, [Define to 1 if we use the shipped iptc library.])
1283 fi
1284 # }}}
1285
1286 # --with-libmysql {{{
1287 with_mysql_config="mysql_config"
1288 with_mysql_cflags=""
1289 with_mysql_libs=""
1290 AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
1291 [
1292         if test "x$withval" = "xno"
1293         then
1294                 with_libmysql="no"
1295         else if test "x$withval" = "xyes"
1296         then
1297                 with_libmysql="yes"
1298         else
1299                 if test -f "$withval" && test -x "$withval";
1300                 then
1301                         with_mysql_config="$withval"
1302                 else if test -x "$withval/bin/mysql_config"
1303                 then
1304                         with_mysql_config="$withval/bin/mysql_config"
1305                 fi; fi
1306                 with_libmysql="yes"
1307         fi; fi
1308 ],
1309 [
1310         with_libmysql="yes"
1311 ])
1312 if test "x$with_libmysql" = "xyes"
1313 then
1314         with_mysql_cflags=`$with_mysql_config --cflags 2>/dev/null`
1315         mysql_config_status=$?
1316
1317         if test $mysql_config_status -ne 0
1318         then
1319                 with_libmysql="no ($with_mysql_config failed)"
1320         else
1321                 SAVE_CPPFLAGS="$CPPFLAGS"
1322                 CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
1323
1324                 have_mysql_h="no"
1325                 have_mysql_mysql_h="no"
1326                 AC_CHECK_HEADERS(mysql.h, [have_mysql_h="yes"])
1327
1328                 if test "x$have_mysql_h" = "xno"
1329                 then
1330                         AC_CHECK_HEADERS(mysql/mysql.h, [have_mysql_mysql_h="yes"])
1331                 fi
1332
1333                 if test "x$have_mysql_h$have_mysql_mysql_h" = "xnono"
1334                 then
1335                         with_libmysql="no (mysql.h not found)"
1336                 fi
1337
1338                 CPPFLAGS="$SAVE_CPPFLAGS"
1339         fi
1340 fi
1341 if test "x$with_libmysql" = "xyes"
1342 then
1343         with_mysql_libs=`$with_mysql_config --libs 2>/dev/null`
1344         mysql_config_status=$?
1345
1346         if test $mysql_config_status -ne 0
1347         then
1348                 with_libmysql="no ($with_mysql_config failed)"
1349         else
1350                 AC_CHECK_LIB(mysqlclient, mysql_init,
1351                  [with_libmysql="yes"],
1352                  [with_libmysql="no (symbol 'mysql_init' not found)"],
1353                  [$with_mysql_libs])
1354         fi
1355 fi
1356 if test "x$with_libmysql" = "xyes"
1357 then
1358         BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
1359         BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
1360         AC_SUBST(BUILD_WITH_LIBMYSQL_CFLAGS)
1361         AC_SUBST(BUILD_WITH_LIBMYSQL_LIBS)
1362 fi
1363 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
1364 # }}}
1365
1366 # --with-libnetlink {{{
1367 with_libnetlink_cflags=""
1368 with_libnetlink_libs="-lnetlink"
1369 AC_ARG_WITH(libnetlink, [AS_HELP_STRING([--with-libnetlink@<:@=PREFIX@:>@], [Path to libnetlink.])],
1370 [
1371  echo "libnetlink: withval = $withval"
1372  if test "x$withval" = "xyes"
1373  then
1374          with_libnetlink="yes"
1375  else if test "x$withval" = "xno"
1376  then
1377          with_libnetlink="no"
1378  else
1379          if test -d "$withval/include"
1380          then
1381                  with_libnetlink_cflags="-I$withval/include"
1382                  with_libnetlink_libs="-L$withval/lib -lnetlink"
1383                  with_libnetlink="yes"
1384          else
1385                  AC_MSG_ERROR("no such directory: $withval/include")
1386          fi
1387  fi; fi
1388 ],
1389 [
1390  if test "x$ac_system" = "xLinux"
1391  then
1392          with_libnetlink="yes"
1393  else
1394          with_libnetlink="no (Linux only library)"
1395  fi
1396 ])
1397 if test "x$with_libnetlink" = "xyes"
1398 then
1399         SAVE_CFLAGS=$CFLAGS
1400         CFLAGS="$CFLAGS $with_libnetlink_cflags"
1401
1402         with_libnetlink="no (libnetlink.h not found)"
1403
1404         AC_CHECK_HEADERS(libnetlink.h iproute/libnetlink.h linux/libnetlink.h,
1405         [
1406          with_libnetlink="yes"
1407          break
1408         ], [],
1409 [#include <stdio.h>
1410 #include <sys/types.h>
1411 #include <asm/types.h>
1412 #include <sys/socket.h>
1413 #include <linux/netlink.h>
1414 #include <linux/rtnetlink.h>])
1415         AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
1416 [#include <stdio.h>
1417 #include <sys/types.h>
1418 #include <asm/types.h>
1419 #include <sys/socket.h>])
1420
1421         AC_COMPILE_IFELSE(
1422 [#include <stdio.h>
1423 #include <sys/types.h>
1424 #include <asm/types.h>
1425 #include <sys/socket.h>
1426 #include <linux/netlink.h>
1427 #include <linux/rtnetlink.h>
1428
1429 int main (void)
1430 {
1431         int retval = TCA_STATS2;
1432         return (retval);
1433 }],
1434         [AC_DEFINE([HAVE_TCA_STATS2], 1, [True if the enum-member TCA_STATS2 exists])]
1435         []);
1436
1437         AC_COMPILE_IFELSE(
1438 [#include <stdio.h>
1439 #include <sys/types.h>
1440 #include <asm/types.h>
1441 #include <sys/socket.h>
1442 #include <linux/netlink.h>
1443 #include <linux/rtnetlink.h>
1444
1445 int main (void)
1446 {
1447         int retval = TCA_STATS;
1448         return (retval);
1449 }],
1450         [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
1451         []);
1452
1453         CFLAGS="$SAVE_CFLAGS"
1454 fi
1455 if test "x$with_libnetlink" = "xyes"
1456 then
1457         AC_CHECK_LIB(netlink, rtnl_open,
1458                      [with_libnetlink="yes"],
1459                      [with_libnetlink="no (symbol 'rtnl_open' not found)"],
1460                      [$with_libnetlink_libs])
1461 fi
1462 if test "x$with_libnetlink" = "xyes"
1463 then
1464         BUILD_WITH_LIBNETLINK_CFLAGS="$with_libnetlink_cflags"
1465         BUILD_WITH_LIBNETLINK_LIBS="$with_libnetlink_libs"
1466         AC_SUBST(BUILD_WITH_LIBNETLINK_CFLAGS)
1467         AC_SUBST(BUILD_WITH_LIBNETLINK_LIBS)
1468 fi
1469 AM_CONDITIONAL(BUILD_WITH_LIBNETLINK, test "x$with_libnetlink" = "xyes")
1470 # }}}
1471
1472 # --with-libnetsnmp {{{
1473 with_snmp_config="net-snmp-config"
1474 with_snmp_cflags=""
1475 with_snmp_libs=""
1476 AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
1477 [
1478         if test "x$withval" = "xno"
1479         then
1480                 with_libnetsnmp="no"
1481         else if test "x$withval" = "xyes"
1482         then
1483                 with_libnetsnmp="yes"
1484         else
1485                 if test -x "$withval"
1486                 then
1487                         with_snmp_config="$withval"
1488                         with_libnetsnmp="yes"
1489                 else
1490                         with_snmp_config="$withval/bin/net-snmp-config"
1491                         with_libnetsnmp="yes"
1492                 fi
1493         fi; fi
1494 ],
1495 [with_libnetsnmp="yes"])
1496 if test "x$with_libnetsnmp" = "xyes"
1497 then
1498         with_snmp_cflags=`$with_snmp_config --cflags 2>/dev/null`
1499         snmp_config_status=$?
1500
1501         if test $snmp_config_status -ne 0
1502         then
1503                 with_libnetsnmp="no ($with_snmp_config failed)"
1504         else
1505                 SAVE_CPPFLAGS="$CPPFLAGS"
1506                 CPPFLAGS="$CPPFLAGS $with_snmp_cflags"
1507                 
1508                 AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
1509
1510                 CPPFLAGS="$SAVE_CPPFLAGS"
1511         fi
1512 fi
1513 if test "x$with_libnetsnmp" = "xyes"
1514 then
1515         with_snmp_libs=`$with_snmp_config --libs 2>/dev/null`
1516         snmp_config_status=$?
1517
1518         if test $snmp_config_status -ne 0
1519         then
1520                 with_libnetsnmp="no ($with_snmp_config failed)"
1521         else
1522                 AC_CHECK_LIB(netsnmp, init_snmp,
1523                 [with_libnetsnmp="yes"],
1524                 [with_libnetsnmp="no (libnetsnmp not found)"],
1525                 [$with_snmp_libs])
1526         fi
1527 fi
1528 if test "x$with_libnetsnmp" = "xyes"
1529 then
1530         BUILD_WITH_LIBSNMP_CFLAGS="$with_snmp_cflags"
1531         BUILD_WITH_LIBSNMP_LIBS="$with_snmp_libs"
1532         AC_SUBST(BUILD_WITH_LIBSNMP_CFLAGS)
1533         AC_SUBST(BUILD_WITH_LIBSNMP_LIBS)
1534 fi
1535 AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")
1536 # }}}
1537
1538 # --with-liboconfig {{{
1539 with_own_liboconfig="no"
1540 liboconfig_LDFLAGS="$LDFLAGS"
1541 liboconfig_CPPFLAGS="$CPPFLAGS"
1542 AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
1543 [
1544         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1545         then
1546                 if test -d "$withval/lib"
1547                 then
1548                         liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
1549                 fi
1550                 if test -d "$withval/include"
1551                 then
1552                         liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
1553                 fi
1554         fi
1555         if test "x$withval" = "xno"
1556         then
1557                 AC_MSG_ERROR("liboconfig is required")
1558         fi
1559 ],
1560 [
1561         with_liboconfig="yes"
1562 ])
1563
1564 save_LDFLAGS="$LDFLAGS"
1565 save_CPPFLAGS="$CPPFLAGS"
1566 LDFLAGS="$liboconfig_LDFLAGS"
1567 CPPFLAGS="$liboconfig_CPPFLAGS"
1568 AC_CHECK_LIB(oconfig, oconfig_parse_fh,
1569 [
1570         with_liboconfig="yes"
1571         with_own_liboconfig="no"
1572 ],
1573 [
1574         with_liboconfig="yes"
1575         with_own_liboconfig="yes"
1576         LDFLAGS="$save_LDFLAGS"
1577         CPPFLAGS="$save_CPPFLAGS"
1578 ])
1579
1580 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
1581 if test "x$with_own_liboconfig" = "xyes"
1582 then
1583         with_liboconfig="yes (shipped version)"
1584 fi
1585 # }}}
1586
1587 # --with-liboping {{{
1588 with_own_liboping="no"
1589 liboping_LDFLAGS="$LDFLAGS"
1590 liboping_CPPFLAGS="$CPPFLAGS"
1591 AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
1592 [
1593         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1594         then
1595                 if test -d "$withval/lib"
1596                 then
1597                         liboping_LDFLAGS="$LDFLAGS -L$withval/lib"
1598                 fi
1599                 if test -d "$withval/include"
1600                 then
1601                         liboping_CPPFLAGS="$CPPFLAGS -I$withval/include"
1602                 fi
1603         fi
1604         if test "x$withval" = "xno"
1605         then
1606                 with_liboping="no"
1607                 with_own_liboping="no"
1608         else if test "x$withval" = "xyes"
1609         then
1610                 with_liboping="yes"
1611         fi; fi
1612 ],
1613 [
1614         with_liboping="yes"
1615 ])
1616
1617 if test "x$with_liboping" = "xyes"
1618 then
1619         save_LDFLAGS="$LDFLAGS"
1620         save_CPPFLAGS="$CPPFLAGS"
1621         LDFLAGS="$liboping_LDFLAGS"
1622         CPPFLAGS="$liboping_CPPFLAGS"
1623         AC_CHECK_LIB(oping, ping_construct,
1624         [
1625                 with_liboping="yes"
1626                 with_own_liboping="no"
1627         ],
1628         [
1629                 with_liboping="yes"
1630                 with_own_liboping="yes"
1631                 LDFLAGS="$save_LDFLAGS"
1632                 CPPFLAGS="$save_CPPFLAGS"
1633         ])
1634 fi
1635 AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
1636 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOPING, test "x$with_own_liboping" = "xyes")
1637 # }}}
1638
1639 # --with-oracle {{{
1640 with_oracle_cppflags=""
1641 with_oracle_libs=""
1642 AC_ARG_WITH(oracle, [AS_HELP_STRING([--with-oracle@<:@=ORACLE_HOME@:>@], [Path to Oracle.])],
1643 [
1644         if test "x$withval" = "xyes"
1645         then
1646                 if test "x$ORACLE_HOME" = "x"
1647                 then
1648                         AC_MSG_WARN([Use of the Oracle library has been forced, but the environment variable ORACLE_HOME is not set.])
1649                 fi
1650                 with_oracle="yes"
1651         else if test "x$withval" = "xno"
1652         then
1653                 with_oracle="no"
1654         else
1655                 with_oracle="yes"
1656                 ORACLE_HOME="$withval"
1657         fi; fi
1658 ],
1659 [
1660         if test "x$ORACLE_HOME" = "x"
1661         then
1662                 with_oracle="no (ORACLE_HOME is not set)"
1663         else
1664                 with_oracle="yes"
1665         fi
1666 ])
1667 if test "x$ORACLE_HOME" != "x"
1668 then
1669         with_oracle_cppflags="-I$ORACLE_HOME/rdbms/public"
1670
1671         if test -e "$ORACLE_HOME/lib/ldflags"
1672         then
1673                 with_oracle_libs=`cat "$ORACLE_HOME/lib/ldflags"`
1674         fi
1675         #with_oracle_libs="-L$ORACLE_HOME/lib $with_oracle_libs -lclntsh"
1676         with_oracle_libs="-L$ORACLE_HOME/lib -lclntsh"
1677 fi
1678 if test "x$with_oracle" = "xyes"
1679 then
1680         SAVE_CPPFLAGS="$CPPFLAGS"
1681         CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
1682
1683         AC_CHECK_HEADERS(oci.h, [with_oracle="yes"], [with_oracle="no (oci.h not found)"])
1684
1685         CPPFLAGS="$SAVE_CPPFLAGS"
1686 fi
1687 if test "x$with_oracle" = "xyes"
1688 then
1689         SAVE_CPPFLAGS="$CPPFLAGS"
1690         SAVE_LDFLAGS="$LDFLAGS"
1691         CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
1692         LDFLAGS="$LDFLAGS $with_oracle_libs"
1693
1694         AC_CHECK_FUNC(OCIEnvCreate, [with_oracle="yes"], [with_oracle="no (Symbol 'OCIEnvCreate' not found)"])
1695
1696         CPPFLAGS="$SAVE_CPPFLAGS"
1697         LDFLAGS="$SAVE_LDFLAGS"
1698 fi
1699 if test "x$with_oracle" = "xyes"
1700 then
1701         BUILD_WITH_ORACLE_CFLAGS="$with_oracle_cppflags"
1702         BUILD_WITH_ORACLE_LIBS="$with_oracle_libs"
1703         AC_SUBST(BUILD_WITH_ORACLE_CFLAGS)
1704         AC_SUBST(BUILD_WITH_ORACLE_LIBS)
1705 fi
1706 # }}}
1707
1708 # --with-libowcapi {{{
1709 with_libowcapi_cppflags=""
1710 with_libowcapi_libs="-lowcapi"
1711 AC_ARG_WITH(libowcapi, [AS_HELP_STRING([--with-libowcapi@<:@=PREFIX@:>@], [Path to libowcapi.])],
1712 [
1713         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1714         then
1715                 with_libowcapi_cppflags="-I$withval/include"
1716                 with_libowcapi_libs="-L$withval/lib -lowcapi"
1717                 with_libowcapi="yes"
1718         else
1719                 with_libowcapi="$withval"
1720         fi
1721 ],
1722 [
1723         with_libowcapi="yes"
1724 ])
1725 if test "x$with_libowcapi" = "xyes"
1726 then
1727         SAVE_CPPFLAGS="$CPPFLAGS"
1728         CPPFLAGS="$with_libowcapi_cppflags"
1729         
1730         AC_CHECK_HEADERS(owcapi.h, [with_libowcapi="yes"], [with_libowcapi="no (owcapi.h not found)"])
1731
1732         CPPFLAGS="$SAVE_CPPFLAGS"
1733 fi
1734 if test "x$with_libowcapi" = "xyes"
1735 then
1736         SAVE_LDFLAGS="$LDFLAGS"
1737         SAVE_CPPFLAGS="$CPPFLAGS"
1738         LDFLAGS="$with_libowcapi_libs"
1739         CPPFLAGS="$with_libowcapi_cppflags"
1740         
1741         AC_CHECK_LIB(owcapi, OW_get, [with_libowcapi="yes"], [with_libowcapi="no (libowcapi not found)"])
1742
1743         LDFLAGS="$SAVE_LDFLAGS"
1744         CPPFLAGS="$SAVE_CPPFLAGS"
1745 fi
1746 if test "x$with_libowcapi" = "xyes"
1747 then
1748         BUILD_WITH_LIBOWCAPI_CPPFLAGS="$with_libowcapi_cppflags"
1749         BUILD_WITH_LIBOWCAPI_LIBS="$with_libowcapi_libs"
1750         AC_SUBST(BUILD_WITH_LIBOWCAPI_CPPFLAGS)
1751         AC_SUBST(BUILD_WITH_LIBOWCAPI_LIBS)
1752 fi
1753 # }}}
1754
1755 # --with-libpcap {{{
1756 AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
1757 [
1758         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1759         then
1760                 LDFLAGS="$LDFLAGS -L$withval/lib"
1761                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1762                 with_libpcap="yes"
1763         else
1764                 with_libpcap="$withval"
1765         fi
1766 ],
1767 [
1768         with_libpcap="yes"
1769 ])
1770 if test "x$with_libpcap" = "xyes"
1771 then
1772         AC_CHECK_LIB(pcap, pcap_open_live,
1773         [
1774                 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
1775         ], [with_libpcap="no (libpcap not found)"])
1776 fi
1777 if test "x$with_libpcap" = "xyes"
1778 then
1779         AC_CHECK_HEADERS(pcap.h,
1780         [
1781                 AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
1782         ], [with_libpcap="no (pcap.h not found)"])
1783 fi
1784 if test "x$with_libpcap" = "xyes"
1785 then
1786         collect_libpcap=1
1787 else
1788         collect_libpcap=0
1789 fi
1790 AC_DEFINE_UNQUOTED(COLLECT_LIBPCAP, [$collect_libpcap],
1791         [Wether or not to use the pcap library])
1792 AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
1793 # }}}
1794
1795 # --with-libperl {{{
1796 perl_interpreter="perl"
1797 AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
1798 [
1799         if test -x "$withval"
1800         then
1801                 perl_interpreter="$withval"
1802                 with_libperl="yes"
1803         else if test "x$withval" != "xno" && test "x$withval" != "xyes"
1804         then
1805                 LDFLAGS="$LDFLAGS -L$withval/lib"
1806                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1807                 perl_interpreter="$withval/bin/perl"
1808                 with_libperl="yes"
1809         else
1810                 with_libperl="$withval"
1811         fi; fi
1812 ],
1813 [
1814         with_libperl="yes"
1815 ])
1816
1817 AC_MSG_CHECKING([for perl])
1818 perl_interpreter=`which "$perl_interpreter" 2> /dev/null`
1819 if test -x "$perl_interpreter"
1820 then
1821         AC_MSG_RESULT([yes ($perl_interpreter)])
1822 else
1823         perl_interpreter=""
1824         AC_MSG_RESULT([no])
1825 fi
1826
1827 AC_SUBST(PERL, "$perl_interpreter")
1828
1829 if test "x$with_libperl" = "xyes" \
1830         && test -n "$perl_interpreter"
1831 then
1832   SAVE_CFLAGS=$CFLAGS
1833   SAVE_LDFLAGS=$LDFLAGS
1834 dnl ARCHFLAGS="" -> disable multi -arch on OSX (see Config_heavy.pl:fetch_string)
1835   PERL_CFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ccopts`
1836   PERL_LDFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ldopts`
1837   CFLAGS="$CFLAGS $PERL_CFLAGS"
1838   LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
1839
1840   AC_CACHE_CHECK([for libperl],
1841     [c_cv_have_libperl],
1842     AC_LINK_IFELSE(
1843       AC_LANG_PROGRAM(
1844       [[
1845 #define PERL_NO_GET_CONTEXT
1846 #include <EXTERN.h>
1847 #include <perl.h>
1848 #include <XSUB.h>
1849       ]],
1850       [[
1851        dTHX;
1852        load_module (PERL_LOADMOD_NOIMPORT,
1853                          newSVpv ("Collectd::Plugin::FooBar", 24),
1854                          Nullsv);
1855       ]]),
1856       [c_cv_have_libperl="yes"],
1857       [c_cv_have_libperl="no"]
1858     )
1859   )
1860
1861   if test "x$c_cv_have_libperl" = "xyes"
1862   then
1863           AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
1864           AC_SUBST(PERL_CFLAGS)
1865           AC_SUBST(PERL_LDFLAGS)
1866   else
1867           with_libperl="no"
1868   fi
1869
1870   CFLAGS=$SAVE_CFLAGS
1871   LDFLAGS=$SAVE_LDFLAGS
1872 else if test -z "$perl_interpreter"; then
1873   with_libperl="no (no perl interpreter found)"
1874   c_cv_have_libperl="no"
1875 fi; fi
1876 AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")
1877
1878 if test "x$with_libperl" = "xyes"
1879 then
1880         SAVE_CFLAGS=$CFLAGS
1881         SAVE_LDFLAGS=$LDFLAGS
1882         CFLAGS="$CFLAGS $PERL_CFLAGS"
1883         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
1884
1885         AC_CACHE_CHECK([if perl supports ithreads],
1886                 [c_cv_have_perl_ithreads],
1887                 AC_LINK_IFELSE(
1888                         AC_LANG_PROGRAM(
1889                         [[
1890 #include <EXTERN.h>
1891 #include <perl.h>
1892 #include <XSUB.h>
1893
1894 #if !defined(USE_ITHREADS)
1895 # error "Perl does not support ithreads!"
1896 #endif /* !defined(USE_ITHREADS) */
1897                         ]],
1898                         [[ ]]),
1899                         [c_cv_have_perl_ithreads="yes"],
1900                         [c_cv_have_perl_ithreads="no"]
1901                 )
1902         )
1903
1904         if test "x$c_cv_have_perl_ithreads" = "xyes"
1905         then
1906                 AC_DEFINE(HAVE_PERL_ITHREADS, 1, [Define if Perl supports ithreads.])
1907         fi
1908
1909         CFLAGS=$SAVE_CFLAGS
1910         LDFLAGS=$SAVE_LDFLAGS
1911 fi
1912
1913 c_cv_have_broken_perl_load_module="no"
1914 if test "x$with_libperl" = "xyes"
1915 then
1916         SAVE_CFLAGS=$CFLAGS
1917         SAVE_LDFLAGS=$LDFLAGS
1918         # trigger an error if Perl_load_module*() uses __attribute__nonnull__(3)
1919         # (see issues #41 and #42)
1920         CFLAGS="$CFLAGS $PERL_CFLAGS -Wall -Werror"
1921         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
1922
1923         AC_CACHE_CHECK([for broken Perl_load_module()],
1924                 [c_cv_have_broken_perl_load_module],
1925                 AC_LINK_IFELSE(
1926                         AC_LANG_PROGRAM(
1927                         [[
1928 #define PERL_NO_GET_CONTEXT
1929 #include <EXTERN.h>
1930 #include <perl.h>
1931 #include <XSUB.h>
1932                         ]],
1933                         [[
1934                          dTHX;
1935                          load_module (PERL_LOADMOD_NOIMPORT,
1936                              newSVpv ("Collectd::Plugin::FooBar", 24),
1937                              Nullsv);
1938                         ]]),
1939                         [c_cv_have_broken_perl_load_module="no"],
1940                         [c_cv_have_broken_perl_load_module="yes"]
1941                 )
1942         )
1943
1944         CFLAGS=$SAVE_CFLAGS
1945         LDFLAGS=$SAVE_LDFLAGS
1946 fi
1947 AM_CONDITIONAL(HAVE_BROKEN_PERL_LOAD_MODULE,
1948                 test "x$c_cv_have_broken_perl_load_module" = "xyes")
1949
1950 if test "x$with_libperl" = "xyes"
1951 then
1952         SAVE_CFLAGS=$CFLAGS
1953         SAVE_LDFLAGS=$LDFLAGS
1954         CFLAGS="$CFLAGS $PERL_CFLAGS"
1955         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
1956
1957         AC_CHECK_MEMBER(
1958                 [struct mgvtbl.svt_local],
1959                 [have_struct_mgvtbl_svt_local="yes"],
1960                 [have_struct_mgvtbl_svt_local="no"],
1961                 [
1962 #include <EXTERN.h>
1963 #include <perl.h>
1964 #include <XSUB.h>
1965                 ])
1966
1967         if test "x$have_struct_mgvtbl_svt_local" = "xyes"
1968         then
1969                 AC_DEFINE(HAVE_PERL_STRUCT_MGVTBL_SVT_LOCAL, 1,
1970                                   [Define if Perl's struct mgvtbl has member svt_local.])
1971         fi
1972
1973         CFLAGS=$SAVE_CFLAGS
1974         LDFLAGS=$SAVE_LDFLAGS
1975 fi
1976 # }}}
1977
1978 # --with-libpq {{{
1979 with_pg_config="pg_config"
1980 with_libpq_includedir=""
1981 with_libpq_libdir=""
1982 with_libpq_cppflags=""
1983 with_libpq_ldflags=""
1984 AC_ARG_WITH(libpq, [AS_HELP_STRING([--with-libpq@<:@=PREFIX@:>@],
1985         [Path to libpq.])],
1986 [
1987         if test "x$withval" = "xno"
1988         then
1989                 with_libpq="no"
1990         else if test "x$withval" = "xyes"
1991         then
1992                 with_libpq="yes"
1993         else
1994                 if test -f "$withval" && test -x "$withval";
1995                 then
1996                         with_pg_config="$withval"
1997                 else if test -x "$withval/bin/pg_config"
1998                 then
1999                         with_pg_config="$withval/bin/pg_config"
2000                 fi; fi
2001                 with_libpq="yes"
2002         fi; fi
2003 ],
2004 [
2005         with_libpq="yes"
2006 ])
2007 if test "x$with_libpq" = "xyes"
2008 then
2009         with_libpq_includedir=`$with_pg_config --includedir 2> /dev/null`
2010         pg_config_status=$?
2011
2012         if test $pg_config_status -eq 0
2013         then
2014                 if test -n "$with_libpq_includedir"; then
2015                         for dir in $with_libpq_includedir; do
2016                                 with_libpq_cppflags="$with_libpq_cppflags -I$dir"
2017                         done
2018                 fi
2019         else
2020                 AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
2021         fi
2022
2023         SAVE_CPPFLAGS="$CPPFLAGS"
2024         CPPFLAGS="$CPPFLAGS $with_libpq_cppflags"
2025
2026         AC_CHECK_HEADERS(libpq-fe.h, [],
2027                 [with_libpq="no (libpq-fe.h not found)"], [])
2028
2029         CPPFLAGS="$SAVE_CPPFLAGS"
2030 fi
2031 if test "x$with_libpq" = "xyes"
2032 then
2033         with_libpq_libdir=`$with_pg_config --libdir 2> /dev/null`
2034         pg_config_status=$?
2035
2036         if test $pg_config_status -eq 0
2037         then
2038                 if test -n "$with_libpq_libdir"; then
2039                         for dir in $with_libpq_libdir; do
2040                                 with_libpq_ldflags="$with_libpq_ldflags -L$dir"
2041                         done
2042                 fi
2043         else
2044                 AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
2045         fi
2046
2047         SAVE_LDFLAGS="$LDFLAGS"
2048         LDFLAGS="$LDFLAGS $with_libpq_ldflags"
2049
2050         AC_CHECK_LIB(pq, PQconnectdb,
2051                 [with_libpq="yes"],
2052                 [with_libpq="no (symbol 'PQconnectdb' not found)"])
2053
2054         LDFLAGS="$SAVE_LDFLAGS"
2055 fi
2056 if test "x$with_libpq" = "xyes"
2057 then
2058         BUILD_WITH_LIBPQ_CPPFLAGS="$with_libpq_cppflags"
2059         BUILD_WITH_LIBPQ_LDFLAGS="$with_libpq_ldflags"
2060         AC_SUBST(BUILD_WITH_LIBPQ_CPPFLAGS)
2061         AC_SUBST(BUILD_WITH_LIBPQ_LDFLAGS)
2062 fi
2063 AM_CONDITIONAL(BUILD_WITH_LIBPQ, test "x$with_libpq" = "xyes")
2064 # }}}
2065
2066 # --with-libpthread {{{
2067 AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
2068 [       if test "x$withval" != "xno" \
2069                 && test "x$withval" != "xyes"
2070         then
2071                 LDFLAGS="$LDFLAGS -L$withval/lib"
2072                 CPPFLAGS="$CPPFLAGS -I$withval/include"
2073                 with_libpthread="yes"
2074         else
2075                 if test "x$withval" = "xno"
2076                 then
2077                         with_libpthread="no (disabled)"
2078                 fi
2079         fi
2080 ], [with_libpthread="yes"])
2081 if test "x$with_libpthread" = "xyes"
2082 then
2083         AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
2084 fi
2085
2086 if test "x$with_libpthread" = "xyes"
2087 then
2088         AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
2089 fi
2090 if test "x$with_libpthread" = "xyes"
2091 then
2092         collect_pthread=1
2093 else
2094         collect_pthread=0
2095 fi
2096 AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
2097         [Wether or not to use pthread (POSIX threads) library])
2098 AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
2099 # }}}
2100
2101 # --with-librrd {{{
2102 # AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
2103 librrd_cflags=""
2104 librrd_ldflags=""
2105 librrd_threadsafe="yes"
2106 librrd_rrdc_update="no"
2107 AC_ARG_WITH(librrd, [AS_HELP_STRING([--with-librrd@<:@=PREFIX@:>@], [Path to rrdtool.])],
2108 [       if test "x$withval" != "xno" && test "x$withval" != "xyes"
2109         then
2110                 librrd_cflags="-I$withval/include"
2111                 librrd_ldflags="-L$withval/lib"
2112                 with_librrd="yes"
2113         else
2114                 with_librrd="$withval"
2115         fi
2116 ], [with_librrd="yes"])
2117 if test "x$with_librrd" = "xyes"
2118 then
2119         SAVE_CPPFLAGS="$CPPFLAGS"
2120         SAVE_LDFLAGS="$LDFLAGS"
2121
2122         CPPFLAGS="$CPPFLAGS $librrd_cflags"
2123         LDFLAGS="$LDFLAGS $librrd_ldflags"
2124
2125         AC_CHECK_HEADERS(rrd.h,, [with_librrd="no (rrd.h not found)"])
2126
2127         CPPFLAGS="$SAVE_CPPFLAGS"
2128         LDFLAGS="$SAVE_LDFLAGS"
2129 fi
2130 if test "x$with_librrd" = "xyes"
2131 then
2132         SAVE_CPPFLAGS="$CPPFLAGS"
2133         SAVE_LDFLAGS="$LDFLAGS"
2134
2135         CPPFLAGS="$CPPFLAGS $librrd_cflags"
2136         LDFLAGS="$LDFLAGS $librrd_ldflags"
2137
2138         AC_CHECK_LIB(rrd_th, rrd_update_r,
2139         [with_librrd="yes"
2140          librrd_ldflags="$librrd_ldflags -lrrd_th -lm"
2141         ],
2142         [librrd_threadsafe="no"
2143          AC_CHECK_LIB(rrd, rrd_update,
2144          [with_librrd="yes"
2145           librrd_ldflags="$librrd_ldflags -lrrd -lm"
2146          ],
2147          [with_librrd="no (symbol 'rrd_update' not found)"],
2148          [-lm])
2149         ],
2150         [-lm])
2151
2152         if test "x$librrd_threadsafe" = "xyes"
2153         then
2154                 AC_CHECK_LIB(rrd_th, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
2155         else
2156                 AC_CHECK_LIB(rrd, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
2157         fi
2158
2159         CPPFLAGS="$SAVE_CPPFLAGS"
2160         LDFLAGS="$SAVE_LDFLAGS"
2161 fi
2162 if test "x$with_librrd" = "xyes"
2163 then
2164         BUILD_WITH_LIBRRD_CFLAGS="$librrd_cflags"
2165         BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
2166         AC_SUBST(BUILD_WITH_LIBRRD_CFLAGS)
2167         AC_SUBST(BUILD_WITH_LIBRRD_LDFLAGS)
2168 fi
2169 if test "x$librrd_threadsafe" = "xyes"
2170 then
2171         AC_DEFINE(HAVE_THREADSAFE_LIBRRD, 1, [Define to 1 if you have the threadsafe rrd library (-lrrd_th).])
2172 fi
2173 # }}}
2174
2175 # --with-libsensors {{{
2176 with_sensors_cflags=""
2177 with_sensors_ldflags=""
2178 AC_ARG_WITH(libsensors, [AS_HELP_STRING([--with-libsensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
2179 [
2180         if test "x$withval" = "xno"
2181         then
2182                 with_libsensors="no"
2183         else
2184                 with_libsensors="yes"
2185                 if test "x$withval" != "xyes"
2186                 then
2187                         with_sensors_cflags="-I$withval/include"
2188                         with_sensors_ldflags="-L$withval/lib"
2189                         with_libsensors="yes"
2190                 fi
2191         fi
2192 ],
2193 [
2194         if test "x$ac_system" = "xLinux"
2195         then
2196                 with_libsensors="yes"
2197         else
2198                 with_libsensors="no (Linux only library)"
2199         fi
2200 ])
2201 if test "x$with_libsensors" = "xyes"
2202 then
2203         SAVE_CPPFLAGS="$CPPFLAGS"
2204         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
2205
2206 #       AC_CHECK_HEADERS(sensors/sensors.h,
2207 #       [
2208 #               AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
2209 #       ],
2210 #       [with_libsensors="no (sensors/sensors.h not found)"])
2211         AC_CHECK_HEADERS(sensors/sensors.h, [], [with_libsensors="no (sensors/sensors.h not found)"])
2212
2213         CPPFLAGS="$SAVE_CPPFLAGS"
2214 fi
2215 if test "x$with_libsensors" = "xyes"
2216 then
2217         SAVE_CPPFLAGS="$CPPFLAGS"
2218         SAVE_LDFLAGS="$LDFLAGS"
2219         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
2220         LDFLAGS="$LDFLAGS $with_sensors_ldflags"
2221
2222         AC_CHECK_LIB(sensors, sensors_init,
2223         [
2224                 AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
2225         ],
2226         [with_libsensors="no (libsensors not found)"])
2227
2228         CPPFLAGS="$SAVE_CPPFLAGS"
2229         LDFLAGS="$SAVE_LDFLAGS"
2230 fi
2231 if test "x$with_libsensors" = "xyes"
2232 then
2233         BUILD_WITH_LIBSENSORS_CFLAGS="$with_sensors_cflags"
2234         BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
2235         AC_SUBST(BUILD_WITH_LIBSENSORS_CFLAGS)
2236         AC_SUBST(BUILD_WITH_LIBSENSORS_LDFLAGS)
2237 fi
2238 AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_libsensors" = "xyes")
2239 # }}}
2240
2241 # --with-libstatgrab {{{
2242 with_libstatgrab_cflags=""
2243 with_libstatgrab_ldflags=""
2244 AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
2245 [
2246  if test "x$withval" != "xno" \
2247    && test "x$withval" != "xyes"
2248  then
2249    with_libstatgrab_cflags="-I$withval/include"
2250    with_libstatgrab_ldflags="-L$withval/lib -lstatgrab"
2251    with_libstatgrab="yes"
2252    with_libstatgrab_pkg_config="no"
2253  else
2254    with_libstatgrab="$withval"
2255    with_libstatgrab_pkg_config="yes"
2256  fi
2257  ],
2258 [
2259  with_libstatgrab="yes"
2260  with_libstatgrab_pkg_config="yes"
2261 ])
2262
2263 if test "x$with_libstatgrab" = "xyes" \
2264   && test "x$with_libstatgrab_pkg_config" = "xyes"
2265 then
2266   if test "x$PKG_CONFIG" != "x"
2267   then
2268     AC_MSG_CHECKING([pkg-config for libstatgrab])
2269     temp_result="found"
2270     $PKG_CONFIG --exists libstatgrab 2>/dev/null
2271     if test "$?" != "0"
2272     then
2273       with_libstatgrab_pkg_config="no"
2274       with_libstatgrab="no ($PKG_CONFIG doesn't know libstatgrab)"
2275       temp_result="not found"
2276     fi
2277     AC_MSG_RESULT([$temp_result])
2278   else
2279     AC_MSG_NOTICE([pkg-config not available, trying to guess flags for the statgrab library.])
2280     with_libstatgrab_pkg_config="no"
2281     with_libstatgrab_ldflags="$with_libstatgrab_ldflags -lstatgrab"
2282   fi
2283 fi
2284
2285 if test "x$with_libstatgrab" = "xyes" \
2286   && test "x$with_libstatgrab_pkg_config" = "xyes" \
2287   && test "x$with_libstatgrab_cflags" = "x"
2288 then
2289   AC_MSG_CHECKING([for libstatgrab CFLAGS])
2290   temp_result="`$PKG_CONFIG --cflags libstatgrab`"
2291   if test "$?" = "0"
2292   then
2293     with_libstatgrab_cflags="$temp_result"
2294   else
2295     with_libstatgrab="no ($PKG_CONFIG --cflags libstatgrab failed)"
2296     temp_result="$PKG_CONFIG --cflags libstatgrab failed"
2297   fi
2298   AC_MSG_RESULT([$temp_result])
2299 fi
2300
2301 if test "x$with_libstatgrab" = "xyes" \
2302   && test "x$with_libstatgrab_pkg_config" = "xyes" \
2303   && test "x$with_libstatgrab_ldflags" = "x"
2304 then
2305   AC_MSG_CHECKING([for libstatgrab LDFLAGS])
2306   temp_result="`$PKG_CONFIG --libs libstatgrab`"
2307   if test "$?" = "0"
2308   then
2309     with_libstatgrab_ldflags="$temp_result"
2310   else
2311     with_libstatgrab="no ($PKG_CONFIG --libs libstatgrab failed)"
2312     temp_result="$PKG_CONFIG --libs libstatgrab failed"
2313   fi
2314   AC_MSG_RESULT([$temp_result])
2315 fi
2316
2317 if test "x$with_libstatgrab" = "xyes"
2318 then
2319   SAVE_CPPFLAGS="$CPPFLAGS"
2320   CPPFLAGS="$CPPFLAGS $with_libstatgrab_cflags"
2321
2322   AC_CHECK_HEADERS(statgrab.h,
2323                    [with_libstatgrab="yes"],
2324                    [with_libstatgrab="no (statgrab.h not found)"])
2325
2326   CPPFLAGS="$SAVE_CPPFLAGS"
2327 fi
2328
2329 if test "x$with_libstatgrab" = "xyes"
2330 then
2331   SAVE_CFLAGS="$CFLAGS"
2332   SAVE_LDFLAGS="$LDFLAGS"
2333
2334   CFLAGS="$CFLAGS $with_libstatgrab_cflags"
2335   LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
2336
2337   AC_CHECK_LIB(statgrab, sg_init,
2338                [with_libstatgrab="yes"],
2339                [with_libstatgrab="no (symbol sg_init not found)"])
2340
2341   CFLAGS="$SAVE_CFLAGS"
2342   LDFLAGS="$SAVE_LDFLAGS"
2343 fi
2344
2345 AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
2346 if test "x$with_libstatgrab" = "xyes"
2347 then
2348   AC_DEFINE(HAVE_LIBSTATGRAB, 1, [Define to 1 if you have the 'statgrab' library (-lstatgrab)])
2349   BUILD_WITH_LIBSTATGRAB_CFLAGS="$with_libstatgrab_cflags"
2350   BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
2351   AC_SUBST(BUILD_WITH_LIBSTATGRAB_CFLAGS)
2352   AC_SUBST(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
2353 fi
2354 # }}}
2355
2356 # --with-libupsclient {{{
2357 with_libupsclient_config=""
2358 with_libupsclient_cflags=""
2359 with_libupsclient_libs=""
2360 AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
2361 [
2362         if test "x$withval" = "xno"
2363         then
2364                 with_libupsclient="no"
2365         else if test "x$withval" = "xyes"
2366         then
2367                 with_libupsclient="use_pkgconfig"
2368         else
2369                 if test -x "$withval"
2370                 then
2371                         with_libupsclient_config="$withval"
2372                         with_libupsclient="use_libupsclient_config"
2373                 else if test -x "$withval/bin/libupsclient-config"
2374                 then
2375                         with_libupsclient_config="$withval/bin/net-snmp-config"
2376                         with_libupsclient="use_libupsclient_config"
2377                 else
2378                         AC_MSG_NOTICE([Not checking for libupsclient: Manually configured])
2379                         with_libupsclient_cflags="-I$withval/include"
2380                         with_libupsclient_libs="-L$withval/lib -lupsclient"
2381                         with_libupsclient="yes"
2382                 fi; fi
2383         fi; fi
2384 ],
2385 [with_libupsclient="use_pkgconfig"])
2386
2387 # configure using libupsclient-config
2388 if test "x$with_libupsclient" = "xuse_libupsclient_config"
2389 then
2390         AC_MSG_NOTICE([Checking for libupsclient using $with_libupsclient_config])
2391         with_libupsclient_cflags="`$with_libupsclient_config --cflags`"
2392         if test $? -ne 0
2393         then
2394                 with_libupsclient="no ($with_libupsclient_config failed)"
2395         fi
2396         with_libupsclient_libs="`$with_libupsclient_config --libs`"
2397         if test $? -ne 0
2398         then
2399                 with_libupsclient="no ($with_libupsclient_config failed)"
2400         fi
2401 fi
2402 if test "x$with_libupsclient" = "xuse_libupsclient_config"
2403 then
2404         with_libupsclient="yes"
2405 fi
2406
2407 # configure using pkg-config
2408 if test "x$with_libupsclient" = "xuse_pkgconfig"
2409 then
2410         if test "x$PKG_CONFIG" = "x"
2411         then
2412                 with_libupsclient="no (Don't have pkg-config)"
2413         fi
2414 fi
2415 if test "x$with_libupsclient" = "xuse_pkgconfig"
2416 then
2417         AC_MSG_NOTICE([Checking for libupsclient using $PKG_CONFIG])
2418         $PKG_CONFIG --exists 'libupsclient' 2>/dev/null
2419         if test $? -ne 0
2420         then
2421                 with_libupsclient="no (pkg-config doesn't know library)"
2422         fi
2423 fi
2424 if test "x$with_libupsclient" = "xuse_pkgconfig"
2425 then
2426         with_libupsclient_cflags="`$PKG_CONFIG --cflags 'libupsclient'`"
2427         if test $? -ne 0
2428         then
2429                 with_libupsclient="no ($PKG_CONFIG failed)"
2430         fi
2431         with_libupsclient_libs="`$PKG_CONFIG --libs 'libupsclient'`"
2432         if test $? -ne 0
2433         then
2434                 with_libupsclient="no ($PKG_CONFIG failed)"
2435         fi
2436 fi
2437 if test "x$with_libupsclient" = "xuse_pkgconfig"
2438 then
2439         with_libupsclient="yes"
2440 fi
2441
2442 # with_libupsclient_cflags and with_libupsclient_libs are set up now, let's do
2443 # the actual checks.
2444 if test "x$with_libupsclient" = "xyes"
2445 then
2446         SAVE_CPPFLAGS="$CPPFLAGS"
2447         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
2448
2449         AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])
2450
2451         CPPFLAGS="$SAVE_CPPFLAGS"
2452 fi
2453 if test "x$with_libupsclient" = "xyes"
2454 then
2455         SAVE_CPPFLAGS="$CPPFLAGS"
2456         SAVE_LDFLAGS="$LDFLAGS"
2457
2458         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
2459         LDFLAGS="$LDFLAGS $with_libupsclient_libs"
2460
2461         AC_CHECK_LIB(upsclient, upscli_connect,
2462                      [with_libupsclient="yes"],
2463                      [with_libupsclient="no (symbol upscli_connect not found)"])
2464
2465         CPPFLAGS="$SAVE_CPPFLAGS"
2466         LDFLAGS="$SAVE_LDFLAGS"
2467 fi
2468 if test "x$with_libupsclient" = "xyes"
2469 then
2470         SAVE_CPPFLAGS="$CPPFLAGS"
2471         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
2472
2473         AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [],
2474 [#include <stdlib.h>
2475 #include <stdio.h>
2476 #include <upsclient.h>])
2477
2478         CPPFLAGS="$SAVE_CPPFLAGS"
2479 fi
2480 if test "x$with_libupsclient" = "xyes"
2481 then
2482         BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_libupsclient_cflags"
2483         BUILD_WITH_LIBUPSCLIENT_LIBS="$with_libupsclient_libs"
2484         AC_SUBST(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
2485         AC_SUBST(BUILD_WITH_LIBUPSCLIENT_LIBS)
2486 fi
2487 # }}}
2488
2489 # --with-libxmms {{{
2490 with_xmms_config="xmms-config"
2491 with_xmms_cflags=""
2492 with_xmms_libs=""
2493 AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
2494 [
2495         if test "x$withval" != "xno" \
2496                 && test "x$withval" != "xyes"
2497         then
2498                 if test -f "$withval" && test -x "$withval";
2499                 then
2500                         with_xmms_config="$withval"
2501                 else if test -x "$withval/bin/xmms-config"
2502                 then
2503                         with_xmms_config="$withval/bin/xmms-config"
2504                 fi; fi
2505                 with_libxmms="yes"
2506         else if test "x$withval" = "xno"
2507         then
2508                 with_libxmms="no"
2509         else
2510                 with_libxmms="yes"
2511         fi; fi
2512 ],
2513 [
2514         with_libxmms="yes"
2515 ])
2516 if test "x$with_libxmms" = "xyes"
2517 then
2518         with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
2519         xmms_config_status=$?
2520
2521         if test $xmms_config_status -ne 0
2522         then
2523                 with_libxmms="no"
2524         fi
2525 fi
2526 if test "x$with_libxmms" = "xyes"
2527 then
2528         with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
2529         xmms_config_status=$?
2530
2531         if test $xmms_config_status -ne 0
2532         then
2533                 with_libxmms="no"
2534         fi
2535 fi
2536 if test "x$with_libxmms" = "xyes"
2537 then
2538         AC_CHECK_LIB(xmms, xmms_remote_get_info,
2539         [
2540                 BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
2541                 BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
2542                 AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
2543                 AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
2544         ],
2545         [
2546                 with_libxmms="no"
2547         ],
2548         [$with_xmms_libs])
2549 fi
2550 with_libxmms_numeric=0
2551 if test "x$with_libxmms" = "xyes"
2552 then
2553         with_libxmms_numeric=1
2554 fi
2555 AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
2556 AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
2557 # }}}
2558
2559 # pkg-config --exists 'libxml-2.0'; pkg-config --exists libvirt {{{
2560 with_libxml2="no (pkg-config isn't available)"
2561 with_libxml2_cflags=""
2562 with_libxml2_ldflags=""
2563 with_libvirt="no (pkg-config isn't available)"
2564 with_libvirt_cflags=""
2565 with_libvirt_ldflags=""
2566 if test "x$PKG_CONFIG" != "x"
2567 then
2568         pkg-config --exists 'libxml-2.0' 2>/dev/null
2569         if test "$?" = "0"
2570         then
2571                 with_libxml2="yes"
2572         else
2573                 with_libxml2="no (pkg-config doesn't know library)"
2574         fi
2575
2576         pkg-config --exists libvirt 2>/dev/null
2577         if test "$?" = "0"
2578         then
2579                 with_libvirt="yes"
2580         else
2581                 with_libvirt="no (pkg-config doesn't know library)"
2582         fi
2583 fi
2584 if test "x$with_libxml2" = "xyes"
2585 then
2586         with_libxml2_cflags="`pkg-config --cflags libxml-2.0`"
2587         if test $? -ne 0
2588         then
2589                 with_libxml2="no"
2590         fi
2591         with_libxml2_ldflags="`pkg-config --libs libxml-2.0`"
2592         if test $? -ne 0
2593         then
2594                 with_libxml2="no"
2595         fi
2596 fi
2597 if test "x$with_libxml2" = "xyes"
2598 then
2599         SAVE_CPPFLAGS="$CPPFLAGS"
2600         CPPFLAGS="$CPPFLAGS $with_libxml2_cflags"
2601
2602         AC_CHECK_HEADERS(libxml/parser.h, [],
2603                       [with_libxml2="no (libxml/parser.h not found)"])
2604
2605         CPPFLAGS="$SAVE_CPPFLAGS"
2606 fi
2607 if test "x$with_libxml2" = "xyes"
2608 then
2609         SAVE_CFLAGS="$CFLAGS"
2610         SAVE_LDFLAGS="$LDFLAGS"
2611
2612         CFLAGS="$CFLAGS $with_libxml2_cflags"
2613         LDFLAGS="$LDFLAGS $with_libxml2_ldflags"
2614
2615         AC_CHECK_LIB(xml2, xmlXPathEval,
2616                      [with_libxml2="yes"],
2617                      [with_libxml2="no (symbol xmlXPathEval not found)"])
2618
2619         CFLAGS="$SAVE_CFLAGS"
2620         LDFLAGS="$SAVE_LDFLAGS"
2621 fi
2622 dnl Add the right compiler flags and libraries.
2623 if test "x$with_libxml2" = "xyes"; then
2624         BUILD_WITH_LIBXML2_CFLAGS="$with_libxml2_cflags"
2625         BUILD_WITH_LIBXML2_LIBS="$with_libxml2_ldflags"
2626         AC_SUBST(BUILD_WITH_LIBXML2_CFLAGS)
2627         AC_SUBST(BUILD_WITH_LIBXML2_LIBS)
2628 fi
2629 if test "x$with_libvirt" = "xyes"
2630 then
2631         with_libvirt_cflags="`pkg-config --cflags libvirt`"
2632         if test $? -ne 0
2633         then
2634                 with_libvirt="no"
2635         fi
2636         with_libvirt_ldflags="`pkg-config --libs libvirt`"
2637         if test $? -ne 0
2638         then
2639                 with_libvirt="no"
2640         fi
2641 fi
2642 if test "x$with_libvirt" = "xyes"
2643 then
2644         SAVE_CPPFLAGS="$CPPFLAGS"
2645         CPPFLAGS="$CPPFLAGS $with_libvirt_cflags"
2646
2647         AC_CHECK_HEADERS(libvirt/libvirt.h, [],
2648                       [with_libvirt="no (libvirt/libvirt.h not found)"])
2649
2650         CPPFLAGS="$SAVE_CPPFLAGS"
2651 fi
2652 if test "x$with_libvirt" = "xyes"
2653 then
2654         SAVE_CFLAGS="$CFLAGS"
2655         SAVE_LDFLAGS="$LDFLAGS"
2656
2657         CFLAGS="$CFLAGS $with_libvirt_cflags"
2658         LDFLAGS="$LDFLAGS $with_libvirt_ldflags"
2659
2660         AC_CHECK_LIB(virt, virDomainBlockStats,
2661                      [with_libvirt="yes"],
2662                      [with_libvirt="no (symbol virDomainBlockStats not found)"])
2663
2664         CFLAGS="$SAVE_CFLAGS"
2665         LDFLAGS="$SAVE_LDFLAGS"
2666 fi
2667 dnl Add the right compiler flags and libraries.
2668 if test "x$with_libvirt" = "xyes"; then
2669         BUILD_WITH_LIBVIRT_CFLAGS="$with_libvirt_cflags"
2670         BUILD_WITH_LIBVIRT_LIBS="$with_libvirt_ldflags"
2671         AC_SUBST(BUILD_WITH_LIBVIRT_CFLAGS)
2672         AC_SUBST(BUILD_WITH_LIBVIRT_LIBS)
2673 fi
2674 # }}}
2675
2676 # $PKG_CONFIG --exists OpenIPMIpthread {{{
2677 with_libopenipmipthread="yes"
2678 with_libopenipmipthread_cflags=""
2679 with_libopenipmipthread_libs=""
2680
2681 AC_MSG_CHECKING([for pkg-config])
2682 temp_result="no"
2683 if test "x$PKG_CONFIG" = "x"
2684 then
2685         with_libopenipmipthread="no"
2686         temp_result="no"
2687 else
2688         temp_result="$PKG_CONFIG"
2689 fi
2690 AC_MSG_RESULT([$temp_result])
2691
2692 if test "x$with_libopenipmipthread" = "xyes"
2693 then
2694         AC_MSG_CHECKING([for libOpenIPMIpthread])
2695         $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
2696         if test "$?" != "0"
2697         then
2698                 with_libopenipmipthread="no ($PKG_CONFIG doesn't know OpenIPMIpthread)"
2699         fi
2700         AC_MSG_RESULT([$with_libopenipmipthread])
2701 fi
2702
2703 if test "x$with_libopenipmipthread" = "xyes"
2704 then
2705         AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS])
2706         temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`"
2707         if test "$?" = "0"
2708         then
2709                 with_libopenipmipthread_cflags="$temp_result"
2710         else
2711                 with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)"
2712                 temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed"
2713         fi
2714         AC_MSG_RESULT([$temp_result])
2715 fi
2716
2717 if test "x$with_libopenipmipthread" = "xyes"
2718 then
2719         AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS])
2720         temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`"
2721         if test "$?" = "0"
2722         then
2723                 with_libopenipmipthread_ldflags="$temp_result"
2724         else
2725                 with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)"
2726                 temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed"
2727         fi
2728         AC_MSG_RESULT([$temp_result])
2729 fi
2730
2731 if test "x$with_libopenipmipthread" = "xyes"
2732 then
2733         SAVE_CPPFLAGS="$CPPFLAGS"
2734         CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags"
2735
2736         AC_CHECK_HEADERS(OpenIPMI/ipmi_smi.h,
2737                          [with_libopenipmipthread="yes"],
2738                          [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"],
2739 [#include <OpenIPMI/ipmiif.h>
2740 #include <OpenIPMI/ipmi_err.h>
2741 #include <OpenIPMI/ipmi_posix.h>
2742 #include <OpenIPMI/ipmi_conn.h>
2743 ])
2744
2745         CPPFLAGS="$SAVE_CPPFLAGS"
2746 fi
2747
2748 if test "x$with_libopenipmipthread" = "xyes"
2749 then
2750         BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags"
2751         BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags"
2752         AC_SUBST(BUILD_WITH_OPENIPMI_CFLAGS)
2753         AC_SUBST(BUILD_WITH_OPENIPMI_LIBS)
2754 fi
2755 # }}}
2756
2757 PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
2758                 [with_libnotify="yes"],
2759                 [with_libnotify="no ($LIBNOTIFY_PKG_ERRORS)"])
2760
2761 # Check for enabled/disabled features
2762 #
2763
2764 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
2765 # ------------------------------------------------------------
2766 dnl
2767 m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
2768 dnl
2769 AC_DEFUN(
2770         [AC_COLLECTD],
2771         [
2772         m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
2773         m4_if(
2774                 [$2],
2775                 [enable],
2776                 [dnl
2777                 m4_define([EnDis],[disabled])dnl
2778                 m4_define([YesNo],[no])dnl
2779                 ],dnl
2780                 [m4_if(
2781                         [$2],
2782                         [disable],
2783                         [dnl
2784                         m4_define([EnDis],[enabled])dnl
2785                         m4_define([YesNo],[yes])dnl
2786                         ],
2787                         [dnl
2788                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
2789                         ]dnl
2790                 )]dnl
2791         )dnl
2792         m4_if([$3], [feature], [],
2793                 [m4_if(
2794                         [$3], [module], [],
2795                         [dnl
2796                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
2797                         ]dnl
2798                 )]dnl
2799         )dnl
2800         AC_ARG_ENABLE(
2801                 [$1],
2802                 AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
2803                 [],
2804                 enable_$1='[YesNo]'dnl
2805         )# AC_ARG_ENABLE
2806 if test "x$enable_$1" = "xno"
2807 then
2808         collectd_$1=0
2809 else
2810         if test "x$enable_$1" = "xyes"
2811         then
2812                 collectd_$1=1
2813         else
2814                 AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
2815                 collectd_$1=1
2816                 enable_$1='yes'
2817         fi
2818 fi
2819         AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
2820         AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
2821         ]dnl
2822 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
2823
2824 # AC_PLUGIN(name, default, info)
2825 # ------------------------------------------------------------
2826 dnl
2827 AC_DEFUN(
2828   [AC_PLUGIN],
2829   [
2830     enable_plugin="no"
2831     AC_ARG_ENABLE([$1], AC_HELP_STRING([--enable-$1], [$3]),
2832     [
2833      if test "x$enableval" = "xyes"
2834      then
2835              enable_plugin="yes"
2836      else
2837              enable_plugin="no"
2838      fi
2839     ],
2840     [
2841      if test "x$2" = "xyes"
2842      then
2843              enable_plugin="yes"
2844      else
2845              enable_plugin="no"
2846      fi
2847     ])
2848     if test "x$enable_plugin" = "xyes"
2849     then
2850             if test "x$2" = "xyes"
2851             then
2852                     AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
2853             else # User passed "yes" but dependency checking yielded "no" => Dependency problem.
2854                     dependency_error="yes"
2855                     enable_plugin="no (dependency error)"
2856             fi
2857     fi
2858     AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), test "x$enable_plugin" = "xyes")
2859     enable_$1="$enable_plugin"
2860   ]
2861 )# AC_PLUGIN(name, default, info)
2862
2863 m4_divert_once([HELP_ENABLE], [
2864 collectd features:])
2865 # FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
2866 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
2867 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
2868 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
2869
2870 dependency_error="no"
2871 plugin_ascent="no"
2872 plugin_battery="no"
2873 plugin_bind="no"
2874 plugin_cpu="no"
2875 plugin_cpufreq="no"
2876 plugin_df="no"
2877 plugin_disk="no"
2878 plugin_entropy="no"
2879 plugin_interface="no"
2880 plugin_ipmi="no"
2881 plugin_ipvs="no"
2882 plugin_irq="no"
2883 plugin_libvirt="no"
2884 plugin_load="no"
2885 plugin_memory="no"
2886 plugin_multimeter="no"
2887 plugin_nfs="no"
2888 plugin_perl="no"
2889 plugin_processes="no"
2890 plugin_serial="no"
2891 plugin_swap="no"
2892 plugin_tape="no"
2893 plugin_tcpconns="no"
2894 plugin_thermal="no"
2895 plugin_users="no"
2896 plugin_vmem="no"
2897 plugin_vserver="no"
2898 plugin_wireless="no"
2899
2900 # Linux
2901 if test "x$ac_system" = "xLinux"
2902 then
2903         plugin_battery="yes"
2904         plugin_cpu="yes"
2905         plugin_cpufreq="yes"
2906         plugin_disk="yes"
2907         plugin_entropy="yes"
2908         plugin_interface="yes"
2909         plugin_irq="yes"
2910         plugin_load="yes"
2911         plugin_memory="yes"
2912         plugin_nfs="yes"
2913         plugin_processes="yes"
2914         plugin_serial="yes"
2915         plugin_swap="yes"
2916         plugin_tcpconns="yes"
2917         plugin_thermal="yes"
2918         plugin_vmem="yes"
2919         plugin_vserver="yes"
2920         plugin_wireless="yes"
2921
2922         if test "x$have_net_ip_vs_h" = "xyes" -o "x$have_ip_vs_h" = "xyes"
2923         then
2924                 plugin_ipvs="yes"
2925         fi
2926 fi
2927
2928 if test "x$ac_system" = "xOpenBSD"
2929 then
2930         plugin_tcpconns="yes"
2931 fi
2932
2933 # Mac OS X devices
2934 if test "x$with_libiokit" = "xyes"
2935 then
2936         plugin_battery="yes"
2937         plugin_disk="yes"
2938 fi
2939
2940 # Solaris
2941 if test "x$with_devinfo$with_kstat" = "xyesyes"
2942 then
2943         plugin_cpu="yes"
2944         plugin_disk="yes"
2945         plugin_interface="yes"
2946         plugin_memory="yes"
2947         plugin_tape="yes"
2948 fi
2949
2950 if test "x$have_sys_swap_h$with_kstat$ac_system" = "xyesyesSolaris"
2951 then
2952         plugin_swap="yes"
2953 fi
2954
2955 # libstatgrab
2956 if test "x$with_libstatgrab" = "xyes"
2957 then
2958         plugin_cpu="yes"
2959         plugin_disk="yes"
2960         plugin_interface="yes"
2961         plugin_load="yes"
2962         plugin_memory="yes"
2963         plugin_swap="yes"
2964         plugin_users="yes"
2965 fi
2966
2967 if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
2968 then
2969         plugin_ascent="yes"
2970         plugin_bind="yes"
2971 fi
2972
2973 if test "x$with_libopenipmipthread" = "xyes"
2974 then
2975         plugin_ipmi="yes"
2976 fi
2977
2978 if test "x$have_processor_info" = "xyes"
2979 then
2980         plugin_cpu="yes"
2981 fi
2982 if test "x$have_sysctl" = "xyes"
2983 then
2984         plugin_cpu="yes"
2985         plugin_swap="yes"
2986 fi
2987 if test "x$have_sysctlbyname" = "xyes"
2988 then
2989         plugin_cpu="yes"
2990         plugin_memory="yes"
2991         plugin_tcpconns="yes"
2992 fi
2993
2994 # Df plugin: Check if we know how to determine mount points first.
2995 #if test "x$have_listmntent" = "xyes"; then
2996 #       plugin_df="yes"
2997 #fi
2998 if test "x$have_getvfsstat" = "xyes" || test "x$have_getfsstat" = "xyes"
2999 then
3000         plugin_df="yes"
3001 fi
3002 if test "x$c_cv_have_two_getmntent" = "xyes" || test "x$have_getmntent" = "xgen" || test "x$have_getmntent" = "xsun"
3003 then
3004         plugin_df="yes"
3005 fi
3006 #if test "x$have_getmntent" = "xseq"
3007 #then
3008 #       plugin_df="yes"
3009 #fi
3010 if test "x$c_cv_have_one_getmntent" = "xyes"
3011 then
3012         plugin_df="yes"
3013 fi
3014
3015 # Df plugin: Check if we have either `statfs' or `statvfs' second.
3016 if test "x$plugin_df" = "xyes"
3017 then
3018         plugin_df="no"
3019         if test "x$have_statfs" = "xyes"
3020         then
3021                 plugin_df="yes"
3022         fi
3023         if test "x$have_statvfs" = "xyes"
3024         then
3025                 plugin_df="yes"
3026         fi
3027 fi
3028
3029 if test "x$have_getifaddrs" = "xyes"
3030 then
3031         plugin_interface="yes"
3032 fi
3033
3034 if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes"
3035 then
3036         plugin_libvirt="yes"
3037 fi
3038
3039 if test "x$have_getloadavg" = "xyes"
3040 then
3041         plugin_load="yes"
3042 fi
3043
3044 if test "x$c_cv_have_libperl$c_cv_have_perl_ithreads" = "xyesyes"
3045 then
3046         plugin_perl="yes"
3047 fi
3048
3049 # Mac OS X memory interface
3050 if test "x$have_host_statistics" = "xyes"
3051 then
3052         plugin_memory="yes"
3053 fi
3054
3055 if test "x$have_termios_h" = "xyes"
3056 then
3057         plugin_multimeter="yes"
3058 fi
3059
3060 if test "x$have_thread_info" = "xyes"
3061 then
3062         plugin_processes="yes"
3063 fi
3064
3065 if test "x$with_kvm_getprocs" = "xyes" && test "x$have_struct_kinfo_proc_freebsd" = "xyes"
3066 then
3067         plugin_processes="yes"
3068 fi
3069
3070 if test "x$with_kvm_getswapinfo" = "xyes"
3071 then
3072         plugin_swap="yes"
3073 fi
3074
3075 if test "x$have_swapctl" = "xyes"
3076 then
3077         plugin_swap="yes"
3078 fi
3079
3080 if test "x$with_kvm_openfiles$with_kvm_nlist" = "xyesyes"
3081 then
3082         plugin_tcpconns="yes"
3083 fi
3084
3085 if test "x$have_getutent" = "xyes"
3086 then
3087         plugin_users="yes"
3088 fi
3089 if test "x$have_getutxent" = "xyes"
3090 then
3091         plugin_users="yes"
3092 fi
3093
3094 m4_divert_once([HELP_ENABLE], [
3095 collectd plugins:])
3096
3097 AC_PLUGIN([apache],      [$with_libcurl],      [Apache httpd statistics])
3098 AC_PLUGIN([apcups],      [yes],                [Statistics of UPSes by APC])
3099 AC_PLUGIN([apple_sensors], [$with_libiokit],   [Apple's hardware sensors])
3100 AC_PLUGIN([ascent],      [$plugin_ascent],     [AscentEmu player statistics])
3101 AC_PLUGIN([battery],     [$plugin_battery],    [Battery statistics])
3102 AC_PLUGIN([bind],        [$plugin_bind],       [ISC Bind nameserver statistics])
3103 AC_PLUGIN([cpufreq],     [$plugin_cpufreq],    [CPU frequency statistics])
3104 AC_PLUGIN([cpu],         [$plugin_cpu],        [CPU usage statistics])
3105 AC_PLUGIN([csv],         [yes],                [CSV output plugin])
3106 AC_PLUGIN([curl],        [$with_libcurl],      [CURL generic web statistics])
3107 AC_PLUGIN([dbi],         [$with_libdbi],       [General database statistics])
3108 AC_PLUGIN([df],          [$plugin_df],         [Filesystem usage statistics])
3109 AC_PLUGIN([disk],        [$plugin_disk],       [Disk usage statistics])
3110 AC_PLUGIN([dns],         [$with_libpcap],      [DNS traffic analysis])
3111 AC_PLUGIN([email],       [yes],                [EMail statistics])
3112 AC_PLUGIN([entropy],     [$plugin_entropy],    [Entropy statistics])
3113 AC_PLUGIN([exec],        [yes],                [Execution of external programs])
3114 AC_PLUGIN([filecount],   [yes],                [Count files in directories])
3115 AC_PLUGIN([hddtemp],     [yes],                [Query hddtempd])
3116 AC_PLUGIN([interface],   [$plugin_interface],  [Interface traffic statistics])
3117 AC_PLUGIN([ipmi],        [$plugin_ipmi],       [IPMI sensor statistics])
3118 AC_PLUGIN([iptables],    [$with_libiptc],      [IPTables rule counters])
3119 AC_PLUGIN([ipvs],        [$plugin_ipvs],       [IPVS connection statistics])
3120 AC_PLUGIN([irq],         [$plugin_irq],        [IRQ statistics])
3121 AC_PLUGIN([libvirt],     [$plugin_libvirt],    [Virtual machine statistics])
3122 AC_PLUGIN([load],        [$plugin_load],       [System load])
3123 AC_PLUGIN([logfile],     [yes],                [File logging plugin])
3124 AC_PLUGIN([match_regex], [yes],                [The regex match])
3125 AC_PLUGIN([match_timediff], [yes],             [The timediff match])
3126 AC_PLUGIN([match_value], [yes],                [The value match])
3127 AC_PLUGIN([mbmon],       [yes],                [Query mbmond])
3128 AC_PLUGIN([memcached],   [yes],                [memcached statistics])
3129 AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
3130 AC_PLUGIN([multimeter],  [$plugin_multimeter], [Read multimeter values])
3131 AC_PLUGIN([mysql],       [$with_libmysql],     [MySQL statistics])
3132 AC_PLUGIN([netlink],     [$with_libnetlink],   [Enhanced Linux network statistics])
3133 AC_PLUGIN([network],     [yes],                [Network communication plugin])
3134 AC_PLUGIN([nfs],         [$plugin_nfs],        [NFS statistics])
3135 AC_PLUGIN([nginx],       [$with_libcurl],      [nginx statistics])
3136 AC_PLUGIN([notify_desktop], [$with_libnotify], [Desktop notifications])
3137 AC_PLUGIN([notify_email], [$with_libesmtp],    [Email notifier])
3138 AC_PLUGIN([ntpd],        [yes],                [NTPd statistics])
3139 AC_PLUGIN([nut],         [$with_libupsclient], [Network UPS tools statistics])
3140 AC_PLUGIN([onewire],     [$with_libowcapi],    [OneWire sensor statistics])
3141 AC_PLUGIN([openvpn],     [yes],                [OpenVPN client statistics])
3142 AC_PLUGIN([oracle],      [$with_oracle],       [Oracle plugin])
3143 AC_PLUGIN([perl],        [$plugin_perl],       [Embed a Perl interpreter])
3144 AC_PLUGIN([ping],        [$with_liboping],     [Network latency statistics])
3145 AC_PLUGIN([postgresql],  [$with_libpq],        [PostgreSQL database statistics])
3146 AC_PLUGIN([powerdns],    [yes],                [PowerDNS statistics])
3147 AC_PLUGIN([processes],   [$plugin_processes],  [Process statistics])
3148 AC_PLUGIN([rrdcached],   [$librrd_rrdc_update], [RRDTool output plugin])
3149 AC_PLUGIN([rrdtool],     [$with_librrd],       [RRDTool output plugin])
3150 AC_PLUGIN([sensors],     [$with_libsensors],   [lm_sensors statistics])
3151 AC_PLUGIN([serial],      [$plugin_serial],     [serial port traffic])
3152 AC_PLUGIN([snmp],        [$with_libnetsnmp],   [SNMP querying plugin])
3153 AC_PLUGIN([swap],        [$plugin_swap],       [Swap usage statistics])
3154 AC_PLUGIN([syslog],      [$have_syslog],       [Syslog logging plugin])
3155 AC_PLUGIN([tail],        [yes],                [Parsing of logfiles])
3156 AC_PLUGIN([tape],        [$plugin_tape],       [Tape drive statistics])
3157 AC_PLUGIN([target_notification], [yes],        [The notification target])
3158 AC_PLUGIN([target_replace], [yes],             [The replace target])
3159 AC_PLUGIN([target_set],  [yes],                [The set target])
3160 AC_PLUGIN([tcpconns],    [$plugin_tcpconns],   [TCP connection statistics])
3161 AC_PLUGIN([teamspeak2],  [yes],                [TeamSpeak2 server statistics])
3162 AC_PLUGIN([thermal],     [$plugin_thermal],    [Linux ACPI thermal zone statistics])
3163 AC_PLUGIN([unixsock],    [yes],                [Unixsock communication plugin])
3164 AC_PLUGIN([users],       [$plugin_users],      [User statistics])
3165 AC_PLUGIN([uuid],        [yes],                [UUID as hostname plugin])
3166 AC_PLUGIN([vmem],        [$plugin_vmem],       [Virtual memory statistics])
3167 AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
3168 AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
3169 AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
3170
3171 dnl ip_vs.h
3172 if test "x$ac_system" = "xLinux" \
3173         && test "x$have_net_ip_vs_h$have_ip_vs_h" = "xnono"
3174 then
3175         enable_ipvs="$enable_ipvs (ip_vs.h not found)"
3176 fi
3177
3178 dnl Perl bindings
3179 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
3180 [
3181         if test "x$withval" != "xno" && test "x$withval" != "xyes"
3182         then
3183                 PERL_BINDINGS_OPTIONS="$withval"
3184                 with_perl_bindings="yes"
3185         else
3186                 PERL_BINDINGS_OPTIONS=""
3187                 with_perl_bindings="$withval"
3188         fi
3189 ],
3190 [
3191         PERL_BINDINGS_OPTIONS=""
3192         if test -n "$perl_interpreter"
3193         then
3194                 with_perl_bindings="yes"
3195         else
3196                 with_perl_bindings="no (no perl interpreter found)"
3197         fi
3198 ])
3199 if test "x$with_perl_bindings" = "xyes"
3200 then
3201         PERL_BINDINGS="perl"
3202 else
3203         PERL_BINDINGS=""
3204 fi
3205 AC_SUBST(PERL_BINDINGS)
3206 AC_SUBST(PERL_BINDINGS_OPTIONS)
3207
3208 dnl libcollectdclient
3209 LCC_VERSION_MAJOR=`echo $PACKAGE_VERSION | cut -d'.' -f1`
3210 LCC_VERSION_MINOR=`echo $PACKAGE_VERSION | cut -d'.' -f2`
3211 LCC_VERSION_PATCH=`echo $PACKAGE_VERSION | cut -d'.' -f3`
3212
3213 LCC_VERSION_EXTRA=`echo $PACKAGE_VERSION | cut -d'.' -f4-`
3214
3215 LCC_VERSION_STRING="$LCC_VERSION_MAJOR.$LCC_VERSION_MINOR.$LCC_VERSION_PATCH"
3216
3217 AC_SUBST(LCC_VERSION_MAJOR)
3218 AC_SUBST(LCC_VERSION_MINOR)
3219 AC_SUBST(LCC_VERSION_PATCH)
3220 AC_SUBST(LCC_VERSION_EXTRA)
3221 AC_SUBST(LCC_VERSION_STRING)
3222
3223 AC_CONFIG_FILES(src/libcollectdclient/lcc_features.h)
3224
3225 AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/libiptc/Makefile src/libcollectdclient/Makefile src/libcollectdclient/libcollectdclient.pc src/liboconfig/Makefile src/liboping/Makefile bindings/Makefile)
3226
3227 if test "x$with_librrd" = "xyes" \
3228         && test "x$librrd_threadsafe" != "xyes"
3229 then
3230         with_librrd="yes (warning: librrd is not thread-safe)"
3231 fi
3232
3233 if test "x$with_liboping" = "xyes" \
3234         && test "x$with_own_liboping" = "xyes"
3235 then
3236         with_liboping="yes (shipped version)"
3237 fi
3238
3239 if test "x$with_libiptc" = "xyes" -a "x$with_own_libiptc" = "xyes"
3240 then
3241         with_libiptc="yes (shipped version)"
3242 fi
3243
3244 if test "x$with_libperl" = "xyes"
3245 then
3246         with_libperl="yes (version `$perl_interpreter -MConfig -e 'print $Config{version};'`)"
3247 else
3248         enable_perl="no (needs libperl)"
3249 fi
3250
3251 if test "x$with_perl_bindings" = "xyes" \
3252         && test "x$PERL_BINDINGS_OPTIONS" != "x"
3253 then
3254         with_perl_bindings="yes ($PERL_BINDINGS_OPTIONS)"
3255 fi
3256
3257 cat <<EOF;
3258
3259 Configuration:
3260   Libraries:
3261     libcurl . . . . . . . $with_libcurl
3262     libdbi  . . . . . . . $with_libdbi
3263     libesmtp  . . . . . . $with_libesmtp
3264     libiokit  . . . . . . $with_libiokit
3265     libiptc . . . . . . . $with_libiptc
3266     libkstat  . . . . . . $with_kstat
3267     libkvm  . . . . . . . $with_libkvm
3268     libmysql  . . . . . . $with_libmysql
3269     libnetlink  . . . . . $with_libnetlink
3270     libnetsnmp  . . . . . $with_libnetsnmp
3271     libnotify . . . . . . $with_libnotify
3272     liboconfig  . . . . . $with_liboconfig
3273     libopenipmi . . . . . $with_libopenipmipthread
3274     liboping  . . . . . . $with_liboping
3275     libpcap . . . . . . . $with_libpcap
3276     libperl . . . . . . . $with_libperl
3277     libpq . . . . . . . . $with_libpq
3278     libpthread  . . . . . $with_libpthread
3279     librrd  . . . . . . . $with_librrd
3280     libsensors  . . . . . $with_libsensors
3281     libstatgrab . . . . . $with_libstatgrab
3282     libupsclient  . . . . $with_libupsclient
3283     libvirt . . . . . . . $with_libvirt
3284     libxml2 . . . . . . . $with_libxml2
3285     libxmms . . . . . . . $with_libxmms
3286     oracle  . . . . . . . $with_oracle
3287
3288   Features:
3289     daemon mode . . . . . $enable_daemon
3290     debug . . . . . . . . $enable_debug
3291
3292   Bindings:
3293     perl  . . . . . . . . $with_perl_bindings
3294
3295   Modules:
3296     apache  . . . . . . . $enable_apache
3297     apcups  . . . . . . . $enable_apcups
3298     apple_sensors . . . . $enable_apple_sensors
3299     ascent  . . . . . . . $enable_ascent
3300     battery . . . . . . . $enable_battery
3301     bind  . . . . . . . . $enable_bind
3302     cpu . . . . . . . . . $enable_cpu
3303     cpufreq . . . . . . . $enable_cpufreq
3304     csv . . . . . . . . . $enable_csv
3305     curl  . . . . . . . . $enable_curl
3306     dbi . . . . . . . . . $enable_dbi
3307     df  . . . . . . . . . $enable_df
3308     disk  . . . . . . . . $enable_disk
3309     dns . . . . . . . . . $enable_dns
3310     email . . . . . . . . $enable_email
3311     entropy . . . . . . . $enable_entropy
3312     exec  . . . . . . . . $enable_exec
3313     filecount . . . . . . $enable_filecount
3314     hddtemp . . . . . . . $enable_hddtemp
3315     interface . . . . . . $enable_interface
3316     ipmi  . . . . . . . . $enable_ipmi
3317     iptables  . . . . . . $enable_iptables
3318     ipvs  . . . . . . . . $enable_ipvs
3319     irq . . . . . . . . . $enable_irq
3320     libvirt . . . . . . . $enable_libvirt
3321     load  . . . . . . . . $enable_load
3322     logfile . . . . . . . $enable_logfile
3323     match_regex . . . . . $enable_match_regex
3324     match_timediff  . . . $enable_match_timediff
3325     match_value . . . . . $enable_match_value
3326     mbmon . . . . . . . . $enable_mbmon
3327     memcached . . . . . . $enable_memcached
3328     memory  . . . . . . . $enable_memory
3329     multimeter  . . . . . $enable_multimeter
3330     mysql . . . . . . . . $enable_mysql
3331     netlink . . . . . . . $enable_netlink
3332     network . . . . . . . $enable_network
3333     nfs . . . . . . . . . $enable_nfs
3334     nginx . . . . . . . . $enable_nginx
3335     notify_desktop  . . . $enable_notify_desktop
3336     notify_email  . . . . $enable_notify_email
3337     ntpd  . . . . . . . . $enable_ntpd
3338     nut . . . . . . . . . $enable_nut
3339     onewire . . . . . . . $enable_onewire
3340     openvpn . . . . . . . $enable_openvpn
3341     oracle  . . . . . . . $enable_oracle
3342     perl  . . . . . . . . $enable_perl
3343     ping  . . . . . . . . $enable_ping
3344     postgresql  . . . . . $enable_postgresql
3345     powerdns  . . . . . . $enable_powerdns
3346     processes . . . . . . $enable_processes
3347     rrdcached . . . . . . $enable_rrdcached
3348     rrdtool . . . . . . . $enable_rrdtool
3349     sensors . . . . . . . $enable_sensors
3350     serial  . . . . . . . $enable_serial
3351     snmp  . . . . . . . . $enable_snmp
3352     swap  . . . . . . . . $enable_swap
3353     syslog  . . . . . . . $enable_syslog
3354     tail  . . . . . . . . $enable_tail
3355     tape  . . . . . . . . $enable_tape
3356     target_notification . $enable_target_notification
3357     target_replace  . . . $enable_target_replace
3358     target_set  . . . . . $enable_target_set
3359     tcpconns  . . . . . . $enable_tcpconns
3360     teamspeak2  . . . . . $enable_teamspeak2
3361     thermal . . . . . . . $enable_thermal
3362     unixsock  . . . . . . $enable_unixsock
3363     users . . . . . . . . $enable_users
3364     uuid  . . . . . . . . $enable_uuid
3365     vmem  . . . . . . . . $enable_vmem
3366     vserver . . . . . . . $enable_vserver
3367     wireless  . . . . . . $enable_wireless
3368     xmms  . . . . . . . . $enable_xmms
3369
3370 EOF
3371
3372 if test "x$dependency_error" = "xyes"; then
3373         AC_MSG_ERROR("Some plugins are missing dependencies - see above summary for details")
3374 fi
3375
3376 # vim: set fdm=marker :