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