Code

whoops, missed this one, same as last commit
[nagiosplug.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_REVISION ($Revision$)
3 AC_PREREQ(2.58)
4 AC_INIT(nagios-plugins,1.4.2)
5 AC_CONFIG_SRCDIR(NPTest.pm)
6 AM_INIT_AUTOMAKE
7 AM_CONFIG_HEADER(config.h)
8 AC_CANONICAL_HOST
10 RELEASE=1
11 AC_SUBST(RELEASE)
13 AC_PREFIX_DEFAULT(/usr/local/nagios)
15 dnl Figure out how to invoke "install" and what install options to use.
16 AC_PROG_INSTALL
17 AC_SUBST(INSTALL)
19 dnl Must come very early on due to coreutils requirement
20 dnl Takes care of AC_GNU_SOURCE, AC_AIX and AC_MINIX
21 gl_USE_SYSTEM_EXTENSIONS
23 AC_PROG_CC
24 AC_PROG_CPP
25 AC_PROG_GCC_TRADITIONAL
26 AC_PROG_RANLIB
28 AC_PROG_MAKE_SET
29 AC_PROG_AWK
31 AC_FUNC_MALLOC
32 AC_FUNC_REALLOC
33 AC_FUNC_ERROR_AT_LINE
35 AC_CONFIG_LIBOBJ_DIR(lib)
36 AC_FUNC_GETLOADAVG([lib])
38 ifdef([AC_FUNC_STRTOD],[AC_FUNC_STRTOD],[AM_FUNC_STRTOD])
39 dnl AM_WITH_REGEX
41 PLUGIN_TEST=`echo $srcdir/plugins/t/*.t|sed -e 's,\.*/plugins/,,g'`
42 AC_SUBST(PLUGIN_TEST)dnl
44 SCRIPT_TEST=`echo $srcdir/plugins-scripts/t/*.t|sed -e 's,\.*/plugins-scripts/,,g'`
45 AC_SUBST(SCRIPT_TEST)dnl
47 WARRANTY="The nagios 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"
48 AC_SUBST(WARRANTY)
50 SUPPORT="Send email to nagios-users@lists.sourceforge.net if you have questions\nregarding use of this software. To submit patches or suggest improvements,\nsend email to nagiosplug-devel@lists.sourceforge.net.\nPlease include version information with all correspondence (when possible,\nuse output from the --version option of the plugin itself).\n"
51 AC_SUBST(SUPPORT)
53 dnl CGIURL has changed for Nagios with 1.0 beta
54 AC_ARG_WITH(cgiurl,
55         ACX_HELP_STRING([--with-cgiurl=DIR],
56                 [sets URL for cgi programs]),
57         with_cgiurl=$withval,
58         with_cgiurl=/nagios/cgi-bin)
59 CGIURL="$with_cgiurl"
60 AC_DEFINE_UNQUOTED(CGIURL,"$CGIURL",[URL of CGI programs])
62 AC_ARG_WITH(nagios_user,
63         ACX_HELP_STRING([--with-nagios-user=USER],
64                 [set user name to run nagios]),
65         with_nagios_user=$withval,
66         with_nagios_user=nagios)
67 AC_ARG_WITH(nagios_group,
68         ACX_HELP_STRING([--with-nagios-group=GROUP],
69                 [set group name to run nagios]),
70         with_nagios_group=$withval,
71         with_nagios_group=nagios)
72 AC_SUBST(with_nagios_user)
73 AC_SUBST(with_nagios_group)
74 INSTALL_OPTS="-o $with_nagios_user -g $with_nagios_group"
75 AC_SUBST(INSTALL_OPTS)
77 AC_ARG_WITH(trusted_path,
78         ACX_HELP_STRING([--with-trusted-path=PATH],
79                 [sets trusted path for executables called by scripts (default=/bin:/sbin:/usr/bin:/usr/sbin)]),
80         with_trusted_path=$withval,
81         with_trusted_path=/bin:/sbin:/usr/bin:/usr/sbin)
82 AC_SUBST(with_trusted_path)
84 EXTRAS=
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`
94 PKG_ARCH=`uname -p`
95 REV_DATESTAMP=`date '+%Y.%m.%d.%H.%M'`
96 REV_TIMESTAMP=`date '+%Y%m%d%H%M%S'`
98 AC_SUBST(PKG_ARCH)
99 AC_SUBST(REV_DATESTAMP)
100 AC_SUBST(REV_TIMESTAMP)
102 dnl Checks for programs.
103 AC_PATH_PROG(PYTHON,python)
104 AC_PATH_PROG(SH,sh)
105 AC_PATH_PROG(PERL,perl)
106 AC_PATH_PROG(LIBGNUTLS_CONFIG,libgnutls-config)
107 AC_PATH_PROG(HOSTNAME,hostname)
108 AC_PATH_PROG(BASENAME,basename)
110 dnl allow them to override the path of perl
111 AC_ARG_WITH(perl,
112         ACX_HELP_STRING([--with-perl=PATH],
113                         [sets path to perl executable]),
114                         with_perl=$withval,with_perl=$PERL)
115 AC_SUBST(PERL, $with_perl)
117 dnl openssl/gnutls
118 AC_ARG_WITH(openssl,
119             AC_HELP_STRING([--with-openssl=DIR], 
120                            [sets path to openssl installation]) AC_HELP_STRING([--without-openssl], [disable openssl]),)
122 AC_ARG_WITH(gnutls,
123             ACX_HELP_STRING([--with-gnutls=PATH],
124                             [path to gnutls installation root]) AC_HELP_STRING([--without-gnutls], [disable gnutls]),)
126 dnl you can only have one or the other
127 if test ! "$with_openssl" = "" && test ! "$with_openssl" = "no"; then
128         with_gnutls="no"
129 fi
130 if test ! "$with_gnutls" = "" && test ! "$with_gnutls" = "no"; then
131         with_openssl="no"
132 fi
134 dnl list of possible dirs to try to autodetect openssl
135 dnl if $dir/include exists, we consider it found
136 dnl the order should allow locally installed versions to override distros' ones
137 OPENSSL_DIRS="/usr /usr/local /usr/slocal /usr/local/openssl /usr/local/ssl \
138               /opt /opt/openssl"
140 dnl
141 dnl Check for miscellaneous stuff
142 dnl 
144 case $host_vender-$host_os in
145 sun*)
146         AC_DEFINE(__EXTENSIONS__,1,[Sun's netdb.h needs this for getaddrinfo])
147         ;;
148 osf*)
149         AC_DEFINE(_OSF_SOURCE,1,[OSF needs this for getaddrinfo])
150         ;;
151 esac
153 dnl
154 dnl Checks for libraries.
155 dnl
157 AC_CHECK_LIB(dce,main,SOCKETLIBS="$SOCKETLIBS -ldce")
158 AC_CHECK_LIB(nsl,main,SOCKETLIBS="$SOCKETLIBS -lnsl")
159 AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket")
160 AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv")
161 AC_SUBST(SOCKETLIBS)
163 dnl
164 dnl check for math-related functions needing -lm
165 AC_CHECK_LIB(m,floor,MATHLIBS="-lm")
166 AC_SUBST(MATHLIBS)
168 dnl Check for PostgreSQL libraries
169 _SAVEDLIBS="$LIBS"
170 _SAVEDCPPFLAGS="$CPPFLAGS"
171 AC_ARG_WITH(pgsql,
172         ACX_HELP_STRING([--with-pgsql=DIR],
173                 [sets path to pgsql installation]),
174         PGSQL=$withval,)
175 AC_CHECK_LIB(crypt,main)
176 if test "$ac_cv_lib_crypt_main" = "yes"; then
177   if test -n "$PGSQL"; then
178     LDFLAGS="$LDFLAGS -L$PGSQL/lib"
179     CPPFLAGS="$CPPFLAGS -I$PGSQL/include"
180   fi
181   AC_CHECK_LIB(pq,PQsetdbLogin,,,-lcrypt)
182   if test "$ac_cv_lib_pq_PQsetdbLogin" = "yes"; then
183     AC_CHECK_HEADERS(pgsql/libpq-fe.h)
184     AC_CHECK_HEADERS(postgresql/libpq-fe.h)
185     AC_CHECK_HEADERS(libpq-fe.h)
186     if [[ -n "$PGSQL" -a "$ac_cv_header_libpq_fe_h" = "yes" ]]; then
187       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
188       PGINCLUDE="-I$PGSQL/include"
189     elif test  "$ac_cv_header_pgsql_libpq_fe_h" = "yes"; then
190       PGLIBS="-lpq -lcrypt"
191       PGINCLUDE="-I/usr/include/pgsql"
192     elif test  "$ac_cv_header_postgresql_libpq_fe_h" = "yes"; then
193       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
194       PGINCLUDE="-I/usr/include/postgresql"
195     elif test  "$ac_cv_header_libpq_fe_h" = "yes"; then
196       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
197       PGINCLUDE="-I$PGSQL/include"
198     fi
199     if test -z "$PGINCLUDE"; then
200       AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
201       AC_MSG_WARN([install PostgreSQL headers to compile this plugin (see REQUIREMENTS).])
202     else
203       AC_SUBST(PGLIBS)
204       AC_SUBST(PGINCLUDE)
205       EXTRAS="$EXTRAS check_pgsql"
206     fi
207   else
208     AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
209     AC_MSG_WARN([LIBS="$LIBS" CPPFLAGS="$CPPFLAGS"])
210     AC_MSG_WARN([install PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
211   fi
212 else
213   AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
214   AC_MSG_WARN([install lib crypt and PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
215 fi
216 LIBS="$_SAVEDLIBS"
217 CPPFLAGS="$_SAVEDCPPFLAGS"
219 dnl Check for radius libraries
220 _SAVEDLIBS="$LIBS"
221 AC_CHECK_LIB(radiusclient,rc_read_config)
222 if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
223   EXTRAS="$EXTRAS check_radius"
224         RADIUSLIBS="-lradiusclient"
225   AC_SUBST(RADIUSLIBS)
226 else
227   AC_MSG_WARN([Skipping radius plugin])
228   AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
229 fi
230 LIBS="$_SAVEDLIBS"
232 dnl Check for LDAP libraries
233 _SAVEDLIBS="$LIBS"
234 AC_CHECK_LIB(ldap,main,,,-llber)
235 if test "$ac_cv_lib_ldap_main" = "yes"; then
236   LDAPLIBS="-lldap -llber"\
237   LDAPINCLUDE="-I/usr/include/ldap"
238   AC_SUBST(LDAPLIBS)
239   AC_SUBST(LDAPINCLUDE)
240   AC_CHECK_FUNCS(ldap_set_option)
241   EXTRAS="$EXTRAS check_ldap"
242         AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
243 else
244   AC_MSG_WARN([Skipping LDAP plugin])
245   AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
246 fi
247 LIBS="$_SAVEDLIBS"
250 dnl Check for mysql libraries
251 _SAVEDLIBS="$LIBS"
252 _SAVEDCPPFLAGS="$CPPFLAGS"
253 AC_ARG_WITH(mysql,
254         ACX_HELP_STRING([--with-mysql=DIR],
255                 [sets path to mysql installation (assumes lib/mysql and include subdirs]),
256         MYSQL=$withval,)
257 if test -n "$MYSQL"; then
258   MYSQLLIBDIR=$MYSQL/lib/mysql
259   CPPFLAGS="-I$MYSQL/include"
260   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L$MYSQLLIBDIR ",,-L$MYSQLLIBDIR -lz)
261   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
262 elif test -f /usr/lib/libmysqlclient.so; then
263   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
264   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
265 elif test -f /usr/lib/libmysqlclient.a; then
266   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
267   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
268 elif test -f /usr/lib/mysql/libmysqlclient.so; then
269   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
270   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
271 elif test -f /usr/lib/mysql/libmysqlclient.a; then
272   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
273   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
274 fi
275 if test "$ac_cv_lib_mysqlclient_mysql_init" = "yes" -o "$ac_cv_lib_mysqlclient_mysql_close" = "yes"; then
276   AC_CHECK_HEADERS(mysql/mysql.h mysql/errmsg.h, MYSQLINCLUDE="-I$MYSQL/include" )
277   if test "$ac_cv_header_mysql_mysql_h" = "yes" -a "$ac_cv_header_mysql_errmsg_h" = "yes"; then
278     EXTRAS="$EXTRAS check_mysql"
279     AC_SUBST(MYSQLINCLUDE)
280     AC_SUBST(MYSQLLIBS)
281     AC_SUBST(check_mysql_LDFLAGS)
282   else
283     AC_MSG_WARN([Skipping mysql plugin])
284     AC_MSG_WARN([install mysql client headers to compile this plugin (see REQUIREMENTS).])
285   fi
286 else
287   AC_MSG_WARN([Skipping mysql plugin])
288   AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
289 fi
290 CPPFLAGS="$_SAVEDCPPFLAGS $MYSQLINCLUDE"
291 LIBS="$_SAVEDLIBS"
293 AC_CHECK_HEADERS(unistd.h)
295 dnl Check for AF_INET6 support - unistd.h required for Darwin
296 AC_CACHE_CHECK([for IPv6 support], with_ipv6, [
297         AC_TRY_COMPILE([#ifdef HAVE_UNISTD_H
298                         #include <unistd.h>
299                         #endif
300                         #include <netinet/in.h>
301                         #include <sys/socket.h>],
302                         [struct sockaddr_in6 sin6;
303                         void *p;
305                         sin6.sin6_family = AF_INET6;
306                         sin6.sin6_port = 587;
307                         p = &sin6.sin6_addr;],
308                         [with_ipv6=yes], 
309                         [with_ipv6=no])
310         ])
312 if test x"$with_ipv6" != xno ; then
313         AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
314 fi
316 dnl #########################################################################
317 dnl Check if Posix getaddrinfo() is available.  It is also possible to use
318 dnl the version from the lwres library distributed with BIND.
319 dnl #########################################################################
320 AC_ARG_ENABLE([emulate-getaddrinfo],
321               ACX_HELP_STRING([--enable-emulate-getaddrinfo],
322                              [enable getaddrinfo emulation (default=no)]),
323               ,
324               enable_emulate_getaddrinfo=no)
326 AC_ARG_WITH(lwres,
327             ACX_HELP_STRING([--with-lwres=DIR],
328                            [use lwres library for getaddrinfo (default=no)]),
329             ,
330             with_lwres=no)
332 dnl ## enable force to test getaddrinfo.c
333 if test x$enable_emulate_getaddrinfo = xforce ; then
334         enable_emulate_getaddrinfo=yes
335         have_getaddrinfo=no
336 else
338 have_getaddrinfo=no
339 if test x$with_lwres != xno ; then
340         if test "$with_lwres" != yes ; then
341                    CPPFLAGS="-I${with_lwres}/include $CPPFLAGS"
342                    LDFLAGS="-L${with_lwres}/lib $LDFLAGS"
343         fi
344         AC_CHECK_HEADERS(lwres/netdb.h, ,
345                         [AC_MSG_ERROR([cannot find <lwres/netdb.h>])])
346         AC_CHECK_LIB(lwres, lwres_getaddrinfo, ,
347                      [AC_MSG_ERROR([cannot find the lwres library])],
348                      -lnsl -lpthread)
349         have_getaddrinfo=yes
350 fi
352 if test x$have_getaddrinfo != xyes ; then
353         AC_SEARCH_LIBS(getaddrinfo, socket resolv bind nsl c_r cr, have_getaddrinfo=yes)
354 fi
356 dnl # Special nonsense for systems that actually have getaddrinfo but
357 dnl # redefine the name to something else, e.g. OSF
358 if test x$have_getaddrinfo != xyes ; then
359         AC_MSG_CHECKING(if getaddrinfo is redefined in netdb.h)
360         AC_TRY_LINK([
361 #               include <netdb.h>
362         ], [
363                 struct addrinfo hints, *res;
364                 int err;
366                 err = getaddrinfo ("host", "service", &hints, &res);
367         ], [
368                 have_getaddrinfo=yes
369                 AC_MSG_RESULT(yes)
370         ], [AC_MSG_RESULT(no)])
371 fi
373 fi
375 if test x$have_getaddrinfo != xno ; then
376         if test x$enable_emulate_getaddrinfo != xno ; then
377                 AC_MSG_ERROR([getaddrinfo found but emulate-getaddrinfo was enabled])
378         fi
379         AC_DEFINE(HAVE_GETADDRINFO, 1,
380                   [Does system provide RFC 2553/Posix getaddrinfo?])
381 else
382         if test x$enable_emulate_getaddrinfo != xyes ; then
383 dnl                AC_MSG_ERROR([getaddrinfo not found: try --with-lwres or --enable-emulate-getaddrinfo])
384                enable_emulate_getaddrinfo=yes
385                AC_MSG_WARN([enabling getaddrinfo emulation])
386         fi
387         EXTRA_NETOBJS="$EXTRA_NETOBJS getaddrinfo.o"
388 fi
390 if test x"$enable_emulate_getaddrinfo" != xno ; then
391     have_resolver=no
393   dnl  Try for getipnodebyname
394     AC_SEARCH_LIBS(getipnodebyname, resolv bind nsl c_r cr, have_resolver=yes)
395     if test x"$have_resolver" != xno ; then
396          AC_DEFINE(HAVE_GETIPNODEBYNAME, 1,
397                    [Set when getipnodebyname is available])
398     fi
400   dnl  Try for gethostbyname_r
401     if test x"$have_resolver" = xno ; then
402         AC_SEARCH_LIBS(gethostbyname_r, resolv bind nsl c_r cr,
403                        [have_resolver=yes
404                         ACX_WHICH_GETHOSTBYNAME_R])
405     fi
407   dnl  Try for gethostbyname
408     if test x"$have_resolver" = xno ; then
409         if test x"$enable_pthreads" != xno ; then
410             AC_MSG_WARN([using threads but cannot find gethostbyname_r or getipnodebyname])
411         fi
412         AC_SEARCH_LIBS(gethostbyname, resolv bind nsl, ,
413                        [AC_MSG_ERROR([cannot find gethostbyname])])
414     fi
415     EXTRA_NETOBJS="$EXTRA_NETOBJS gethostbyname.o"
417 fi
419 dnl Checks for Kerberos. Must come before openssl checks for Redhat EL 3
420 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
421 if test "$FOUNDINCLUDE" = "no"; then
422   _SAVEDCPPFLAGS="$CPPFLAGS"
423   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
424   unset ac_cv_header_krb5_h
425   AC_CHECK_HEADERS(krb5.h,
426                    KRB5INCLUDE="-I/usr/kerberos/include"
427                    FOUNDINCLUDE=yes,
428                    FOUNDINCLUDE=no)
429 fi
430 AC_SUBST(KRBINCLUDE)
431 if test "$FOUNDINCLUDE" = "no"; then
432   CPPFLAGS="$_SAVEDCPPFLAGS"
433 fi
436 dnl openssl detection/configuration
437 if ! test "$with_openssl" = "no"; then
438         dnl Check for OpenSSL location if it wasn't already specified
439         if ! test -d "$with_openssl"; then
440                 for d in $OPENSSL_DIRS; do
441                         if test -x ${d}/bin/openssl || test -x ${d}/sbin/openssl ; then
442                                 with_openssl=$d
443                         fi
444                 done
445         fi
447         _SAVEDCPPFLAGS="$CPPFLAGS"
448         _SAVEDLDFLAGS="$LDFLAGS"
449         dnl Check for OpenSSL header files
450         unset FOUNDINCLUDE
451         CPPFLAGS="$CPPFLAGS -I$OPENSSL/include"
452         LDFLAGS="$LDFLAGS -R$OPENSSL/lib"
454         dnl check for openssl in $dir/include/openssl
455         AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
456                          SSLINCLUDE="-I$OPENSSL/include"
457                          FOUNDINCLUDE=yes,
458                          FOUNDINCLUDE=no)
459         dnl else check to see if $dir/include has it
460         if test "$FOUNDINCLUDE" = "no"; then
461                 AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
462                                  SSLINCLUDE="-I$OPENSSL/include"
463                                  FOUNDINCLUDE=yes,
464                                  FOUNDINCLUDE=no)
465         fi
466         AC_SUBST(SSLINCLUDE)
467         dnl if we didn't find it, reset CPPFLAGS
468         if test "$FOUNDINCLUDE" = "no"; then
469                 CPPFLAGS="$_SAVEDCPPFLAGS"
470                 LDFLAGS="$_SAVEDLDFLAGS"
471         fi
473         dnl Check for crypto lib
474         _SAVEDLIBS="$LIBS"
475         LIBS="-L${with_openssl}/lib"
476         AC_CHECK_LIB(crypto,CRYPTO_lock)
477         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
478                 dnl Check for SSL lib
479                 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
480         fi
481         LIBS="$_SAVEDLIBS"
483         dnl test headers and libs to decide whether check_http should use SSL
484         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
485                 if test "$ac_cv_lib_ssl_main" = "yes"; then
486                         if test "$FOUNDINCLUDE" = "yes"; then
487                                 FOUNDOPENSSL="yes"
488                         fi
489                 fi
490         fi
491 fi
494 dnl check for gnutls if openssl isn't found (or is disabled)
495 if test ! "$FOUNDOPENSSL" = "yes" && test ! "$with_gnutls" = "no"; then
496         if test ! "$with_gnutls" = ""; then
497                 CPPFLAGS="$CPPFLAGS -I${with_gnutls}/include"
498         elif test ! "$LIBGNUTLS_CONFIG" = ""; then
499                 CPPFLAGS="$CPPFLAGS -I`$LIBGNUTLS_CONFIG --prefix`"
500         fi
501         AC_CHECK_HEADERS([gnutls/openssl.h],FOUNDGNUTLS="yes",)
502         if test "$FOUNDGNUTLS" = "yes"; then
503                 AC_CHECK_LIB(gnutls-openssl,main,SSLLIBS="-lgnutls-openssl")
504         fi
505 fi
506 dnl end check for gnutls
508 if test "$FOUNDOPENSSL" = "yes" || test "$FOUNDGNUTLS" = "yes"; then
509         check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
510         AC_SUBST(check_tcp_ssl)
511         AC_SUBST(SSLLIBS)
512         AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
513         if test "$FOUNDOPENSSL" = "yes"; then
514                 AC_DEFINE(USE_OPENSSL,1,[Define if using OpenSSL libraries])
515                 with_openssl="yes"
516                 with_gnutls="no"
517         else
518                 AC_DEFINE(USE_GNUTLS,1,[Define if using gnutls libraries])
519                 with_gnutls="yes"
520                 with_openssl="no"
521         fi
522 else
523         dnl else deliberately disabled or no ssl support available
524         AC_MSG_WARN([OpenSSL or GnuTLS libs could not be found or were disabled])
525         with_openssl="no"
526         with_gnutls="no"
527 fi
529 dnl
530 dnl Checks for header files.
531 dnl
533 AC_HEADER_STDC
534 AC_HEADER_TIME
535 AC_HEADER_SYS_WAIT
536 AC_CHECK_HEADERS(signal.h strings.h string.h syslog.h uio.h errno.h regex.h sys/types.h sys/time.h sys/socket.h sys/loadavg.h)
537 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h stdlib.h)
539 dnl Checks for typedefs, structures, and compiler characteristics.
540 AC_C_CONST
541 AC_STRUCT_TM
542 AC_TYPE_PID_T
543 AC_TYPE_SIZE_T
544 AC_TYPE_SIGNAL
546 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
547 AC_TRY_LINK([#include <stdarg.h>
548 va_list ap1,ap2;], [va_copy(ap1,ap2);],
549 ac_cv_HAVE_VA_COPY=yes,
550 ac_cv_HAVE_VA_COPY=no)])
551 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
552     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
553 else    
554     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
555     AC_TRY_LINK([#include <stdarg.h>
556     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
557     ac_cv_HAVE___VA_COPY=yes,
558     ac_cv_HAVE___VA_COPY=no)])
559     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
560         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
561     fi
562 fi
564 AC_CHECK_FUNCS(vsnprintf snprintf asprintf vasprintf)
565 AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[
566 AC_TRY_RUN([
567 #include <sys/types.h>
568 #include <stdarg.h>
569 void foo(const char *format, ...) { 
570        va_list ap;
571        int len;
572        char buf[5];
574        va_start(ap, format);
575        len = vsnprintf(buf, 0, format, ap);
576        va_end(ap);
577        if (len != 5) exit(1);
579        va_start(ap, format);
580        len = vsnprintf(0, 0, format, ap);
581        va_end(ap);
582        if (len != 5) exit(1);
584        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
586        exit(0);
588 main() { foo("hello"); }
589 ],
590 ac_cv_HAVE_C99_VSNPRINTF=yes,ac_cv_HAVE_C99_VSNPRINTF=no,ac_cv_HAVE_C99_VSNPRINTF=cross)])
591 if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
592     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Define if system has C99 compatible vsnprintf])
593 fi
595 AC_TRY_COMPILE([#include <sys/time.h>],
596                [struct timeval *tv;
597                 struct timezone *tz;],
598                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
599                AC_TRY_COMPILE([#include <sys/time.h>],
600                               [struct timeval *tv;
601                                struct timezone *tz;
602                                gettimeofday(tv, tz);],
603                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
604                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
606 dnl Checks for library functions.
607 AC_CHECK_FUNCS(memmove select socket strdup strstr strtod strtol strtoul floor)
609 AC_MSG_CHECKING(return type of socket size)
610 AC_TRY_COMPILE([#include <stdlib.h>
611                 #include <sys/types.h>
612                 #include <sys/socket.h>],
613                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
614                ac_cv_socket_size_type=["size_t"]
615                 AC_MSG_RESULT(size_t),
616                ac_cv_socket_size_type=["int"]
617                 AC_MSG_RESULT(int))
619 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
620         [Define type of socket size])
622 if test -f "/proc/loadavg"
623 then
624   AC_DEFINE(HAVE_PROC_LOADAVG,1,[Define if /proc/loadavg or similar exists])
625   AC_DEFINE_UNQUOTED(PROC_LOADAVG,"/proc/loadavg",[Location of /proc/loadavg])
626 fi
628 dnl #### Process table test
630 AC_PATH_PROG(PATH_TO_PS,ps)
632 AC_MSG_CHECKING(for ps syntax)
634 dnl Now using the pst3/kmem hack for solaris systems to avoid truncation
635 AM_CONDITIONAL(WANT_PST3, false)
636 if test "$ac_cv_uname_s" = "SunOS"; then
637         #
638         # this is a very, very ugly hack, to hardcode the location for plugins
639         #
640         if test "$libexecdir" = '${exec_prefix}/libexec'; then
641                 if test "$exec_prefix" = "NONE"; then
642                         if test "$prefix" = "NONE"; then
643                                 pst3="$ac_default_prefix/libexec/pst3"
644                         else
645                                 pst3="$prefix/libexec/pst3"
646                         fi
647                 else
648                         pst3="$exec_prefix/libexec/pst3"
649                 fi
650         else
651                 pst3="$libexecdir/pst3"
652         fi
653         ac_cv_ps_command="$pst3"
654         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
655         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
656         ac_cv_ps_cols=8
657         AC_MSG_RESULT([using nagios-plugins internal ps for solaris])
658         AM_CONDITIONAL(WANT_PST3, true)
660 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
661 dnl so test for this first...
662 elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
663         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
664 then
665         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
666         ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
667         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
668         ac_cv_ps_cols=9
669         AC_MSG_RESULT([$ac_cv_ps_command])
671 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
672 dnl Should also work for FreeBSD 5.2.1 and 5.3
673 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
674 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
675         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
676 then
677         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
678         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
679         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
680         ac_cv_ps_cols=9
681         AC_MSG_RESULT([$ac_cv_ps_command])
683 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4. 
684 dnl Limitation: Only first 16 chars returned for ucomm field
685 dnl Must come before ps -weo
686 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
687         egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
688 then
689         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
690         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
691         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
692         ac_cv_ps_cols=9
693         AC_MSG_RESULT([$ac_cv_ps_command])
695 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
696 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
697         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
698 then
699         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
700         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
701         ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
702         ac_cv_ps_cols=10
703         AC_MSG_RESULT([$ac_cv_ps_command])
705 dnl FreeBSD
706 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
707         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
708 then
709         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
710         ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
711         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
712         ac_cv_ps_cols=9
713         AC_MSG_RESULT([$ac_cv_ps_command])
715 dnl BSD-like mode in RH 6.1
716 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
717         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
718 then
719         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
720         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
721         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
722         ac_cv_ps_cols=9
723         AC_MSG_RESULT([$ac_cv_ps_command])
725 dnl SunOS 4.1.3:
726 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
727 dnl Need the head -1 otherwise test will work because arguments are found
728 elif ps -laxnwww 2>/dev/null | head -1 | \
729         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
730 then
731         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
732         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
733         ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
734         ac_cv_ps_cols=9
735         AC_MSG_RESULT([$ac_cv_ps_command])
737 dnl Debian Linux / procps v1.2.9:
738 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
739 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
740 dnl
741 elif ps laxnwww 2>/dev/null | \
742         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
743 then
744         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
745         ac_cv_ps_command="$PATH_TO_PS laxnwww"
746         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
747         ac_cv_ps_cols=9
748         AC_MSG_RESULT([$ac_cv_ps_command])
750 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
751 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
752         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
753 then
754         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
755         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
756         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
757         ac_cv_ps_cols=9
758         AC_MSG_RESULT([$ac_cv_ps_command])
760 dnl Tru64 - needs %*[ +<>] in PS_FORMAT. 
761 dnl Has /usr/bin/ps and /sbin/ps - force sbin version
762 dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead 
763 dnl of 1500). Will need big changes to check_procs to support
764 elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
765         egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
766 then
767         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
768         ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
769         ac_cv_ps_format=["%s%*[ +<>] %d %d %d %f %s %s %n"]
770         ac_cv_ps_cols=8
771         AC_MSG_RESULT([$ac_cv_ps_command])
773 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
774         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
775 then
776         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
777         ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
778         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
779         ac_cv_ps_cols=9
780         AC_MSG_RESULT([$ac_cv_ps_command])
782 dnl AIX 4.3.3 and 5.1 do not have an rss field
783 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
784         egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
785 then
786         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
787         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
788         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
789         ac_cv_ps_cols=8
790         AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
792 dnl Solaris 2.6
793 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
794         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
795 then
796         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
797         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
798         # There must be no space between the %s and %n due to a wierd problem in sscanf where
799         # it will return %n as longer than the line length
800         ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
801         ac_cv_ps_cols=9
802         AC_MSG_RESULT([$ac_cv_ps_command])
804 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
805         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
806 then
807         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
808         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
809         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
810         ac_cv_ps_cols=9
811         AC_MSG_RESULT([$ac_cv_ps_command])
813 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
814         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
815 then
816         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
817         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
818         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
819         ac_cv_ps_cols=9
820         AC_MSG_RESULT([$ac_cv_ps_command])
822 dnl wonder who takes state instead of stat
823 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
824         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
825 then
826         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
827         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
828         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
829         ac_cv_ps_cols=8
830         AC_MSG_RESULT([$ac_cv_ps_command])
832 dnl IRIX 53
833 elif ps -el 2>/dev/null | \
834         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
835 then
836         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
837         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
838         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
839         ac_cv_ps_cols=8
840         AC_MSG_RESULT([$ac_cv_ps_command])
842 dnl IRIX 63
843 elif ps -el 2>/dev/null | \
844         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
845 then
846         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
847         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
848         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
849         ac_cv_ps_cols=6
850         AC_MSG_RESULT([$ac_cv_ps_command])
852 dnl AIX 4.1:
853 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
854 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
855 elif ps -el 2>/dev/null | \
856         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
857 then
858         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
859         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
860         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
861         ac_cv_ps_cols=6
862         AC_MSG_RESULT([$ac_cv_ps_command])
864 dnl AIX?
865 elif ps glaxen 2>/dev/null | \
866         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
867 then
868         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
869         ac_cv_ps_command="$PATH_TO_PS glaxen"
870         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
871         ac_cv_ps_cols=8
872         AC_MSG_RESULT([$ac_cv_ps_command])
874 dnl MacOSX / Darwin
875 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
876 dnl Some truncation will happen in UCOMM column
877 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
878 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
879 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
880         egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
881 then
882         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
883         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
884         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
885         ac_cv_ps_cols=8
886         AC_MSG_RESULT([$ac_cv_ps_command])
888 dnl UnixWare 
889 elif ps -Al 2>/dev/null | \
890         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
891 then
892         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
893         ac_cv_ps_command="$PATH_TO_PS -Al"
894         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
895         ac_cv_ps_cols=8
896         AC_MSG_RESULT([$ac_cv_ps_command])
898 else
899         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
900 fi
902 if test -n "$ac_cv_ps_varlist" ; then
903         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
904                 [Variable list for sscanf of 'ps' output])
905         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
906                 [Verbatim command to execute for ps in check_procs])
907         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
908                 [Format string for scanning ps output in check_procs])
909         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
910                 [Number of columns in ps command])
911         EXTRAS="$EXTRAS check_procs check_nagios"
912 fi
914 AC_PATH_PROG(PATH_TO_PING,ping)
915 AC_PATH_PROG(PATH_TO_PING6,ping6)
917 AC_ARG_WITH(ping_command,
918         ACX_HELP_STRING([--with-ping-command=SYNTAX],
919                 [sets syntax for ICMP ping]),
920         with_ping_command=$withval,)
922 AC_MSG_CHECKING(for ICMP ping syntax)
923 ac_cv_ping_packets_first=no
924 ac_cv_ping_has_timeout=no
925 if test -n "$with_ping_command"
926 then
927         AC_MSG_RESULT([(command-line) $with_ping_command])
928         if test -n "$ac_cv_ping_packets_first"
929         then
930                 ac_cv_ping_packets_first=yes
931         fi
933 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
934         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
935         egrep -i "^round-trip|^rtt" >/dev/null
936 then
937         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
938         ac_cv_ping_packets_first=yes
939         AC_MSG_RESULT([$with_ping_command])
941 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
942         egrep -i "^round-trip|^rtt" >/dev/null
943 then
944         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
945         ac_cv_ping_packets_first=yes
946   ac_cv_ping_has_timeout=yes
947         AC_MSG_RESULT([$with_ping_command])
949 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
950         egrep -i "^round-trip|^rtt" >/dev/null
951 then
952         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
953         ac_cv_ping_packets_first=yes
954         AC_MSG_RESULT([$with_ping_command])
956 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
957         egrep -i "^round-trip|^rtt" >/dev/null
958 then
959         with_ping_command="$PATH_TO_PING -n -c %d %s"
960         ac_cv_ping_packets_first=yes
961         AC_MSG_RESULT([$with_ping_command])
963 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
964         egrep -i "^round-trip|^rtt" >/dev/null
965 then
966         with_ping_command="$PATH_TO_PING -n %s -c %d"
967         AC_MSG_RESULT([$with_ping_command])
969 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
970         egrep -i "^round-trip|^rtt" >/dev/null
971 then
972         with_ping_command="$PATH_TO_PING %s -n %d"
973         AC_MSG_RESULT([$with_ping_command])
975 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
976         egrep -i "^round-trip|^rtt" >/dev/null
977 then
978         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
979         AC_MSG_RESULT([$with_ping_command])
981 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
982         egrep -i "^round-trip|^rtt" >/dev/null
983 then
984         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
985         AC_MSG_RESULT([$with_ping_command])
987 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
988         egrep -i "^round-trip|^rtt" >/dev/null
989 then
990         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
991         ac_cv_ping_packets_first=yes
992         AC_MSG_RESULT([$with_ping_command])
994 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
995         egrep -i "^round-trip|^rtt" >/dev/null
996 then
997         with_ping_command="$PATH_TO_PING -n -c %d %s"
998         ac_cv_ping_packets_first=yes
999         AC_MSG_RESULT([$with_ping_command])
1001 else
1002         AC_MSG_WARN([unable to find usable ping syntax])
1003 fi
1005 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
1006         [path and args for ICMP ping command])
1008 if test "x$ac_cv_ping_packets_first" != "xno"
1009 then
1010         AC_DEFINE(PING_PACKETS_FIRST,1,
1011                 [Define if packet count must precede host])
1012 fi
1014 if test "x$ac_cv_ping_has_timeout" != "xno"
1015 then
1016         AC_DEFINE(PING_HAS_TIMEOUT,1,
1017                 [Define if ping has its own timeout option that should be set])
1018 fi
1020 AC_ARG_WITH(ping6_command,
1021         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
1022                 [sets syntax for ICMPv6 ping]),
1023         with_ping6_command=$withval,)
1025 if test x"$with_ipv6" != xno ; then
1026 AC_MSG_CHECKING(for ICMPv6 ping syntax)
1027 ac_cv_ping6_packets_first=no
1028 if test -n "$with_ping6_command"
1029 then
1030         AC_MSG_RESULT([(command-line) $with_ping6_command])
1031         if test -n "$ac_cv_ping6_packets_first"
1032         then
1033                 ac_cv_ping6_packets_first=yes
1034         fi
1036 elif test "x$PATH_TO_PING6" != "x"; then
1037         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1038                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1039                 egrep -i "^round-trip|^rtt" >/dev/null
1040         then
1041                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1042                 ac_cv_ping6_packets_first=yes
1043                 AC_MSG_RESULT([$with_ping6_command])
1045         elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
1046                 egrep -i "^round-trip|^rtt" >/dev/null
1047         then
1048                 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
1049                 ac_cv_ping6_packets_first=yes
1050                 ac_cv_ping_has_timeout=yes
1051                 AC_MSG_RESULT([$with_ping6_command])
1053         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1054                 egrep -i "^round-trip|^rtt" >/dev/null
1055         then
1056                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1057                 ac_cv_ping6_packets_first=yes
1058                 AC_MSG_RESULT([$with_ping6_command])
1060         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1061                 egrep -i "^round-trip|^rtt" >/dev/null
1062         then
1063                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1064                 ac_cv_ping6_packets_first=yes
1065                 AC_MSG_RESULT([$with_ping6_command])
1067         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1068                 egrep -i "^round-trip|^rtt" >/dev/null
1069         then
1070                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1071                 AC_MSG_RESULT([$with_ping6_command])
1073         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1074                 egrep -i "^round-trip|^rtt" >/dev/null
1075         then
1076                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1077                 AC_MSG_RESULT([$with_ping6_command])
1079         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1080                 egrep -i "^round-trip|^rtt" >/dev/null
1081         then
1082                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1083                 AC_MSG_RESULT([$with_ping6_command])
1085         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1086                 egrep -i "^round-trip|^rtt" >/dev/null
1087         then
1088                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1089                 AC_MSG_RESULT([$with_ping6_command])
1091         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1092                 egrep -i "^round-trip|^rtt" >/dev/null
1093         then
1094                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1095                 ac_cv_ping6_packets_first=yes
1096                 AC_MSG_RESULT([$with_ping_command])
1098         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1099                 egrep -i "^round-trip|^rtt" >/dev/null
1100         then
1101                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1102                 ac_cv_ping6_packets_first=yes
1103                 AC_MSG_RESULT([$with_ping6_command])
1105         fi
1107 elif test "x$PATH_TO_PING" != "x"; then
1108         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1109                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1110                 egrep -i "^round-trip|^rtt" >/dev/null
1111         then
1112                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1113                 ac_cv_ping6_packets_first=yes
1114                 AC_MSG_RESULT([$with_ping6_command])
1116         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1117                 egrep -i "^round-trip|^rtt" >/dev/null
1118         then
1119                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1120                 ac_cv_ping6_packets_first=yes
1121                 AC_MSG_RESULT([$with_ping6_command])
1123         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1124                 egrep -i "^round-trip|^rtt" >/dev/null
1125         then
1126                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1127                 ac_cv_ping6_packets_first=yes
1128                 AC_MSG_RESULT([$with_ping6_command])
1130         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1131                 egrep -i "^round-trip|^rtt" >/dev/null
1132         then
1133                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1134                 AC_MSG_RESULT([$with_ping6_command])
1136         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1137                 egrep -i "^round-trip|^rtt" >/dev/null
1138         then
1139                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1140                 AC_MSG_RESULT([$with_ping6_command])
1142         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1143                 egrep -i "^round-trip|^rtt" >/dev/null
1144         then
1145                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1146                 AC_MSG_RESULT([$with_ping6_command])
1148         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1149                 egrep -i "^round-trip|^rtt" >/dev/null
1150         then
1151                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1152                 AC_MSG_RESULT([$with_ping6_command])
1154         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1155                 egrep -i "^round-trip|^rtt" >/dev/null
1156         then
1157                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1158                 ac_cv_ping6_packets_first=yes
1159                 AC_MSG_RESULT([$with_ping_command])
1161         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1162                 egrep -i "^round-trip|^rtt" >/dev/null
1163         then
1164                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1165                 ac_cv_ping6_packets_first=yes
1166                 AC_MSG_RESULT([$with_ping6_command])
1168         fi
1170 fi
1172 if test "x$with_ping6_command" != "x"; then
1173         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1174                 [path and args for ICMPv6 ping command])
1175 else
1176         AC_MSG_RESULT([none])
1177 fi
1179 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1180         AC_DEFINE(PING6_PACKETS_FIRST,1,
1181                 [Define if packet count must precede host])
1182 fi
1183 fi
1185 AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1187 AC_MSG_CHECKING(for nslookup syntax)
1188 if test -n "$PATH_TO_NSLOOKUP"
1189 then
1190         if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1191         then
1192                 ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1193                 AC_MSG_RESULT([$ac_cv_nslookup_command])
1195         else
1196                 ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1197                 AC_MSG_RESULT([$ac_cv_nslookup_command])
1199         fi
1200         EXTRAS="$EXTRAS check_dns"
1202 else
1203         AC_MSG_WARN([nslookup command not found])
1204 fi
1206 AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command",
1207         [path and args for nslookup])
1209 AC_PATH_PROG(PATH_TO_HOST,host)
1210 if test -n "$ac_cv_path_PATH_TO_HOST"
1211 then
1212         EXTRAS="$EXTRAS check_dns"
1213 fi
1215 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1216 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1218 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1219 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1221 AC_PATH_PROG(PATH_TO_NTPDATE,ntpdate)
1222 AC_PATH_PROGS(PATH_TO_NTPDC,ntpdc xntpdc)
1223 AC_PATH_PROGS(PATH_TO_NTPQ,ntpq)
1224 if (test -x "$PATH_TO_NTPDATE" || test -x "$PATH_TO_NTPQ")
1225 then
1226         AC_DEFINE_UNQUOTED(PATH_TO_NTPQ,"$PATH_TO_NTPQ",[path to ntpq binary])
1227         AC_DEFINE_UNQUOTED(PATH_TO_NTPDATE,"$PATH_TO_NTPDATE",[path to ntpdate binary])
1228 else
1229         AC_MSG_WARN([Install NTP programs (http://www.ntp.org) if you want to monitor time synchronization])
1230 fi
1232 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1233 if test -x "$PATH_TO_LMSTAT"
1234 then
1235         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1236 else
1237         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1238 fi
1240 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1241 if test -x "$PATH_TO_SMBCLIENT"
1242 then
1243         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1244 else
1245         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1246 fi
1249 AC_PATH_PROG(PATH_TO_WHO,who)
1251 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1252 then
1253         ac_cv_path_to_who="$PATH_TO_WHO -q"
1254 else
1255         ac_cv_path_to_who="$PATH_TO_WHO"
1256 fi
1258 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1259         [path and arguments for invoking 'who'])
1261 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1262 if test -x "$PATH_TO_SNMPGET"
1263 then
1264         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1265         EXTRAS="$EXTRAS check_hpjd check_snmp"
1266 else
1267         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1268 fi
1270 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1271 if test -x "$PATH_TO_SNMPGETNEXT"
1272 then
1273         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1274 fi
1276 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1277 then
1278         AC_MSG_CHECKING(for Net::SNMP perl module)
1279         AC_MSG_RESULT([found])
1280 else
1281         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1282 fi
1284 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1285 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1287 if test -x "$PATH_TO_QUAKESTAT"
1288 then
1289         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1290         EXTRAS="$EXTRAS check_game"
1292 elif test -x "$PATH_TO_QSTAT"
1293 then
1294         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1295         EXTRAS="$EXTRAS check_game"
1296 else
1297         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1298 fi
1300 if test $ac_cv_path_to_qstat 
1301 then
1302         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1303                 [path to qstat/quakestat])
1304 fi
1306 AC_PATH_PROG(PATH_TO_FPING,fping)
1307 if test -x "$PATH_TO_FPING"
1308 then
1309         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1310         EXTRAS="$EXTRAS check_fping"
1311 else
1312         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1313 fi
1315 AC_PATH_PROG(PATH_TO_SSH,ssh)
1317 if test -x "$PATH_TO_SSH"
1318 then
1319         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1320         EXTRAS="$EXTRAS check_by_ssh"
1321 else
1322         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1323 fi
1326 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1327 if test -x "$PATH_TO_MAILQ"
1328 then
1329         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1330 else
1331         AC_MSG_WARN([Could not find mailq or eqivalent])
1332 fi
1334 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1335 if test -x "$PATH_TO_QMAIL_QSTAT"
1336 then
1337         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1338 else
1339         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1340 fi
1342 dnl SWAP info required is amount allocated/available and amount free
1343 dnl The plugin works through all the swap devices and adds up the total swap
1344 dnl available.
1345 AC_PATH_PROG(PATH_TO_SWAP,swap)
1346 if (test -n "$PATH_TO_SWAP")
1347 then
1348 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1349 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1350 then
1351         ac_cv_have_swap=yes
1352         ac_cv_swap_command="$PATH_TO_SWAP -l"
1353         if [$PATH_TO_SWAP -l 2>/dev/null | \
1354                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1355                 >/dev/null]
1356         then
1357                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1358                 ac_cv_swap_conv=2048
1359                 AC_MSG_RESULT([using IRIX format swap])
1361         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1362         then
1363                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1364                 ac_cv_swap_conv=2048
1365                 AC_MSG_RESULT([using Unixware format swap])
1366         else
1367                 dnl if we don't know what format swap's output is
1368                 dnl we might as well pretend we didn't see it
1369                 ac_cv_have_swap=""
1370                 ac_cv_swap_command=""
1371         fi
1372 fi
1373 dnl end if for PATH_TO_SWAP
1374 fi
1376 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1377 if (test -n "$PATH_TO_SWAPINFO")
1378 then
1379 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1380 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1381 then
1382         ac_cv_have_swap=yes
1383         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1385         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1386         then
1387                 ac_cv_swap_format=["%*s %f %*d %f"]
1388                 ac_cv_swap_conv=1024
1389                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1390         fi
1392 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1393 then
1394         ac_cv_have_swap=yes
1395         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM",
1396         ac_cv_swap_format=["%*s %f %*d %f"]
1397         ac_cv_swap_conv=1024
1398         AC_MSG_RESULT([using HP-UX format swapinfo])
1399 fi
1400 dnl end if for PATH_TO_SWAPINFO
1401 fi
1403 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1404 if (test -n "$PATH_TO_LSPS")
1405 then
1406 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1407 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1408 then
1409         ac_cv_have_swap=yes
1410         ac_cv_swap_command="$PATH_TO_LSPS -a"
1411         ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1412         ac_cv_swap_conv=1
1413         AC_MSG_RESULT([using AIX lsps])
1414 fi
1415 dnl end if for PATH_TO_SWAPINFO
1416 fi
1418 dnl
1419 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1420 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1421 dnl in the various BSD's
1422 dnl
1424 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1425 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1426 #ifdef HAVE_SYS_PARAM_H
1427 #include <sys/param.h>
1428 #endif
1429 ])
1430 AC_CHECK_DECLS([swapctl],,,[
1431                #include <unistd.h>
1432                #include <sys/types.h>
1433                #include <sys/param.h>
1434                #include <sys/stat.h>
1435                #include <sys/swap.h>
1436                ])
1437 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1438                #include <sys/types.h>
1439                #include <sys/param.h>
1440                #include <sys/stat.h>
1441                #include <sys/swap.h>
1442                ])
1443 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1444                #include <unistd.h>
1445                #include <sys/types.h>
1446                #include <sys/param.h>
1447                #include <sys/stat.h>
1448                #include <sys/swap.h>
1449                ])
1451 if test "$ac_cv_have_decl_swapctl" = "yes"; 
1452 then
1453         EXTRAS="$EXTRAS check_swap"
1454         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1455         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1456                 "$ac_cv_type_swapent_t" = "yes"; 
1457         then
1458                 AC_MSG_RESULT([yes])
1459                 ac_cv_check_swap_swapctl_svr4="1";
1460                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1461                           [Define if 2-argument SVR4 swapctl exists])
1462         else
1463                 AC_MSG_RESULT([no])
1464                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1465                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes"; 
1466                 then
1467                         AC_MSG_RESULT([yes])
1468                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1469                                   [Define if 3-argument BSD swapctl exists])
1470                 else
1471                         AC_MSG_RESULT([no])
1472                 fi
1473         fi
1474         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1475         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1476         then
1477                 dnl
1478                 dnl the SVR4 spec returns values in pages
1479                 dnl
1480                 AC_MSG_RESULT([page])
1481                 AC_CHECK_DECLS([sysconf])
1482                 AC_MSG_CHECKING([for system page size])
1483                 if test "$ac_cv_have_decl_sysconf" = "yes";
1484                 then
1485                         AC_MSG_RESULT([determined by sysconf(3)])
1486                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1487                 else
1488                         AC_MSG_WARN([don't know. guessing 4096k])
1489                         ac_cv_swap_conv=256
1490                 fi
1491         else
1492                 dnl
1493                 dnl the BSD spec returns values in blocks
1494                 dnl
1495                 AC_MSG_RESULT([blocks (assuming 512b)])
1496                 ac_cv_swap_conv=2048
1497         fi
1498         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1499                 [Conversion factor to MB])
1500 fi
1501 dnl
1502 dnl end tests for the swapctl system calls
1503 dnl
1506 if test "x$ac_cv_have_swap" != "x" 
1507 then
1508         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1509         EXTRAS="$EXTRAS check_swap"
1510 fi
1511 if test "x$ac_cv_swap_command" != "x" 
1512 then
1513         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1514                 [Path to swap/swapinfo binary, with any args])
1515         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1516                 [Format string for parsing swap output])
1517         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1518                 [Conversion factor to MB])
1519 fi
1521 dnl dunno why this does not work below - use hack (kbd)
1522 dnl fine on linux, broken on solaris
1523 dnl if /bin/test -e "/proc/meminfo"
1524 AC_MSG_CHECKING([for /proc/meminfo])
1525 if [cat /proc/meminfo > /dev/null 2>&1]
1526 then
1527         AC_MSG_RESULT([found /proc/meminfo])
1528         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1529         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"/proc/meminfo",[path to /proc/meminfo if name changes])
1530         EXTRAS="$EXTRAS check_swap"
1531 else
1532         AC_MSG_RESULT([no])
1533 fi
1535 AC_PATH_PROG(PATH_TO_DIG,dig)
1536 AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1537 if test -n "$PATH_TO_DIG"; then
1538         EXTRAS="$EXTRAS check_dig"
1539 fi
1541 if test -f plugins/check_nt.c ; then
1542   EXTRAS="$EXTRAS check_nt"
1543 elif test -f ../plugins/check_nt.c ; then
1544   EXTRAS="$EXTRAS check_nt"
1545 fi
1547 AC_MSG_CHECKING(for va_list)
1548 AC_TRY_COMPILE([#ifdef __STDC__
1549                 #include <stdio.h>
1550                 #include <stdlib.h>
1551                 #include <stdarg.h>
1552                 #else
1553                 #include <sys/types.h>
1554                 #include <stdio.h>
1555                 #include <varargs.h>
1556                 #endif],
1557                 [va_list args;],
1558                 [AC_MSG_RESULT(yes)],
1559                 [NEED_VA_LIST=-DNEED_VA_LIST AC_SUBST(NEED_VA_LIST) AC_MSG_RESULT(no)])
1561 case $host in
1562         *bsd*)
1563                 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1564         ;;
1565         *linux*)
1566                 AC_DEFINE(__linux__,1,[sun specific code in check_dhcp.c])
1567         ;;
1568         *sun* | solaris*)
1569                 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1570         ;;
1571         *hpux*)  
1572                 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1573         ;;
1574 esac
1576 AC_SUBST(EXTRAS)
1577 AC_SUBST(EXTRA_NETOBJS)
1578 AC_SUBST(DEPLIBS)
1580 AM_GNU_GETTEXT([no-libtool], [need-ngettext])
1581 AM_GNU_GETTEXT_VERSION(0.11.5)
1583 dnl Check for Redhat spopen problem
1584 dnl Wierd problem where ECHILD is returned from a wait call in error
1585 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1586 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1587 dnl We patch plugins/popen.c
1588 dnl Need to add smp because uname different on those. May need to check
1589 dnl Fedora Core too in future
1590 if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then
1591         AC_MSG_CHECKING(for redhat spopen problem)
1592         ( cd config_test && make && make test ) > /dev/null 2>&1
1593         if test $? -eq 0 ; then
1594                 AC_MSG_RESULT(okay)
1595         else
1596                 AC_MSG_RESULT(error)
1597                 AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, "Problem on redhat with spopen")
1598         fi
1599 fi
1601 dnl External libraries - see ACKNOWLEDGEMENTS
1602 np_COREUTILS
1603 np_CURL
1605 AC_OUTPUT(
1606   Makefile 
1607   lib/Makefile 
1608   m4/Makefile 
1609   plugins/Makefile 
1610   plugins-root/Makefile
1611   plugins-scripts/Makefile 
1612   plugins-scripts/subst 
1613   plugins-scripts/utils.pm 
1614   plugins-scripts/utils.sh 
1615   command.cfg 
1616   test.pl 
1617   pkg/solaris/pkginfo 
1618   intl/Makefile
1619   po/Makefile.in 
1622 ACX_FEATURE([with],[perl])
1623 ACX_FEATURE([with],[cgiurl])
1624 ACX_FEATURE([with],[nagios-user])
1625 ACX_FEATURE([with],[nagios-group])
1626 ACX_FEATURE([with],[trusted-path])
1627 ACX_FEATURE([with],[ping-command])
1628 ACX_FEATURE([with],[ping6-command])
1629 ACX_FEATURE([with],[lwres])
1630 ACX_FEATURE([with],[ipv6])
1631 ACX_FEATURE([with],[openssl])
1632 ACX_FEATURE([with],[gnutls])
1633 ACX_FEATURE([enable],[emulate-getaddrinfo])