check_pgsql: update copyright
[monitoring-plugins.git] / configure.ac
blob8594238fe7e5ddb0ad674368ae0c344c9509ed00
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.64)
3 AC_INIT(monitoring-plugins,2.4git)
4 AC_CONFIG_SRCDIR(NPTest.pm)
5 AC_CONFIG_FILES([gl/Makefile])
6 AC_CONFIG_AUX_DIR(build-aux)
7 AM_INIT_AUTOMAKE([1.8.3])
8 AM_SILENT_RULES([yes])
9 AM_MAINTAINER_MODE([enable])
10 AC_CONFIG_HEADERS([config.h])
11 AC_CANONICAL_HOST
13 DEFAULT_PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
14 RELEASE=1
15 AC_SUBST(RELEASE)
17 dnl Deprecated configure options
20 dnl Append user (-o), group (-g), mode (-m) to install command
21 dnl There is an assumption that this is possible with ./configure's chosen install command
22 extra_install_args=""
23 AC_ARG_WITH(nagios_user,
24         ACX_HELP_STRING([--with-nagios-user=USER],
25                 [Installs executables with this user. Defaults to install user]),
26         extra_install_args="-o $withval")
27 AC_ARG_WITH(nagios_group,
28         ACX_HELP_STRING([--with-nagios-group=GROUP],
29                 [Installs executables with this group. Defaults to install user]),
30         extra_install_args="$extra_install_args -g $withval")
31 AC_ARG_WITH(world_permissions,
32         ACX_HELP_STRING([--without-world-permissions],
33                 [Installs executables without world permissions]))
35 if test "x$with_world_permissions" = xno ; then
36         extra_install_args="$extra_install_args -m 0550"
39 INSTALL="$INSTALL $extra_install_args"
40 INSTALL_STRIP_PROGRAM="$INSTALL_STRIP_PROGRAM $extra_install_args"
41 AC_SUBST(INSTALL)
43 AC_PROG_CC
44 gl_EARLY
45 AC_PROG_GCC_TRADITIONAL
46 AC_PROG_LIBTOOL
48 AM_PROG_CC_C_O
50 AC_FUNC_ERROR_AT_LINE
51 AC_SYS_LARGEFILE
53 ifdef([AC_FUNC_STRTOD],[AC_FUNC_STRTOD],[AM_FUNC_STRTOD])
55 PLUGIN_TEST=`echo $srcdir/plugins/t/*.t|sed -e 's,\.*/plugins/,,g'`
56 AC_SUBST(PLUGIN_TEST)dnl
58 SCRIPT_TEST=`echo $srcdir/plugins-scripts/t/*.t|sed -e 's,\.*/plugins-scripts/,,g'`
59 AC_SUBST(SCRIPT_TEST)dnl
61 WARRANTY="The Monitoring Plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\ncopies of the plugins under the terms of the GNU General Public License.\nFor more information about these matters, see the file named COPYING.\n"
62 AC_SUBST(WARRANTY)
64 SUPPORT="Send email to help@monitoring-plugins.org if you have questions regarding use\nof this software. To submit patches or suggest improvements, send email to\ndevel@monitoring-plugins.org. Please include version information with all\ncorrespondence (when possible, use output from the --version option of the\nplugin itself).\n"
65 AC_SUBST(SUPPORT)
67 dnl CGIURL has changed for Nagios with 1.0 beta
68 AC_ARG_WITH(cgiurl,
69         ACX_HELP_STRING([--with-cgiurl=DIR],
70                 [sets URL for cgi programs]),
71         with_cgiurl=$withval,
72         with_cgiurl=/nagios/cgi-bin)
73 CGIURL="$with_cgiurl"
74 AC_DEFINE_UNQUOTED(CGIURL,"$CGIURL",[URL of CGI programs])
76 AC_ARG_WITH(trusted_path,
77         ACX_HELP_STRING([--with-trusted-path=PATH],
78                 [sets trusted path for executables called by scripts]),
79         with_trusted_path=$withval,
80         with_trusted_path=$DEFAULT_PATH)
81 AC_SUBST(with_trusted_path)
83 EXTRAS=
84 EXTRAS_ROOT=
85 dnl PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/etc:/usr/local/bin:/usr/local/sbin:$PATH
87 LDFLAGS="$LDFLAGS -L."
89 ac_cv_uname_m=`uname -m`
90 ac_cv_uname_s=`uname -s`
91 ac_cv_uname_r=`uname -r`
92 ac_cv_uname_v=`uname -v`
93 ac_cv_uname_o=`uname -o`
95 PKG_ARCH=`uname -p`
96 REV_DATESTAMP=`date '+%Y.%m.%d.%H.%M'`
97 REV_TIMESTAMP=`date '+%Y%m%d%H%M%S'`
99 AC_SUBST(PKG_ARCH)
100 AC_SUBST(REV_DATESTAMP)
101 AC_SUBST(REV_TIMESTAMP)
103 dnl Check if version file is present
104 AM_CONDITIONAL([RELEASE_PRESENT], [test -f $srcdir/release])
106 # Also read in the version from it
107 if test -f $srcdir/release; then
108         NP_RELEASE="$(<release)"
109 else
110         NP_RELEASE="$PACKAGE_VERSION"
112 AC_SUBST(NP_RELEASE)
114 dnl Checks for programs.
115 AC_PATH_PROG(PERL,perl)
116 AC_PATH_PROG(HOSTNAME,hostname)
117 AC_PATH_PROG(BASENAME,basename)
119 dnl allow them to override the path of perl
120 AC_ARG_WITH(perl,
121         ACX_HELP_STRING([--with-perl=PATH],
122                         [sets path to perl executable]),
123                         with_perl=$withval,with_perl=$PERL)
124 AC_SUBST(PERL, $with_perl)
126 dnl openssl/gnutls
127 AC_ARG_WITH(openssl,
128             AC_HELP_STRING([--with-openssl=DIR],
129                            [path to openssl installation]),)
131 AC_ARG_WITH(gnutls,
132             ACX_HELP_STRING([--with-gnutls=PATH],
133                             [path to gnutls installation root]),)
135 dnl you can only have one or the other
136 if test ! "$with_openssl" = "" && test ! "$with_openssl" = "no"; then
137         with_gnutls="no"
139 if test ! "$with_gnutls" = "" && test ! "$with_gnutls" = "no"; then
140         with_openssl="no"
143 dnl list of possible dirs to try to autodetect openssl
144 dnl if $dir/include exists, we consider it found
145 dnl the order should allow locally installed versions to override distros' ones
146 OPENSSL_DIRS="/usr /usr/local /usr/slocal /usr/local/openssl /usr/local/ssl \
147               /opt /opt/openssl"
151 dnl Checks for libraries.
154 AC_CHECK_LIB(dce,main,SOCKETLIBS="$SOCKETLIBS -ldce")
155 AC_CHECK_LIB(nsl,main,SOCKETLIBS="$SOCKETLIBS -lnsl")
156 AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket")
157 AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv")
158 AC_SUBST(SOCKETLIBS)
161 dnl check for math-related functions needing -lm
162 AC_CHECK_HEADERS(math.h)
163 AC_CHECK_LIB(m,floor,MATHLIBS="-lm")
164 AC_CHECK_HEADERS(mp.h)
165 AC_CHECK_LIB(bsd,pow,MATHLIBS="$MATHLIBS -lbsd")
166 AC_SUBST(MATHLIBS)
168 dnl Check if we buils local libtap
169 AC_ARG_ENABLE(libtap,
170   AC_HELP_STRING([--enable-libtap],
171                 [Enable built-in libtap for unit-testing (default: autodetect system library).]),
172         [enable_libtap=$enableval],
173         [enable_libtap=no])
174 AM_CONDITIONAL([USE_LIBTAP_LOCAL],[test "$enable_libtap" = "yes"])
176 # If not local, check if we can use the system one
177 if test "$enable_libtap" != "yes" ; then
178         dnl Check for libtap, to run perl-like tests
179         AC_CHECK_LIB(tap, plan_tests,
180                 enable_libtap="yes"
181                 )
184 # Finally, define tests if we use libtap
185 if test "$enable_libtap" = "yes" ; then
186         EXTRA_TEST="test_utils test_disk test_tcp test_cmd test_base64"
187         AC_SUBST(EXTRA_TEST)
190 dnl INI Parsing
191 AC_ARG_ENABLE(extra-opts,
192   AC_HELP_STRING([--enable-extra-opts],
193                 [Enables parsing of plugins ini config files for extra options (default: no)]),
194         [enable_extra_opts=$enableval],
195         [enable_extra_opts=yes])
196 AM_CONDITIONAL([USE_PARSE_INI],[test "$enable_extra_opts" = "yes"])
197 if test "$enable_extra_opts" = "yes" ; then
198         AC_DEFINE(NP_EXTRA_OPTS,[1],[Enable INI file parsing.])
199         if test "$enable_libtap" = "yes"; then
200                 EXTRA_TEST="$EXTRA_TEST test_ini1 test_ini3 test_opts1 test_opts2 test_opts3"
201                 AC_SUBST(EXTRA_TEST)
202         fi
205 dnl Check for PostgreSQL libraries
206 _SAVEDLIBS="$LIBS"
207 _SAVEDCPPFLAGS="$CPPFLAGS"
208 AC_ARG_WITH(pgsql,
209         ACX_HELP_STRING([--with-pgsql=DIR],
210                 [sets path to pgsql installation]),
211         PGSQL=$withval,)
212 AC_CHECK_LIB(crypt,main)
213 if test "$ac_cv_lib_crypt_main" = "yes" -a "x$PGSQL" != "xno"; then
214   if test -n "$PGSQL"; then
215     LDFLAGS="$LDFLAGS -L$PGSQL/lib"
216     CPPFLAGS="$CPPFLAGS -I$PGSQL/include"
217   fi
218   AC_CHECK_LIB(pq,PQsetdbLogin,,,-lcrypt)
219   if test "$ac_cv_lib_pq_PQsetdbLogin" = "yes"; then
220     AC_CHECK_HEADERS(pgsql/libpq-fe.h)
221     AC_CHECK_HEADERS(postgresql/libpq-fe.h)
222     AC_CHECK_HEADERS(libpq-fe.h)
223     if [[ -n "$PGSQL" -a "$ac_cv_header_libpq_fe_h" = "yes" ]]; then
224       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
225       PGINCLUDE="-I$PGSQL/include"
226     elif test  "$ac_cv_header_pgsql_libpq_fe_h" = "yes"; then
227       PGLIBS="-lpq -lcrypt"
228       PGINCLUDE="-I/usr/include/pgsql"
229     elif test  "$ac_cv_header_postgresql_libpq_fe_h" = "yes"; then
230       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
231       PGINCLUDE="-I/usr/include/postgresql"
232     elif test  "$ac_cv_header_libpq_fe_h" = "yes"; then
233       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
234       PGINCLUDE="-I$PGSQL/include"
235     fi
236     if test -z "$PGINCLUDE"; then
237       AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
238       AC_MSG_WARN([install PostgreSQL headers to compile this plugin (see REQUIREMENTS).])
239     else
240       AC_SUBST(PGLIBS)
241       AC_SUBST(PGINCLUDE)
242       EXTRAS="$EXTRAS check_pgsql\$(EXEEXT)"
243     fi
244   else
245     AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
246     AC_MSG_WARN([LIBS="$LIBS" CPPFLAGS="$CPPFLAGS"])
247     AC_MSG_WARN([install PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
248   fi
249 else
250   AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
251   AC_MSG_WARN([install lib crypt and PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
253 LIBS="$_SAVEDLIBS"
254 CPPFLAGS="$_SAVEDCPPFLAGS"
256 AC_ARG_WITH([dbi], [AS_HELP_STRING([--without-dbi], [Skips the dbi plugin])])
257 dnl Check for DBI libraries
258 AS_IF([test "x$with_dbi" != "xno"], [
259   _SAVEDLIBS="$LIBS"
260   AC_CHECK_LIB(dbi,dbi_initialize)
261   if test "$ac_cv_lib_dbi_dbi_initialize" = "yes"; then
262     EXTRAS="$EXTRAS check_dbi\$(EXEEXT)"
263         DBILIBS="-ldbi"
264     AC_SUBST(DBILIBS)
265   else
266     AC_MSG_WARN([Skipping dbi plugin])
267     AC_MSG_WARN([install DBI libs to compile this plugin (see REQUIREMENTS).])
268   fi
269   LIBS="$_SAVEDLIBS"
272 AC_ARG_WITH([radius], [AS_HELP_STRING([--without-radius], [Skips the radius plugin])])
274 dnl Check for radius libraries
275 AS_IF([test "x$with_radius" != "xno"], [
276   _SAVEDLIBS="$LIBS"
277   AC_CHECK_LIB(radcli,rc_read_config)
278   if test "$ac_cv_lib_radcli_rc_read_config" = "yes"; then
279     EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
280     RADIUSLIBS="-lradcli"
281     AC_SUBST(RADIUSLIBS)
282   else
283     AC_CHECK_LIB(freeradius-client,rc_read_config)
284     if test "$ac_cv_lib_freeradius_client_rc_read_config" = "yes"; then
285       EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
286       RADIUSLIBS="-lfreeradius-client"
287       AC_SUBST(RADIUSLIBS)
288     else
289       AC_CHECK_LIB(radiusclient-ng,rc_read_config)
290       if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then
291         EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
292         RADIUSLIBS="-lradiusclient-ng"
293         AC_SUBST(RADIUSLIBS)
294       else
295         AC_CHECK_LIB(radiusclient,rc_read_config)
296         if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
297           EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
298           RADIUSLIBS="-lradiusclient"
299           AC_SUBST(RADIUSLIBS)
300         else
301           AC_MSG_WARN([Skipping radius plugin])
302           AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
303         fi
304       fi
305     fi
306   fi
307   LIBS="$_SAVEDLIBS"
310 AC_ARG_WITH([ldap], [AS_HELP_STRING([--without-ldap], [Skips the LDAP plugin])])
312 dnl Check for LDAP libraries
313 AS_IF([test "x$with_ldap" != "xno"], [
314   _SAVEDLIBS="$LIBS"
315   AC_CHECK_LIB(ldap,main,,,-llber)
316   if test "$ac_cv_lib_ldap_main" = "yes"; then
317     LDAPLIBS="-lldap -llber"\
318     LDAPINCLUDE="-I/usr/include/ldap"
319     AC_SUBST(LDAPLIBS)
320     AC_SUBST(LDAPINCLUDE)
321     AC_CHECK_FUNCS(ldap_set_option)
322     EXTRAS="$EXTRAS check_ldap\$(EXEEXT)"
323         AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
324   else
325     AC_MSG_WARN([Skipping LDAP plugin])
326     AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
327   fi
328   LIBS="$_SAVEDLIBS"
332 AC_ARG_WITH([systemd], [AS_HELP_STRING([--without-systemd], [Skips systemd support])])
334 dnl Check for libsystemd
335 AS_IF([test "x$with_systemd" != "xno"], [
336   _SAVEDLIBS="$LIBS"
337   AC_CHECK_LIB(systemd,sd_get_sessions,,,-lsystemd)
338   if test "$ac_cv_lib_systemd_sd_get_sessions" = "yes"; then
339     SYSTEMDLIBS="-lsystemd"
340     SYSTEMDINCLUDE=""
341     AC_SUBST(SYSTEMDLIBS)
342     AC_SUBST(SYSTEMDINCLUDE)
343   else
344     AC_MSG_WARN([Skipping systemd support])
345   fi
346   LIBS="$_SAVEDLIBS"
350 dnl Check for headers used by check_ide_smart
351 case $host in
352   *linux*)
353     AC_CHECK_HEADER(linux/hdreg.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
354     if test "$FOUNDINCLUDE" = "yes" ; then
355         AC_CHECK_HEADER(linux/types.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
356     fi
357     if test "$FOUNDINCLUDE" = "no" ; then
358         AC_MSG_WARN([Skipping check_ide_smart plugin.])
359         AC_MSG_WARN([check_ide_smart requires linux/hdreg.h and linux/types.h.])
360     fi
361   ;;
362   *netbsd*)
363     AC_CHECK_HEADER(dev/ata/atareg.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
364     if test "$FOUNDINCLUDE" = "yes" ; then
365         AC_CHECK_HEADER(dev/ic/wdcreg.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
366     fi
367     if test "$FOUNDINCLUDE" = "no" ; then
368         AC_MSG_WARN([Skipping check_ide_smart plugin.])
369         AC_MSG_WARN([check_ide_smart requires dev/ata/atareg.h and dev/ic/wdcreg.h])
370     fi
371   ;;
372   *)
373     AC_MSG_WARN([Skipping check_ide_smart plugin.])
374     AC_MSG_WARN([check_ide_smart works only on Linux and NetBSD])
375 esac
377 if test "$FOUNDINCLUDE" = "yes" ; then
378         EXTRAS="$EXTRAS check_ide_smart\$(EXEEXT)"
381 dnl Check for mysql libraries
382 np_mysqlclient
383 if test $with_mysql = "no" ; then
384   AC_MSG_WARN([Skipping mysql plugin])
385   AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
386 else
387   EXTRAS="$EXTRAS check_mysql\$(EXEEXT) check_mysql_query\$(EXEEXT)"
388   MYSQLINCLUDE="$np_mysql_include"
389   MYSQLLIBS="$np_mysql_libs"
390   MYSQLCFLAGS="$np_mysql_cflags"
391   AC_SUBST(MYSQLINCLUDE)
392   AC_SUBST(MYSQLLIBS)
393   AC_SUBST(MYSQLCFLAGS)
396 dnl Check for headers used by check_users
397 AC_CHECK_HEADERS(utmpx.h)
398 AM_CONDITIONAL([HAVE_UTMPX], [test "$ac_cv_header_utmpx_h" = "yes"])
400 AC_CHECK_HEADERS(wtsapi32.h, [], [], [#include <windows.h>])
401 AM_CONDITIONAL([HAVE_WTS32API], [test "$ac_cv_header_wtsapi32_h" = "yes"])
403 if test "$ac_cv_header_wtsapi32_h" = "yes"; then
404   WTSAPI32LIBS="-lwtsapi32"
405   AC_SUBST(WTSAPI32LIBS)
408 _can_enable_check_curl=no
409 dnl Check for cURL library
410 LIBCURL_CHECK_CONFIG(yes, 7.15.2, [
411     _can_enable_check_curl=yes
412     LIBCURLINCLUDE="$LIBCURL_CPPFLAGS"
413     LIBCURLLIBS="$LIBCURL"
414     LIBCURLCFLAGS="$LIBCURL_CPPFLAGS"
415     AC_SUBST(LIBCURLINCLUDE)
416     AC_SUBST(LIBCURLLIBS)
417     AC_SUBST(LIBCURLCFLAGS)
418   ], [
419     _can_enable_check_curl=no
420     AC_MSG_WARN([Skipping curl plugin])
421     AC_MSG_WARN([install libcurl libs to compile this plugin (see REQUIREMENTS).])
424 dnl Check for uriparser library
425 URIPARSER_CHECK(yes, 0.7.5, [
426     URIPARSERINCLUDE="$URIPARSER_CPPFLAGS"
427     URIPARSERLIBS="$URIPARSER"
428     URIPARSERCFLAGS="$URIPARSER_CPPFLAGS"
429     AC_SUBST(URIPARSERINCLUDE)
430     AC_SUBST(URIPARSERLIBS)
431     AC_SUBST(URIPARSERCFLAGS)
432   ], [
433     _can_enable_check_curl=no
434     AC_MSG_WARN([Skipping curl plugin])
435     AC_MSG_WARN([install the uriparser library to compile this plugin (see REQUIREMENTS).])
438 dnl prerequisites met, enable the plugin
439 if test x$_can_enable_check_curl = xyes; then
440   EXTRAS="$EXTRAS check_curl\$(EXEEXT)"
442 AC_CONFIG_FILES([plugins/picohttpparser/Makefile])
444 dnl Fallback to who(1) if the system doesn't provide an utmpx(5) interface
445 if test "$ac_cv_header_utmpx_h" = "no" -a "$ac_cv_header_wtsapi32_h" = "no"
446 then
447         AC_PATH_PROG(PATH_TO_WHO,who)
449         if [$PATH_TO_WHO -q 2>/dev/null | grep -E -i "^# users=[0-9]+$" >/dev/null]
450         then
451                 ac_cv_path_to_who="$PATH_TO_WHO -q"
452         else
453                 ac_cv_path_to_who="$PATH_TO_WHO"
454         fi
456         AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
457                 [path and arguments for invoking 'who'])
460 AC_ARG_WITH([ipv6],
461         [AS_HELP_STRING([--with-ipv6], [support IPv6 @<:@default=check@:>@])],
462         [], [with_ipv6=check])
464 dnl Check for AF_INET6 support - unistd.h required for Darwin
465 if test "$with_ipv6" != "no"; then
466         AC_CACHE_CHECK([for IPv6 support], np_cv_sys_ipv6, [
467                 AC_TRY_COMPILE(
468                         [#ifdef HAVE_UNISTD_H
469                         #include <unistd.h>
470                         #endif
471                         #include <netinet/in.h>
472                         #include <sys/socket.h>],
473                         [struct sockaddr_in6 sin6;
474                         void *p;
476                         sin6.sin6_family = AF_INET6;
477                         sin6.sin6_port = 587;
478                         p = &sin6.sin6_addr;],
479                         [np_cv_sys_ipv6=yes],
480                         [np_cv_sys_ipv6=no])
481                 ])
482         if test "$np_cv_sys_ipv6" = "no" -a "$with_ipv6" != "check"; then
483                 AC_MSG_FAILURE([--with-ipv6 was given, but test for IPv6 support failed])
484         fi
485         if test "$np_cv_sys_ipv6" = "yes"; then
486                 AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
487         fi
488         with_ipv6="$np_cv_sys_ipv6"
492 dnl Checks for Kerberos. Must come before openssl checks for Redhat EL 3
493 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
494 if test "$FOUNDINCLUDE" = "no"; then
495   _SAVEDCPPFLAGS="$CPPFLAGS"
496   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
497   unset ac_cv_header_krb5_h
498   AC_CHECK_HEADERS(krb5.h,
499                    KRB5INCLUDE="-I/usr/kerberos/include"
500                    FOUNDINCLUDE=yes,
501                    FOUNDINCLUDE=no)
503 AC_SUBST(KRBINCLUDE)
504 if test "$FOUNDINCLUDE" = "no"; then
505   CPPFLAGS="$_SAVEDCPPFLAGS"
508 dnl *** The following block comes from wget configure.ac ***
509 dnl Unfortunately, as of this writing (OpenSSL 0.9.6), the libcrypto
510 dnl shared library doesn't record its dependency on libdl, so we
511 dnl need to check for it ourselves so we won't fail to link due to a
512 dnl lack of -ldl.  Most OSes use dlopen(), but HP-UX uses
513 dnl shl_load().
514 AC_CHECK_LIB(dl,dlopen)
515 AC_CHECK_LIB(dl,shl_load)
517 dnl openssl detection/configuration
518 if ! test x"$with_openssl" = x"no"; then
519         dnl Check for OpenSSL location if it wasn't already specified
520         if ! test -d "$with_openssl"; then
521                 for d in $OPENSSL_DIRS; do
522                         if test -x ${d}/bin/openssl || test -x ${d}/sbin/openssl ; then
523                                 with_openssl=$d
524                         fi
525                 done
526         fi
528         _SAVEDCPPFLAGS="$CPPFLAGS"
529         _SAVEDLDFLAGS="$LDFLAGS"
530         dnl Check for OpenSSL header files
531         unset FOUNDINCLUDE
532         if test x"$with_openssl" != x"/usr" ; then
533                 CPPFLAGS="$CPPFLAGS -I$with_openssl/include"
534                 LDFLAGS="$LDFLAGS -L$with_openssl/lib"
535         fi
537         dnl check for openssl in $dir/include/openssl
538         AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
539                          SSLINCLUDE="-I$with_openssl/include"
540                          FOUNDINCLUDE=yes,
541                          FOUNDINCLUDE=no)
542         dnl else check to see if $dir/include has it
543         if test "$FOUNDINCLUDE" = "no"; then
544                 AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
545                                  SSLINCLUDE="-I$with_openssl/include"
546                                  FOUNDINCLUDE=yes,
547                                  FOUNDINCLUDE=no)
548         fi
549         AC_SUBST(SSLINCLUDE)
550         dnl if we didn't find it, reset CPPFLAGS
551         if test "$FOUNDINCLUDE" = "no"; then
552                 CPPFLAGS="$_SAVEDCPPFLAGS"
553                 LDFLAGS="$_SAVEDLDFLAGS"
554         fi
556         dnl Check for crypto lib
557         _SAVEDLIBS="$LIBS"
558         LIBS="-L${with_openssl}/lib"
559         AC_CHECK_LIB(crypto,CRYPTO_new_ex_data)
560         if test "$ac_cv_lib_crypto_CRYPTO_new_ex_data" = "yes"; then
561                 dnl Check for SSL lib
562                 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
563         fi
564         LIBS="$_SAVEDLIBS"
566         dnl test headers and libs to decide whether check_http should use SSL
567         if test "$ac_cv_lib_crypto_CRYPTO_new_ex_data" = "yes"; then
568                 if test "$ac_cv_lib_ssl_main" = "yes"; then
569                         if test "$FOUNDINCLUDE" = "yes"; then
570                                 FOUNDOPENSSL="yes"
571                         fi
572                 fi
573         fi
577 dnl check for gnutls if openssl isn't found (or is disabled)
578 if test ! "$FOUNDOPENSSL" = "yes" && test ! "$with_gnutls" = "no"; then
579         if test ! "$with_gnutls" = ""; then
580                 CPPFLAGS="$CPPFLAGS -I${with_gnutls}/include"
581         fi
582         AC_CHECK_HEADERS([gnutls/openssl.h],FOUNDGNUTLS="yes",)
583         if test "$FOUNDGNUTLS" = "yes"; then
584                 AC_CHECK_LIB(gnutls-openssl,main,SSLLIBS="-lgnutls-openssl")
585         fi
587 dnl end check for gnutls
589 if test "$FOUNDOPENSSL" = "yes" || test "$FOUNDGNUTLS" = "yes"; then
590         check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
591         AC_SUBST(check_tcp_ssl)
592         AC_SUBST(SSLLIBS)
593         AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
594         if test "$FOUNDOPENSSL" = "yes"; then
595                 AC_DEFINE(USE_OPENSSL,1,[Define if using OpenSSL libraries])
596                 with_openssl="yes"
597                 with_gnutls="no"
598         else
599                 AC_DEFINE(USE_GNUTLS,1,[Define if using gnutls libraries])
600                 with_gnutls="yes"
601                 with_openssl="no"
602         fi
603 else
604         dnl else deliberately disabled or no ssl support available
605         AC_MSG_WARN([OpenSSL or GnuTLS libs could not be found or were disabled])
606         with_openssl="no"
607         with_gnutls="no"
611 dnl Checks for header files.
614 AC_HEADER_TIME
615 AC_HEADER_SYS_WAIT
616 AC_CHECK_HEADERS(signal.h syslog.h uio.h errno.h sys/time.h sys/socket.h sys/un.h sys/poll.h)
617 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h)
619 dnl Checks for typedefs, structures, and compiler characteristics.
620 AC_C_CONST
621 AC_STRUCT_TM
622 AC_TYPE_PID_T
623 AC_TYPE_SIZE_T
625 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
626 AC_TRY_LINK([#include <stdarg.h>
627 va_list ap1,ap2;], [va_copy(ap1,ap2);],
628 ac_cv_HAVE_VA_COPY=yes,
629 ac_cv_HAVE_VA_COPY=no)])
630 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
631     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
632 else
633     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
634     AC_TRY_LINK([#include <stdarg.h>
635     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
636     ac_cv_HAVE___VA_COPY=yes,
637     ac_cv_HAVE___VA_COPY=no)])
638     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
639         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
640     fi
643 AC_TRY_COMPILE([#include <sys/time.h>],
644                [struct timeval *tv;
645                 struct timezone *tz;],
646                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
647                            FOUND_STRUCT_TIMEVAL="yes")
649 if test x"$FOUND_STRUCT_TIMEVAL" = x"yes"; then
650         AC_TRY_COMPILE([#include <sys/time.h>],
651                           [struct timeval *tv;
652                            struct timezone *tz;
653                            gettimeofday(tv, tz);],
654                           AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
655                           AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed]))
658 dnl Checks for library functions.
659 AC_CHECK_FUNCS(memmove select socket strdup strstr strtol strtoul floor)
660 AC_CHECK_FUNCS(poll)
662 AC_MSG_CHECKING(return type of socket size)
663 AC_TRY_COMPILE([#include <stdlib.h>
664                 #include <sys/types.h>
665                 #include <sys/socket.h>],
666                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
667                ac_cv_socket_size_type=["size_t"]
668                 AC_MSG_RESULT(size_t),
669                ac_cv_socket_size_type=["int"]
670                 AC_MSG_RESULT(int))
672 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
673         [Define type of socket size])
676 dnl #### Process table test
678 AC_PATH_PROG(PATH_TO_PS,ps)
679 AC_PATH_PROG(PATH_TO_ENV,env)
681 AC_MSG_CHECKING(for ps syntax)
682 AC_ARG_WITH(ps_command,
683             ACX_HELP_STRING([--with-ps-command=PATH],
684                             [Verbatim command to execute for ps]),
685             PS_COMMAND=$withval)
686 AC_ARG_WITH(ps_format,
687             ACX_HELP_STRING([--with-ps-format=FORMAT],
688                             [Format string for scanning ps output]),
689             PS_FORMAT=$withval)
690 AC_ARG_WITH(ps_cols,
691             ACX_HELP_STRING([--with-ps-cols=NUM],
692                             [Number of columns in ps command]),
693             PS_COLS=$withval)
694 AC_ARG_WITH(ps_varlist,
695             ACX_HELP_STRING([--with-ps-varlist=LIST],
696                             [Variable list for sscanf of 'ps' output]),
697             PS_VARLIST=$withval)
699 if test -n "$PS_COMMAND" && test -n "$PS_FORMAT" && test -n "$PS_COLS" && test -n "$PS_VARLIST"; then
700         ac_cv_ps_command="$PS_COMMAND"
701         ac_cv_ps_format="$PS_FORMAT"
702         ac_cv_ps_varlist="$PS_VARLIST"
703         ac_cv_ps_cols="$PS_COLS"
704         AC_MSG_RESULT([(command-line) $ac_cv_ps_command])
706 dnl Now using the pst3/kmem hack for solaris systems to avoid truncation
707 elif test "$ac_cv_uname_s" = "SunOS"; then
708         #
709         # this is a very, very ugly hack, to hardcode the location for plugins
710         #
711         if test "$libexecdir" = '${exec_prefix}/libexec'; then
712                 if test "$exec_prefix" = "NONE"; then
713                         if test "$prefix" = "NONE"; then
714                                 pst3="$ac_default_prefix/libexec/pst3"
715                         else
716                                 pst3="$prefix/libexec/pst3"
717                         fi
718                 else
719                         pst3="$exec_prefix/libexec/pst3"
720                 fi
721         else
722                 pst3="$libexecdir/pst3"
723         fi
724         ac_cv_ps_command="$pst3"
725         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
726         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
727         ac_cv_ps_cols=9
728         AC_MSG_RESULT([using monitoring-plugins internal ps command (pst3) for solaris])
729         if test `isainfo -b` = 64 ; then
730                 pst3_use_64bit=1
731                 AC_MSG_NOTICE([using 64bit pst3])
732         else
733                 AC_MSG_NOTICE([using 32bit pst3])
734         fi
735         EXTRAS_ROOT="$EXTRAS_ROOT pst3\$(EXEEXT)"
737         if test "$pst3_use_64bit" = 1; then
738                 dnl Test if we can actually compile code in 64bit
739                 old_cflags=$CFLAGS
740                 CFLAGS="$CFLAGS -m64"
741                 pst3_64bit_working=0
742                 AC_RUN_IFELSE(
743                         [AC_LANG_PROGRAM([], [
744 return sizeof(void*) == 8 ? 0 : 1;
745                         ])
746                 ],[
747                         PST3CFLAGS="-m64"
748                         AC_SUBST(PST3CFLAGS)
749                         pst3_64bit_working=1
750                         AC_MSG_NOTICE([using -m64 for 64bit code])
751                 ],[
752                         pst3_64bit_working=0
753                         AC_MSG_NOTICE([compiler do not like -m64])
754                 ])
755                 CFLAGS=$old_cflags
756                 if test "$pst3_64bit_working" = 0; then
757                         old_cflags=$CFLAGS
758                         CFLAGS="$CFLAGS -xarch=v9"
759                         AC_RUN_IFELSE(
760                                 [AC_LANG_PROGRAM([], [
761 return sizeof(void*) == 8 ? 0 : 1;
762                                 ])
763                         ],[
764                                 PST3CFLAGS="-xarch=v9"
765                                 AC_SUBST(PST3CFLAGS)
766                                 pst3_64bit_working=1
767                                 AC_MSG_NOTICE([using -xarch=v9 for 64bit code])
768                         ],[
769                                 pst3_64bit_working=0
770                                 AC_MSG_NOTICE([compiler do not like -xarch=v9])
771                         ])
772                         CFLAGS=$old_cflags
773                 fi
774                 if test "$pst3_64bit_working" = 0; then
775                         old_cflags=$CFLAGS
776                         CFLAGS="$CFLAGS -xarch=amd64"
777                         AC_RUN_IFELSE(
778                                 [AC_LANG_PROGRAM([], [
779 return sizeof(void*) == 8 ? 0 : 1;
780                                 ])
781                         ],[
782                                 PST3CFLAGS="-xarch=amd64"
783                                 AC_SUBST(PST3CFLAGS)
784                                 pst3_64bit_working=1
785                                 AC_MSG_NOTICE([using -xarch=amd64 for 64bit code])
786                         ],[
787                                 pst3_64bit_working=0
788                                 AC_MSG_NOTICE([compiler do not like -xarch=amd64])
789                         ])
790                         CFLAGS=$old_cflags
791                 fi
792                 if test "$pst3_64bit_working" = 0; then
793                         AC_MSG_ERROR([I don't know how to build a 64-bit object!])
794                 fi
795         fi
797 dnl Removing this for the moment - Ton
798 dnl Using /usr/ucb/ps on Solaris systems, to avoid truncation
799 dnl Limitation that command name is not available
800 dnl elif test "$ac_cv_uname_s" = "SunOS" && /usr/ucb/ps -alxwwn 2>/dev/null | \
801 dnl     grep -E -i ["^ *F +UID +PID +PPID +%C +PRI +NI +SZ +RSS +WCHAN +S +TT +TIME +COMMAND"] > /dev/null
802 dnl then
803 dnl     ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procpcpu,&procvsz,&procrss,procstat,&pos]"
804 dnl     ac_cv_ps_command="/usr/ucb/ps -alxwwn"
805 dnl     ac_cv_ps_format=["%*s %d %d %d %d %*d %*d %d %d%*[ 0123456789abcdef]%[OSRZT]%*s %*s %n"]
806 dnl     ac_cv_ps_cols=8
807 dnl     AC_MSG_RESULT([$ac_cv_ps_command])
809 dnl This one is the exact same test as the next one but includes etime
810 elif ps axwo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
811         grep -E -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +ELAPSED +COMMAND"] > /dev/null
812 then
813         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
814         ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu etime comm args'"
815         ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
816         ac_cv_ps_cols=10
817         AC_MSG_RESULT([$ac_cv_ps_command])
819 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
820 dnl so test for this first...
821 elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
822         grep -E -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
823 then
824         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
825         ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
826         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
827         ac_cv_ps_cols=9
828         AC_MSG_RESULT([$ac_cv_ps_command])
830 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
831 dnl Should also work for FreeBSD 5.2.1 and 5.3
832 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
833 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
834         grep -E -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
835 then
836         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
837         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
838         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
839         ac_cv_ps_cols=9
840         AC_MSG_RESULT([$ac_cv_ps_command])
842 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4.
843 dnl Limitation: Only first 16 chars returned for ucomm field
844 dnl Must come before ps -weo
845 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
846         grep -E -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
847 then
848         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
849         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
850         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
851         ac_cv_ps_cols=9
852         AC_MSG_RESULT([$ac_cv_ps_command])
854 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
855 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
856         grep -E -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
857 then
858         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
859         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
860         ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
861         ac_cv_ps_cols=10
862         AC_MSG_RESULT([$ac_cv_ps_command])
864 dnl FreeBSD
865 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
866         grep -E -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
867 then
868         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
869         ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
870         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
871         ac_cv_ps_cols=9
872         AC_MSG_RESULT([$ac_cv_ps_command])
874 dnl BSD-like mode in RH 6.1
875 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
876         grep -E -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
877 then
878         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
879         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
880         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
881         ac_cv_ps_cols=9
882         AC_MSG_RESULT([$ac_cv_ps_command])
884 dnl SunOS 4.1.3:
885 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
886 dnl Need the head -1 otherwise test will work because arguments are found
887 elif ps -laxnwww 2>/dev/null | head -1 | \
888         grep -E -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
889 then
890         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
891         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
892         ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
893         ac_cv_ps_cols=9
894         AC_MSG_RESULT([$ac_cv_ps_command])
896 dnl Debian Linux / procps v1.2.9:
897 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
898 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
900 elif ps laxnwww 2>/dev/null | \
901         grep -E -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
902 then
903         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
904         ac_cv_ps_command="$PATH_TO_PS laxnwww"
905         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
906         ac_cv_ps_cols=9
907         AC_MSG_RESULT([$ac_cv_ps_command])
909 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
910 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
911         grep -E -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
912 then
913         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
914         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
915         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
916         ac_cv_ps_cols=9
917         AC_MSG_RESULT([$ac_cv_ps_command])
919 dnl Tru64 - needs %*[ +<>] in PS_FORMAT.
920 dnl Has /usr/bin/ps and /sbin/ps - force sbin version
921 dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead
922 dnl of 1500). Will need big changes to check_procs to support
923 elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
924         grep -E -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
925 then
926         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
927         ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
928         ac_cv_ps_format=["%s%*[ +<>] %d %d %d %f %s %s %n"]
929         ac_cv_ps_cols=8
930         AC_MSG_RESULT([$ac_cv_ps_command])
932 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
933         grep -E -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
934 then
935         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
936         ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
937         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
938         ac_cv_ps_cols=9
939         AC_MSG_RESULT([$ac_cv_ps_command])
941 dnl AIX 4.3.3 and 5.1 do not have an rss field
942 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
943         grep -E -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
944 then
945         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
946         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
947         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
948         ac_cv_ps_cols=8
949         AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
951 dnl Solaris 2.6
952 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
953         grep -E -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
954 then
955         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
956         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
957         # There must be no space between the %s and %n due to a weird problem in sscanf where
958         # it will return %n as longer than the line length
959         ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
960         ac_cv_ps_cols=9
961         AC_MSG_RESULT([$ac_cv_ps_command])
963 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
964         grep -E -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
965 then
966         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
967         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
968         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
969         ac_cv_ps_cols=9
970         AC_MSG_RESULT([$ac_cv_ps_command])
972 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
973         grep -E -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
974 then
975         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
976         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
977         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
978         ac_cv_ps_cols=9
979         AC_MSG_RESULT([$ac_cv_ps_command])
981 dnl wonder who takes state instead of stat
982 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
983         grep -E -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
984 then
985         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
986         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
987         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
988         ac_cv_ps_cols=8
989         AC_MSG_RESULT([$ac_cv_ps_command])
991 dnl IRIX 53
992 elif ps -el 2>/dev/null | \
993         grep -E -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
994 then
995         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
996         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
997         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
998         ac_cv_ps_cols=8
999         AC_MSG_RESULT([$ac_cv_ps_command])
1001 dnl IRIX 63
1002 elif ps -el 2>/dev/null | \
1003         grep -E -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
1004 then
1005         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
1006         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
1007         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
1008         ac_cv_ps_cols=6
1009         AC_MSG_RESULT([$ac_cv_ps_command])
1011 dnl HP-UX:
1012 dnl S        UID       RUID USER     RUSER      PID  PPID     VSZ  %CPU COMMAND         COMMAND
1013 dnl S          0        400 root     oracle    2805     1   12904  0.00 ora_dism_SEA1X  ora_dism_SEA1X
1014 dnl S        400        400 oracle   oracle   19261     1  126488  0.00 tnslsnr         /u01/app/oracle/product/db/11.2.0.3/bin/tnslsnr LISTENER -inherit
1015 elif env UNIX95=1 ps -eo 'state uid ruid user ruser pid ppid vsz pcpu comm args' 2>/dev/null | head -n 1 | \
1016     grep -E -i ["^ *S +UID +RUID +USER +RUSER +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
1017 then
1018     ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
1019     ac_cv_ps_command="$PATH_TO_ENV UNIX95=1 $PATH_TO_PS -eo 'state uid pid ppid vsz pcpu comm args'"
1020     ac_cv_ps_format="%s %d %d %d %d %f %s %n"
1021     ac_cv_ps_cols=8
1022     AC_MSG_RESULT([$ac_cv_ps_command])
1024 dnl AIX 4.1:
1025 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
1026 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
1027 elif ps -el 2>/dev/null | \
1028         grep -E -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
1029 then
1030         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
1031         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
1032         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
1033         ac_cv_ps_cols=6
1034         AC_MSG_RESULT([$ac_cv_ps_command])
1036 dnl AIX?
1037 elif ps glaxen 2>/dev/null | \
1038         grep -E -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
1039 then
1040         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
1041         ac_cv_ps_command="$PATH_TO_PS glaxen"
1042         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
1043         ac_cv_ps_cols=8
1044         AC_MSG_RESULT([$ac_cv_ps_command])
1046 dnl MacOSX / Darwin
1047 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
1048 dnl Some truncation will happen in UCOMM column
1049 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
1050 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
1051 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
1052         grep -E -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
1053 then
1054         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
1055         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
1056         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
1057         ac_cv_ps_cols=8
1058         AC_MSG_RESULT([$ac_cv_ps_command])
1060 dnl UnixWare
1061 elif ps -Al 2>/dev/null | \
1062         grep -E -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
1063 then
1064         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
1065         ac_cv_ps_command="$PATH_TO_PS -Al"
1066         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
1067         ac_cv_ps_cols=8
1068         AC_MSG_RESULT([$ac_cv_ps_command])
1070 else
1071         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
1074 if test -n "$ac_cv_ps_varlist" ; then
1075         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
1076                 [Variable list for sscanf of 'ps' output])
1077         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
1078                 [Verbatim command to execute for ps in check_procs])
1079         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
1080                 [Format string for scanning ps output in check_procs])
1081         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
1082                 [Number of columns in ps command])
1083         EXTRAS="$EXTRAS check_procs check_nagios\$(EXEEXT)"
1084         if echo "$ac_cv_ps_varlist" | grep "procetime" >/dev/null; then
1085                 AC_DEFINE(PS_USES_PROCETIME,"yes",
1086                           [Whether the ps utility uses the "procetime" field])
1087         fi
1088         if echo "$ac_cv_ps_varlist" | grep "procpcpu" >/dev/null; then
1089                 AC_DEFINE(PS_USES_PROCPCPU,"yes",
1090                           [Whether the ps utility uses the "procpcpu" field])
1091         fi
1094 AC_PATH_PROG(PATH_TO_PING,ping)
1095 AC_PATH_PROG(PATH_TO_PING6,ping6)
1097 AC_ARG_WITH(ping_command,
1098         ACX_HELP_STRING([--with-ping-command=SYNTAX],
1099                 [sets syntax for ICMP ping]),
1100         with_ping_command=$withval,)
1102 AC_MSG_CHECKING(for ICMP ping syntax)
1103 ac_cv_ping_packets_first=no
1104 ac_cv_ping_has_timeout=no
1105 if test -n "$with_ping_command"
1106 then
1107         AC_MSG_RESULT([(command-line) $with_ping_command])
1108         if echo "$with_ping_command" | grep '%d.*%d.*%s' >/dev/null
1109         then
1110                 ac_cv_ping_packets_first=yes
1111                 ac_cv_ping_has_timeout=yes
1112         elif echo "$with_ping_command" | grep '%d.*%s.*%d' >/dev/null || \
1113              echo "$with_ping_command" | grep '%s.*%d.*%d' >/dev/null
1114         then
1115                 ac_cv_ping_has_timeout=yes
1116         elif echo "$with_ping_command" | grep '%d.*%s' >/dev/null
1117         then
1118                 ac_cv_ping_packets_first=yes
1119         fi
1121 elif [[ "z$ac_cv_uname_o" = "zCygwin" ]]
1122 then
1123         with_ping_command="$PATH_TO_PING -n %d -w %d000 %s"
1124         ac_cv_ping_packets_first=yes
1125         ac_cv_ping_has_timeout=yes
1126         AC_MSG_RESULT([$with_ping_command])
1128 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1129         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
1130         grep -E -i "^round-trip|^rtt" >/dev/null
1131 then
1132         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
1133         ac_cv_ping_packets_first=yes
1134         AC_MSG_RESULT([$with_ping_command])
1136 elif $PATH_TO_PING -4 -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
1137         grep -E -i "^round-trip|^rtt" >/dev/null
1138 then
1139         # check if -4 is supported - issue #1550
1140         with_ping_command="$PATH_TO_PING -4 -n -U -w %d -c %d %s"
1141         ac_cv_ping_packets_first=yes
1142         ac_cv_ping_has_timeout=yes
1143         AC_MSG_RESULT([$with_ping_command])
1144 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
1145         grep -E -i "^round-trip|^rtt" >/dev/null
1146 then
1147         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
1148         ac_cv_ping_packets_first=yes
1149         ac_cv_ping_has_timeout=yes
1150         AC_MSG_RESULT([$with_ping_command])
1152 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
1153         grep -E -i "^round-trip|^rtt" >/dev/null
1154 then
1155         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
1156         ac_cv_ping_packets_first=yes
1157         AC_MSG_RESULT([$with_ping_command])
1159 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1160         grep -E -i "^round-trip|^rtt" >/dev/null
1161 then
1162         with_ping_command="$PATH_TO_PING -n -c %d %s"
1163         ac_cv_ping_packets_first=yes
1164         AC_MSG_RESULT([$with_ping_command])
1166 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
1167         grep -E -i "^round-trip|^rtt" >/dev/null
1168 then
1169         with_ping_command="$PATH_TO_PING -n %s -c %d"
1170         AC_MSG_RESULT([$with_ping_command])
1172 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
1173         grep -E -i "^round-trip|^rtt" >/dev/null
1174 then
1175         with_ping_command="$PATH_TO_PING %s -n %d"
1176         AC_MSG_RESULT([$with_ping_command])
1178 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
1179         grep -E -i "^round-trip|^rtt" >/dev/null
1180 then
1181         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
1182         AC_MSG_RESULT([$with_ping_command])
1184 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
1185         grep -E -i "^round-trip|^rtt" >/dev/null
1186 then
1187         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
1188         AC_MSG_RESULT([$with_ping_command])
1190 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
1191         grep -E -i "^round-trip|^rtt" >/dev/null
1192 then
1193         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
1194         ac_cv_ping_packets_first=yes
1195         AC_MSG_RESULT([$with_ping_command])
1197 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1198         grep -E -i "^round-trip|^rtt" >/dev/null
1199 then
1200         with_ping_command="$PATH_TO_PING -n -c %d %s"
1201         ac_cv_ping_packets_first=yes
1202         AC_MSG_RESULT([$with_ping_command])
1204 else
1205         AC_MSG_WARN([unable to find usable ping syntax])
1208 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
1209         [path and args for ICMP ping command])
1211 if test "x$ac_cv_ping_packets_first" != "xno"
1212 then
1213         AC_DEFINE(PING_PACKETS_FIRST,1,
1214                 [Define if packet count must precede host])
1217 if test "x$ac_cv_ping_has_timeout" != "xno"
1218 then
1219         AC_DEFINE(PING_HAS_TIMEOUT,1,
1220                 [Define if ping has its own timeout option that should be set])
1223 AC_ARG_WITH(ping6_command,
1224         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
1225                 [sets syntax for ICMPv6 ping]),
1226         with_ping6_command=$withval,)
1228 if test x"$with_ipv6" != xno ; then
1229 AC_MSG_CHECKING(for ICMPv6 ping syntax)
1230 ac_cv_ping6_packets_first=no
1231 if test -n "$with_ping6_command"
1232 then
1233         AC_MSG_RESULT([(command-line) $with_ping6_command])
1234         if echo "$with_ping6_command" | grep '%d.*%d.*%s' >/dev/null
1235         then
1236                 ac_cv_ping6_packets_first=yes
1237         elif echo "$with_ping6_command" | grep '%d.*%s.*%d' >/dev/null || \
1238              echo "$with_ping6_command" | grep '%s.*%d.*%d' >/dev/null
1239         then
1240                 # Just keep same logic as ping (IPv4) if we ever need ac_cv_ping6_has_timeout
1241                 true
1242         elif echo "$with_ping6_command" | grep '%d.*%s' >/dev/null
1243         then
1244                 ac_cv_ping6_packets_first=yes
1245         fi
1246 elif [[ "z$ac_cv_uname_o" = "zCygwin" -a "x$PATH_TO_PING" != "x" ]]; then
1247         with_ping6_command="$PATH_TO_PING -6 -n %d -w %d000 %s"
1248         ac_cv_ping6_packets_first=yes
1249         ac_cv_ping_has_timeout=yes
1250         AC_MSG_RESULT([$with_ping6_command])
1251 elif test "x$PATH_TO_PING6" != "x"; then
1252         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1253                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1254                 grep -E -i "^round-trip|^rtt" >/dev/null
1255         then
1256                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1257                 ac_cv_ping6_packets_first=yes
1258                 AC_MSG_RESULT([$with_ping6_command])
1260         elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
1261                 grep -E -i "^round-trip|^rtt" >/dev/null
1262         then
1263                 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
1264                 ac_cv_ping6_packets_first=yes
1265                 ac_cv_ping_has_timeout=yes
1266                 AC_MSG_RESULT([$with_ping6_command])
1268         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1269                 grep -E -i "^round-trip|^rtt" >/dev/null
1270         then
1271                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1272                 ac_cv_ping6_packets_first=yes
1273                 AC_MSG_RESULT([$with_ping6_command])
1275         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1276                 grep -E -i "^round-trip|^rtt" >/dev/null
1277         then
1278                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1279                 ac_cv_ping6_packets_first=yes
1280                 AC_MSG_RESULT([$with_ping6_command])
1282         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1283                 grep -E -i "^round-trip|^rtt" >/dev/null
1284         then
1285                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1286                 AC_MSG_RESULT([$with_ping6_command])
1288         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1289                 grep -E -i "^round-trip|^rtt" >/dev/null
1290         then
1291                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1292                 AC_MSG_RESULT([$with_ping6_command])
1294         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1295                 grep -E -i "^round-trip|^rtt" >/dev/null
1296         then
1297                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1298                 AC_MSG_RESULT([$with_ping6_command])
1300         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1301                 grep -E -i "^round-trip|^rtt" >/dev/null
1302         then
1303                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1304                 AC_MSG_RESULT([$with_ping6_command])
1306         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1307                 grep -E -i "^round-trip|^rtt" >/dev/null
1308         then
1309                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1310                 ac_cv_ping6_packets_first=yes
1311                 AC_MSG_RESULT([$with_ping_command])
1313         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1314                 grep -E -i "^round-trip|^rtt" >/dev/null
1315         then
1316                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1317                 ac_cv_ping6_packets_first=yes
1318                 AC_MSG_RESULT([$with_ping6_command])
1320         fi
1322 elif test "x$PATH_TO_PING" != "x"; then
1323         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1324                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1325                 grep -E -i "^round-trip|^rtt" >/dev/null
1326         then
1327                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1328                 ac_cv_ping6_packets_first=yes
1329                 AC_MSG_RESULT([$with_ping6_command])
1331         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1332                 grep -E -i "^round-trip|^rtt" >/dev/null
1333         then
1334                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1335                 ac_cv_ping6_packets_first=yes
1336                 AC_MSG_RESULT([$with_ping6_command])
1338         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1339                 grep -E -i "^round-trip|^rtt" >/dev/null
1340         then
1341                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1342                 ac_cv_ping6_packets_first=yes
1343                 AC_MSG_RESULT([$with_ping6_command])
1345         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1346                 grep -E -i "^round-trip|^rtt" >/dev/null
1347         then
1348                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1349                 AC_MSG_RESULT([$with_ping6_command])
1351         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1352                 grep -E -i "^round-trip|^rtt" >/dev/null
1353         then
1354                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1355                 AC_MSG_RESULT([$with_ping6_command])
1357         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1358                 grep -E -i "^round-trip|^rtt" >/dev/null
1359         then
1360                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1361                 AC_MSG_RESULT([$with_ping6_command])
1363         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1364                 grep -E -i "^round-trip|^rtt" >/dev/null
1365         then
1366                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1367                 AC_MSG_RESULT([$with_ping6_command])
1369         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1370                 grep -E -i "^round-trip|^rtt" >/dev/null
1371         then
1372                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1373                 ac_cv_ping6_packets_first=yes
1374                 AC_MSG_RESULT([$with_ping_command])
1376         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1377                 grep -E -i "^round-trip|^rtt" >/dev/null
1378         then
1379                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1380                 ac_cv_ping6_packets_first=yes
1381                 AC_MSG_RESULT([$with_ping6_command])
1383         fi
1387 if test "x$with_ping6_command" != "x"; then
1388         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1389                 [path and args for ICMPv6 ping command])
1390 else
1391         AC_MSG_RESULT([none])
1394 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1395         AC_DEFINE(PING6_PACKETS_FIRST,1,
1396                 [Define if packet count must precede host])
1401 AC_ARG_WITH(nslookup_command,
1402             ACX_HELP_STRING([--with-nslookup-command=PATH],
1403                             [sets path to nslookup executable]),
1404             ac_cv_nslookup_command=$withval)
1405 if test -n "$ac_cv_nslookup_command"; then
1406         AC_MSG_NOTICE([Using specific nslookup at $ac_cv_nslookup_command])
1407 else
1408         AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1409         if test -n "$PATH_TO_NSLOOKUP"
1410         then
1411                 AC_MSG_CHECKING(for nslookup syntax)
1412                 if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1413                 then
1414                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1415                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1417                 else
1418                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1419                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1421                 fi
1422         else
1423                 AC_MSG_WARN([nslookup command not found])
1424         fi
1427 if test -n "$ac_cv_nslookup_command"; then
1428         EXTRAS="$EXTRAS check_dns\$(EXEEXT)"
1429         AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
1432 AC_MSG_CHECKING([for number of online cpus])
1433 AC_TRY_COMPILE([#include <unistd.h>],
1434         [sysconf(_SC_NPROCESSORS_ONLN) > 0;],
1435         AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_ONLN,1,[Define if sysconf returns number of online cpus])
1436         AC_MSG_RESULT([sysconf(_SC_NPROCESSORS_ONLN)]),
1437         AC_MSG_RESULT([cannot calculate])
1438         )
1440 AC_MSG_CHECKING([for number of available cpus])
1441 AC_TRY_COMPILE([#include <unistd.h>],
1442         [sysconf(_SC_NPROCESSORS_CONF) > 0;],
1443         AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_CONF,1,[Define if sysconf returns number of available cpus])
1444         AC_MSG_RESULT([sysconf(_SC_NPROCESSORS_CONF)]),
1445         AC_MSG_RESULT([cannot calculate])
1446         )
1448 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1449 AC_ARG_WITH(uptime_command,
1450             ACX_HELP_STRING([--with-uptime-command=PATH],
1451                             [sets path to uptime]), PATH_TO_UPTIME=$withval)
1452 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1454 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1455 AC_ARG_WITH(rpcinfo_command,
1456             ACX_HELP_STRING([--with-rpcinfo-command=PATH],
1457                             [sets path to rpcinfo]), PATH_TO_RPCINFO=$withval)
1458 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1460 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1461 if test -x "$PATH_TO_LMSTAT"
1462 then
1463         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1464 else
1465         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1468 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1469 AC_ARG_WITH(smbclient_command,
1470             ACX_HELP_STRING([--with-smbclient-command=PATH],
1471                             [sets path to smbclient]),
1472             PATH_TO_SMBCLIENT=$withval)
1473 if test -n "$PATH_TO_SMBCLIENT"
1474 then
1475         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1476 else
1477         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1480 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1481 AC_ARG_WITH(snmpget_command,
1482             ACX_HELP_STRING([--with-snmpget-command=PATH],
1483                             [Path to snmpget command]),
1484             PATH_TO_SNMPGET=$withval)
1485 if test -n "$PATH_TO_SNMPGET"
1486 then
1487         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1488         EXTRAS="$EXTRAS check_hpjd check_snmp\$(EXEEXT)"
1489 else
1490         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1493 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1494 AC_ARG_WITH(snmpgetnext_command,
1495             ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
1496                             [Path to snmpgetnext command]),
1497             PATH_TO_SNMPGETNEXT=$withval)
1498 if test -n "$PATH_TO_SNMPGETNEXT"
1499 then
1500         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1503 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1504 then
1505         AC_MSG_CHECKING(for Net::SNMP perl module)
1506         AC_MSG_RESULT([found])
1507 else
1508         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1511 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1512 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1513 AC_ARG_WITH(qstat_command,
1514             ACX_HELP_STRING([--with-qstat-command=PATH],
1515                             [Path to qstat command]), PATH_TO_QSTAT=$withval)
1517 if test -x "$PATH_TO_QUAKESTAT"
1518 then
1519         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1520         EXTRAS="$EXTRAS check_game\$(EXEEXT)"
1522 elif test -n "$PATH_TO_QSTAT"
1523 then
1524         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1525         EXTRAS="$EXTRAS check_game\$(EXEEXT)"
1526 else
1527         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1530 if test $ac_cv_path_to_qstat
1531 then
1532         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1533                 [path to qstat/quakestat])
1536 AC_PATH_PROG(PATH_TO_FPING,fping)
1537 AC_PATH_PROG(PATH_TO_FPING6,fping6)
1539 AC_ARG_WITH(fping_command,
1540             ACX_HELP_STRING([--with-fping-command=PATH],
1541                             [Path to fping command]), PATH_TO_FPING=$withval)
1542 AC_ARG_WITH(fping6_command,
1543             ACX_HELP_STRING([--with-fping6-command=PATH],
1544                             [Path to fping6 command]), PATH_TO_FPING6=$withval)
1546 if test -n "$PATH_TO_FPING"
1547 then
1548         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1549         EXTRAS="$EXTRAS check_fping\$(EXEEXT)"
1550         if test x"$with_ipv6" != xno && test -n "$PATH_TO_FPING6"; then
1551                 AC_DEFINE_UNQUOTED(PATH_TO_FPING6,"$PATH_TO_FPING6",[path to fping6])
1552         fi
1553 else
1554         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1557 AC_PATH_PROG(PATH_TO_SSH,ssh)
1558 AC_ARG_WITH(ssh_command,
1559             ACX_HELP_STRING([--with-ssh-command=PATH],
1560                             [sets path for ssh]), PATH_TO_SSH=$withval)
1561 if test -n "$PATH_TO_SSH"
1562 then
1563         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1564         EXTRAS="$EXTRAS check_by_ssh\$(EXEEXT)"
1565 else
1566         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1569 AC_PATH_PROG(PATH_TO_SUDO,sudo)
1570 AC_ARG_WITH(sudo_command,
1571             ACX_HELP_STRING([--with-sudo-command=PATH],
1572                             [sets path to sudo]), PATH_TO_SUDO=$withval)
1573 if test -n "$PATH_TO_SUDO"
1574 then
1575         AC_DEFINE_UNQUOTED(PATH_TO_SUDO,"$PATH_TO_SUDO",[path to sudo])
1576 else
1577         AC_MSG_WARN([Could not find sudo or equivalent])
1580 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1581 AC_ARG_WITH(mailq_command,
1582             ACX_HELP_STRING([--with-mailq-command=PATH],
1583                             [sets path to mailq]), PATH_TO_MAILQ=$withval)
1584 if test -n "$PATH_TO_MAILQ"
1585 then
1586         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1587 else
1588         AC_MSG_WARN([Could not find mailq or equivalent])
1591 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1592 AC_ARG_WITH(qmail_qstat_command,
1593             ACX_HELP_STRING([--with-qmail-qstat-command=PATH],
1594                             [sets path to qmail-qstat]), PATH_TO_QMAIL_QSTAT=$withval)
1595 if test -n "$PATH_TO_QMAIL_QSTAT"
1596 then
1597         AC_DEFINE_UNQUOTED(PATH_TO_QMAIL_QSTAT,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1598 else
1599         AC_MSG_WARN([Could not find qmail-qstat or equivalent])
1602 dnl SWAP info required is amount allocated/available and amount free
1603 dnl The plugin works through all the swap devices and adds up the total swap
1604 dnl available.
1605 AC_PATH_PROG(PATH_TO_SWAP,swap)
1606 if (test -n "$PATH_TO_SWAP")
1607 then
1608 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1609 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1610 then
1611         ac_cv_have_swap=yes
1612         ac_cv_swap_command="$PATH_TO_SWAP -l"
1613         if [$PATH_TO_SWAP -l 2>/dev/null | \
1614                 grep -E -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1615                 >/dev/null]
1616         then
1617                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %lu %lu"]
1618                 ac_cv_swap_conv=2048
1619                 AC_MSG_RESULT([using IRIX format swap])
1621         elif [$PATH_TO_SWAP -l 2>/dev/null | grep -E -i "^path +dev +swaplo +blocks +free" >/dev/null]
1622         then
1623                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %lu %lu"]
1624                 ac_cv_swap_conv=2048
1625                 AC_MSG_RESULT([using Unixware format swap])
1626         else
1627                 dnl if we don't know what format swap's output is
1628                 dnl we might as well pretend we didn't see it
1629                 ac_cv_have_swap=""
1630                 ac_cv_swap_command=""
1631         fi
1633 dnl end if for PATH_TO_SWAP
1636 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1637 if (test -n "$PATH_TO_SWAPINFO")
1638 then
1639 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1640 if [$PATH_TO_SWAPINFO -k 2>&1 | grep -E -i "^Device" >/dev/null]
1641 then
1642         ac_cv_have_swap=yes
1643         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1645         if [$PATH_TO_SWAPINFO -k 2>/dev/null | grep -E -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1646         then
1647                 ac_cv_swap_format=["%*s %lu %*d %lu"]
1648                 ac_cv_swap_conv=1024
1649                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1650         fi
1652 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | grep -E -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1653 then
1654         ac_cv_have_swap=yes
1655         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM"
1656         ac_cv_swap_format=["%*s %lu %*d %lu"]
1657         ac_cv_swap_conv=1024
1658         AC_MSG_RESULT([using HP-UX format swapinfo])
1660 dnl end if for PATH_TO_SWAPINFO
1663 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1664 if (test -n "$PATH_TO_LSPS")
1665 then
1666 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1667 if [$PATH_TO_LSPS -a 2>/dev/null | grep -E -i "^Page Space" > /dev/null]
1668 then
1669         ac_cv_have_swap=yes
1670         ac_cv_swap_command="$PATH_TO_LSPS -a"
1671         ac_cv_swap_format=["%*s %*s %*s %lu%*s %lu %*s"]
1672         ac_cv_swap_conv=1
1673         AC_MSG_RESULT([using AIX lsps])
1675 dnl end if for PATH_TO_SWAPINFO
1679 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1680 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1681 dnl in the various BSD's
1684 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1685 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1686 #ifdef HAVE_SYS_PARAM_H
1687 #include <sys/param.h>
1688 #endif
1690 AC_CHECK_DECLS([swapctl],,,[
1691                #include <unistd.h>
1692                #include <sys/types.h>
1693                #include <sys/param.h>
1694                #include <sys/stat.h>
1695                #include <sys/swap.h>
1696                ])
1697 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1698                #include <sys/types.h>
1699                #include <sys/param.h>
1700                #include <sys/stat.h>
1701                #include <sys/swap.h>
1702                ])
1703 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1704                  #include <unistd.h>
1705                  #include <sys/types.h>
1706                  #include <sys/param.h>
1707                  #include <sys/stat.h>
1708                  #include <sys/swap.h>
1709                  ])
1711 if test "$ac_cv_have_decl_swapctl" = "yes";
1712 then
1713         EXTRAS="$EXTRAS check_swap\$(EXEEXT)"
1714         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1715         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1716                 "$ac_cv_type_swapent_t" = "yes";
1717         then
1718                 AC_MSG_RESULT([yes])
1719                 ac_cv_check_swap_swapctl_svr4="1";
1720                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1721                           [Define if 2-argument SVR4 swapctl exists])
1722         else
1723                 AC_MSG_RESULT([no])
1724                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1725                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes";
1726                 then
1727                         AC_MSG_RESULT([yes])
1728                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1729                                   [Define if 3-argument BSD swapctl exists])
1730                 else
1731                         AC_MSG_RESULT([no])
1732                 fi
1733         fi
1734         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1735         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1736         then
1737                 dnl
1738                 dnl the SVR4 spec returns values in pages
1739                 dnl
1740                 AC_MSG_RESULT([page])
1741                 AC_CHECK_DECLS([sysconf])
1742                 AC_MSG_CHECKING([for system page size])
1743                 if test "$ac_cv_have_decl_sysconf" = "yes";
1744                 then
1745                         AC_MSG_RESULT([determined by sysconf(3)])
1746                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1747                 else
1748                         AC_MSG_WARN([don't know. guessing 4096k])
1749                         ac_cv_swap_conv=256
1750                 fi
1751         else
1752                 dnl
1753                 dnl the BSD spec returns values in blocks
1754                 dnl
1755                 AC_MSG_RESULT([blocks (assuming 512b)])
1756                 ac_cv_swap_conv=2048
1757         fi
1758         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1759                 [Conversion factor to MB])
1762 dnl end tests for the swapctl system calls
1766 if test "x$ac_cv_have_swap" != "x"
1767 then
1768         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1769         EXTRAS="$EXTRAS check_swap\$(EXEEXT)"
1771 if test "x$ac_cv_swap_command" != "x"
1772 then
1773         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1774                 [Path to swap/swapinfo binary, with any args])
1775         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1776                 [Format string for parsing swap output])
1777         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1778                 [Conversion factor to MB])
1781 AC_ARG_WITH(proc-meminfo,
1782             ACX_HELP_STRING([--with-proc-meminfo=PATH],
1783                             [path to /proc/meminfo or equivalent]),
1784                             ac_cv_proc_meminfo=$withval)
1785 dnl dunno why this does not work below - use hack (kbd)
1786 dnl fine on linux, broken on solaris
1787 dnl if /bin/test -e "/proc/meminfo"
1788 AC_MSG_CHECKING([for /proc/meminfo])
1789 if test -n "$ac_cv_proc_meminfo"; then
1790         AC_MSG_RESULT([(command line) $ac_cv_proc_meminfo])
1791 elif [cat /proc/meminfo > /dev/null 2>&1]; then
1792         AC_MSG_RESULT([found /proc/meminfo])
1793         ac_cv_proc_meminfo="/proc/meminfo"
1794 else
1795         AC_MSG_RESULT([no])
1798 if test -n "$ac_cv_proc_meminfo"; then
1799         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1800         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"$ac_cv_proc_meminfo",[path to /proc/meminfo if name changes])
1801         EXTRAS="$EXTRAS check_swap\$(EXEEXT)"
1804 AC_PATH_PROG(PATH_TO_DIG,dig)
1805 AC_ARG_WITH(dig_command,
1806             ACX_HELP_STRING([--with-dig-command=PATH],
1807                             [Path to dig command]), PATH_TO_DIG=$withval)
1808 if test -n "$PATH_TO_DIG"; then
1809         EXTRAS="$EXTRAS check_dig\$(EXEEXT)"
1810         AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1813 AC_PATH_PROG(PATH_TO_APTGET,apt-get)
1814 AC_ARG_WITH(apt-get_command,
1815             ACX_HELP_STRING([--with-apt-get-command=PATH],
1816                             [Path to apt-get command]),
1817                             with_apt_get_command=$withval,
1818                             with_apt_get_command=$PATH_TO_APTGET)
1819 AC_DEFINE_UNQUOTED(PATH_TO_APTGET,"$PATH_TO_APTGET",[Path to apt-get command, if present])
1820 if test -n "$PATH_TO_APTGET" ; then
1821         EXTRAS="$EXTRAS check_apt\$(EXEEXT)"
1825 if test -f $srcdir/plugins/check_nt.c ; then
1826   EXTRAS="$EXTRAS check_nt\$(EXEEXT)"
1830 dnl used in check_dhcp
1831 AC_CHECK_HEADERS(sys/sockio.h)
1833 case $host in
1834         *bsd*)
1835                 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1836         ;;
1837         *linux*)
1838                 AC_DEFINE(__linux__,1,[linux specific code in check_dhcp.c])
1839         ;;
1840         *sun* | *solaris*)
1841                 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1842         ;;
1843         *hpux*)
1844                 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1845         ;;
1846 esac
1848 AC_SUBST(EXTRAS)
1849 AC_SUBST(EXTRAS_ROOT)
1850 AC_SUBST(EXTRA_NETOBJS)
1851 AC_SUBST(DEPLIBS)
1853 AM_GNU_GETTEXT([external], [need-ngettext])
1854 AM_GNU_GETTEXT_VERSION(0.15)
1856 dnl Check for Redhat spopen problem
1857 dnl Weird problem where ECHILD is returned from a wait call in error
1858 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1859 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1860 dnl We patch plugins/popen.c
1861 dnl Need to add smp because uname different on those
1862 dnl Can force patch to be applied with --enable-redhat-pthread-workaround
1863 AC_ARG_ENABLE(redhat-pthread-workaround,
1864         AC_HELP_STRING([--enable-redhat-pthread-workaround],
1865                 [force Redhat patch to be applied (default: test system)]),
1866         [ac_cv_enable_redhat_pthread_workaround=$enableval],
1867         [ac_cv_enable_redhat_pthread_workaround=test])
1868 if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1869         if echo $ac_cv_uname_r | grep -E "\.EL(smp)?$" >/dev/null 2>&1 ; then
1870                 AC_MSG_NOTICE([See https://www.monitoring-plugins.org/doc/faq/configure-hangs.html if this next part takes a long time])
1871                 AC_MSG_CHECKING(for redhat spopen problem)
1872                 ( cd config_test && make && make test ) > /dev/null 2>&1
1873                 if test $? -eq 0 ; then
1874                         AC_MSG_RESULT(okay)
1875                 else
1876                         AC_MSG_RESULT(error)
1877                         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Workaround on redhat in spopen])
1878                 fi
1879         fi
1880 elif test "$ac_cv_enable_redhat_pthread_workaround" = "yes" ; then
1881         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Forced workaround on redhat in spopen])
1884 dnl Perl modules
1885 AC_ARG_ENABLE(perl-modules,
1886         AC_HELP_STRING([--enable-perl-modules],
1887                 [Enables installation of Monitoring::Plugin and its dependencies (default: no)]),
1888         [enable_perl_modules=$enableval],
1889         [enable_perl_modules=no])
1890 if test "$enable_perl_modules" = "yes" ; then
1891   AC_SUBST(PERLMODS_DIR,perlmods)
1894 # From Tap configure
1895 # Checks for libraries
1896 case "$host" in
1897         *-*-*freebsd4*)
1898                 LDFLAGS="$LDFLAGS -pthread"
1899                 HAVE_LIBPTHREAD=1
1900                 ;;
1901         *)
1902                 AC_CHECK_LIB(pthread, main)
1903                 ;;
1904 esac
1906 dnl External libraries - see ACKNOWLEDGEMENTS
1907 gl_INIT
1909 dnl Some helpful common compile errors checked here
1910 if test "$ac_cv_uname_s" = 'SunOS' -a \( "x$ac_cv_prog_ac_ct_AR" = "x" -o "$ac_cv_prog_ac_ct_AR" = 'false' \) ; then
1911         AC_MSG_ERROR(No ar found for Solaris - is /usr/ccs/bin in PATH?)
1914 AC_OUTPUT(
1915   Makefile
1916   tap/Makefile
1917   lib/Makefile
1918   plugins/Makefile
1919   lib/tests/Makefile
1920   plugins-root/Makefile
1921   plugins-scripts/Makefile
1922   plugins-scripts/utils.pm
1923   plugins-scripts/utils.sh
1924   perlmods/Makefile
1925   test.pl
1926   pkg/solaris/pkginfo
1930 dnl the ones below that are commented out need to be cleaned up
1931 dnl in the configure code above to use with_foo instead of ac_cv_foo
1932 dnl if we want them to show up here.  it'd also make the code cleaner.
1933 dnl i'll get to that on another rainy day :) -sf
1934 ACX_FEATURE([with],[apt-get-command])
1935 dnl ACX_FEATURE([with],[dig-command])
1936 dnl ACX_FEATURE([with],[fping-command])
1937 dnl ACX_FEATURE([with],[mailq-command])
1938 dnl ACX_FEATURE([with],[nslookup-command])
1939 ACX_FEATURE([with],[ping6-command])
1940 ACX_FEATURE([with],[ping-command])
1941 dnl ACX_FEATURE([with],[qstat-command])
1942 dnl ACX_FEATURE([with],[rpcinfo-command])
1943 dnl ACX_FEATURE([with],[smbclient-command])
1944 dnl ACX_FEATURE([with],[snmpget-command])
1945 dnl ACX_FEATURE([with],[snmpgetnext-command])
1946 dnl ACX_FEATURE([with],[ssh-command])
1947 dnl ACX_FEATURE([with],[uptime-command])
1949 dnl ACX_FEATURE([with],[proc-meminfo])
1950 dnl ACX_FEATURE([with],[ps-command])
1951 dnl ACX_FEATURE([with],[ps-format])
1952 dnl ACX_FEATURE([with],[ps-cols])
1953 dnl ACX_FEATURE([with],[ps-varlist])
1955 ACX_FEATURE([with],[ipv6])
1956 ACX_FEATURE([with],[mysql])
1957 ACX_FEATURE([with],[openssl])
1958 ACX_FEATURE([with],[gnutls])
1959 ACX_FEATURE([enable],[extra-opts])
1960 ACX_FEATURE([with],[perl])
1961 ACX_FEATURE([enable],[perl-modules])
1962 ACX_FEATURE([with],[cgiurl])
1963 ACX_FEATURE([with],[trusted-path])
1964 ACX_FEATURE([enable],[libtap])
1965 ACX_FEATURE([with],[libcurl])
1966 ACX_FEATURE([with],[uriparser])