Code

Patch from Russell Miller which adds elapsed time as a metric. Only for linux so...
[nagiosplug.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_REVISION ($Revision$)
3 AC_PREREQ(2.50)
4 AC_INIT(nagios-plugins,1.4.0-alpha3)
5 AC_CONFIG_SRCDIR(Helper.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 AC_GNU_SOURCE
20 AC_PROG_CC
21 AC_PROG_CPP
22 AC_PROG_GCC_TRADITIONAL
23 AC_PROG_RANLIB
24 AC_AIX
25 AC_MINIX
27 AC_PROG_MAKE_SET
28 AC_PROG_AWK
30 AC_FUNC_MALLOC
31 AC_FUNC_REALLOC
32 jm_PREREQ_ERROR
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(PERL,perl)
105 AC_PATH_PROG(SH,sh)
107 AC_PATH_PROG(HOSTNAME,hostname)
108 AC_PATH_PROG(BASENAME,basename)
110 dnl
111 dnl Check for miscellaneous stuff
112 dnl 
114 case $host_vender-$host_os in
115 sun*)
116         AC_DEFINE(__EXTENSIONS__,1,[Sun's netdb.h needs this for getaddrinfo])
117         ;;
118 osf*)
119         AC_DEFINE(_OSF_SOURCE,1,[OSF needs this for getaddrinfo])
120         ;;
121 esac
123 dnl
124 dnl Checks for libraries.
125 dnl
127 AC_CHECK_LIB(dce,main,SOCKETLIBS="$SOCKETLIBS -ldce")
128 AC_CHECK_LIB(nsl,main,SOCKETLIBS="$SOCKETLIBS -lnsl")
129 AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket")
130 AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv")
131 AC_SUBST(SOCKETLIBS)
133 dnl Check for PostgreSQL libraries
134 _SAVEDLIBS="$LIBS"
135 _SAVEDCPPFLAGS="$CPPFLAGS"
136 AC_ARG_WITH(pgsql,
137         ACX_HELP_STRING([--with-pgsql=DIR],
138                 [sets path to pgsql installation]),
139         PGSQL=$withval,)
140 AC_CHECK_LIB(crypt,main)
141 if test "$ac_cv_lib_crypt_main" = "yes"; then
142   if test -n "$PGSQL"; then
143     LDFLAGS="$LDFLAGS -L$PGSQL/lib"
144     CPPFLAGS="$CPPFLAGS -I$PGSQL/include"
145   fi
146   AC_CHECK_LIB(pq,PQsetdbLogin,,,-lcrypt)
147   if test "$ac_cv_lib_pq_PQsetdbLogin" = "yes"; then
148     AC_CHECK_HEADERS(pgsql/libpq-fe.h)
149     AC_CHECK_HEADERS(postgresql/libpq-fe.h)
150     AC_CHECK_HEADERS(libpq-fe.h)
151     if [[ -n "$PGSQL" -a "$ac_cv_header_libpq_fe_h" = "yes" ]]; then
152       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
153       PGINCLUDE="-I$PGSQL/include"
154     elif test  "$ac_cv_header_pgsql_libpq_fe_h" = "yes"; then
155       PGLIBS="-lpq -lcrypt"
156       PGINCLUDE="-I/usr/include/pgsql"
157     elif test  "$ac_cv_header_postgresql_libpq_fe_h" = "yes"; then
158       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
159       PGINCLUDE="-I/usr/include/postgresql"
160     elif test  "$ac_cv_header_libpq_fe_h" = "yes"; then
161       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
162       PGINCLUDE="-I$PGSQL/include"
163     fi
164     if test -z "$PGINCLUDE"; then
165       AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
166       AC_MSG_WARN([install PostgreSQL headers to compile this plugin (see REQUIREMENTS).])
167     else
168       AC_SUBST(PGLIBS)
169       AC_SUBST(PGINCLUDE)
170       EXTRAS="$EXTRAS check_pgsql"
171     fi
172   else
173     AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
174     AC_MSG_WARN([LIBS="$LIBS" CPPFLAGS="$CPPFLAGS"])
175     AC_MSG_WARN([install PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
176   fi
177 else
178   AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
179   AC_MSG_WARN([install lib crypt and PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
180 fi
181 LIBS="$_SAVEDLIBS"
182 CPPFLAGS="$_SAVEDCPPFLAGS"
184 dnl Check for radius libraries
185 _SAVEDLIBS="$LIBS"
186 AC_CHECK_LIB(radiusclient,rc_read_config)
187 if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
188   EXTRAS="$EXTRAS check_radius"
189         RADIUSLIBS="-lradiusclient"
190   AC_SUBST(RADIUSLIBS)
191 else
192   AC_MSG_WARN([Skipping radius plugin])
193   AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
194 fi
195 LIBS="$_SAVEDLIBS"
197 dnl Check for LDAP libraries
198 _SAVEDLIBS="$LIBS"
199 AC_CHECK_LIB(ldap,main,,,-llber)
200 if test "$ac_cv_lib_ldap_main" = "yes"; then
201   LDAPLIBS="-lldap -llber"\
202   LDAPINCLUDE="-I/usr/include/ldap"
203   AC_SUBST(LDAPLIBS)
204   AC_SUBST(LDAPINCLUDE)
205   AC_CHECK_FUNCS(ldap_set_option)
206   EXTRAS="$EXTRAS check_ldap"
207 else
208   AC_MSG_WARN([Skipping LDAP plugin])
209   AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
210 fi
211 LIBS="$_SAVEDLIBS"
214 dnl Check for mysql libraries
215 _SAVEDLIBS="$LIBS"
216 _SAVEDCPPFLAGS="$CPPFLAGS"
217 AC_ARG_WITH(mysql,
218         ACX_HELP_STRING([--with-mysql=DIR],
219                 [sets path to mysql installation (assumes lib/mysql and include subdirs]),
220         MYSQL=$withval,)
221 if test -n "$MYSQL"; then
222   MYSQLLIBDIR=$MYSQL/lib/mysql
223   CPPFLAGS="-I$MYSQL/include"
224   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L$MYSQLLIBDIR ",,-L$MYSQLLIBDIR -lz)
225   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
226 elif test -f /usr/lib/libmysqlclient.so; then
227   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
228   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
229 elif test -f /usr/lib/libmysqlclient.a; then
230   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
231   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
232 elif test -f /usr/lib/mysql/libmysqlclient.so; then
233   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
234   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
235 elif test -f /usr/lib/mysql/libmysqlclient.a; then
236   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
237   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
238 fi
239 if test "$ac_cv_lib_mysqlclient_mysql_init" = "yes" -o "$ac_cv_lib_mysqlclient_mysql_close" = "yes"; then
240   AC_CHECK_HEADERS(mysql/mysql.h mysql/errmsg.h, MYSQLINCLUDE="-I$MYSQL/include" )
241   if test "$ac_cv_header_mysql_mysql_h" = "yes" -a "$ac_cv_header_mysql_errmsg_h" = "yes"; then
242     EXTRAS="$EXTRAS check_mysql"
243     AC_SUBST(MYSQLINCLUDE)
244     AC_SUBST(MYSQLLIBS)
245     AC_SUBST(check_mysql_LDFLAGS)
246   else
247     AC_MSG_WARN([Skipping mysql plugin])
248     AC_MSG_WARN([install mysql client headers to compile this plugin (see REQUIREMENTS).])
249   fi
250 else
251   AC_MSG_WARN([Skipping mysql plugin])
252   AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
253 fi
254 CPPFLAGS="$_SAVEDCPPFLAGS $MYSQLINCLUDE"
255 LIBS="$_SAVEDLIBS"
257 dnl Check for OpenSSL location
258 AC_PATH_PROG(OPENSSL,openssl)
259 if test "$OPENSSL" = "/usr/bin/openssl"; then
260   OPENSSL=/usr
261 elif test "$OPENSSL" = "/usr/sbin/openssl"; then
262   OPENSSL=/usr
263 elif test "$OPENSSL" = "/opt/bin/openssl"; then
264   OPENSSL=/opt
265 elif test "$OPENSSL" = "/opt/openssl/bin/openssl"; then
266   OPENSSL=/opt/openssl
267 elif test "$OPENSSL" = "/usr/slocal/bin/openssl"; then
268   OPENSSL=/usr/slocal
269 elif test "$OPENSSL" = "/usr/local/bin/openssl"; then
270   OPENSSL=/usr/local
271 elif test "$OPENSSL" = "/usr/local/ssl/bin/openssl"; then
272   OPENSSL=/usr/local/ssl
273 fi
274 AC_ARG_WITH(openssl,
275         ACX_HELP_STRING([--with-openssl=DIR],
276                 [sets path to openssl installation]),
277         OPENSSL=$withval,)
279 AC_CHECK_HEADERS(unistd.h)
281 dnl Check for AF_INET6 support - unistd.h required for Darwin
282 AC_CACHE_CHECK([for IPv6 support], with_ipv6, [
283         AC_TRY_COMPILE([#ifdef HAVE_UNISTD_H
284                         #include <unistd.h>
285                         #endif
286                         #include <netinet/in.h>
287                         #include <sys/socket.h>],
288                         [struct sockaddr_in6 sin6;
289                         void *p;
291                         sin6.sin6_family = AF_INET6;
292                         sin6.sin6_port = 587;
293                         p = &sin6.sin6_addr;],
294                         [with_ipv6=yes], 
295                         [with_ipv6=no])
296         ])
298 if test x"$with_ipv6" != xno ; then
299         AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
300 fi
302 dnl #########################################################################
303 dnl Check if Posix getaddrinfo() is available.  It is also possible to use
304 dnl the version from the lwres library distributed with BIND.
305 dnl #########################################################################
306 AC_ARG_ENABLE([emulate-getaddrinfo],
307               ACX_HELP_STRING([--enable-emulate-getaddrinfo],
308                              [enable getaddrinfo emulation (default=no)]),
309               ,
310               enable_emulate_getaddrinfo=no)
312 AC_ARG_WITH(lwres,
313             ACX_HELP_STRING([--with-lwres=DIR],
314                            [use lwres library for getaddrinfo (default=no)]),
315             ,
316             with_lwres=no)
318 dnl ## enable force to test getaddrinfo.c
319 if test x$enable_emulate_getaddrinfo = xforce ; then
320         enable_emulate_getaddrinfo=yes
321         have_getaddrinfo=no
322 else
324 have_getaddrinfo=no
325 if test x$with_lwres != xno ; then
326         if test "$with_lwres" != yes ; then
327                    CPPFLAGS="-I${with_lwres}/include $CPPFLAGS"
328                    LDFLAGS="-L${with_lwres}/lib $LDFLAGS"
329         fi
330         AC_CHECK_HEADERS(lwres/netdb.h, ,
331                         [AC_MSG_ERROR([cannot find <lwres/netdb.h>])])
332         AC_CHECK_LIB(lwres, lwres_getaddrinfo, ,
333                      [AC_MSG_ERROR([cannot find the lwres library])],
334                      -lnsl -lpthread)
335         have_getaddrinfo=yes
336 fi
338 if test x$have_getaddrinfo != xyes ; then
339         AC_SEARCH_LIBS(getaddrinfo, socket resolv bind nsl c_r cr, have_getaddrinfo=yes)
340 fi
342 dnl # Special nonsense for systems that actually have getaddrinfo but
343 dnl # redefine the name to something else, e.g. OSF
344 if test x$have_getaddrinfo != xyes ; then
345         AC_MSG_CHECKING(if getaddrinfo is redefined in netdb.h)
346         AC_TRY_LINK([
347 #               include <netdb.h>
348         ], [
349                 struct addrinfo hints, *res;
350                 int err;
352                 err = getaddrinfo ("host", "service", &hints, &res);
353         ], [
354                 have_getaddrinfo=yes
355                 AC_MSG_RESULT(yes)
356         ], [AC_MSG_RESULT(no)])
357 fi
359 fi
361 if test x$have_getaddrinfo != xno ; then
362         if test x$enable_emulate_getaddrinfo != xno ; then
363                 AC_MSG_ERROR([getaddrinfo found but emulate-getaddrinfo was enabled])
364         fi
365         AC_DEFINE(HAVE_GETADDRINFO, 1,
366                   [Does system provide RFC 2553/Posix getaddrinfo?])
367 else
368         if test x$enable_emulate_getaddrinfo != xyes ; then
369 dnl                AC_MSG_ERROR([getaddrinfo not found: try --with-lwres or --enable-emulate-getaddrinfo])
370                enable_emulate_getaddrinfo=yes
371                AC_MSG_WARN([enabling getaddrinfo emulation])
372         fi
373         EXTRA_NETOBJS="$EXTRA_NETOBJS getaddrinfo.o"
374 fi
376 if test x"$enable_emulate_getaddrinfo" != xno ; then
377     have_resolver=no
379   dnl  Try for getipnodebyname
380     AC_SEARCH_LIBS(getipnodebyname, resolv bind nsl c_r cr, have_resolver=yes)
381     if test x"$have_resolver" != xno ; then
382          AC_DEFINE(HAVE_GETIPNODEBYNAME, 1,
383                    [Set when getipnodebyname is available])
384     fi
386   dnl  Try for gethostbyname_r
387     if test x"$have_resolver" = xno ; then
388         AC_SEARCH_LIBS(gethostbyname_r, resolv bind nsl c_r cr,
389                        [have_resolver=yes
390                         ACX_WHICH_GETHOSTBYNAME_R])
391     fi
393   dnl  Try for gethostbyname
394     if test x"$have_resolver" = xno ; then
395         if test x"$enable_pthreads" != xno ; then
396             AC_MSG_WARN([using threads but cannot find gethostbyname_r or getipnodebyname])
397         fi
398         AC_SEARCH_LIBS(gethostbyname, resolv bind nsl, ,
399                        [AC_MSG_ERROR([cannot find gethostbyname])])
400     fi
401     EXTRA_NETOBJS="$EXTRA_NETOBJS gethostbyname.o"
403 fi
405 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
406 if test "$FOUNDINCLUDE" = "no"; then
407   _SAVEDCPPFLAGS="$CPPFLAGS"
408   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
409   unset ac_cv_header_krb5_h
410   AC_CHECK_HEADERS(krb5.h,
411                    KRB5INCLUDE="-I/usr/kerberos/include"
412                    FOUNDINCLUDE=yes,
413                    FOUNDINCLUDE=no)
414 fi
415 AC_SUBST(KRBINCLUDE)
416 if test "$FOUNDINCLUDE" = "no"; then
417   CPPFLAGS="$_SAVEDCPPFLAGS"
418 fi
420 dnl Check for OpenSSL header files
421 unset FOUNDINCLUDE
422 _SAVEDCPPFLAGS="$CPPFLAGS"
423 if test "$OPENSSL" != "/usr"; then
424   CPPFLAGS="$CPPFLAGS -I$OPENSSL/include"
425 fi
426 AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
427                  SSLINCLUDE="-I$OPENSSL/include"
428                  FOUNDINCLUDE=yes,
429                  FOUNDINCLUDE=no)
430 if test "$FOUNDINCLUDE" = "no"; then
431   AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
432                    SSLINCLUDE="-I$OPENSSL/include"
433                    FOUNDINCLUDE=yes,
434                    FOUNDINCLUDE=no)
435 fi
436 AC_SUBST(SSLINCLUDE)
437 if test "$FOUNDINCLUDE" = "no"; then
438   CPPFLAGS="$_SAVEDCPPFLAGS"
439 fi
441 dnl Check for crypto lib
442 _SAVEDLIBS="$LIBS"
443 AC_CHECK_LIB(crypto,CRYPTO_lock,,,-L$OPENSSL/lib)
444 if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
445   dnl Check for SSL lib
446   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)
447 fi
448 LIBS="$_SAVEDLIBS"
450 dnl test headers and libs to decide whether check_http should use SSL
451 if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
452   if test "$ac_cv_lib_ssl_main" = "yes"; then
453     if test "$FOUNDINCLUDE" = "yes"; then
454       check_tcp_ssl="check_simap check_spop check_jabber check_nntps"
455       AC_SUBST(check_tcp_ssl)
456       AC_SUBST(SSLLIBS)
457       AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
458     fi
459   fi
460 fi
461 CPPFLAGS="$_SAVEDCPPFLAGS"
463 dnl
464 dnl Checks for header files.
465 dnl
467 AC_HEADER_STDC
468 AC_HEADER_TIME
469 AC_HEADER_SYS_WAIT
470 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)
471 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h stdlib.h)
472 AC_CHECK_HEADERS(limits.h sys/param.h)
473 AC_CHECK_HEADERS([sys/mount.h],[],[],[
474 #ifdef HAVE_SYS_PARAM_H
475 #include <sys/param.h>
476 #endif
477 ])
478 AC_CHECK_HEADERS(sys/vfs.h sys/fs/s5param.h sys/filsys.h fcntl.h sys/statfs.h sys/dustat.h sys/statvfs.h)
480 # glibc 2.3.2 stdlib.h does not define HUGE_VAL (see man strtod)
481 AC_MSG_CHECKING([for HUGE_VAL in <stdlib.h>])
482 AC_TRY_COMPILE([#include <stdlib.h>],
483                [double x = HUGE_VAL;],
484                [AC_MSG_RESULT(yes)],
485                [AC_MSG_RESULT(no)
486                 AC_MSG_CHECKING([for HUGE_VAL in <math.h>])
487                 AC_TRY_COMPILE([#include <math.h>],
488                                [double x = HUGE_VAL;],
489                                [AC_MSG_RESULT(yes)
490                                 AC_DEFINE_UNQUOTED(HUGE_VAL_NEEDS_MATH_H, 1,
491                                                   [Define if <math.h> is required for HUGE_VAL])],
492                                [AC_MSG_RESULT(no)])])
494 # Define HAVE_INTTYPES_H if <inttypes.h> exists,
495 # doesn't clash with <sys/types.h>, and declares uintmax_t.
497 AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
498 [AC_TRY_COMPILE(
499   [#include <sys/types.h>
500 #include <inttypes.h>],
501   [uintmax_t i = (uintmax_t) -1;],
502   jm_ac_cv_header_inttypes_h=yes,
503   jm_ac_cv_header_inttypes_h=no)])
505 if test $jm_ac_cv_header_inttypes_h = yes; then
506   AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1,
507 [Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
508    and declares uintmax_t. ])
509 fi
511 # Check for SunOS statfs brokenness wrt partitions 2GB and larger.
512 # If <sys/vfs.h> exists and struct statfs has a member named f_spare,
513 # enable the work-around code in fsusage.c.
514 AC_MSG_CHECKING([for statfs that truncates block counts])
515 AC_CACHE_VAL(fu_cv_sys_truncating_statfs,
516 [AC_TRY_COMPILE([
517 #if !defined(sun) && !defined(__sun)
518 choke -- this is a workaround for a Sun-specific problem
519 #endif
520 #include <sys/types.h>
521 #include <sys/vfs.h>],
522 [struct statfs t; long c = *(t.f_spare);],
523 fu_cv_sys_truncating_statfs=yes
524 AC_MSG_RESULT(yes),
525 fu_cv_sys_truncating_statfs=no
526 AC_MSG_RESULT(no),
527 )])
528 if test $fu_cv_sys_truncating_statfs = yes; then
529   AC_DEFINE(STATFS_TRUNCATES_BLOCK_COUNTS, 1,
530 [  Define if the block counts reported by statfs may be truncated to 2GB
531    and the correct values may be stored in the f_spare array.
532    (SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem.
533    SunOS 4.1.1 seems not to be affected.)])
534 fi
536 dnl Checks for typedefs, structures, and compiler characteristics.
537 AC_C_CONST
538 AC_STRUCT_TM
539 AC_TYPE_PID_T
540 AC_TYPE_SIZE_T
541 AC_TYPE_SIGNAL
543 AC_CHECK_SIZEOF(int,cross)
544 AC_CHECK_SIZEOF(long,cross)
545 AC_CHECK_SIZEOF(short,cross)
547 AC_CACHE_CHECK([for long long],ac_cv_have_longlong,[
548 AC_TRY_RUN([#include <stdio.h>
549 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
550 ac_cv_have_longlong=yes,ac_cv_have_longlong=no,ac_cv_have_longlong=cross)])
551 if test x"$ac_cv_have_longlong" = x"yes"; then
552     AC_DEFINE(HAVE_LONGLONG,1,[Define if system has long long type])
553 fi
556 # Check if the compiler supports the LL prefix on long long integers.
557 # AIX needs this.
559 AC_CACHE_CHECK([for LL suffix on long long integers],ac_cv_compiler_supports_ll, [
560     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
561         ac_cv_compiler_supports_ll=yes,ac_cv_compiler_supports_ll=no)])
562 if test x"$ac_cv_compiler_supports_ll" = x"yes"; then
563    AC_DEFINE(COMPILER_SUPPORTS_LL,1,[Define if compiler support long long])
564 fi
566 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
567 AC_TRY_LINK([#include <stdarg.h>
568 va_list ap1,ap2;], [va_copy(ap1,ap2);],
569 ac_cv_HAVE_VA_COPY=yes,
570 ac_cv_HAVE_VA_COPY=no)])
571 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
572     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
573 else    
574     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
575     AC_TRY_LINK([#include <stdarg.h>
576     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
577     ac_cv_HAVE___VA_COPY=yes,
578     ac_cv_HAVE___VA_COPY=no)])
579     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
580         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
581     fi
582 fi
584 AC_CHECK_FUNCS(vsnprintf snprintf asprintf vasprintf)
585 AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[
586 AC_TRY_RUN([
587 #include <sys/types.h>
588 #include <stdarg.h>
589 void foo(const char *format, ...) { 
590        va_list ap;
591        int len;
592        char buf[5];
594        va_start(ap, format);
595        len = vsnprintf(buf, 0, format, ap);
596        va_end(ap);
597        if (len != 5) exit(1);
599        va_start(ap, format);
600        len = vsnprintf(0, 0, format, ap);
601        va_end(ap);
602        if (len != 5) exit(1);
604        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
606        exit(0);
608 main() { foo("hello"); }
609 ],
610 ac_cv_HAVE_C99_VSNPRINTF=yes,ac_cv_HAVE_C99_VSNPRINTF=no,ac_cv_HAVE_C99_VSNPRINTF=cross)])
611 if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
612     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Define if system has C99 compatible vsnprintf])
613 fi
615 AC_TRY_COMPILE([#include <sys/time.h>],
616                [struct timeval *tv;
617                 struct timezone *tz;],
618                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
619                AC_TRY_COMPILE([#include <sys/time.h>],
620                               [struct timeval *tv;
621                                struct timezone *tz;
622                                gettimeofday(tv, tz);],
623                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
624                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
626 dnl Checks for library functions.
627 AC_CHECK_FUNCS(memmove select socket strdup strstr strtod strtol strtoul)
629 AC_MSG_CHECKING(return type of socket size)
630 AC_TRY_COMPILE([#include <stdlib.h>
631                 #include <sys/types.h>
632                 #include <sys/socket.h>],
633                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
634                ac_cv_socket_size_type=["size_t"]
635                 AC_MSG_RESULT(size_t),
636                ac_cv_socket_size_type=["int"]
637                 AC_MSG_RESULT(int))
639 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
640         [Define type of socket size])
642 if test -f "/proc/loadavg"
643 then
644   AC_DEFINE(HAVE_PROC_LOADAVG,1,[Define if /proc/loadavg or similar exists])
645   AC_DEFINE_UNQUOTED(PROC_LOADAVG,"/proc/loadavg",[Location of /proc/loadavg])
646 fi
648 dnl #### Process table test
650 AC_PATH_PROG(PATH_TO_PS,ps)
652 AC_MSG_CHECKING(for ps syntax)
653 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
654 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
655 if ps -axwo 'stat comm vsz rss user uid ppid args' 2>/dev/null | \
656         egrep -i ["^ *STAT +UCOMM +VSZ +RSS +USER +UID +PPID +COMMAND"] > /dev/null
657 then
658         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
659         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid ppid vsz rss pcpu comm args'"
660         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
661         ac_cv_ps_cols=8
662         AC_MSG_RESULT([$ac_cv_ps_command])
664 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
665 elif ps -weo 'stat comm vsz rss user uid ppid etime args' 2>/dev/null | \
666         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
667 then
668         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
669         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid ppid vsz rss pcpu etime comm args'"
670         ac_cv_ps_format="%s %d %d %d %d %f %s %s %n"
671         ac_cv_ps_cols=9
672         AC_MSG_RESULT([$ac_cv_ps_command])
674 dnl FreeBSD
675 elif ps waxco 'state command vsz rss uid user ppid' 2>/dev/null | \
676         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PPID"] >/dev/null
677 then
678         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
679         ac_cv_ps_command="$PATH_TO_PS waxco 'state uid ppid vsz rss pcpu command command'"
680         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
681         ac_cv_ps_cols=8
682         AC_MSG_RESULT([$ac_cv_ps_command])
684 dnl BSD-like mode in RH 6.1
685 elif ps waxno 'state comm vsz rss uid user ppid args' 2>/dev/null | \
686         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null
687 then
688         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
689         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid ppid vsz rss pcpu comm args'"
690         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
691         ac_cv_ps_cols=8
692         AC_MSG_RESULT([$ac_cv_ps_command])
694 dnl SunOS 4.1.3:
695 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
696 dnl Need the head -1 otherwise test will work because arguments are found
697 elif ps -laxnwww 2>/dev/null | head -1 | \
698         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
699 then
700         ac_cv_ps_varlist="[&procuid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
701         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
702         ac_cv_ps_format="%*s %d %*s %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
703         ac_cv_ps_cols=8
704         AC_MSG_RESULT([$ac_cv_ps_command])
706 dnl Debian Linux / procps v1.2.9:
707 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
708 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
709 dnl
710 elif ps laxnwww 2>/dev/null | \
711         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
712 then
713         ac_cv_ps_varlist="[&procuid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
714         ac_cv_ps_command="$PATH_TO_PS laxnwww"
715         ac_cv_ps_format="%*s %d %*s %d %*s %*s %d %d %*s %s %*s %*s %n%s"
716         ac_cv_ps_cols=8
717         AC_MSG_RESULT([$ac_cv_ps_command])
719 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
720 elif ps -axo 'stat comm vsz rss user uid ppid args' 2>/dev/null | \
721         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
722 then
723         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
724         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid ppid vsz rss pcpu comm args'"
725         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
726         ac_cv_ps_cols=8
727         AC_MSG_RESULT([$ac_cv_ps_command])
729 dnl Tru64 - needs %*[ +] in PS_FORMAT
730 elif ps -ao 'stat comm vsz rss user uid ppid args' 2>/dev/null | \
731         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
732 then
733         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
734         ac_cv_ps_command="$PATH_TO_PS -ao 'stat uid ppid vsz rss pcpu comm args'"
735         ac_cv_ps_format=["%s%*[ +] %d %d %d %d %f %s %n"]
736         ac_cv_ps_cols=8
737         AC_MSG_RESULT([$ac_cv_ps_command])
739 elif ps -eo 's comm vsz rss user uid ppid args' 2>/dev/null | \
740         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
741 then
742         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
743         ac_cv_ps_command="$PATH_TO_PS -eo 's uid ppid vsz rss pcpu comm args'"
744         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
745         ac_cv_ps_cols=8
746         AC_MSG_RESULT([$ac_cv_ps_command])
748 dnl AIX 4.3.3 and 5.1 do not have an rss field
749 elif ps -eo 'stat uid ppid vsz pcpu comm args' 2>/dev/null | \
750         egrep -i ["^ *S[TAUES]* +UID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
751 then
752         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
753         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid ppid vsz pcpu comm args'"
754         ac_cv_ps_format="%s %d %d %d %f %s %n"
755         ac_cv_ps_cols=7
756         AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
758 dnl Solaris 2.6
759 elif ps -Ao 's comm vsz rss uid user ppid args' 2>/dev/null | \
760         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null
761 then
762         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
763         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid ppid vsz rss pcpu comm args'"
764         # There must be no space between the %s and %n due to a wierd problem in sscanf where
765         # it will return %n as longer than the line length
766         ac_cv_ps_format="%s %d %d %d %d %f %s%n"
767         ac_cv_ps_cols=8
768         AC_MSG_RESULT([$ac_cv_ps_command])
770 elif ps -Ao 'status comm vsz rss uid user ppid args' 2>/dev/null | \
771         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null
772 then
773         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
774         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid ppid vsz rss pcpu comm args'"
775         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
776         ac_cv_ps_cols=8
777         AC_MSG_RESULT([$ac_cv_ps_command])
779 elif ps -Ao 'state comm vsz rss uid user ppid args' 2>/dev/null | \
780         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null
781 then
782         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
783         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid ppid vsz rss pcpu comm args'"
784         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
785         ac_cv_ps_cols=8
786         AC_MSG_RESULT([$ac_cv_ps_command])
788 dnl wonder who takes state instead of stat
789 elif ps -ao 'state command vsz rss user ppid args' 2>/dev/null | \
790         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null
791 then
792         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
793         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid ppid vsz rss pcpu command args'"
794         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
795         ac_cv_ps_cols=7
796         AC_MSG_RESULT([$ac_cv_ps_command])
798 dnl IRIX 53
799 elif ps -el 2>/dev/null | \
800         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
801 then
802         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&pos,procprog]"
803         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
804         ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
805         ac_cv_ps_cols=7
806         AC_MSG_RESULT([$ac_cv_ps_command])
808 dnl IRIX 63
809 elif ps -el 2>/dev/null | \
810         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
811 then
812         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&pos,procprog]"
813         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
814         ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
815         ac_cv_ps_cols=5
816         AC_MSG_RESULT([$ac_cv_ps_command])
818 dnl AIX 4.1:
819 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
820 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
821 elif ps -el 2>/dev/null | \
822         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
823 then
824         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&pos,procprog]"
825         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
826         ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
827         ac_cv_ps_cols=5
828         AC_MSG_RESULT([$ac_cv_ps_command])
830 dnl AIX?
831 elif ps glaxen 2>/dev/null | \
832         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
833 then
834         ac_cv_ps_varlist="[&procuid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
835         ac_cv_ps_command="$PATH_TO_PS glaxen"
836         ac_cv_ps_format="%*s %d %*s %d %*s %*s %d %d %*s %s %*s %*s %n%s"
837         ac_cv_ps_cols=7
838         AC_MSG_RESULT([$ac_cv_ps_command])
840 dnl MacOSX / Darwin
841 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
842 dnl Some truncation will happen in UCOMM column
843 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
844 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
845 elif ps wwaxo 'state vsz rss uid ppid pcpu ucomm command' 2>/dev/null | \
846         egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
847 then
848         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid ppid pcpu ucomm command'"
849         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procppid,&procpcpu,procprog,&pos]"
850         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
851         ac_cv_ps_cols=7
852         AC_MSG_RESULT([$ac_cv_ps_command])
854 dnl UnixWare 
855 elif ps -Al 2>/dev/null | \
856         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
857 then
858         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&pos,procprog]"
859         ac_cv_ps_command="$PATH_TO_PS -Al"
860         ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
861         ac_cv_ps_cols=7
862         AC_MSG_RESULT([$ac_cv_ps_command])
864 else
865         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
866 fi
868 if test -n "$ac_cv_ps_varlist" ; then
869         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
870                 [Variable list for sscanf of 'ps' output])
871         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
872                 [Verbatim command to execute for ps in check_procs])
873         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
874                 [Format string for scanning ps output in check_procs])
875         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
876                 [Number of columns in ps command])
877         EXTRAS="$EXTRAS check_procs check_nagios"
878 fi
880 dnl jm_AFS
881 jm_LIST_MOUNTED_FILESYSTEMS([list_mounted_fs=yes], [list_mounted_fs=no])
882 jm_FSTYPENAME
883 jm_FILE_SYSTEM_USAGE([space=yes], [space=no])
885 AC_PATH_PROG(PATH_TO_PING,ping)
886 AC_PATH_PROG(PATH_TO_PING6,ping6)
888 AC_ARG_WITH(ping_command,
889         ACX_HELP_STRING([--with-ping-command=SYNTAX],
890                 [sets syntax for ICMP ping]),
891         with_ping_command=$withval,)
893 AC_MSG_CHECKING(for ICMP ping syntax)
894 ac_cv_ping_packets_first=no
895 ac_cv_ping_has_timeout=no
896 if test -n "$with_ping_command"
897 then
898         AC_MSG_RESULT([(command-line) $with_ping_command])
899         if test -n "$ac_cv_ping_packets_first"
900         then
901                 ac_cv_ping_packets_first=yes
902         fi
904 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
905         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
906         egrep -i "^round-trip|^rtt" >/dev/null
907 then
908         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
909         ac_cv_ping_packets_first=yes
910         AC_MSG_RESULT([$with_ping_command])
912 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
913         egrep -i "^round-trip|^rtt" >/dev/null
914 then
915         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
916         ac_cv_ping_packets_first=yes
917   ac_cv_ping_has_timeout=yes
918         AC_MSG_RESULT([$with_ping_command])
920 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
921         egrep -i "^round-trip|^rtt" >/dev/null
922 then
923         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
924         ac_cv_ping_packets_first=yes
925         AC_MSG_RESULT([$with_ping_command])
927 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
928         egrep -i "^round-trip|^rtt" >/dev/null
929 then
930         with_ping_command="$PATH_TO_PING -n -c %d %s"
931         ac_cv_ping_packets_first=yes
932         AC_MSG_RESULT([$with_ping_command])
934 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
935         egrep -i "^round-trip|^rtt" >/dev/null
936 then
937         with_ping_command="$PATH_TO_PING -n %s -c %d"
938         AC_MSG_RESULT([$with_ping_command])
940 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
941         egrep -i "^round-trip|^rtt" >/dev/null
942 then
943         with_ping_command="$PATH_TO_PING %s -n %d"
944         AC_MSG_RESULT([$with_ping_command])
946 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
947         egrep -i "^round-trip|^rtt" >/dev/null
948 then
949         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
950         AC_MSG_RESULT([$with_ping_command])
952 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
953         egrep -i "^round-trip|^rtt" >/dev/null
954 then
955         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
956         AC_MSG_RESULT([$with_ping_command])
958 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
959         egrep -i "^round-trip|^rtt" >/dev/null
960 then
961         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
962         ac_cv_ping_packets_first=yes
963         AC_MSG_RESULT([$with_ping_command])
965 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
966         egrep -i "^round-trip|^rtt" >/dev/null
967 then
968         with_ping_command="$PATH_TO_PING -n -c %d %s"
969         ac_cv_ping_packets_first=yes
970         AC_MSG_RESULT([$with_ping_command])
972 else
973         AC_MSG_WARN([unable to find usable ping syntax])
974 fi
976 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
977         [path and args for ICMP ping command])
979 if test "x$ac_cv_ping_packets_first" != "xno"
980 then
981         AC_DEFINE(PING_PACKETS_FIRST,1,
982                 [Define if packet count must precede host])
983 fi
985 if test "x$ac_cv_ping_has_timeout" != "xno"
986 then
987         AC_DEFINE(PING_HAS_TIMEOUT,1,
988                 [Define if ping has its own timeout option that should be set])
989 fi
991 AC_ARG_WITH(ping6_command,
992         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
993                 [sets syntax for ICMPv6 ping]),
994         with_ping6_command=$withval,)
996 if test x"$with_ipv6" != xno ; then
997 AC_MSG_CHECKING(for ICMPv6 ping syntax)
998 ac_cv_ping6_packets_first=no
999 if test -n "$with_ping6_command"
1000 then
1001         AC_MSG_RESULT([(command-line) $with_ping6_command])
1002         if test -n "$ac_cv_ping6_packets_first"
1003         then
1004                 ac_cv_ping6_packets_first=yes
1005         fi
1007 elif test "x$PATH_TO_PING6" != "x"; then
1008         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1009                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1010                 egrep -i "^round-trip|^rtt" >/dev/null
1011         then
1012                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1013                 ac_cv_ping6_packets_first=yes
1014                 AC_MSG_RESULT([$with_ping6_command])
1016         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1017                 egrep -i "^round-trip|^rtt" >/dev/null
1018         then
1019                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1020                 ac_cv_ping6_packets_first=yes
1021                 AC_MSG_RESULT([$with_ping6_command])
1023         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1024                 egrep -i "^round-trip|^rtt" >/dev/null
1025         then
1026                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1027                 ac_cv_ping6_packets_first=yes
1028                 AC_MSG_RESULT([$with_ping6_command])
1030         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1031                 egrep -i "^round-trip|^rtt" >/dev/null
1032         then
1033                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1034                 AC_MSG_RESULT([$with_ping6_command])
1036         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1037                 egrep -i "^round-trip|^rtt" >/dev/null
1038         then
1039                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1040                 AC_MSG_RESULT([$with_ping6_command])
1042         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1043                 egrep -i "^round-trip|^rtt" >/dev/null
1044         then
1045                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1046                 AC_MSG_RESULT([$with_ping6_command])
1048         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1049                 egrep -i "^round-trip|^rtt" >/dev/null
1050         then
1051                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1052                 AC_MSG_RESULT([$with_ping6_command])
1054         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1055                 egrep -i "^round-trip|^rtt" >/dev/null
1056         then
1057                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1058                 ac_cv_ping6_packets_first=yes
1059                 AC_MSG_RESULT([$with_ping_command])
1061         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1062                 egrep -i "^round-trip|^rtt" >/dev/null
1063         then
1064                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1065                 ac_cv_ping6_packets_first=yes
1066                 AC_MSG_RESULT([$with_ping6_command])
1068         fi
1070 elif test "x$PATH_TO_PING" != "x"; then
1071         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1072                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1073                 egrep -i "^round-trip|^rtt" >/dev/null
1074         then
1075                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1076                 ac_cv_ping6_packets_first=yes
1077                 AC_MSG_RESULT([$with_ping6_command])
1079         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1080                 egrep -i "^round-trip|^rtt" >/dev/null
1081         then
1082                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1083                 ac_cv_ping6_packets_first=yes
1084                 AC_MSG_RESULT([$with_ping6_command])
1086         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1087                 egrep -i "^round-trip|^rtt" >/dev/null
1088         then
1089                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1090                 ac_cv_ping6_packets_first=yes
1091                 AC_MSG_RESULT([$with_ping6_command])
1093         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1094                 egrep -i "^round-trip|^rtt" >/dev/null
1095         then
1096                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1097                 AC_MSG_RESULT([$with_ping6_command])
1099         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1100                 egrep -i "^round-trip|^rtt" >/dev/null
1101         then
1102                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1103                 AC_MSG_RESULT([$with_ping6_command])
1105         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1106                 egrep -i "^round-trip|^rtt" >/dev/null
1107         then
1108                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1109                 AC_MSG_RESULT([$with_ping6_command])
1111         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1112                 egrep -i "^round-trip|^rtt" >/dev/null
1113         then
1114                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1115                 AC_MSG_RESULT([$with_ping6_command])
1117         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1118                 egrep -i "^round-trip|^rtt" >/dev/null
1119         then
1120                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1121                 ac_cv_ping6_packets_first=yes
1122                 AC_MSG_RESULT([$with_ping_command])
1124         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1125                 egrep -i "^round-trip|^rtt" >/dev/null
1126         then
1127                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1128                 ac_cv_ping6_packets_first=yes
1129                 AC_MSG_RESULT([$with_ping6_command])
1131         fi
1133 fi
1135 if test "x$with_ping6_command" != "x"; then
1136         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1137                 [path and args for ICMPv6 ping command])
1138 else
1139         AC_MSG_RESULT([none])
1140 fi
1142 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1143         AC_DEFINE(PING6_PACKETS_FIRST,1,
1144                 [Define if packet count must precede host])
1145 fi
1146 fi
1148 AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1150 AC_MSG_CHECKING(for nslookup syntax)
1151 if test -n "$PATH_TO_NSLOOKUP"
1152 then
1153         if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1154         then
1155                 ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1156                 AC_MSG_RESULT([$ac_cv_nslookup_command])
1158         else
1159                 ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1160                 AC_MSG_RESULT([$ac_cv_nslookup_command])
1162         fi
1163         EXTRAS="$EXTRAS check_dns"
1165 else
1166         AC_MSG_WARN([nslookup command not found])
1167 fi
1169 AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command",
1170         [path and args for nslookup])
1172 AC_PATH_PROG(PATH_TO_HOST,host)
1173 if test -n "$ac_cv_path_PATH_TO_HOST"
1174 then
1175         EXTRAS="$EXTRAS check_dns"
1176 fi
1178 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1179 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1181 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1182 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1184 AC_PATH_PROG(PATH_TO_NTPDATE,ntpdate)
1185 AC_PATH_PROGS(PATH_TO_NTPDC,ntpdc xntpdc)
1186 AC_PATH_PROGS(PATH_TO_NTPQ,ntpq)
1187 if (test -x "$PATH_TO_NTPDATE" || test -x "$PATH_TO_NTPQ")
1188 then
1189         AC_DEFINE_UNQUOTED(PATH_TO_NTPQ,"$PATH_TO_NTPQ",[path to ntpq binary])
1190         AC_DEFINE_UNQUOTED(PATH_TO_NTPDATE,"$PATH_TO_NTPDATE",[path to ntpdate binary])
1191 else
1192         AC_MSG_WARN([Install NTP programs (http://www.ntp.org) if you want to monitor time synchronization])
1193 fi
1195 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1196 if test -x "$PATH_TO_LMSTAT"
1197 then
1198         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1199 else
1200         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1201 fi
1203 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1204 if test -x "$PATH_TO_SMBCLIENT"
1205 then
1206         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1207 else
1208         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1209 fi
1212 AC_PATH_PROG(PATH_TO_WHO,who)
1214 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1215 then
1216         ac_cv_path_to_who="$PATH_TO_WHO -q"
1217 else
1218         ac_cv_path_to_who="$PATH_TO_WHO"
1219 fi
1221 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1222         [path and arguments for invoking 'who'])
1224 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1225 if test -x "$PATH_TO_SNMPGET"
1226 then
1227         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1228         EXTRAS="$EXTRAS check_hpjd check_snmp"
1229 else
1230         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1231 fi
1233 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1234 if test -x "$PATH_TO_SNMPGETNEXT"
1235 then
1236         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1237 fi
1239 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1240 then
1241         AC_MSG_CHECKING(for Net::SNMP perl module)
1242         AC_MSG_RESULT([found])
1243 else
1244         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1245 fi
1247 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1248 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1250 if test -x "$PATH_TO_QUAKESTAT"
1251 then
1252         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1253         EXTRAS="$EXTRAS check_game"
1255 elif test -x "$PATH_TO_QSTAT"
1256 then
1257         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1258         EXTRAS="$EXTRAS check_game"
1259 else
1260         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1261 fi
1263 if test $ac_cv_path_to_qstat 
1264 then
1265         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1266                 [path to qstat/quakestat])
1267 fi
1269 AC_PATH_PROG(PATH_TO_FPING,fping)
1270 if test -x "$PATH_TO_FPING"
1271 then
1272         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1273         EXTRAS="$EXTRAS check_fping"
1274 else
1275         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1276 fi
1278 AC_PATH_PROG(PATH_TO_SSH,ssh)
1280 if test -x "$PATH_TO_SSH"
1281 then
1282         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1283         EXTRAS="$EXTRAS check_by_ssh"
1284 else
1285         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1286 fi
1289 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1290 if test -x "$PATH_TO_MAILQ"
1291 then
1292         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1293 else
1294         AC_MSG_WARN([Could not find mailq or eqivalent])
1295 fi
1297 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1298 if test -x "$PATH_TO_QMAIL_QSTAT"
1299 then
1300         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1301 else
1302         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1303 fi
1305 dnl SWAP info required is amount allocated/available and amount free
1306 dnl The plugin works through all the swap devices and adds up the total swap
1307 dnl available.
1308 AC_PATH_PROG(PATH_TO_SWAP,swap)
1309 if (test -n "$PATH_TO_SWAP")
1310 then
1311 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1312 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1313 then
1314         ac_cv_have_swap=yes
1315         ac_cv_swap_command="$PATH_TO_SWAP -l"
1316         if [$PATH_TO_SWAP -l 2>/dev/null | \
1317                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1318                 >/dev/null]
1319         then
1320                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %d %d"]
1321                 ac_cv_swap_conv=2048
1322                 AC_MSG_RESULT([using IRIX format swap])
1324         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1325         then
1326                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %d %d"]
1327                 ac_cv_swap_conv=2048
1328                 AC_MSG_RESULT([using Unixware format swap])
1329         else
1330                 dnl if we don't know what format swap's output is
1331                 dnl we might as well pretend we didn't see it
1332                 ac_cv_have_swap=""
1333                 ac_cv_swap_command=""
1334         fi
1335 fi
1336 dnl end if for PATH_TO_SWAP
1337 fi
1339 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1340 if (test -n "$PATH_TO_SWAPINFO")
1341 then
1342 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1343 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1344 then
1345         ac_cv_have_swap=yes
1346         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1348         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1349         then
1350                 ac_cv_swap_format=["%*s %d %*d %d"]
1351                 ac_cv_swap_conv=1024
1352                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1353         fi
1355 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1356 then
1357         ac_cv_have_swap=yes
1358         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM",
1359         ac_cv_swap_format=["%*s %d %*d %d"]
1360         ac_cv_swap_conv=1024
1361         AC_MSG_RESULT([using HP-UX format swapinfo])
1362 fi
1363 dnl end if for PATH_TO_SWAPINFO
1364 fi
1366 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1367 if (test -n "$PATH_TO_LSPS")
1368 then
1369 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1370 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1371 then
1372         ac_cv_have_swap=yes
1373         ac_cv_swap_command="$PATH_TO_LSPS -a"
1374         ac_cv_swap_format=["%*s %*s %*s %d%*s %d %*s"]
1375         ac_cv_swap_conv=1
1376         AC_MSG_RESULT([using AIX lsps])
1377 fi
1378 dnl end if for PATH_TO_SWAPINFO
1379 fi
1381 dnl
1382 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1383 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1384 dnl in the various BSD's
1385 dnl
1387 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1388 #ifdef HAVE_SYS_PARAM_H
1389 #include <sys/param.h>
1390 #endif
1391 ])
1392 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1393 AC_CHECK_DECLS([swapctl],,,[
1394                #include <unistd.h>
1395                #include <sys/types.h>
1396                #include <sys/param.h>
1397                #include <sys/stat.h>
1398                #include <sys/swap.h>
1399                ])
1400 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1401                #include <sys/types.h>
1402                #include <sys/param.h>
1403                #include <sys/stat.h>
1404                #include <sys/swap.h>
1405                ])
1406 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1407                #include <unistd.h>
1408                #include <sys/types.h>
1409                #include <sys/param.h>
1410                #include <sys/stat.h>
1411                #include <sys/swap.h>
1412                ])
1414 if test "$ac_cv_have_decl_swapctl" = "yes"; 
1415 then
1416         EXTRAS="$EXTRAS check_swap"
1417         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1418         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1419                 "$ac_cv_type_swapent_t" = "yes"; 
1420         then
1421                 AC_MSG_RESULT([yes])
1422                 ac_cv_check_swap_swapctl_svr4="1";
1423                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1424                           [Define if 2-argument SVR4 swapctl exists])
1425         else
1426                 AC_MSG_RESULT([no])
1427                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1428                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes"; 
1429                 then
1430                         AC_MSG_RESULT([yes])
1431                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1432                                   [Define if 3-argument BSD swapctl exists])
1433                 else
1434                         AC_MSG_RESULT([no])
1435                 fi
1436         fi
1437         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1438         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1439         then
1440                 dnl
1441                 dnl the SVR4 spec returns values in pages
1442                 dnl
1443                 AC_MSG_RESULT([page])
1444                 AC_CHECK_DECLS([sysconf])
1445                 AC_MSG_CHECKING([for system page size])
1446                 if test "$ac_cv_have_decl_sysconf" = "yes";
1447                 then
1448                         AC_MSG_RESULT([determined by sysconf(3)])
1449                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1450                 else
1451                         AC_MSG_WARN([don't know. guessing 4096k])
1452                         ac_cv_swap_conv=256
1453                 fi
1454         else
1455                 dnl
1456                 dnl the BSD spec returns values in blocks
1457                 dnl
1458                 AC_MSG_RESULT([blocks (assuming 512b)])
1459                 ac_cv_swap_conv=2048
1460         fi
1461         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1462                 [Conversion factor to MB])
1463 fi
1464 dnl
1465 dnl end tests for the swapctl system calls
1466 dnl
1469 if test "x$ac_cv_have_swap" != "x" 
1470 then
1471         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1472         EXTRAS="$EXTRAS check_swap"
1473 fi
1474 if test "x$ac_cv_swap_command" != "x" 
1475 then
1476         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1477                 [Path to swap/swapinfo binary, with any args])
1478         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1479                 [Format string for parsing swap output])
1480         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1481                 [Conversion factor to MB])
1482 fi
1484 dnl dunno why this does not work below - use hack (kbd)
1485 dnl fine on linux, broken on solaris
1486 dnl if /bin/test -e "/proc/meminfo"
1487 AC_MSG_CHECKING([for /proc/meminfo])
1488 if [cat /proc/meminfo > /dev/null 2>&1]
1489 then
1490         AC_MSG_RESULT([found /proc/meminfo])
1491         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1492         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"/proc/meminfo",[path to /proc/meminfo if name changes])
1493         EXTRAS="$EXTRAS check_swap"
1494 else
1495         AC_MSG_RESULT([no])
1496 fi
1498 AC_PATH_PROG(PATH_TO_DIG,dig)
1499 AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1500 if test -n "$PATH_TO_DIG"; then
1501         EXTRAS="$EXTRAS check_dig"
1502 fi
1504 if test -f plugins/check_nt.c ; then
1505   EXTRAS="$EXTRAS check_nt"
1506 elif test -f ../plugins/check_nt.c ; then
1507   EXTRAS="$EXTRAS check_nt"
1508 fi
1510 AC_MSG_CHECKING(for va_list)
1511 AC_TRY_COMPILE([#ifdef __STDC__
1512                 #include <stdio.h>
1513                 #include <stdlib.h>
1514                 #include <stdarg.h>
1515                 #else
1516                 #include <sys/types.h>
1517                 #include <stdio.h>
1518                 #include <varargs.h>
1519                 #endif],
1520                 [va_list args;],
1521                 [AC_MSG_RESULT(yes)],
1522                 [NEED_VA_LIST=-DNEED_VA_LIST AC_SUBST(NEED_VA_LIST) AC_MSG_RESULT(no)])
1524 AC_SUBST(EXTRAS)
1525 AC_SUBST(EXTRA_NETOBJS)
1526 AC_SUBST(DEPLIBS)
1528 AM_GNU_GETTEXT_VERSION(0.11.5)
1529 AM_GNU_GETTEXT([no-libtool], [need-ngettext])
1531 AC_OUTPUT(Makefile lib/Makefile plugins/Makefile plugins-scripts/Makefile plugins-scripts/subst plugins-scripts/utils.pm plugins-scripts/utils.sh command.cfg test.pl pkg/solaris/pkginfo intl/Makefile po/Makefile.in )
1533 ACX_FEATURE([with],[cgiurl])
1534 ACX_FEATURE([with],[nagios-user])
1535 ACX_FEATURE([with],[nagios-group])
1536 ACX_FEATURE([with],[trusted-path])
1537 ACX_FEATURE([with],[ping-command])
1538 ACX_FEATURE([with],[ping6-command])
1539 ACX_FEATURE([with],[lwres])
1540 ACX_FEATURE([with],[ipv6])
1541 ACX_FEATURE([enable],[emulate-getaddrinfo])