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