1dnl Process this file with autoconf to produce a configure script.
2AC_PREREQ([2.60])
3AC_INIT([collectd],[m4_esyscmd(./version-gen.sh)])
4AC_CONFIG_SRCDIR(src/target_set.c)
5AC_CONFIG_HEADERS(src/config.h)
6AC_CONFIG_AUX_DIR([build-aux])
7AC_CONFIG_MACRO_DIR([m4])
8
9dnl older automake's default of ARFLAGS=cru is noisy on newer binutils;
10dnl we don't really need the 'u' even in older toolchains.  Then there is
11dnl older libtool, which spelled it AR_FLAGS
12m4_divert_text([DEFAULTS], [: "${ARFLAGS=cr} ${AR_FLAGS=cr}"])
13
14LT_INIT([dlopen disable-static])
15
16AM_INIT_AUTOMAKE([subdir-objects tar-pax dist-bzip2 no-dist-gzip foreign])
17m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
18AC_LANG(C)
19
20AC_PREFIX_DEFAULT("/opt/collectd")
21
22AC_SYS_LARGEFILE
23
24#
25# Checks for programs.
26#
27AC_PROG_CC_C99([],
28  [AC_MSG_ERROR([No compiler found that supports C99])]
29)
30
31AX_COMPILER_VENDOR
32
33AC_PROG_CXX
34AC_PROG_CPP
35AC_PROG_EGREP
36AC_PROG_INSTALL
37AC_PROG_LN_S
38AC_PROG_MAKE_SET
39AM_PROG_CC_C_O
40
41AC_PROG_LEX
42AC_PROG_YACC
43
44AC_PATH_PROG([VALGRIND], [valgrind])
45
46# Warn when pkg.m4 is missing
47m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-config])
48
49PKG_PROG_PKG_CONFIG
50
51AC_CACHE_CHECK([if Bison is the parser generator],
52  [collectd_cv_prog_bison],
53  [
54    AS_IF([$YACC --version 2>/dev/null | $EGREP -q '^bison '],
55      [collectd_cv_prog_bison=yes],
56      [collectd_cv_prog_bison=no]
57    )
58  ]
59)
60
61if test "x$collectd_cv_prog_bison" = "xno" && test ! -f "${srcdir}/src/liboconfig/parser.c"; then
62  AC_MSG_ERROR([bison is missing and you do not have ${srcdir}/src/liboconfig/parser.c. Please install bison])
63fi
64
65if test "x$lt_cv_dlopen" = "xno"; then
66  AC_MSG_ERROR([Your system does not support dlopen])
67fi
68
69AC_SUBST([DLOPEN_LIBS], [$lt_cv_dlopen_libs])
70
71
72AC_MSG_CHECKING([for kernel type ($host_os)])
73case $host_os in
74  *aix*)
75    AC_DEFINE([KERNEL_AIX], [1], [True if program is to be compiled for a AIX kernel])
76    ac_system="AIX"
77    ;;
78  *darwin*)
79    AC_DEFINE([KERNEL_DARWIN], [1], [True if program is to be compiled for a Darwin kernel])
80    ac_system="Darwin"
81    ;;
82  *freebsd*)
83    AC_DEFINE([KERNEL_FREEBSD], [1], [True if program is to be compiled for a FreeBSD kernel])
84    ac_system="FreeBSD"
85    ;;
86  *dragonfly*)
87    AC_DEFINE([KERNEL_DRAGONFLY], [1], [True if program is to be compiled for a DragonFly BSD kernel])
88    ac_system="DragonFlyBSD"
89    ;;
90  *linux*)
91    AC_DEFINE([KERNEL_LINUX], [1], [True if program is to be compiled for a Linux kernel])
92    ac_system="Linux"
93    ;;
94  *netbsd*)
95    AC_DEFINE([KERNEL_NETBSD], [1], [True if program is to be compiled for a NetBSD kernel])
96    ac_system="NetBSD"
97    ;;
98  *openbsd*)
99    AC_DEFINE([KERNEL_OPENBSD], [1], [True if program is to be compiled for an OpenBSD kernel])
100    ac_system="OpenBSD"
101    ;;
102  *solaris*)
103    AC_DEFINE([KERNEL_SOLARIS], [1], [True if program is to be compiled for a Solaris kernel])
104    ac_system="Solaris"
105    ;;
106  *mingw32*)
107    AC_DEFINE([KERNEL_WIN32], [1], [True if program is to be compiled for a Windows kernel])
108    ac_system="Windows"
109    ;;
110  *)
111    ac_system="unknown"
112    ;;
113esac
114AC_MSG_RESULT([$ac_system])
115
116AM_CONDITIONAL([BUILD_AIX], [test "x$ac_system" = "xAIX"])
117AM_CONDITIONAL([BUILD_DARWIN], [test "x$ac_system" = "xDarwin"])
118AM_CONDITIONAL([BUILD_FREEBSD], [test "x$ac_system" = "xFreeBSD"])
119AM_CONDITIONAL([BUILD_DRAGONFLY], [test "x$ac_system" = "xDragonFlyBSD"])
120AM_CONDITIONAL([BUILD_LINUX], [test "x$ac_system" = "xLinux"])
121AM_CONDITIONAL([BUILD_OPENBSD], [test "x$ac_system" = "xOpenBSD"])
122AM_CONDITIONAL([BUILD_NETBSD], [test "x$ac_system" = "xNetBSD"])
123AM_CONDITIONAL([BUILD_SOLARIS], [test "x$ac_system" = "xSolaris"])
124AM_CONDITIONAL([BUILD_WIN32], [test "x$ac_system" = "xWindows"])
125
126if test "x$ac_system" = "xSolaris"; then
127  AC_DEFINE([_POSIX_PTHREAD_SEMANTICS], [1], [Define to enforce POSIX thread semantics under Solaris.])
128  AC_DEFINE([_REENTRANT], [1], [Define to enable reentrancy interfaces.])
129
130  AC_MSG_CHECKING([whether compiler builds 64bit binaries])
131  AC_COMPILE_IFELSE(
132    [
133      AC_LANG_PROGRAM(
134        [
135          #ifndef _LP64
136          # error "Compiler not in 64bit mode."
137          #endif
138        ]
139      )
140    ],
141    [AC_MSG_RESULT([yes])],
142    [
143      AC_MSG_RESULT([no])
144      AC_MSG_NOTICE([Solaris detected. Please consider building a 64-bit binary.])
145    ]
146  )
147fi
148
149if test "x$ac_system" = "xAIX"; then
150  AC_DEFINE([_THREAD_SAFE_ERRNO], [1], [Define to use the thread-safe version of errno under AIX.])
151fi
152
153# Where to install .pc files.
154pkgconfigdir="${libdir}/pkgconfig"
155AC_SUBST([pkgconfigdir])
156
157#
158# Checks for header files.
159#
160AC_HEADER_SYS_WAIT
161AC_HEADER_DIRENT
162
163AC_CHECK_HEADERS_ONCE([ \
164  arpa/inet.h \
165  endian.h \
166  fcntl.h \
167  fnmatch.h \
168  fs_info.h \
169  fshelp.h \
170  grp.h \
171  kstat.h \
172  kvm.h \
173  libgen.h \
174  locale.h \
175  mntent.h \
176  mnttab.h \
177  netdb.h \
178  paths.h \
179  poll.h \
180  pthread_np.h \
181  pwd.h \
182  regex.h \
183  sys/endian.h \
184  sys/fs_types.h \
185  sys/fstyp.h \
186  sys/ioctl.h \
187  sys/isa_defs.h \
188  sys/mntent.h \
189  sys/mnttab.h \
190  sys/param.h \
191  sys/resource.h \
192  sys/select.h \
193  sys/socket.h \
194  sys/statfs.h \
195  sys/statvfs.h \
196  sys/types.h \
197  sys/un.h \
198  sys/vfs.h \
199  sys/vfstab.h \
200  sys/vmmeter.h \
201  syslog.h \
202  wordexp.h
203])
204
205if test "x$ac_system" = "xNetBSD"; then
206  # For entropy plugin on newer NetBSD
207  AC_CHECK_HEADERS([sys/rndio.h], [], [],
208    [[
209      #if HAVE_SYS_TYPES_H
210      # include <sys/types.h>
211      #endif
212      #if HAVE_SYS_IOCTL_H
213      # include <sys/ioctl.h>
214      #endif
215      #if HAVE_SYS_PARAM_H
216      # include <sys/param.h>
217      #endif
218    ]]
219  )
220fi
221
222# For ping library
223AC_CHECK_HEADERS([netinet/in_systm.h], [], [],
224  [[
225    #include <stdint.h>
226    #if HAVE_SYS_TYPES_H
227    # include <sys/types.h>
228    #endif
229  ]]
230)
231
232AC_CHECK_HEADERS([netinet/in.h], [], [],
233  [[
234    #include <stdint.h>
235    #if HAVE_SYS_TYPES_H
236    # include <sys/types.h>
237    #endif
238    #if HAVE_NETINET_IN_SYSTM_H
239    # include <netinet/in_systm.h>
240    #endif
241  ]]
242)
243
244AC_CHECK_HEADERS([netinet/ip.h], [], [],
245  [[
246    #include <stdint.h>
247    #if HAVE_SYS_TYPES_H
248    # include <sys/types.h>
249    #endif
250    #if HAVE_NETINET_IN_SYSTM_H
251    # include <netinet/in_systm.h>
252    #endif
253    #if HAVE_NETINET_IN_H
254    # include <netinet/in.h>
255    #endif
256  ]]
257)
258
259AC_CHECK_HEADERS([netinet/ip_icmp.h], [], [],
260  [[
261    #include <stdint.h>
262    #if HAVE_SYS_TYPES_H
263    # include <sys/types.h>
264    #endif
265    #if HAVE_NETINET_IN_SYSTM_H
266    # include <netinet/in_systm.h>
267    #endif
268    #if HAVE_NETINET_IN_H
269    # include <netinet/in.h>
270    #endif
271    #if HAVE_NETINET_IP_H
272    # include <netinet/ip.h>
273    #endif
274  ]]
275)
276
277AC_CHECK_HEADERS([netinet/ip_var.h], [], [],
278  [[
279    #include <stdint.h>
280    #if HAVE_SYS_TYPES_H
281    # include <sys/types.h>
282    #endif
283    #if HAVE_NETINET_IN_SYSTM_H
284    # include <netinet/in_systm.h>
285    #endif
286    #if HAVE_NETINET_IN_H
287    # include <netinet/in.h>
288    #endif
289    #if HAVE_NETINET_IP_H
290    # include <netinet/ip.h>
291    #endif
292  ]]
293)
294
295AC_CHECK_HEADERS([netinet/ip6.h], [], [],
296  [[
297    #include <stdint.h>
298    #if HAVE_SYS_TYPES_H
299    # include <sys/types.h>
300    #endif
301    #if HAVE_NETINET_IN_SYSTM_H
302    # include <netinet/in_systm.h>
303    #endif
304    #if HAVE_NETINET_IN_H
305    # include <netinet/in.h>
306    #endif
307  ]]
308)
309
310AC_CHECK_HEADERS([netinet/icmp6.h], [], [],
311  [[
312    #include <stdint.h>
313    #if HAVE_SYS_TYPES_H
314    # include <sys/types.h>
315    #endif
316    #if HAVE_NETINET_IN_SYSTM_H
317    # include <netinet/in_systm.h>
318    #endif
319    #if HAVE_NETINET_IN_H
320    # include <netinet/in.h>
321    #endif
322    #if HAVE_NETINET_IP6_H
323    # include <netinet/ip6.h>
324    #endif
325  ]]
326)
327
328AC_CHECK_HEADERS([netinet/tcp.h], [], [],
329  [[
330    #include <stdint.h>
331    #if HAVE_SYS_TYPES_H
332    # include <sys/types.h>
333    #endif
334    #if HAVE_NETINET_IN_SYSTM_H
335    # include <netinet/in_systm.h>
336    #endif
337    #if HAVE_NETINET_IN_H
338    # include <netinet/in.h>
339    #endif
340    #if HAVE_NETINET_IP_H
341    # include <netinet/ip.h>
342    #endif
343  ]]
344)
345
346AC_CHECK_HEADERS([netinet/udp.h], [], [],
347  [[
348    #include <stdint.h>
349    #if HAVE_SYS_TYPES_H
350    # include <sys/types.h>
351    #endif
352    #if HAVE_NETINET_IN_SYSTM_H
353    # include <netinet/in_systm.h>
354    #endif
355    #if HAVE_NETINET_IN_H
356    # include <netinet/in.h>
357    #endif
358    #if HAVE_NETINET_IP_H
359    # include <netinet/ip.h>
360    #endif
361  ]]
362)
363
364# For cpu modules
365AC_CHECK_HEADERS([sys/dkstat.h])
366if test "x$ac_system" = "xDarwin"; then
367  AC_CHECK_HEADERS(
368    [ \
369      mach/mach_init.h \
370      mach/host_priv.h \
371      mach/mach_error.h \
372      mach/mach_host.h \
373      mach/mach_port.h \
374      mach/mach_types.h \
375      mach/message.h \
376      mach/processor_set.h \
377      mach/processor.h \
378      mach/processor_info.h \
379      mach/task.h \
380      mach/thread_act.h \
381      mach/vm_region.h \
382      mach/vm_map.h \
383      mach/vm_prot.h \
384      mach/vm_statistics.h \
385      mach/kern_return.h \
386      CoreFoundation/CoreFoundation.h \
387      IOKit/IOKitLib.h \
388      IOKit/IOTypes.h \
389      IOKit/ps/IOPSKeys.h \
390      IOKit/IOBSD.h \
391      IOKit/storage/IOBlockStorageDriver.h
392    ]
393  )
394
395  # For the battery plugin
396  AC_CHECK_HEADERS([IOKit/ps/IOPowerSources.h], [], [],
397    [[
398      #if HAVE_IOKIT_IOKITLIB_H
399      #  include <IOKit/IOKitLib.h>
400      #endif
401      #if HAVE_IOKIT_IOTYPES_H
402      #  include <IOKit/IOTypes.h>
403      #endif
404    ]]
405  )
406fi
407
408AC_CHECK_HEADERS([sys/sysctl.h], [], [],
409  [[
410    #if HAVE_SYS_TYPES_H
411    #  include <sys/types.h>
412    #endif
413    #if HAVE_SYS_PARAM_H
414    # include <sys/param.h>
415    #endif
416  ]]
417)
418
419# For interface plugin
420AC_CHECK_HEADERS([ifaddrs.h])
421AC_CHECK_HEADERS([net/if.h], [], [],
422  [[
423    #if HAVE_SYS_TYPES_H
424    #  include <sys/types.h>
425    #endif
426    #if HAVE_SYS_SOCKET_H
427    #  include <sys/socket.h>
428    #endif
429  ]]
430)
431
432if test "x$ac_system" = "xLinux"; then
433  # For hddtemp module
434  AC_CHECK_HEADERS([linux/major.h])
435
436  # For md module (Linux only)
437  AC_CHECK_HEADERS([linux/raid/md_u.h],
438    [have_linux_raid_md_u_h="yes"],
439    [have_linux_raid_md_u_h="no"],
440    [[
441      #include <sys/ioctl.h>
442      #include <linux/major.h>
443      #include <linux/types.h>
444    ]]
445  )
446  AC_CHECK_HEADERS([sys/sysmacros.h])
447
448  AC_CHECK_HEADERS([linux/wireless.h],
449    [have_linux_wireless_h="yes"],
450    [have_linux_wireless_h="no"],
451    [[
452      #include <dirent.h>
453      #include <sys/ioctl.h>
454      #include <sys/socket.h>
455    ]]
456  )
457
458  AC_CHECK_HEADERS([linux/if.h], [], [],
459    [[
460      #if HAVE_SYS_TYPES_H
461      #  include <sys/types.h>
462      #endif
463      #if HAVE_SYS_SOCKET_H
464      #  include <sys/socket.h>
465      #endif
466    ]]
467  )
468
469  AC_CHECK_HEADERS([linux/inet_diag.h], [], [],
470    [[
471      #if HAVE_SYS_TYPES_H
472      #  include <sys/types.h>
473      #endif
474      #if HAVE_SYS_SOCKET_H
475      #  include <sys/socket.h>
476      #endif
477    ]]
478  )
479
480  AC_CHECK_HEADERS([linux/netdevice.h], [], [],
481    [[
482      #if HAVE_SYS_TYPES_H
483      #  include <sys/types.h>
484      #endif
485      #if HAVE_SYS_SOCKET_H
486      #  include <sys/socket.h>
487      #endif
488      #if HAVE_LINUX_IF_H
489      # include <linux/if.h>
490      #endif
491    ]]
492  )
493
494  # For ethstat module
495  AC_CHECK_HEADERS([linux/sockios.h],
496    [have_linux_sockios_h="yes"],
497    [have_linux_sockios_h="no"],
498    [[
499      #if HAVE_SYS_IOCTL_H
500      # include <sys/ioctl.h>
501      #endif
502      #if HAVE_NET_IF_H
503      # include <net/if.h>
504      #endif
505    ]]
506  )
507
508  AC_CHECK_HEADERS([linux/ethtool.h],
509    [have_linux_ethtool_h="yes"],
510    [have_linux_ethtool_h="no"],
511    [[
512      #if HAVE_SYS_IOCTL_H
513      # include <sys/ioctl.h>
514      #endif
515      #if HAVE_NET_IF_H
516      # include <net/if.h>
517      #endif
518      #if HAVE_LINUX_SOCKIOS_H
519      # include <linux/sockios.h>
520      #endif
521    ]]
522  )
523
524  # For ipvs module
525  AC_CHECK_HEADERS_ONCE([linux/ip_vs.h])
526
527  # For the email plugin
528  AC_CHECK_HEADERS([linux/un.h], [], [],
529    [[
530      #if HAVE_SYS_SOCKET_H
531      #  include <sys/socket.h>
532      #endif
533    ]]
534  )
535  # For the turbostat plugin
536  AC_CHECK_HEADERS([cpuid.h],
537    [have_cpuid_h="yes"],
538    [have_cpuid_h="no (cpuid.h not found)"]
539  )
540
541  AC_CHECK_HEADERS([sys/capability.h],
542    [have_capability="yes"],
543    [have_capability="no (<sys/capability.h> not found)"]
544  )
545
546  if test "x$have_capability" = "xyes"; then
547    AC_CHECK_LIB([cap], [cap_get_proc],
548      [have_capability="yes"],
549      [have_capability="no (cap_get_proc() not found)"]
550    )
551  fi
552
553  if test "x$have_capability" = "xyes"; then
554    AC_CHECK_DECL([CAP_IS_SUPPORTED],
555      [have_capability="yes"],
556      [have_capability="no (CAP_IS_SUPPORTED not found)"],
557      [[#include <sys/capability.h>]]
558    )
559  fi
560
561  if test "x$have_capability" = "xyes"; then
562    AC_DEFINE([HAVE_CAPABILITY], [1], [Define to 1 if you have cap_get_proc() (-lcap).])
563  fi
564
565  # For pcie_errors plugin
566  AC_CHECK_HEADERS([linux/pci_regs.h],
567    [have_pci_regs_h="yes"],
568    [have_pci_regs_h="no (linux/pci_regs.h not found)"]
569  )
570
571else
572  have_linux_raid_md_u_h="no"
573  have_linux_wireless_h="no"
574fi
575
576AM_CONDITIONAL([BUILD_WITH_CAPABILITY], [test "x$have_capability" = "xyes"])
577
578# For the swap module
579have_sys_swap_h="yes"
580AC_CHECK_HEADERS([sys/swap.h vm/anon.h],
581  [],
582  [have_sys_swap_h="no"],
583  [[
584    #undef _FILE_OFFSET_BITS
585    #undef _LARGEFILE64_SOURCE
586    #if HAVE_SYS_TYPES_H
587    #  include <sys/types.h>
588    #endif
589    #if HAVE_SYS_PARAM_H
590    # include <sys/param.h>
591    #endif
592  ]]
593)
594
595# For load module
596# For the processes plugin
597# For users module
598AC_CHECK_HEADERS([sys/loadavg.h linux/config.h utmp.h utmpx.h])
599
600# For quota module
601AC_CHECK_HEADERS([sys/ucred.h], [], [],
602  [[
603    #if HAVE_SYS_TYPES_H
604    #  include <sys/types.h>
605    #endif
606    #if HAVE_SYS_PARAM_H
607    # include <sys/param.h>
608    #endif
609  ]]
610)
611
612# For mount interface
613AC_CHECK_HEADERS([sys/mount.h], [], [],
614  [[
615    #if HAVE_SYS_TYPES_H
616    #  include <sys/types.h>
617    #endif
618    #if HAVE_SYS_PARAM_H
619    # include <sys/param.h>
620    #endif
621  ]]
622)
623
624# --enable-xfs {{{
625AC_ARG_ENABLE([xfs],
626  [AS_HELP_STRING([--enable-xfs], [xfs support in df plugin @<:@default=yes@:>@])],
627  [],
628  [enable_xfs="auto"]
629)
630
631if test "x$enable_xfs" != "xno"; then
632  AC_CHECK_HEADERS([xfs/xqm.h],
633    [],
634    [
635      if test "x$enable_xfs" = "xyes"; then
636        AC_MSG_ERROR([xfs/xqm.h not found])
637      fi
638    ],
639    [[#define _GNU_SOURCE]]
640  )
641fi
642
643# }}}
644
645AC_CHECK_HEADERS([net/if_arp.h], [], [],
646  [[
647    #if HAVE_SYS_SOCKET_H
648    # include <sys/socket.h>
649    #endif
650  ]]
651)
652
653AC_CHECK_HEADERS([net/ppp_defs.h])
654AC_CHECK_HEADERS([net/if_ppp.h], [], [],
655  [[
656    #if HAVE_NET_PPP_DEFS_H
657    # include <net/ppp_defs.h>
658    #endif
659  ]]
660)
661
662AC_CHECK_HEADERS([netinet/if_ether.h], [], [],
663  [[
664    #include <stdint.h>
665    #if HAVE_SYS_TYPES_H
666    # include <sys/types.h>
667    #endif
668    #if HAVE_SYS_SOCKET_H
669    # include <sys/socket.h>
670    #endif
671    #if HAVE_NET_IF_H
672    # include <net/if.h>
673    #endif
674    #if HAVE_NETINET_IN_H
675    # include <netinet/in.h>
676    #endif
677  ]]
678)
679
680AC_CHECK_HEADERS([net/pfvar.h net/pf/pfvar.h],
681  [have_net_pfvar_h="yes"],
682  [have_net_pfvar_h="no"],
683  [[
684    #if HAVE_SYS_IOCTL_H
685    # include <sys/ioctl.h>
686    #endif
687    #if HAVE_SYS_SOCKET_H
688    # include <sys/socket.h>
689    #endif
690    #if HAVE_NET_IF_H
691    # include <net/if.h>
692    #endif
693    #if HAVE_NETINET_IN_H
694    # include <netinet/in.h>
695    #endif
696  ]]
697)
698
699# For the multimeter plugin
700AC_CHECK_HEADERS([termios.h],
701  [have_termios_h="yes"],
702  [have_termios_h="no"]
703)
704
705# For cpusleep plugin
706AC_CACHE_CHECK([whether clock_boottime and clock_monotonic are supported],
707  [c_cv_have_clock_boottime_monotonic],
708  [
709    AC_COMPILE_IFELSE(
710      [AC_LANG_PROGRAM(
711        [[#include <time.h>]],
712        [[
713          struct timespec b, m;
714          clock_gettime(CLOCK_BOOTTIME, &b );
715          clock_gettime(CLOCK_MONOTONIC, &m );
716        ]]
717      )
718      ],
719      [c_cv_have_clock_boottime_monotonic="yes"],
720      [c_cv_have_clock_boottime_monotonic="no"]
721    )
722  ]
723)
724
725
726#
727# Checks for typedefs, structures, and compiler characteristics.
728#
729AC_C_CONST
730AC_TYPE_PID_T
731AC_TYPE_SIZE_T
732AC_TYPE_UID_T
733AC_HEADER_TIME
734
735test_cxx_flags() {
736  AC_LANG_PUSH([C++])
737  AC_LANG_CONFTEST(
738    [AC_LANG_SOURCE([[int main(void){}]]) ]
739  )
740  $CXX -c conftest.cpp $CXXFLAGS $@ > /dev/null 2> /dev/null
741  ret=$?
742  rm -f conftest.o
743  AC_LANG_POP([C++])
744  return $ret
745}
746
747#
748# Checks for library functions.
749#
750AC_CHECK_FUNCS_ONCE([ \
751    asprintf \
752    execvpe \
753    getpwnam \
754    getpwnam_r \
755    if_indextoname \
756    setgroups \
757    setlocale
758  ]
759)
760
761AC_FUNC_STRERROR_R
762
763if test "x$GCC" = "xyes"; then
764  SAVE_CFLAGS="$CFLAGS"
765  CFLAGS="$CFLAGS -Wall "
766fi
767SAVE_LDFLAGS="$LDFLAGS"
768LDFLAGS=""
769if test "x$ac_system" = "xWindows"; then
770  # This is exported from build.sh
771  LDFLAGS="$LDFLAGS -L${GNULIB_DIR}"
772fi
773
774AC_CACHE_CHECK([for strtok_r],
775  [c_cv_have_strtok_r_default],
776  [
777    AC_LINK_IFELSE(
778      [
779        AC_LANG_PROGRAM(
780          [[
781            #include <stdlib.h>
782            #include <stdio.h>
783            #include <string.h>
784          ]],
785          [[
786            char buffer[] = "foo,bar,baz";
787            char *token;
788            char *dummy;
789            char *saveptr;
790
791            dummy = buffer;
792            saveptr = NULL;
793            while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
794            {
795              dummy = NULL;
796              printf ("token = %s;\n", token);
797            }
798          ]]
799        )
800      ],
801      [c_cv_have_strtok_r_default="yes"],
802      [c_cv_have_strtok_r_default="no"]
803    )
804  ]
805)
806
807if test "x$c_cv_have_strtok_r_default" = "xno"; then
808  CFLAGS="$CFLAGS -D_REENTRANT=1"
809
810  AC_CACHE_CHECK([if strtok_r needs _REENTRANT],
811    [c_cv_have_strtok_r_reentrant],
812    [
813      AC_LINK_IFELSE(
814        [
815          AC_LANG_PROGRAM(
816            [[
817              #include <stdlib.h>
818              #include <stdio.h>
819              #include <string.h>
820            ]],
821            [[
822              char buffer[] = "foo,bar,baz";
823              char *token;
824              char *dummy;
825              char *saveptr;
826
827              dummy = buffer;
828              saveptr = NULL;
829              while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
830              {
831                dummy = NULL;
832                printf ("token = %s;\n", token);
833              }
834            ]]
835          )
836        ],
837        [c_cv_have_strtok_r_reentrant="yes"],
838        [AC_MSG_FAILURE([strtok_r is not available. Please file a bugreport!])]
839      )
840    ]
841  )
842fi
843
844CFLAGS="$SAVE_CFLAGS"
845LDFLAGS="$SAVE_LDFLAGS"
846if test "x$c_cv_have_strtok_r_reentrant" = "xyes"; then
847  CFLAGS="$CFLAGS -D_REENTRANT=1"
848fi
849
850AC_CHECK_FUNCS([socket],
851  [],
852  [
853    AC_CHECK_LIB([socket], [socket],
854      [socket_needs_socket="yes"],
855      [
856        AC_CHECK_LIB([gnu], [rpl_socket],
857          [socket_needs_gnulib="yes"],
858          [AC_MSG_ERROR([cannot find socket() in libsocket])]
859        )
860      ]
861    )
862  ]
863)
864AM_CONDITIONAL([BUILD_WITH_LIBSOCKET], [test "x$socket_needs_socket" = "xyes"])
865AM_CONDITIONAL([BUILD_WITH_GNULIB], [test "x$socket_needs_gnulib" = "xyes"])
866
867AC_CHECK_FUNCS([inet_ntop],
868  [],
869  [
870    AC_CHECK_LIB([nsl], [inet_ntop],
871      [inet_ntop_needs_nsl="yes"],
872      [AC_MSG_ERROR([cannot find inet_ntop() in libnsl])]
873    )
874  ]
875)
876AM_CONDITIONAL([BUILD_WITH_LIBNSL], [test "x$inet_ntop_needs_nsl" = "xyes"])
877
878clock_gettime_needs_posix4="no"
879AC_CHECK_FUNCS([clock_gettime],
880  [have_clock_gettime="yes"],
881  [have_clock_gettime="no"]
882)
883
884if test "x$have_clock_gettime" = "xno"; then
885  AC_CHECK_LIB([rt], [clock_gettime],
886    [
887      clock_gettime_needs_rt="yes"
888      have_clock_gettime="yes"
889    ]
890  )
891fi
892
893if test "x$have_clock_gettime" = "xno"; then
894  AC_CHECK_LIB([posix4], [clock_gettime],
895    [
896      clock_gettime_needs_posix4="yes"
897      have_clock_gettime="yes"
898    ]
899  )
900fi
901
902if test "x$have_clock_gettime" = "xyes"; then
903  AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Define if the clock_gettime(2) function is available.])
904fi
905
906AC_CHECK_FUNCS([nanosleep], [],
907  AC_CHECK_LIB([rt], [nanosleep],
908    [nanosleep_needs_rt="yes"],
909    [
910      AC_CHECK_LIB([posix4], [nanosleep],
911        [nanosleep_needs_posix4="yes"],
912        [AC_MSG_ERROR([cannot find nanosleep])]
913      )
914    ]
915  )
916)
917
918AM_CONDITIONAL([BUILD_WITH_LIBRT], [test "x$clock_gettime_needs_rt" = "xyes" || test "x$nanosleep_needs_rt" = "xyes"])
919AM_CONDITIONAL([BUILD_WITH_LIBPOSIX4], [test "x$clock_gettime_needs_posix4" = "xyes" || test "x$nanosleep_needs_posix4" = "xyes"])
920
921AC_CHECK_FUNCS([getifaddrs], [have_getifaddrs="yes"], [have_getifaddrs="no"])
922AC_CHECK_FUNCS([getloadavg], [have_getloadavg="yes"], [have_getloadavg="no"])
923AC_CHECK_FUNCS([getutent], [have_getutent="yes"], [have_getutent="no"])
924AC_CHECK_FUNCS([getutxent], [have_getutxent="yes"], [have_getutxent="no"])
925AC_CHECK_FUNCS([host_statistics], [have_host_statistics="yes"], [have_host_statistics="no"])
926AC_CHECK_FUNCS([processor_info], [have_processor_info="yes"], [have_processor_info="no"])
927AC_CHECK_FUNCS([statfs], [have_statfs="yes"], [have_statfs="no"])
928AC_CHECK_FUNCS([statvfs], [have_statvfs="yes"], [have_statvfs="no"])
929AC_CHECK_FUNCS([sysctl], [have_sysctl="yes"], [have_sysctl="no"])
930AC_CHECK_FUNCS([sysctlbyname], [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
931AC_CHECK_FUNCS([syslog], [have_syslog="yes"], [have_syslog="no"])
932AC_CHECK_FUNCS([thread_info], [have_thread_info="yes"], [have_thread_info="no"])
933
934# Check for strptime {{{
935if test "x$GCC" = "xyes"; then
936  SAVE_CFLAGS="$CFLAGS"
937  CFLAGS="$CFLAGS -Wall -Wextra "
938fi
939
940AC_CHECK_FUNCS([strptime], [have_strptime="yes"], [have_strptime="no"])
941if test "x$have_strptime" = "xyes"; then
942  AC_CACHE_CHECK([whether strptime is exported by default],
943    [c_cv_have_strptime_default],
944    [
945      AC_COMPILE_IFELSE(
946        [
947          AC_LANG_PROGRAM(
948            [[#include <time.h>]],
949            [[
950              struct tm stm;
951              (void)strptime ("2010-12-30%13:42:42", "%Y-%m-%dT%T", &stm);
952            ]]
953          )
954        ],
955        [c_cv_have_strptime_default="yes"],
956        [c_cv_have_strptime_default="no"])
957    ]
958  )
959fi
960
961if test "x$have_strptime" = "xyes" && test "x$c_cv_have_strptime_default" = "xno"; then
962  AC_CACHE_CHECK([whether strptime needs standards mode],
963    [c_cv_have_strptime_standards],
964    [
965      AC_COMPILE_IFELSE(
966        [
967          AC_LANG_PROGRAM(
968            [[
969              #ifndef _ISOC99_SOURCE
970              # define _ISOC99_SOURCE 1
971              #endif
972              #ifndef _POSIX_C_SOURCE
973              # define _POSIX_C_SOURCE 200112L
974              #endif
975              #ifndef _XOPEN_SOURCE
976              # define _XOPEN_SOURCE 500
977              #endif
978              #include <time.h>
979            ]],
980            [[
981              struct tm stm;
982              (void)strptime ("2010-12-30%13:42:42", "%Y-%m-%dT%T", &stm);
983            ]]
984          )
985        ],
986        [c_cv_have_strptime_standards="yes"],
987        [c_cv_have_strptime_standards="no"]
988      )
989    ]
990  )
991
992  if test "x$c_cv_have_strptime_standards" = "xyes"; then
993    AC_DEFINE([STRPTIME_NEEDS_STANDARDS], [1],
994      [Set to true if strptime is only exported in X/Open mode (GNU libc).]
995    )
996  else
997    have_strptime="no"
998  fi
999fi
1000
1001if test "x$GCC" = "xyes"; then
1002  CFLAGS="$SAVE_CFLAGS"
1003fi
1004# }}} Check for strptime
1005
1006# Check for timegm {{{
1007
1008# These checks need  because implicit function declarations are only a
1009# warning ...
1010SAVE_CFLAGS="$CFLAGS"
1011CFLAGS="$CFLAGS "
1012
1013AC_CACHE_CHECK([for timegm],
1014  [c_cv_have_timegm],
1015  AC_LINK_IFELSE(
1016    [AC_LANG_PROGRAM(
1017[[[
1018#if STRPTIME_NEEDS_STANDARDS
1019# ifndef _ISOC99_SOURCE
1020#  define _ISOC99_SOURCE 1
1021# endif
1022# ifndef _POSIX_C_SOURCE
1023#  define _POSIX_C_SOURCE 200112L
1024# endif
1025# ifndef _XOPEN_SOURCE
1026#  define _XOPEN_SOURCE 500
1027# endif
1028#endif
1029#include <time.h>
1030]]],
1031[[[
1032 time_t t = timegm(&(struct tm){0});
1033 if (t == ((time_t) -1)) {
1034   return 1;
1035 }
1036]]]
1037    )],
1038    [c_cv_have_timegm="yes"],
1039    [c_cv_have_timegm="no"]
1040  )
1041)
1042
1043if test "x$c_cv_have_timegm" != "xyes"
1044then
1045  AC_CACHE_CHECK([for timegm with _BSD_SOURCE],
1046    [c_cv_have_timegm_bsd],
1047    AC_LINK_IFELSE(
1048      [AC_LANG_PROGRAM(
1049[[[
1050#if STRPTIME_NEEDS_STANDARDS
1051# ifndef _ISOC99_SOURCE
1052#  define _ISOC99_SOURCE 1
1053# endif
1054# ifndef _POSIX_C_SOURCE
1055#  define _POSIX_C_SOURCE 200112L
1056# endif
1057# ifndef _XOPEN_SOURCE
1058#  define _XOPEN_SOURCE 500
1059# endif
1060#endif
1061#ifndef _BSD_SOURCE
1062# define _BSD_SOURCE 1
1063#endif
1064#include <time.h>
1065]]],
1066[[[
1067 time_t t = timegm(&(struct tm){0});
1068 if (t == ((time_t) -1)) {
1069   return 1;
1070 }
1071]]]
1072      )],
1073      [c_cv_have_timegm_bsd="yes"
1074       c_cv_have_timegm="yes"],
1075      [c_cv_have_timegm_bsd="no"]
1076    )
1077  )
1078fi
1079
1080if test "x$c_cv_have_timegm" = "xyes"
1081then
1082  AC_DEFINE(HAVE_TIMEGM, 1, [Define if the timegm(3) function is available.])
1083  if test "x$c_cv_have_timegm_bsd" = "xyes"
1084  then
1085    AC_DEFINE(TIMEGM_NEEDS_BSD, 1, [Set to true if timegm is only exported in BSD mode.])
1086  fi
1087fi
1088
1089CFLAGS="$SAVE_CFLAGS"
1090# }}} Check for timegm
1091
1092AC_MSG_CHECKING([for sysctl kern.cp_times])
1093if test -x /sbin/sysctl; then
1094  /sbin/sysctl kern.cp_times >/dev/null 2>&1
1095  if test $? -eq 0; then
1096    AC_MSG_RESULT([yes])
1097    AC_DEFINE([HAVE_SYSCTL_KERN_CP_TIMES], [1], [Define if sysctl supports kern.cp_times])
1098  else
1099    AC_MSG_RESULT([no])
1100  fi
1101else
1102  AC_MSG_RESULT([no])
1103fi
1104
1105AC_MSG_CHECKING([for sysctl kern.cp_time])
1106if test -x /sbin/sysctl; then
1107  /sbin/sysctl kern.cp_time >/dev/null 2>&1
1108  if test $? -eq 0
1109  then
1110    AC_MSG_RESULT([yes])
1111    AC_DEFINE([HAVE_SYSCTL_KERN_CP_TIME], [1], [Define if sysctl supports kern.cp_time])
1112  else
1113    AC_MSG_RESULT([no])
1114  fi
1115else
1116  AC_MSG_RESULT([no])
1117fi
1118
1119AC_CHECK_FUNCS([swapctl], [have_swapctl="yes"], [have_swapctl="no"])
1120if test "x$have_swapctl" = "xyes"; then
1121  AC_CACHE_CHECK([whether swapctl takes two arguments],
1122    [c_cv_have_swapctl_two_args],
1123    [
1124      AC_COMPILE_IFELSE(
1125        [
1126          AC_LANG_PROGRAM(
1127            [[
1128              #if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64
1129              #  undef _FILE_OFFSET_BITS
1130              #  undef _LARGEFILE64_SOURCE
1131              #endif
1132              #include <sys/stat.h>
1133              #include <sys/param.h>
1134              #include <sys/swap.h>
1135              #include <unistd.h>
1136            ]],
1137            [[int num = swapctl(0, NULL);]]
1138          )
1139        ],
1140        [c_cv_have_swapctl_two_args="yes"],
1141        [c_cv_have_swapctl_two_args="no"]
1142      )
1143    ]
1144  )
1145
1146  AC_CACHE_CHECK([whether swapctl takes three arguments],
1147    [c_cv_have_swapctl_three_args],
1148    [
1149      AC_COMPILE_IFELSE(
1150        [
1151          AC_LANG_PROGRAM(
1152            [[
1153              #if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64
1154              #  undef _FILE_OFFSET_BITS
1155              #  undef _LARGEFILE64_SOURCE
1156              #endif
1157              #include <sys/stat.h>
1158              #include <sys/param.h>
1159              #include <sys/swap.h>
1160              #include <unistd.h>
1161            ]],
1162            [[int num = swapctl(0, NULL, 0);]]
1163          )
1164        ],
1165        [c_cv_have_swapctl_three_args="yes"],
1166        [c_cv_have_swapctl_three_args="no"]
1167      )
1168    ]
1169  )
1170fi
1171
1172# Check for different versions of `swapctl' here..
1173if test "x$have_swapctl" = "xyes"; then
1174  if test "x$c_cv_have_swapctl_two_args" = "xyes"; then
1175    AC_DEFINE([HAVE_SWAPCTL_TWO_ARGS], [1], [Define if the function swapctl exists and takes two arguments.])
1176  fi
1177
1178  if test "x$c_cv_have_swapctl_three_args" = "xyes"; then
1179    AC_DEFINE([HAVE_SWAPCTL_THREE_ARGS], [1], [Define if the function swapctl exists and takes three arguments.])
1180  fi
1181fi
1182
1183# Check for NAN
1184AC_ARG_WITH([nan-emulation],
1185  [AS_HELP_STRING([--with-nan-emulation], [use emulated NAN. For crosscompiling only.])],
1186  [
1187    if test "x$withval" = "xno"; then
1188      nan_type="none"
1189    else if test "x$withval" = "xyes"; then
1190      nan_type="zero"
1191    else
1192      nan_type="$withval"
1193    fi; fi
1194  ],
1195  [nan_type="none"]
1196)
1197
1198if test "x$nan_type" = "xnone"; then
1199  AC_CACHE_CHECK([whether NAN is defined by default],
1200    [c_cv_have_nan_default],
1201    [
1202      AC_COMPILE_IFELSE(
1203        [
1204          AC_LANG_PROGRAM(
1205            [[
1206              #include <stdlib.h>
1207              #include <math.h>
1208              static double foo = NAN;
1209            ]],
1210            [[
1211              if (isnan (foo))
1212                return 0;
1213              return 1;
1214            ]]
1215          )
1216        ],
1217        [c_cv_have_nan_default="yes"],
1218        [c_cv_have_nan_default="no"]
1219      )
1220    ]
1221  )
1222fi
1223
1224if test "x$c_cv_have_nan_default" = "xyes"; then
1225  nan_type="default"
1226fi
1227
1228if test "x$nan_type" = "xnone"; then
1229  AC_CACHE_CHECK([whether NAN is defined by __USE_ISOC99],
1230    [c_cv_have_nan_isoc],
1231    [
1232      AC_COMPILE_IFELSE(
1233        [
1234          AC_LANG_PROGRAM(
1235            [[
1236              #include <stdlib.h>
1237              #define __USE_ISOC99 1
1238              #include <math.h>
1239              static double foo = NAN;
1240            ]],
1241            [[
1242              if (isnan (foo))
1243                return 0;
1244              return 1;
1245            ]]
1246          )
1247        ],
1248        [c_cv_have_nan_isoc="yes"],
1249        [c_cv_have_nan_isoc="no"]
1250      )
1251    ]
1252  )
1253fi
1254
1255if test "x$c_cv_have_nan_isoc" = "xyes"; then
1256  nan_type="isoc99"
1257fi
1258
1259if test "x$nan_type" = "xnone"; then
1260  SAVE_LDFLAGS="$LDFLAGS"
1261  LDFLAGS="$LDFLAGS -lm"
1262  AC_CACHE_CHECK([whether NAN can be defined by 0/0],
1263    [c_cv_have_nan_zero],
1264    [
1265      AC_RUN_IFELSE(
1266        [
1267          AC_LANG_PROGRAM(
1268            [[
1269              #include <stdlib.h>
1270              #include <math.h>
1271              #ifdef NAN
1272              # undef NAN
1273              #endif
1274              #define NAN (0.0 / 0.0)
1275              #ifndef isnan
1276              # define isnan(f) ((f) != (f))
1277              #endif
1278              static double foo = NAN;
1279            ]],
1280            [[
1281              if (isnan (foo))
1282                return 0;
1283              return 1;
1284            ]]
1285          )
1286        ],
1287        [c_cv_have_nan_zero="yes"],
1288        [c_cv_have_nan_zero="no"]
1289      )
1290    ]
1291  )
1292  LDFLAGS=$SAVE_LDFLAGS
1293fi
1294
1295if test "x$c_cv_have_nan_zero" = "xyes"; then
1296  nan_type="zero"
1297fi
1298
1299if test "x$nan_type" = "xdefault"; then
1300  AC_DEFINE([NAN_STATIC_DEFAULT], [1],
1301    [Define if NAN is defined by default and can initialize static variables.]
1302  )
1303else if test "x$nan_type" = "xisoc99"; then
1304  AC_DEFINE([NAN_STATIC_ISOC], [1],
1305    [Define if NAN is defined by __USE_ISOC99 and can initialize static variables.]
1306  )
1307else if test "x$nan_type" = "xzero"; then
1308  AC_DEFINE([NAN_ZERO_ZERO], [1],
1309    [Define if NAN can be defined as (0.0 / 0.0)]
1310  )
1311else
1312  AC_MSG_ERROR([Didn't find out how to statically initialize variables to NAN. Sorry.])
1313fi; fi; fi
1314
1315AC_ARG_WITH([fp-layout],
1316  [
1317    AS_HELP_STRING([--with-fp-layout],
1318      [set the memory layout of doubles. For crosscompiling only.]
1319    )
1320  ],
1321  [
1322    if test "x$withval" = "xnothing"; then
1323      fp_layout_type="nothing"
1324    else if test "x$withval" = "xendianflip"; then
1325      fp_layout_type="endianflip"
1326    else if test "x$withval" = "xintswap"; then
1327      fp_layout_type="intswap"
1328    else
1329      AC_MSG_ERROR([Invalid argument for --with-fp-layout. Valid arguments are: nothing, endianflip, intswap]);
1330    fi; fi; fi
1331  ],
1332  [fp_layout_type="unknown"]
1333)
1334
1335if test "x$fp_layout_type" = "xunknown"; then
1336  AC_CACHE_CHECK([if doubles are stored in x86 representation],
1337    [c_cv_fp_layout_need_nothing],
1338    [
1339      AC_RUN_IFELSE(
1340        [
1341          AC_LANG_PROGRAM(
1342            [[
1343              #include <stdlib.h>
1344              #include <stdio.h>
1345              #include <string.h>
1346              #include <stdint.h>
1347              #include <inttypes.h>
1348              #include <stdbool.h>
1349            ]],
1350            [[
1351              uint64_t i0;
1352              uint64_t i1;
1353              uint8_t c[8];
1354              double d;
1355
1356              d = 8.642135e130;
1357              memcpy ((void *) &i0, (void *) &d, 8);
1358
1359              i1 = i0;
1360              memcpy ((void *) c, (void *) &i1, 8);
1361
1362              if ((c[0] == 0x2f) && (c[1] == 0x25)
1363                  && (c[2] == 0xc0) && (c[3] == 0xc7)
1364                  && (c[4] == 0x43) && (c[5] == 0x2b)
1365                  && (c[6] == 0x1f) && (c[7] == 0x5b))
1366                return 0;
1367              return 1;
1368            ]]
1369          )
1370        ],
1371        [c_cv_fp_layout_need_nothing="yes"],
1372        [c_cv_fp_layout_need_nothing="no"]
1373      )
1374    ]
1375  )
1376fi
1377
1378if test "x$c_cv_fp_layout_need_nothing" = "xyes"; then
1379  fp_layout_type="nothing"
1380fi
1381
1382if test "x$fp_layout_type" = "xunknown"; then
1383  AC_CACHE_CHECK([if endianflip converts to x86 representation],
1384    [c_cv_fp_layout_need_endianflip],
1385    [
1386      AC_RUN_IFELSE(
1387        [
1388          AC_LANG_PROGRAM(
1389            [[
1390              #include <stdlib.h>
1391              #include <stdio.h>
1392              #include <string.h>
1393              #include <stdint.h>
1394              #include <inttypes.h>
1395              #include <stdbool.h>
1396              #define endianflip(A) ((((uint64_t)(A) & 0xff00000000000000LL) >> 56) | \
1397                                     (((uint64_t)(A) & 0x00ff000000000000LL) >> 40) | \
1398                                     (((uint64_t)(A) & 0x0000ff0000000000LL) >> 24) | \
1399                                     (((uint64_t)(A) & 0x000000ff00000000LL) >> 8)  | \
1400                                     (((uint64_t)(A) & 0x00000000ff000000LL) << 8)  | \
1401                                     (((uint64_t)(A) & 0x0000000000ff0000LL) << 24) | \
1402                                     (((uint64_t)(A) & 0x000000000000ff00LL) << 40) | \
1403                                     (((uint64_t)(A) & 0x00000000000000ffLL) << 56))
1404            ]],
1405            [[
1406              uint64_t i0;
1407              uint64_t i1;
1408              uint8_t c[8];
1409              double d;
1410
1411              d = 8.642135e130;
1412              memcpy ((void *) &i0, (void *) &d, 8);
1413
1414              i1 = endianflip (i0);
1415              memcpy ((void *) c, (void *) &i1, 8);
1416
1417              if ((c[0] == 0x2f) && (c[1] == 0x25)
1418                  && (c[2] == 0xc0) && (c[3] == 0xc7)
1419                  && (c[4] == 0x43) && (c[5] == 0x2b)
1420                  && (c[6] == 0x1f) && (c[7] == 0x5b))
1421                return 0;
1422              return 1;
1423            ]]
1424          )
1425        ],
1426        [c_cv_fp_layout_need_endianflip="yes"],
1427        [c_cv_fp_layout_need_endianflip="no"]
1428      ]
1429    )
1430  )
1431fi
1432
1433if test "x$c_cv_fp_layout_need_endianflip" = "xyes"; then
1434  fp_layout_type="endianflip"
1435fi
1436
1437if test "x$fp_layout_type" = "xunknown"; then
1438  AC_CACHE_CHECK([if intswap converts to x86 representation],
1439    [c_cv_fp_layout_need_intswap],
1440    [
1441      AC_RUN_IFELSE(
1442        [
1443          AC_LANG_PROGRAM(
1444            [[
1445              #include <stdlib.h>
1446              #include <stdio.h>
1447              #include <string.h>
1448              #include <stdint.h>
1449              #include <inttypes.h>
1450              #include <stdbool.h>
1451              #define intswap(A)    ((((uint64_t)(A) & 0xffffffff00000000LL) >> 32) | \
1452                                     (((uint64_t)(A) & 0x00000000ffffffffLL) << 32))
1453            ]],
1454            [[
1455              uint64_t i0;
1456              uint64_t i1;
1457              uint8_t c[8];
1458              double d;
1459
1460              d = 8.642135e130;
1461              memcpy ((void *) &i0, (void *) &d, 8);
1462
1463              i1 = intswap (i0);
1464              memcpy ((void *) c, (void *) &i1, 8);
1465
1466              if ((c[0] == 0x2f) && (c[1] == 0x25)
1467                  && (c[2] == 0xc0) && (c[3] == 0xc7)
1468                  && (c[4] == 0x43) && (c[5] == 0x2b)
1469                  && (c[6] == 0x1f) && (c[7] == 0x5b))
1470                return 0;
1471              return 1;
1472            ]]
1473          )
1474        ],
1475        [c_cv_fp_layout_need_intswap="yes"],
1476        [c_cv_fp_layout_need_intswap="no"]
1477      )
1478    ]
1479  )
1480fi
1481
1482if test "x$c_cv_fp_layout_need_intswap" = "xyes"; then
1483  fp_layout_type="intswap"
1484fi
1485
1486if test "x$fp_layout_type" = "xnothing"; then
1487  AC_DEFINE([FP_LAYOUT_NEED_NOTHING], [1],
1488    [Define if doubles are stored in x86 representation.]
1489  )
1490else if test "x$fp_layout_type" = "xendianflip"; then
1491  AC_DEFINE([FP_LAYOUT_NEED_ENDIANFLIP], [1],
1492    [Define if endianflip is needed to convert to x86 representation.]
1493  )
1494else if test "x$fp_layout_type" = "xintswap"; then
1495  AC_DEFINE([FP_LAYOUT_NEED_INTSWAP], [1],
1496    [Define if intswap is needed to convert to x86 representation.]
1497  )
1498else
1499  AC_MSG_ERROR([Didn't find out how doubles are stored in memory. Sorry.])
1500fi; fi; fi
1501
1502# For cpusleep plugin
1503AC_CACHE_CHECK([whether clock_boottime and clock_monotonic are supported],
1504  [c_cv_have_clock_boottime_monotonic],
1505  [
1506    AC_COMPILE_IFELSE(
1507      [AC_LANG_PROGRAM(
1508        [[#include <time.h>]],
1509        [[
1510          struct timespec b, m;
1511          clock_gettime(CLOCK_BOOTTIME, &b );
1512          clock_gettime(CLOCK_MONOTONIC, &m );
1513        ]]
1514      )
1515      ],
1516      [c_cv_have_clock_boottime_monotonic="yes"],
1517      [c_cv_have_clock_boottime_monotonic="no"]
1518    )
1519  ]
1520)
1521
1522# --with-useragent {{{
1523AC_ARG_WITH([useragent],
1524  [AS_HELP_STRING([--with-useragent@<:@=AGENT@:>@], [User agent to use on http requests])],
1525  [
1526    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
1527      AC_DEFINE_UNQUOTED([COLLECTD_USERAGENT], ["$withval"], [User agent for http requests])
1528    fi
1529  ]
1530)
1531
1532# }}}
1533
1534# --with-data-max-name-len {{{
1535AC_ARG_WITH([data-max-name-len],
1536  [AS_HELP_STRING([--with-data-max-name-len@<:@=VALUE@:>@], [Maximum length of data buffers])],
1537  [
1538    if test "x$withval" != "x" && test $withval -gt 0; then
1539      AC_DEFINE_UNQUOTED([DATA_MAX_NAME_LEN], [$withval], [Maximum length of data buffers])
1540    else
1541      AC_MSG_ERROR([DATA_MAX_NAME_LEN must be a positive integer -- $withval given])
1542    fi
1543  ],
1544  [AC_DEFINE([DATA_MAX_NAME_LEN], [128], [Maximum length of data buffers])]
1545)
1546# }}}
1547
1548AC_CHECK_FUNCS([getfsstat], [have_getfsstat="yes"], [have_getfsstat="no"])
1549AC_CHECK_FUNCS(getvfsstat, [have_getvfsstat="yes"], [have_getvfsstat="no"])
1550AC_CHECK_FUNCS(listmntent, [have_listmntent="yes"], [have_listmntent="no"])
1551AC_CHECK_FUNCS(getmntent_r, [have_getmntent_r="yes"], [have_getmntent_r="no"])
1552
1553AC_CHECK_FUNCS(getmntent, [have_getmntent="libc"], [have_getmntent="no"])
1554if test "x$have_getmntent" = "xno"; then
1555  AC_CHECK_LIB([sun], [getmntent],
1556    [have_getmntent="sun"],
1557    [have_gemntent="no"]
1558  )
1559fi
1560
1561if test "x$have_getmntent" = "xno"; then
1562  AC_CHECK_LIB([seq], [getmntent],
1563    [have_getmntent="seq"],
1564    [have_getmntent="no"]
1565  )
1566fi
1567
1568if test "x$have_getmntent" = "xno"; then
1569  AC_CHECK_LIB([gen], [getmntent],
1570    [have_getmntent="gen"],
1571    [have_getmntent="no"]
1572  )
1573fi
1574
1575if test "x$have_getmntent" = "xlibc"; then
1576  AC_CACHE_CHECK([whether getmntent takes one argument],
1577    [c_cv_have_one_getmntent],
1578    [
1579      AC_COMPILE_IFELSE(
1580        [
1581          AC_LANG_PROGRAM(
1582            [[#include "$srcdir/src/utils/mount/mount.h"]],
1583            [[
1584              FILE *fh;
1585              struct mntent *me;
1586              fh = setmntent ("/etc/mtab", "r");
1587              me = getmntent (fh);
1588              return me->mnt_passno;
1589            ]]
1590          )
1591        ],
1592        [c_cv_have_one_getmntent="yes"],
1593        [c_cv_have_one_getmntent="no"]
1594      )
1595    ]
1596  )
1597
1598  AC_CACHE_CHECK([whether getmntent takes two arguments],
1599    [c_cv_have_two_getmntent],
1600    [
1601      AC_COMPILE_IFELSE(
1602        [
1603          AC_LANG_PROGRAM(
1604            [[#include "$srcdir/src/utils/mount/mount.h"]],
1605            [[
1606              FILE *fh;
1607              struct mnttab mt;
1608              int status;
1609              fh = fopen ("/etc/mnttab", "r");
1610              status = getmntent (fh, &mt);
1611              return status;
1612            ]]
1613          )
1614        ],
1615        [c_cv_have_two_getmntent="yes"],
1616        [c_cv_have_two_getmntent="no"]
1617      )
1618    ]
1619  )
1620fi
1621
1622# Check for different versions of `getmntent' here..
1623
1624if test "x$have_getmntent" = "xlibc"; then
1625  if test "x$c_cv_have_one_getmntent" = "xyes"; then
1626    AC_DEFINE([HAVE_ONE_GETMNTENT], [1],
1627      [Define if the function getmntent exists and takes one argument.]
1628    )
1629  fi
1630
1631  if test "x$c_cv_have_two_getmntent" = "xyes"; then
1632    AC_DEFINE([HAVE_TWO_GETMNTENT], [1],
1633      [Define if the function getmntent exists and takes two arguments.]
1634    )
1635  fi
1636fi
1637
1638if test "x$have_getmntent" = "xsun"; then
1639  AC_DEFINE([HAVE_SUN_GETMNTENT], [1],
1640    [Define if the function getmntent exists. It is the version from libsun.]
1641  )
1642fi
1643
1644if test "x$have_getmntent" = "xgen"; then
1645  AC_DEFINE([HAVE_GEN_GETMNTENT], [1],
1646    [Define if the function getmntent exists. It is the version from libgen.]
1647  )
1648fi
1649
1650# Check for htonll
1651AC_CACHE_CHECK([whether htonll is defined],
1652  [c_cv_have_htonll],
1653  [
1654    AC_LINK_IFELSE(
1655      [
1656        AC_LANG_PROGRAM(
1657          [[
1658            #include <inttypes.h>
1659            #include <sys/types.h>
1660            #include <netinet/in.h>
1661          ]],
1662          [[return htonll(0);]]
1663        )
1664      ],
1665      [c_cv_have_htonll="yes"],
1666      [c_cv_have_htonll="no"]
1667    )
1668  ]
1669)
1670
1671if test "x$c_cv_have_htonll" = "xyes"; then
1672  AC_DEFINE([HAVE_HTONLL], [1], [Define if the function htonll exists.])
1673fi
1674
1675# Check for structures
1676AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
1677  [AC_DEFINE([HAVE_STRUCT_IF_DATA], [1], [Define if struct if_data exists and is usable.])],
1678  [],
1679  [[
1680    #include <sys/types.h>
1681    #include <sys/socket.h>
1682    #include <net/if.h>
1683  ]]
1684)
1685
1686AC_CHECK_MEMBERS([struct net_device_stats.rx_bytes, struct net_device_stats.tx_packets, struct net_device_stats.rx_errors],
1687  [AC_DEFINE([HAVE_STRUCT_NET_DEVICE_STATS], [1], [Define if struct net_device_stats exists and is usable.])],
1688  [],
1689  [[
1690    #include <sys/types.h>
1691    #include <sys/socket.h>
1692    #include <linux/if.h>
1693    #include <linux/netdevice.h>
1694  ]]
1695)
1696
1697AC_CHECK_MEMBERS([struct inet_diag_req.id, struct inet_diag_req.idiag_states],
1698  [AC_DEFINE([HAVE_STRUCT_LINUX_INET_DIAG_REQ], [1], [Define if struct inet_diag_req exists and is usable.])],
1699  [],
1700  [[#include <linux/inet_diag.h>]]
1701)
1702
1703AC_CHECK_MEMBERS([struct ip_mreqn.imr_ifindex], [],
1704  [],
1705  [[
1706    #include <netinet/in.h>
1707    #include <net/if.h>
1708  ]]
1709)
1710
1711AC_CHECK_MEMBERS([struct kinfo_proc.ki_pid, struct kinfo_proc.ki_rssize, struct kinfo_proc.ki_rusage],
1712  [
1713    AC_DEFINE([HAVE_STRUCT_KINFO_PROC_FREEBSD], [1], [Define if struct kinfo_proc exists in the FreeBSD variant.])
1714    have_struct_kinfo_proc_freebsd="yes"
1715  ],
1716  [],
1717  [[
1718    #include <kvm.h>
1719    #include <sys/param.h>
1720    #include <sys/sysctl.h>
1721    #include <sys/user.h>
1722  ]]
1723)
1724
1725AC_CHECK_MEMBERS([struct kinfo_proc.kp_pid, struct kinfo_proc.kp_rssize, struct kinfo_proc.kp_ru],
1726  [
1727    AC_DEFINE([HAVE_STRUCT_KINFO_PROC_DRAGONFLY], [1], [Define if struct kinfo_proc exists in the DragonFly BSD variant.])
1728    have_struct_kinfo_proc_dragonfly="yes"
1729  ],
1730  [],
1731  [[
1732    #include <sys/types.h>
1733    #include <kvm.h>
1734    #include <sys/param.h>
1735    #include <sys/sysctl.h>
1736    #include <sys/user.h>
1737  ]]
1738)
1739
1740AC_CHECK_MEMBERS([struct kinfo_proc.p_pid, struct kinfo_proc.p_vm_rssize],
1741  [
1742    AC_DEFINE([HAVE_STRUCT_KINFO_PROC_OPENBSD], [1], [Define if struct kinfo_proc exists in the OpenBSD variant.])
1743    have_struct_kinfo_proc_openbsd="yes"
1744  ],
1745  [],
1746  [[
1747    #include <sys/param.h>
1748    #include <sys/sysctl.h>
1749    #include <kvm.h>
1750  ]]
1751)
1752
1753AC_CHECK_MEMBERS([struct kinfo_proc2.p_pid, struct kinfo_proc2.p_uru_maxrss],
1754  [
1755    AC_DEFINE([HAVE_STRUCT_KINFO_PROC2_NETBSD], [1], [Define if struct kinfo_proc2 exists in the NetBSD variant.])
1756    have_struct_kinfo_proc2_netbsd="yes"
1757  ],
1758  [],
1759  [[
1760    #include <sys/param.h>
1761    #include <sys/sysctl.h>
1762    #include <kvm.h>
1763  ]]
1764)
1765
1766AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport],
1767  [],
1768  [],
1769  [[
1770    #define _BSD_SOURCE
1771    #define _DEFAULT_SOURCE
1772    #include <stdint.h>
1773    #if HAVE_SYS_TYPES_H
1774    # include <sys/types.h>
1775    #endif
1776    #if HAVE_NETINET_IN_SYSTM_H
1777    # include <netinet/in_systm.h>
1778    #endif
1779    #if HAVE_NETINET_IN_H
1780    # include <netinet/in.h>
1781    #endif
1782    #if HAVE_NETINET_IP_H
1783    # include <netinet/ip.h>
1784    #endif
1785    #if HAVE_NETINET_UDP_H
1786    # include <netinet/udp.h>
1787    #endif
1788  ]]
1789)
1790
1791AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source],
1792  [],
1793  [],
1794  [[
1795    #define _BSD_SOURCE
1796    #define _DEFAULT_SOURCE
1797    #include <stdint.h>
1798    #if HAVE_SYS_TYPES_H
1799    # include <sys/types.h>
1800    #endif
1801    #if HAVE_NETINET_IN_SYSTM_H
1802    # include <netinet/in_systm.h>
1803    #endif
1804    #if HAVE_NETINET_IN_H
1805    # include <netinet/in.h>
1806    #endif
1807    #if HAVE_NETINET_IP_H
1808    # include <netinet/ip.h>
1809    #endif
1810    #if HAVE_NETINET_UDP_H
1811    # include <netinet/udp.h>
1812    #endif
1813  ]]
1814)
1815
1816AC_CHECK_MEMBERS([kstat_io_t.nwritten, kstat_io_t.writes, kstat_io_t.nwrites, kstat_io_t.wtime],
1817  [],
1818  [],
1819  [[# include <kstat.h>]]
1820)
1821
1822# check for pthread_setname_np
1823SAVE_LDFLAGS="$LDFLAGS"
1824LDFLAGS="$LDFLAGS -lpthread"
1825
1826AC_MSG_CHECKING([for pthread_setname_np])
1827have_pthread_setname_np="no"
1828AC_LINK_IFELSE(
1829  [
1830    AC_LANG_PROGRAM(
1831      [[
1832        #define _GNU_SOURCE
1833        #include <pthread.h>
1834      ]],
1835      [[pthread_setname_np((pthread_t) {0}, "conftest");]]
1836    )
1837  ],
1838  [
1839    have_pthread_setname_np="yes"
1840    AC_DEFINE(HAVE_PTHREAD_SETNAME_NP, 1, [pthread_setname_np() is available.])
1841  ]
1842)
1843
1844AC_MSG_RESULT([$have_pthread_setname_np])
1845
1846# check for pthread_set_name_np(3) (FreeBSD)
1847AC_MSG_CHECKING([for pthread_set_name_np])
1848have_pthread_set_name_np="no"
1849AC_LINK_IFELSE(
1850  [
1851    AC_LANG_PROGRAM(
1852      [[#include <pthread_np.h>]],
1853      [[pthread_set_name_np((pthread_t) {0}, "conftest");]]
1854    )
1855   ],
1856  [
1857    have_pthread_set_name_np="yes"
1858    AC_DEFINE(HAVE_PTHREAD_SET_NAME_NP, 1, [pthread_set_name_np() is available.])
1859  ]
1860)
1861AC_MSG_RESULT([$have_pthread_set_name_np])
1862
1863LDFLAGS="$SAVE_LDFLAGS"
1864
1865AC_CHECK_TYPES([struct ip6_ext],
1866  [have_ip6_ext="yes"],
1867  [have_ip6_ext="no"],
1868  [[
1869    #include <stdint.h>
1870    #if HAVE_SYS_TYPES_H
1871    # include <sys/types.h>
1872    #endif
1873    #if HAVE_NETINET_IN_SYSTM_H
1874    # include <netinet/in_systm.h>
1875    #endif
1876    #if HAVE_NETINET_IN_H
1877    # include <netinet/in.h>
1878    #endif
1879    #if HAVE_NETINET_IP6_H
1880    # include <netinet/ip6.h>
1881    #endif
1882  ]]
1883)
1884
1885if test "x$have_ip6_ext" = "xno"; then
1886  SAVE_CFLAGS="$CFLAGS"
1887  CFLAGS="$CFLAGS -DSOLARIS2=8"
1888  AC_CHECK_TYPES([struct ip6_ext],
1889    [have_ip6_ext="yes, with -DSOLARIS2=8"],
1890    [have_ip6_ext="no"],
1891    [[
1892      #include <stdint.h>
1893      #if HAVE_SYS_TYPES_H
1894      # include <sys/types.h>
1895      #endif
1896      #if HAVE_NETINET_IN_SYSTM_H
1897      # include <netinet/in_systm.h>
1898      #endif
1899      #if HAVE_NETINET_IN_H
1900      # include <netinet/in.h>
1901      #endif
1902      #if HAVE_NETINET_IP6_H
1903      # include <netinet/ip6.h>
1904      #endif
1905    ]]
1906  )
1907  if test "x$have_ip6_ext" = "xno"; then
1908    CFLAGS="$SAVE_CFLAGS"
1909  fi
1910fi
1911
1912# libi2c-dev
1913if test "x$ac_system" = "xLinux"; then
1914  with_libi2c_libs=""
1915  AC_CHECK_HEADERS([i2c/smbus.h],
1916    [with_libi2c_libs="-li2c"]
1917  )
1918  AC_CHECK_DECL([i2c_smbus_read_i2c_block_data],
1919    [with_libi2c="yes"],
1920    [with_libi2c="no (symbol i2c_smbus_read_i2c_block_data not found - have you installed libi2c-dev ?)"],
1921    [[
1922      #include <stdlib.h>
1923      #include <linux/i2c-dev.h>
1924      #if HAVE_I2C_SMBUS_H
1925      # include <i2c/smbus.h>
1926      #endif
1927    ]]
1928  )
1929  BUILD_WITH_LIBI2C_LIBS="$with_libi2c_libs"
1930  AC_SUBST([BUILD_WITH_LIBI2C_LIBS])
1931else
1932  with_libi2c="no (Linux only)"
1933fi
1934
1935#
1936# Checks for libraries begin here
1937#
1938
1939# Check for libpthread
1940SAVE_LIBS="$LIBS"
1941AC_CHECK_LIB([pthread],
1942  [pthread_create],
1943  [],
1944  [AC_MSG_ERROR([Symbol 'pthread_create' not found in libpthread])],
1945  []
1946)
1947PTHREAD_LIBS="$LIBS"
1948LIBS="$SAVE_LIBS"
1949AC_SUBST([PTHREAD_LIBS])
1950
1951AC_CHECK_HEADERS([pthread.h],
1952  [],
1953  [AC_MSG_ERROR([pthread.h not found])]
1954)
1955
1956m4_divert_once([HELP_WITH], [
1957Collectd additional packages:])
1958
1959if test "x$ac_system" = "xAIX"; then
1960  with_perfstat="yes"
1961  with_procinfo="yes"
1962else
1963  with_perfstat="no (AIX only)"
1964  with_procinfo="no (AIX only)"
1965fi
1966
1967if test "x$with_perfstat" = "xyes"; then
1968  AC_CHECK_LIB([perfstat], [perfstat_reset],
1969    [with_perfstat="yes"],
1970    [with_perfstat="no (perfstat not found)"]
1971  )
1972fi
1973
1974if test "x$with_perfstat" = "xyes"; then
1975  AC_DEFINE([HAVE_PERFSTAT], [1], [Define to 1 if you have the 'perfstat' library (-lperfstat)])
1976  # struct members pertaining to donation have been added to libperfstat somewhere between AIX5.3ML5 and AIX5.3ML9
1977  AC_CHECK_MEMBER([perfstat_partition_type_t.b.donate_enabled],
1978    [],
1979    [],
1980    [[#include <libperfstat.h]]
1981  )
1982  if test "x$av_cv_member_perfstat_partition_type_t_b_donate_enabled" = "xyes"; then
1983    AC_DEFINE([PERFSTAT_SUPPORTS_DONATION], [1], [Define to 1 if your version of the 'perfstat' library supports donation])
1984  fi
1985fi
1986AM_CONDITIONAL([BUILD_WITH_PERFSTAT], [test "x$with_perfstat" = "xyes"])
1987
1988# Processes plugin under AIX.
1989if test "x$with_procinfo" = "xyes"; then
1990  AC_CHECK_HEADERS([procinfo.h],
1991    [AC_DEFINE([HAVE_PROCINFO_H], [1], [Define to 1 if you have the procinfo.h])],
1992    [with_procinfo="no (procinfo.h not found)"]
1993  )
1994fi
1995
1996if test "x$ac_system" = "xSolaris"; then
1997  with_kstat="yes"
1998  with_devinfo="yes"
1999else
2000  with_kstat="no (Solaris only)"
2001  with_devinfo="no (Solaris only)"
2002fi
2003
2004if test "x$with_kstat" = "xyes"; then
2005  AC_CHECK_LIB([kstat], [kstat_open],
2006    [with_kstat="yes"],
2007    [with_kstat="no (libkstat not found)"]
2008  )
2009fi
2010
2011if test "x$with_kstat" = "xyes"; then
2012  AC_CHECK_LIB([devinfo], [di_init],
2013    [with_devinfo="yes"],
2014    [with_devinfo="no (not found)"]
2015  )
2016  AC_CHECK_HEADERS([kstat.h],
2017    [AC_DEFINE(HAVE_LIBKSTAT, [1], [Define to 1 if you have the 'kstat' library (-lkstat)])],
2018    [with_kstat="no (kstat.h not found)"]
2019  )
2020fi
2021
2022AM_CONDITIONAL([BUILD_WITH_LIBDEVINFO], [test "x$with_devinfo" = "xyes"])
2023AM_CONDITIONAL([BUILD_WITH_LIBKSTAT], [test "x$with_kstat" = "xyes"])
2024
2025if test "x$ac_system" = "xDarwin"; then
2026  with_libiokit="yes"
2027else
2028  with_libiokit="no"
2029fi
2030AM_CONDITIONAL([BUILD_WITH_LIBIOKIT], [test "x$with_libiokit" = "xyes"])
2031
2032with_libkvm="no"
2033AC_CHECK_LIB([kvm], [kvm_getprocs],
2034  [with_kvm_getprocs="yes"],
2035  [with_kvm_getprocs="no"]
2036)
2037
2038if test "x$with_kvm_getprocs" = "xyes"; then
2039  AC_DEFINE([HAVE_LIBKVM_GETPROCS], [1],
2040    [Define to 1 if you have the 'kvm' library with the 'kvm_getprocs' symbol (-lkvm)]
2041  )
2042  with_libkvm="yes"
2043fi
2044
2045AM_CONDITIONAL([BUILD_WITH_LIBKVM_GETPROCS], [test "x$with_kvm_getprocs" = "xyes"])
2046
2047AC_CHECK_LIB([kvm], [kvm_getswapinfo],
2048  [with_kvm_getswapinfo="yes"],
2049  [with_kvm_getswapinfo="no"]
2050)
2051
2052if test "x$with_kvm_getswapinfo" = "xyes"; then
2053  AC_DEFINE([HAVE_LIBKVM_GETSWAPINFO], [1],
2054    [Define to 1 if you have the 'kvm' library with the 'kvm_getswapinfo' symbol (-lkvm)]
2055  )
2056  with_libkvm="yes"
2057fi
2058
2059AM_CONDITIONAL([BUILD_WITH_LIBKVM_GETSWAPINFO], [test "x$with_kvm_getswapinfo" = "xyes"])
2060
2061AC_CHECK_LIB([kvm], [kvm_nlist],
2062  [with_kvm_nlist="yes"],
2063  [with_kvm_nlist="no"]
2064)
2065
2066if test "x$with_kvm_nlist" = "xyes"; then
2067  AC_CHECK_HEADERS([bsd/nlist.h nlist.h])
2068  AC_DEFINE([HAVE_LIBKVM_NLIST], [1],
2069    [Define to 1 if you have the 'kvm' library with the 'kvm_nlist' symbol (-lkvm)]
2070  )
2071  with_libkvm="yes"
2072fi
2073
2074AM_CONDITIONAL([BUILD_WITH_LIBKVM_NLIST], [test "x$with_kvm_nlist" = "xyes"])
2075
2076AC_CHECK_LIB([kvm], [kvm_openfiles],
2077  [with_kvm_openfiles="yes"],
2078  [with_kvm_openfiles="no"]
2079)
2080
2081if test "x$with_kvm_openfiles" = "xyes"; then
2082  AC_DEFINE([HAVE_LIBKVM_NLIST], [1],
2083    [Define to 1 if you have the 'kvm' library with the 'kvm_openfiles' symbol (-lkvm)]
2084  )
2085  with_libkvm="yes"
2086fi
2087
2088# --with-cuda {{{
2089AC_ARG_WITH([cuda],
2090  [AS_HELP_STRING([--with-cuda@<:@=PREFIX@:>@], [Path to cuda.])],
2091  [
2092    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
2093      with_cuda_cppflags="-I$withval/include"
2094      with_cuda_ldflags="-I$withval/lib"
2095      with_cuda="yes"
2096    else
2097      with_cuda="$withval"
2098    fi
2099  ],
2100  [with_cuda="no"]
2101)
2102
2103if test "x$with_cuda" = "xyes"; then
2104  SAVE_CPPFLAGS="$CPPFLAGS"
2105  CPPFLAGS="$CPPFLAGS $with_cuda_cppflags"
2106
2107  AC_CHECK_HEADERS([nvml.h],
2108    [with_cuda="yes"],
2109    [with_cuda="no (nvml.h not found)"]
2110  )
2111
2112  CPPFLAGS="$SAVE_CPPFLAGS"
2113fi
2114
2115if test "x$with_cuda" = "xyes"; then
2116  BUILD_WITH_CUDA_CPPFLAGS="$with_cuda_cppflags"
2117  BUILD_WITH_CUDA_LDFLAGS="$with_cuda_ldflags"
2118  BUILD_WITH_CUDA_LIBS="-lnvidia-ml"
2119fi
2120
2121AC_SUBST([BUILD_WITH_CUDA_CPPFLAGS])
2122AC_SUBST([BUILD_WITH_CUDA_LDFLAGS])
2123AC_SUBST([BUILD_WITH_CUDA_LIBS])
2124
2125# }}}
2126
2127# --with-libaquaero5 {{{
2128AC_ARG_WITH([libaquaero5],
2129  [AS_HELP_STRING([--with-libaquaero5@<:@=PREFIX@:>@], [Path to aquatools-ng source code.])],
2130  [
2131    if test "x$withval" = "xyes"; then
2132      with_libaquaero5="yes"
2133    else if test "x$withval" = "xno"; then
2134      with_libaquaero5="no"
2135    else
2136      with_libaquaero5="yes"
2137      LIBAQUAERO5_CFLAGS="$LIBAQUAERO5_CFLAGS -I$withval/src"
2138      LIBAQUAERO5_LDFLAGS="$LIBAQUAERO5_LDFLAGS -L$withval/obj"
2139    fi; fi
2140  ],
2141  [with_libaquaero5="yes"]
2142)
2143
2144SAVE_CPPFLAGS="$CPPFLAGS"
2145SAVE_LDFLAGS="$LDFLAGS"
2146CPPFLAGS="$CPPFLAGS $LIBAQUAERO5_CFLAGS"
2147LDFLAGS="$LDFLAGS $LIBAQUAERO5_LDFLAGS"
2148
2149if test "x$with_libaquaero5" = "xyes"; then
2150  AC_CHECK_HEADERS([libaquaero5.h],
2151    [with_libaquaero5="yes"],
2152    [with_libaquaero5="no (libaquaero5.h not found)"]
2153  )
2154fi
2155
2156if test "x$with_libaquaero5" = "xyes"; then
2157  AC_CHECK_LIB([aquaero5], libaquaero5_poll,
2158    [with_libaquaero5="yes"],
2159    [with_libaquaero5="no (symbol 'libaquaero5_poll' not found)"]
2160  )
2161fi
2162
2163CPPFLAGS="$SAVE_CPPFLAGS"
2164LDFLAGS="$SAVE_LDFLAGS"
2165
2166if test "x$with_libaquaero5" = "xyes"; then
2167  BUILD_WITH_LIBAQUAERO5_CFLAGS="$LIBAQUAERO5_CFLAGS"
2168  BUILD_WITH_LIBAQUAERO5_LDFLAGS="$LIBAQUAERO5_LDFLAGS"
2169fi
2170AC_SUBST([BUILD_WITH_LIBAQUAERO5_CFLAGS])
2171AC_SUBST([BUILD_WITH_LIBAQUAERO5_LDFLAGS])
2172# }}}
2173
2174# --with-libhiredis {{{
2175AC_ARG_WITH([libhiredis],
2176  [AS_HELP_STRING([--with-libhiredis@<:@=PREFIX@:>@], [Path to libhiredis.])],
2177  [
2178    if test "x$withval" = "xyes"; then
2179      with_libhiredis="yes"
2180    else if test "x$withval" = "xno"; then
2181      with_libhiredis="no"
2182    else
2183      with_libhiredis="yes"
2184      LIBHIREDIS_CPPFLAGS="$LIBHIREDIS_CPPFLAGS -I$withval/include"
2185      LIBHIREDIS_LDFLAGS="$LIBHIREDIS_LDFLAGS -L$withval/lib"
2186    fi; fi
2187  ],
2188  [with_libhiredis="yes"]
2189)
2190
2191SAVE_CPPFLAGS="$CPPFLAGS"
2192SAVE_LDFLAGS="$LDFLAGS"
2193CPPFLAGS="$CPPFLAGS $LIBHIREDIS_CPPFLAGS"
2194LDFLAGS="$LDFLAGS $LIBHIREDIS_LDFLAGS"
2195
2196if test "x$with_libhiredis" = "xyes"; then
2197  AC_CHECK_HEADERS([hiredis/hiredis.h],
2198    [with_libhiredis="yes"],
2199    [with_libhiredis="no (hiredis.h not found)"]
2200  )
2201fi
2202
2203if test "x$with_libhiredis" = "xyes"; then
2204  AC_CHECK_LIB([hiredis], [redisCommand],
2205    [with_libhiredis="yes"],
2206    [with_libhiredis="no (symbol 'redisCommand' not found)"]
2207  )
2208fi
2209
2210CPPFLAGS="$SAVE_CPPFLAGS"
2211LDFLAGS="$SAVE_LDFLAGS"
2212
2213if test "x$with_libhiredis" = "xyes"; then
2214  BUILD_WITH_LIBHIREDIS_CPPFLAGS="$LIBHIREDIS_CPPFLAGS"
2215  BUILD_WITH_LIBHIREDIS_LDFLAGS="$LIBHIREDIS_LDFLAGS"
2216fi
2217
2218AC_SUBST([BUILD_WITH_LIBHIREDIS_CPPFLAGS])
2219AC_SUBST([BUILD_WITH_LIBHIREDIS_LDFLAGS])
2220# }}}
2221
2222# --with-libredfish {{{
2223AC_ARG_WITH([libredfish],
2224  [AS_HELP_STRING([--with-libredfish@<:@=PREFIX@:>@], [Path to libredfish.])],
2225  [
2226    if test "x$withval" = "xyes"; then
2227      with_libredfish="yes"
2228    else if test "x$withval" = "xno"; then
2229      with_libredfish="no"
2230    else
2231      with_libredfish="yes"
2232      LIBREDFISH_CPPFLAGS="$LIBREDFISH_CPPFLAGS -I$withval/include"
2233      LIBREDFISH_LDFLAGS="$LIBREDFISH_LDFLAGS -L$withval/lib"
2234    fi; fi
2235  ],
2236  [with_libredfish="yes"]
2237)
2238
2239SAVE_CPPFLAGS="$CPPFLAGS"
2240SAVE_LDFLAGS="$LDFLAGS"
2241CPPFLAGS="$CPPFLAGS $LIBREDFISH_CPPFLAGS"
2242LDFLAGS="$LDFLAGS $LIBREDFISH_LDFLAGS"
2243
2244if test "x$with_libredfish" = "xyes"; then
2245  if test "x$LIBREDFISH_CPPFLAGS" != "x"; then
2246    AC_MSG_NOTICE([libredfish CPPFLAGS: $LIBHIREDFISH_CPPFLAGS])
2247  fi
2248  AC_CHECK_HEADERS([redfish.h],
2249    [with_libredfish="yes"],
2250    [with_libredfish="no (redfish.h not found)"]
2251  )
2252fi
2253
2254if test "x$with_libredfish" = "xyes"; then
2255  if test "x$LIBREDFISH_LDFLAGS" != "x"; then
2256    AC_MSG_NOTICE([libredfish LDFLAGS: $LIBREDFISH_LDFLAGS])
2257  fi
2258  AC_CHECK_LIB([redfish], [createServiceEnumerator],
2259    [with_libredfish="yes"],
2260    [with_libredfish="no (symbol 'createServiceEnumerator' not found)"]
2261  )
2262fi
2263
2264CPPFLAGS="$SAVE_CPPFLAGS"
2265LDFLAGS="$SAVE_LDFLAGS"
2266
2267if test "x$with_libredfish" = "xyes"; then
2268  BUILD_WITH_LIBREDFISH_CPPFLAGS="$LIBREDFISH_CPPFLAGS"
2269  BUILD_WITH_LIBREDFISH_LDFLAGS="$LIBREDFISH_LDFLAGS"
2270fi
2271
2272AC_SUBST([BUILD_WITH_LIBREDFISH_CPPFLAGS])
2273AC_SUBST([BUILD_WITH_LIBREDFISH_LDFLAGS])
2274
2275# }}}
2276
2277# --with-libcurl {{{
2278with_curl_config="curl-config"
2279with_curl_cflags=""
2280with_curl_libs=""
2281AC_ARG_WITH(libcurl,
2282  [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
2283  [
2284    if test "x$withval" = "xno"; then
2285      with_libcurl="no"
2286    else if test "x$withval" = "xyes"; then
2287      with_libcurl="yes"
2288    else
2289      if test -f "$withval" && test -x "$withval"; then
2290        with_curl_config="$withval"
2291        with_libcurl="yes"
2292      else if test -x "$withval/bin/curl-config"; then
2293        with_curl_config="$withval/bin/curl-config"
2294        with_libcurl="yes"
2295      fi; fi
2296      with_libcurl="yes"
2297    fi; fi
2298  ],
2299  [with_libcurl="yes"]
2300)
2301
2302if test "x$with_libcurl" = "xyes"; then
2303  with_curl_cflags=`$with_curl_config --cflags 2>/dev/null`
2304  curl_config_status=$?
2305
2306  if test $curl_config_status -ne 0; then
2307    with_libcurl="no ($with_curl_config failed)"
2308  else
2309    SAVE_CPPFLAGS="$CPPFLAGS"
2310    CPPFLAGS="$CPPFLAGS $with_curl_cflags"
2311
2312    AC_CHECK_HEADERS([curl/curl.h],
2313      [with_libcurl="yes"],
2314      [with_libcurl="no (curl/curl.h not found)"]
2315    )
2316
2317    CPPFLAGS="$SAVE_CPPFLAGS"
2318  fi
2319fi
2320
2321if test "x$with_libcurl" = "xyes"; then
2322  with_curl_libs=`$with_curl_config --libs 2>/dev/null`
2323  curl_config_status=$?
2324
2325  if test $curl_config_status -ne 0; then
2326    with_libcurl="no ($with_curl_config failed)"
2327  else
2328    AC_CHECK_LIB([curl], [curl_easy_init],
2329      [with_libcurl="yes"],
2330      [with_libcurl="no (symbol 'curl_easy_init' not found)"],
2331      [$with_curl_libs]
2332    )
2333
2334    AC_CHECK_DECL([CURLOPT_USERNAME],
2335      [have_curlopt_username="yes"],
2336      [have_curlopt_username="no"],
2337      [[#include <curl/curl.h>]]
2338    )
2339
2340    AC_CHECK_DECL(CURLOPT_TIMEOUT_MS,
2341      [have_curlopt_timeout="yes"],
2342      [have_curlopt_timeout="no"],
2343      [[#include <curl/curl.h>]]
2344    )
2345  fi
2346fi
2347
2348if test "x$with_libcurl" = "xyes"; then
2349  SAVE_CPPFLAGS="$CPPFLAGS"
2350  SAVE_LDFLAGS="$LDFLAGS"
2351  CPPFLAGS="$CPPFLAGS $with_curl_cflags"
2352  LDFLAGS="$LDFLAGS $with_curl_libs"
2353  AC_CACHE_CHECK([for CURLINFO_APPCONNECT_TIME],
2354    [c_cv_have_curlinfo_appconnect_time],
2355    [
2356      AC_LINK_IFELSE(
2357        [
2358          AC_LANG_PROGRAM(
2359            [[#include <curl/curl.h>]],
2360            [[
2361              int val = CURLINFO_APPCONNECT_TIME;
2362              return val;
2363            ]]
2364          )
2365        ],
2366        [c_cv_have_curlinfo_appconnect_time="yes"],
2367        [c_cv_have_curlinfo_appconnect_time="no"]
2368      )
2369    ]
2370  )
2371  CPPFLAGS="$SAVE_CPPFLAGS"
2372  LDFLAGS="$SAVE_LDFLAGS"
2373fi
2374
2375if test "x$c_cv_have_curlinfo_appconnect_time" = "xyes"; then
2376  AC_DEFINE([HAVE_CURLINFO_APPCONNECT_TIME], [1],
2377    [Define if curl.h defines CURLINFO_APPCONNECT_TIME.]
2378  )
2379fi
2380
2381if test "x$with_libcurl" = "xyes"; then
2382  BUILD_WITH_LIBCURL_CFLAGS="$with_curl_cflags"
2383  BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
2384
2385  if test "x$have_curlopt_username" = "xyes"; then
2386    AC_DEFINE([HAVE_CURLOPT_USERNAME], [1],
2387      [Define if libcurl supports CURLOPT_USERNAME option.]
2388    )
2389  fi
2390
2391  if test "x$have_curlopt_timeout" = "xyes"; then
2392    AC_DEFINE([HAVE_CURLOPT_TIMEOUT_MS], [1],
2393      [Define if libcurl supports CURLOPT_TIMEOUT_MS option.]
2394    )
2395  fi
2396fi
2397
2398AC_SUBST(BUILD_WITH_LIBCURL_CFLAGS)
2399AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
2400
2401AM_CONDITIONAL([BUILD_WITH_LIBCURL], [test "x$with_libcurl" = "xyes"])
2402# }}}
2403
2404# --with-libdbi {{{
2405AC_ARG_WITH([libdbi],
2406  [AS_HELP_STRING([--with-libdbi@<:@=PREFIX@:>@], [Path to libdbi.])],
2407  [
2408    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
2409      with_libdbi_cppflags="-I$withval/include"
2410      with_libdbi_ldflags="-L$withval/lib"
2411      with_libdbi="yes"
2412    else
2413      with_libdbi="$withval"
2414    fi
2415  ],
2416  [with_libdbi="yes"]
2417)
2418
2419if test "x$with_libdbi" = "xyes"; then
2420  SAVE_CPPFLAGS="$CPPFLAGS"
2421  CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
2422
2423  AC_CHECK_HEADERS([dbi/dbi.h],
2424    [with_libdbi="yes"],
2425    [with_libdbi="no (dbi/dbi.h not found)"]
2426  )
2427
2428  CPPFLAGS="$SAVE_CPPFLAGS"
2429fi
2430
2431if test "x$with_libdbi" = "xyes"; then
2432  SAVE_LDFLAGS="$LDFLAGS"
2433  LDFLAGS="$LDFLAGS $with_libdbi_ldflags"
2434
2435  AC_CHECK_LIB([dbi], [dbi_initialize],
2436    [with_libdbi="yes"],
2437    [with_libdbi="no (Symbol 'dbi_initialize' not found)"]
2438  )
2439
2440  LDFLAGS="$SAVE_LDFLAGS"
2441fi
2442
2443BUILD_WITH_LIBDBI_CPPFLAGS="$with_libdbi_cppflags"
2444BUILD_WITH_LIBDBI_LDFLAGS="$with_libdbi_ldflags"
2445BUILD_WITH_LIBDBI_LIBS="-ldbi"
2446AC_SUBST(BUILD_WITH_LIBDBI_CPPFLAGS)
2447AC_SUBST(BUILD_WITH_LIBDBI_LDFLAGS)
2448AC_SUBST(BUILD_WITH_LIBDBI_LIBS)
2449# }}}
2450
2451# --with-libdpdk {{{
2452AC_ARG_VAR([LIBDPDK_CPPFLAGS], [Preprocessor flags for libdpdk])
2453AC_ARG_VAR([LIBDPDK_CFLAGS], [Compiler flags for libdpdk])
2454AC_ARG_VAR([LIBDPDK_LDFLAGS], [Linker flags for libdpdk])
2455AC_ARG_VAR([LIBDPDK_LIBS], [Libraries to link for libdpdk])
2456
2457AC_ARG_WITH([libdpdk],
2458  [AS_HELP_STRING([--without-libdpdk], [Disable libdpdk.])],
2459  [with_libdpdk="$withval"],
2460  [with_libdpdk="yes"]
2461)
2462
2463if test "x$with_libdpdk" != "xno"; then
2464  PKG_CHECK_MODULES([DPDK], [libdpdk], [],
2465    [AC_MSG_NOTICE([no DPDK pkg-config, using defaults])])
2466  if test "x$LIBDPDK_CPPFLAGS" = "x"; then
2467    LIBDPDK_CPPFLAGS="-I/usr/include/dpdk"
2468  fi
2469  if test "x$LIBDPDK_CFLAGS" = "x"; then
2470    LIBDPDK_CFLAGS="$DPDK_CFLAGS"
2471    LIBDPDK_CPPFLAGS="$LIBDPDK_CPPFLAGS $DPDK_CFLAGS"
2472  fi
2473  if test "x$LIBDPDK_LIBS" = "x"; then
2474    if test "x$DPDK_LIBS" != "x"; then
2475      LIBDPDK_LIBS="$DPDK_LIBS"
2476    else
2477      LIBDPDK_LIBS="-ldpdk"
2478    fi
2479  fi
2480  SAVE_CPPFLAGS="$CPPFLAGS"
2481  CPPFLAGS="$LIBDPDK_CPPFLAGS $CPPFLAGS"
2482  SAVE_CFLAGS="$CFLAGS"
2483  CFLAGS="$LIBDPDK_CFLAGS $CFLAGS"
2484  AC_CHECK_HEADERS([rte_config.h],
2485    [
2486      with_libdpdk="yes"
2487      AC_PREPROC_IFELSE(
2488        [
2489          AC_LANG_SOURCE(
2490            [[
2491              #include <rte_version.h>
2492              #if RTE_VERSION < RTE_VERSION_NUM(16,7,0,0)
2493              #error "required DPDK >= 16.07"
2494              #endif
2495            ]]
2496          )
2497        ],
2498        [dpdk_keepalive="yes"],
2499        [dpdk_keepalive="no (DPDK version < 16.07)"]
2500      )
2501    ],
2502    [with_libdpdk="no (rte_config.h not found)"]
2503  )
2504  CPPFLAGS="$SAVE_CPPFLAGS"
2505  CFLAGS="$SAVE_CFLAGS"
2506fi
2507
2508if test "x$with_libdpdk" = "xyes"; then
2509  SAVE_LIBS="$LIBS"
2510  LIBS="$LIBDPDK_LIBS $LIBS"
2511  SAVE_LDFLAGS="$LDFLAGS"
2512  LDFLAGS="$LIBDPDK_LDFLAGS $LDFLAGS"
2513  SAVE_CPPFLAGS="$CPPFLAGS"
2514  CPPFLAGS="$LIBDPDK_CPPFLAGS $CPPFLAGS"
2515  SAVE_CFLAGS="$CFLAGS"
2516  CFLAGS="$LIBDPDK_CFLAGS $CFLAGS"
2517  AC_LINK_IFELSE(
2518    [
2519      AC_LANG_PROGRAM(
2520        [[
2521          #include <rte_eal.h>
2522        ]],
2523        [[return rte_eal_init(0, NULL);]]
2524      )
2525    ],
2526    [with_libdpdk="yes"],
2527    [with_libdpdk="no (symbol 'rte_eal_init' not found)"]
2528  )
2529  LIBS="$SAVE_LIBS"
2530  LDFLAGS="$SAVE_LDFLAGS"
2531  CPPFLAGS="$SAVE_CPPFLAGS"
2532  CFLAGS="$SAVE_CFLAGS"
2533fi
2534
2535# }}}
2536
2537# --with-libesmtp {{{
2538AC_ARG_WITH([libesmtp],
2539  [AS_HELP_STRING([--with-libesmtp@<:@=PREFIX@:>@], [Path to libesmtp.])],
2540  [
2541    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
2542      with_libesmtp_cppflags="-I$withval/include"
2543      with_libesmtp_ldflags="-L$withval/lib"
2544      with_libesmtp="yes"
2545    else
2546      with_libesmtp="$withval"
2547    fi
2548  ],
2549  [with_libesmtp="yes"]
2550)
2551
2552if test "x$with_libesmtp" = "xyes"; then
2553  SAVE_CPPFLAGS="$CPPFLAGS"
2554  CPPFLAGS="$CPPFLAGS $with_libesmtp_cppflags"
2555
2556  AC_CHECK_HEADERS([libesmtp.h],
2557    [with_libesmtp="yes"],
2558    [with_libesmtp="no (libesmtp.h not found)"]
2559  )
2560
2561  CPPFLAGS="$SAVE_CPPFLAGS"
2562fi
2563
2564if test "x$with_libesmtp" = "xyes"; then
2565  SAVE_LDFLAGS="$LDFLAGS"
2566  LDFLAGS="$LDFLAGS $with_esmtp_ldflags"
2567
2568  AC_CHECK_LIB([esmtp], [smtp_create_session],
2569    [with_libesmtp="yes"],
2570    [with_libesmtp="no (Symbol 'smtp_create_session' not found)"]
2571  )
2572
2573  LDFLAGS="$SAVE_LDFLAGS"
2574fi
2575
2576BUILD_WITH_LIBESMTP_CPPFLAGS="$with_libesmtp_cppflags"
2577BUILD_WITH_LIBESMTP_LDFLAGS="$with_libesmtp_ldflags"
2578BUILD_WITH_LIBESMTP_LIBS="-lesmtp"
2579AC_SUBST(BUILD_WITH_LIBESMTP_CPPFLAGS)
2580AC_SUBST(BUILD_WITH_LIBESMTP_LDFLAGS)
2581AC_SUBST(BUILD_WITH_LIBESMTP_LIBS)
2582# }}}
2583
2584# --with-libganglia {{{
2585AC_ARG_WITH([libganglia],
2586  [AS_HELP_STRING([--with-libganglia@<:@=PREFIX@:>@], [Path to libganglia.])],
2587  [
2588    if test -f "$withval" && test -x "$withval"; then
2589      with_libganglia_config="$withval"
2590      with_libganglia="yes"
2591    else if test -f "$withval/bin/ganglia-config" && test -x "$withval/bin/ganglia-config"; then
2592      with_libganglia_config="$withval/bin/ganglia-config"
2593      with_libganglia="yes"
2594    else if test -d "$withval"; then
2595      GANGLIA_CPPFLAGS="-I$withval/include"
2596      GANGLIA_LDFLAGS="-L$withval/lib"
2597      with_libganglia="yes"
2598    else
2599      with_libganglia="$withval"
2600    fi; fi; fi
2601  ],
2602  [with_libganglia="yes"]
2603)
2604
2605if test "x$with_libganglia" = "xyes"; then
2606  if test "x$with_libganglia_config" != "x"; then
2607    if test "x$GANGLIA_CPPFLAGS" = "x"; then
2608      GANGLIA_CPPFLAGS=`"$with_libganglia_config" --cflags 2>/dev/null`
2609    fi
2610
2611    if test "x$GANGLIA_LDFLAGS" = "x"; then
2612      GANGLIA_LDFLAGS=`"$with_libganglia_config" --ldflags 2>/dev/null`
2613    fi
2614
2615    if test "x$GANGLIA_LIBS" = "x"; then
2616      GANGLIA_LIBS=`"$with_libganglia_config" --libs 2>/dev/null`
2617    fi
2618  else
2619    GANGLIA_LIBS="-lganglia"
2620  fi
2621fi
2622
2623SAVE_CPPFLAGS="$CPPFLAGS"
2624SAVE_LDFLAGS="$LDFLAGS"
2625CPPFLAGS="$CPPFLAGS $GANGLIA_CPPFLAGS"
2626LDFLAGS="$LDFLAGS $GANGLIA_LDFLAGS"
2627
2628if test "x$with_libganglia" = "xyes"; then
2629  AC_CHECK_HEADERS([gm_protocol.h],
2630    [with_libganglia="yes"],
2631    [with_libganglia="no (gm_protocol.h not found)"]
2632  )
2633fi
2634
2635if test "x$with_libganglia" = "xyes"; then
2636  AC_CHECK_LIB([ganglia], [xdr_Ganglia_value_msg],
2637    [with_libganglia="yes"],
2638    [with_libganglia="no (symbol xdr_Ganglia_value_msg not found)"]
2639  )
2640fi
2641
2642CPPFLAGS="$SAVE_CPPFLAGS"
2643LDFLAGS="$SAVE_LDFLAGS"
2644
2645AC_SUBST(GANGLIA_CPPFLAGS)
2646AC_SUBST(GANGLIA_LDFLAGS)
2647AC_SUBST(GANGLIA_LIBS)
2648# }}}
2649
2650# --with-libgcrypt {{{
2651GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS"
2652GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS"
2653GCRYPT_LIBS="$GCRYPT_LIBS"
2654AC_ARG_WITH([libgcrypt],
2655  [AS_HELP_STRING([--with-libgcrypt@<:@=PREFIX@:>@], [Path to libgcrypt.])],
2656  [
2657    if test -f "$withval" && test -x "$withval"; then
2658      with_libgcrypt_config="$withval"
2659      with_libgcrypt="yes"
2660    else if test -f "$withval/bin/gcrypt-config" && test -x "$withval/bin/gcrypt-config"; then
2661      with_libgcrypt_config="$withval/bin/gcrypt-config"
2662      with_libgcrypt="yes"
2663    else if test -d "$withval"; then
2664      GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS -I$withval/include"
2665      GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS -L$withval/lib"
2666      with_libgcrypt="yes"
2667    else
2668      with_libgcrypt_config="gcrypt-config"
2669      with_libgcrypt="$withval"
2670    fi; fi; fi
2671  ],
2672  [
2673    with_libgcrypt_config="libgcrypt-config"
2674    with_libgcrypt="yes"
2675  ]
2676)
2677
2678if test "x$with_libgcrypt" = "xyes" && test "x$with_libgcrypt_config" != "x"; then
2679  if test "x$GCRYPT_CPPFLAGS" = "x"; then
2680    GCRYPT_CPPFLAGS=`"$with_libgcrypt_config" --cflags 2>/dev/null`
2681  fi
2682
2683  if test "x$GCRYPT_LIBS" = "x"; then
2684    GCRYPT_LIBS=`"$with_libgcrypt_config" --libs 2>/dev/null`
2685  fi
2686fi
2687
2688SAVE_CPPFLAGS="$CPPFLAGS"
2689SAVE_LDFLAGS="$LDFLAGS"
2690SAVE_LIBS="$LIBS"
2691CPPFLAGS="$CPPFLAGS $GCRYPT_CPPFLAGS"
2692LDFLAGS="$LDFLAGS $GCRYPT_LDFLAGS"
2693LIBS="$LIBS $GCRYPT_LIBS"
2694
2695if test "x$with_libgcrypt" = "xyes"; then
2696  AC_CHECK_HEADERS([gcrypt.h],
2697    [with_libgcrypt="yes"],
2698    [with_libgcrypt="no (gcrypt.h not found)"]
2699  )
2700fi
2701
2702if test "x$with_libgcrypt" = "xyes"; then
2703  AC_CHECK_LIB(gcrypt, gcry_md_hash_buffer,
2704    [with_libgcrypt="yes"],
2705    [with_libgcrypt="no (symbol gcry_md_hash_buffer not found)"]
2706  )
2707fi
2708
2709CPPFLAGS="$SAVE_CPPFLAGS"
2710LDFLAGS="$SAVE_LDFLAGS"
2711LIBS="$SAVE_LIBS"
2712
2713AC_SUBST([GCRYPT_CPPFLAGS])
2714AC_SUBST([GCRYPT_LDFLAGS])
2715AC_SUBST([GCRYPT_LIBS])
2716AM_CONDITIONAL([BUILD_WITH_LIBGCRYPT], [test "x$with_libgcrypt" = "xyes"])
2717# }}}
2718
2719# --with-libgps {{{
2720AC_ARG_WITH([libgps],
2721  [AS_HELP_STRING([--with-libgps@<:@=PREFIX@:>@], [Path to libgps.])],
2722  [
2723    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
2724      with_libgps_cflags="-I$withval/include"
2725      with_libgps_ldflags="-L$withval/lib"
2726      with_libgps="yes"
2727    else
2728      with_libgps="$withval"
2729    fi
2730  ],
2731  [with_libgps="yes"]
2732)
2733
2734if test "x$with_libgps" = "xyes"; then
2735  SAVE_CFLAGS="$CFLAGS"
2736  CFLAGS="$CFLAGS $with_libgps_cflags"
2737
2738  AC_CHECK_HEADERS([gps.h],
2739    [with_libgps="yes"],
2740    [with_libgps="no (gps.h not found)"]
2741  )
2742
2743  CFLAGS="$SAVE_CFLAGS"
2744fi
2745
2746if test "x$with_libgps" = "xyes"; then
2747  SAVE_LDFLAGS="$LDFLAGS"
2748  LDFLAGS="$LDFLAGS $with_libgps_ldflags"
2749
2750  AC_CHECK_LIB([gps], [gps_open],
2751    [with_libgps="yes"],
2752    [with_libgps="no (symbol gps_open not found)"]
2753  )
2754
2755  LDFLAGS="$SAVE_LDFLAGS"
2756fi
2757
2758if test "x$with_libgps" = "xyes"; then
2759  BUILD_WITH_LIBGPS_CFLAGS="$with_libgps_cflags"
2760  BUILD_WITH_LIBGPS_LDFLAGS="$with_libgps_ldflags"
2761  BUILD_WITH_LIBGPS_LIBS="-lgps"
2762fi
2763
2764AC_SUBST([BUILD_WITH_LIBGPS_CFLAGS])
2765AC_SUBST([BUILD_WITH_LIBGPS_LDFLAGS])
2766AC_SUBST([BUILD_WITH_LIBGPS_LIBS])
2767
2768# }}}
2769
2770# --with-libgrpc++ {{{
2771AC_ARG_WITH([libgrpc++],
2772  [AS_HELP_STRING([--with-libgrpc++@<:@=PREFIX@:>@], [Path to libgrpc++.])],
2773  [
2774    with_grpcpp="$withval"
2775    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
2776      with_libgrpcpp_cppflags="-I$withval/include"
2777      with_libgrpcpp_ldflags="-L$withval/lib"
2778      with_libgrpcpp_bin="$withval/bin"
2779      with_libgrpcpp="yes"
2780    fi
2781    if test "x$withval" = "xno"; then
2782      with_libgrpcpp="no (disabled on command line)"
2783    fi
2784  ],
2785  [withval="yes"]
2786)
2787if test "x$withval" = "xyes"; then
2788PKG_CHECK_MODULES([GRPCPP], [grpc++],
2789  [with_libgrpcpp="yes"],
2790  [with_libgrpcpp="no (pkg-config could not find libgrpc++)"]
2791)
2792fi
2793
2794if test "x$withval" != "xno"; then
2795  AC_MSG_CHECKING([whether $CXX accepts -std=c++11])
2796  if test_cxx_flags -std=c++11; then
2797    AC_MSG_RESULT([yes])
2798  else
2799    AC_MSG_RESULT([no])
2800    with_libgrpcpp="no (requires C++11 support)"
2801    with_libprotobuf="no (<google/protobuf/util/time_util.h> requires C++11 support)"
2802  fi
2803fi
2804
2805if test "x$with_libgrpcpp" = "xyes"; then
2806  AC_LANG_PUSH(C++)
2807  SAVE_CPPFLAGS="$CPPFLAGS"
2808  CPPFLAGS="-std=c++11 $with_libgrpcpp_cppflags $GRPCPP_CFLAGS $CPPFLAGS"
2809  AC_CHECK_HEADERS([grpc++/grpc++.h],
2810    [with_libgrpcpp="yes"],
2811    [with_libgrpcpp="no (<grpc++/grpc++.h> not found)"]
2812  )
2813  CPPFLAGS="$SAVE_CPPFLAGS"
2814  AC_LANG_POP(C++)
2815fi
2816
2817if test "x$with_libgrpcpp" = "xyes"; then
2818  AC_LANG_PUSH(C++)
2819  SAVE_CPPFLAGS="$CPPFLAGS"
2820  SAVE_LDFLAGS="$LDFLAGS"
2821  SAVE_LIBS="$LIBS"
2822  CPPFLAGS="-std=c++11 $with_libgrpcpp_cppflags $GRPCPP_CFLAGS $CPPFLAGS"
2823  LDFLAGS="$with_libgrpcpp_ldflags"
2824  if test "x$GRPCPP_LIBS" = "x"; then
2825    LIBS="-lgrpc++"
2826  else
2827    LIBS="$GRPCPP_LIBS"
2828  fi
2829  AC_LINK_IFELSE(
2830    [
2831      AC_LANG_PROGRAM(
2832        [[#include <grpc++/grpc++.h>]],
2833        [[grpc::ServerBuilder sb;]]
2834      )
2835    ],
2836    [
2837      with_libgrpcpp="yes"
2838      if test "x$GRPCPP_LIBS" = "x"; then
2839        GRPCPP_LIBS="-lgrpc++"
2840      fi
2841    ],
2842    [with_libgrpcpp="no (libgrpc++ not found)"]
2843  )
2844  CPPFLAGS="$SAVE_CPPFLAGS"
2845  LDFLAGS="$SAVE_LDFLAGS"
2846  LIBS="$SAVE_LIBS"
2847  AC_LANG_POP(C++)
2848fi
2849
2850BUILD_WITH_LIBGRPCPP_CPPFLAGS="-std=c++11 $with_libgrpcpp_cppflags $GRPCPP_CFLAGS"
2851BUILD_WITH_LIBGRPCPP_LDFLAGS="$with_libgrpcpp_ldflags"
2852BUILD_WITH_LIBGRPCPP_LIBS="$GRPCPP_LIBS"
2853AC_SUBST([BUILD_WITH_LIBGRPCPP_CPPFLAGS])
2854AC_SUBST([BUILD_WITH_LIBGRPCPP_LDFLAGS])
2855AC_SUBST([BUILD_WITH_LIBGRPCPP_LIBS])
2856# }}}
2857
2858AC_ARG_VAR([GRPC_CPP_PLUGIN], [path to the grpc_cpp_plugin binary])
2859if test "x$with_libgrpcpp_bin" = "x"; then
2860  AC_PATH_PROG([GRPC_CPP_PLUGIN], [grpc_cpp_plugin])
2861else
2862  AC_PATH_PROG([GRPC_CPP_PLUGIN], [grpc_cpp_plugin], [], "$with_libgrpcpp_bin:$PATH")
2863fi
2864AM_CONDITIONAL([HAVE_GRPC_CPP], [test "x$GRPC_CPP_PLUGIN" != "x"])
2865
2866# --with-libiptc {{{
2867AC_ARG_WITH([libiptc],
2868  [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
2869  [
2870    if test "x$withval" = "xyes"; then
2871      with_libiptc="pkgconfig"
2872    else if test "x$withval" = "xno"; then
2873      with_libiptc="no"
2874    else
2875      with_libiptc="yes"
2876      with_libiptc_cflags="-I$withval/include"
2877      with_libiptc_libs="-L$withval/lib"
2878    fi; fi
2879  ],
2880  [
2881    if test "x$ac_system" = "xLinux"; then
2882      with_libiptc="pkgconfig"
2883    else
2884      with_libiptc="no (Linux only)"
2885    fi
2886  ]
2887)
2888
2889if test "x$with_libiptc" = "xpkgconfig"; then
2890  $PKG_CONFIG --exists 'libiptc' 2>/dev/null
2891  if test $? -ne 0; then
2892    with_libiptc="no (pkg-config doesn't know libiptc)"
2893  fi
2894fi
2895
2896if test "x$with_libiptc" = "xpkgconfig"; then
2897  with_libiptc_cflags="`$PKG_CONFIG --cflags 'libiptc'`"
2898  if test $? -ne 0; then
2899    with_libiptc="no ($PKG_CONFIG failed)"
2900  fi
2901
2902  with_libiptc_libs="`$PKG_CONFIG --libs 'libiptc'`"
2903  if test $? -ne 0; then
2904    with_libiptc="no ($PKG_CONFIG failed)"
2905  fi
2906fi
2907
2908SAVE_CPPFLAGS="$CPPFLAGS"
2909CPPFLAGS="$CPPFLAGS $with_libiptc_cflags"
2910
2911# check whether the header file for libiptc is available.
2912if test "x$with_libiptc" = "xpkgconfig"; then
2913  AC_CHECK_HEADERS([libiptc/libiptc.h libiptc/libip6tc.h],
2914    [],
2915    [with_libiptc="no (header file missing)"]
2916  )
2917fi
2918
2919# If the header file is available, check for the required type declaractions.
2920# They may be missing in old versions of libiptc. In that case, they will be
2921# declared in the iptables plugin.
2922if test "x$with_libiptc" = "xpkgconfig"; then
2923  AC_CHECK_TYPES([iptc_handle_t, ip6tc_handle_t], [], [])
2924fi
2925
2926# Check for the iptc_init symbol in the library.
2927# This could be in iptc or ip4tc
2928if test "x$with_libiptc" = "xpkgconfig"; then
2929  SAVE_LIBS="$LIBS"
2930  AC_SEARCH_LIBS([iptc_init], [iptc ip4tc],
2931    [with_libiptc="pkgconfig"],
2932    [with_libiptc="no"],
2933    [$with_libiptc_libs]
2934  )
2935  LIBS="$SAVE_LIBS"
2936fi
2937
2938if test "x$with_libiptc" = "xpkgconfig"; then
2939  with_libiptc="yes"
2940fi
2941
2942CPPFLAGS="$SAVE_CPPFLAGS"
2943
2944if test "x$with_libiptc" = "xyes"; then
2945  BUILD_WITH_LIBIPTC_CPPFLAGS="$with_libiptc_cflags"
2946  BUILD_WITH_LIBIPTC_LDFLAGS="$with_libiptc_libs"
2947fi
2948AC_SUBST([BUILD_WITH_LIBIPTC_CPPFLAGS])
2949AC_SUBST([BUILD_WITH_LIBIPTC_LDFLAGS])
2950# }}}
2951
2952# --with-java {{{
2953with_java_home="$JAVA_HOME"
2954if test "x$with_java_home" = "x"; then
2955  with_java_home="/usr/lib/jvm"
2956fi
2957
2958JAVAC="$JAVAC"
2959JAR="$JAR"
2960AC_ARG_WITH([java],
2961  [AS_HELP_STRING([--with-java@<:@=PREFIX@:>@], [Path to Java home.])],
2962  [
2963    if test "x$withval" = "xno"; then
2964      with_java="no"
2965    else if test "x$withval" = "xyes"; then
2966      with_java="yes"
2967    else
2968      with_java_home="$withval"
2969      with_java="yes"
2970    fi; fi
2971  ],
2972  [with_java="yes"]
2973)
2974
2975AX_COMPARE_VERSION([$am__api_version],[lt],[1.12],
2976  [JAVA_TIMESTAMP_FILE="classdist_noinst.stamp"],
2977  [JAVA_TIMESTAMP_FILE="classnoinst.stamp"])
2978if test "x$with_java" = "xyes"; then
2979  if test -d "$with_java_home"; then
2980    AC_MSG_CHECKING([for jni.h])
2981    TMPVAR=`find -L "$with_java_home" -name jni.h -type f -exec 'dirname' '{}' ';' 2>/dev/null | LC_ALL=C sort | head -n 1`
2982    if test "x$TMPVAR" != "x"; then
2983      AC_MSG_RESULT([found in $TMPVAR])
2984      JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPVAR"
2985    else
2986      AC_MSG_RESULT([not found])
2987    fi
2988
2989    AC_MSG_CHECKING([for jni_md.h])
2990    TMPVAR=`find -L "$with_java_home" -name jni_md.h -type f -exec 'dirname' '{}' ';' 2>/dev/null | LC_ALL=C sort | head -n 1`
2991    if test "x$TMPVAR" != "x"; then
2992      AC_MSG_RESULT([found in $TMPVAR])
2993      JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPVAR"
2994    else
2995      AC_MSG_RESULT([not found])
2996    fi
2997
2998    AC_MSG_CHECKING([for libjvm.so])
2999    TMPVAR=`find -L "$with_java_home" -type f \( -name libjvm.so -o -name libjvm.dylib \) -exec 'dirname' '{}' ';' 2>/dev/null | LC_ALL=C sort | head -n 1`
3000    if test "x$TMPVAR" != "x"; then
3001      AC_MSG_RESULT([found in $TMPVAR])
3002      JAVA_LDFLAGS="$JAVA_LDFLAGS -L$TMPVAR -Wl,-rpath -Wl,$TMPVAR"
3003    else
3004      AC_MSG_RESULT([not found])
3005    fi
3006
3007    if test "x$JAVAC" = "x"; then
3008      AC_MSG_CHECKING([for javac])
3009      TMPVAR=`find -L "$with_java_home" -name javac -type f 2>/dev/null | LC_ALL=C sort | head -n 1`
3010      if test "x$TMPVAR" != "x"; then
3011        JAVAC="$TMPVAR"
3012        AC_MSG_RESULT([$JAVAC])
3013      else
3014        AC_MSG_RESULT([not found])
3015      fi
3016    fi
3017
3018    if test "x$JAR" = "x"; then
3019      AC_MSG_CHECKING([for jar])
3020      TMPVAR=`find -L "$with_java_home" -name jar -type f 2>/dev/null | LC_ALL=C sort | head -n 1`
3021      if test "x$TMPVAR" != "x"; then
3022        JAR="$TMPVAR"
3023        AC_MSG_RESULT([$JAR])
3024      else
3025        AC_MSG_RESULT([not found])
3026      fi
3027    fi
3028  else if test "x$with_java_home" != "x"; then
3029    AC_MSG_WARN([JAVA_HOME: No such directory: $with_java_home])
3030  fi; fi
3031fi
3032
3033if test "x$JAVAC" = "x"; then
3034  with_javac_path="$PATH"
3035  if test "x$with_java_home" != "x"; then
3036    with_javac_path="$with_java_home:with_javac_path"
3037    if test -d "$with_java_home/bin"; then
3038      with_javac_path="$with_java_home/bin:with_javac_path"
3039    fi
3040  fi
3041
3042  AC_PATH_PROG([JAVAC], [javac], [], "$with_javac_path")
3043fi
3044
3045if test "x$JAVAC" = "x"; then
3046  with_java="no (javac not found)"
3047fi
3048
3049if test "x$JAR" = "x"; then
3050  with_jar_path="$PATH"
3051  if test "x$with_java_home" != "x"; then
3052    with_jar_path="$with_java_home:$with_jar_path"
3053    if test -d "$with_java_home/bin"; then
3054      with_jar_path="$with_java_home/bin:$with_jar_path"
3055    fi
3056  fi
3057
3058  AC_PATH_PROG([JAR], [jar], [], "$with_jar_path")
3059fi
3060
3061if test "x$JAR" = "x"; then
3062  with_java="no (jar not found)"
3063fi
3064
3065SAVE_CPPFLAGS="$CPPFLAGS"
3066SAVE_CFLAGS="$CFLAGS"
3067SAVE_LDFLAGS="$LDFLAGS"
3068SAVE_LIBS="$LIBS"
3069CPPFLAGS="$CPPFLAGS $JAVA_CPPFLAGS"
3070CFLAGS="$CFLAGS $JAVA_CFLAGS"
3071LDFLAGS="$LDFLAGS $JAVA_LDFLAGS"
3072LIBS="$LIBS $JAVA_LIBS"
3073
3074if test "x$with_java" = "xyes"; then
3075  AC_CHECK_HEADERS([jni.h],
3076    [with_jave="yes"],
3077    [with_java="no (jni.h not found)"])
3078fi
3079
3080if test "x$with_java" = "xyes"; then
3081  AC_CHECK_LIB([jvm], [JNI_CreateJavaVM],
3082    [with_java="yes"],
3083    [with_java="no (Symbol 'JNI_CreateJavaVM' not found)"],
3084    [$JAVA_LIBS $PTHREAD_LIBS]
3085  )
3086fi
3087
3088if test "x$with_java" = "xyes"; then
3089  JAVA_LIBS="$JAVA_LIBS -ljvm"
3090fi
3091
3092CPPFLAGS="$SAVE_CPPFLAGS"
3093CFLAGS="$SAVE_CFLAGS"
3094LDFLAGS="$SAVE_LDFLAGS"
3095LIBS="$SAVE_LIBS"
3096
3097AC_SUBST([JAVA_CPPFLAGS])
3098AC_SUBST([JAVA_CFLAGS])
3099AC_SUBST([JAVA_LDFLAGS])
3100AC_SUBST([JAVA_LIBS])
3101AC_SUBST([JAVA_TIMESTAMP_FILE])
3102AM_CONDITIONAL([BUILD_WITH_JAVA], [test "x$with_java" = "xyes"])
3103# }}}
3104
3105# --with-libldap {{{
3106AC_ARG_WITH([libldap],
3107  [AS_HELP_STRING([--with-libldap@<:@=PREFIX@:>@], [Path to libldap.])],
3108  [
3109    if test "x$withval" = "xyes"; then
3110      with_libldap="yes"
3111    else if test "x$withval" = "xno"; then
3112      with_libldap="no"
3113    else
3114      with_libldap="yes"
3115      LIBLDAP_CPPFLAGS="$LIBLDAP_CPPFLAGS -I$withval/include"
3116      LIBLDAP_LDFLAGS="$LIBLDAP_LDFLAGS -L$withval/lib"
3117    fi; fi
3118  ],
3119  [with_libldap="yes"]
3120)
3121
3122SAVE_CPPFLAGS="$CPPFLAGS"
3123SAVE_LDFLAGS="$LDFLAGS"
3124
3125CPPFLAGS="$CPPFLAGS $LIBLDAP_CPPFLAGS"
3126LDFLAGS="$LDFLAGS $LIBLDAP_LDFLAGS"
3127
3128if test "x$with_libldap" = "xyes"; then
3129  AC_CHECK_HEADERS([ldap.h],
3130    [with_libldap="yes"],
3131    [with_libldap="no ('ldap.h' not found)"]
3132  )
3133fi
3134
3135if test "x$with_libldap" = "xyes"; then
3136  AC_CHECK_LIB([ldap], [ldap_initialize],
3137    [with_libldap="yes"],
3138    [with_libldap="no (symbol 'ldap_initialize' not found)"]
3139  )
3140fi
3141
3142CPPFLAGS="$SAVE_CPPFLAGS"
3143LDFLAGS="$SAVE_LDFLAGS"
3144
3145if test "x$with_libldap" = "xyes"
3146then
3147  BUILD_WITH_LIBLDAP_CPPFLAGS="$LIBLDAP_CPPFLAGS"
3148  BUILD_WITH_LIBLDAP_LDFLAGS="$LIBLDAP_LDFLAGS"
3149fi
3150AC_SUBST([BUILD_WITH_LIBLDAP_CPPFLAGS])
3151AC_SUBST([BUILD_WITH_LIBLDAP_LDFLAGS])
3152# }}}
3153
3154# --with-liblua {{{
3155AC_ARG_VAR([LIBLUA_PKG_CONFIG_NAME], [Name of liblua used by pkg-config])
3156if test "x$LIBLUA_PKG_CONFIG_NAME" != "x"
3157then
3158  PKG_CHECK_MODULES([LUA], [$LIBLUA_PKG_CONFIG_NAME],
3159    [with_liblua="yes"],
3160    [with_liblua="no"]
3161  )
3162else
3163  PKG_CHECK_MODULES([LUA], [lua],
3164    [with_liblua="yes"],
3165    [
3166      PKG_CHECK_MODULES([LUA], [lua-5.3],
3167        [with_liblua="yes"],
3168        [
3169          PKG_CHECK_MODULES([LUA], [lua5.3],
3170            [with_liblua="yes"],
3171            [
3172              PKG_CHECK_MODULES([LUA], [lua53],
3173                [with_liblua="yes"],
3174                [
3175                  PKG_CHECK_MODULES([LUA], [lua-5.2],
3176                    [with_liblua="yes"],
3177                    [
3178                      PKG_CHECK_MODULES([LUA], [lua5.2],
3179                        [with_liblua="yes"],
3180                        [
3181                          PKG_CHECK_MODULES([LUA], [lua52],
3182                            [with_liblua="yes"],
3183                            [
3184                              PKG_CHECK_MODULES([LUA], [lua-5.1],
3185                                [with_liblua="yes"],
3186                                [
3187                                  PKG_CHECK_MODULES([LUA], [lua5.1],
3188                                    [with_liblua="yes"],
3189                                    [
3190                                      PKG_CHECK_MODULES([LUA], [lua51],
3191                                        [with_liblua="yes"],
3192                                        [with_liblua="no (pkg-config cannot find liblua)"]
3193                                      )
3194                                    ]
3195                                  )
3196                                ]
3197                              )
3198                            ]
3199                          )
3200                        ]
3201                      )
3202                    ]
3203                  )
3204                ]
3205              )
3206            ]
3207          )
3208        ]
3209      )
3210    ]
3211  )
3212fi
3213
3214if test "x$with_liblua" = "xyes"
3215then
3216  SAVE_CPPFLAGS="$CPPFLAGS"
3217  CPPFLAGS="$CPPFLAGS $LUA_CFLAGS"
3218
3219  AC_CHECK_HEADERS([lua.h lauxlib.h lualib.h],
3220    [with_liblua="yes"],
3221    [with_liblua="no (header not found)"]
3222  )
3223
3224  CPPFLAGS="$SAVE_CPPFLAGS"
3225fi
3226
3227if test "x$with_liblua" = "xyes"
3228then
3229  SAVE_LIBS="$LIBS"
3230  LIBS="$LIBS $LUA_LIBS"
3231
3232  AC_CHECK_FUNC([lua_settop],
3233    [with_liblua="yes"],
3234    [with_liblua="no (symbol 'lua_settop' not found)"]
3235  )
3236
3237  LIBS="$SAVE_LIBS"
3238fi
3239
3240if test "x$with_liblua" = "xyes"
3241then
3242    BUILD_WITH_LIBLUA_CFLAGS="$LUA_CFLAGS"
3243    BUILD_WITH_LIBLUA_LIBS="$LUA_LIBS"
3244fi
3245AC_SUBST(BUILD_WITH_LIBLUA_CFLAGS)
3246AC_SUBST(BUILD_WITH_LIBLUA_LIBS)
3247# }}}
3248
3249# --with-libmemcached {{{
3250AC_ARG_WITH([libmemcached],
3251  [AS_HELP_STRING([--with-libmemcached@<:@=PREFIX@:>@], [Path to libmemcached.])],
3252  [
3253    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
3254      with_libmemcached_cppflags="-I$withval/include"
3255      with_libmemcached_ldflags="-L$withval/lib"
3256      with_libmemcached="yes"
3257    else
3258      with_libmemcached="$withval"
3259    fi
3260  ],
3261  [with_libmemcached="yes"]
3262)
3263
3264if test "x$with_libmemcached" = "xyes"; then
3265  SAVE_CPPFLAGS="$CPPFLAGS"
3266  CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
3267
3268  AC_CHECK_HEADERS([libmemcached/memcached.h],
3269    [with_libmemcached="yes"],
3270    [with_libmemcached="no (libmemcached/memcached.h not found)"]
3271  )
3272
3273  CPPFLAGS="$SAVE_CPPFLAGS"
3274fi
3275
3276if test "x$with_libmemcached" = "xyes"; then
3277  SAVE_CPPFLAGS="$CPPFLAGS"
3278  SAVE_LDFLAGS="$LDFLAGS"
3279  CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
3280  LDFLAGS="$LDFLAGS $with_libmemcached_ldflags"
3281
3282  AC_CHECK_LIB([memcached], [memcached_create],
3283    [with_libmemcached="yes"],
3284    [with_libmemcached="no (Symbol 'memcached_create' not found)"]
3285  )
3286
3287  CPPFLAGS="$SAVE_CPPFLAGS"
3288  LDFLAGS="$SAVE_LDFLAGS"
3289fi
3290
3291if test "x$with_libmemcached" = "xyes"; then
3292  BUILD_WITH_LIBMEMCACHED_CPPFLAGS="$with_libmemcached_cppflags"
3293  BUILD_WITH_LIBMEMCACHED_LDFLAGS="$with_libmemcached_ldflags"
3294  BUILD_WITH_LIBMEMCACHED_LIBS="-lmemcached"
3295fi
3296
3297AC_SUBST([BUILD_WITH_LIBMEMCACHED_CPPFLAGS])
3298AC_SUBST([BUILD_WITH_LIBMEMCACHED_LDFLAGS])
3299AC_SUBST([BUILD_WITH_LIBMEMCACHED_LIBS])
3300# }}}
3301
3302# --with-libmicrohttpd {{{
3303with_libmicrohttpd_cppflags=""
3304with_libmicrohttpd_ldflags=""
3305AC_ARG_WITH([libmicrohttpd], [AS_HELP_STRING([--with-libmicrohttpd@<:@=PREFIX@:>@], [Path to libmicrohttpd.])],
3306  [
3307    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
3308      with_libmicrohttpd_cppflags="-I$withval/include"
3309      with_libmicrohttpd_ldflags="-L$withval/lib"
3310      with_libmicrohttpd="yes"
3311    fi
3312    if test "x$withval" = "xno"; then
3313      with_libmicrohttpd="no (disabled on command line)"
3314    fi
3315  ],
3316  [withval="yes"]
3317)
3318if test "x$withval" = "xyes"; then
3319  PKG_CHECK_MODULES([MICROHTTPD], [libmicrohttpd],
3320    [with_libmicrohttpd="yes"],
3321    [with_libmicrohttpd="no (pkg-config could not find libmicrohttpd)"]
3322  )
3323fi
3324
3325if test "x$MICROHTTPD_LIBS" = "x"; then
3326  MICROHTTPD_LIBS="-lmicrohttpd"
3327fi
3328
3329SAVE_CPPFLAGS="$CPPFLAGS"
3330SAVE_LDFLAGS="$LDFLAGS"
3331SAVE_LIBS="$LIBS"
3332CPPFLAGS="$with_libmicrohttpd_cppflags $MICROHTTPD_CFLAGS"
3333LDFLAGS="$with_libmicrohttpd_ldflags $LDFLAGS"
3334LIBS="$LIBS $MICROHTTPD_LIBS"
3335
3336if test "x$with_libmicrohttpd" = "xyes"; then
3337  AC_CHECK_HEADERS([microhttpd.h],
3338   [with_libmicrohttpd="yes"],
3339   [with_libmicrohttpd="no (<microhttpd.h> not found)"]
3340  )
3341fi
3342
3343if test "x$with_libmicrohttpd" = "xyes"; then
3344  AC_CHECK_LIB([microhttpd], [MHD_start_daemon],
3345    [with_libmicrohttpd="yes"],
3346    [with_libmicrohttpd="no (libmicrohttpd not found)"]
3347  )
3348fi
3349
3350CPPFLAGS="$SAVE_CPPFLAGS"
3351LDFLAGS="$SAVE_LDFLAGS"
3352LIBS="$SAVE_LIBS"
3353
3354BUILD_WITH_LIBMICROHTTPD_CPPFLAGS="$with_libmicrohttpd_cppflags $MICROHTTPD_CFLAGS"
3355BUILD_WITH_LIBMICROHTTPD_LDFLAGS="$with_libmicrohttpd_ldflags"
3356BUILD_WITH_LIBMICROHTTPD_LIBS="$MICROHTTPD_LIBS"
3357AC_SUBST([BUILD_WITH_LIBMICROHTTPD_CPPFLAGS])
3358AC_SUBST([BUILD_WITH_LIBMICROHTTPD_LDFLAGS])
3359AC_SUBST([BUILD_WITH_LIBMICROHTTPD_LIBS])
3360# }}}
3361
3362# --with-libmodbus {{{
3363AC_ARG_WITH([libmodbus],
3364  [AS_HELP_STRING([--with-libmodbus@<:@=PREFIX@:>@], [Path to the modbus library.])],
3365  [
3366    if test "x$withval" = "xno"; then
3367      with_libmodbus="no"
3368    else if test "x$withval" = "xyes"; then
3369      with_libmodbus="use_pkgconfig"
3370    else if test -d "$with_libmodbus/lib"; then
3371      AC_MSG_NOTICE([Not checking for libmodbus: Manually configured])
3372      with_libmodbus_cflags="-I$withval/include"
3373      with_libmodbus_libs="-L$withval/lib -lmodbus"
3374      with_libmodbus="yes"
3375    fi; fi; fi
3376  ],
3377  [with_libmodbus="use_pkgconfig"]
3378)
3379
3380# configure using pkg-config
3381if test "x$with_libmodbus" = "xuse_pkgconfig"; then
3382  $PKG_CONFIG --exists 'libmodbus' 2>/dev/null
3383  if test $? -ne 0; then
3384    with_libmodbus="no (pkg-config doesn't know libmodbus)"
3385  fi
3386fi
3387
3388if test "x$with_libmodbus" = "xuse_pkgconfig"; then
3389  with_libmodbus_cflags="`$PKG_CONFIG --cflags 'libmodbus'`"
3390  if test $? -ne 0; then
3391    with_libmodbus="no ($PKG_CONFIG failed)"
3392  fi
3393
3394  with_libmodbus_libs="`$PKG_CONFIG --libs 'libmodbus'`"
3395  if test $? -ne 0; then
3396    with_libmodbus="no ($PKG_CONFIG failed)"
3397  fi
3398fi
3399
3400if test "x$with_libmodbus" = "xuse_pkgconfig"; then
3401  with_libmodbus="yes"
3402fi
3403
3404if test "x$with_libmodbus" = "xyes"; then
3405  SAVE_CPPFLAGS="$CPPFLAGS"
3406  CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"
3407
3408  AC_CHECK_HEADERS([modbus.h],
3409    [with_libmodbus="yes"],
3410    [with_libmodbus="no (modbus.h not found)"]
3411  )
3412
3413  CPPFLAGS="$SAVE_CPPFLAGS"
3414fi
3415
3416if test "x$with_libmodbus" = "xyes"; then
3417  SAVE_LDFLAGS="$LDFLAGS"
3418  LDFLAGS="$LDFLAGS $with_libmodbus_libs"
3419
3420  AC_CHECK_LIB([modbus], [modbus_connect],
3421    [with_libmodbus="yes"],
3422    [with_libmodbus="no (symbol modbus_connect not found)"]
3423  )
3424
3425  LDFLAGS="$SAVE_LDFLAGS"
3426fi
3427
3428if test "x$with_libmodbus" = "xyes"; then
3429  BUILD_WITH_LIBMODBUS_CFLAGS="$with_libmodbus_cflags"
3430  BUILD_WITH_LIBMODBUS_LIBS="$with_libmodbus_libs"
3431fi
3432
3433AC_SUBST([BUILD_WITH_LIBMODBUS_CFLAGS])
3434AC_SUBST([BUILD_WITH_LIBMODBUS_LIBS])
3435# }}}
3436
3437# --with-libmongoc {{{
3438AC_ARG_WITH([libmongoc],
3439  [AS_HELP_STRING([--with-libmongoc@<:@=PREFIX@:>@], [Path to libmongoc.])],
3440  [
3441    if test "x$withval" = "xyes"; then
3442      with_libmongoc="yes"
3443    else if test "x$withval" = "xno"; then
3444      with_libmongoc="no"
3445    else
3446      with_libmongoc="no"
3447    fi; fi
3448  ],
3449  [with_libmongoc="yes"]
3450)
3451
3452if test "x$with_libmongoc" = "xyes"; then
3453  PKG_CHECK_MODULES([LIBMONGOC], [libmongoc-1.0],
3454    [with_libmongoc="yes"],
3455    [with_libmongoc="no (pkg-config could not find libmongoc)"]
3456  )
3457fi
3458
3459if test "x$with_libmongoc" = "xyes"; then
3460  SAVE_CPPFLAGS="$CPPFLAGS"
3461
3462  CPPFLAGS="$CPPFLAGS $LIBMONGOC_CFLAGS"
3463
3464  AC_CHECK_HEADERS([mongoc.h],
3465    [with_libmongoc="yes"],
3466    [with_libmongoc="no ('mongoc.h' not found)"]
3467  )
3468
3469  CPPFLAGS="$SAVE_CPPFLAGS"
3470fi
3471
3472if test "x$with_libmongoc" = "xyes"; then
3473  SAVE_CPPFLAGS="$CPPFLAGS"
3474  SAVE_LDFLAGS="$LDFLAGS"
3475
3476  CPPFLAGS="$CPPFLAGS $LIBMONGOC_CFLAGS"
3477  LDFLAGS="$LDFLAGS $LIBMONGOC_LDFLAGS"
3478
3479  AC_CHECK_LIB([mongoc-1.0], [mongoc_init],
3480    [with_libmongoc="yes"],
3481    [with_libmongoc="no (symbol 'mongoc_init' not found)"]
3482  )
3483
3484  CPPFLAGS="$SAVE_CPPFLAGS"
3485  LDFLAGS="$SAVE_LDFLAGS"
3486fi
3487
3488if test "x$with_libmongoc" = "xyes"; then
3489  BUILD_WITH_LIBMONGOC_CFLAGS="$LIBMONGOC_CFLAGS"
3490  BUILD_WITH_LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS"
3491  BUILD_WITH_LIBMONGOC_LIBS="$LIBMONGOC_LIBS"
3492fi
3493
3494AC_SUBST([BUILD_WITH_LIBMONGOC_CFLAGS])
3495AC_SUBST([BUILD_WITH_LIBMONGOC_LDFLAGS])
3496AC_SUBST([BUILD_WITH_LIBMONGOC_LIBS])
3497# }}}
3498
3499# --with-libmosquitto {{{
3500AC_ARG_WITH([libmosquitto],
3501  [AS_HELP_STRING([--with-libmosquitto@<:@=PREFIX@:>@], [Path to libmosquitto.])],
3502  [
3503    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
3504      with_libmosquitto_cppflags="-I$withval/include"
3505      with_libmosquitto_ldflags="-L$withval/lib"
3506      with_libmosquitto="yes"
3507    else
3508      with_libmosquitto="$withval"
3509    fi
3510  ],
3511  [with_libmosquitto="yes"]
3512)
3513
3514if test "x$with_libmosquitto" = "xyes"; then
3515  SAVE_CPPFLAGS="$CPPFLAGS"
3516  CPPFLAGS="$CPPFLAGS $with_libmosquitto_cppflags"
3517
3518  AC_CHECK_HEADERS([mosquitto.h],
3519    [with_libmosquitto="yes"],
3520    [with_libmosquitto="no (mosquitto.h not found)"]
3521  )
3522
3523  CPPFLAGS="$SAVE_CPPFLAGS"
3524fi
3525
3526if test "x$with_libmosquitto" = "xyes"; then
3527  SAVE_LDFLAGS="$LDFLAGS"
3528  LDFLAGS="$LDFLAGS $with_libmosquitto_ldflags"
3529
3530  AC_CHECK_LIB([mosquitto], [mosquitto_connect],
3531    [with_libmosquitto="yes"],
3532    [with_libmosquitto="no (libmosquitto not found)"]
3533  )
3534
3535  LDFLAGS="$SAVE_LDFLAGS"
3536fi
3537
3538if test "x$with_libmosquitto" = "xyes"; then
3539  BUILD_WITH_LIBMOSQUITTO_CPPFLAGS="$with_libmosquitto_cppflags"
3540  BUILD_WITH_LIBMOSQUITTO_LDFLAGS="$with_libmosquitto_ldflags"
3541  BUILD_WITH_LIBMOSQUITTO_LIBS="-lmosquitto"
3542fi
3543
3544AC_SUBST([BUILD_WITH_LIBMOSQUITTO_CPPFLAGS])
3545AC_SUBST([BUILD_WITH_LIBMOSQUITTO_LDFLAGS])
3546AC_SUBST([BUILD_WITH_LIBMOSQUITTO_LIBS])
3547# }}}
3548
3549# --with-libmysql {{{
3550with_mysql_config="mysql_config"
3551AC_ARG_WITH([libmysql],
3552  [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
3553  [
3554    if test "x$withval" = "xno"; then
3555      with_libmysql="no"
3556    else if test "x$withval" = "xyes"; then
3557      with_libmysql="yes"
3558    else
3559      if test -f "$withval" && test -x "$withval"; then
3560        with_mysql_config="$withval"
3561      else if test -x "$withval/bin/mysql_config"; then
3562        with_mysql_config="$withval/bin/mysql_config"
3563      fi; fi
3564      with_libmysql="yes"
3565    fi; fi
3566  ],
3567  [with_libmysql="yes"]
3568)
3569
3570if test "x$with_libmysql" = "xyes"; then
3571  with_mysql_cflags=`$with_mysql_config --include 2>/dev/null`
3572  if test $? -ne 0; then
3573    with_libmysql="no ($with_mysql_config failed)"
3574  else
3575    SAVE_CPPFLAGS="$CPPFLAGS"
3576    CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
3577
3578    AC_CHECK_HEADERS([mysql.h],
3579      [have_mysql_h="yes"],
3580      [have_mysql_h="no"]
3581    )
3582
3583    if test "x$have_mysql_h" != "xyes"; then
3584      AC_CHECK_HEADERS([mysql/mysql.h],
3585        [have_mysql_mysql_h="yes"],
3586        [],
3587      )
3588    fi
3589
3590    if test "x$have_mysql_h" != "xyes" && test "x$have_mysql_mysql_h" != "xyes"; then
3591      with_libmysql="no (mysql.h not found)"
3592    fi
3593
3594    CPPFLAGS="$SAVE_CPPFLAGS"
3595  fi
3596fi
3597
3598if test "x$with_libmysql" = "xyes"; then
3599  with_mysql_libs=`$with_mysql_config --libs_r 2>/dev/null`
3600  if test $? -ne 0; then
3601    with_libmysql="no ($with_mysql_config failed)"
3602  else
3603    SAVE_LIBS="$LIBS"
3604    LIBS="$with_mysql_libs"
3605
3606    AC_SEARCH_LIBS([mysql_get_server_version],
3607      [],
3608      [with_libmysql="yes"],
3609      [with_libmysql="no (symbol 'mysql_get_server_version' not found in ${LIBS})"],
3610      []
3611    )
3612    LIBS="$SAVE_LIBS"
3613  fi
3614fi
3615
3616if test "x$with_libmysql" = "xyes"; then
3617  BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
3618  BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
3619fi
3620
3621AC_SUBST([BUILD_WITH_LIBMYSQL_CFLAGS])
3622AC_SUBST([BUILD_WITH_LIBMYSQL_LIBS])
3623# }}}
3624
3625# --with-libmnl {{{
3626AC_ARG_WITH([libmnl],
3627  [AS_HELP_STRING([--with-libmnl@<:@=PREFIX@:>@], [Path to libmnl.])],
3628  [
3629    if test "x$withval" = "xyes"; then
3630      with_libmnl="yes"
3631     else if test "x$withval" = "xno"; then
3632       with_libmnl="no"
3633     else
3634       if test -d "$withval/include"; then
3635         with_libmnl_cflags="-I$withval/include"
3636         with_libmnl_libs="-L$withval/lib -lmnl"
3637         with_libmnl="yes"
3638       else
3639         AC_MSG_ERROR("no such directory: $withval/include")
3640       fi
3641     fi; fi
3642  ],
3643  [
3644    if test "x$ac_system" = "xLinux"; then
3645      with_libmnl="yes"
3646    else
3647      with_libmnl="no (Linux only library)"
3648    fi
3649  ]
3650)
3651
3652if test "x$with_libmnl" = "xyes"; then
3653  if $PKG_CONFIG --exists libmnl 2>/dev/null; then
3654    with_libmnl_cflags="$with_libmnl_ldflags `$PKG_CONFIG --cflags libmnl`"
3655    with_libmnl_libs="$with_libmnl_libs `$PKG_CONFIG --libs libmnl`"
3656  fi
3657
3658  AC_CHECK_HEADERS([libmnl.h libmnl/libmnl.h],
3659    [
3660      with_libmnl="yes"
3661      break
3662    ],
3663    [],
3664    [[
3665      #include <stdio.h>
3666      #include <sys/types.h>
3667      #include <asm/types.h>
3668      #include <sys/socket.h>
3669      #include <linux/netlink.h>
3670      #include <linux/rtnetlink.h>]]
3671  )
3672
3673  AC_CHECK_HEADERS([linux/gen_stats.h linux/pkt_sched.h],
3674    [],
3675    [],
3676    [[
3677      #include <stdio.h>
3678      #include <sys/types.h>
3679      #include <asm/types.h>
3680      #include <sys/socket.h>
3681    ]]
3682  )
3683
3684  AC_COMPILE_IFELSE(
3685    [
3686      AC_LANG_PROGRAM(
3687        [[
3688          #include <stdio.h>
3689          #include <sys/types.h>
3690          #include <asm/types.h>
3691          #include <sys/socket.h>
3692          #include <linux/netlink.h>
3693          #include <linux/rtnetlink.h>
3694        ]],
3695        [[
3696          int retval = TCA_STATS2;
3697          return retval;
3698        ]]
3699      )
3700    ],
3701    [AC_DEFINE([HAVE_TCA_STATS2], [1], [True if the enum-member TCA_STATS2 exists])]
3702  )
3703
3704  AC_COMPILE_IFELSE(
3705    [
3706      AC_LANG_PROGRAM(
3707        [[
3708          #include <stdio.h>
3709          #include <sys/types.h>
3710          #include <asm/types.h>
3711          #include <sys/socket.h>
3712          #include <linux/netlink.h>
3713          #include <linux/rtnetlink.h>
3714        ]],
3715        [[
3716          int retval = TCA_STATS;
3717          return retval;
3718        ]]
3719      )
3720    ],
3721    [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
3722  )
3723
3724  AC_CHECK_MEMBERS([struct rtnl_link_stats64.tx_window_errors],
3725    [AC_DEFINE(HAVE_RTNL_LINK_STATS64, 1, [Define if struct rtnl_link_stats64 exists and is usable.])],
3726    [],
3727    [[#include <linux/if_link.h>]]
3728  )
3729
3730  AC_CHECK_MEMBERS([struct rtnl_link_stats.rx_nohandler],
3731    [],
3732    [],
3733    [[#include <linux/if_link.h>]]
3734  )
3735
3736  AC_CHECK_MEMBERS([struct rtnl_link_stats64.rx_nohandler],
3737    [],
3738    [],
3739    [[#include <linux/if_link.h>]]
3740  )
3741
3742  AC_CHECK_DECLS([IFLA_VF_STATS_RX_DROPPED],
3743    [AC_DEFINE(HAVE_IFLA_VF_STATS_RX_DROPPED, 1, [Define if IFLA_VF_STATS_RX_DROPPED exists.])],
3744    [],
3745    [[#include <linux/if_link.h>]]
3746  )
3747
3748  AC_CHECK_DECLS([IFLA_VF_STATS_TX_DROPPED],
3749    [AC_DEFINE(HAVE_IFLA_VF_STATS_TX_DROPPED, 1, [Define if IFLA_VF_STATS_TX_DROPPED exists.])],
3750    [],
3751    [[#include <linux/if_link.h>]]
3752  )
3753
3754  AC_CHECK_DECLS([IFLA_VF_STATS],
3755    [AC_DEFINE(HAVE_IFLA_VF_STATS, 1, [Define if IFLA_VF_STATS exists.])],
3756    [],
3757    [[#include <linux/if_link.h>]]
3758  )
3759
3760  AC_CHECK_LIB([mnl], [mnl_nlmsg_get_payload],
3761    [with_libmnl="yes"],
3762    [with_libmnl="no (symbol 'mnl_nlmsg_get_payload' not found)"],
3763    [$with_libmnl_libs]
3764  )
3765fi
3766
3767if test "x$with_libmnl" = "xyes"; then
3768  BUILD_WITH_LIBMNL_CFLAGS="$with_libmnl_cflags"
3769  BUILD_WITH_LIBMNL_LIBS="$with_libmnl_libs"
3770fi
3771AC_SUBST([BUILD_WITH_LIBMNL_CFLAGS])
3772AC_SUBST([BUILD_WITH_LIBMNL_LIBS])
3773AM_CONDITIONAL([HAVE_LIBMNL], [test "x$with_libmnl" = "xyes"])
3774# }}}
3775
3776# --with-libnetapp {{{
3777AC_ARG_VAR([LIBNETAPP_CPPFLAGS], [C preprocessor flags required to build with libnetapp])
3778AC_ARG_VAR([LIBNETAPP_LDFLAGS],  [Linker flags required to build with libnetapp])
3779AC_ARG_VAR([LIBNETAPP_LIBS],     [Other libraries required to link against libnetapp])
3780AC_ARG_WITH([libnetapp],
3781  [AS_HELP_STRING([--with-libnetapp@<:@=PREFIX@:>@], [Path to libnetapp.])],
3782  [
3783   if test -d "$withval"; then
3784     LIBNETAPP_CPPFLAGS="$LIBNETAPP_CPPFLAGS -I$withval/include"
3785     LIBNETAPP_LDFLAGS="$LIBNETAPP_LDFLAGS -L$withval/lib"
3786     with_libnetapp="yes"
3787   else
3788     with_libnetapp="$withval"
3789   fi
3790  ],
3791  [with_libnetapp="yes"]
3792)
3793
3794SAVE_CPPFLAGS="$CPPFLAGS"
3795SAVE_LDFLAGS="$LDFLAGS"
3796CPPFLAGS="$CPPFLAGS $LIBNETAPP_CPPFLAGS"
3797LDFLAGS="$LDFLAGS $LIBNETAPP_LDFLAGS"
3798
3799if test "x$with_libnetapp" = "xyes"; then
3800  AC_CHECK_HEADERS([netapp_api.h],
3801    [with_libnetapp="yes"],
3802    [with_libnetapp="no (netapp_api.h not found)"]
3803  )
3804fi
3805
3806if test "x$with_libnetapp" = "xyes"; then
3807  if test "x$LIBNETAPP_LIBS" = "x"; then
3808    LIBNETAPP_LIBS="$PTHREAD_LIBS -lxml -ladt -lssl -lm -lcrypto -lz"
3809  fi
3810
3811  AC_CHECK_LIB([netapp], [na_server_invoke_elem],
3812    [with_libnetapp="yes"],
3813    [with_libnetapp="no (symbol na_server_invoke_elem not found)"],
3814    [$LIBNETAPP_LIBS]
3815  )
3816
3817  LIBNETAPP_LIBS="-lnetapp $LIBNETAPP_LIBS"
3818fi
3819
3820CPPFLAGS="$SAVE_CPPFLAGS"
3821LDFLAGS="$SAVE_LDFLAGS"
3822
3823AC_SUBST([LIBNETAPP_CPPFLAGS])
3824AC_SUBST([LIBNETAPP_LDFLAGS])
3825AC_SUBST([LIBNETAPP_LIBS])
3826# }}}
3827
3828# --with-libnetsnmp {{{
3829AC_ARG_WITH([libnetsnmp],
3830  [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to libnetsnmp.])],
3831  [
3832    if test "x$withval" = "xno"; then
3833     with_libnetsnmp="no"
3834    else if test "x$withval" = "xyes"; then
3835     with_libnetsnmp="yes"
3836    else
3837      with_libnetsnmp_cppflags="-I$withval/include"
3838      with_libnetsnmp_ldflags="-I$withval/lib"
3839      with_libnetsnmp="yes"
3840    fi; fi
3841  ],
3842  [with_libnetsnmp="yes"]
3843)
3844
3845if test "x$with_libnetsnmp" = "xyes"; then
3846  SAVE_CPPFLAGS="$CPPFLAGS"
3847  CPPFLAGS="$CPPFLAGS $with_libnetsnmp_cppflags"
3848
3849  AC_CHECK_HEADERS([net-snmp/net-snmp-config.h],
3850    [with_libnetsnmp="yes"],
3851    [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"]
3852  )
3853
3854  AC_CHECK_HEADERS([net-snmp/net-snmp-includes.h],
3855    [with_libnetsnmp="yes"],
3856    [with_libnetsnmp="no (net-snmp/net-snmp-includes.h not found)"],
3857    [[
3858      #if HAVE_NET_SNMP_NET_SNMP_CONFIG_H
3859      # include <net-snmp/net-snmp-config.h>
3860      #endif
3861    ]]
3862  )
3863
3864  CPPFLAGS="$SAVE_CPPFLAGS"
3865fi
3866
3867if test "x$with_libnetsnmp" = "xyes"; then
3868  SAVE_LDFLAGS="$LDFLAGS"
3869  LDFLAGS="$LDFLAGS $with_libnetsnmp_ldflags"
3870
3871  AC_CHECK_LIB([netsnmp], [init_snmp],
3872    [with_libnetsnmp="yes"],
3873    [with_libnetsnmp="no (libnetsnmp not found)"]
3874  )
3875
3876  LDFLAGS="$SAVE_LDFLAGS"
3877fi
3878
3879if test "x$with_libnetsnmp" = "xyes"; then
3880  SAVE_LDFLAGS="$LDFLAGS"
3881  LDFLAGS="$LDFLAGS $with_libnetsnmp_ldflags"
3882
3883  AC_CHECK_LIB([netsnmp], [netsnmp_get_version],
3884    [with_libnetsnmp="yes"],
3885    [with_libnetsnmp="no (couldn't get libnetsnmp version)"]
3886  )
3887
3888  LDFLAGS="$SAVE_LDFLAGS"
3889fi
3890
3891if test "x$with_libnetsnmp" = "xyes"; then
3892  SAVE_CPPFLAGS="$CPPFLAGS"
3893  SAVE_LDFLAGS="$LDFLAGS"
3894  SAVE_LIBS="$LIBS"
3895  CPPFLAGS="$CPPFLAGS $with_libnetsnmp_cppflags"
3896  if test "x$GCC" = "xyes"; then
3897    CPPFLAGS="$CPPFLAGS -Wall "
3898  fi
3899  LDFLAGS="$LDFLAGS $with_libnetsnmp_ldflags"
3900  LIBS="$LIBS -lnetsnmp"
3901
3902  AC_CACHE_CHECK([whether netsnmp library has old API],
3903    [c_cv_have_netsnmp_old_api],
3904    [
3905      AC_LINK_IFELSE(
3906        [
3907          AC_LANG_PROGRAM(
3908            [[
3909              #include <net-snmp/net-snmp-config.h>
3910              #include <net-snmp/net-snmp-includes.h>
3911            ]],
3912            [[
3913              netsnmp_variable_list *key = SNMP_MALLOC_TYPEDEF(netsnmp_variable_list);;
3914              int val;
3915              u_char type = ASN_INTEGER;
3916              snmp_set_var_value(key, &val, sizeof(val));
3917              snmp_set_var_typed_value(key, type, &val, sizeof(val));
3918              return 0;
3919            ]]
3920          )
3921        ],
3922        [c_cv_have_netsnmp_old_api="no"],
3923        [c_cv_have_netsnmp_old_api="yes"]
3924      )
3925    ]
3926  )
3927
3928  if test "x$c_cv_have_netsnmp_old_api" = "xyes"; then
3929    AC_DEFINE([HAVE_NETSNMP_OLD_API], [1],
3930              ["Define 1 if you have old netsnmp API]")
3931  fi
3932
3933  CPPFLAGS="$SAVE_CPPFLAGS"
3934  LDFLAGS="$SAVE_LDFLAGS"
3935  LIBS="$SAVE_LIBS"
3936fi
3937
3938if test "x$with_libnetsnmp" = "xyes"; then
3939  BUILD_WITH_LIBNETSNMP_CPPFLAGS="$with_libnetsnmp_cppflags"
3940  BUILD_WITH_LIBNETSNMP_LDFLAGS="$with_libnetsnmp_ldflags"
3941  BUILD_WITH_LIBNETSNMP_LIBS="-lnetsnmp"
3942fi
3943
3944AC_SUBST([BUILD_WITH_LIBNETSNMP_CPPFLAGS])
3945AC_SUBST([BUILD_WITH_LIBNETSNMP_LDFLAGS])
3946AC_SUBST([BUILD_WITH_LIBNETSNMP_LIBS])
3947# }}}
3948
3949# --with-libnetsnmpagent {{{
3950AC_ARG_WITH([libnetsnmpagent],
3951  [AS_HELP_STRING([--with-libnetsnmpagent@<:@=PREFIX@:>@], [Path to libnetsnmpagent.])],
3952  [
3953    if test "x$withval" = "xno"; then
3954      with_libnetsnmpagent="no"
3955    else if test "x$withval" = "xyes"; then
3956      with_libnetsnmpagent="yes"
3957    else
3958      with_libnetsnmpagent_cppflags="-I$withval/include"
3959      with_libnetsnmpagent_ldflags="-I$withval/lib"
3960      with_libnetsnmpagent="yes"
3961    fi; fi
3962  ],
3963  [with_libnetsnmpagent="yes"]
3964)
3965
3966if test "x$with_libnetsnmpagent" = "xyes"; then
3967  SAVE_CPPFLAGS="$CPPFLAGS"
3968  CPPFLAGS="$CPPFLAGS $with_libnetsnmpagent_cppflags"
3969
3970  AC_CHECK_HEADERS([net-snmp/agent/net-snmp-agent-includes.h],
3971    [],
3972    [with_libnetsnmpagent="no (net-snmp/agent/net-snmp-agent-includes.h not found)"],
3973    [[
3974      #if HAVE_NET_SNMP_NET_SNMP_CONFIG_H
3975      # include <net-snmp/net-snmp-config.h>
3976      #endif
3977      #if HAVE_NET_SNMP_NET_SNMP_INCLUDES_H
3978      # include <net-snmp/net-snmp-includes.h>
3979      #endif
3980    ]]
3981  )
3982
3983  CPPFLAGS="$SAVE_CPPFLAGS"
3984fi
3985
3986if test "x$with_libnetsnmpagent" = "xyes"; then
3987  SAVE_LDFLAGS="$LDFLAGS"
3988  LDFLAGS="$LDFLAGS $with_libnetsnmpagent_ldflags"
3989
3990  # older versions of libnetsnmpagent fail to link
3991  # against the helpers library, so do that explicitly
3992  AC_CHECK_LIB([netsnmphelpers], [netsnmp_init_helpers],
3993    [libnetsnmphelpers="-lnetsnmphelpers"],
3994    [libnetsnmphelpers=""]
3995  )
3996
3997  AC_CHECK_LIB([netsnmpagent], [init_agent],
3998    [
3999      # libnetsnmp can be built without mib loading support
4000      AC_CHECK_LIB([netsnmp], [get_tree],
4001        [with_libnetsnmpagent="yes"],
4002        [with_libnetsnmpagent="no (libnetsnmp doesn't support mib loading)"]
4003      )
4004    ],
4005    [with_libnetsnmpagent="no (libnetsnmpagent not found)"],
4006    [$libnetsnmphelpers]
4007  )
4008
4009  LDFLAGS="$SAVE_LDFLAGS"
4010fi
4011
4012if test "x$with_libnetsnmpagent" = "xyes"; then
4013  BUILD_WITH_LIBNETSNMPAGENT_CPPFLAGS="$with_libnetsnmpagent_cppflags"
4014  BUILD_WITH_LIBNETSNMPAGENT_LDFLAGS="$with_libnetsnmpagent_ldflags"
4015  BUILD_WITH_LIBNETSNMPAGENT_LIBS="-lnetsnmpagent $libnetsnmphelpers"
4016fi
4017
4018AC_SUBST([BUILD_WITH_LIBNETSNMPAGENT_CPPFLAGS])
4019AC_SUBST([BUILD_WITH_LIBNETSNMPAGENT_LDFLAGS])
4020AC_SUBST([BUILD_WITH_LIBNETSNMPAGENT_LIBS])
4021# }}}
4022
4023# --with-liboping {{{
4024AC_ARG_WITH([liboping],
4025  [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
4026  [
4027    if test "x$withval" = "xyes"; then
4028      with_liboping="yes"
4029    else if test "x$withval" = "xno"; then
4030      with_liboping="no"
4031    else
4032      with_liboping="yes"
4033      LIBOPING_CPPFLAGS="-I$withval/include"
4034      LIBOPING_LDFLAGS="-L$withval/lib"
4035    fi; fi
4036  ],
4037  [with_liboping="yes"]
4038)
4039
4040SAVE_CPPFLAGS="$CPPFLAGS"
4041SAVE_LDFLAGS="$LDFLAGS"
4042CPPFLAGS="$CPPFLAGS $LIBOPING_CPPFLAGS"
4043LDFLAGS="$LDFLAGS $LIBOPING_LDFLAGS"
4044
4045if test "x$with_liboping" = "xyes"; then
4046  AC_CHECK_HEADERS([oping.h],
4047    [with_liboping="yes"],
4048    [with_liboping="no (oping.h not found)"]
4049  )
4050fi
4051
4052if test "x$with_liboping" = "xyes"; then
4053  AC_CHECK_LIB([oping], [ping_construct],
4054    [with_liboping="yes"],
4055    [with_liboping="no (symbol 'ping_construct' not found)"]
4056  )
4057fi
4058
4059CPPFLAGS="$SAVE_CPPFLAGS"
4060LDFLAGS="$SAVE_LDFLAGS"
4061
4062if test "x$with_liboping" = "xyes"; then
4063  BUILD_WITH_LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS"
4064  BUILD_WITH_LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS"
4065fi
4066
4067AC_SUBST([BUILD_WITH_LIBOPING_CPPFLAGS])
4068AC_SUBST([BUILD_WITH_LIBOPING_LDFLAGS])
4069# }}}
4070
4071# --with-oracle {{{
4072AC_ARG_WITH([oracle],
4073  [AS_HELP_STRING([--with-oracle@<:@=ORACLE_HOME@:>@], [Path to Oracle.])],
4074  [
4075    if test "x$withval" = "xyes"; then
4076      if test "x$ORACLE_HOME" = "x"; then
4077        AC_MSG_WARN([Use of the Oracle library has been forced, but the environment variable ORACLE_HOME is not set.])
4078      fi
4079      with_oracle="yes"
4080    else if test "x$withval" = "xno"; then
4081      with_oracle="no"
4082    else
4083      with_oracle="yes"
4084      ORACLE_HOME="$withval"
4085    fi; fi
4086  ],
4087  [
4088    if test "x$ORACLE_HOME" = "x"; then
4089      with_oracle="no (ORACLE_HOME is not set)"
4090    else
4091      with_oracle="yes"
4092    fi
4093  ]
4094)
4095
4096if test "x$ORACLE_HOME" != "x"; then
4097  with_oracle_cppflags="-I$ORACLE_HOME/rdbms/public"
4098  if test -e "$ORACLE_HOME/lib/ldflags"; then
4099    with_oracle_libs=`cat "$ORACLE_HOME/lib/ldflags"`
4100  fi
4101  with_oracle_libs="-L$ORACLE_HOME/lib -lclntsh"
4102fi
4103
4104if test "x$with_oracle" = "xyes"; then
4105  SAVE_CPPFLAGS="$CPPFLAGS"
4106  CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
4107
4108  AC_CHECK_HEADERS([oci.h],
4109    [with_oracle="yes"],
4110    [with_oracle="no (oci.h not found)"]
4111  )
4112
4113  CPPFLAGS="$SAVE_CPPFLAGS"
4114fi
4115
4116if test "x$with_oracle" = "xyes"; then
4117  SAVE_CPPFLAGS="$CPPFLAGS"
4118  SAVE_LIBS="$LIBS"
4119  CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
4120  LIBS="$LIBS $with_oracle_libs"
4121
4122  AC_CHECK_FUNC([OCIEnvCreate],
4123    [with_oracle="yes"],
4124    [with_oracle="no (Symbol 'OCIEnvCreate' not found)"]
4125  )
4126
4127  CPPFLAGS="$SAVE_CPPFLAGS"
4128  LIBS="$SAVE_LIBS"
4129fi
4130
4131if test "x$with_oracle" = "xyes"; then
4132  BUILD_WITH_ORACLE_CPPFLAGS="$with_oracle_cppflags"
4133  BUILD_WITH_ORACLE_LIBS="$with_oracle_libs"
4134fi
4135
4136AC_SUBST([BUILD_WITH_ORACLE_CPPFLAGS])
4137AC_SUBST([BUILD_WITH_ORACLE_LIBS])
4138# }}}
4139
4140# --with-libowcapi {{{
4141AC_ARG_WITH([libowcapi],
4142  [AS_HELP_STRING([--with-libowcapi@<:@=PREFIX@:>@], [Path to libowcapi.])],
4143  [
4144    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4145      with_libowcapi_cppflags="-I$withval/include"
4146      with_libowcapi_ldflags="-L$withval/lib"
4147      with_libowcapi="yes"
4148    else
4149      with_libowcapi="$withval"
4150    fi
4151  ],
4152  [with_libowcapi="yes"]
4153)
4154
4155if test "x$with_libowcapi" = "xyes"; then
4156  SAVE_CPPFLAGS="$CPPFLAGS"
4157  CPPFLAGS="$CPPFLAGS $with_libowcapi_cppflags"
4158
4159  AC_CHECK_HEADERS([owcapi.h],
4160    [with_libowcapi="yes"],
4161    [with_libowcapi="no (owcapi.h not found)"]
4162  )
4163
4164  CPPFLAGS="$SAVE_CPPFLAGS"
4165fi
4166
4167if test "x$with_libowcapi" = "xyes"; then
4168  SAVE_LDFLAGS="$LDFLAGS"
4169  LDFLAGS="$LDFLAGS $with_libowcapi_ldflags"
4170
4171  AC_CHECK_LIB([owcapi], [OW_get],
4172    [with_libowcapi="yes"],
4173    [with_libowcapi="no (libowcapi not found)"]
4174  )
4175
4176  LDFLAGS="$SAVE_LDFLAGS"
4177fi
4178
4179if test "x$with_libowcapi" = "xyes"; then
4180  BUILD_WITH_LIBOWCAPI_CPPFLAGS="$with_libowcapi_cppflags"
4181  BUILD_WITH_LIBOWCAPI_LDFLAGS="$with_libowcapi_ldflags"
4182  BUILD_WITH_LIBOWCAPI_LIBS="-lowcapi"
4183fi
4184
4185AC_SUBST([BUILD_WITH_LIBOWCAPI_CPPFLAGS])
4186AC_SUBST([BUILD_WITH_LIBOWCAPI_LDFLAGS])
4187AC_SUBST([BUILD_WITH_LIBOWCAPI_LIBS])
4188# }}}
4189
4190# --with-libpcap {{{
4191AC_ARG_WITH([libpcap],
4192  [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
4193  [
4194    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4195      with_libpcap_cppflags="-I$withval/include"
4196      with_libpcap_ldflags="$LDFLAGS -L$withval/lib"
4197      with_libpcap="yes"
4198    else
4199      with_libpcap="$withval"
4200    fi
4201  ],
4202  [with_libpcap="yes"]
4203)
4204
4205if test "x$with_libpcap" = "xyes"; then
4206  SAVE_CPPFLAGS="$CPPFLAGS"
4207  CPPFLAGS="$CPPFLAGS $with_libpcap_cppflags"
4208
4209  AC_CHECK_HEADERS([pcap.h],
4210    [with_libpcap="yes"],
4211    [with_libpcap="no (pcap.h not found)"]
4212  )
4213
4214  CPPFLAGS="$SAVE_CPPFLAGS"
4215fi
4216
4217if test "x$with_libpcap" = "xyes"; then
4218  SAVE_LDFLAGS="$LDFLAGS"
4219  LDFLAGS="$LDFLAGS $with_libpcap_ldflags"
4220
4221  AC_CHECK_LIB([pcap], [pcap_open_live],
4222    [with_libpcap="yes"],
4223    [with_libpcap="no (libpcap not found)"]
4224  )
4225
4226  LDFLAGS="$SAVE_LDFLAGS"
4227fi
4228
4229if test "x$with_libpcap" = "xyes"; then
4230  AC_CACHE_CHECK([whether libpcap has PCAP_ERROR_IFACE_NOT_UP],
4231    [c_cv_libpcap_have_pcap_error_iface_not_up],
4232    [
4233      AC_COMPILE_IFELSE(
4234        [
4235          AC_LANG_PROGRAM(
4236            [[#include <pcap.h>]],
4237            [[
4238              int val = PCAP_ERROR_IFACE_NOT_UP;
4239              return val;
4240            ]]
4241          )
4242        ],
4243        [c_cv_libpcap_have_pcap_error_iface_not_up="yes"],
4244        [c_cv_libpcap_have_pcap_error_iface_not_up="no"]
4245      )
4246    ]
4247  )
4248fi
4249
4250if test "x$c_cv_libpcap_have_pcap_error_iface_not_up" != "xyes"; then
4251  with_libpcap="no (pcap.h misses PCAP_ERROR_IFACE_NOT_UP)"
4252fi
4253
4254if test "x$with_libpcap" = "xyes"; then
4255  BUILD_WITH_LIBPCAP_CPPFLAGS="$with_libpcap_cppflags"
4256  BUILD_WITH_LIBPCAP_LDFLAGS="$with_libpcap_ldflags"
4257  BUILD_WITH_LIBPCAP_LIBS="-lpcap"
4258fi
4259
4260AC_SUBST([BUILD_WITH_LIBPCAP_CPPFLAGS])
4261AC_SUBST([BUILD_WITH_LIBPCAP_LDFLAGS])
4262AC_SUBST([BUILD_WITH_LIBPCAP_LIBS])
4263# }}}
4264
4265# --with-libperl {{{
4266AC_ARG_WITH([libperl],
4267  [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
4268  [
4269    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4270      LDFLAGS="$LDFLAGS -L$withval/lib"
4271      CPPFLAGS="$CPPFLAGS -I$withval/include"
4272      with_libperl="yes"
4273    else
4274      with_libperl="$withval"
4275    fi
4276  ],
4277  [with_libperl="yes"]
4278)
4279
4280AC_ARG_VAR([PERL], [path to Perl interpreter])
4281AC_PATH_PROG([PERL], [perl])
4282
4283if test "x$PERL" = "x"; then
4284  with_libperl="no (no Perl interpreter found)"
4285fi
4286
4287if test "x$with_libperl" = "xyes"; then
4288  SAVE_CFLAGS="$CFLAGS"
4289  SAVE_LIBS="$LIBS"
4290  dnl ARCHFLAGS="" -> disable multi -arch on OSX (see Config_heavy.pl:fetch_string)
4291  PERL_CFLAGS=`ARCHFLAGS="" $PERL -MExtUtils::Embed -e perl_inc`
4292  PERL_LIBS=`ARCHFLAGS="" $PERL -MExtUtils::Embed -e ldopts`
4293  CFLAGS="$CFLAGS $PERL_CFLAGS"
4294  LIBS="$LIBS $PERL_LIBS"
4295
4296  AC_CACHE_CHECK([for libperl],
4297    [c_cv_have_libperl],
4298    [
4299      AC_LINK_IFELSE(
4300        [
4301          AC_LANG_PROGRAM(
4302            [[
4303              #define PERL_NO_GET_CONTEXT
4304              #include <EXTERN.h>
4305              #include <perl.h>
4306              #include <XSUB.h>
4307            ]],
4308            [[
4309              dTHX;
4310              load_module (PERL_LOADMOD_NOIMPORT,
4311                newSVpv ("Collectd::Plugin::FooBar", 24),
4312                Nullsv);
4313            ]]
4314          )
4315        ],
4316        [c_cv_have_libperl="yes"],
4317        [c_cv_have_libperl="no"]
4318      )
4319    ]
4320  )
4321
4322  CFLAGS="$SAVE_CFLAGS"
4323  LIBS="$SAVE_LIBS"
4324
4325  if test "x$c_cv_have_libperl" = "xno"; then
4326    with_libperl="no"
4327  fi
4328fi
4329
4330if test "x$with_libperl" = "xyes"; then
4331  SAVE_CFLAGS="$CFLAGS"
4332  SAVE_LIBS="$LIBS"
4333  CFLAGS="$CFLAGS $PERL_CFLAGS"
4334  LIBS="$LIBS $PERL_LIBS"
4335
4336  AC_CACHE_CHECK([if Perl supports ithreads],
4337    [c_cv_have_perl_ithreads],
4338    [
4339      AC_LINK_IFELSE(
4340        [
4341          AC_LANG_PROGRAM(
4342            [[
4343              #include <EXTERN.h>
4344              #include <perl.h>
4345              #include <XSUB.h>
4346
4347              #if !defined(USE_ITHREADS)
4348              # error "Perl does not support ithreads!"
4349              #endif /* !defined(USE_ITHREADS) */
4350            ]],
4351            []
4352          )
4353        ],
4354        [c_cv_have_perl_ithreads="yes"],
4355        [c_cv_have_perl_ithreads="no"]
4356      )
4357    ]
4358  )
4359
4360  CFLAGS="$SAVE_CFLAGS"
4361  LIBS="$SAVE_LIBS"
4362fi
4363
4364if test "x$with_libperl" = "xyes"; then
4365  # trigger an error if Perl_load_module*() uses __attribute__nonnull__(3)
4366  # (see issues #41 and #42)
4367  SAVE_CFLAGS="$CFLAGS"
4368  SAVE_LIBS="$LIBS"
4369  CFLAGS="$CFLAGS $PERL_CFLAGS"
4370  if test "x$GCC" = "xyes"; then
4371    CFLAGS="$CFLAGS -Wall "
4372  fi
4373  LIBS="$LIBS $PERL_LIBS"
4374
4375  AC_CACHE_CHECK([for broken Perl_load_module()],
4376    [c_cv_have_broken_perl_load_module],
4377    [
4378      AC_LINK_IFELSE(
4379        [
4380          AC_LANG_PROGRAM(
4381            [[
4382              #define PERL_NO_GET_CONTEXT
4383              #include <EXTERN.h>
4384              #include <perl.h>
4385              #include <XSUB.h>
4386            ]],
4387            [[
4388              dTHX;
4389              load_module (PERL_LOADMOD_NOIMPORT,
4390                newSVpv ("Collectd::Plugin::FooBar", 24),
4391                Nullsv);
4392            ]]
4393          )
4394        ],
4395        [c_cv_have_broken_perl_load_module="no"],
4396        [c_cv_have_broken_perl_load_module="yes"]
4397      )
4398    ]
4399  )
4400
4401  CFLAGS="$SAVE_CFLAGS"
4402  LIBS="$SAVE_LIBS"
4403fi
4404
4405if test "x$c_cv_have_broken_perl_load_module" = "xyes"; then
4406  PERL_CFLAGS="$PERL_CFLAGS -Wno-nonnull"
4407fi
4408
4409if test "x$with_libperl" = "xyes"; then
4410  SAVE_CFLAGS="$CFLAGS"
4411  SAVE_LIBS="$LIBS"
4412  CFLAGS="$CFLAGS $PERL_CFLAGS"
4413  LIBS="$LIBS $PERL_LIBS"
4414
4415  AC_CHECK_MEMBER(
4416    [struct mgvtbl.svt_local],
4417    [have_struct_mgvtbl_svt_local="yes"],
4418    [have_struct_mgvtbl_svt_local="no"],
4419    [[
4420      #include <EXTERN.h>
4421      #include <perl.h>
4422      #include <XSUB.h>
4423    ]]
4424  )
4425
4426  if test "x$have_struct_mgvtbl_svt_local" = "xyes"; then
4427    AC_DEFINE([HAVE_PERL_STRUCT_MGVTBL_SVT_LOCAL], [1], [Define if Perls struct mgvtbl has member svt_local.])
4428  fi
4429
4430  CFLAGS="$SAVE_CFLAGS"
4431  LIBS="$SAVE_LIBS"
4432fi
4433AC_SUBST([PERL_CFLAGS])
4434AC_SUBST([PERL_LIBS])
4435
4436# }}}
4437
4438
4439# --with-libpmwapi {{{
4440AC_ARG_WITH([libpmwapi],
4441  [AS_HELP_STRING([--with-libpmwapi@<:@=PREFIX@:>@], [Path to libpmwapi.])],
4442  [
4443    if test "x$withval" = "xyes" || test "x$withval" = "xno"; then
4444      with_libpmwapi="$withval"
4445    else
4446      with_libpmwapi_cppflags="-I$withval/include"
4447      with_libpmwapi_ldflags="-L$withval/lib64"
4448      with_libpmwapi="yes"
4449    fi
4450  ],
4451  [with_libpmwapi="yes"]
4452)
4453
4454if test "x$with_libpmwapi" = "xyes"; then
4455  SAVE_CPPFLAGS="$CPPFLAGS"
4456  CPPFLAGS="$CPPFLAGS $with_libpmwapi_cppflags"
4457
4458  AC_CHECK_HEADERS([pmw_api.h],
4459    [with_libpmwapi="yes"],
4460    [with_libpmwapi="no (pmw_api.h not found)"]
4461  )
4462
4463  CPPFLAGS="$SAVE_CPPFLAGS"
4464fi
4465
4466if test "x$with_libpmwapi" = "xyes"; then
4467  SAVE_LDFLAGS="$LDFLAGS"
4468  LDFLAGS="$LDFLAGS $with_libpmwapi_ldflags"
4469
4470  AC_CHECK_LIB([pmwapi], [PMWAPIGetDIMMCount],
4471    [with_libpmwapis="yes"],
4472    [with_libpmwapi="no (symbol 'PMWAPIGetDIMMCount' not found)"],
4473    [-lpmwcollect]
4474  )
4475
4476  AC_CHECK_LIB([pmwapi], [PMWAPIStart],
4477    [with_libpmwapi="yes"],
4478    [with_libpmwapi="no (symbol 'PMWAPIStart' not found)"],
4479    [-lpmwcollect]
4480  )
4481
4482  AC_CHECK_LIB([pmwapi], [PMWAPIStop],
4483    [with_libpmwapi="yes"],
4484    [with_libpmwapi="no (symbol 'PMWAPIStop' not found)"],
4485    [-lpmwcollect]
4486  )
4487
4488  AC_CHECK_LIB([pmwapi], [PMWAPIRead],
4489    [with_libpmwapi="yes"],
4490    [with_libpmwapi="no (symbol 'PMWAPIRead' not found)"],
4491    [-lpmwcollect]
4492  )
4493
4494  LDFLAGS="$SAVE_LDFLAGS"
4495fi
4496
4497if test "x$with_libpmwapi" = "xyes"; then
4498  BUILD_WITH_LIBPMWAPI_CPPFLAGS="$with_libpmwapi_cppflags"
4499  BUILD_WITH_LIBPMWAPI_LDFLAGS="$with_libpmwapi_ldflags"
4500fi
4501
4502AC_SUBST([BUILD_WITH_LIBPMWAPI_CPPFLAGS])
4503AC_SUBST([BUILD_WITH_LIBPMWAPI_LDFLAGS])
4504# }}}
4505
4506# --with-libpq {{{
4507with_pg_config="pg_config"
4508AC_ARG_WITH([libpq],
4509  [AS_HELP_STRING([--with-libpq@<:@=PREFIX@:>@], [Path to libpq.])],
4510  [
4511    if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
4512      with_libpq="$withval"
4513    else
4514      if test -f "$withval" && test -x "$withval"; then
4515        with_pg_config="$withval"
4516      else if test -x "$withval/bin/pg_config"; then
4517        with_pg_config="$withval/bin/pg_config"
4518      fi; fi
4519      with_libpq="yes"
4520    fi
4521  ],
4522  [with_libpq="yes"]
4523)
4524
4525if test "x$with_libpq" = "xyes"; then
4526  with_libpq_includedir=`$with_pg_config --includedir 2> /dev/null`
4527  pg_config_status=$?
4528
4529  if test $pg_config_status -eq 0; then
4530    if test -n "$with_libpq_includedir"; then
4531      for dir in $with_libpq_includedir; do
4532        with_libpq_cppflags="$with_libpq_cppflags -I$dir"
4533      done
4534    fi
4535  else
4536    AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
4537  fi
4538
4539  SAVE_CPPFLAGS="$CPPFLAGS"
4540  CPPFLAGS="$CPPFLAGS $with_libpq_cppflags"
4541
4542  AC_CHECK_HEADERS([libpq-fe.h],
4543    [with_libpq="yes"],
4544    [with_libpq="no (libpq-fe.h not found)"]
4545  )
4546
4547  CPPFLAGS="$SAVE_CPPFLAGS"
4548fi
4549
4550if test "x$with_libpq" = "xyes"; then
4551  with_libpq_libdir=`$with_pg_config --libdir 2> /dev/null`
4552  pg_config_status=$?
4553
4554  if test $pg_config_status -eq 0
4555  then
4556    if test -n "$with_libpq_libdir"; then
4557      for dir in $with_libpq_libdir; do
4558        with_libpq_ldflags="$with_libpq_ldflags -L$dir"
4559      done
4560    fi
4561  else
4562    AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
4563  fi
4564
4565  SAVE_LDFLAGS="$LDFLAGS"
4566  LDFLAGS="$LDFLAGS $with_libpq_ldflags"
4567
4568  AC_CHECK_LIB([pq], [PQserverVersion],
4569    [with_libpq="yes"],
4570    [with_libpq="no (symbol 'PQserverVersion' not found)"])
4571
4572  LDFLAGS="$SAVE_LDFLAGS"
4573fi
4574
4575if test "x$with_libpq" = "xyes"; then
4576  BUILD_WITH_LIBPQ_CPPFLAGS="$with_libpq_cppflags"
4577  BUILD_WITH_LIBPQ_LDFLAGS="$with_libpq_ldflags"
4578  BUILD_WITH_LIBPQ_LIBS="-lpq"
4579fi
4580
4581AC_SUBST([BUILD_WITH_LIBPQ_CPPFLAGS])
4582AC_SUBST([BUILD_WITH_LIBPQ_LDFLAGS])
4583AC_SUBST([BUILD_WITH_LIBPQ_LIBS])
4584# }}}
4585
4586# --with-libpqos {{{
4587AC_ARG_WITH([libpqos],
4588  [AS_HELP_STRING([--with-libpqos@<:@=PREFIX@:>@], [Path to libpqos.])],
4589  [
4590    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4591      with_libpqos_cppflags="-I$withval/include"
4592      with_libpqos_ldflags="-L$withval/lib"
4593      with_libpqos="yes"
4594    else
4595      with_libpqos="$withval"
4596    fi
4597  ],
4598  [with_libpqos="yes"]
4599)
4600
4601if test "x$with_libpqos" = "xyes"; then
4602  SAVE_CPPFLAGS="$CPPFLAGS"
4603  CPPFLAGS="$CPPFLAGS $with_libpqos_cppflags"
4604
4605  AC_CHECK_HEADERS([pqos.h],
4606    [with_libpqos="yes"],
4607    [with_libpqos="no (pqos.h not found)"]
4608  )
4609
4610  CPPFLAGS="$SAVE_CPPFLAGS"
4611fi
4612
4613if test "x$with_libpqos" = "xyes"; then
4614  SAVE_LDFLAGS="$LDFLAGS"
4615  LDFLAGS="$LDFLAGS $with_libpqos_ldflags"
4616
4617  AC_CHECK_LIB([pqos], [pqos_init],
4618    [with_libpqos="yes"],
4619    [with_libpqos="no (Can't find libpqos)"]
4620  )
4621
4622  LDFLAGS="$SAVE_LDFLAGS"
4623fi
4624
4625if test "x$with_libpqos" = "xyes"; then
4626  SAVE_CPPFLAGS="$CPPFLAGS"
4627  CPPFLAGS="$CPPFLAGS $with_libpqos_cppflags"
4628  AC_PREPROC_IFELSE(
4629    [
4630      AC_LANG_SOURCE(
4631        [[
4632          #include <pqos.h>
4633          #if PQOS_VERSION < 106
4634          #error "required PQOS version >= 1.06"
4635          #endif
4636        ]]
4637      )
4638    ],
4639    [with_libpqos="yes"],
4640    [with_libpqos="no (pqos library version 1.06 or higher is required)"]
4641  )
4642
4643  CPPFLAGS="$SAVE_CPPFLAGS"
4644fi
4645
4646if test "x$with_libpqos" = "xyes"; then
4647  BUILD_WITH_LIBPQOS_CPPFLAGS="$with_libpqos_cppflags"
4648  BUILD_WITH_LIBPQOS_LDFLAGS="$with_libpqos_ldflags"
4649  BUILD_WITH_LIBPQOS_LIBS="-lpqos"
4650fi
4651
4652AC_SUBST([BUILD_WITH_LIBPQOS_CPPFLAGS])
4653AC_SUBST([BUILD_WITH_LIBPQOS_LDFLAGS])
4654AC_SUBST([BUILD_WITH_LIBPQOS_LIBS])
4655# }}}
4656
4657# --with-libjansson {{{
4658AC_ARG_WITH([libjansson],
4659[AS_HELP_STRING([--with-libjansson@<:@=PREFIX@:>@], [Path to libjansson.])],
4660[
4661  if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4662   with_libjansson_cppflags="-I$withval/include"
4663   with_libjansson_ldflags="-L$withval/lib"
4664   with_libjansson="yes"
4665  else
4666      with_libjansson="$withval"
4667  fi
4668],
4669  [with_libjansson="yes"]
4670)
4671
4672if test "x$with_libjansson" = "xyes"; then
4673  SAVE_CPPFLAGS="$CPPFLAGS"
4674  CPPFLAGS="$CPPFLAGS $with_libjansson_cppflags"
4675
4676  AC_CHECK_HEADERS([jansson.h],
4677    [with_libjansson="yes"],
4678    [with_libjansson="no (jansson.h not found)"]
4679  )
4680 CPPFLAGS="$SAVE_CPPFLAGS"
4681fi
4682if test "x$with_libjansson" = "xyes"; then
4683  SAVE_LDFLAGS="$LDFLAGS"
4684  LDFLAGS="$LDFLAGS $with_libjansson_ldflags"
4685
4686  AC_CHECK_LIB([jansson], [json_loads],
4687    [with_libjansson="yes"],
4688    [with_libjansson="no (symbol 'json_loads' not found)"]
4689  )
4690
4691  LDFLAGS="$SAVE_LDFLAGS"
4692fi
4693
4694BUILD_WITH_LIBJANSSON_CPPFLAGS="$with_libjansson_cppflags"
4695BUILD_WITH_LIBJANSSON_LDFLAGS="$with_libjansson_ldflags"
4696BUILD_WITH_LIBJANSSON_LIBS="-ljansson"
4697AC_SUBST(BUILD_WITH_LIBJANSSON_CPPFLAGS)
4698AC_SUBST(BUILD_WITH_LIBJANSSON_LDFLAGS)
4699AC_SUBST(BUILD_WITH_LIBJANSSON_LIBS)
4700# }}}
4701
4702# --with-libjevents {{{
4703with_libjevents_cppflags=""
4704with_libjevents_ldflags=""
4705AC_ARG_WITH([libjevents],
4706  [AS_HELP_STRING([--with-libjevents@<:@=PREFIX@:>@], [Path to libjevents.])],
4707  [
4708    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4709      with_libjevents_cppflags="-I$withval/include"
4710      with_libjevents_ldflags="-L$withval/lib"
4711      with_libjevents="yes"
4712    else
4713      with_libjevents="$withval"
4714    fi
4715  ],
4716  [with_libjevents="yes"]
4717)
4718
4719if test "x$with_libjevents" = "xyes"; then
4720  SAVE_CPPFLAGS="$CPPFLAGS"
4721  CPPFLAGS="$CPPFLAGS $with_libjevents_cppflags"
4722
4723  AC_CHECK_HEADERS([jevents.h], [with_libjevents="yes"], [with_libjevents="no (jevents.h not found)"])
4724
4725  CPPFLAGS="$SAVE_CPPFLAGS"
4726fi
4727if test "x$with_libjevents" = "xyes"; then
4728  SAVE_LDFLAGS="$LDFLAGS"
4729  LDFLAGS="$LDFLAGS $with_libjevents_ldflags"
4730
4731  AC_CHECK_LIB([jevents], [json_events], [with_libjevents="yes"], [with_libjevents="no (Can't find libjevents)"])
4732
4733  LDFLAGS="$SAVE_LDFLAGS"
4734fi
4735if test "x$with_libjevents" = "xyes"; then
4736  SAVE_LDFLAGS="$LDFLAGS"
4737  LDFLAGS="$LDFLAGS $with_libjevents_ldflags"
4738
4739  AC_CHECK_LIB([jevents], [event_scaled_value_sum], [with_libjevents="yes"], [with_libjevents="no (libjevents is too old)"])
4740
4741  LDFLAGS="$SAVE_LDFLAGS"
4742fi
4743if test "x$with_libjevents" = "xyes"; then
4744  BUILD_WITH_LIBJEVENTS_CPPFLAGS="$with_libjevents_cppflags"
4745  BUILD_WITH_LIBJEVENTS_LDFLAGS="$with_libjevents_ldflags"
4746  BUILD_WITH_LIBJEVENTS_LIBS="-ljevents"
4747fi
4748AC_SUBST([BUILD_WITH_LIBJEVENTS_CPPFLAGS])
4749AC_SUBST([BUILD_WITH_LIBJEVENTS_LDFLAGS])
4750AC_SUBST([BUILD_WITH_LIBJEVENTS_LIBS])
4751# }}}
4752
4753# --with-libprotobuf {{{
4754with_libprotobuf_cppflags=""
4755with_libprotobuf_ldflags=""
4756AC_ARG_WITH([libprotobuf],
4757  [AS_HELP_STRING([--with-libprotobuf@<:@=PREFIX@:>@], [Path to libprotobuf.])],
4758  [
4759    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4760      with_libprotobuf_cppflags="-I$withval/include"
4761      with_libprotobuf_ldflags="-L$withval/lib"
4762      with_libprotobuf="yes"
4763    fi
4764    if test "x$withval" = "xno"; then
4765      with_libprotobuf="no (disabled on command line)"
4766    fi
4767  ],
4768  [withval="yes"]
4769)
4770
4771if test "x$withval" = "xyes"; then
4772  PKG_CHECK_MODULES([PROTOBUF], [protobuf],
4773    [with_libprotobuf="yes"],
4774    [with_libprotobuf="no (pkg-config could not find libprotobuf)"]
4775  )
4776fi
4777
4778if test "x$withval" != "xno"; then
4779  SAVE_LDFLAGS="$LDFLAGS"
4780  SAVE_LIBS="$LIBS"
4781  LDFLAGS="$with_libprotobuf_ldflags"
4782  LIBS="$PROTOBUF_LIBS $LIBS"
4783  AC_LANG_PUSH([C++])
4784  AC_CHECK_LIB([protobuf], [main],
4785    [
4786      SAVE_CPPFLAGS="$CPPFLAGS"
4787      CPPFLAGS="-std=c++11 $with_libprotobuf_cppflags $PROTOBUF_CFLAGS"
4788      if test "x$PROTOBUF_LIBS" = "x"
4789      then
4790        PROTOBUF_LIBS="-lprotobuf"
4791      fi
4792      AC_CHECK_HEADERS([google/protobuf/util/time_util.h],
4793        [with_libprotobuf="yes"],
4794        [with_libprotobuf="no (<google/protobuf/util/time_util.h> not found)"]
4795      )
4796      CPPFLAGS="$SAVE_CPPFLAGS"
4797    ],
4798    [with_libprotobuf="no (libprotobuf not found)"]
4799  )
4800  AC_LANG_POP([C++])
4801  LDFLAGS="$SAVE_LDFLAGS"
4802  LIBS="$SAVE_LIBS"
4803fi
4804
4805BUILD_WITH_LIBPROTOBUF_CPPFLAGS="$with_libprotobuf_cppflags $PROTOBUF_CFLAGS"
4806BUILD_WITH_LIBPROTOBUF_LDFLAGS="$with_libprotobuf_ldflags"
4807BUILD_WITH_LIBPROTOBUF_LIBS="$PROTOBUF_LIBS"
4808AC_SUBST([BUILD_WITH_LIBPROTOBUF_CPPFLAGS])
4809AC_SUBST([BUILD_WITH_LIBPROTOBUF_LDFLAGS])
4810AC_SUBST([BUILD_WITH_LIBPROTOBUF_LIBS])
4811# }}}
4812
4813AC_ARG_VAR([PROTOC], [path to the protoc binary])
4814AC_PATH_PROG([PROTOC], [protoc])
4815have_protoc3="no"
4816if test "x$PROTOC" != "x"; then
4817  AC_MSG_CHECKING([for protoc 3.0.0+])
4818  if $PROTOC --version | $EGREP libprotoc.3 >/dev/null; then
4819    protoc3="yes (`$PROTOC --version`)"
4820    have_protoc3="yes"
4821  else
4822    protoc3="no (`$PROTOC --version`)"
4823  fi
4824  AC_MSG_RESULT([$protoc3])
4825fi
4826AM_CONDITIONAL([HAVE_PROTOC3], [test "x$have_protoc3" = "xyes"])
4827
4828# --with-libprotobuf-c {{{
4829AC_ARG_WITH([libprotobuf-c],
4830  [AS_HELP_STRING([--with-libprotobuf-c@<:@=PREFIX@:>@], [Path to libprotobuf-c.])],
4831  [
4832    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4833      with_libprotobuf_c_cppflags="-I$withval/include"
4834      with_libprotobuf_c_ldflags="-L$withval/lib"
4835      with_libprotobuf_c="yes"
4836    fi
4837
4838    if test "x$withval" = "xno"; then
4839      with_libprotobuf_c="no (disabled on command line)"
4840    fi
4841  ],
4842  [withval="yes"]
4843)
4844
4845if test "x$withval" = "xyes"; then
4846  PKG_CHECK_MODULES([PROTOBUF_C], [libprotobuf-c],
4847    [with_libprotobuf_c="yes"],
4848    [with_libprotobuf_c="no (pkg-config could not find libprotobuf-c)"]
4849  )
4850fi
4851
4852if test "x$withval" != "xno"; then
4853  SAVE_LDFLAGS="$LDFLAGS"
4854  SAVE_LIBS="$LIBS"
4855  LDFLAGS="$with_libprotobuf_c_ldflags"
4856  LIBS="$PROTOBUF_C_LIBS $LIBS"
4857  AC_CHECK_LIB([protobuf-c], [protobuf_c_message_pack],
4858    [
4859      SAVE_CPPFLAGS="$CPPFLAGS"
4860      CPPFLAGS="$with_libprotobuf_c_cppflags $PROTOBUF_C_CFLAGS"
4861      if test "x$PROTOBUF_C_LIBS" = "x"; then
4862        PROTOBUF_C_LIBS="-lprotobuf-c"
4863      fi
4864
4865      AC_CHECK_HEADERS([protobuf-c/protobuf-c.h google/protobuf-c/protobuf-c.h],
4866        [
4867          with_libprotobuf_c="yes"
4868          break
4869        ],
4870        [with_libprotobuf_c="no (<protobuf-c.h> not found)"]
4871      )
4872
4873      CPPFLAGS="$SAVE_CPPFLAGS"
4874    ],
4875    [with_libprotobuf_c="no (libprotobuf-c not found)"]
4876  )
4877  LDFLAGS="$SAVE_LDFLAGS"
4878  LIBS="$SAVE_LIBS"
4879fi
4880
4881BUILD_WITH_LIBPROTOBUF_C_CPPFLAGS="$with_libprotobuf_c_cppflags $PROTOBUF_C_CFLAGS"
4882BUILD_WITH_LIBPROTOBUF_C_LDFLAGS="$with_libprotobuf_c_ldflags"
4883BUILD_WITH_LIBPROTOBUF_C_LIBS="$PROTOBUF_C_LIBS"
4884AC_SUBST([BUILD_WITH_LIBPROTOBUF_C_CPPFLAGS])
4885AC_SUBST([BUILD_WITH_LIBPROTOBUF_C_LDFLAGS])
4886AC_SUBST([BUILD_WITH_LIBPROTOBUF_C_LIBS])
4887# }}}
4888
4889AC_ARG_VAR([PROTOC_C], [path to the protoc-c binary])
4890AC_PATH_PROG([PROTOC_C], [protoc-c])
4891if test "x$PROTOC_C" = "x"
4892then
4893  have_protoc_c="no (protoc-c compiler not found)"
4894else
4895  have_protoc_c="yes"
4896fi
4897
4898# --with-libpython {{{
4899AC_ARG_VAR([LIBPYTHON_CPPFLAGS], [Preprocessor flags for libpython])
4900AC_ARG_VAR([LIBPYTHON_LDFLAGS], [Linker flags for libpython])
4901AC_ARG_VAR([LIBPYTHON_LIBS], [Libraries for libpython])
4902
4903AC_ARG_WITH([libpython],
4904  [AS_HELP_STRING([--with-libpython], [if we should build with libpython @<:@default=yes@:>@])],
4905  [with_libpython="$withval"],
4906  [with_libpython="check"]
4907)
4908
4909if test "$with_libpython" != "no"; then
4910  if test "$LIBPYTHON_CPPFLAGS" = "" && test "$LIBPYTHON_LDFLAGS" = ""; then
4911    AC_ARG_VAR([PYTHON_CONFIG], [path to python-config])
4912    AC_PATH_PROGS([PYTHON_CONFIG],
4913      [python3-config python2-config python-config]
4914    )
4915    if test "$PYTHON_CONFIG" = ""; then
4916      if test "$with_libpython" = "yes"; then
4917        AC_MSG_ERROR([Unable to find python-config])
4918      fi
4919      with_libpython="no"
4920    fi
4921  fi
4922fi
4923
4924if test "$PYTHON_CONFIG" != ""; then
4925  LIBPYTHON_CPPFLAGS="`${PYTHON_CONFIG} --includes`"
4926  if test $? -ne 0; then
4927    with_libpython="no"
4928  fi
4929  LIBPYTHON_LDFLAGS="`${PYTHON_CONFIG} --ldflags --embed`" || LIBPYTHON_LDFLAGS="`${PYTHON_CONFIG} --ldflags`"
4930  if test $? -ne 0; then
4931    with_libpython="no"
4932  fi
4933  LIBPYTHON_LIBS="`${PYTHON_CONFIG} --libs --embed`" || LIBPYTHON_LIBS="`${PYTHON_CONFIG} --libs`"
4934  if test $? -ne 0; then
4935    with_libpython="no"
4936  fi
4937fi
4938
4939if test "$with_libpython" != "xno"; then
4940  SAVE_CPPFLAGS="$CPPFLAGS"
4941  SAVE_LDFLAGS="$LDFLAGS"
4942  SAVE_LIBS="$LIBS"
4943  CPPFLAGS="$LIBPYTHON_CPPFLAGS $CPPFLAGS"
4944  LDFLAGS="$LIBPYTHON_LDFLAGS $LDFLAGS"
4945  LIBS="$LIBPYTHON_LIBS $LIBS"
4946
4947  AC_CHECK_HEADERS([Python.h],
4948    [
4949      AC_MSG_CHECKING([for libpython])
4950      AC_LINK_IFELSE([AC_LANG_PROGRAM(
4951          [[#include <Python.h>]],
4952          [[Py_Initialize();]])
4953        ],
4954        [with_libpython="yes"],
4955        [with_libpython="no"]
4956      )
4957      AC_MSG_RESULT([$with_libpython])
4958    ],
4959    [with_libpython="no"]
4960  )
4961
4962  CPPFLAGS="$SAVE_CPPFLAGS"
4963  LDFLAGS="$SAVE_LDFLAGS"
4964  LIBS="$SAVE_LIBS"
4965fi
4966# }}} --with-libpython
4967
4968# --with-libqpid_proton {{{
4969AC_ARG_WITH([libqpid_proton],
4970  [AS_HELP_STRING([--with-libqpid_proton@<:@=PREFIX@:>@], [Path to libqpid_proton.])],
4971  [
4972    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4973      with_libqpid_proton_cppflags="-I$withval/include"
4974      with_libqpid_proton_ldflags="-L$withval/lib"
4975      with_libqpid_proton="yes"
4976    else
4977      with_libqpid_proton="$withval"
4978    fi
4979  ],
4980  [with_libqpid_proton="yes"]
4981)
4982
4983if test "x$with_libqpid_proton" = "xyes"; then
4984  SAVE_CPPFLAGS="$CPPFLAGS"
4985  CPPFLAGS="$CPPFLAGS $with_libqpid_proton_cppflags"
4986
4987  AC_CHECK_HEADERS([proton/proactor.h],
4988    [with_libqpid_proton="yes"],
4989    [with_libqpid_proton="no (proton/proactor.h not found)"]
4990  )
4991
4992  CPPFLAGS="$SAVE_CPPFLAGS"
4993fi
4994
4995if test "x$with_libqpid_proton" = "xyes"; then
4996  SAVE_LDFLAGS="$LDFLAGS"
4997  LDFLAGS="$LDFLAGS $with_libqpid_proton_ldflags"
4998
4999  AC_CHECK_LIB([qpid-proton], [pn_connection],
5000    [with_libqpid_proton="yes"],
5001    [with_libqpid_proton="no (Symbol 'pn_connection' not found)"])
5002
5003  LDFLAGS="$SAVE_LDFLAGS"
5004fi
5005
5006if test "x$with_libqpid_proton" = "xyes"; then
5007  BUILD_WITH_LIBQPIDPROTON_CPPFLAGS="$with_libqpid_proton_cppflags"
5008  BUILD_WITH_LIBQPIDPROTON_LDFLAGS="$with_libqpid_proton_ldflags"
5009  BUILD_WITH_LIBQPIDPROTON_LIBS="-lqpid-proton"
5010fi
5011
5012AC_SUBST(BUILD_WITH_LIBQPIDPROTON_CPPFLAGS)
5013AC_SUBST(BUILD_WITH_LIBQPIDPROTON_LDFLAGS)
5014AC_SUBST(BUILD_WITH_LIBQPIDPROTON_LIBS)
5015
5016# }}}
5017
5018# --with-librabbitmq {{{
5019AC_ARG_WITH([librabbitmq],
5020  [AS_HELP_STRING([--with-librabbitmq@<:@=PREFIX@:>@], [Path to librabbitmq.])],
5021  [
5022    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
5023      with_librabbitmq_cppflags="-I$withval/include"
5024      with_librabbitmq_ldflags="-L$withval/lib"
5025      with_librabbitmq="yes"
5026    else
5027      with_librabbitmq="$withval"
5028    fi
5029  ],
5030  [with_librabbitmq="yes"]
5031)
5032
5033if test "x$with_librabbitmq" = "xyes"; then
5034  SAVE_CPPFLAGS="$CPPFLAGS"
5035  CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
5036
5037  AC_CHECK_HEADERS([amqp.h],
5038    [with_librabbitmq="yes"],
5039    [with_librabbitmq="no (amqp.h not found)"]
5040  )
5041
5042  CPPFLAGS="$SAVE_CPPFLAGS"
5043fi
5044
5045if test "x$with_librabbitmq" = "xyes"; then
5046  # librabbitmq up to version 0.9.1 provides "library_errno", later
5047  # versions use "library_error". The library does not provide a version
5048  # macro :(.
5049
5050  SAVE_CPPFLAGS="$CPPFLAGS"
5051  CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
5052
5053  AC_CHECK_MEMBERS([amqp_rpc_reply_t.library_errno],
5054    [],
5055    [],
5056    [[
5057      #include <stdlib.h>
5058      #include <stdio.h>
5059      #include <stdint.h>
5060      #include <inttypes.h>
5061      #include <amqp.h>
5062    ]]
5063  )
5064  CPPFLAGS="$SAVE_CPPFLAGS"
5065
5066  SAVE_LDFLAGS="$LDFLAGS"
5067  LDFLAGS="$LDFLAGS $with_librabbitmq_ldflags"
5068
5069  AC_CHECK_LIB([rabbitmq], [amqp_basic_publish],
5070    [with_librabbitmq="yes"],
5071    [with_librabbitmq="no (Symbol 'amqp_basic_publish' not found)"]
5072  )
5073
5074  LDFLAGS="$SAVE_LDFLAGS"
5075fi
5076
5077if test "x$with_librabbitmq" = "xyes"; then
5078  SAVE_CPPFLAGS="$CPPFLAGS"
5079  SAVE_LDFLAGS="$LDFLAGS"
5080  SAVE_LIBS="$LIBS"
5081  CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
5082  LDFLAGS="$LDFLAGS $with_librabbitmq_ldflags"
5083  LIBS="-lrabbitmq"
5084
5085  AC_CHECK_HEADERS([amqp_tcp_socket.h amqp_socket.h])
5086  AC_CHECK_FUNC([amqp_tcp_socket_new],
5087    [
5088      AC_DEFINE([HAVE_AMQP_TCP_SOCKET], [1],
5089        [Define if librabbitmq provides the new TCP socket interface.])
5090    ]
5091  )
5092
5093  AC_CHECK_DECLS([amqp_socket_close],
5094    [],
5095    [],
5096    [[
5097      #include <amqp.h>
5098      #ifdef HAVE_AMQP_TCP_SOCKET_H
5099      # include <amqp_tcp_socket.h>
5100      #endif
5101      #ifdef HAVE_AMQP_SOCKET_H
5102      # include <amqp_socket.h>
5103      #endif
5104    ]]
5105  )
5106
5107  CPPFLAGS="$SAVE_CPPFLAGS"
5108  LDFLAGS="$SAVE_LDFLAGS"
5109  LIBS="$SAVE_LIBS"
5110fi
5111
5112if test "x$with_librabbitmq" = "xyes"; then
5113  BUILD_WITH_LIBRABBITMQ_CPPFLAGS="$with_librabbitmq_cppflags"
5114  BUILD_WITH_LIBRABBITMQ_LDFLAGS="$with_librabbitmq_ldflags"
5115  BUILD_WITH_LIBRABBITMQ_LIBS="-lrabbitmq"
5116fi
5117
5118AC_SUBST(BUILD_WITH_LIBRABBITMQ_CPPFLAGS)
5119AC_SUBST(BUILD_WITH_LIBRABBITMQ_LDFLAGS)
5120AC_SUBST(BUILD_WITH_LIBRABBITMQ_LIBS)
5121
5122# }}}
5123
5124# --with-librdkafka {{{
5125AC_ARG_WITH([librdkafka],
5126  [AS_HELP_STRING([--with-librdkafka@<:@=PREFIX@:>@], [Path to librdkafka.])],
5127  [
5128    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
5129      with_librdkafka_cppflags="-I$withval/include"
5130      with_librdkafka_ldflags="-L$withval/lib"
5131      with_librdkafka_rpath="$withval/lib"
5132      with_librdkafka="yes"
5133    else
5134      with_librdkafka="$withval"
5135    fi
5136  ],
5137  [with_librdkafka="yes"]
5138)
5139
5140if test "x$with_librdkafka" = "xyes"; then
5141  SAVE_CPPFLAGS="$CPPFLAGS"
5142  CPPFLAGS="$CPPFLAGS $with_librdkafka_cppflags"
5143
5144  AC_CHECK_HEADERS([librdkafka/rdkafka.h],
5145    [with_librdkafka="yes"],
5146    [with_librdkafka="no (librdkafka/rdkafka.h not found)"]
5147  )
5148
5149  CPPFLAGS="$SAVE_CPPFLAGS"
5150fi
5151
5152if test "x$with_librdkafka" = "xyes"; then
5153  SAVE_LDFLAGS="$LDFLAGS"
5154  LDFLAGS="$LDFLAGS $with_librdkafka_ldflags"
5155
5156  AC_CHECK_LIB([rdkafka], [rd_kafka_new],
5157    [with_librdkafka="yes"],
5158    [with_librdkafka="no (Symbol 'rd_kafka_new' not found)"])
5159
5160  AC_CHECK_LIB([rdkafka], [rd_kafka_conf_set_log_cb],
5161    [with_librdkafka_log_cb="yes"],
5162    [with_librdkafka_log_cb="no"])
5163
5164  AC_CHECK_LIB([rdkafka], [rd_kafka_set_logger],
5165    [with_librdkafka_logger="yes"],
5166    [with_librdkafka_logger="no"]
5167  )
5168
5169  LDFLAGS="$SAVE_LDFLAGS"
5170fi
5171
5172if test "x$with_librdkafka" = "xyes"; then
5173  BUILD_WITH_LIBRDKAFKA_CPPFLAGS="$with_librdkafka_cppflags"
5174  BUILD_WITH_LIBRDKAFKA_LDFLAGS="$with_librdkafka_ldflags"
5175
5176  if test "x$with_librdkafka_rpath" != "x"; then
5177    BUILD_WITH_LIBRDKAFKA_LIBS="-Wl,-rpath,$with_librdkafka_rpath -lrdkafka"
5178  else
5179    BUILD_WITH_LIBRDKAFKA_LIBS="-lrdkafka"
5180  fi
5181
5182  if test "x$with_librdkafka_log_cb" = "xyes"; then
5183    AC_DEFINE(HAVE_LIBRDKAFKA_LOG_CB, 1, [Define if librdkafka log facility is present and usable.])
5184  else if test "x$with_librdkafka_logger" = "xyes"; then
5185    AC_DEFINE(HAVE_LIBRDKAFKA_LOGGER, 1, [Define if librdkafka log facility is present and usable.])
5186  fi; fi
5187fi
5188
5189AC_SUBST([BUILD_WITH_LIBRDKAFKA_CPPFLAGS])
5190AC_SUBST([BUILD_WITH_LIBRDKAFKA_LDFLAGS])
5191AC_SUBST([BUILD_WITH_LIBRDKAFKA_LIBS])
5192# }}}
5193
5194# --with-librouteros {{{
5195AC_ARG_WITH([librouteros],
5196  [AS_HELP_STRING([--with-librouteros@<:@=PREFIX@:>@], [Path to librouteros.])],
5197  [
5198    if test "x$withval" = "xyes" || test "x$withval" = "xno"; then
5199      with_librouteros="$witval"
5200    else
5201      with_librouteros_cppflags="-I$withval/include"
5202      with_librouteros_ldflags="-L$withval/lib"
5203      with_librouteros="yes"
5204   fi
5205  ],
5206  [with_librouteros="yes"]
5207)
5208
5209if test "x$with_librouteros" = "xyes"; then
5210  SAVE_CPPFLAGS="$CPPFLAGS"
5211  CPPFLAGS="$CPPFLAGS $with_librouteros_cppflags"
5212
5213  AC_CHECK_HEADERS([routeros_api.h],
5214    [with_librouteros="yes"],
5215    [with_librouteros="no (routeros_api.h not found)"]
5216  )
5217
5218  CPPFLAGS="$SAVE_CPPFLAGS"
5219fi
5220
5221if test "x$with_librouteros" = "xyes"; then
5222  SAVE_LDFLAGS="$LDFLAGS"
5223  LDFLAGS="$LDFLAGS $with_librouteros_ldflags"
5224
5225  AC_CHECK_LIB([routeros], [ros_interface],
5226    [with_librouteros="yes"],
5227    [with_librouteros="no (symbol 'ros_interface' not found)"]
5228  )
5229
5230  LDFLAGS="$SAVE_LDFLAGS"
5231fi
5232
5233if test "x$with_librouteros" = "xyes"; then
5234  BUILD_WITH_LIBROUTEROS_CPPFLAGS="$with_librouteros_cppflags"
5235  BUILD_WITH_LIBROUTEROS_LDFLAGS="$with_librouteros_ldflags"
5236fi
5237
5238AC_SUBST([BUILD_WITH_LIBROUTEROS_CPPFLAGS])
5239AC_SUBST([BUILD_WITH_LIBROUTEROS_LDFLAGS])
5240# }}}
5241
5242# --with-librrd {{{
5243librrd_threadsafe="no"
5244librrd_rrdc_update="no"
5245AC_ARG_WITH([librrd],
5246  [AS_HELP_STRING([--with-librrd@<:@=PREFIX@:>@], [Path to rrdtool.])],
5247  [
5248    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
5249      librrd_cflags="-I$withval/include"
5250      librrd_ldflags="-L$withval/lib"
5251      with_librrd="yes"
5252    else
5253      with_librrd="$withval"
5254    fi
5255  ],
5256  [with_librrd="yes"]
5257)
5258
5259if test "x$with_librrd" = "xyes"; then
5260  SAVE_LDFLAGS="$LDFLAGS"
5261  LDFLAGS="$LDFLAGS $librrd_ldflags"
5262  PKG_CHECK_MODULES([RRD], [librrd >= 1.6.0],
5263    [
5264      AC_CHECK_LIB([rrd], [rrd_update_r],
5265        [librrd_threadsafe="yes"],
5266        [:]
5267      )
5268      AC_CHECK_LIB([rrd], [rrdc_update],
5269        [librrd_rrdc_update="yes"],
5270        [:]
5271      )
5272    ],[:]
5273  )
5274  LDFLAGS="$SAVE_LDFLAGS"
5275
5276  SAVE_CPPFLAGS="$CPPFLAGS"
5277  CPPFLAGS="$CPPFLAGS $RRD_CFLAGS $librrd_cflags"
5278
5279  AC_CHECK_HEADERS([rrd.h],, [with_librrd="no (rrd.h not found)"])
5280
5281  CPPFLAGS="$SAVE_CPPFLAGS"
5282fi
5283
5284if test "x$with_librrd" = "xyes" && test "x$librrd_threadsafe" = "xno"; then
5285  SAVE_LDFLAGS="$LDFLAGS"
5286  LDFLAGS="$LDFLAGS $librrd_ldflags"
5287
5288  AC_CHECK_LIB([rrd_th], [rrd_update_r],
5289    [
5290      librrd_ldflags="$librrd_ldflags -lrrd_th"
5291      librrd_threadsafe="yes"
5292      AC_CHECK_LIB([rrd_th], [rrdc_update],
5293        [librrd_rrdc_update="yes"],
5294        [:],
5295      )
5296    ],
5297    [:]
5298  )
5299  LDFLAGS="$SAVE_LDFLAGS"
5300fi
5301
5302if test "x$with_librrd" = "xyes" && test "x$librrd_threadsafe" = "xno"; then
5303  SAVE_LDFLAGS="$LDFLAGS"
5304  LDFLAGS="$LDFLAGS $librrd_ldflags"
5305
5306  AC_CHECK_LIB([rrd], [rrd_update],
5307    [
5308      librrd_ldflags="$librrd_ldflags -lrrd"
5309      AC_CHECK_LIB([rrd], [rrdc_update],
5310        [librrd_rrdc_update="yes"],
5311        [:]
5312      )
5313    ],
5314    [with_librrd="no (symbol 'rrd_update' not found)"]
5315  )
5316  LDFLAGS="$SAVE_LDFLAGS"
5317fi
5318
5319if test "x$with_librrd" = "xyes"; then
5320  BUILD_WITH_LIBRRD_CFLAGS="$RRD_CFLAGS $librrd_cflags"
5321  BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
5322  BUILD_WITH_LIBRRD_LIBS="$RRD_LIBS"
5323fi
5324
5325if test "x$librrd_threadsafe" = "xyes"; then
5326  AC_DEFINE([HAVE_THREADSAFE_LIBRRD], [1],
5327    [Define to 1 if the rrd library is thread-safe]
5328  )
5329fi
5330
5331AC_SUBST([BUILD_WITH_LIBRRD_CFLAGS])
5332AC_SUBST([BUILD_WITH_LIBRRD_LDFLAGS])
5333AC_SUBST([BUILD_WITH_LIBRRD_LIBS])
5334# }}}
5335
5336# --with-libsensors {{{
5337AC_ARG_WITH([libsensors],
5338  [AS_HELP_STRING([--with-libsensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
5339  [
5340    if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
5341      with_libsensors="$withval"
5342    else
5343      with_sensors_cppflags="-I$withval/include"
5344      with_sensors_ldflags="-L$withval/lib"
5345      with_libsensors="yes"
5346    fi
5347  ],
5348  [
5349    if test "x$ac_system" = "xLinux"; then
5350      with_libsensors="yes"
5351    else
5352      with_libsensors="no (Linux only library)"
5353    fi
5354  ]
5355)
5356
5357if test "x$with_libsensors" = "xyes"; then
5358  SAVE_CPPFLAGS="$CPPFLAGS"
5359  CPPFLAGS="$CPPFLAGS $with_sensors_cppflags"
5360
5361  AC_CHECK_HEADERS([sensors/sensors.h],
5362    [with_libsensors="yes"],
5363    [with_libsensors="no (sensors/sensors.h not found)"]
5364  )
5365
5366  CPPFLAGS="$SAVE_CPPFLAGS"
5367fi
5368
5369if test "x$with_libsensors" = "xyes"; then
5370  SAVE_LDFLAGS="$LDFLAGS"
5371  LDFLAGS="$LDFLAGS $with_sensors_ldflags"
5372
5373  AC_CHECK_LIB([sensors], [sensors_init],
5374    [with_libsensors="yes"],
5375    [with_libsensors="no (libsensors not found)"]
5376  )
5377
5378  LDFLAGS="$SAVE_LDFLAGS"
5379fi
5380
5381if test "x$with_libsensors" = "xyes"; then
5382  SAVE_CPPFLAGS="$CPPFLAGS"
5383  CPPFLAGS="$CPPFLAGS $with_sensors_cppflags"
5384  AC_PREPROC_IFELSE(
5385    [
5386      AC_LANG_SOURCE(
5387        [[
5388          #include <sensors/sensors.h>
5389          #if SENSORS_API_VERSION < 0x400
5390          #error "required libsensors version >= 3.0"
5391          #endif
5392        ]]
5393      )
5394    ],
5395    [with_libsensors="yes"],
5396    [with_libsensors="no (sensors library version 3.0.0 or higher is required)"]
5397  )
5398
5399  CPPFLAGS="$SAVE_CPPFLAGS"
5400fi
5401
5402if test "x$with_libsensors" = "xyes"; then
5403  BUILD_WITH_LIBSENSORS_CPPFLAGS="$with_sensors_cppflags"
5404  BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
5405  BUILD_WITH_LIBSENSORS_LIBS="-lsensors"
5406fi
5407
5408AC_SUBST([BUILD_WITH_LIBSENSORS_CPPFLAGS])
5409AC_SUBST([BUILD_WITH_LIBSENSORS_LDFLAGS])
5410AC_SUBST([BUILD_WITH_LIBSENSORS_LIBS])
5411
5412# }}}
5413
5414# libsigrok {{{
5415AC_SUBST([LIBSIGROK_CFLAGS])
5416AC_SUBST([LIBSIGROK_LIBS])
5417PKG_CHECK_MODULES([LIBSIGROK], [libsigrok < 0.4],
5418  [with_libsigrok="yes"],
5419  [with_libsigrok="no (pkg-config could not find libsigrok)"]
5420)
5421# }}}
5422
5423# --with-libssl {{{
5424with_libssl_cflags=""
5425with_libssl_ldflags=""
5426AC_ARG_WITH([libssl], [AS_HELP_STRING([--with-libssl@<:@=PREFIX@:>@], [Path to libssl.])],
5427[
5428	if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
5429		with_libssl_cppflags="-I$withval/include"
5430		with_libssl_ldflags="-L$withval/lib"
5431		with_libssl="yes"
5432	else
5433		with_libssl="$withval"
5434	fi
5435],
5436[
5437	with_libssl="yes"
5438])
5439if test "x$with_libssl" = "xyes"; then
5440	SAVE_CPPFLAGS="$CPPFLAGS"
5441	CPPFLAGS="$CPPFLAGS $with_libssl_cppflags"
5442
5443  AC_CHECK_HEADERS([openssl/sha.h openssl/blowfish.h openssl/rand.h],
5444    [with_libssl="yes"],
5445    [with_libssl="no (ssl header not found)"])
5446
5447	CPPFLAGS="$SAVE_CPPFLAGS"
5448fi
5449if test "x$with_libssl" = "xyes"; then
5450	SAVE_CPPFLAGS="$CPPFLAGS"
5451	SAVE_LDFLAGS="$LDFLAGS"
5452	CPPFLAGS="$CPPFLAGS $with_libssl_cppflags"
5453	LDFLAGS="$LDFLAGS $with_libssl_ldflags"
5454
5455	AC_CHECK_LIB([ssl], [OPENSSL_init_ssl], [with_libssl="yes"], [with_libssl="no (Symbol 'SSL_library_init' not found)"])
5456
5457	CPPFLAGS="$SAVE_CPPFLAGS"
5458	LDFLAGS="$SAVE_LDFLAGS"
5459fi
5460if test "x$with_libssl" = "xyes"; then
5461	BUILD_WITH_LIBSSL_CFLAGS="$with_libssl_cflags"
5462	BUILD_WITH_LIBSSL_LDFLAGS="$with_libssl_ldflags"
5463	BUILD_WITH_LIBSSL_LIBS="-lssl -lcrypto"
5464	AC_SUBST([BUILD_WITH_LIBSSL_CFLAGS])
5465	AC_SUBST([BUILD_WITH_LIBSSL_LDFLAGS])
5466	AC_SUBST([BUILD_WITH_LIBSSL_LIBS])
5467	AC_DEFINE([HAVE_LIBSSL], [1], [Define if libssl is present and usable.])
5468fi
5469AM_CONDITIONAL(BUILD_WITH_LIBSSL, test "x$with_libssl" = "xyes")
5470# }}}
5471
5472# --with-libstatgrab {{{
5473AC_ARG_WITH([libstatgrab],
5474  [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
5475  [
5476    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
5477      with_libstatgrab_cflags="-I$withval/include"
5478      with_libstatgrab_ldflags="-L$withval/lib -lstatgrab"
5479      with_libstatgrab="yes"
5480      with_libstatgrab_pkg_config="no"
5481    else
5482      with_libstatgrab="$withval"
5483      with_libstatgrab_pkg_config="yes"
5484    fi
5485  ],
5486  [
5487    with_libstatgrab="yes"
5488    with_libstatgrab_pkg_config="yes"
5489  ])
5490
5491if test "x$with_libstatgrab" = "xyes" && test "x$with_libstatgrab_pkg_config" = "xyes"; then
5492  AC_MSG_CHECKING([pkg-config for libstatgrab])
5493  temp_result="found"
5494  $PKG_CONFIG --exists libstatgrab 2>/dev/null
5495  if test "$?" != "0"; then
5496    with_libstatgrab_pkg_config="no"
5497    with_libstatgrab="no (pkg-config doesn't know libstatgrab)"
5498    temp_result="not found"
5499  fi
5500  AC_MSG_RESULT([$temp_result])
5501fi
5502
5503if test "x$with_libstatgrab" = "xyes" && test "x$with_libstatgrab_pkg_config" = "xyes" && test "x$with_libstatgrab_cflags" = "x"; then
5504  AC_MSG_CHECKING([for libstatgrab CFLAGS])
5505  temp_result="`$PKG_CONFIG --cflags libstatgrab`"
5506  if test "$?" = "0"; then
5507    with_libstatgrab_cflags="$temp_result"
5508  else
5509    with_libstatgrab="no ($PKG_CONFIG --cflags libstatgrab failed)"
5510    temp_result="$PKG_CONFIG --cflags libstatgrab failed"
5511  fi
5512  AC_MSG_RESULT([$temp_result])
5513fi
5514
5515if test "x$with_libstatgrab" = "xyes" && test "x$with_libstatgrab_pkg_config" = "xyes" && test "x$with_libstatgrab_ldflags" = "x"; then
5516  AC_MSG_CHECKING([for libstatgrab LDFLAGS])
5517  temp_result="`$PKG_CONFIG --libs libstatgrab`"
5518  if test "$?" = "0"
5519  then
5520    with_libstatgrab_ldflags="$temp_result"
5521  else
5522    with_libstatgrab="no ($PKG_CONFIG --libs libstatgrab failed)"
5523    temp_result="$PKG_CONFIG --libs libstatgrab failed"
5524  fi
5525  AC_MSG_RESULT([$temp_result])
5526fi
5527
5528if test "x$with_libstatgrab" = "xyes"; then
5529  SAVE_CPPFLAGS="$CPPFLAGS"
5530  CPPFLAGS="$CPPFLAGS $with_libstatgrab_cflags"
5531
5532  AC_CHECK_HEADERS([statgrab.h],
5533    [with_libstatgrab="yes"],
5534    [with_libstatgrab="no (statgrab.h not found)"]
5535  )
5536
5537  CPPFLAGS="$SAVE_CPPFLAGS"
5538fi
5539
5540if test "x$with_libstatgrab" = "xyes"; then
5541  SAVE_LDFLAGS="$LDFLAGS"
5542  LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
5543
5544  AC_CHECK_LIB([statgrab], [sg_init],
5545    [with_libstatgrab="yes"],
5546    [with_libstatgrab="no (symbol sg_init not found)"]
5547  )
5548
5549  LDFLAGS="$SAVE_LDFLAGS"
5550fi
5551
5552if test "x$with_libstatgrab" = "xyes"; then
5553  SAVE_CFLAGS="$CFLAGS"
5554  SAVE_LDFLAGS="$LDFLAGS"
5555  SAVE_LIBS="$LIBS"
5556
5557  CFLAGS="$CFLAGS $with_libstatgrab_cflags"
5558  LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
5559  LIBS="-lstatgrab $LIBS"
5560
5561  AC_CACHE_CHECK([if libstatgrab >= 0.90],
5562    [c_cv_have_libstatgrab_0_90],
5563    [
5564      AC_LINK_IFELSE(
5565        [
5566          AC_LANG_PROGRAM(
5567            [[
5568              #include <stdio.h>
5569              #include <statgrab.h>
5570            ]],
5571            [[
5572              if (sg_init()) return 0;
5573            ]]
5574          )
5575        ],
5576        [c_cv_have_libstatgrab_0_90="no"],
5577        [c_cv_have_libstatgrab_0_90="yes"]
5578      )
5579    ]
5580  )
5581
5582  CFLAGS="$SAVE_CFLAGS"
5583  LDFLAGS="$SAVE_LDFLAGS"
5584  LIBS="$SAVE_LIBS"
5585fi
5586
5587AM_CONDITIONAL([BUILD_WITH_LIBSTATGRAB], [test "x$with_libstatgrab" = "xyes"])
5588
5589if test "x$with_libstatgrab" = "xyes"; then
5590  AC_DEFINE([HAVE_LIBSTATGRAB], [1],
5591    [Define to 1 if you have the 'statgrab' library (-lstatgrab)]
5592  )
5593
5594  if test "x$c_cv_have_libstatgrab_0_90" = "xyes"; then
5595    AC_DEFINE([HAVE_LIBSTATGRAB_0_90], [1],
5596      [Define to 1 if libstatgrab version >= 0.90]
5597    )
5598  fi
5599
5600  BUILD_WITH_LIBSTATGRAB_CFLAGS="$with_libstatgrab_cflags"
5601  BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
5602
5603fi
5604
5605AC_SUBST([BUILD_WITH_LIBSTATGRAB_CFLAGS])
5606AC_SUBST([BUILD_WITH_LIBSTATGRAB_LDFLAGS])
5607# }}}
5608
5609# --with-libtokyotyrant {{{
5610AC_ARG_WITH([libtokyotyrant],
5611  [AS_HELP_STRING([--with-libtokyotyrant@<:@=PREFIX@:>@], [Path to libtokyotyrant.])],
5612  [
5613    if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
5614      with_libtokyotyrant="$withval"
5615    else
5616      with_libtokyotyrant_cppflags="-I$withval/include"
5617      with_libtokyotyrant_ldflags="-L$withval/lib"
5618      with_libtokyotyrant_libs="-ltokyotyrant"
5619      with_libtokyotyrant="yes"
5620    fi
5621  ],
5622  [with_libtokyotyrant="yes"]
5623)
5624
5625if test "x$with_libtokyotyrant" = "xyes"; then
5626  if $PKG_CONFIG --exists tokyotyrant; then
5627    with_libtokyotyrant_cppflags="$with_libtokyotyrant_cppflags `$PKG_CONFIG --cflags tokyotyrant`"
5628    with_libtokyotyrant_ldflags="$with_libtokyotyrant_ldflags `$PKG_CONFIG --libs-only-L tokyotyrant`"
5629    with_libtokyotyrant_libs="$with_libtokyotyrant_libs `$PKG_CONFIG --libs-only-l tokyotyrant`"
5630  fi
5631fi
5632
5633if test "x$with_libtokyotyrant" = "xyes"; then
5634  SAVE_CPPFLAGS="$CPPFLAGS"
5635  CPPFLAGS="$CPPFLAGS $with_libtokyotyrant_cppflags"
5636
5637  AC_CHECK_HEADERS([tcrdb.h],
5638    [with_libtokyotyrant="yes"],
5639    [with_libtokyotyrant="no (tcrdb.h not found)"]
5640  )
5641
5642  CPPFLAGS="$SAVE_CPPFLAGS"
5643fi
5644
5645if test "x$with_libtokyotyrant" = "xyes"; then
5646  SAVE_LDFLAGS="$LDFLAGS"
5647  LDFLAGS="$LDFLAGS $with_libtokyotyrant_ldflags"
5648
5649  AC_CHECK_LIB([tokyotyrant], [tcrdbrnum],
5650    [with_libtokyotyrant="yes"],
5651    [with_libtokyotyrant="no (symbol tcrdbrnum not found)"],
5652    [$with_libtokyotyrant_libs]
5653  )
5654
5655  LDFLAGS="$SAVE_LDFLAGS"
5656fi
5657
5658if test "x$with_libtokyotyrant" = "xyes"; then
5659  BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS="$with_libtokyotyrant_cppflags"
5660  BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS="$with_libtokyotyrant_ldflags"
5661  BUILD_WITH_LIBTOKYOTYRANT_LIBS="$with_libtokyotyrant_libs"
5662fi
5663AC_SUBST([BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS])
5664AC_SUBST([BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS])
5665AC_SUBST([BUILD_WITH_LIBTOKYOTYRANT_LIBS])
5666# }}}
5667
5668# --with-libudev {{{
5669AC_ARG_WITH([libudev],
5670  [AS_HELP_STRING([--with-libudev@<:@=PREFIX@:>@], [Path to libudev.])],
5671  [
5672    if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
5673      with_libudev="$withval"
5674    else
5675      with_libudev_cppflags="-I$withval/include"
5676      with_libudev_ldflags="-L$withval/lib"
5677      with_libudev="yes"
5678    fi
5679  ],
5680  [
5681    if test "x$ac_system" = "xLinux"; then
5682      with_libudev="yes"
5683    else
5684      with_libudev="no (Linux only library)"
5685    fi
5686  ]
5687)
5688
5689if test "x$with_libudev" = "xyes"; then
5690  SAVE_CPPFLAGS="$CPPFLAGS"
5691  CPPFLAGS="$CPPFLAGS $with_libudev_cppflags"
5692
5693  AC_CHECK_HEADERS([libudev.h],
5694    [with_libudev="yes"],
5695    [with_libudev="no (libudev.h not found)"]
5696  )
5697
5698  CPPFLAGS="$SAVE_CPPFLAGS"
5699fi
5700
5701if test "x$with_libudev" = "xyes"; then
5702  SAVE_LDFLAGS="$LDFLAGS"
5703  LDFLAGS="$LDFLAGS $with_libudev_ldflags"
5704
5705  AC_CHECK_LIB([udev], [udev_new],
5706    [with_libudev="yes"],
5707    [with_libudev="no (libudev not found)"]
5708  )
5709
5710  LDFLAGS="$SAVE_LDFLAGS"
5711fi
5712
5713if test "x$with_libudev" = "xyes"; then
5714  BUILD_WITH_LIBUDEV_CPPFLAGS="$with_libudev_cppflags"
5715  BUILD_WITH_LIBUDEV_LDFLAGS="$with_libudev_ldflags"
5716  BUILD_WITH_LIBUDEV_LIBS="-ludev"
5717fi
5718
5719AC_SUBST([BUILD_WITH_LIBUDEV_CPPFLAGS])
5720AC_SUBST([BUILD_WITH_LIBUDEV_LDFLAGS])
5721AC_SUBST([BUILD_WITH_LIBUDEV_LIBS])
5722
5723AM_CONDITIONAL([BUILD_WITH_LIBUDEV], [test "x$with_libudev" = "xyes"])
5724# }}}
5725
5726# --with-libupsclient {{{
5727with_libupsclient_config=""
5728AC_ARG_WITH([libupsclient],
5729  [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to the upsclient library.])],
5730  [
5731    if test "x$withval" = "xno"; then
5732      with_libupsclient="no"
5733    else if test "x$withval" = "xyes"; then
5734      with_libupsclient="use_pkgconfig"
5735    else
5736      if test -f "$withval" && test -x "$withval"; then
5737        with_libupsclient_config="$withval"
5738        with_libupsclient="use_libupsclient_config"
5739      else if test -x "$withval/bin/libupsclient-config"; then
5740        with_libupsclient_config="$withval/bin/libupsclient-config"
5741        with_libupsclient="use_libupsclient_config"
5742      else
5743        AC_MSG_NOTICE([Not checking for libupsclient: Manually configured])
5744        with_libupsclient_cflags="-I$withval/include"
5745        with_libupsclient_libs="-L$withval/lib -lupsclient"
5746        with_libupsclient="yes"
5747      fi; fi
5748    fi; fi
5749  ],
5750  [with_libupsclient="use_pkgconfig"]
5751)
5752
5753# configure using libupsclient-config
5754if test "x$with_libupsclient" = "xuse_libupsclient_config"; then
5755  with_libupsclient_cflags="`$with_libupsclient_config --cflags`"
5756  if test $? -ne 0; then
5757    with_libupsclient="no ($with_libupsclient_config failed)"
5758  fi
5759  with_libupsclient_libs="`$with_libupsclient_config --libs`"
5760  if test $? -ne 0; then
5761    with_libupsclient="no ($with_libupsclient_config failed)"
5762  fi
5763fi
5764
5765if test "x$with_libupsclient" = "xuse_libupsclient_config"; then
5766  with_libupsclient="yes"
5767fi
5768
5769# configure using pkg-config
5770if test "x$with_libupsclient" = "xuse_pkgconfig"; then
5771  $PKG_CONFIG --exists 'libupsclient' 2>/dev/null
5772  if test $? -ne 0; then
5773    with_libupsclient="no (pkg-config doesn't know libupsclient)"
5774  fi
5775fi
5776
5777if test "x$with_libupsclient" = "xuse_pkgconfig"; then
5778  with_libupsclient_cflags="`$PKG_CONFIG --cflags 'libupsclient'`"
5779  if test $? -ne 0; then
5780    with_libupsclient="no ($PKG_CONFIG failed)"
5781  fi
5782
5783  with_libupsclient_libs="`$PKG_CONFIG --libs 'libupsclient'`"
5784  if test $? -ne 0; then
5785    with_libupsclient="no ($PKG_CONFIG failed)"
5786  fi
5787fi
5788
5789if test "x$with_libupsclient" = "xuse_pkgconfig"; then
5790  with_libupsclient="yes"
5791fi
5792
5793if test "x$with_libupsclient" = "xyes"; then
5794  SAVE_CPPFLAGS="$CPPFLAGS"
5795  CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
5796
5797  AC_CHECK_HEADERS([upsclient.h],
5798    [with_libupsclient="yes"],
5799    [with_libupsclient="no (upsclient.h not found)"]
5800  )
5801
5802  CPPFLAGS="$SAVE_CPPFLAGS"
5803fi
5804
5805if test "x$with_libupsclient" = "xyes"; then
5806  SAVE_LDFLAGS="$LDFLAGS"
5807  LDFLAGS="$LDFLAGS $with_libupsclient_libs"
5808
5809  AC_CHECK_LIB([upsclient], [upscli_connect],
5810    [with_libupsclient="yes"],
5811    [with_libupsclient="no (symbol upscli_connect not found)"]
5812  )
5813
5814  AC_CHECK_LIB([upsclient], [upscli_init],
5815    [AC_DEFINE([HAVE_UPSCLI_INIT], [1], [Define when upscli_init() (since version 2-7) is available.])]
5816  )
5817
5818  AC_CHECK_LIB([upsclient], [upscli_tryconnect],
5819    [AC_DEFINE([HAVE_UPSCLI_TRYCONNECT], [1], [Define when upscli_tryconnect() (since version 2.6.2) is available.])]
5820  )
5821
5822  LDFLAGS="$SAVE_LDFLAGS"
5823fi
5824
5825if test "x$with_libupsclient" = "xyes"; then
5826  SAVE_CPPFLAGS="$CPPFLAGS"
5827  CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
5828
5829  AC_CHECK_TYPES([UPSCONN_t, UPSCONN],
5830    [],
5831    [],
5832    [[
5833      #include <stdlib.h>
5834      #include <stdio.h>
5835      #include <upsclient.h>
5836    ]]
5837  )
5838
5839  CPPFLAGS="$SAVE_CPPFLAGS"
5840fi
5841
5842if test "x$with_libupsclient" = "xyes"; then
5843  BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_libupsclient_cflags"
5844  BUILD_WITH_LIBUPSCLIENT_LIBS="$with_libupsclient_libs"
5845fi
5846
5847AC_SUBST([BUILD_WITH_LIBUPSCLIENT_CFLAGS])
5848AC_SUBST([BUILD_WITH_LIBUPSCLIENT_LIBS])
5849# }}}
5850
5851# --with-libxenctrl {{{
5852AC_ARG_WITH([libxenctrl],
5853  [AS_HELP_STRING([--with-libxenctrl@<:@=PREFIX@:>@], [Path to libxenctrl.])],
5854  [
5855    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
5856      with_libxenctrl_cppflags="-I$withval/include"
5857      with_libxenctrl_ldflags="-L$withval/lib"
5858      with_libxenctrl="yes"
5859    else
5860      with_libxenctrl="$withval"
5861    fi
5862  ],
5863  [with_libxenctrl="yes"]
5864)
5865
5866if test "x$with_libxenctrl" = "xyes"; then
5867  SAVE_CPPFLAGS="$CPPFLAGS"
5868  CPPFLAGS="$CPPFLAGS $with_libxenctrl_cppflags"
5869
5870  AC_CHECK_HEADERS([xenctrl.h],
5871    [with_libxenctrl="yes"],
5872    [with_libxenctrl="no (xenctrl.h not found)"]
5873  )
5874
5875  CPPFLAGS="$SAVE_CPPFLAGS"
5876fi
5877
5878if test "x$with_libxenctrl" = "xyes"; then
5879  SAVE_LDFLAGS="$LDFLAGS"
5880  LDFLAGS="$LDFLAGS $with_libxenctrl_ldflags"
5881
5882  #Xen versions older than 3.4 has no xc_getcpuinfo()
5883  AC_CHECK_LIB([xenctrl], [xc_getcpuinfo],
5884    [with_libxenctrl="yes"],
5885    [with_libxenctrl="no (symbol 'xc_getcpuinfo' not found)"]
5886  )
5887
5888  LDFLAGS="$SAVE_LDFLAGS"
5889fi
5890
5891LIBXENCTL_CPPFLAGS="$with_libxenctl_cppflags"
5892LIBXENCTL_LDFLAGS="$with_libxenctl_ldflags"
5893AC_SUBST([LIBXENCTL_CPPFLAGS])
5894AC_SUBST([LIBXENCTL_LDFLAGS])
5895# }}}
5896
5897# --with-libxmms {{{
5898with_xmms_config="xmms-config"
5899AC_ARG_WITH([libxmms],
5900  [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
5901  [
5902    if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
5903      with_libxmms="$withval"
5904    else
5905      if test -f "$withval" && test -x "$withval"; then
5906        with_xmms_config="$withval"
5907      else if test -x "$withval/bin/xmms-config"; then
5908        with_xmms_config="$withval/bin/xmms-config"
5909      fi; fi
5910      with_libxmms="yes"
5911    fi
5912  ],
5913  [with_libxmms="yes"]
5914)
5915
5916if test "x$with_libxmms" = "xyes"; then
5917  with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
5918  if test $? -ne 0; then
5919    with_libxmms="no"
5920  fi
5921fi
5922
5923if test "x$with_libxmms" = "xyes"; then
5924  with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
5925  if test $? -ne 0; then
5926    with_libxmms="no"
5927  fi
5928fi
5929
5930if test "x$with_libxmms" = "xyes"; then
5931  SAVE_CPPFLAGS="$CPPFLAGS"
5932  CPPFLAGS="$with_xmms_cflags"
5933
5934  AC_CHECK_HEADER([xmmsctrl.h],
5935    [with_libxmms="yes"],
5936    [with_libxmms="no"],
5937  )
5938
5939  CPPFLAGS="$SAVE_CPPFLAGS"
5940fi
5941
5942if test "x$with_libxmms" = "xyes"; then
5943  SAVE_LIBS="$LIBS"
5944  LIBS="$with_xmms_libs"
5945
5946  AC_CHECK_LIB([xmms], [xmms_remote_get_info],
5947    [with_libxmss="yes"],
5948    [with_libxmms="no"],
5949    [$with_xmms_libs]
5950
5951  )
5952
5953  LIBS="$SAVE_LIBS"
5954fi
5955
5956BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
5957BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
5958
5959AC_SUBST([BUILD_WITH_LIBXMMS_CFLAGS])
5960AC_SUBST([BUILD_WITH_LIBXMMS_LIBS])
5961# }}}
5962
5963# --with-libyajl {{{
5964AC_ARG_WITH([libyajl],
5965  [AS_HELP_STRING([--with-libyajl@<:@=PREFIX@:>@], [Path to libyajl.])],
5966  [
5967    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
5968      with_libyajl_cppflags="-I$withval/include"
5969      with_libyajl_ldflags="-L$withval/lib"
5970      with_libyajl="yes"
5971    else
5972      with_libyajl="$withval"
5973    fi
5974  ],
5975  [with_libyajl="yes"]
5976)
5977
5978if test "x$with_libyajl" = "xyes"; then
5979  SAVE_CPPFLAGS="$CPPFLAGS"
5980  CPPFLAGS="$CPPFLAGS $with_libyajl_cppflags"
5981
5982  AC_CHECK_HEADERS([yajl/yajl_parse.h],
5983    [with_libyajl="yes"],
5984    [with_libyajl="no (yajl/yajl_parse.h not found)"]
5985  )
5986
5987  AC_CHECK_HEADERS([yajl/yajl_tree.h],
5988    [with_libyajl2="yes"],
5989    [with_libyajl2="no (yajl/yajl_tree.h not found)"]
5990  )
5991
5992  AC_CHECK_HEADERS([yajl/yajl_version.h])
5993
5994  CPPFLAGS="$SAVE_CPPFLAGS"
5995fi
5996
5997if test "x$with_libyajl" = "xyes"; then
5998  SAVE_LDFLAGS="$LDFLAGS"
5999  LDFLAGS="$LDFLAGS $with_libyajl_ldflags"
6000
6001  AC_CHECK_LIB([yajl], [yajl_alloc],
6002    [with_libyajl="yes"],
6003    [with_libyajl="no (Symbol 'yajl_alloc' not found)"]
6004  )
6005
6006  AC_CHECK_LIB([yajl], [yajl_tree_parse],
6007    [with_libyajl2="yes"],
6008    [with_libyajl2="no (Symbol 'yajl_tree_parse' not found)"]
6009  )
6010
6011  LDFLAGS="$SAVE_LDFLAGS"
6012fi
6013
6014if test "x$with_libyajl" = "xyes"; then
6015  BUILD_WITH_LIBYAJL_CPPFLAGS="$with_libyajl_cppflags"
6016  BUILD_WITH_LIBYAJL_LDFLAGS="$with_libyajl_ldflags"
6017  BUILD_WITH_LIBYAJL_LIBS="-lyajl"
6018  AC_DEFINE([HAVE_LIBYAJL], [1], [Define if libyajl is present and usable.])
6019fi
6020
6021AC_SUBST([BUILD_WITH_LIBYAJL_CPPFLAGS])
6022AC_SUBST([BUILD_WITH_LIBYAJL_LDFLAGS])
6023AC_SUBST([BUILD_WITH_LIBYAJL_LIBS])
6024
6025AM_CONDITIONAL([BUILD_WITH_LIBYAJL], [test "x$with_libyajl" = "xyes"])
6026AM_CONDITIONAL([BUILD_WITH_LIBYAJL2], [test "x$with_libyajl$with_libyajl2" = "xyesyes"])
6027# }}}
6028
6029# --with-mic {{{
6030with_mic_cppflags="-I/opt/intel/mic/sysmgmt/sdk/include"
6031with_mic_ldflags="-L/opt/intel/mic/sysmgmt/sdk/lib/Linux"
6032with_mic_libs="-lMicAccessSDK -scif"
6033AC_ARG_WITH([mic],
6034  [AS_HELP_STRING([--with-mic@<:@=PREFIX@:>@], [Path to Intel MIC Access API.])],
6035  [
6036    if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
6037      with_mic="$withval"
6038    else if test -d "$with_mic/lib"; then
6039      with_mic_cppflags="-I$withval/include"
6040      with_mic_ldflags="-L$withval/lib/Linux"
6041      with_mic="yes"
6042    fi; fi
6043  ],
6044  [with_mic="yes"]
6045)
6046
6047if test "x$with_mic" = "xyes"; then
6048  SAVE_CPPFLAGS="$CPPFLAGS"
6049  CPPFLAGS="$CPPFLAGS $with_mic_cppflags"
6050
6051  AC_CHECK_HEADERS([MicAccessApi.h],
6052    [with_mic="yes"],
6053    [with_mic="no (MicAccessApi not found)"]
6054  )
6055
6056  CPPFLAGS="$SAVE_CPPFLAGS"
6057fi
6058
6059if test "x$with_mic" = "xyes"; then
6060  SAVE_LDFLAGS="$LDFLAGS"
6061  LDFLAGS="$LDFLAGS $with_mic_ldflags"
6062
6063  AC_CHECK_LIB([MicAccessSDK], [MicInitAPI],
6064    [with_mic="yes"],
6065    [with_mic="no (symbol MicInitAPI not found)"],
6066    [$PTHREAD_LIBS -lscif]
6067  )
6068
6069  LDFLAGS="$SAVE_LDFLAGS"
6070fi
6071
6072if test "x$with_mic" = "xyes"; then
6073  BUILD_WITH_MIC_CPPFLAGS="$with_mic_cppflags"
6074  BUILD_WITH_MIC_LDFLAGS="$with_mic_ldflags"
6075  BUILD_WITH_MIC_LIBS="$with_mic_libs"
6076fi
6077AC_SUBST([BUILD_WITH_MIC_CPPFLAGS])
6078AC_SUBST([BUILD_WITH_MIC_LDFLAGS])
6079AC_SUBST([BUILD_WITH_MIC_LIBS])
6080#}}}
6081
6082# --with-libvarnish {{{
6083AC_ARG_WITH([libvarnish],
6084  [AS_HELP_STRING([--with-libvarnish@<:@=PREFIX@:>@], [Path to libvarnish.])],
6085  [
6086    if test "x$withval" = "xno"; then
6087      with_libvarnish="no"
6088    else if test "x$withval" = "xyes"; then
6089      with_libvarnish="use_pkgconfig"
6090    else if test -d "$with_libvarnish/lib"; then
6091      with_libvarnish_cflags="-I$withval/include"
6092      with_libvarnish_libs="-L$withval/lib -lvarnishapi"
6093      with_libvarnish="yes"
6094    fi; fi; fi
6095  ],
6096  [with_libvarnish="use_pkgconfig"]
6097)
6098
6099# configure using pkg-config
6100if test "x$with_libvarnish" = "xuse_pkgconfig"; then
6101  $PKG_CONFIG --exists 'varnishapi' 2>/dev/null
6102  if test $? -ne 0; then
6103    with_libvarnish="no (pkg-config doesn't know varnishapi)"
6104  fi
6105fi
6106
6107if test "x$with_libvarnish" = "xuse_pkgconfig"; then
6108  with_libvarnish_cflags="`$PKG_CONFIG --cflags 'varnishapi'`"
6109  if test $? -ne 0; then
6110    with_libvarnish="no ($PKG_CONFIG failed)"
6111  fi
6112
6113  with_libvarnish_libs="`$PKG_CONFIG --libs 'varnishapi'`"
6114  if test $? -ne 0; then
6115    with_libvarnish="no ($PKG_CONFIG failed)"
6116  fi
6117fi
6118if test "x$with_libvarnish" = "xuse_pkgconfig"; then
6119  with_libvarnish="yes"
6120fi
6121
6122if test "x$with_libvarnish" = "xyes"; then
6123  SAVE_CPPFLAGS="$CPPFLAGS"
6124  CPPFLAGS="$CPPFLAGS $with_libvarnish_cflags"
6125
6126  $PKG_CONFIG --atleast-version=6 'varnishapi' 2>/dev/null
6127  if test $? -eq 0; then
6128    AC_DEFINE([HAVE_VARNISH_V6], [1], [Varnish 6 API support])
6129  else
6130    $PKG_CONFIG --atleast-version=5.2 'varnishapi' 2>/dev/null
6131    if test $? -eq 0; then
6132      AC_DEFINE([HAVE_VARNISH_V5], [1], [Varnish 5 API support])
6133    else
6134      AC_CHECK_HEADERS([vapi/vsc.h],
6135        [AC_DEFINE([HAVE_VARNISH_V4], [1], [Varnish 4 API support])],
6136        [
6137          AC_CHECK_HEADERS([vsc.h],
6138            [AC_DEFINE([HAVE_VARNISH_V3], [1], [Varnish 3 API support]) ],
6139            [
6140              AC_CHECK_HEADERS([varnishapi.h],
6141                [AC_DEFINE([HAVE_VARNISH_V2], [1], [Varnish 2 API support])],
6142                [with_libvarnish="no (found none of the varnish header files)"]
6143              )
6144            ]
6145          )
6146        ]
6147      )
6148    fi
6149  fi
6150
6151  CPPFLAGS="$SAVE_CPPFLAGS"
6152fi
6153
6154if test "x$with_libvarnish" = "xyes"; then
6155  BUILD_WITH_LIBVARNISH_CFLAGS="$with_libvarnish_cflags"
6156  BUILD_WITH_LIBVARNISH_LIBS="$with_libvarnish_libs"
6157fi
6158
6159AC_SUBST([BUILD_WITH_LIBVARNISH_CFLAGS])
6160AC_SUBST([BUILD_WITH_LIBVARNISH_LIBS])
6161# }}}
6162
6163# --with-libxml2 {{{
6164AC_ARG_WITH(libxml2,
6165  [AS_HELP_STRING([--with-libxml2@<:@=PREFIX@:>@], [Path to libxml2.])],
6166  [
6167    if test "x$withval" = "xno"; then
6168      with_libxml2="no"
6169    else if test "x$withval" = "xyes"; then
6170      $PKG_CONFIG --exists 'libxml-2.0' 2>/dev/null
6171      if test $? -eq 0; then
6172        with_libxml2="yes"
6173        with_libxml2_cflags="`$PKG_CONFIG --cflags libxml-2.0`"
6174        with_libxml2_ldflags="`$PKG_CONFIG --libs libxml-2.0`"
6175      else
6176        with_libxml2="no (pkg-config doesn't know libxml-2.0)"
6177      fi
6178    else
6179      with_libxml2="yes"
6180      with_libxml2_cflags="-I$withval/include"
6181      with_libxml2_ldflags="-L$withval/lib"
6182    fi; fi
6183  ],
6184  dnl  if no argument --with-libxml2 was passed, find the library locations
6185  dnl  with pkg-config just like above, when --with-libxml2=yes.
6186  [
6187    with_libxml2="yes"
6188    $PKG_CONFIG --exists 'libxml-2.0' 2>/dev/null
6189    if test $? -eq 0; then
6190      with_libxml2="yes"
6191      with_libxml2_cflags="`$PKG_CONFIG --cflags libxml-2.0`"
6192      with_libxml2_ldflags="`$PKG_CONFIG --libs libxml-2.0`"
6193    else
6194      with_libxml2="no (pkg-config doesn't know libxml-2.0)"
6195    fi
6196  ]
6197)
6198
6199if test "x$with_libxml2" = "xyes"; then
6200  SAVE_CPPFLAGS="$CPPFLAGS"
6201  CPPFLAGS="$CPPFLAGS $with_libxml2_cflags"
6202
6203  AC_CHECK_HEADERS([libxml/parser.h],
6204    [with_libxml2="yes"],
6205    [with_libxml2="no (libxml/parser.h not found)"]
6206  )
6207
6208  CPPFLAGS="$SAVE_CPPFLAGS"
6209fi
6210
6211if test "x$with_libxml2" = "xyes"; then
6212  SAVE_LDFLAGS="$LDFLAGS"
6213  LDFLAGS="$LDFLAGS $with_libxml2_ldflags"
6214
6215  AC_CHECK_LIB([xml2], [xmlXPathEval],
6216    [with_libxml2="yes"],
6217    [with_libxml2="no (symbol xmlXPathEval not found)"]
6218  )
6219
6220  LDFLAGS="$SAVE_LDFLAGS"
6221fi
6222
6223if test "x$with_libxml2" = "xyes"; then
6224  BUILD_WITH_LIBXML2_CFLAGS="$with_libxml2_cflags"
6225  BUILD_WITH_LIBXML2_LIBS="$with_libxml2_ldflags"
6226fi
6227
6228AC_SUBST([BUILD_WITH_LIBXML2_CFLAGS])
6229AC_SUBST([BUILD_WITH_LIBXML2_LIBS])
6230# }}}
6231
6232# pkg-config --exists libvirt {{{
6233$PKG_CONFIG --exists libvirt 2>/dev/null
6234if test $? = 0; then
6235  with_libvirt="yes"
6236else
6237  with_libvirt="no (pkg-config doesn't know libvirt)"
6238fi
6239
6240if test "x$with_libvirt" = "xyes"; then
6241  with_libvirt_cflags="`$PKG_CONFIG --cflags libvirt`"
6242  if test $? -ne 0; then
6243    with_libvirt="no"
6244  fi
6245
6246  with_libvirt_ldflags="`$PKG_CONFIG --libs libvirt`"
6247  if test $? -ne 0; then
6248    with_libvirt="no"
6249  fi
6250fi
6251
6252if test "x$with_libvirt" = "xyes"; then
6253  SAVE_CPPFLAGS="$CPPFLAGS"
6254  CPPFLAGS="$CPPFLAGS $with_libvirt_cflags"
6255
6256  AC_CHECK_HEADERS([libvirt/libvirt.h],
6257    [with_libvirt="yes"],
6258    [with_libvirt="no (libvirt/libvirt.h not found)"]
6259  )
6260
6261  CPPFLAGS="$SAVE_CPPFLAGS"
6262fi
6263
6264if test "x$with_libvirt" = "xyes"; then
6265  SAVE_LDFLAGS="$LDFLAGS"
6266  LDFLAGS="$LDFLAGS $with_libvirt_ldflags"
6267
6268  AC_CHECK_LIB([virt], [virDomainBlockStats],
6269    [with_libvirt="yes"],
6270    [with_libvirt="no (symbol virDomainBlockStats not found)"]
6271  )
6272
6273  LDFLAGS="$SAVE_LDFLAGS"
6274fi
6275
6276if test "x$with_libvirt" = "xyes"; then
6277  BUILD_WITH_LIBVIRT_CFLAGS="$with_libvirt_cflags"
6278  BUILD_WITH_LIBVIRT_LIBS="$with_libvirt_ldflags"
6279fi
6280
6281AC_SUBST([BUILD_WITH_LIBVIRT_CFLAGS])
6282AC_SUBST([BUILD_WITH_LIBVIRT_LIBS])
6283# }}}
6284
6285# $PKG_CONFIG --exists OpenIPMIpthread {{{
6286with_libopenipmipthread="yes"
6287AC_MSG_CHECKING([for libOpenIPMIpthread])
6288$PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
6289if test $? -ne 0; then
6290  with_libopenipmipthread="no (pkg-config doesn't know OpenIPMIpthread)"
6291fi
6292AC_MSG_RESULT([$with_libopenipmipthread])
6293
6294if test "x$with_libopenipmipthread" = "xyes"; then
6295  AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS])
6296  temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`"
6297  if test $? -eq 0; then
6298    with_libopenipmipthread_cflags="$temp_result"
6299  else
6300    with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)"
6301    temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed"
6302  fi
6303  AC_MSG_RESULT([$temp_result])
6304fi
6305
6306if test "x$with_libopenipmipthread" = "xyes"; then
6307  AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS])
6308  temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`"
6309  if test $? -eq 0; then
6310    with_libopenipmipthread_ldflags="$temp_result"
6311  else
6312    with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)"
6313    temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed"
6314  fi
6315  AC_MSG_RESULT([$temp_result])
6316fi
6317
6318if test "x$with_libopenipmipthread" = "xyes"; then
6319  SAVE_CPPFLAGS="$CPPFLAGS"
6320  CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags"
6321
6322  AC_CHECK_HEADERS([OpenIPMI/ipmi_smi.h],
6323    [with_libopenipmipthread="yes"],
6324    [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"],
6325    [[
6326      #include <OpenIPMI/ipmiif.h>
6327      #include <OpenIPMI/ipmi_err.h>
6328      #include <OpenIPMI/ipmi_posix.h>
6329      #include <OpenIPMI/ipmi_conn.h>
6330    ]]
6331  )
6332
6333  CPPFLAGS="$SAVE_CPPFLAGS"
6334fi
6335
6336if test "x$with_libopenipmipthread" = "xyes"; then
6337  BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags"
6338  BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags"
6339fi
6340
6341AC_SUBST([BUILD_WITH_OPENIPMI_CFLAGS])
6342AC_SUBST([BUILD_WITH_OPENIPMI_LIBS])
6343# }}}
6344
6345# --with-libatasmart {{{
6346AC_ARG_WITH([libatasmart],
6347  [AS_HELP_STRING([--with-libatasmart@<:@=PREFIX@:>@], [Path to libatasmart.])],
6348  [
6349    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
6350      with_libatasmart_cppflags="-I$withval/include"
6351      with_libatasmart_ldflags="-L$withval/lib"
6352      with_libatasmart="yes"
6353    else
6354      with_libatasmart="$withval"
6355    fi
6356  ],
6357  [
6358    if test "x$ac_system" = "xLinux"; then
6359      with_libatasmart="yes"
6360    else
6361      with_libatasmart="no (Linux only library)"
6362    fi
6363  ]
6364)
6365
6366if test "x$with_libatasmart" = "xyes"; then
6367  SAVE_CPPFLAGS="$CPPFLAGS"
6368  CPPFLAGS="$CPPFLAGS $with_libatasmart_cppflags"
6369
6370  AC_CHECK_HEADERS([atasmart.h],
6371    [with_libatasmart="yes"],
6372    [with_libatasmart="no (atasmart.h not found)"])
6373
6374  CPPFLAGS="$SAVE_CPPFLAGS"
6375fi
6376
6377if test "x$with_libatasmart" = "xyes"; then
6378  SAVE_LDFLAGS="$LDFLAGS"
6379  LDFLAGS="$LDFLAGS $with_libatasmart_ldflags"
6380
6381  AC_CHECK_LIB([atasmart], [sk_disk_open],
6382    [with_libatasmart="yes"],
6383    [with_libatasmart="no (Symbol 'sk_disk_open' not found)"]
6384  )
6385
6386  LDFLAGS="$SAVE_LDFLAGS"
6387fi
6388
6389if test "x$with_libatasmart" = "xyes"; then
6390  BUILD_WITH_LIBATASMART_CPPFLAGS="$with_libatasmart_cppflags"
6391  BUILD_WITH_LIBATASMART_LDFLAGS="$with_libatasmart_ldflags"
6392  BUILD_WITH_LIBATASMART_LIBS="-latasmart"
6393fi
6394
6395AC_SUBST([BUILD_WITH_LIBATASMART_CPPFLAGS])
6396AC_SUBST([BUILD_WITH_LIBATASMART_LDFLAGS])
6397AC_SUBST([BUILD_WITH_LIBATASMART_LIBS])
6398# }}}
6399
6400PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
6401  [with_libnotify="yes"],
6402  [with_libnotify="no (pkg-config doesn't know libnotify)"]
6403)
6404
6405PKG_CHECK_MODULES([LIBRIEMANN_CLIENT], [riemann-client >= 1.6.0],
6406 [with_libriemann_client="yes"],
6407 [with_libriemann_client="no (pkg-config doesn't know libriemann-client)"]
6408)
6409
6410# Check for enabled/disabled features
6411#
6412
6413# AC_COLLECTD(name, enable/disable, info-text, feature/module)
6414# ------------------------------------------------------------
6415dnl
6416m4_define([my_toupper],[m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
6417dnl
6418AC_DEFUN(
6419  [AC_COLLECTD],
6420  [
6421  m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
6422  m4_if(
6423    [$2],
6424    [enable],
6425    [dnl
6426    m4_define([EnDis],[disabled])dnl
6427    m4_define([YesNo],[no])dnl
6428    ],dnl
6429    [m4_if(
6430      [$2],
6431      [disable],
6432      [dnl
6433      m4_define([EnDis],[enabled])dnl
6434      m4_define([YesNo],[yes])dnl
6435      ],
6436      [dnl
6437      AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
6438      ]dnl
6439    )]dnl
6440  )dnl
6441  m4_if([$3], [feature], [],
6442    [m4_if(
6443      [$3], [module], [],
6444      [dnl
6445      AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
6446      ]dnl
6447    )]dnl
6448  )dnl
6449  AC_ARG_ENABLE(
6450    [$1],
6451    AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
6452    [],
6453    enable_$1='[YesNo]'dnl
6454  )# AC_ARG_ENABLE
6455  if test "x$enable_$1" = "xno"; then
6456    collectd_$1=0
6457  else
6458    if test "x$enable_$1" = "xyes"; then
6459      collectd_$1=1
6460    else
6461      AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
6462      collectd_$1=1
6463      enable_$1='yes'
6464    fi
6465  fi
6466  AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [whether or not to enable $3 $4])
6467  AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
6468  ]dnl
6469)# AC_COLLECTD(name, enable/disable, info-text, feature/module)
6470
6471# AC_PLUGIN(name, default, info)
6472# ------------------------------------------------------------
6473dnl
6474AC_DEFUN(
6475  [AC_PLUGIN],
6476  [
6477    enable_plugin="no"
6478    force="no"
6479    AC_ARG_ENABLE([$1],
6480      [AS_HELP_STRING([--enable-$1],[$3])],
6481      [
6482        if test "x$enableval" = "xyes"; then
6483          enable_plugin="yes"
6484        else if test "x$enableval" = "xforce"; then
6485          enable_plugin="yes"
6486          force="yes"
6487        else
6488          enable_plugin="no (disabled on command line)"
6489        fi; fi
6490      ],
6491      [
6492        if test "x$enable_all_plugins" = "xauto"; then
6493          if test "x$2" = "xyes"; then
6494            enable_plugin="yes"
6495          else
6496            enable_plugin="$2"
6497          fi
6498        else
6499          enable_plugin="$enable_all_plugins"
6500        fi
6501      ]
6502    )
6503    if test "x$enable_plugin" = "xyes"; then
6504      if test "x$2" = "xyes" || test "x$force" = "xyes"; then
6505        AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
6506        if test "x$2" != "xyes"; then
6507          dependency_warning="yes"
6508        fi
6509      else # User passed "yes" but dependency checking yielded "no" => Dependency problem.
6510        dependency_error="yes"
6511        enable_plugin="$2 (dependency error)"
6512      fi
6513    fi
6514    AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), [test "x$enable_plugin" = "xyes"])
6515    enable_$1="$enable_plugin"
6516  ]
6517)# AC_PLUGIN(name, default, info)
6518
6519# --with-libslurm {{{
6520AC_ARG_WITH([libslurm],
6521  [AS_HELP_STRING([--with-libslurm@<:@=PREFIX@:>@], [Path to the libslurm library.])],
6522  [
6523    if test "x$withval" = "xno"; then
6524      with_libslurm="no"
6525    else if test "x$withval" = "xyes"; then
6526      with_libslurm="use_pkgconfig"
6527    else if test -d "$with_libslurm/lib"; then
6528      AC_MSG_NOTICE([Not checking for libslurm: Manually configured])
6529      with_libslurm_cflags="-I$withval/include"
6530      with_libslurm_libs="-L$withval/lib -lslurm"
6531      with_libslurm="yes"
6532    fi; fi; fi
6533  ],
6534  [with_libslurm="use_pkgconfig"]
6535)
6536
6537# configure using pkg-config
6538if test "x$with_libslurm" = "xuse_pkgconfig"; then
6539  AC_MSG_NOTICE([Checking for libslurm using $PKG_CONFIG])
6540  $PKG_CONFIG --exists 'slurm' 2>/dev/null
6541  if test $? -ne 0; then
6542    with_libslurm="no (pkg-config doesn't know libslurm)"
6543  fi
6544fi
6545
6546if test "x$with_libslurm" = "xuse_pkgconfig"; then
6547  with_libslurm_cflags="`$PKG_CONFIG --cflags 'slurm'`"
6548  if test $? -ne 0; then
6549    with_libslurm="no ($PKG_CONFIG failed)"
6550  fi
6551
6552  with_libslurm_libs="`$PKG_CONFIG --libs 'slurm'`"
6553  if test $? -ne 0; then
6554    with_libslurm="no ($PKG_CONFIG failed)"
6555  fi
6556fi
6557
6558if test "x$with_libslurm" = "xuse_pkgconfig"; then
6559  with_libslurm="yes"
6560fi
6561
6562if test "x$with_libslurm" = "xyes"; then
6563  SAVE_CPPFLAGS="$CPPFLAGS"
6564  CPPFLAGS="$CPPFLAGS $with_libslurm_cflags"
6565
6566  AC_CHECK_HEADERS([slurm/slurm.h],
6567    [with_libslurm="yes"],
6568    [with_libslurm="no (slurm/slurm.h not found)"]
6569  )
6570
6571  CPPFLAGS="$SAVE_CPPFLAGS"
6572fi
6573
6574if test "x$with_libslurm" = "xyes"; then
6575  SAVE_LDFLAGS="$LDFLAGS"
6576  LDFLAGS="$LDFLAGS $with_libslurm_libs"
6577
6578  AC_CHECK_LIB([slurm], [slurm_load_jobs],
6579    [with_libslurm="yes"],
6580    [with_libslurm="no (symbol slurm_load_jobs not found)"]
6581  )
6582
6583  LDFLAGS="$SAVE_LDFLAGS"
6584fi
6585
6586if test "x$with_libslurm" = "xyes"; then
6587  BUILD_WITH_LIBSLURM_CFLAGS="$with_libslurm_cflags"
6588  BUILD_WITH_LIBSLURM_LIBS="$with_libslurm_libs"
6589fi
6590
6591AC_SUBST([BUILD_WITH_LIBSLURM_CFLAGS])
6592AC_SUBST([BUILD_WITH_LIBSLURM_LIBS])
6593# }}}
6594
6595
6596m4_divert_once([HELP_ENABLE], [
6597collectd features:])
6598# FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
6599AC_COLLECTD([debug],     [enable],  [feature], [debugging])
6600AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
6601AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
6602AC_COLLECTD([werror],    [disable], [feature], [building with ])
6603
6604dependency_warning="no"
6605dependency_error="no"
6606
6607plugin_ascent="no"
6608plugin_barometer="no"
6609plugin_battery="no"
6610plugin_bind="no"
6611plugin_buddyinfo="no"
6612plugin_capabilities="no"
6613plugin_ceph="no"
6614plugin_cgroups="no"
6615plugin_connectivity="no"
6616plugin_conntrack="no"
6617plugin_contextswitch="no"
6618plugin_cpu="no"
6619plugin_cpufreq="no"
6620plugin_cpusleep="no"
6621plugin_curl_json="no"
6622plugin_curl_xml="no"
6623plugin_df="no"
6624plugin_disk="no"
6625plugin_drbd="no"
6626plugin_dpdkevents="no"
6627plugin_dpdkstat="no"
6628plugin_dpdk_telemetry="no"
6629plugin_entropy="no"
6630plugin_ethstat="no"
6631plugin_fhcount="no"
6632plugin_fscache="no"
6633plugin_gps="no"
6634plugin_gpu_nvidia="no"
6635plugin_grpc="no"
6636plugin_hugepages="no"
6637plugin_infiniband="no"
6638plugin_intel_pmu="no"
6639plugin_intel_rdt="no"
6640plugin_interface="no"
6641plugin_ipc="no"
6642plugin_ipmi="no"
6643plugin_ipstats="no"
6644plugin_ipvs="no"
6645plugin_irq="no"
6646plugin_load="no"
6647plugin_log_logstash="no"
6648plugin_mcelog="no"
6649plugin_mdevents="no"
6650plugin_memory="no"
6651plugin_multimeter="no"
6652plugin_netstat_udp="no"
6653plugin_nfs="no"
6654plugin_numa="no"
6655plugin_ovs_events="no"
6656plugin_ovs_stats="no"
6657plugin_pcie_errors="no"
6658plugin_perl="no"
6659plugin_pinba="no"
6660plugin_processes="no"
6661plugin_procevent="no"
6662plugin_protocols="no"
6663plugin_python="no"
6664plugin_serial="no"
6665plugin_smart="no"
6666plugin_swap="no"
6667plugin_synproxy="no"
6668plugin_sysevent="no"
6669plugin_tape="no"
6670plugin_tcpconns="no"
6671plugin_ted="no"
6672plugin_thermal="no"
6673plugin_turbostat="no"
6674plugin_ubi="no"
6675plugin_uptime="no"
6676plugin_users="no"
6677plugin_virt="no"
6678plugin_vmem="no"
6679plugin_vserver="no"
6680plugin_wireless="no"
6681plugin_write_prometheus="no"
6682plugin_write_stackdriver="no"
6683plugin_xencpu="no"
6684plugin_zfs_arc="no"
6685plugin_zone="no"
6686plugin_zookeeper="no"
6687
6688# Linux
6689if test "x$ac_system" = "xLinux"; then
6690  plugin_battery="yes"
6691  plugin_buddyinfo="yes"
6692  plugin_cgroups="yes"
6693  plugin_conntrack="yes"
6694  plugin_contextswitch="yes"
6695  plugin_cpu="yes"
6696  plugin_cpufreq="yes"
6697  plugin_disk="yes"
6698  plugin_drbd="yes"
6699  plugin_entropy="yes"
6700  plugin_fhcount="yes"
6701  plugin_fscache="yes"
6702  plugin_hugepages="yes"
6703  plugin_infiniband="yes"
6704  plugin_interface="yes"
6705  plugin_ipc="yes"
6706  plugin_irq="yes"
6707  plugin_load="yes"
6708  plugin_mcelog="yes"
6709  plugin_mdevents="yes"
6710  plugin_memory="yes"
6711  plugin_nfs="yes"
6712  plugin_numa="yes"
6713  plugin_processes="yes"
6714  plugin_protocols="yes"
6715  plugin_serial="yes"
6716  plugin_swap="yes"
6717  plugin_synproxy="yes"
6718  plugin_tcpconns="yes"
6719  plugin_thermal="yes"
6720  plugin_ubi="yes"
6721  plugin_uptime="yes"
6722  plugin_vmem="yes"
6723  plugin_vserver="yes"
6724  plugin_wireless="yes"
6725  plugin_zfs_arc="yes"
6726
6727  if test "x$ac_cv_header_linux_ip_vs_h" = "xyes"; then
6728    plugin_ipvs="yes"
6729  fi
6730
6731  if test "x$have_cpuid_h" = "xyes"; then
6732    plugin_turbostat="yes"
6733  fi
6734
6735  if test "x$c_cv_have_clock_boottime_monotonic" = "xyes"; then
6736    plugin_cpusleep="yes"
6737  fi
6738
6739  if test "x$with_libyajl" = "xyes" && test "x$with_libyajl2" = "xyes"; then
6740    plugin_ovs_events="yes"
6741    plugin_ovs_stats="yes"
6742    plugin_procevent="yes"
6743
6744    if test "x$with_libmnl" = "xyes"; then
6745      plugin_connectivity="yes"
6746    fi
6747  fi
6748
6749  if test "x$have_pci_regs_h" = "xyes"; then
6750    plugin_pcie_errors="yes"
6751  fi
6752
6753  if test "x$with_libmicrohttpd" = "xyes" && test "x$with_libjansson" = "xyes"; then
6754    plugin_capabilities="yes"
6755  fi
6756fi
6757
6758if test "x$ac_system" = "xOpenBSD"; then
6759  plugin_tcpconns="yes"
6760fi
6761
6762if test "x$ac_system" = "xNetBSD"; then
6763  plugin_disk="yes"
6764  plugin_entropy="yes"
6765  plugin_irq="yes"
6766  plugin_nfs="yes"
6767  plugin_processes="yes"
6768  plugin_netstat_udp="yes"
6769fi
6770
6771# Mac OS X devices
6772if test "x$with_libiokit" = "xyes"; then
6773  plugin_battery="yes"
6774  plugin_disk="yes"
6775fi
6776
6777# AIX
6778
6779if test "x$ac_system" = "xAIX"; then
6780  plugin_ipc="yes"
6781  plugin_tcpconns="yes"
6782fi
6783
6784# FreeBSD
6785
6786if test "x$ac_system" = "xFreeBSD"; then
6787  plugin_cpufreq="yes"
6788  plugin_disk="yes"
6789  plugin_ipstats="yes"
6790  plugin_zfs_arc="yes"
6791fi
6792
6793if test "x$with_perfstat" = "xyes"; then
6794  plugin_contextswitch="yes"
6795  plugin_cpu="yes"
6796  plugin_disk="yes"
6797  plugin_interface="yes"
6798  plugin_load="yes"
6799  plugin_memory="yes"
6800  plugin_swap="yes"
6801  plugin_uptime="yes"
6802fi
6803
6804if test "x$with_procinfo" = "xyes"; then
6805  plugin_processes="yes"
6806fi
6807
6808# Solaris
6809if test "x$with_kstat" = "xyes"; then
6810  plugin_nfs="yes"
6811  plugin_processes="yes"
6812  plugin_uptime="yes"
6813  plugin_zfs_arc="yes"
6814  plugin_zone="yes"
6815fi
6816
6817if test "x$with_devinfo" = "xyes" && test "x$with_kstat" = "xyes"; then
6818  plugin_cpu="yes"
6819  plugin_disk="yes"
6820  plugin_interface="yes"
6821  plugin_memory="yes"
6822  plugin_tape="yes"
6823fi
6824
6825if test "x$with_libi2c" = "xyes"; then
6826  plugin_barometer="yes"
6827fi
6828
6829
6830# libstatgrab
6831if test "x$with_libstatgrab" = "xyes"; then
6832  plugin_cpu="yes"
6833  plugin_disk="yes"
6834  plugin_interface="yes"
6835  plugin_load="yes"
6836  plugin_memory="yes"
6837  plugin_swap="yes"
6838  plugin_users="yes"
6839fi
6840
6841if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"; then
6842  plugin_ascent="yes"
6843  if test "x$have_strptime" = "xyes"; then
6844    plugin_bind="yes"
6845  fi
6846fi
6847
6848if test "x$with_libopenipmipthread" = "xyes"; then
6849  plugin_ipmi="yes"
6850fi
6851
6852if test "x$with_libcurl" = "xyes" && test "x$with_libyajl" = "xyes"; then
6853  plugin_curl_json="yes"
6854fi
6855
6856if test "x$with_libcurl" = "xyes" && test "x$with_libssl" = "xyes" && test "x$with_libyajl" = "xyes" && test "x$with_libyajl2" = "xyes"; then
6857  plugin_write_stackdriver="yes"
6858fi
6859
6860if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"; then
6861  plugin_curl_xml="yes"
6862fi
6863
6864if test "x$with_libyajl" = "xyes"; then
6865  plugin_ceph="yes"
6866  plugin_sysevent="yes"
6867fi
6868
6869if test "x$have_processor_info" = "xyes"; then
6870  plugin_cpu="yes"
6871fi
6872
6873if test "x$have_sysctl" = "xyes"; then
6874  plugin_cpu="yes"
6875  plugin_memory="yes"
6876  plugin_uptime="yes"
6877  if test "x$ac_system" = "xDarwin"; then
6878    plugin_swap="yes"
6879  fi
6880fi
6881
6882if test "x$have_sysctlbyname" = "xyes"; then
6883  plugin_contextswitch="yes"
6884  plugin_cpu="yes"
6885  plugin_memory="yes"
6886  plugin_tcpconns="yes"
6887fi
6888
6889if test "x$have_getvfsstat" = "xyes" || test "x$have_getfsstat" = "xyes"; then
6890  plugin_df="yes"
6891fi
6892
6893if test "x$c_cv_have_two_getmntent" = "xyes" || test "x$have_getmntent" = "xgen" || test "x$have_getmntent" = "xsun"; then
6894  plugin_df="yes"
6895fi
6896
6897if test "x$c_cv_have_one_getmntent" = "xyes"; then
6898  plugin_df="yes"
6899fi
6900
6901if test "x$have_getmntent_r" = "xyes"; then
6902  plugin_df="yes"
6903fi
6904
6905if test "x$plugin_df" = "xyes"; then
6906  plugin_df="no"
6907  if test "x$have_statfs" = "xyes"; then
6908    plugin_df="yes"
6909  fi
6910
6911  if test "x$have_statvfs" = "xyes"; then
6912    plugin_df="yes"
6913  fi
6914fi
6915
6916if test "x$have_linux_sockios_h" = "xyes" && test "x$have_linux_ethtool_h" = "xyes"; then
6917  plugin_ethstat="yes"
6918fi
6919
6920if test "x$with_libgps" = "xyes"; then
6921  plugin_gps="yes"
6922fi
6923
6924plugin_grpc="yes"
6925if test "x$GRPC_CPP_PLUGIN" = "x"; then
6926  plugin_grpc="no (grpc_cpp_plugin not found)"
6927fi
6928if test "x$have_protoc3" != "xyes"; then
6929  plugin_grpc="no (protoc3 not found)"
6930fi
6931if test "x$with_libprotobuf" != "xyes"; then
6932  plugin_grpc="no (libprotobuf not found)"
6933fi
6934if test "x$with_libgrpcpp" != "xyes"; then
6935  plugin_grpc="no (libgrpc++ not found)"
6936fi
6937
6938if test "x$have_getifaddrs" = "xyes"; then
6939  plugin_interface="yes"
6940fi
6941
6942if test "x$have_getloadavg" = "xyes"; then
6943  plugin_load="yes"
6944fi
6945
6946if test "x$with_libyajl" = "xyes"; then
6947  plugin_log_logstash="yes"
6948fi
6949
6950if test "x$with_libperl" = "xyes" && test "x$c_cv_have_perl_ithreads" = "xyes"; then
6951  plugin_perl="yes"
6952fi
6953
6954if test "x$have_protoc_c" = "xyes" && test "x$with_libprotobuf_c" = "xyes"; then
6955  plugin_pinba="yes"
6956  if test "x$with_libmicrohttpd" = "xyes"; then
6957    plugin_write_prometheus="yes"
6958  fi
6959fi
6960
6961# Mac OS X memory interface
6962if test "x$have_host_statistics" = "xyes"; then
6963  plugin_memory="yes"
6964fi
6965
6966if test "x$have_termios_h" = "xyes"; then
6967  if test "x$ac_system" != "xAIX"; then
6968    plugin_multimeter="yes"
6969  fi
6970  plugin_ted="yes"
6971fi
6972
6973if test "x$have_thread_info" = "xyes"; then
6974  plugin_processes="yes"
6975fi
6976
6977if test "x$with_kvm_getprocs" = "xyes" && test "x$have_struct_kinfo_proc_freebsd" = "xyes"; then
6978  plugin_processes="yes"
6979fi
6980
6981if test "x$with_kvm_getprocs" = "xyes" && test "x$have_struct_kinfo_proc_dragonfly" = "xyes"; then
6982  plugin_processes="yes"
6983fi
6984
6985if test "x$with_kvm_getprocs" = "xyes" && test "x$have_struct_kinfo_proc_openbsd" = "xyes"; then
6986  plugin_processes="yes"
6987fi
6988
6989if test "x$with_libpython" != "xno"; then
6990  plugin_python="yes"
6991fi
6992
6993if test "x$with_libatasmart" = "xyes" && test "x$with_libudev" = "xyes"; then
6994  plugin_smart="yes"
6995fi
6996
6997if test "x$with_kvm_getswapinfo" = "xyes"; then
6998  plugin_swap="yes"
6999fi
7000
7001if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_two_args" = "xyes"; then
7002  plugin_swap="yes"
7003fi
7004
7005if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_three_args" = "xyes"; then
7006  plugin_swap="yes"
7007fi
7008
7009if test "x$with_kvm_openfiles = "xyes" && $with_kvm_nlist" = "xyes"; then
7010  plugin_tcpconns="yes"
7011fi
7012
7013if test "x$have_getutent" = "xyes"; then
7014  plugin_users="yes"
7015fi
7016
7017if test "x$have_getutxent" = "xyes"; then
7018  plugin_users="yes"
7019fi
7020
7021if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes"; then
7022  plugin_virt="yes"
7023fi
7024
7025if test "x$with_libxenctrl" = "xyes"; then
7026  plugin_xencpu="yes"
7027fi
7028
7029if test "x$with_libdpdk" = "xyes"; then
7030  plugin_dpdkevents="$dpdk_keepalive"
7031  plugin_dpdkstat="yes"
7032fi
7033
7034if test "x$with_libjansson" = "xyes"; then
7035  plugin_dpdk_telemetry="yes"
7036fi
7037
7038m4_divert_once([HELP_ENABLE], [
7039collectd plugins:])
7040
7041AC_ARG_ENABLE([all-plugins],
7042  [AS_HELP_STRING([--enable-all-plugins], [enable all plugins @<:@default=yes@:>@])],
7043  [
7044     if test "x$enableval" = "xyes"; then
7045       enable_all_plugins="yes"
7046     else if test "x$enableval" = "xauto"; then
7047       enable_all_plugins="auto"
7048     else
7049       enable_all_plugins="no"
7050     fi; fi
7051  ],
7052  [enable_all_plugins="auto"]
7053)
7054
7055m4_divert_once([HELP_ENABLE], [])
7056
7057AC_PLUGIN([aggregation],         [yes],                       [Aggregation plugin])
7058AC_PLUGIN([amqp],                [$with_librabbitmq],         [AMQP output plugin])
7059AC_PLUGIN([amqp1],               [$with_libqpid_proton],      [AMQP 1.0 output plugin])
7060AC_PLUGIN([apache],              [$with_libcurl],             [Apache httpd statistics])
7061AC_PLUGIN([apcups],              [yes],                       [Statistics of UPSes by APC])
7062AC_PLUGIN([apple_sensors],       [$with_libiokit],            [Apple hardware sensors])
7063AC_PLUGIN([aquaero],             [$with_libaquaero5],         [Aquaero hardware sensors])
7064AC_PLUGIN([ascent],              [$plugin_ascent],            [AscentEmu player statistics])
7065AC_PLUGIN([barometer],           [$plugin_barometer],         [Barometer sensor on I2C])
7066AC_PLUGIN([battery],             [$plugin_battery],           [Battery statistics])
7067AC_PLUGIN([bind],                [$plugin_bind],              [ISC Bind nameserver statistics])
7068AC_PLUGIN([buddyinfo],           [$plugin_buddyinfo],         [buddyinfo statistics])
7069AC_PLUGIN([capabilities],        [$plugin_capabilities],      [Platform static capabilities])
7070AC_PLUGIN([ceph],                [$plugin_ceph],              [Ceph daemon statistics])
7071AC_PLUGIN([cgroups],             [$plugin_cgroups],           [CGroups CPU usage accounting])
7072AC_PLUGIN([chrony],              [yes],                       [Chrony statistics])
7073AC_PLUGIN([check_uptime],        [yes],                       [Notify about uptime reset])
7074AC_PLUGIN([connectivity],        [$plugin_connectivity],      [Network interface up/down events])
7075AC_PLUGIN([conntrack],           [$plugin_conntrack],         [nf_conntrack statistics])
7076AC_PLUGIN([contextswitch],       [$plugin_contextswitch],     [context switch statistics])
7077AC_PLUGIN([cpu],                 [$plugin_cpu],               [CPU usage statistics])
7078AC_PLUGIN([cpufreq],             [$plugin_cpufreq],           [CPU frequency statistics])
7079AC_PLUGIN([cpusleep],            [$plugin_cpusleep],          [CPU sleep statistics])
7080AC_PLUGIN([csv],                 [yes],                       [CSV output plugin])
7081AC_PLUGIN([curl],                [$with_libcurl],             [CURL generic web statistics])
7082AC_PLUGIN([curl_json],           [$plugin_curl_json],         [CouchDB statistics])
7083AC_PLUGIN([curl_xml],            [$plugin_curl_xml],          [CURL generic xml statistics])
7084AC_PLUGIN([dbi],                 [$with_libdbi],              [General database statistics])
7085AC_PLUGIN([dcpmm],               [$with_libpmwapi],           [Intel(R) Optane(TM) DC Persistent Memory performance and health statistics])
7086AC_PLUGIN([df],                  [$plugin_df],                [Filesystem usage statistics])
7087AC_PLUGIN([disk],                [$plugin_disk],              [Disk usage statistics])
7088AC_PLUGIN([dns],                 [$with_libpcap],             [DNS traffic analysis])
7089AC_PLUGIN([dpdkevents],          [$plugin_dpdkevents],        [Events from DPDK])
7090AC_PLUGIN([dpdkstat],            [$plugin_dpdkstat],          [Stats from DPDK])
7091AC_PLUGIN([dpdk_telemetry],      [$plugin_dpdk_telemetry],    [Metrics from DPDK Telemetry])
7092AC_PLUGIN([drbd],                [$plugin_drbd],              [DRBD statistics])
7093AC_PLUGIN([email],               [yes],                       [EMail statistics])
7094AC_PLUGIN([entropy],             [$plugin_entropy],           [Entropy statistics])
7095AC_PLUGIN([ethstat],             [$plugin_ethstat],           [Stats from NIC driver])
7096AC_PLUGIN([exec],                [yes],                       [Execution of external programs])
7097AC_PLUGIN([fhcount],             [$plugin_fhcount],           [File handles statistics])
7098AC_PLUGIN([filecount],           [yes],                       [Count files in directories])
7099AC_PLUGIN([fscache],             [$plugin_fscache],           [fscache statistics])
7100AC_PLUGIN([gmond],               [$with_libganglia],          [Ganglia plugin])
7101AC_PLUGIN([gps],                 [$plugin_gps],               [GPS plugin])
7102AC_PLUGIN([gpu_nvidia],          [$with_cuda],                [NVIDIA GPU plugin])
7103AC_PLUGIN([grpc],                [$plugin_grpc],              [gRPC plugin])
7104AC_PLUGIN([hddtemp],             [yes],                       [Query hddtempd])
7105AC_PLUGIN([hugepages],           [$plugin_hugepages],         [Hugepages statistics])
7106AC_PLUGIN([infiniband],          [$plugin_infiniband],        [Infiniband statistics])
7107AC_PLUGIN([intel_pmu],           [$with_libjevents],          [Intel performance monitor plugin])
7108AC_PLUGIN([intel_rdt],           [$with_libpqos],             [Intel RDT monitor plugin])
7109AC_PLUGIN([interface],           [$plugin_interface],         [Interface traffic statistics])
7110AC_PLUGIN([ipc],                 [$plugin_ipc],               [IPC statistics])
7111AC_PLUGIN([ipmi],                [$plugin_ipmi],              [IPMI sensor statistics])
7112AC_PLUGIN([iptables],            [$with_libiptc],             [IPTables rule counters])
7113AC_PLUGIN([ipstats],             [$plugin_ipstats],           [IP packet statistics])
7114AC_PLUGIN([ipvs],                [$plugin_ipvs],              [IPVS connection statistics])
7115AC_PLUGIN([irq],                 [$plugin_irq],               [IRQ statistics])
7116AC_PLUGIN([java],                [$with_java],                [Embed the Java Virtual Machine])
7117AC_PLUGIN([load],                [$plugin_load],              [System load])
7118AC_PLUGIN([log_logstash],        [$plugin_log_logstash],      [Logstash json_event compatible logging])
7119AC_PLUGIN([logfile],             [yes],                       [File logging plugin])
7120AC_PLUGIN([logparser],           [yes],                       [Log parsing plugin])
7121AC_PLUGIN([lpar],                [$with_perfstat],            [AIX logical partitions statistics])
7122AC_PLUGIN([lua],                 [$with_liblua],              [Lua plugin])
7123AC_PLUGIN([madwifi],             [$have_linux_wireless_h],    [Madwifi wireless statistics])
7124AC_PLUGIN([match_empty_counter], [yes],                       [The empty counter match])
7125AC_PLUGIN([match_hashed],        [yes],                       [The hashed match])
7126AC_PLUGIN([match_regex],         [yes],                       [The regex match])
7127AC_PLUGIN([match_timediff],      [yes],                       [The timediff match])
7128AC_PLUGIN([match_value],         [yes],                       [The value match])
7129AC_PLUGIN([mbmon],               [yes],                       [Query mbmond])
7130AC_PLUGIN([mcelog],              [$plugin_mcelog],            [Machine Check Exceptions notifications])
7131AC_PLUGIN([md],                  [$have_linux_raid_md_u_h],   [md (Linux software RAID) devices])
7132AC_PLUGIN([mdevents],            [$plugin_mdevents],          [Events from md (Linux Software RAID) devices])
7133AC_PLUGIN([memcachec],           [$with_libmemcached],        [memcachec statistics])
7134AC_PLUGIN([memcached],           [yes],                       [memcached statistics])
7135AC_PLUGIN([memory],              [$plugin_memory],            [Memory usage])
7136AC_PLUGIN([mic],                 [$with_mic],                 [Intel Many Integrated Core stats])
7137AC_PLUGIN([modbus],              [$with_libmodbus],           [Modbus plugin])
7138AC_PLUGIN([mqtt],                [$with_libmosquitto],        [MQTT output plugin])
7139AC_PLUGIN([multimeter],          [$plugin_multimeter],        [Read multimeter values])
7140AC_PLUGIN([mysql],               [$with_libmysql],            [MySQL statistics])
7141AC_PLUGIN([netapp],              [$with_libnetapp],           [NetApp plugin])
7142AC_PLUGIN([netlink],             [$with_libmnl],              [Enhanced Linux network statistics])
7143AC_PLUGIN([netstat_udp],         [$plugin_netstat_udp],       [UDP network statistics])
7144AC_PLUGIN([network],             [yes],                       [Network communication plugin])
7145AC_PLUGIN([nfs],                 [$plugin_nfs],               [NFS statistics])
7146AC_PLUGIN([nginx],               [$with_libcurl],             [nginx statistics])
7147AC_PLUGIN([notify_desktop],      [$with_libnotify],           [Desktop notifications])
7148AC_PLUGIN([notify_email],        [$with_libesmtp],            [Email notifier])
7149AC_PLUGIN([notify_nagios],       [yes],                       [Nagios notification plugin])
7150AC_PLUGIN([ntpd],                [yes],                       [NTPd statistics])
7151AC_PLUGIN([numa],                [$plugin_numa],              [NUMA virtual memory statistics])
7152AC_PLUGIN([nut],                 [$with_libupsclient],        [Network UPS tools statistics])
7153AC_PLUGIN([olsrd],               [yes],                       [olsrd statistics])
7154AC_PLUGIN([onewire],             [$with_libowcapi],           [OneWire sensor statistics])
7155AC_PLUGIN([openldap],            [$with_libldap],             [OpenLDAP statistics])
7156AC_PLUGIN([openvpn],             [yes],                       [OpenVPN client statistics])
7157AC_PLUGIN([oracle],              [$with_oracle],              [Oracle plugin])
7158AC_PLUGIN([ovs_events],          [$plugin_ovs_events],        [OVS events plugin])
7159AC_PLUGIN([ovs_stats],           [$plugin_ovs_stats],         [OVS statistics plugin])
7160AC_PLUGIN([pcie_errors],         [$plugin_pcie_errors],       [PCIe errors plugin])
7161AC_PLUGIN([perl],                [$plugin_perl],              [Embed a Perl interpreter])
7162AC_PLUGIN([pf],                  [$have_net_pfvar_h],         [BSD packet filter (PF) statistics])
7163# FIXME: Check for libevent, too.
7164AC_PLUGIN([pinba],               [$plugin_pinba],             [Pinba statistics])
7165AC_PLUGIN([ping],                [$with_liboping],            [Network latency statistics])
7166AC_PLUGIN([postgresql],          [$with_libpq],               [PostgreSQL database statistics])
7167AC_PLUGIN([powerdns],            [yes],                       [PowerDNS statistics])
7168AC_PLUGIN([processes],           [$plugin_processes],         [Process statistics])
7169AC_PLUGIN([procevent],           [$plugin_procevent],         [Process event (start, stop) statistics])
7170AC_PLUGIN([protocols],           [$plugin_protocols],         [Protocol (IP, TCP, ...) statistics])
7171AC_PLUGIN([python],              [$plugin_python],            [Embed a Python interpreter])
7172AC_PLUGIN([redfish],             [$with_libredfish],          [Redfish plugin])
7173AC_PLUGIN([redis],               [$with_libhiredis],          [Redis plugin])
7174AC_PLUGIN([routeros],            [$with_librouteros],         [RouterOS plugin])
7175AC_PLUGIN([rrdcached],           [$librrd_rrdc_update],       [RRDTool output plugin])
7176AC_PLUGIN([rrdtool],             [$with_librrd],              [RRDTool output plugin])
7177AC_PLUGIN([sensors],             [$with_libsensors],          [lm_sensors statistics])
7178AC_PLUGIN([serial],              [$plugin_serial],            [serial port traffic])
7179AC_PLUGIN([sigrok],              [$with_libsigrok],           [sigrok acquisition sources])
7180AC_PLUGIN([slurm],               [$with_libslurm],            [SLURM jobs and nodes status])
7181AC_PLUGIN([smart],               [$plugin_smart],             [SMART statistics])
7182AC_PLUGIN([snmp],                [$with_libnetsnmp],          [SNMP querying plugin])
7183AC_PLUGIN([snmp_agent],          [$with_libnetsnmpagent],     [SNMP agent plugin])
7184AC_PLUGIN([statsd],              [yes],                       [StatsD plugin])
7185AC_PLUGIN([swap],                [$plugin_swap],              [Swap usage statistics])
7186AC_PLUGIN([synproxy],            [$plugin_synproxy],          [Synproxy stats plugin])
7187AC_PLUGIN([sysevent],            [$plugin_sysevent],          [rsyslog events])
7188AC_PLUGIN([syslog],              [$have_syslog],              [Syslog logging plugin])
7189AC_PLUGIN([table],               [yes],                       [Parsing of tabular data])
7190AC_PLUGIN([tail],                [yes],                       [Parsing of logfiles])
7191AC_PLUGIN([tail_csv],            [yes],                       [Parsing of CSV files])
7192AC_PLUGIN([tape],                [$plugin_tape],              [Tape drive statistics])
7193AC_PLUGIN([target_notification], [yes],                       [The notification target])
7194AC_PLUGIN([target_replace],      [yes],                       [The replace target])
7195AC_PLUGIN([target_scale],        [yes],                       [The scale target])
7196AC_PLUGIN([target_set],          [yes],                       [The set target])
7197AC_PLUGIN([target_v5upgrade],    [yes],                       [The v5upgrade target])
7198AC_PLUGIN([tcpconns],            [$plugin_tcpconns],          [TCP connection statistics])
7199AC_PLUGIN([teamspeak2],          [yes],                       [TeamSpeak2 server statistics])
7200AC_PLUGIN([ted],                 [$plugin_ted],               [Read The Energy Detective values])
7201AC_PLUGIN([thermal],             [$plugin_thermal],           [Linux ACPI thermal zone statistics])
7202AC_PLUGIN([threshold],           [yes],                       [Threshold checking plugin])
7203AC_PLUGIN([tokyotyrant],         [$with_libtokyotyrant],      [TokyoTyrant database statistics])
7204AC_PLUGIN([turbostat],           [$plugin_turbostat],         [Advanced statistic on Intel cpu states])
7205AC_PLUGIN([ubi],                 [$plugin_ubi],               [UBIFS statistics])
7206AC_PLUGIN([unixsock],            [yes],                       [Unixsock communication plugin])
7207AC_PLUGIN([uptime],              [$plugin_uptime],            [Uptime statistics])
7208AC_PLUGIN([users],               [$plugin_users],             [User statistics])
7209AC_PLUGIN([uuid],                [yes],                       [UUID as hostname plugin])
7210AC_PLUGIN([varnish],             [$with_libvarnish],          [Varnish cache statistics])
7211AC_PLUGIN([virt],                [$plugin_virt],              [Virtual machine statistics])
7212AC_PLUGIN([vmem],                [$plugin_vmem],              [Virtual memory statistics])
7213AC_PLUGIN([vserver],             [$plugin_vserver],           [Linux VServer statistics])
7214AC_PLUGIN([wireless],            [$plugin_wireless],          [Wireless statistics])
7215AC_PLUGIN([write_graphite],      [yes],                       [Graphite / Carbon output plugin])
7216AC_PLUGIN([write_http],          [$with_libcurl],             [HTTP output plugin])
7217AC_PLUGIN([write_influxdb_udp],  [yes],                       [Influxdb udp output plugin])
7218AC_PLUGIN([write_kafka],         [$with_librdkafka],          [Kafka output plugin])
7219AC_PLUGIN([write_log],           [yes],                       [Log output plugin])
7220AC_PLUGIN([write_mongodb],       [$with_libmongoc],           [MongoDB output plugin])
7221AC_PLUGIN([write_prometheus],    [$plugin_write_prometheus],  [Prometheus write plugin])
7222AC_PLUGIN([write_redis],         [$with_libhiredis],          [Redis output plugin])
7223AC_PLUGIN([write_riemann],       [$with_libriemann_client],   [Riemann output plugin])
7224AC_PLUGIN([write_sensu],         [yes],                       [Sensu output plugin])
7225AC_PLUGIN([write_stackdriver],   [$plugin_write_stackdriver], [Google Stackdriver Monitoring output plugin])
7226AC_PLUGIN([write_syslog],        [yes],                       [Syslog output plugin])
7227AC_PLUGIN([write_tsdb],          [yes],                       [TSDB output plugin])
7228AC_PLUGIN([xencpu],              [$plugin_xencpu],            [Xen Host CPU usage])
7229AC_PLUGIN([xmms],                [$with_libxmms],             [XMMS statistics])
7230AC_PLUGIN([zfs_arc],             [$plugin_zfs_arc],           [ZFS ARC statistics])
7231AC_PLUGIN([zone],                [$plugin_zone],              [Solaris container statistics])
7232AC_PLUGIN([zookeeper],           [yes],                       [Zookeeper statistics])
7233
7234dnl Default configuration file
7235# Load either syslog or logfile
7236LOAD_PLUGIN_SYSLOG=""
7237LOAD_PLUGIN_LOGFILE=""
7238LOAD_PLUGIN_LOG_LOGSTASH=""
7239
7240AC_MSG_CHECKING([which default log plugin to load])
7241default_log_plugin="none"
7242if test "x$enable_syslog" = "xyes"; then
7243  default_log_plugin="syslog"
7244else
7245  LOAD_PLUGIN_SYSLOG="##"
7246fi
7247
7248if test "x$enable_logfile" = "xyes"; then
7249  if test "x$default_log_plugin" = "xnone"; then
7250    default_log_plugin="logfile"
7251  else
7252    LOAD_PLUGIN_LOGFILE="#"
7253  fi
7254else
7255  LOAD_PLUGIN_LOGFILE="##"
7256fi
7257
7258if test "x$enable_log_logstash" = "xyes"; then
7259  LOAD_PLUGIN_LOG_LOGSTASH="#"
7260else
7261  LOAD_PLUGIN_LOG_LOGSTASH="##"
7262fi
7263
7264AC_MSG_RESULT([$default_log_plugin])
7265
7266AC_SUBST([LOAD_PLUGIN_SYSLOG])
7267AC_SUBST([LOAD_PLUGIN_LOGFILE])
7268AC_SUBST([LOAD_PLUGIN_LOG_LOGSTASH])
7269
7270if test "x$enable_debug" = "xyes"; then
7271  DEFAULT_LOG_LEVEL="debug"
7272else
7273  DEFAULT_LOG_LEVEL="info"
7274fi
7275AC_SUBST([DEFAULT_LOG_LEVEL])
7276
7277# Load only one of rrdtool, network, csv in the default config.
7278LOAD_PLUGIN_RRDTOOL=""
7279LOAD_PLUGIN_NETWORK=""
7280LOAD_PLUGIN_CSV=""
7281
7282AC_MSG_CHECKING([which default write plugin to load])
7283default_write_plugin="none"
7284if test "x$enable_rrdtool" = "xyes"; then
7285  default_write_plugin="rrdtool"
7286else
7287  LOAD_PLUGIN_RRDTOOL="##"
7288fi
7289
7290if test "x$enable_network" = "xyes"; then
7291  if test "x$default_write_plugin" = "xnone"; then
7292    default_write_plugin="network"
7293  else
7294    LOAD_PLUGIN_NETWORK="#"
7295  fi
7296else
7297  LOAD_PLUGIN_NETWORK="##"
7298fi
7299
7300if test "x$enable_csv" = "xyes"; then
7301  if test "x$default_write_plugin" = "xnone"; then
7302    default_write_plugin="csv"
7303  else
7304    LOAD_PLUGIN_CSV="#"
7305  fi
7306else
7307  LOAD_PLUGIN_CSV="##"
7308fi
7309AC_MSG_RESULT([$default_write_plugin])
7310
7311AC_SUBST([LOAD_PLUGIN_RRDTOOL])
7312AC_SUBST([LOAD_PLUGIN_NETWORK])
7313AC_SUBST([LOAD_PLUGIN_CSV])
7314
7315dnl Perl bindings
7316PERL_BINDINGS_OPTIONS="PREFIX=${prefix}"
7317AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
7318[
7319  if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
7320    PERL_BINDINGS_OPTIONS="$withval"
7321    with_perl_bindings="yes"
7322  else
7323    with_perl_bindings="$withval"
7324  fi
7325],
7326[
7327  if test "x$PERL" != "x"; then
7328    with_perl_bindings="yes"
7329  else
7330    with_perl_bindings="no (no perl interpreter found)"
7331  fi
7332])
7333
7334if test "x$with_perl_bindings" = "xyes"; then
7335  AC_MSG_CHECKING([for the ExtUtils::MakeMaker module])
7336  if $PERL -MExtUtils::MakeMaker -e '' 2>/dev/null; then
7337    AC_MSG_RESULT([yes])
7338  else
7339    AC_MSG_RESULT([no])
7340    with_perl_bindings="no (ExtUtils::MakeMaker not found)"
7341  fi
7342fi
7343
7344if test "x$with_perl_bindings" = "xyes"; then
7345  PERL_BINDINGS="perl"
7346else
7347  PERL_BINDINGS=""
7348fi
7349
7350AC_SUBST([PERL_BINDINGS])
7351AC_SUBST([PERL_BINDINGS_OPTIONS])
7352
7353dnl libcollectdclient
7354LCC_VERSION_MAJOR=`echo $PACKAGE_VERSION | cut -d'.' -f1`
7355LCC_VERSION_MINOR=`echo $PACKAGE_VERSION | cut -d'.' -f2`
7356LCC_VERSION_PATCH=`echo $PACKAGE_VERSION | cut -d'.' -f3`
7357
7358LCC_VERSION_EXTRA=`echo $PACKAGE_VERSION | cut -d'.' -f4-`
7359
7360LCC_VERSION_STRING="$LCC_VERSION_MAJOR.$LCC_VERSION_MINOR.$LCC_VERSION_PATCH"
7361
7362AC_SUBST([LCC_VERSION_MAJOR])
7363AC_SUBST([LCC_VERSION_MINOR])
7364AC_SUBST([LCC_VERSION_PATCH])
7365AC_SUBST([LCC_VERSION_EXTRA])
7366AC_SUBST([LCC_VERSION_STRING])
7367
7368AC_CONFIG_FILES([src/libcollectdclient/collectd/lcc_features.h])
7369
7370if test "x$GCC" = "xyes"; then
7371  AM_CFLAGS="-Wall"
7372  AM_CXXFLAGS="-Wall"
7373  if test "x$enable_werror" != "xno"; then
7374    AM_CFLAGS="$AM_CFLAGS "
7375    AM_CXXFLAGS="$AM_CXXFLAGS "
7376  fi
7377fi
7378
7379AC_SUBST([AM_CFLAGS])
7380AC_SUBST([AM_CXXFLAGS])
7381
7382AC_CONFIG_FILES([ \
7383  Makefile \
7384  src/collectd.conf \
7385  src/libcollectdclient/libcollectdclient.pc \
7386])
7387
7388AC_OUTPUT
7389
7390if test "x$with_librrd" = "xyes" && test "x$librrd_threadsafe" != "xyes"; then
7391  with_librrd="yes (warning: librrd is not thread-safe)"
7392fi
7393
7394if test "x$with_libperl" = "xyes"; then
7395  with_libperl="yes (version `$PERL -MConfig -e 'print $Config{version};'`)"
7396else
7397  enable_perl="no (needs libperl)"
7398fi
7399
7400if test "x$enable_perl" = "xno" && test "x$c_cv_have_perl_ithreads" = "xno"; then
7401  enable_perl="no (libperl doesn't support ithreads)"
7402fi
7403
7404if test "x$with_perl_bindings" = "xyes" && test "x$PERL_BINDINGS_OPTIONS" != "x"; then
7405  with_perl_bindings="yes ($PERL_BINDINGS_OPTIONS)"
7406fi
7407
7408AC_MSG_RESULT()
7409AC_MSG_RESULT([Configuration:])
7410AC_MSG_RESULT([  Build:])
7411AC_MSG_RESULT([    Platform  . . . . . . $ac_system])
7412AC_MSG_RESULT([    Compiler vendor . . . $ax_cv_c_compiler_vendor])
7413AC_MSG_RESULT([    CC  . . . . . . . . . $CC])
7414AC_MSG_RESULT([    CFLAGS  . . . . . . . $AM_CFLAGS $CFLAGS])
7415AC_MSG_RESULT([    CXXFLAGS  . . . . . . $AM_CXXFLAGS $CXXFLAGS])
7416AC_MSG_RESULT([    CPP . . . . . . . . . $CPP])
7417AC_MSG_RESULT([    CPPFLAGS  . . . . . . $CPPFLAGS])
7418AC_MSG_RESULT([    GRPC_CPP_PLUGIN . . . $GRPC_CPP_PLUGIN])
7419AC_MSG_RESULT([    LD  . . . . . . . . . $LD])
7420AC_MSG_RESULT([    LDFLAGS . . . . . . . $LDFLAGS])
7421AC_MSG_RESULT([    PROTOC  . . . . . . . $PROTOC])
7422AC_MSG_RESULT([    YACC  . . . . . . . . $YACC])
7423AC_MSG_RESULT([    YFLAGS  . . . . . . . $YFLAGS])
7424AC_MSG_RESULT()
7425AC_MSG_RESULT([  Libraries:])
7426AC_MSG_RESULT([    intel mic . . . . . . $with_mic])
7427AC_MSG_RESULT([    libaquaero5 . . . . . $with_libaquaero5])
7428AC_MSG_RESULT([    libatasmart . . . . . $with_libatasmart])
7429AC_MSG_RESULT([    libcurl . . . . . . . $with_libcurl])
7430AC_MSG_RESULT([    libdbi  . . . . . . . $with_libdbi])
7431AC_MSG_RESULT([    libdpdk . . . . . . . $with_libdpdk])
7432AC_MSG_RESULT([    libesmtp  . . . . . . $with_libesmtp])
7433AC_MSG_RESULT([    libganglia  . . . . . $with_libganglia])
7434AC_MSG_RESULT([    libgcrypt . . . . . . $with_libgcrypt])
7435AC_MSG_RESULT([    libgps  . . . . . . . $with_libgps])
7436AC_MSG_RESULT([    libgrpc++ . . . . . . $with_libgrpcpp])
7437AC_MSG_RESULT([    libhiredis  . . . . . $with_libhiredis])
7438AC_MSG_RESULT([    libi2c-dev  . . . . . $with_libi2c])
7439AC_MSG_RESULT([    libiokit  . . . . . . $with_libiokit])
7440AC_MSG_RESULT([    libiptc . . . . . . . $with_libiptc])
7441AC_MSG_RESULT([    libjansson  . . . . . $with_libjansson])
7442AC_MSG_RESULT([    libjevents  . . . . . $with_libjevents])
7443AC_MSG_RESULT([    libjvm  . . . . . . . $with_java])
7444AC_MSG_RESULT([    libkstat  . . . . . . $with_kstat])
7445AC_MSG_RESULT([    libkvm  . . . . . . . $with_libkvm])
7446AC_MSG_RESULT([    libldap . . . . . . . $with_libldap])
7447AC_MSG_RESULT([    liblua  . . . . . . . $with_liblua])
7448AC_MSG_RESULT([    libmemcached  . . . . $with_libmemcached])
7449AC_MSG_RESULT([    libmicrohttpd . . . . $with_libmicrohttpd])
7450AC_MSG_RESULT([    libmnl  . . . . . . . $with_libmnl])
7451AC_MSG_RESULT([    libmodbus . . . . . . $with_libmodbus])
7452AC_MSG_RESULT([    libmongoc . . . . . . $with_libmongoc])
7453AC_MSG_RESULT([    libmosquitto  . . . . $with_libmosquitto])
7454AC_MSG_RESULT([    libmysql  . . . . . . $with_libmysql])
7455AC_MSG_RESULT([    libnetapp . . . . . . $with_libnetapp])
7456AC_MSG_RESULT([    libnetsnmp  . . . . . $with_libnetsnmp])
7457AC_MSG_RESULT([    libnetsnmpagent . . . $with_libnetsnmpagent])
7458AC_MSG_RESULT([    libnotify . . . . . . $with_libnotify])
7459AC_MSG_RESULT([    libnvidia-ml  . . . . $with_cuda])
7460AC_MSG_RESULT([    libopenipmi . . . . . $with_libopenipmipthread])
7461AC_MSG_RESULT([    liboping  . . . . . . $with_liboping])
7462AC_MSG_RESULT([    libowcapi . . . . . . $with_libowcapi])
7463AC_MSG_RESULT([    libpcap . . . . . . . $with_libpcap])
7464AC_MSG_RESULT([    libperfstat . . . . . $with_perfstat])
7465AC_MSG_RESULT([    libperl . . . . . . . $with_libperl])
7466AC_MSG_RESULT([    libpmwapi . . . . . . $with_libpmwapi])
7467AC_MSG_RESULT([    libpq . . . . . . . . $with_libpq])
7468AC_MSG_RESULT([    libpqos . . . . . . . $with_libpqos])
7469AC_MSG_RESULT([    libprotobuf . . . . . $with_libprotobuf])
7470AC_MSG_RESULT([    libprotobuf-c . . . . $with_libprotobuf_c])
7471AC_MSG_RESULT([    libpython . . . . . . $with_libpython])
7472AC_MSG_RESULT([    libqpid-proton .  . . $with_libqpid_proton])
7473AC_MSG_RESULT([    librabbitmq . . . . . $with_librabbitmq])
7474AC_MSG_RESULT([    libriemann-client . . $with_libriemann_client])
7475AC_MSG_RESULT([    librdkafka  . . . . . $with_librdkafka])
7476AC_MSG_RESULT([    librouteros . . . . . $with_librouteros])
7477AC_MSG_RESULT([    librrd  . . . . . . . $with_librrd])
7478AC_MSG_RESULT([    libsensors  . . . . . $with_libsensors])
7479AC_MSG_RESULT([    libsigrok   . . . . . $with_libsigrok])
7480AC_MSG_RESULT([    libssl  . . . . . . . $with_libssl])
7481AC_MSG_RESULT([    libslurm .  . . . . . $with_libslurm])
7482AC_MSG_RESULT([    libstatgrab . . . . . $with_libstatgrab])
7483AC_MSG_RESULT([    libtokyotyrant  . . . $with_libtokyotyrant])
7484AC_MSG_RESULT([    libudev . . . . . . . $with_libudev])
7485AC_MSG_RESULT([    libupsclient  . . . . $with_libupsclient])
7486AC_MSG_RESULT([    libvarnish  . . . . . $with_libvarnish])
7487AC_MSG_RESULT([    libvirt . . . . . . . $with_libvirt])
7488AC_MSG_RESULT([    libxenctrl  . . . . . $with_libxenctrl])
7489AC_MSG_RESULT([    libxml2 . . . . . . . $with_libxml2])
7490AC_MSG_RESULT([    libxmms . . . . . . . $with_libxmms])
7491AC_MSG_RESULT([    libyajl . . . . . . . $with_libyajl])
7492AC_MSG_RESULT([    oracle  . . . . . . . $with_oracle])
7493AC_MSG_RESULT([    protobuf-c  . . . . . $have_protoc_c])
7494AC_MSG_RESULT([    protoc 3  . . . . . . $have_protoc3])
7495AC_MSG_RESULT()
7496AC_MSG_RESULT([  Features:])
7497AC_MSG_RESULT([    daemon mode . . . . . $enable_daemon])
7498AC_MSG_RESULT([    debug . . . . . . . . $enable_debug])
7499AC_MSG_RESULT()
7500AC_MSG_RESULT([  Bindings:])
7501AC_MSG_RESULT([    perl  . . . . . . . . $with_perl_bindings])
7502AC_MSG_RESULT()
7503AC_MSG_RESULT([  Modules:])
7504AC_MSG_RESULT([    aggregation . . . . . $enable_aggregation])
7505AC_MSG_RESULT([    amqp    . . . . . . . $enable_amqp])
7506AC_MSG_RESULT([    amqp1   . . . . . . . $enable_amqp1])
7507AC_MSG_RESULT([    apache  . . . . . . . $enable_apache])
7508AC_MSG_RESULT([    apcups  . . . . . . . $enable_apcups])
7509AC_MSG_RESULT([    apple_sensors . . . . $enable_apple_sensors])
7510AC_MSG_RESULT([    aquaero . . . . . . . $enable_aquaero])
7511AC_MSG_RESULT([    ascent  . . . . . . . $enable_ascent])
7512AC_MSG_RESULT([    barometer . . . . . . $enable_barometer])
7513AC_MSG_RESULT([    battery . . . . . . . $enable_battery])
7514AC_MSG_RESULT([    bind  . . . . . . . . $enable_bind])
7515AC_MSG_RESULT([    buddyinfo . . . . . . $enable_buddyinfo])
7516AC_MSG_RESULT([    capabilities  . . . . $enable_capabilities])
7517AC_MSG_RESULT([    ceph  . . . . . . . . $enable_ceph])
7518AC_MSG_RESULT([    cgroups . . . . . . . $enable_cgroups])
7519AC_MSG_RESULT([    chrony. . . . . . . . $enable_chrony])
7520AC_MSG_RESULT([    check_uptime. . . . . $enable_check_uptime])
7521AC_MSG_RESULT([    connectivity. . . . . $enable_connectivity])
7522AC_MSG_RESULT([    conntrack . . . . . . $enable_conntrack])
7523AC_MSG_RESULT([    contextswitch . . . . $enable_contextswitch])
7524AC_MSG_RESULT([    cpu . . . . . . . . . $enable_cpu])
7525AC_MSG_RESULT([    cpufreq . . . . . . . $enable_cpufreq])
7526AC_MSG_RESULT([    cpusleep  . . . . . . $enable_cpusleep])
7527AC_MSG_RESULT([    csv . . . . . . . . . $enable_csv])
7528AC_MSG_RESULT([    curl  . . . . . . . . $enable_curl])
7529AC_MSG_RESULT([    curl_json . . . . . . $enable_curl_json])
7530AC_MSG_RESULT([    curl_xml  . . . . . . $enable_curl_xml])
7531AC_MSG_RESULT([    dbi . . . . . . . . . $enable_dbi])
7532AC_MSG_RESULT([    dcpmm  . . . . . .  . $enable_dcpmm])
7533AC_MSG_RESULT([    df  . . . . . . . . . $enable_df])
7534AC_MSG_RESULT([    disk  . . . . . . . . $enable_disk])
7535AC_MSG_RESULT([    dns . . . . . . . . . $enable_dns])
7536AC_MSG_RESULT([    dpdkevents. . . . . . $enable_dpdkevents])
7537AC_MSG_RESULT([    dpdkstat  . . . . . . $enable_dpdkstat])
7538AC_MSG_RESULT([    dpdk_telemetry. . . . $enable_dpdk_telemetry])
7539AC_MSG_RESULT([    drbd  . . . . . . . . $enable_drbd])
7540AC_MSG_RESULT([    email . . . . . . . . $enable_email])
7541AC_MSG_RESULT([    entropy . . . . . . . $enable_entropy])
7542AC_MSG_RESULT([    ethstat . . . . . . . $enable_ethstat])
7543AC_MSG_RESULT([    exec  . . . . . . . . $enable_exec])
7544AC_MSG_RESULT([    fhcount . . . . . . . $enable_fhcount])
7545AC_MSG_RESULT([    filecount . . . . . . $enable_filecount])
7546AC_MSG_RESULT([    fscache . . . . . . . $enable_fscache])
7547AC_MSG_RESULT([    gmond . . . . . . . . $enable_gmond])
7548AC_MSG_RESULT([    gps . . . . . . . . . $enable_gps])
7549AC_MSG_RESULT([    gpu_nvidia  . . . . . $enable_gpu_nvidia])
7550AC_MSG_RESULT([    grpc  . . . . . . . . $enable_grpc])
7551AC_MSG_RESULT([    hddtemp . . . . . . . $enable_hddtemp])
7552AC_MSG_RESULT([    hugepages . . . . . . $enable_hugepages])
7553AC_MSG_RESULT([    infiniband  . . . . . $enable_infiniband])
7554AC_MSG_RESULT([    intel_pmu . . . . . . $enable_intel_pmu])
7555AC_MSG_RESULT([    intel_rdt . . . . . . $enable_intel_rdt])
7556AC_MSG_RESULT([    interface . . . . . . $enable_interface])
7557AC_MSG_RESULT([    ipc . . . . . . . . . $enable_ipc])
7558AC_MSG_RESULT([    ipmi  . . . . . . . . $enable_ipmi])
7559AC_MSG_RESULT([    iptables  . . . . . . $enable_iptables])
7560AC_MSG_RESULT([    ipstats . . . . . . . $enable_ipstats])
7561AC_MSG_RESULT([    ipvs  . . . . . . . . $enable_ipvs])
7562AC_MSG_RESULT([    irq . . . . . . . . . $enable_irq])
7563AC_MSG_RESULT([    java  . . . . . . . . $enable_java])
7564AC_MSG_RESULT([    load  . . . . . . . . $enable_load])
7565AC_MSG_RESULT([    logfile . . . . . . . $enable_logfile])
7566AC_MSG_RESULT([    logparser . . . . . . $enable_logparser])
7567AC_MSG_RESULT([    log_logstash  . . . . $enable_log_logstash])
7568AC_MSG_RESULT([    lpar  . . . . . . . . $enable_lpar])
7569AC_MSG_RESULT([    lua . . . . . . . . . $enable_lua])
7570AC_MSG_RESULT([    madwifi . . . . . . . $enable_madwifi])
7571AC_MSG_RESULT([    match_empty_counter . $enable_match_empty_counter])
7572AC_MSG_RESULT([    match_hashed  . . . . $enable_match_hashed])
7573AC_MSG_RESULT([    match_regex . . . . . $enable_match_regex])
7574AC_MSG_RESULT([    match_timediff  . . . $enable_match_timediff])
7575AC_MSG_RESULT([    match_value . . . . . $enable_match_value])
7576AC_MSG_RESULT([    mbmon . . . . . . . . $enable_mbmon])
7577AC_MSG_RESULT([    mcelog  . . . . . . . $enable_mcelog])
7578AC_MSG_RESULT([    md  . . . . . . . . . $enable_md])
7579AC_MSG_RESULT([    mdevents  . . . . . . $enable_mdevents])
7580AC_MSG_RESULT([    memcachec . . . . . . $enable_memcachec])
7581AC_MSG_RESULT([    memcached . . . . . . $enable_memcached])
7582AC_MSG_RESULT([    memory  . . . . . . . $enable_memory])
7583AC_MSG_RESULT([    mic . . . . . . . . . $enable_mic])
7584AC_MSG_RESULT([    modbus  . . . . . . . $enable_modbus])
7585AC_MSG_RESULT([    mqtt  . . . . . . . . $enable_mqtt])
7586AC_MSG_RESULT([    multimeter  . . . . . $enable_multimeter])
7587AC_MSG_RESULT([    mysql . . . . . . . . $enable_mysql])
7588AC_MSG_RESULT([    netapp  . . . . . . . $enable_netapp])
7589AC_MSG_RESULT([    netlink . . . . . . . $enable_netlink])
7590AC_MSG_RESULT([    netstat_udp . . . . . $enable_netstat_udp])
7591AC_MSG_RESULT([    network . . . . . . . $enable_network])
7592AC_MSG_RESULT([    nfs . . . . . . . . . $enable_nfs])
7593AC_MSG_RESULT([    nginx . . . . . . . . $enable_nginx])
7594AC_MSG_RESULT([    notify_desktop  . . . $enable_notify_desktop])
7595AC_MSG_RESULT([    notify_email  . . . . $enable_notify_email])
7596AC_MSG_RESULT([    notify_nagios . . . . $enable_notify_nagios])
7597AC_MSG_RESULT([    ntpd  . . . . . . . . $enable_ntpd])
7598AC_MSG_RESULT([    numa  . . . . . . . . $enable_numa])
7599AC_MSG_RESULT([    nut . . . . . . . . . $enable_nut])
7600AC_MSG_RESULT([    olsrd . . . . . . . . $enable_olsrd])
7601AC_MSG_RESULT([    onewire . . . . . . . $enable_onewire])
7602AC_MSG_RESULT([    openldap  . . . . . . $enable_openldap])
7603AC_MSG_RESULT([    openvpn . . . . . . . $enable_openvpn])
7604AC_MSG_RESULT([    oracle  . . . . . . . $enable_oracle])
7605AC_MSG_RESULT([    ovs_events  . . . . . $enable_ovs_events])
7606AC_MSG_RESULT([    ovs_stats . . . . . . $enable_ovs_stats])
7607AC_MSG_RESULT([    pcie_errors . . . . . $enable_pcie_errors])
7608AC_MSG_RESULT([    perl  . . . . . . . . $enable_perl])
7609AC_MSG_RESULT([    pf  . . . . . . . . . $enable_pf])
7610AC_MSG_RESULT([    pinba . . . . . . . . $enable_pinba])
7611AC_MSG_RESULT([    ping  . . . . . . . . $enable_ping])
7612AC_MSG_RESULT([    postgresql  . . . . . $enable_postgresql])
7613AC_MSG_RESULT([    powerdns  . . . . . . $enable_powerdns])
7614AC_MSG_RESULT([    processes . . . . . . $enable_processes])
7615AC_MSG_RESULT([    procevent . . . . . . $enable_procevent])
7616AC_MSG_RESULT([    protocols . . . . . . $enable_protocols])
7617AC_MSG_RESULT([    python  . . . . . . . $enable_python])
7618AC_MSG_RESULT([    redfish . . . . . . . $enable_redfish])
7619AC_MSG_RESULT([    redis . . . . . . . . $enable_redis])
7620AC_MSG_RESULT([    routeros  . . . . . . $enable_routeros])
7621AC_MSG_RESULT([    rrdcached . . . . . . $enable_rrdcached])
7622AC_MSG_RESULT([    rrdtool . . . . . . . $enable_rrdtool])
7623AC_MSG_RESULT([    sensors . . . . . . . $enable_sensors])
7624AC_MSG_RESULT([    serial  . . . . . . . $enable_serial])
7625AC_MSG_RESULT([    sigrok  . . . . . . . $enable_sigrok])
7626AC_MSG_RESULT([    slurm . . . . . . . . $enable_slurm])
7627AC_MSG_RESULT([    smart . . . . . . . . $enable_smart])
7628AC_MSG_RESULT([    snmp  . . . . . . . . $enable_snmp])
7629AC_MSG_RESULT([    snmp_agent  . . . . . $enable_snmp_agent])
7630AC_MSG_RESULT([    statsd  . . . . . . . $enable_statsd])
7631AC_MSG_RESULT([    swap  . . . . . . . . $enable_swap])
7632AC_MSG_RESULT([    synproxy  . . . . . . $enable_synproxy])
7633AC_MSG_RESULT([    sysevent. . . . . . . $enable_sysevent])
7634AC_MSG_RESULT([    syslog  . . . . . . . $enable_syslog])
7635AC_MSG_RESULT([    table . . . . . . . . $enable_table])
7636AC_MSG_RESULT([    tail_csv  . . . . . . $enable_tail_csv])
7637AC_MSG_RESULT([    tail  . . . . . . . . $enable_tail])
7638AC_MSG_RESULT([    tape  . . . . . . . . $enable_tape])
7639AC_MSG_RESULT([    target_notification . $enable_target_notification])
7640AC_MSG_RESULT([    target_replace  . . . $enable_target_replace])
7641AC_MSG_RESULT([    target_scale  . . . . $enable_target_scale])
7642AC_MSG_RESULT([    target_set  . . . . . $enable_target_set])
7643AC_MSG_RESULT([    target_v5upgrade  . . $enable_target_v5upgrade])
7644AC_MSG_RESULT([    tcpconns  . . . . . . $enable_tcpconns])
7645AC_MSG_RESULT([    teamspeak2  . . . . . $enable_teamspeak2])
7646AC_MSG_RESULT([    ted . . . . . . . . . $enable_ted])
7647AC_MSG_RESULT([    thermal . . . . . . . $enable_thermal])
7648AC_MSG_RESULT([    threshold . . . . . . $enable_threshold])
7649AC_MSG_RESULT([    tokyotyrant . . . . . $enable_tokyotyrant])
7650AC_MSG_RESULT([    turbostat . . . . . . $enable_turbostat])
7651AC_MSG_RESULT([    ubi . . . . . . . . . $enable_ubi])
7652AC_MSG_RESULT([    unixsock  . . . . . . $enable_unixsock])
7653AC_MSG_RESULT([    uptime  . . . . . . . $enable_uptime])
7654AC_MSG_RESULT([    users . . . . . . . . $enable_users])
7655AC_MSG_RESULT([    uuid  . . . . . . . . $enable_uuid])
7656AC_MSG_RESULT([    varnish . . . . . . . $enable_varnish])
7657AC_MSG_RESULT([    virt  . . . . . . . . $enable_virt])
7658AC_MSG_RESULT([    vmem  . . . . . . . . $enable_vmem])
7659AC_MSG_RESULT([    vserver . . . . . . . $enable_vserver])
7660AC_MSG_RESULT([    wireless  . . . . . . $enable_wireless])
7661AC_MSG_RESULT([    write_graphite  . . . $enable_write_graphite])
7662AC_MSG_RESULT([    write_http  . . . . . $enable_write_http])
7663AC_MSG_RESULT([    write_influxdb_udp. . $enable_write_influxdb_udp])
7664AC_MSG_RESULT([    write_kafka . . . . . $enable_write_kafka])
7665AC_MSG_RESULT([    write_log . . . . . . $enable_write_log])
7666AC_MSG_RESULT([    write_mongodb . . . . $enable_write_mongodb])
7667AC_MSG_RESULT([    write_prometheus. . . $enable_write_prometheus])
7668AC_MSG_RESULT([    write_redis . . . . . $enable_write_redis])
7669AC_MSG_RESULT([    write_riemann . . . . $enable_write_riemann])
7670AC_MSG_RESULT([    write_sensu . . . . . $enable_write_sensu])
7671AC_MSG_RESULT([    write_stackdriver . . $enable_write_stackdriver])
7672AC_MSG_RESULT([    write_syslog . .  . . $enable_write_syslog])
7673AC_MSG_RESULT([    write_tsdb  . . . . . $enable_write_tsdb])
7674AC_MSG_RESULT([    xencpu  . . . . . . . $enable_xencpu])
7675AC_MSG_RESULT([    xmms  . . . . . . . . $enable_xmms])
7676AC_MSG_RESULT([    zfs_arc . . . . . . . $enable_zfs_arc])
7677AC_MSG_RESULT([    zone  . . . . . . . . $enable_zone])
7678AC_MSG_RESULT([    zookeeper . . . . . . $enable_zookeeper])
7679AC_MSG_RESULT()
7680
7681if test "x$dependency_error" = "xyes"; then
7682  AC_MSG_ERROR("Some plugins are missing dependencies - see the summary above for details")
7683fi
7684
7685if test "x$dependency_warning" = "xyes"; then
7686  AC_MSG_WARN("Some plugins seem to have missing dependencies but have been enabled forcibly - see the summary above for details")
7687fi
7688
7689# vim: set fdm=marker sw=2 sts=2 ts=2 et :
7690
7691