NEWS: Add missing entries for the upcoming release
[monitoring-plugins.git] / configure.ac
blob87d43fd2f73dbe5426722a7faef3940c4409ccef
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.59)
3 AC_INIT(monitoring-plugins,1.5)
4 AC_CONFIG_SRCDIR(NPTest.pm)
5 AC_CONFIG_FILES([gl/Makefile 
6         monitoring-plugins.spec])
7 AC_CONFIG_AUX_DIR(build-aux)
8 AM_INIT_AUTOMAKE([1.8.3])
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(freeradius-client,rc_read_config)
278   if test "$ac_cv_lib_freeradius_client_rc_read_config" = "yes"; then
279     EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
280     RADIUSLIBS="-lfreeradius-client"
281     AC_SUBST(RADIUSLIBS)
282   else
283     AC_CHECK_LIB(radiusclient-ng,rc_read_config)
284     if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then
285       EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
286       RADIUSLIBS="-lradiusclient-ng"
287       AC_SUBST(RADIUSLIBS)
288     else
289       AC_CHECK_LIB(radiusclient,rc_read_config)
290       if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
291         EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
292         RADIUSLIBS="-lradiusclient"
293         AC_SUBST(RADIUSLIBS)
294       else
295         AC_MSG_WARN([Skipping radius plugin])
296         AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
297       fi
298     fi
299   fi
300   LIBS="$_SAVEDLIBS"
303 AC_ARG_WITH([ldap], [AS_HELP_STRING([--without-ldap], [Skips the LDAP plugin])])
305 dnl Check for LDAP libraries
306 AS_IF([test "x$with_ldap" != "xno"], [
307   _SAVEDLIBS="$LIBS"
308   AC_CHECK_LIB(ldap,main,,,-llber)
309   if test "$ac_cv_lib_ldap_main" = "yes"; then
310     LDAPLIBS="-lldap -llber"\
311     LDAPINCLUDE="-I/usr/include/ldap"
312     AC_SUBST(LDAPLIBS)
313     AC_SUBST(LDAPINCLUDE)
314     AC_CHECK_FUNCS(ldap_set_option)
315     EXTRAS="$EXTRAS check_ldap\$(EXEEXT)"
316         AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
317   else
318     AC_MSG_WARN([Skipping LDAP plugin])
319     AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
320   fi
321   LIBS="$_SAVEDLIBS"
324 dnl Check for headers used by check_ide_smart
325 case $host in
326   *linux*)
327     AC_CHECK_HEADER(linux/hdreg.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
328     if test "$FOUNDINCLUDE" = "yes" ; then
329         AC_CHECK_HEADER(linux/types.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
330     fi
331     if test "$FOUNDINCLUDE" = "no" ; then
332         AC_MSG_WARN([Skipping check_ide_smart plugin.])
333         AC_MSG_WARN([check_ide_smart requires linux/hdreg.h and linux/types.h.])
334     fi
335   ;;
336   *netbsd*)
337     AC_CHECK_HEADER(dev/ata/atareg.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
338     if test "$FOUNDINCLUDE" = "yes" ; then
339         AC_CHECK_HEADER(dev/ic/wdcreg.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
340     fi
341     if test "$FOUNDINCLUDE" = "no" ; then
342         AC_MSG_WARN([Skipping check_ide_smart plugin.])
343         AC_MSG_WARN([check_ide_smart requires dev/ata/atareg.h and dev/ic/wdcreg.h])
344     fi
345   ;;
346   *)
347     AC_MSG_WARN([Skipping check_ide_smart plugin.])
348     AC_MSG_WARN([check_ide_smart works only on Linux and NetBSD])
349 esac
351 if test "$FOUNDINCLUDE" = "yes" ; then
352         EXTRAS="$EXTRAS check_ide_smart\$(EXEEXT)"
355 dnl Check for mysql libraries
356 np_mysqlclient
357 if test $with_mysql = "no" ; then
358   AC_MSG_WARN([Skipping mysql plugin])
359   AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
360 else
361   EXTRAS="$EXTRAS check_mysql\$(EXEEXT) check_mysql_query\$(EXEEXT)"
362   MYSQLINCLUDE="$np_mysql_include"
363   MYSQLLIBS="$np_mysql_libs"
364   MYSQLCFLAGS="$np_mysql_cflags"
365   AC_SUBST(MYSQLINCLUDE)
366   AC_SUBST(MYSQLLIBS)
367   AC_SUBST(MYSQLCFLAGS)
370 dnl Check for headers used by check_users
371 AC_CHECK_HEADERS(utmpx.h)
372 AM_CONDITIONAL([HAVE_UTMPX], [test "$ac_cv_header_utmpx_h" = "yes"])
374 AC_CHECK_HEADERS(wtsapi32.h, [], [], [#include <windows.h>])
375 AM_CONDITIONAL([HAVE_WTS32API], [test "$ac_cv_header_wtsapi32_h" = "yes"])
377 if test "$ac_cv_header_wtsapi32_h" = "yes"; then
378   WTSAPI32LIBS="-lwtsapi32"
379   AC_SUBST(WTSAPI32LIBS)
382 dnl Fallback to who(1) if the system doesn't provide an utmpx(5) interface
383 if test "$ac_cv_header_utmpx_h" = "no" -a "$ac_cv_header_wtsapi32_h" = "no"
384 then
385         AC_PATH_PROG(PATH_TO_WHO,who)
387         if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
388         then
389                 ac_cv_path_to_who="$PATH_TO_WHO -q"
390         else
391                 ac_cv_path_to_who="$PATH_TO_WHO"
392         fi
394         AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
395                 [path and arguments for invoking 'who'])
398 AC_ARG_WITH([ipv6],
399         [AS_HELP_STRING([--with-ipv6], [support IPv6 @<:@default=check@:>@])],
400         [], [with_ipv6=check])
402 dnl Check for AF_INET6 support - unistd.h required for Darwin
403 if test "$with_ipv6" != "no"; then
404         AC_CACHE_CHECK([for IPv6 support], np_cv_sys_ipv6, [
405                 AC_TRY_COMPILE(
406                         [#ifdef HAVE_UNISTD_H
407                         #include <unistd.h>
408                         #endif
409                         #include <netinet/in.h>
410                         #include <sys/socket.h>],
411                         [struct sockaddr_in6 sin6;
412                         void *p;
414                         sin6.sin6_family = AF_INET6;
415                         sin6.sin6_port = 587;
416                         p = &sin6.sin6_addr;],
417                         [np_cv_sys_ipv6=yes],
418                         [np_cv_sys_ipv6=no])
419                 ])
420         if test "$np_cv_sys_ipv6" = "no" -a "$with_ipv6" != "check"; then
421                 AC_MSG_FAILURE([--with-ipv6 was given, but test for IPv6 support failed])
422         fi
423         if test "$np_cv_sys_ipv6" = "yes"; then
424                 AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
425         fi
426         with_ipv6="$np_cv_sys_ipv6"
430 dnl Checks for Kerberos. Must come before openssl checks for Redhat EL 3
431 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
432 if test "$FOUNDINCLUDE" = "no"; then
433   _SAVEDCPPFLAGS="$CPPFLAGS"
434   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
435   unset ac_cv_header_krb5_h
436   AC_CHECK_HEADERS(krb5.h,
437                    KRB5INCLUDE="-I/usr/kerberos/include"
438                    FOUNDINCLUDE=yes,
439                    FOUNDINCLUDE=no)
441 AC_SUBST(KRBINCLUDE)
442 if test "$FOUNDINCLUDE" = "no"; then
443   CPPFLAGS="$_SAVEDCPPFLAGS"
446 dnl *** The following block comes from wget configure.ac ***
447 dnl Unfortunately, as of this writing (OpenSSL 0.9.6), the libcrypto
448 dnl shared library doesn't record its dependency on libdl, so we
449 dnl need to check for it ourselves so we won't fail to link due to a
450 dnl lack of -ldl.  Most OSes use dlopen(), but HP-UX uses
451 dnl shl_load().
452 AC_CHECK_LIB(dl,dlopen)
453 AC_CHECK_LIB(dl,shl_load)
455 dnl openssl detection/configuration
456 if ! test x"$with_openssl" = x"no"; then
457         dnl Check for OpenSSL location if it wasn't already specified
458         if ! test -d "$with_openssl"; then
459                 for d in $OPENSSL_DIRS; do
460                         if test -x ${d}/bin/openssl || test -x ${d}/sbin/openssl ; then
461                                 with_openssl=$d
462                         fi
463                 done
464         fi
466         _SAVEDCPPFLAGS="$CPPFLAGS"
467         _SAVEDLDFLAGS="$LDFLAGS"
468         dnl Check for OpenSSL header files
469         unset FOUNDINCLUDE
470         if test x"$with_openssl" != x"/usr" ; then
471                 CPPFLAGS="$CPPFLAGS -I$with_openssl/include"
472                 LDFLAGS="$LDFLAGS -L$with_openssl/lib"
473         fi
475         dnl check for openssl in $dir/include/openssl
476         AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
477                          SSLINCLUDE="-I$with_openssl/include"
478                          FOUNDINCLUDE=yes,
479                          FOUNDINCLUDE=no)
480         dnl else check to see if $dir/include has it
481         if test "$FOUNDINCLUDE" = "no"; then
482                 AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
483                                  SSLINCLUDE="-I$with_openssl/include"
484                                  FOUNDINCLUDE=yes,
485                                  FOUNDINCLUDE=no)
486         fi
487         AC_SUBST(SSLINCLUDE)
488         dnl if we didn't find it, reset CPPFLAGS
489         if test "$FOUNDINCLUDE" = "no"; then
490                 CPPFLAGS="$_SAVEDCPPFLAGS"
491                 LDFLAGS="$_SAVEDLDFLAGS"
492         fi
494         dnl Check for crypto lib
495         _SAVEDLIBS="$LIBS"
496         LIBS="-L${with_openssl}/lib"
497         AC_CHECK_LIB(crypto,CRYPTO_lock)
498         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
499                 dnl Check for SSL lib
500                 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
501         fi
502         LIBS="$_SAVEDLIBS"
504         dnl test headers and libs to decide whether check_http should use SSL
505         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
506                 if test "$ac_cv_lib_ssl_main" = "yes"; then
507                         if test "$FOUNDINCLUDE" = "yes"; then
508                                 FOUNDOPENSSL="yes"
509                         fi
510                 fi
511         fi
515 dnl check for gnutls if openssl isn't found (or is disabled)
516 if test ! "$FOUNDOPENSSL" = "yes" && test ! "$with_gnutls" = "no"; then
517         if test ! "$with_gnutls" = ""; then
518                 CPPFLAGS="$CPPFLAGS -I${with_gnutls}/include"
519         fi
520         AC_CHECK_HEADERS([gnutls/openssl.h],FOUNDGNUTLS="yes",)
521         if test "$FOUNDGNUTLS" = "yes"; then
522                 AC_CHECK_LIB(gnutls-openssl,main,SSLLIBS="-lgnutls-openssl")
523         fi
525 dnl end check for gnutls
527 if test "$FOUNDOPENSSL" = "yes" || test "$FOUNDGNUTLS" = "yes"; then
528         check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
529         AC_SUBST(check_tcp_ssl)
530         AC_SUBST(SSLLIBS)
531         AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
532         if test "$FOUNDOPENSSL" = "yes"; then
533                 AC_DEFINE(USE_OPENSSL,1,[Define if using OpenSSL libraries])
534                 with_openssl="yes"
535                 with_gnutls="no"
536         else
537                 AC_DEFINE(USE_GNUTLS,1,[Define if using gnutls libraries])
538                 with_gnutls="yes"
539                 with_openssl="no"
540         fi
541 else
542         dnl else deliberately disabled or no ssl support available
543         AC_MSG_WARN([OpenSSL or GnuTLS libs could not be found or were disabled])
544         with_openssl="no"
545         with_gnutls="no"
549 dnl Checks for header files.
552 AC_HEADER_TIME
553 AC_HEADER_SYS_WAIT
554 AC_CHECK_HEADERS(signal.h syslog.h uio.h errno.h sys/time.h sys/socket.h sys/un.h sys/poll.h)
555 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h)
557 dnl Checks for typedefs, structures, and compiler characteristics.
558 AC_C_CONST
559 AC_STRUCT_TM
560 AC_TYPE_PID_T
561 AC_TYPE_SIZE_T
562 AC_TYPE_SIGNAL
564 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
565 AC_TRY_LINK([#include <stdarg.h>
566 va_list ap1,ap2;], [va_copy(ap1,ap2);],
567 ac_cv_HAVE_VA_COPY=yes,
568 ac_cv_HAVE_VA_COPY=no)])
569 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
570     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
571 else
572     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
573     AC_TRY_LINK([#include <stdarg.h>
574     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
575     ac_cv_HAVE___VA_COPY=yes,
576     ac_cv_HAVE___VA_COPY=no)])
577     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
578         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
579     fi
582 AC_TRY_COMPILE([#include <sys/time.h>],
583                [struct timeval *tv;
584                 struct timezone *tz;],
585                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
586                AC_TRY_COMPILE([#include <sys/time.h>],
587                               [struct timeval *tv;
588                                struct timezone *tz;
589                                gettimeofday(tv, tz);],
590                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
591                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
593 dnl Checks for library functions.
594 AC_CHECK_FUNCS(memmove select socket strdup strstr strtol strtoul floor)
595 AC_CHECK_FUNCS(poll)
597 AC_MSG_CHECKING(return type of socket size)
598 AC_TRY_COMPILE([#include <stdlib.h>
599                 #include <sys/types.h>
600                 #include <sys/socket.h>],
601                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
602                ac_cv_socket_size_type=["size_t"]
603                 AC_MSG_RESULT(size_t),
604                ac_cv_socket_size_type=["int"]
605                 AC_MSG_RESULT(int))
607 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
608         [Define type of socket size])
611 dnl #### Process table test
613 AC_PATH_PROG(PATH_TO_PS,ps)
615 AC_MSG_CHECKING(for ps syntax)
616 AC_ARG_WITH(ps_command,
617             ACX_HELP_STRING([--with-ps-command=PATH],
618                             [Verbatim command to execute for ps]),
619             PS_COMMAND=$withval)
620 AC_ARG_WITH(ps_format,
621             ACX_HELP_STRING([--with-ps-format=FORMAT],
622                             [Format string for scanning ps output]),
623             PS_FORMAT=$withval)
624 AC_ARG_WITH(ps_cols,
625             ACX_HELP_STRING([--with-ps-cols=NUM],
626                             [Number of columns in ps command]),
627             PS_COLS=$withval)
628 AC_ARG_WITH(ps_varlist,
629             ACX_HELP_STRING([--with-ps-varlist=LIST],
630                             [Variable list for sscanf of 'ps' output]),
631             PS_VARLIST=$withval)
633 if test -n "$PS_COMMAND" && test -n "$PS_FORMAT" && test -n "$PS_COLS" && test -n "$PS_VARLIST"; then
634         ac_cv_ps_command="$PS_COMMAND"
635         ac_cv_ps_format="$PS_FORMAT"
636         ac_cv_ps_varlist="$PS_VARLIST"
637         ac_cv_ps_cols="$PS_COLS"
638         AC_MSG_RESULT([(command-line) $ac_cv_ps_command])
640 dnl Now using the pst3/kmem hack for solaris systems to avoid truncation
641 elif test "$ac_cv_uname_s" = "SunOS"; then
642         #
643         # this is a very, very ugly hack, to hardcode the location for plugins
644         #
645         if test "$libexecdir" = '${exec_prefix}/libexec'; then
646                 if test "$exec_prefix" = "NONE"; then
647                         if test "$prefix" = "NONE"; then
648                                 pst3="$ac_default_prefix/libexec/pst3"
649                         else
650                                 pst3="$prefix/libexec/pst3"
651                         fi
652                 else
653                         pst3="$exec_prefix/libexec/pst3"
654                 fi
655         else
656                 pst3="$libexecdir/pst3"
657         fi
658         ac_cv_ps_command="$pst3"
659         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
660         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
661         ac_cv_ps_cols=9
662         AC_MSG_RESULT([using monitoring-plugins internal ps command (pst3) for solaris])
663         if test `isainfo -b` = 64 ; then
664                 pst3_use_64bit=1
665                 AC_MSG_NOTICE([using 64bit pst3])
666         else
667                 AC_MSG_NOTICE([using 32bit pst3])
668         fi
669         EXTRAS_ROOT="$EXTRAS_ROOT pst3\$(EXEEXT)"
671         if test "$pst3_use_64bit" = 1; then
672                 dnl Test if we can actually compile code in 64bit
673                 old_cflags=$CFLAGS
674                 CFLAGS="$CFLAGS -m64"
675                 pst3_64bit_working=0
676                 AC_RUN_IFELSE(
677                         [AC_LANG_PROGRAM([], [
678 return sizeof(void*) == 8 ? 0 : 1;
679                         ])
680                 ],[
681                         PST3CFLAGS="-m64"
682                         AC_SUBST(PST3CFLAGS)
683                         pst3_64bit_working=1
684                         AC_MSG_NOTICE([using -m64 for 64bit code])
685                 ],[
686                         pst3_64bit_working=0
687                         AC_MSG_NOTICE([compiler do not like -m64])
688                 ])
689                 CFLAGS=$old_cflags
690                 if test "$pst3_64bit_working" = 0; then
691                         old_cflags=$CFLAGS
692                         CFLAGS="$CFLAGS -xarch=v9"
693                         AC_RUN_IFELSE(
694                                 [AC_LANG_PROGRAM([], [
695 return sizeof(void*) == 8 ? 0 : 1;
696                                 ])
697                         ],[
698                                 PST3CFLAGS="-xarch=v9"
699                                 AC_SUBST(PST3CFLAGS)
700                                 pst3_64bit_working=1
701                                 AC_MSG_NOTICE([using -xarch=v9 for 64bit code])
702                         ],[
703                                 pst3_64bit_working=0
704                                 AC_MSG_NOTICE([compiler do not like -xarch=v9])
705                         ])
706                         CFLAGS=$old_cflags
707                 fi
708                 if test "$pst3_64bit_working" = 0; then
709                         old_cflags=$CFLAGS
710                         CFLAGS="$CFLAGS -xarch=amd64"
711                         AC_RUN_IFELSE(
712                                 [AC_LANG_PROGRAM([], [
713 return sizeof(void*) == 8 ? 0 : 1;
714                                 ])
715                         ],[
716                                 PST3CFLAGS="-xarch=amd64"
717                                 AC_SUBST(PST3CFLAGS)
718                                 pst3_64bit_working=1
719                                 AC_MSG_NOTICE([using -xarch=amd64 for 64bit code])
720                         ],[
721                                 pst3_64bit_working=0
722                                 AC_MSG_NOTICE([compiler do not like -xarch=amd64])
723                         ])
724                         CFLAGS=$old_cflags
725                 fi
726                 if test "$pst3_64bit_working" = 0; then
727                         AC_MSG_ERROR([I don't know how to build a 64-bit object!])
728                 fi
729         fi
731 dnl Removing this for the moment - Ton
732 dnl Using /usr/ucb/ps on Solaris systems, to avoid truncation
733 dnl Limitation that command name is not available
734 dnl elif test "$ac_cv_uname_s" = "SunOS" && /usr/ucb/ps -alxwwn 2>/dev/null | \
735 dnl     egrep -i ["^ *F +UID +PID +PPID +%C +PRI +NI +SZ +RSS +WCHAN +S +TT +TIME +COMMAND"] > /dev/null
736 dnl then
737 dnl     ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procpcpu,&procvsz,&procrss,procstat,&pos]"
738 dnl     ac_cv_ps_command="/usr/ucb/ps -alxwwn"
739 dnl     ac_cv_ps_format=["%*s %d %d %d %d %*d %*d %d %d%*[ 0123456789abcdef]%[OSRZT]%*s %*s %n"]
740 dnl     ac_cv_ps_cols=8
741 dnl     AC_MSG_RESULT([$ac_cv_ps_command])
743 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
744 dnl so test for this first...
745 elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
746         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
747 then
748         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
749         ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
750         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
751         ac_cv_ps_cols=9
752         AC_MSG_RESULT([$ac_cv_ps_command])
754 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
755 dnl Should also work for FreeBSD 5.2.1 and 5.3
756 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
757 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
758         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
759 then
760         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
761         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
762         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
763         ac_cv_ps_cols=9
764         AC_MSG_RESULT([$ac_cv_ps_command])
766 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4.
767 dnl Limitation: Only first 16 chars returned for ucomm field
768 dnl Must come before ps -weo
769 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
770         egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
771 then
772         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
773         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
774         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
775         ac_cv_ps_cols=9
776         AC_MSG_RESULT([$ac_cv_ps_command])
778 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
779 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
780         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
781 then
782         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
783         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
784         ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
785         ac_cv_ps_cols=10
786         AC_MSG_RESULT([$ac_cv_ps_command])
788 dnl FreeBSD
789 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
790         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
791 then
792         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
793         ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
794         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
795         ac_cv_ps_cols=9
796         AC_MSG_RESULT([$ac_cv_ps_command])
798 dnl BSD-like mode in RH 6.1
799 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
800         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
801 then
802         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
803         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
804         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
805         ac_cv_ps_cols=9
806         AC_MSG_RESULT([$ac_cv_ps_command])
808 dnl SunOS 4.1.3:
809 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
810 dnl Need the head -1 otherwise test will work because arguments are found
811 elif ps -laxnwww 2>/dev/null | head -1 | \
812         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
813 then
814         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
815         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
816         ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
817         ac_cv_ps_cols=9
818         AC_MSG_RESULT([$ac_cv_ps_command])
820 dnl Debian Linux / procps v1.2.9:
821 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
822 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
824 elif ps laxnwww 2>/dev/null | \
825         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
826 then
827         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
828         ac_cv_ps_command="$PATH_TO_PS laxnwww"
829         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
830         ac_cv_ps_cols=9
831         AC_MSG_RESULT([$ac_cv_ps_command])
833 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
834 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
835         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
836 then
837         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
838         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
839         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
840         ac_cv_ps_cols=9
841         AC_MSG_RESULT([$ac_cv_ps_command])
843 dnl Tru64 - needs %*[ +<>] in PS_FORMAT.
844 dnl Has /usr/bin/ps and /sbin/ps - force sbin version
845 dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead
846 dnl of 1500). Will need big changes to check_procs to support
847 elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
848         egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
849 then
850         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
851         ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
852         ac_cv_ps_format=["%s%*[ +<>] %d %d %d %f %s %s %n"]
853         ac_cv_ps_cols=8
854         AC_MSG_RESULT([$ac_cv_ps_command])
856 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
857         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
858 then
859         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
860         ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
861         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
862         ac_cv_ps_cols=9
863         AC_MSG_RESULT([$ac_cv_ps_command])
865 dnl AIX 4.3.3 and 5.1 do not have an rss field
866 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
867         egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
868 then
869         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
870         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
871         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
872         ac_cv_ps_cols=8
873         AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
875 dnl Solaris 2.6
876 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
877         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
878 then
879         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
880         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
881         # There must be no space between the %s and %n due to a wierd problem in sscanf where
882         # it will return %n as longer than the line length
883         ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
884         ac_cv_ps_cols=9
885         AC_MSG_RESULT([$ac_cv_ps_command])
887 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
888         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
889 then
890         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
891         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
892         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
893         ac_cv_ps_cols=9
894         AC_MSG_RESULT([$ac_cv_ps_command])
896 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
897         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
898 then
899         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
900         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
901         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
902         ac_cv_ps_cols=9
903         AC_MSG_RESULT([$ac_cv_ps_command])
905 dnl wonder who takes state instead of stat
906 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
907         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
908 then
909         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
910         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
911         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
912         ac_cv_ps_cols=8
913         AC_MSG_RESULT([$ac_cv_ps_command])
915 dnl IRIX 53
916 elif ps -el 2>/dev/null | \
917         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
918 then
919         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
920         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
921         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
922         ac_cv_ps_cols=8
923         AC_MSG_RESULT([$ac_cv_ps_command])
925 dnl IRIX 63
926 elif ps -el 2>/dev/null | \
927         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
928 then
929         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
930         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
931         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
932         ac_cv_ps_cols=6
933         AC_MSG_RESULT([$ac_cv_ps_command])
935 dnl AIX 4.1:
936 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
937 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
938 elif ps -el 2>/dev/null | \
939         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
940 then
941         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
942         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
943         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
944         ac_cv_ps_cols=6
945         AC_MSG_RESULT([$ac_cv_ps_command])
947 dnl AIX?
948 elif ps glaxen 2>/dev/null | \
949         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
950 then
951         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
952         ac_cv_ps_command="$PATH_TO_PS glaxen"
953         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
954         ac_cv_ps_cols=8
955         AC_MSG_RESULT([$ac_cv_ps_command])
957 dnl MacOSX / Darwin
958 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
959 dnl Some truncation will happen in UCOMM column
960 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
961 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
962 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
963         egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
964 then
965         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
966         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
967         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
968         ac_cv_ps_cols=8
969         AC_MSG_RESULT([$ac_cv_ps_command])
971 dnl UnixWare
972 elif ps -Al 2>/dev/null | \
973         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
974 then
975         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
976         ac_cv_ps_command="$PATH_TO_PS -Al"
977         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
978         ac_cv_ps_cols=8
979         AC_MSG_RESULT([$ac_cv_ps_command])
981 else
982         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
985 if test -n "$ac_cv_ps_varlist" ; then
986         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
987                 [Variable list for sscanf of 'ps' output])
988         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
989                 [Verbatim command to execute for ps in check_procs])
990         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
991                 [Format string for scanning ps output in check_procs])
992         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
993                 [Number of columns in ps command])
994         EXTRAS="$EXTRAS check_procs check_nagios\$(EXEEXT)"
995         if echo "$ac_cv_ps_varlist" | grep "procetime" >/dev/null; then
996                 AC_DEFINE(PS_USES_PROCETIME,"yes",
997                           [Whether the ps utility uses the "procetime" field])
998         fi
1001 AC_PATH_PROG(PATH_TO_PING,ping)
1002 AC_PATH_PROG(PATH_TO_PING6,ping6)
1004 AC_ARG_WITH(ping_command,
1005         ACX_HELP_STRING([--with-ping-command=SYNTAX],
1006                 [sets syntax for ICMP ping]),
1007         with_ping_command=$withval,)
1009 AC_MSG_CHECKING(for ICMP ping syntax)
1010 ac_cv_ping_packets_first=no
1011 ac_cv_ping_has_timeout=no
1012 if test -n "$with_ping_command"
1013 then
1014         AC_MSG_RESULT([(command-line) $with_ping_command])
1015         if echo "$with_ping_command" | grep '%d.*%d.*%s' >/dev/null
1016         then
1017                 ac_cv_ping_packets_first=yes
1018                 ac_cv_ping_has_timeout=yes
1019         elif echo "$with_ping_command" | grep '%d.*%s.*%d' >/dev/null || \
1020              echo "$with_ping_command" | grep '%s.*%d.*%d' >/dev/null
1021         then
1022                 ac_cv_ping_has_timeout=yes
1023         elif echo "$with_ping_command" | grep '%d.*%s' >/dev/null
1024         then
1025                 ac_cv_ping_packets_first=yes
1026         fi
1028 elif [[ "z$ac_cv_uname_o" = "zCygwin" ]]
1029 then
1030         with_ping_command="$PATH_TO_PING -n %d -w %d000 %s"
1031         ac_cv_ping_packets_first=yes
1032         ac_cv_ping_has_timeout=yes
1033         AC_MSG_RESULT([$with_ping_command])
1035 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1036         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
1037         egrep -i "^round-trip|^rtt" >/dev/null
1038 then
1039         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
1040         ac_cv_ping_packets_first=yes
1041         AC_MSG_RESULT([$with_ping_command])
1043 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
1044         egrep -i "^round-trip|^rtt" >/dev/null
1045 then
1046         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
1047         ac_cv_ping_packets_first=yes
1048         ac_cv_ping_has_timeout=yes
1049         AC_MSG_RESULT([$with_ping_command])
1051 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
1052         egrep -i "^round-trip|^rtt" >/dev/null
1053 then
1054         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
1055         ac_cv_ping_packets_first=yes
1056         AC_MSG_RESULT([$with_ping_command])
1058 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1059         egrep -i "^round-trip|^rtt" >/dev/null
1060 then
1061         with_ping_command="$PATH_TO_PING -n -c %d %s"
1062         ac_cv_ping_packets_first=yes
1063         AC_MSG_RESULT([$with_ping_command])
1065 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
1066         egrep -i "^round-trip|^rtt" >/dev/null
1067 then
1068         with_ping_command="$PATH_TO_PING -n %s -c %d"
1069         AC_MSG_RESULT([$with_ping_command])
1071 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
1072         egrep -i "^round-trip|^rtt" >/dev/null
1073 then
1074         with_ping_command="$PATH_TO_PING %s -n %d"
1075         AC_MSG_RESULT([$with_ping_command])
1077 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
1078         egrep -i "^round-trip|^rtt" >/dev/null
1079 then
1080         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
1081         AC_MSG_RESULT([$with_ping_command])
1083 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
1084         egrep -i "^round-trip|^rtt" >/dev/null
1085 then
1086         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
1087         AC_MSG_RESULT([$with_ping_command])
1089 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
1090         egrep -i "^round-trip|^rtt" >/dev/null
1091 then
1092         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
1093         ac_cv_ping_packets_first=yes
1094         AC_MSG_RESULT([$with_ping_command])
1096 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1097         egrep -i "^round-trip|^rtt" >/dev/null
1098 then
1099         with_ping_command="$PATH_TO_PING -n -c %d %s"
1100         ac_cv_ping_packets_first=yes
1101         AC_MSG_RESULT([$with_ping_command])
1103 else
1104         AC_MSG_WARN([unable to find usable ping syntax])
1107 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
1108         [path and args for ICMP ping command])
1110 if test "x$ac_cv_ping_packets_first" != "xno"
1111 then
1112         AC_DEFINE(PING_PACKETS_FIRST,1,
1113                 [Define if packet count must precede host])
1116 if test "x$ac_cv_ping_has_timeout" != "xno"
1117 then
1118         AC_DEFINE(PING_HAS_TIMEOUT,1,
1119                 [Define if ping has its own timeout option that should be set])
1122 AC_ARG_WITH(ping6_command,
1123         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
1124                 [sets syntax for ICMPv6 ping]),
1125         with_ping6_command=$withval,)
1127 if test x"$with_ipv6" != xno ; then
1128 AC_MSG_CHECKING(for ICMPv6 ping syntax)
1129 ac_cv_ping6_packets_first=no
1130 if test -n "$with_ping6_command"
1131 then
1132         AC_MSG_RESULT([(command-line) $with_ping6_command])
1133         if echo "$with_ping6_command" | grep '%d.*%d.*%s' >/dev/null
1134         then
1135                 ac_cv_ping6_packets_first=yes
1136         elif echo "$with_ping6_command" | grep '%d.*%s.*%d' >/dev/null || \
1137              echo "$with_ping6_command" | grep '%s.*%d.*%d' >/dev/null
1138         then
1139                 # Just keep same logic as ping (IPv4) if we ever need ac_cv_ping6_has_timeout
1140                 true
1141         elif echo "$with_ping6_command" | grep '%d.*%s' >/dev/null
1142         then
1143                 ac_cv_ping6_packets_first=yes
1144         fi
1145 elif [[ "z$ac_cv_uname_o" = "zCygwin" -a "x$PATH_TO_PING" != "x" ]]; then
1146         with_ping6_command="$PATH_TO_PING -6 -n %d -w %d000 %s"
1147         ac_cv_ping6_packets_first=yes
1148         ac_cv_ping_has_timeout=yes
1149         AC_MSG_RESULT([$with_ping6_command])
1150 elif test "x$PATH_TO_PING6" != "x"; then
1151         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1152                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1153                 egrep -i "^round-trip|^rtt" >/dev/null
1154         then
1155                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1156                 ac_cv_ping6_packets_first=yes
1157                 AC_MSG_RESULT([$with_ping6_command])
1159         elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
1160                 egrep -i "^round-trip|^rtt" >/dev/null
1161         then
1162                 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
1163                 ac_cv_ping6_packets_first=yes
1164                 ac_cv_ping_has_timeout=yes
1165                 AC_MSG_RESULT([$with_ping6_command])
1167         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1168                 egrep -i "^round-trip|^rtt" >/dev/null
1169         then
1170                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1171                 ac_cv_ping6_packets_first=yes
1172                 AC_MSG_RESULT([$with_ping6_command])
1174         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1175                 egrep -i "^round-trip|^rtt" >/dev/null
1176         then
1177                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1178                 ac_cv_ping6_packets_first=yes
1179                 AC_MSG_RESULT([$with_ping6_command])
1181         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1182                 egrep -i "^round-trip|^rtt" >/dev/null
1183         then
1184                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1185                 AC_MSG_RESULT([$with_ping6_command])
1187         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1188                 egrep -i "^round-trip|^rtt" >/dev/null
1189         then
1190                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1191                 AC_MSG_RESULT([$with_ping6_command])
1193         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1194                 egrep -i "^round-trip|^rtt" >/dev/null
1195         then
1196                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1197                 AC_MSG_RESULT([$with_ping6_command])
1199         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1200                 egrep -i "^round-trip|^rtt" >/dev/null
1201         then
1202                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1203                 AC_MSG_RESULT([$with_ping6_command])
1205         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1206                 egrep -i "^round-trip|^rtt" >/dev/null
1207         then
1208                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1209                 ac_cv_ping6_packets_first=yes
1210                 AC_MSG_RESULT([$with_ping_command])
1212         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1213                 egrep -i "^round-trip|^rtt" >/dev/null
1214         then
1215                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1216                 ac_cv_ping6_packets_first=yes
1217                 AC_MSG_RESULT([$with_ping6_command])
1219         fi
1221 elif test "x$PATH_TO_PING" != "x"; then
1222         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1223                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1224                 egrep -i "^round-trip|^rtt" >/dev/null
1225         then
1226                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1227                 ac_cv_ping6_packets_first=yes
1228                 AC_MSG_RESULT([$with_ping6_command])
1230         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1231                 egrep -i "^round-trip|^rtt" >/dev/null
1232         then
1233                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1234                 ac_cv_ping6_packets_first=yes
1235                 AC_MSG_RESULT([$with_ping6_command])
1237         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1238                 egrep -i "^round-trip|^rtt" >/dev/null
1239         then
1240                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1241                 ac_cv_ping6_packets_first=yes
1242                 AC_MSG_RESULT([$with_ping6_command])
1244         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1245                 egrep -i "^round-trip|^rtt" >/dev/null
1246         then
1247                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1248                 AC_MSG_RESULT([$with_ping6_command])
1250         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1251                 egrep -i "^round-trip|^rtt" >/dev/null
1252         then
1253                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1254                 AC_MSG_RESULT([$with_ping6_command])
1256         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1257                 egrep -i "^round-trip|^rtt" >/dev/null
1258         then
1259                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1260                 AC_MSG_RESULT([$with_ping6_command])
1262         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1263                 egrep -i "^round-trip|^rtt" >/dev/null
1264         then
1265                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1266                 AC_MSG_RESULT([$with_ping6_command])
1268         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1269                 egrep -i "^round-trip|^rtt" >/dev/null
1270         then
1271                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1272                 ac_cv_ping6_packets_first=yes
1273                 AC_MSG_RESULT([$with_ping_command])
1275         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1276                 egrep -i "^round-trip|^rtt" >/dev/null
1277         then
1278                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1279                 ac_cv_ping6_packets_first=yes
1280                 AC_MSG_RESULT([$with_ping6_command])
1282         fi
1286 if test "x$with_ping6_command" != "x"; then
1287         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1288                 [path and args for ICMPv6 ping command])
1289 else
1290         AC_MSG_RESULT([none])
1293 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1294         AC_DEFINE(PING6_PACKETS_FIRST,1,
1295                 [Define if packet count must precede host])
1300 AC_ARG_WITH(nslookup_command,
1301             ACX_HELP_STRING([--with-nslookup-command=PATH],
1302                             [sets path to nslookup executable]),
1303             ac_cv_nslookup_command=$withval)
1304 if test -n "$ac_cv_nslookup_command"; then
1305         AC_MSG_NOTICE([Using specific nslookup at $ac_cv_nslookup_command])
1306 else
1307         AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1308         if test -n "$PATH_TO_NSLOOKUP"
1309         then
1310                 AC_MSG_CHECKING(for nslookup syntax)
1311                 if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1312                 then
1313                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1314                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1316                 else
1317                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1318                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1320                 fi
1321         else
1322                 AC_MSG_WARN([nslookup command not found])
1323         fi
1326 if test -n "$ac_cv_nslookup_command"; then
1327         EXTRAS="$EXTRAS check_dns\$(EXEEXT)"
1328         AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
1331 AC_MSG_CHECKING([for number of online cpus])
1332 AC_TRY_COMPILE([#include <unistd.h>],
1333         [sysconf(_SC_NPROCESSORS_ONLN) > 0;],
1334         AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_ONLN,1,[Define if sysconf returns number of online cpus])
1335         AC_MSG_RESULT([sysconf(_SC_NPROCESSORS_ONLN)]),
1336         AC_MSG_RESULT([cannot calculate])
1337         )
1339 AC_MSG_CHECKING([for number of available cpus])
1340 AC_TRY_COMPILE([#include <unistd.h>],
1341         [sysconf(_SC_NPROCESSORS_CONF) > 0;],
1342         AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_CONF,1,[Define if sysconf returns number of available cpus])
1343         AC_MSG_RESULT([sysconf(_SC_NPROCESSORS_CONF)]),
1344         AC_MSG_RESULT([cannot calculate])
1345         )
1347 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1348 AC_ARG_WITH(uptime_command,
1349             ACX_HELP_STRING([--with-uptime-command=PATH],
1350                             [sets path to uptime]), PATH_TO_UPTIME=$withval)
1351 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1353 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1354 AC_ARG_WITH(rpcinfo_command,
1355             ACX_HELP_STRING([--with-rpcinfo-command=PATH],
1356                             [sets path to rpcinfo]), PATH_TO_RPCINFO=$withval)
1357 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1359 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1360 if test -x "$PATH_TO_LMSTAT"
1361 then
1362         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1363 else
1364         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1367 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1368 AC_ARG_WITH(smbclient_command,
1369             ACX_HELP_STRING([--with-smbclient-command=PATH],
1370                             [sets path to smbclient]),
1371             PATH_TO_SMBCLIENT=$withval)
1372 if test -n "$PATH_TO_SMBCLIENT"
1373 then
1374         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1375 else
1376         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1379 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1380 AC_ARG_WITH(snmpget_command,
1381             ACX_HELP_STRING([--with-snmpget-command=PATH],
1382                             [Path to snmpget command]),
1383             PATH_TO_SNMPGET=$withval)
1384 if test -n "$PATH_TO_SNMPGET"
1385 then
1386         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1387         EXTRAS="$EXTRAS check_hpjd check_snmp\$(EXEEXT)"
1388 else
1389         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1392 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1393 AC_ARG_WITH(snmpgetnext_command,
1394             ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
1395                             [Path to snmpgetnext command]),
1396             PATH_TO_SNMPGETNEXT=$withval)
1397 if test -n "$PATH_TO_SNMPGETNEXT"
1398 then
1399         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1402 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1403 then
1404         AC_MSG_CHECKING(for Net::SNMP perl module)
1405         AC_MSG_RESULT([found])
1406 else
1407         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1410 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1411 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1412 AC_ARG_WITH(qstat_command,
1413             ACX_HELP_STRING([--with-qstat-command=PATH],
1414                             [Path to qstat command]), PATH_TO_QSTAT=$withval)
1416 if test -x "$PATH_TO_QUAKESTAT"
1417 then
1418         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1419         EXTRAS="$EXTRAS check_game\$(EXEEXT)"
1421 elif test -n "$PATH_TO_QSTAT"
1422 then
1423         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1424         EXTRAS="$EXTRAS check_game\$(EXEEXT)"
1425 else
1426         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1429 if test $ac_cv_path_to_qstat
1430 then
1431         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1432                 [path to qstat/quakestat])
1435 AC_PATH_PROG(PATH_TO_FPING,fping)
1436 AC_PATH_PROG(PATH_TO_FPING6,fping6)
1438 AC_ARG_WITH(fping_command,
1439             ACX_HELP_STRING([--with-fping-command=PATH],
1440                             [Path to fping command]), PATH_TO_FPING=$withval)
1441 AC_ARG_WITH(fping6_command,
1442             ACX_HELP_STRING([--with-fping6-command=PATH],
1443                             [Path to fping6 command]), PATH_TO_FPING6=$withval)
1445 if test -n "$PATH_TO_FPING"
1446 then
1447         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1448         EXTRAS="$EXTRAS check_fping\$(EXEEXT)"
1449         if test x"$with_ipv6" != xno && test -n "$PATH_TO_FPING6"; then
1450                 AC_DEFINE_UNQUOTED(PATH_TO_FPING6,"$PATH_TO_FPING6",[path to fping6])
1451         fi
1452 else
1453         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1456 AC_PATH_PROG(PATH_TO_SSH,ssh)
1457 AC_ARG_WITH(ssh_command,
1458             ACX_HELP_STRING([--with-ssh-command=PATH],
1459                             [sets path for ssh]), PATH_TO_SSH=$withval)
1460 if test -n "$PATH_TO_SSH"
1461 then
1462         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1463         EXTRAS="$EXTRAS check_by_ssh\$(EXEEXT)"
1464 else
1465         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1469 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1470 AC_ARG_WITH(mailq_command,
1471             ACX_HELP_STRING([--with-mailq-command=PATH],
1472                             [sets path to mailq]), PATH_TO_MAILQ=$withval)
1473 if test -n "$PATH_TO_MAILQ"
1474 then
1475         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1476 else
1477         AC_MSG_WARN([Could not find mailq or eqivalent])
1480 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1481 if test -x "$PATH_TO_QMAIL_QSTAT"
1482 then
1483         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1484 else
1485         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1488 dnl SWAP info required is amount allocated/available and amount free
1489 dnl The plugin works through all the swap devices and adds up the total swap
1490 dnl available.
1491 AC_PATH_PROG(PATH_TO_SWAP,swap)
1492 if (test -n "$PATH_TO_SWAP")
1493 then
1494 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1495 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1496 then
1497         ac_cv_have_swap=yes
1498         ac_cv_swap_command="$PATH_TO_SWAP -l"
1499         if [$PATH_TO_SWAP -l 2>/dev/null | \
1500                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1501                 >/dev/null]
1502         then
1503                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1504                 ac_cv_swap_conv=2048
1505                 AC_MSG_RESULT([using IRIX format swap])
1507         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1508         then
1509                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1510                 ac_cv_swap_conv=2048
1511                 AC_MSG_RESULT([using Unixware format swap])
1512         else
1513                 dnl if we don't know what format swap's output is
1514                 dnl we might as well pretend we didn't see it
1515                 ac_cv_have_swap=""
1516                 ac_cv_swap_command=""
1517         fi
1519 dnl end if for PATH_TO_SWAP
1522 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1523 if (test -n "$PATH_TO_SWAPINFO")
1524 then
1525 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1526 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1527 then
1528         ac_cv_have_swap=yes
1529         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1531         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1532         then
1533                 ac_cv_swap_format=["%*s %f %*d %f"]
1534                 ac_cv_swap_conv=1024
1535                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1536         fi
1538 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1539 then
1540         ac_cv_have_swap=yes
1541         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM"
1542         ac_cv_swap_format=["%*s %f %*d %f"]
1543         ac_cv_swap_conv=1024
1544         AC_MSG_RESULT([using HP-UX format swapinfo])
1546 dnl end if for PATH_TO_SWAPINFO
1549 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1550 if (test -n "$PATH_TO_LSPS")
1551 then
1552 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1553 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1554 then
1555         ac_cv_have_swap=yes
1556         ac_cv_swap_command="$PATH_TO_LSPS -a"
1557         ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1558         ac_cv_swap_conv=1
1559         AC_MSG_RESULT([using AIX lsps])
1561 dnl end if for PATH_TO_SWAPINFO
1565 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1566 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1567 dnl in the various BSD's
1570 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1571 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1572 #ifdef HAVE_SYS_PARAM_H
1573 #include <sys/param.h>
1574 #endif
1576 AC_CHECK_DECLS([swapctl],,,[
1577                #include <unistd.h>
1578                #include <sys/types.h>
1579                #include <sys/param.h>
1580                #include <sys/stat.h>
1581                #include <sys/swap.h>
1582                ])
1583 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1584                #include <sys/types.h>
1585                #include <sys/param.h>
1586                #include <sys/stat.h>
1587                #include <sys/swap.h>
1588                ])
1589 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1590                  #include <unistd.h>
1591                  #include <sys/types.h>
1592                  #include <sys/param.h>
1593                  #include <sys/stat.h>
1594                  #include <sys/swap.h>
1595                  ])
1597 if test "$ac_cv_have_decl_swapctl" = "yes";
1598 then
1599         EXTRAS="$EXTRAS check_swap\$(EXEEXT)"
1600         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1601         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1602                 "$ac_cv_type_swapent_t" = "yes";
1603         then
1604                 AC_MSG_RESULT([yes])
1605                 ac_cv_check_swap_swapctl_svr4="1";
1606                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1607                           [Define if 2-argument SVR4 swapctl exists])
1608         else
1609                 AC_MSG_RESULT([no])
1610                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1611                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes";
1612                 then
1613                         AC_MSG_RESULT([yes])
1614                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1615                                   [Define if 3-argument BSD swapctl exists])
1616                 else
1617                         AC_MSG_RESULT([no])
1618                 fi
1619         fi
1620         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1621         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1622         then
1623                 dnl
1624                 dnl the SVR4 spec returns values in pages
1625                 dnl
1626                 AC_MSG_RESULT([page])
1627                 AC_CHECK_DECLS([sysconf])
1628                 AC_MSG_CHECKING([for system page size])
1629                 if test "$ac_cv_have_decl_sysconf" = "yes";
1630                 then
1631                         AC_MSG_RESULT([determined by sysconf(3)])
1632                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1633                 else
1634                         AC_MSG_WARN([don't know. guessing 4096k])
1635                         ac_cv_swap_conv=256
1636                 fi
1637         else
1638                 dnl
1639                 dnl the BSD spec returns values in blocks
1640                 dnl
1641                 AC_MSG_RESULT([blocks (assuming 512b)])
1642                 ac_cv_swap_conv=2048
1643         fi
1644         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1645                 [Conversion factor to MB])
1648 dnl end tests for the swapctl system calls
1652 if test "x$ac_cv_have_swap" != "x"
1653 then
1654         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1655         EXTRAS="$EXTRAS check_swap\$(EXEEXT)"
1657 if test "x$ac_cv_swap_command" != "x"
1658 then
1659         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1660                 [Path to swap/swapinfo binary, with any args])
1661         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1662                 [Format string for parsing swap output])
1663         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1664                 [Conversion factor to MB])
1667 AC_ARG_WITH(proc-meminfo,
1668             ACX_HELP_STRING([--with-proc-meminfo=PATH],
1669                             [path to /proc/meminfo or equivalent]),
1670                             ac_cv_proc_meminfo=$withval)
1671 dnl dunno why this does not work below - use hack (kbd)
1672 dnl fine on linux, broken on solaris
1673 dnl if /bin/test -e "/proc/meminfo"
1674 AC_MSG_CHECKING([for /proc/meminfo])
1675 if test -n "$ac_cv_proc_meminfo"; then
1676         AC_MSG_RESULT([(command line) $ac_cv_proc_meminfo])
1677 elif [cat /proc/meminfo > /dev/null 2>&1]; then
1678         AC_MSG_RESULT([found /proc/meminfo])
1679         ac_cv_proc_meminfo="/proc/meminfo"
1680 else
1681         AC_MSG_RESULT([no])
1684 if test -n "$ac_cv_proc_meminfo"; then
1685         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1686         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"$ac_cv_proc_meminfo",[path to /proc/meminfo if name changes])
1687         EXTRAS="$EXTRAS check_swap\$(EXEEXT)"
1690 AC_PATH_PROG(PATH_TO_DIG,dig)
1691 AC_ARG_WITH(dig_command,
1692             ACX_HELP_STRING([--with-dig-command=PATH],
1693                             [Path to dig command]), PATH_TO_DIG=$withval)
1694 if test -n "$PATH_TO_DIG"; then
1695         EXTRAS="$EXTRAS check_dig\$(EXEEXT)"
1696         AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1699 AC_PATH_PROG(PATH_TO_APTGET,apt-get)
1700 AC_ARG_WITH(apt-get_command,
1701             ACX_HELP_STRING([--with-apt-get-command=PATH],
1702                             [Path to apt-get command]),
1703                             with_apt_get_command=$withval,
1704                             with_apt_get_command=$PATH_TO_APTGET)
1705 AC_DEFINE_UNQUOTED(PATH_TO_APTGET,"$PATH_TO_APTGET",[Path to apt-get command, if present])
1706 if test -n "$PATH_TO_APTGET" ; then
1707         EXTRAS="$EXTRAS check_apt\$(EXEEXT)"
1711 if test -f $srcdir/plugins/check_nt.c ; then
1712   EXTRAS="$EXTRAS check_nt\$(EXEEXT)"
1716 dnl used in check_dhcp
1717 AC_CHECK_HEADERS(sys/sockio.h)
1719 case $host in
1720         *bsd*)
1721                 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1722         ;;
1723         *linux*)
1724                 AC_DEFINE(__linux__,1,[linux specific code in check_dhcp.c])
1725         ;;
1726         *sun* | *solaris*)
1727                 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1728         ;;
1729         *hpux*)
1730                 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1731         ;;
1732 esac
1734 AC_SUBST(EXTRAS)
1735 AC_SUBST(EXTRAS_ROOT)
1736 AC_SUBST(EXTRA_NETOBJS)
1737 AC_SUBST(DEPLIBS)
1739 AM_GNU_GETTEXT([external], [need-ngettext])
1740 AM_GNU_GETTEXT_VERSION(0.15)
1742 dnl Check for Redhat spopen problem
1743 dnl Wierd problem where ECHILD is returned from a wait call in error
1744 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1745 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1746 dnl We patch plugins/popen.c
1747 dnl Need to add smp because uname different on those
1748 dnl Can force patch to be applied with --enable-redhat-pthread-workaround
1749 AC_ARG_ENABLE(redhat-pthread-workaround,
1750         AC_HELP_STRING([--enable-redhat-pthread-workaround],
1751                 [force Redhat patch to be applied (default: test system)]),
1752         [ac_cv_enable_redhat_pthread_workaround=$enableval],
1753         [ac_cv_enable_redhat_pthread_workaround=test])
1754 if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1755         if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then
1756                 AC_MSG_NOTICE([See https://www.monitoring-plugins.org/doc/faq/configure-hangs.html if this next part takes a long time])
1757                 AC_MSG_CHECKING(for redhat spopen problem)
1758                 ( cd config_test && make && make test ) > /dev/null 2>&1
1759                 if test $? -eq 0 ; then
1760                         AC_MSG_RESULT(okay)
1761                 else
1762                         AC_MSG_RESULT(error)
1763                         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Workaround on redhat in spopen])
1764                 fi
1765         fi
1766 elif test "$ac_cv_enable_redhat_pthread_workaround" = "yes" ; then
1767         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Forced workaround on redhat in spopen])
1770 dnl Perl modules
1771 AC_ARG_ENABLE(perl-modules,
1772         AC_HELP_STRING([--enable-perl-modules],
1773                 [Enables installation of Monitoring::Plugin and its dependencies (default: no)]),
1774         [enable_perl_modules=$enableval],
1775         [enable_perl_modules=no])
1776 if test "$enable_perl_modules" = "yes" ; then
1777   AC_SUBST(PERLMODS_DIR,perlmods)
1780 # From Tap configure
1781 # Checks for libraries
1782 case "$host" in
1783         *-*-*freebsd4*)
1784                 LDFLAGS="$LDFLAGS -pthread"
1785                 HAVE_LIBPTHREAD=1
1786                 ;;
1787         *)
1788                 AC_CHECK_LIB(pthread, main)
1789                 ;;
1790 esac
1792 dnl External libraries - see ACKNOWLEDGEMENTS
1793 gl_INIT
1795 dnl Some helpful common compile errors checked here
1796 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
1797         AC_MSG_ERROR(No ar found for Solaris - is /usr/ccs/bin in PATH?)
1800 AC_OUTPUT(
1801   Makefile
1802   tap/Makefile
1803   lib/Makefile
1804   plugins/Makefile
1805   lib/tests/Makefile
1806   plugins-root/Makefile
1807   plugins-scripts/Makefile
1808   plugins-scripts/utils.pm
1809   plugins-scripts/utils.sh
1810   perlmods/Makefile
1811   test.pl
1812   pkg/solaris/pkginfo
1813   po/Makefile.in
1817 dnl the ones below that are commented out need to be cleaned up
1818 dnl in the configure code above to use with_foo instead of ac_cv_foo
1819 dnl if we want them to show up here.  it'd also make the code cleaner.
1820 dnl i'll get to that on another rainy day :) -sf
1821 ACX_FEATURE([with],[apt-get-command])
1822 dnl ACX_FEATURE([with],[dig-command])
1823 dnl ACX_FEATURE([with],[fping-command])
1824 dnl ACX_FEATURE([with],[mailq-command])
1825 dnl ACX_FEATURE([with],[nslookup-command])
1826 ACX_FEATURE([with],[ping6-command])
1827 ACX_FEATURE([with],[ping-command])
1828 dnl ACX_FEATURE([with],[qstat-command])
1829 dnl ACX_FEATURE([with],[rpcinfo-command])
1830 dnl ACX_FEATURE([with],[smbclient-command])
1831 dnl ACX_FEATURE([with],[snmpget-command])
1832 dnl ACX_FEATURE([with],[snmpgetnext-command])
1833 dnl ACX_FEATURE([with],[ssh-command])
1834 dnl ACX_FEATURE([with],[uptime-command])
1836 dnl ACX_FEATURE([with],[proc-meminfo])
1837 dnl ACX_FEATURE([with],[ps-command])
1838 dnl ACX_FEATURE([with],[ps-format])
1839 dnl ACX_FEATURE([with],[ps-cols])
1840 dnl ACX_FEATURE([with],[ps-varlist])
1842 ACX_FEATURE([with],[ipv6])
1843 ACX_FEATURE([with],[mysql])
1844 ACX_FEATURE([with],[openssl])
1845 ACX_FEATURE([with],[gnutls])
1846 ACX_FEATURE([enable],[extra-opts])
1847 ACX_FEATURE([with],[perl])
1848 ACX_FEATURE([enable],[perl-modules])
1849 ACX_FEATURE([with],[cgiurl])
1850 ACX_FEATURE([with],[trusted-path])
1851 ACX_FEATURE([enable],[libtap])