Code

whoops. now using automake conditionals to prevent attempted compiles
[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)
107 dnl allow them to override the path of perl
108 AC_ARG_WITH(perl,
109         ACX_HELP_STRING([--with-perl=PATH],
110                         [sets path to perl executable]),
111                         with_perl=$withval,with_perl=$PERL)
112 AC_SUBST(PERL, $with_perl)
114 AC_PATH_PROG(HOSTNAME,hostname)
115 AC_PATH_PROG(BASENAME,basename)
117 dnl
118 dnl Check for miscellaneous stuff
119 dnl 
121 case $host_vender-$host_os in
122 sun*)
123         AC_DEFINE(__EXTENSIONS__,1,[Sun's netdb.h needs this for getaddrinfo])
124         ;;
125 osf*)
126         AC_DEFINE(_OSF_SOURCE,1,[OSF needs this for getaddrinfo])
127         ;;
128 esac
130 dnl
131 dnl Checks for libraries.
132 dnl
134 AC_CHECK_LIB(dce,main,SOCKETLIBS="$SOCKETLIBS -ldce")
135 AC_CHECK_LIB(nsl,main,SOCKETLIBS="$SOCKETLIBS -lnsl")
136 AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket")
137 AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv")
138 AC_SUBST(SOCKETLIBS)
140 dnl
141 dnl check for math-related functions needing -lm
142 AC_CHECK_LIB(m,floor,MATHLIBS="-lm")
143 AC_SUBST(MATHLIBS)
145 dnl Check for PostgreSQL libraries
146 _SAVEDLIBS="$LIBS"
147 _SAVEDCPPFLAGS="$CPPFLAGS"
148 AC_ARG_WITH(pgsql,
149         ACX_HELP_STRING([--with-pgsql=DIR],
150                 [sets path to pgsql installation]),
151         PGSQL=$withval,)
152 AC_CHECK_LIB(crypt,main)
153 if test "$ac_cv_lib_crypt_main" = "yes"; then
154   if test -n "$PGSQL"; then
155     LDFLAGS="$LDFLAGS -L$PGSQL/lib"
156     CPPFLAGS="$CPPFLAGS -I$PGSQL/include"
157   fi
158   AC_CHECK_LIB(pq,PQsetdbLogin,,,-lcrypt)
159   if test "$ac_cv_lib_pq_PQsetdbLogin" = "yes"; then
160     AC_CHECK_HEADERS(pgsql/libpq-fe.h)
161     AC_CHECK_HEADERS(postgresql/libpq-fe.h)
162     AC_CHECK_HEADERS(libpq-fe.h)
163     if [[ -n "$PGSQL" -a "$ac_cv_header_libpq_fe_h" = "yes" ]]; then
164       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
165       PGINCLUDE="-I$PGSQL/include"
166     elif test  "$ac_cv_header_pgsql_libpq_fe_h" = "yes"; then
167       PGLIBS="-lpq -lcrypt"
168       PGINCLUDE="-I/usr/include/pgsql"
169     elif test  "$ac_cv_header_postgresql_libpq_fe_h" = "yes"; then
170       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
171       PGINCLUDE="-I/usr/include/postgresql"
172     elif test  "$ac_cv_header_libpq_fe_h" = "yes"; then
173       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
174       PGINCLUDE="-I$PGSQL/include"
175     fi
176     if test -z "$PGINCLUDE"; then
177       AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
178       AC_MSG_WARN([install PostgreSQL headers to compile this plugin (see REQUIREMENTS).])
179     else
180       AC_SUBST(PGLIBS)
181       AC_SUBST(PGINCLUDE)
182       EXTRAS="$EXTRAS check_pgsql"
183     fi
184   else
185     AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
186     AC_MSG_WARN([LIBS="$LIBS" CPPFLAGS="$CPPFLAGS"])
187     AC_MSG_WARN([install PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
188   fi
189 else
190   AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
191   AC_MSG_WARN([install lib crypt and PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
192 fi
193 LIBS="$_SAVEDLIBS"
194 CPPFLAGS="$_SAVEDCPPFLAGS"
196 dnl Check for radius libraries
197 _SAVEDLIBS="$LIBS"
198 AC_CHECK_LIB(radiusclient,rc_read_config)
199 if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
200   EXTRAS="$EXTRAS check_radius"
201         RADIUSLIBS="-lradiusclient"
202   AC_SUBST(RADIUSLIBS)
203 else
204   AC_MSG_WARN([Skipping radius plugin])
205   AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
206 fi
207 LIBS="$_SAVEDLIBS"
209 dnl Check for LDAP libraries
210 _SAVEDLIBS="$LIBS"
211 AC_CHECK_LIB(ldap,main,,,-llber)
212 if test "$ac_cv_lib_ldap_main" = "yes"; then
213   LDAPLIBS="-lldap -llber"\
214   LDAPINCLUDE="-I/usr/include/ldap"
215   AC_SUBST(LDAPLIBS)
216   AC_SUBST(LDAPINCLUDE)
217   AC_CHECK_FUNCS(ldap_set_option)
218   EXTRAS="$EXTRAS check_ldap"
219         AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
220 else
221   AC_MSG_WARN([Skipping LDAP plugin])
222   AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
223 fi
224 LIBS="$_SAVEDLIBS"
227 dnl Check for mysql libraries
228 _SAVEDLIBS="$LIBS"
229 _SAVEDCPPFLAGS="$CPPFLAGS"
230 AC_ARG_WITH(mysql,
231         ACX_HELP_STRING([--with-mysql=DIR],
232                 [sets path to mysql installation (assumes lib/mysql and include subdirs]),
233         MYSQL=$withval,)
234 if test -n "$MYSQL"; then
235   MYSQLLIBDIR=$MYSQL/lib/mysql
236   CPPFLAGS="-I$MYSQL/include"
237   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L$MYSQLLIBDIR ",,-L$MYSQLLIBDIR -lz)
238   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
239 elif test -f /usr/lib/libmysqlclient.so; then
240   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
241   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
242 elif test -f /usr/lib/libmysqlclient.a; then
243   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
244   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
245 elif test -f /usr/lib/mysql/libmysqlclient.so; then
246   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
247   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
248 elif test -f /usr/lib/mysql/libmysqlclient.a; then
249   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
250   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
251 fi
252 if test "$ac_cv_lib_mysqlclient_mysql_init" = "yes" -o "$ac_cv_lib_mysqlclient_mysql_close" = "yes"; then
253   AC_CHECK_HEADERS(mysql/mysql.h mysql/errmsg.h, MYSQLINCLUDE="-I$MYSQL/include" )
254   if test "$ac_cv_header_mysql_mysql_h" = "yes" -a "$ac_cv_header_mysql_errmsg_h" = "yes"; then
255     EXTRAS="$EXTRAS check_mysql"
256     AC_SUBST(MYSQLINCLUDE)
257     AC_SUBST(MYSQLLIBS)
258     AC_SUBST(check_mysql_LDFLAGS)
259   else
260     AC_MSG_WARN([Skipping mysql plugin])
261     AC_MSG_WARN([install mysql client headers to compile this plugin (see REQUIREMENTS).])
262   fi
263 else
264   AC_MSG_WARN([Skipping mysql plugin])
265   AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
266 fi
267 CPPFLAGS="$_SAVEDCPPFLAGS $MYSQLINCLUDE"
268 LIBS="$_SAVEDLIBS"
270 AC_CHECK_HEADERS(unistd.h)
272 dnl Check for AF_INET6 support - unistd.h required for Darwin
273 AC_CACHE_CHECK([for IPv6 support], with_ipv6, [
274         AC_TRY_COMPILE([#ifdef HAVE_UNISTD_H
275                         #include <unistd.h>
276                         #endif
277                         #include <netinet/in.h>
278                         #include <sys/socket.h>],
279                         [struct sockaddr_in6 sin6;
280                         void *p;
282                         sin6.sin6_family = AF_INET6;
283                         sin6.sin6_port = 587;
284                         p = &sin6.sin6_addr;],
285                         [with_ipv6=yes], 
286                         [with_ipv6=no])
287         ])
289 if test x"$with_ipv6" != xno ; then
290         AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
291 fi
293 dnl #########################################################################
294 dnl Check if Posix getaddrinfo() is available.  It is also possible to use
295 dnl the version from the lwres library distributed with BIND.
296 dnl #########################################################################
297 AC_ARG_ENABLE([emulate-getaddrinfo],
298               ACX_HELP_STRING([--enable-emulate-getaddrinfo],
299                              [enable getaddrinfo emulation (default=no)]),
300               ,
301               enable_emulate_getaddrinfo=no)
303 AC_ARG_WITH(lwres,
304             ACX_HELP_STRING([--with-lwres=DIR],
305                            [use lwres library for getaddrinfo (default=no)]),
306             ,
307             with_lwres=no)
309 dnl ## enable force to test getaddrinfo.c
310 if test x$enable_emulate_getaddrinfo = xforce ; then
311         enable_emulate_getaddrinfo=yes
312         have_getaddrinfo=no
313 else
315 have_getaddrinfo=no
316 if test x$with_lwres != xno ; then
317         if test "$with_lwres" != yes ; then
318                    CPPFLAGS="-I${with_lwres}/include $CPPFLAGS"
319                    LDFLAGS="-L${with_lwres}/lib $LDFLAGS"
320         fi
321         AC_CHECK_HEADERS(lwres/netdb.h, ,
322                         [AC_MSG_ERROR([cannot find <lwres/netdb.h>])])
323         AC_CHECK_LIB(lwres, lwres_getaddrinfo, ,
324                      [AC_MSG_ERROR([cannot find the lwres library])],
325                      -lnsl -lpthread)
326         have_getaddrinfo=yes
327 fi
329 if test x$have_getaddrinfo != xyes ; then
330         AC_SEARCH_LIBS(getaddrinfo, socket resolv bind nsl c_r cr, have_getaddrinfo=yes)
331 fi
333 dnl # Special nonsense for systems that actually have getaddrinfo but
334 dnl # redefine the name to something else, e.g. OSF
335 if test x$have_getaddrinfo != xyes ; then
336         AC_MSG_CHECKING(if getaddrinfo is redefined in netdb.h)
337         AC_TRY_LINK([
338 #               include <netdb.h>
339         ], [
340                 struct addrinfo hints, *res;
341                 int err;
343                 err = getaddrinfo ("host", "service", &hints, &res);
344         ], [
345                 have_getaddrinfo=yes
346                 AC_MSG_RESULT(yes)
347         ], [AC_MSG_RESULT(no)])
348 fi
350 fi
352 if test x$have_getaddrinfo != xno ; then
353         if test x$enable_emulate_getaddrinfo != xno ; then
354                 AC_MSG_ERROR([getaddrinfo found but emulate-getaddrinfo was enabled])
355         fi
356         AC_DEFINE(HAVE_GETADDRINFO, 1,
357                   [Does system provide RFC 2553/Posix getaddrinfo?])
358 else
359         if test x$enable_emulate_getaddrinfo != xyes ; then
360 dnl                AC_MSG_ERROR([getaddrinfo not found: try --with-lwres or --enable-emulate-getaddrinfo])
361                enable_emulate_getaddrinfo=yes
362                AC_MSG_WARN([enabling getaddrinfo emulation])
363         fi
364         EXTRA_NETOBJS="$EXTRA_NETOBJS getaddrinfo.o"
365 fi
367 if test x"$enable_emulate_getaddrinfo" != xno ; then
368     have_resolver=no
370   dnl  Try for getipnodebyname
371     AC_SEARCH_LIBS(getipnodebyname, resolv bind nsl c_r cr, have_resolver=yes)
372     if test x"$have_resolver" != xno ; then
373          AC_DEFINE(HAVE_GETIPNODEBYNAME, 1,
374                    [Set when getipnodebyname is available])
375     fi
377   dnl  Try for gethostbyname_r
378     if test x"$have_resolver" = xno ; then
379         AC_SEARCH_LIBS(gethostbyname_r, resolv bind nsl c_r cr,
380                        [have_resolver=yes
381                         ACX_WHICH_GETHOSTBYNAME_R])
382     fi
384   dnl  Try for gethostbyname
385     if test x"$have_resolver" = xno ; then
386         if test x"$enable_pthreads" != xno ; then
387             AC_MSG_WARN([using threads but cannot find gethostbyname_r or getipnodebyname])
388         fi
389         AC_SEARCH_LIBS(gethostbyname, resolv bind nsl, ,
390                        [AC_MSG_ERROR([cannot find gethostbyname])])
391     fi
392     EXTRA_NETOBJS="$EXTRA_NETOBJS gethostbyname.o"
394 fi
396 dnl Checks for Kerberos. Must come before openssl checks for Redhat EL 3
397 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
398 if test "$FOUNDINCLUDE" = "no"; then
399   _SAVEDCPPFLAGS="$CPPFLAGS"
400   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
401   unset ac_cv_header_krb5_h
402   AC_CHECK_HEADERS(krb5.h,
403                    KRB5INCLUDE="-I/usr/kerberos/include"
404                    FOUNDINCLUDE=yes,
405                    FOUNDINCLUDE=no)
406 fi
407 AC_SUBST(KRBINCLUDE)
408 if test "$FOUNDINCLUDE" = "no"; then
409   CPPFLAGS="$_SAVEDCPPFLAGS"
410 fi
412 dnl Check for OpenSSL location
413 AC_PATH_PROG(OPENSSL,openssl)
414 if test "$OPENSSL" = "/usr/bin/openssl"; then
415   OPENSSL=/usr
416 elif test "$OPENSSL" = "/usr/sbin/openssl"; then
417   OPENSSL=/usr
418 elif test "$OPENSSL" = "/opt/bin/openssl"; then
419   OPENSSL=/opt
420 elif test "$OPENSSL" = "/opt/openssl/bin/openssl"; then
421   OPENSSL=/opt/openssl
422 elif test "$OPENSSL" = "/usr/slocal/bin/openssl"; then
423   OPENSSL=/usr/slocal
424 elif test "$OPENSSL" = "/usr/local/bin/openssl"; then
425   OPENSSL=/usr/local
426 elif test "$OPENSSL" = "/usr/local/ssl/bin/openssl"; then
427   OPENSSL=/usr/local/ssl
428 fi
429 AC_ARG_WITH(openssl,
430 AC_HELP_STRING([--with-openssl=DIR], [sets path to openssl installation])
431 AC_HELP_STRING([--without-openssl], [disable openssl]),
432 OPENSSL=$withval)
434 _SAVEDCPPFLAGS="$CPPFLAGS"
435 _SAVEDLDFLAGS="$LDFLAGS"
436 if test X"$OPENSSL" = "Xno"; then
437   AC_MSG_WARN([openssl disabled, you will not be able to use ssl options in some plugins])
438   FOUNDSSL="dontbother"
439 else
440   dnl Check for OpenSSL header files
441   unset FOUNDINCLUDE
442   if test "$OPENSSL" != "/usr"; then
443     CPPFLAGS="$CPPFLAGS -I$OPENSSL/include"
444     LDFLAGS="$LDFLAGS -R$OPENSSL/lib"
445   fi
446   AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
447                  SSLINCLUDE="-I$OPENSSL/include"
448                  FOUNDINCLUDE=yes,
449                  FOUNDINCLUDE=no)
450   if test "$FOUNDINCLUDE" = "no"; then
451     AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
452                    SSLINCLUDE="-I$OPENSSL/include"
453                    FOUNDINCLUDE=yes,
454                    FOUNDINCLUDE=no)
455   fi
456   AC_SUBST(SSLINCLUDE)
457   if test "$FOUNDINCLUDE" = "no"; then
458     CPPFLAGS="$_SAVEDCPPFLAGS"
459   fi
461   dnl Check for crypto lib
462   _SAVEDLIBS="$LIBS"
463   AC_CHECK_LIB(crypto,CRYPTO_lock,,,-L$OPENSSL/lib)
464   if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
465     dnl Check for SSL lib
466     AC_CHECK_LIB(ssl,main,LDFLAGS="$LDFLAGS -L$OPENSSL/lib" SSLLIBS="-lssl -lcrypto",AC_CHECK_LIB(ssl,main,LDFLAGS="$LDFLAGS -L$OPENSSL/lib" SSLLIBS="-lssl -lcrypto"),-L$OPENSSL/lib -lcrypto)
467   fi
468   LIBS="$_SAVEDLIBS"
470   FOUNDSSL="no"
471   dnl test headers and libs to decide whether check_http should use SSL
472   if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
473     if test "$ac_cv_lib_ssl_main" = "yes"; then
474       if test "$FOUNDINCLUDE" = "yes"; then
475         FOUNDSSL="yes"
476       fi
477     fi
478   fi
479 fi
481 if test "$FOUNDSSL" = "yes"; then
482   check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
483   AC_SUBST(check_tcp_ssl)
484   AC_SUBST(SSLLIBS)
485   AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
486   with_openssl="yes"
487 else
488   if test "$FOUNDSSL" = "no"; then
489     AC_MSG_WARN([OpenSSL libs could not be found])
490   dnl else deliberately disabled
491   fi
492   with_openssl="no"
493   CPPFLAGS="$_SAVEDCPPFLAGS"
494   LDFLAGS="$_SAVEDLDFLAGS"
495 fi
497 dnl
498 dnl Checks for header files.
499 dnl
501 AC_HEADER_STDC
502 AC_HEADER_TIME
503 AC_HEADER_SYS_WAIT
504 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)
505 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h stdlib.h)
507 dnl Checks for typedefs, structures, and compiler characteristics.
508 AC_C_CONST
509 AC_STRUCT_TM
510 AC_TYPE_PID_T
511 AC_TYPE_SIZE_T
512 AC_TYPE_SIGNAL
514 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
515 AC_TRY_LINK([#include <stdarg.h>
516 va_list ap1,ap2;], [va_copy(ap1,ap2);],
517 ac_cv_HAVE_VA_COPY=yes,
518 ac_cv_HAVE_VA_COPY=no)])
519 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
520     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
521 else    
522     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
523     AC_TRY_LINK([#include <stdarg.h>
524     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
525     ac_cv_HAVE___VA_COPY=yes,
526     ac_cv_HAVE___VA_COPY=no)])
527     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
528         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
529     fi
530 fi
532 AC_CHECK_FUNCS(vsnprintf snprintf asprintf vasprintf)
533 AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[
534 AC_TRY_RUN([
535 #include <sys/types.h>
536 #include <stdarg.h>
537 void foo(const char *format, ...) { 
538        va_list ap;
539        int len;
540        char buf[5];
542        va_start(ap, format);
543        len = vsnprintf(buf, 0, format, ap);
544        va_end(ap);
545        if (len != 5) exit(1);
547        va_start(ap, format);
548        len = vsnprintf(0, 0, format, ap);
549        va_end(ap);
550        if (len != 5) exit(1);
552        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
554        exit(0);
556 main() { foo("hello"); }
557 ],
558 ac_cv_HAVE_C99_VSNPRINTF=yes,ac_cv_HAVE_C99_VSNPRINTF=no,ac_cv_HAVE_C99_VSNPRINTF=cross)])
559 if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
560     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Define if system has C99 compatible vsnprintf])
561 fi
563 AC_TRY_COMPILE([#include <sys/time.h>],
564                [struct timeval *tv;
565                 struct timezone *tz;],
566                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
567                AC_TRY_COMPILE([#include <sys/time.h>],
568                               [struct timeval *tv;
569                                struct timezone *tz;
570                                gettimeofday(tv, tz);],
571                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
572                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
574 dnl Checks for library functions.
575 AC_CHECK_FUNCS(memmove select socket strdup strstr strtod strtol strtoul floor)
577 AC_MSG_CHECKING(return type of socket size)
578 AC_TRY_COMPILE([#include <stdlib.h>
579                 #include <sys/types.h>
580                 #include <sys/socket.h>],
581                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
582                ac_cv_socket_size_type=["size_t"]
583                 AC_MSG_RESULT(size_t),
584                ac_cv_socket_size_type=["int"]
585                 AC_MSG_RESULT(int))
587 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
588         [Define type of socket size])
590 if test -f "/proc/loadavg"
591 then
592   AC_DEFINE(HAVE_PROC_LOADAVG,1,[Define if /proc/loadavg or similar exists])
593   AC_DEFINE_UNQUOTED(PROC_LOADAVG,"/proc/loadavg",[Location of /proc/loadavg])
594 fi
596 dnl #### Process table test
598 AC_PATH_PROG(PATH_TO_PS,ps)
600 AC_MSG_CHECKING(for ps syntax)
602 dnl Now using the pst3/kmem hack for solaris systems to avoid truncation
603 AM_CONDITIONAL(WANT_PST3, false)
604 if test "$ac_cv_uname_s" = "SunOS"; then
605         #
606         # this is a very, very ugly hack, to hardcode the location for plugins
607         #
608         if test "$libexecdir" = '${exec_prefix}/libexec'; then
609                 if test "$exec_prefix" = "NONE"; then
610                         if test "$prefix" = "NONE"; then
611                                 pst3="$ac_default_prefix/libexec/pst3"
612                         else
613                                 pst3="$prefix/libexec/pst3"
614                         fi
615                 else
616                         pst3="$exec_prefix/libexec/pst3"
617                 fi
618         else
619                 pst3="$libexecdir/pst3"
620         fi
621         ac_cv_ps_command="$pst3"
622         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
623         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
624         ac_cv_ps_cols=8
625         AC_MSG_RESULT([using nagios-plugins internal ps for solaris])
626         AM_CONDITIONAL(WANT_PST3, true)
628 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
629 dnl so test for this first...
630 elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
631         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
632 then
633         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
634         ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
635         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
636         ac_cv_ps_cols=9
637         AC_MSG_RESULT([$ac_cv_ps_command])
639 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
640 dnl Should also work for FreeBSD 5.2.1 and 5.3
641 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
642 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
643         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
644 then
645         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
646         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
647         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
648         ac_cv_ps_cols=9
649         AC_MSG_RESULT([$ac_cv_ps_command])
651 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4. 
652 dnl Limitation: Only first 16 chars returned for ucomm field
653 dnl Must come before ps -weo
654 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
655         egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
656 then
657         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
658         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
659         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
660         ac_cv_ps_cols=9
661         AC_MSG_RESULT([$ac_cv_ps_command])
663 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
664 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
665         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
666 then
667         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
668         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
669         ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
670         ac_cv_ps_cols=10
671         AC_MSG_RESULT([$ac_cv_ps_command])
673 dnl FreeBSD
674 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
675         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/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 waxco 'state uid pid ppid vsz rss pcpu command command'"
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 BSD-like mode in RH 6.1
684 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
685         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
686 then
687         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
688         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
689         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
690         ac_cv_ps_cols=9
691         AC_MSG_RESULT([$ac_cv_ps_command])
693 dnl SunOS 4.1.3:
694 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
695 dnl Need the head -1 otherwise test will work because arguments are found
696 elif ps -laxnwww 2>/dev/null | head -1 | \
697         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
698 then
699         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
700         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
701         ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
702         ac_cv_ps_cols=9
703         AC_MSG_RESULT([$ac_cv_ps_command])
705 dnl Debian Linux / procps v1.2.9:
706 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
707 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
708 dnl
709 elif ps laxnwww 2>/dev/null | \
710         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
711 then
712         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
713         ac_cv_ps_command="$PATH_TO_PS laxnwww"
714         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
715         ac_cv_ps_cols=9
716         AC_MSG_RESULT([$ac_cv_ps_command])
718 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
719 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
720         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
721 then
722         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
723         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
724         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
725         ac_cv_ps_cols=9
726         AC_MSG_RESULT([$ac_cv_ps_command])
728 dnl Tru64 - needs %*[ +<>] in PS_FORMAT. 
729 dnl Has /usr/bin/ps and /sbin/ps - force sbin version
730 dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead 
731 dnl of 1500). Will need big changes to check_procs to support
732 elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
733         egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
734 then
735         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
736         ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
737         ac_cv_ps_format=["%s%*[ +<>] %d %d %d %f %s %s %n"]
738         ac_cv_ps_cols=8
739         AC_MSG_RESULT([$ac_cv_ps_command])
741 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
742         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
743 then
744         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
745         ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
746         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
747         ac_cv_ps_cols=9
748         AC_MSG_RESULT([$ac_cv_ps_command])
750 dnl AIX 4.3.3 and 5.1 do not have an rss field
751 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
752         egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
753 then
754         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
755         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
756         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
757         ac_cv_ps_cols=8
758         AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
760 dnl Solaris 2.6
761 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
762         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
763 then
764         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
765         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
766         # There must be no space between the %s and %n due to a wierd problem in sscanf where
767         # it will return %n as longer than the line length
768         ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
769         ac_cv_ps_cols=9
770         AC_MSG_RESULT([$ac_cv_ps_command])
772 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
773         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
774 then
775         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
776         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
777         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
778         ac_cv_ps_cols=9
779         AC_MSG_RESULT([$ac_cv_ps_command])
781 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
782         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
783 then
784         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
785         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
786         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
787         ac_cv_ps_cols=9
788         AC_MSG_RESULT([$ac_cv_ps_command])
790 dnl wonder who takes state instead of stat
791 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
792         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
793 then
794         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
795         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
796         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
797         ac_cv_ps_cols=8
798         AC_MSG_RESULT([$ac_cv_ps_command])
800 dnl IRIX 53
801 elif ps -el 2>/dev/null | \
802         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
803 then
804         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
805         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
806         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
807         ac_cv_ps_cols=8
808         AC_MSG_RESULT([$ac_cv_ps_command])
810 dnl IRIX 63
811 elif ps -el 2>/dev/null | \
812         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
813 then
814         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
815         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
816         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
817         ac_cv_ps_cols=6
818         AC_MSG_RESULT([$ac_cv_ps_command])
820 dnl AIX 4.1:
821 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
822 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
823 elif ps -el 2>/dev/null | \
824         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
825 then
826         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
827         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
828         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
829         ac_cv_ps_cols=6
830         AC_MSG_RESULT([$ac_cv_ps_command])
832 dnl AIX?
833 elif ps glaxen 2>/dev/null | \
834         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
835 then
836         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
837         ac_cv_ps_command="$PATH_TO_PS glaxen"
838         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
839         ac_cv_ps_cols=8
840         AC_MSG_RESULT([$ac_cv_ps_command])
842 dnl MacOSX / Darwin
843 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
844 dnl Some truncation will happen in UCOMM column
845 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
846 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
847 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
848         egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
849 then
850         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
851         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
852         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
853         ac_cv_ps_cols=8
854         AC_MSG_RESULT([$ac_cv_ps_command])
856 dnl UnixWare 
857 elif ps -Al 2>/dev/null | \
858         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
859 then
860         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
861         ac_cv_ps_command="$PATH_TO_PS -Al"
862         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
863         ac_cv_ps_cols=8
864         AC_MSG_RESULT([$ac_cv_ps_command])
866 else
867         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
868 fi
870 if test -n "$ac_cv_ps_varlist" ; then
871         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
872                 [Variable list for sscanf of 'ps' output])
873         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
874                 [Verbatim command to execute for ps in check_procs])
875         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
876                 [Format string for scanning ps output in check_procs])
877         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
878                 [Number of columns in ps command])
879         EXTRAS="$EXTRAS check_procs check_nagios"
880 fi
882 AC_PATH_PROG(PATH_TO_PING,ping)
883 AC_PATH_PROG(PATH_TO_PING6,ping6)
885 AC_ARG_WITH(ping_command,
886         ACX_HELP_STRING([--with-ping-command=SYNTAX],
887                 [sets syntax for ICMP ping]),
888         with_ping_command=$withval,)
890 AC_MSG_CHECKING(for ICMP ping syntax)
891 ac_cv_ping_packets_first=no
892 ac_cv_ping_has_timeout=no
893 if test -n "$with_ping_command"
894 then
895         AC_MSG_RESULT([(command-line) $with_ping_command])
896         if test -n "$ac_cv_ping_packets_first"
897         then
898                 ac_cv_ping_packets_first=yes
899         fi
901 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
902         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
903         egrep -i "^round-trip|^rtt" >/dev/null
904 then
905         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
906         ac_cv_ping_packets_first=yes
907         AC_MSG_RESULT([$with_ping_command])
909 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
910         egrep -i "^round-trip|^rtt" >/dev/null
911 then
912         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
913         ac_cv_ping_packets_first=yes
914   ac_cv_ping_has_timeout=yes
915         AC_MSG_RESULT([$with_ping_command])
917 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
918         egrep -i "^round-trip|^rtt" >/dev/null
919 then
920         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
921         ac_cv_ping_packets_first=yes
922         AC_MSG_RESULT([$with_ping_command])
924 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
925         egrep -i "^round-trip|^rtt" >/dev/null
926 then
927         with_ping_command="$PATH_TO_PING -n -c %d %s"
928         ac_cv_ping_packets_first=yes
929         AC_MSG_RESULT([$with_ping_command])
931 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
932         egrep -i "^round-trip|^rtt" >/dev/null
933 then
934         with_ping_command="$PATH_TO_PING -n %s -c %d"
935         AC_MSG_RESULT([$with_ping_command])
937 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
938         egrep -i "^round-trip|^rtt" >/dev/null
939 then
940         with_ping_command="$PATH_TO_PING %s -n %d"
941         AC_MSG_RESULT([$with_ping_command])
943 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
944         egrep -i "^round-trip|^rtt" >/dev/null
945 then
946         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
947         AC_MSG_RESULT([$with_ping_command])
949 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
950         egrep -i "^round-trip|^rtt" >/dev/null
951 then
952         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
953         AC_MSG_RESULT([$with_ping_command])
955 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
956         egrep -i "^round-trip|^rtt" >/dev/null
957 then
958         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
959         ac_cv_ping_packets_first=yes
960         AC_MSG_RESULT([$with_ping_command])
962 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
963         egrep -i "^round-trip|^rtt" >/dev/null
964 then
965         with_ping_command="$PATH_TO_PING -n -c %d %s"
966         ac_cv_ping_packets_first=yes
967         AC_MSG_RESULT([$with_ping_command])
969 else
970         AC_MSG_WARN([unable to find usable ping syntax])
971 fi
973 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
974         [path and args for ICMP ping command])
976 if test "x$ac_cv_ping_packets_first" != "xno"
977 then
978         AC_DEFINE(PING_PACKETS_FIRST,1,
979                 [Define if packet count must precede host])
980 fi
982 if test "x$ac_cv_ping_has_timeout" != "xno"
983 then
984         AC_DEFINE(PING_HAS_TIMEOUT,1,
985                 [Define if ping has its own timeout option that should be set])
986 fi
988 AC_ARG_WITH(ping6_command,
989         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
990                 [sets syntax for ICMPv6 ping]),
991         with_ping6_command=$withval,)
993 if test x"$with_ipv6" != xno ; then
994 AC_MSG_CHECKING(for ICMPv6 ping syntax)
995 ac_cv_ping6_packets_first=no
996 if test -n "$with_ping6_command"
997 then
998         AC_MSG_RESULT([(command-line) $with_ping6_command])
999         if test -n "$ac_cv_ping6_packets_first"
1000         then
1001                 ac_cv_ping6_packets_first=yes
1002         fi
1004 elif test "x$PATH_TO_PING6" != "x"; then
1005         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1006                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1007                 egrep -i "^round-trip|^rtt" >/dev/null
1008         then
1009                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1010                 ac_cv_ping6_packets_first=yes
1011                 AC_MSG_RESULT([$with_ping6_command])
1013         elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
1014                 egrep -i "^round-trip|^rtt" >/dev/null
1015         then
1016                 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
1017                 ac_cv_ping6_packets_first=yes
1018                 ac_cv_ping_has_timeout=yes
1019                 AC_MSG_RESULT([$with_ping6_command])
1021         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1022                 egrep -i "^round-trip|^rtt" >/dev/null
1023         then
1024                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1025                 ac_cv_ping6_packets_first=yes
1026                 AC_MSG_RESULT([$with_ping6_command])
1028         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1029                 egrep -i "^round-trip|^rtt" >/dev/null
1030         then
1031                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1032                 ac_cv_ping6_packets_first=yes
1033                 AC_MSG_RESULT([$with_ping6_command])
1035         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1036                 egrep -i "^round-trip|^rtt" >/dev/null
1037         then
1038                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1039                 AC_MSG_RESULT([$with_ping6_command])
1041         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1042                 egrep -i "^round-trip|^rtt" >/dev/null
1043         then
1044                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1045                 AC_MSG_RESULT([$with_ping6_command])
1047         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1048                 egrep -i "^round-trip|^rtt" >/dev/null
1049         then
1050                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1051                 AC_MSG_RESULT([$with_ping6_command])
1053         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1054                 egrep -i "^round-trip|^rtt" >/dev/null
1055         then
1056                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1057                 AC_MSG_RESULT([$with_ping6_command])
1059         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1060                 egrep -i "^round-trip|^rtt" >/dev/null
1061         then
1062                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1063                 ac_cv_ping6_packets_first=yes
1064                 AC_MSG_RESULT([$with_ping_command])
1066         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1067                 egrep -i "^round-trip|^rtt" >/dev/null
1068         then
1069                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1070                 ac_cv_ping6_packets_first=yes
1071                 AC_MSG_RESULT([$with_ping6_command])
1073         fi
1075 elif test "x$PATH_TO_PING" != "x"; then
1076         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1077                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1078                 egrep -i "^round-trip|^rtt" >/dev/null
1079         then
1080                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1081                 ac_cv_ping6_packets_first=yes
1082                 AC_MSG_RESULT([$with_ping6_command])
1084         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1085                 egrep -i "^round-trip|^rtt" >/dev/null
1086         then
1087                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1088                 ac_cv_ping6_packets_first=yes
1089                 AC_MSG_RESULT([$with_ping6_command])
1091         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1092                 egrep -i "^round-trip|^rtt" >/dev/null
1093         then
1094                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1095                 ac_cv_ping6_packets_first=yes
1096                 AC_MSG_RESULT([$with_ping6_command])
1098         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1099                 egrep -i "^round-trip|^rtt" >/dev/null
1100         then
1101                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1102                 AC_MSG_RESULT([$with_ping6_command])
1104         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1105                 egrep -i "^round-trip|^rtt" >/dev/null
1106         then
1107                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1108                 AC_MSG_RESULT([$with_ping6_command])
1110         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1111                 egrep -i "^round-trip|^rtt" >/dev/null
1112         then
1113                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1114                 AC_MSG_RESULT([$with_ping6_command])
1116         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1117                 egrep -i "^round-trip|^rtt" >/dev/null
1118         then
1119                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1120                 AC_MSG_RESULT([$with_ping6_command])
1122         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1123                 egrep -i "^round-trip|^rtt" >/dev/null
1124         then
1125                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1126                 ac_cv_ping6_packets_first=yes
1127                 AC_MSG_RESULT([$with_ping_command])
1129         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1130                 egrep -i "^round-trip|^rtt" >/dev/null
1131         then
1132                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1133                 ac_cv_ping6_packets_first=yes
1134                 AC_MSG_RESULT([$with_ping6_command])
1136         fi
1138 fi
1140 if test "x$with_ping6_command" != "x"; then
1141         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1142                 [path and args for ICMPv6 ping command])
1143 else
1144         AC_MSG_RESULT([none])
1145 fi
1147 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1148         AC_DEFINE(PING6_PACKETS_FIRST,1,
1149                 [Define if packet count must precede host])
1150 fi
1151 fi
1153 AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1155 AC_MSG_CHECKING(for nslookup syntax)
1156 if test -n "$PATH_TO_NSLOOKUP"
1157 then
1158         if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1159         then
1160                 ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1161                 AC_MSG_RESULT([$ac_cv_nslookup_command])
1163         else
1164                 ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1165                 AC_MSG_RESULT([$ac_cv_nslookup_command])
1167         fi
1168         EXTRAS="$EXTRAS check_dns"
1170 else
1171         AC_MSG_WARN([nslookup command not found])
1172 fi
1174 AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command",
1175         [path and args for nslookup])
1177 AC_PATH_PROG(PATH_TO_HOST,host)
1178 if test -n "$ac_cv_path_PATH_TO_HOST"
1179 then
1180         EXTRAS="$EXTRAS check_dns"
1181 fi
1183 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1184 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1186 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1187 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1189 AC_PATH_PROG(PATH_TO_NTPDATE,ntpdate)
1190 AC_PATH_PROGS(PATH_TO_NTPDC,ntpdc xntpdc)
1191 AC_PATH_PROGS(PATH_TO_NTPQ,ntpq)
1192 if (test -x "$PATH_TO_NTPDATE" || test -x "$PATH_TO_NTPQ")
1193 then
1194         AC_DEFINE_UNQUOTED(PATH_TO_NTPQ,"$PATH_TO_NTPQ",[path to ntpq binary])
1195         AC_DEFINE_UNQUOTED(PATH_TO_NTPDATE,"$PATH_TO_NTPDATE",[path to ntpdate binary])
1196 else
1197         AC_MSG_WARN([Install NTP programs (http://www.ntp.org) if you want to monitor time synchronization])
1198 fi
1200 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1201 if test -x "$PATH_TO_LMSTAT"
1202 then
1203         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1204 else
1205         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1206 fi
1208 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1209 if test -x "$PATH_TO_SMBCLIENT"
1210 then
1211         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1212 else
1213         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1214 fi
1217 AC_PATH_PROG(PATH_TO_WHO,who)
1219 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1220 then
1221         ac_cv_path_to_who="$PATH_TO_WHO -q"
1222 else
1223         ac_cv_path_to_who="$PATH_TO_WHO"
1224 fi
1226 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1227         [path and arguments for invoking 'who'])
1229 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1230 if test -x "$PATH_TO_SNMPGET"
1231 then
1232         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1233         EXTRAS="$EXTRAS check_hpjd check_snmp"
1234 else
1235         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1236 fi
1238 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1239 if test -x "$PATH_TO_SNMPGETNEXT"
1240 then
1241         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1242 fi
1244 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1245 then
1246         AC_MSG_CHECKING(for Net::SNMP perl module)
1247         AC_MSG_RESULT([found])
1248 else
1249         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1250 fi
1252 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1253 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1255 if test -x "$PATH_TO_QUAKESTAT"
1256 then
1257         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1258         EXTRAS="$EXTRAS check_game"
1260 elif test -x "$PATH_TO_QSTAT"
1261 then
1262         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1263         EXTRAS="$EXTRAS check_game"
1264 else
1265         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1266 fi
1268 if test $ac_cv_path_to_qstat 
1269 then
1270         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1271                 [path to qstat/quakestat])
1272 fi
1274 AC_PATH_PROG(PATH_TO_FPING,fping)
1275 if test -x "$PATH_TO_FPING"
1276 then
1277         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1278         EXTRAS="$EXTRAS check_fping"
1279 else
1280         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1281 fi
1283 AC_PATH_PROG(PATH_TO_SSH,ssh)
1285 if test -x "$PATH_TO_SSH"
1286 then
1287         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1288         EXTRAS="$EXTRAS check_by_ssh"
1289 else
1290         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1291 fi
1294 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1295 if test -x "$PATH_TO_MAILQ"
1296 then
1297         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1298 else
1299         AC_MSG_WARN([Could not find mailq or eqivalent])
1300 fi
1302 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1303 if test -x "$PATH_TO_QMAIL_QSTAT"
1304 then
1305         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1306 else
1307         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1308 fi
1310 dnl SWAP info required is amount allocated/available and amount free
1311 dnl The plugin works through all the swap devices and adds up the total swap
1312 dnl available.
1313 AC_PATH_PROG(PATH_TO_SWAP,swap)
1314 if (test -n "$PATH_TO_SWAP")
1315 then
1316 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1317 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1318 then
1319         ac_cv_have_swap=yes
1320         ac_cv_swap_command="$PATH_TO_SWAP -l"
1321         if [$PATH_TO_SWAP -l 2>/dev/null | \
1322                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1323                 >/dev/null]
1324         then
1325                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1326                 ac_cv_swap_conv=2048
1327                 AC_MSG_RESULT([using IRIX format swap])
1329         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1330         then
1331                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1332                 ac_cv_swap_conv=2048
1333                 AC_MSG_RESULT([using Unixware format swap])
1334         else
1335                 dnl if we don't know what format swap's output is
1336                 dnl we might as well pretend we didn't see it
1337                 ac_cv_have_swap=""
1338                 ac_cv_swap_command=""
1339         fi
1340 fi
1341 dnl end if for PATH_TO_SWAP
1342 fi
1344 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1345 if (test -n "$PATH_TO_SWAPINFO")
1346 then
1347 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1348 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1349 then
1350         ac_cv_have_swap=yes
1351         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1353         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1354         then
1355                 ac_cv_swap_format=["%*s %f %*d %f"]
1356                 ac_cv_swap_conv=1024
1357                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1358         fi
1360 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1361 then
1362         ac_cv_have_swap=yes
1363         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM",
1364         ac_cv_swap_format=["%*s %f %*d %f"]
1365         ac_cv_swap_conv=1024
1366         AC_MSG_RESULT([using HP-UX format swapinfo])
1367 fi
1368 dnl end if for PATH_TO_SWAPINFO
1369 fi
1371 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1372 if (test -n "$PATH_TO_LSPS")
1373 then
1374 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1375 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1376 then
1377         ac_cv_have_swap=yes
1378         ac_cv_swap_command="$PATH_TO_LSPS -a"
1379         ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1380         ac_cv_swap_conv=1
1381         AC_MSG_RESULT([using AIX lsps])
1382 fi
1383 dnl end if for PATH_TO_SWAPINFO
1384 fi
1386 dnl
1387 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1388 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1389 dnl in the various BSD's
1390 dnl
1392 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1393 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1394 #ifdef HAVE_SYS_PARAM_H
1395 #include <sys/param.h>
1396 #endif
1397 ])
1398 AC_CHECK_DECLS([swapctl],,,[
1399                #include <unistd.h>
1400                #include <sys/types.h>
1401                #include <sys/param.h>
1402                #include <sys/stat.h>
1403                #include <sys/swap.h>
1404                ])
1405 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1406                #include <sys/types.h>
1407                #include <sys/param.h>
1408                #include <sys/stat.h>
1409                #include <sys/swap.h>
1410                ])
1411 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1412                #include <unistd.h>
1413                #include <sys/types.h>
1414                #include <sys/param.h>
1415                #include <sys/stat.h>
1416                #include <sys/swap.h>
1417                ])
1419 if test "$ac_cv_have_decl_swapctl" = "yes"; 
1420 then
1421         EXTRAS="$EXTRAS check_swap"
1422         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1423         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1424                 "$ac_cv_type_swapent_t" = "yes"; 
1425         then
1426                 AC_MSG_RESULT([yes])
1427                 ac_cv_check_swap_swapctl_svr4="1";
1428                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1429                           [Define if 2-argument SVR4 swapctl exists])
1430         else
1431                 AC_MSG_RESULT([no])
1432                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1433                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes"; 
1434                 then
1435                         AC_MSG_RESULT([yes])
1436                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1437                                   [Define if 3-argument BSD swapctl exists])
1438                 else
1439                         AC_MSG_RESULT([no])
1440                 fi
1441         fi
1442         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1443         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1444         then
1445                 dnl
1446                 dnl the SVR4 spec returns values in pages
1447                 dnl
1448                 AC_MSG_RESULT([page])
1449                 AC_CHECK_DECLS([sysconf])
1450                 AC_MSG_CHECKING([for system page size])
1451                 if test "$ac_cv_have_decl_sysconf" = "yes";
1452                 then
1453                         AC_MSG_RESULT([determined by sysconf(3)])
1454                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1455                 else
1456                         AC_MSG_WARN([don't know. guessing 4096k])
1457                         ac_cv_swap_conv=256
1458                 fi
1459         else
1460                 dnl
1461                 dnl the BSD spec returns values in blocks
1462                 dnl
1463                 AC_MSG_RESULT([blocks (assuming 512b)])
1464                 ac_cv_swap_conv=2048
1465         fi
1466         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1467                 [Conversion factor to MB])
1468 fi
1469 dnl
1470 dnl end tests for the swapctl system calls
1471 dnl
1474 if test "x$ac_cv_have_swap" != "x" 
1475 then
1476         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1477         EXTRAS="$EXTRAS check_swap"
1478 fi
1479 if test "x$ac_cv_swap_command" != "x" 
1480 then
1481         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1482                 [Path to swap/swapinfo binary, with any args])
1483         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1484                 [Format string for parsing swap output])
1485         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1486                 [Conversion factor to MB])
1487 fi
1489 dnl dunno why this does not work below - use hack (kbd)
1490 dnl fine on linux, broken on solaris
1491 dnl if /bin/test -e "/proc/meminfo"
1492 AC_MSG_CHECKING([for /proc/meminfo])
1493 if [cat /proc/meminfo > /dev/null 2>&1]
1494 then
1495         AC_MSG_RESULT([found /proc/meminfo])
1496         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1497         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"/proc/meminfo",[path to /proc/meminfo if name changes])
1498         EXTRAS="$EXTRAS check_swap"
1499 else
1500         AC_MSG_RESULT([no])
1501 fi
1503 AC_PATH_PROG(PATH_TO_DIG,dig)
1504 AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1505 if test -n "$PATH_TO_DIG"; then
1506         EXTRAS="$EXTRAS check_dig"
1507 fi
1509 if test -f plugins/check_nt.c ; then
1510   EXTRAS="$EXTRAS check_nt"
1511 elif test -f ../plugins/check_nt.c ; then
1512   EXTRAS="$EXTRAS check_nt"
1513 fi
1515 AC_MSG_CHECKING(for va_list)
1516 AC_TRY_COMPILE([#ifdef __STDC__
1517                 #include <stdio.h>
1518                 #include <stdlib.h>
1519                 #include <stdarg.h>
1520                 #else
1521                 #include <sys/types.h>
1522                 #include <stdio.h>
1523                 #include <varargs.h>
1524                 #endif],
1525                 [va_list args;],
1526                 [AC_MSG_RESULT(yes)],
1527                 [NEED_VA_LIST=-DNEED_VA_LIST AC_SUBST(NEED_VA_LIST) AC_MSG_RESULT(no)])
1529 case $host in
1530         *bsd*)
1531                 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1532         ;;
1533         *linux*)
1534                 AC_DEFINE(__linux__,1,[sun specific code in check_dhcp.c])
1535         ;;
1536         *sun* | solaris*)
1537                 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1538         ;;
1539         *hpux*)  
1540                 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1541         ;;
1542 esac
1544 AC_SUBST(EXTRAS)
1545 AC_SUBST(EXTRA_NETOBJS)
1546 AC_SUBST(DEPLIBS)
1548 AM_GNU_GETTEXT([no-libtool], [need-ngettext])
1549 AM_GNU_GETTEXT_VERSION(0.11.5)
1551 dnl Check for Redhat spopen problem
1552 dnl Wierd problem where ECHILD is returned from a wait call in error
1553 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1554 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1555 dnl We patch plugins/popen.c
1556 if echo $ac_cv_uname_r | egrep "\.EL$" >/dev/null 2>&1 ; then
1557         AC_MSG_CHECKING(for redhat spopen problem)
1558         ( cd config_test && make && make test ) > /dev/null 2>&1
1559         if test $? -eq 0 ; then
1560                 AC_MSG_RESULT(okay)
1561         else
1562                 AC_MSG_RESULT(error)
1563                 AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, "Problem on redhat with spopen")
1564         fi
1565 fi
1567 dnl External libraries - see ACKNOWLEDGEMENTS
1568 np_COREUTILS
1569 np_CURL
1571 AC_OUTPUT(
1572   Makefile 
1573   lib/Makefile 
1574   m4/Makefile 
1575   plugins/Makefile 
1576   plugins-root/Makefile
1577   plugins-scripts/Makefile 
1578   plugins-scripts/subst 
1579   plugins-scripts/utils.pm 
1580   plugins-scripts/utils.sh 
1581   command.cfg 
1582   test.pl 
1583   pkg/solaris/pkginfo 
1584   intl/Makefile
1585   po/Makefile.in 
1588 ACX_FEATURE([with],[perl])
1589 ACX_FEATURE([with],[cgiurl])
1590 ACX_FEATURE([with],[nagios-user])
1591 ACX_FEATURE([with],[nagios-group])
1592 ACX_FEATURE([with],[trusted-path])
1593 ACX_FEATURE([with],[ping-command])
1594 ACX_FEATURE([with],[ping6-command])
1595 ACX_FEATURE([with],[lwres])
1596 ACX_FEATURE([with],[ipv6])
1597 ACX_FEATURE([with],[openssl])
1598 ACX_FEATURE([enable],[emulate-getaddrinfo])