Code

Removed redundant check and make export LD_LIBRARY_PATH more sh friendly
[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         AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
208 else
209   AC_MSG_WARN([Skipping LDAP plugin])
210   AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
211 fi
212 LIBS="$_SAVEDLIBS"
215 dnl Check for mysql libraries
216 _SAVEDLIBS="$LIBS"
217 _SAVEDCPPFLAGS="$CPPFLAGS"
218 AC_ARG_WITH(mysql,
219         ACX_HELP_STRING([--with-mysql=DIR],
220                 [sets path to mysql installation (assumes lib/mysql and include subdirs]),
221         MYSQL=$withval,)
222 if test -n "$MYSQL"; then
223   MYSQLLIBDIR=$MYSQL/lib/mysql
224   CPPFLAGS="-I$MYSQL/include"
225   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L$MYSQLLIBDIR ",,-L$MYSQLLIBDIR -lz)
226   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
227 elif test -f /usr/lib/libmysqlclient.so; then
228   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
229   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
230 elif test -f /usr/lib/libmysqlclient.a; then
231   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
232   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
233 elif test -f /usr/lib/mysql/libmysqlclient.so; then
234   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
235   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
236 elif test -f /usr/lib/mysql/libmysqlclient.a; then
237   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
238   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
239 fi
240 if test "$ac_cv_lib_mysqlclient_mysql_init" = "yes" -o "$ac_cv_lib_mysqlclient_mysql_close" = "yes"; then
241   AC_CHECK_HEADERS(mysql/mysql.h mysql/errmsg.h, MYSQLINCLUDE="-I$MYSQL/include" )
242   if test "$ac_cv_header_mysql_mysql_h" = "yes" -a "$ac_cv_header_mysql_errmsg_h" = "yes"; then
243     EXTRAS="$EXTRAS check_mysql"
244     AC_SUBST(MYSQLINCLUDE)
245     AC_SUBST(MYSQLLIBS)
246     AC_SUBST(check_mysql_LDFLAGS)
247   else
248     AC_MSG_WARN([Skipping mysql plugin])
249     AC_MSG_WARN([install mysql client headers to compile this plugin (see REQUIREMENTS).])
250   fi
251 else
252   AC_MSG_WARN([Skipping mysql plugin])
253   AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
254 fi
255 CPPFLAGS="$_SAVEDCPPFLAGS $MYSQLINCLUDE"
256 LIBS="$_SAVEDLIBS"
258 dnl Check for OpenSSL location
259 dnl This whole check is inspired by curl 7.12.2's configure.ac
260 OPT_OPENSSL=off
261 AC_ARG_WITH(openssl,
262 AC_HELP_STRING([--with-openssl=DIR], [sets path to openssl installation])
263 AC_HELP_STRING([--without-openssl], [disable openssl]),
264 OPT_OPENSSL=$withval)
266 if test X"$OPT_OPENSSL" = "Xno"; then
267   AC_MSG_WARN([openssl disabled, you will not be able to use ssl options in some plugins])
268   with_openssl=no
269 else
270   dnl backup the pre-ssl variables
271   CLEANLDFLAGS="$LDFLAGS"
272   CLEANCPPFLAGS="$CPPFLAGS"
273   CLEANLIBS="$LIBS"
275   case "$OPT_OPENSSL" in
276   yes)
277     dnl --with-openssl (without path) used
278     PKGTEST="yes"
279     ;;
280   off)
281     dnl no --with-openssl given, check default places
282     PKGTEST="yes"
283     ;;
284   *)
285     dnl use the given area
286     PKGTEST="no"
287     OPENSSL=$OPT_OPENSSL
288     LDFLAGS="$LDFLAGS -L$OPENSSL/lib"
289     CPPFLAGS="$CPPFLAGS -I$OPENSSL/include/openssl -I$OPENSSL/include"
290   ;;
291   esac
293   dnl Check usual areas for openssl
294   if test "$PKGTEST" = "yes"; then
295     AC_PATH_PROG(OPENSSL,openssl)
296     # Don't think 2 tests below are necessary because /usr is always included
297     # if test "$OPENSSL" = "/usr/bin/openssl"; then
298     #  OPENSSL=/usr
299     #elif test "$OPENSSL" = "/usr/sbin/openssl"; then
300     #  OPENSSL=/usr
301     if test "$OPENSSL" = "/opt/bin/openssl"; then
302       OPENSSL=/opt
303     elif test "$OPENSSL" = "/opt/openssl/bin/openssl"; then
304       OPENSSL=/opt/openssl
305     elif test "$OPENSSL" = "/usr/slocal/bin/openssl"; then
306       OPENSSL=/usr/slocal
307     elif test "$OPENSSL" = "/usr/local/bin/openssl"; then
308       OPENSSL=/usr/local
309     elif test "$OPENSSL" = "/usr/local/ssl/bin/openssl"; then
310       OPENSSL=/usr/local/ssl
311     fi
312   fi
314   AC_CHECK_LIB(crypto, CRYPTO_lock,[
315      HAVECRYPTO="yes"
316      ],[
317      LDFLAGS="$CLEANLDFLAGS -L$OPENSSL/lib"
318      CPPFLAGS="$CLEANCPPFLAGS -I$OPENSSL/include/openssl -I$OPENSSL/include"
319      AC_CHECK_LIB(crypto, CRYPTO_add_lock,[
320        HAVECRYPTO="yes" ], [
321        LDFLAGS="$CLEANLDFLAGS"
322        CPPFLAGS="$CLEANCPPFLAGS"
323        LIBS="$CLEANLIBS"
324        ])
325     ])
327   if test "$HAVECRYPTO" = "yes"; then
328     dnl This is only reasonable to do if crypto actually is there: check for
329     dnl SSL libs NOTE: it is important to do this AFTER the crypto lib
331     dnl This is for Msys/Mingw
332     AC_MSG_CHECKING([for gdi32])
333     my_ac_save_LIBS=$LIBS
334     LIBS="-lgdi32 $LIBS"
335     AC_TRY_LINK([#include <windef.h>
336                  #include <wingdi.h>],
337                [GdiFlush();],
338                [ dnl worked!
339                AC_MSG_RESULT([yes])],
340                [ dnl failed, restore LIBS
341                LIBS=$my_ac_save_LIBS
342                AC_MSG_RESULT(no)]
343               )
345     AC_CHECK_LIB(crypto, CRYPTO_add_lock)
346     AC_CHECK_LIB(ssl, SSL_connect)
348     if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
349         dnl we didn't find the SSL lib, try the RSAglue/rsaref stuff
350         AC_MSG_CHECKING(for ssl with RSAglue/rsaref libs in use);
351         OLIBS=$LIBS
352         LIBS="$LIBS -lRSAglue -lrsaref"
353         AC_CHECK_LIB(ssl, SSL_connect)
354         if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
355             dnl still no SSL_connect
356             AC_MSG_RESULT(no)
357             LIBS=$OLIBS
358         else
359             AC_MSG_RESULT(yes)
360         fi
361     fi
364     dnl Check for SSLeay headers
365     AC_CHECK_HEADERS(openssl/x509.h openssl/rsa.h openssl/crypto.h \
366                      openssl/pem.h openssl/ssl.h openssl/err.h,
367       OPENSSL_ENABLED=1)
369     if test $ac_cv_header_openssl_x509_h = no; then
370       AC_CHECK_HEADERS(x509.h rsa.h crypto.h pem.h ssl.h err.h,
371         OPENSSL_ENABLED=1)
372     fi
374     dnl If the ENGINE library seems to be around, check for the OpenSSL engine
375     dnl header, it is kind of "separated" from the main SSL check
376     AC_CHECK_FUNC(ENGINE_init, [ AC_CHECK_HEADERS(openssl/engine.h) ])
378     dnl AC_SUBST(OPENSSL_ENABLED)
380     dnl these can only exist if openssl exists
381     AC_CHECK_FUNCS( RAND_status \
382                     RAND_screen \
383                     RAND_egd \
384                     CRYPTO_cleanup_all_ex_data )
386   fi
388   if test "$OPENSSL_ENABLED" != "1"; then
389     AC_MSG_WARN([OpenSSL libs and/or directories were not found where specified!])
390     with_openssl="no"
391   else
392     check_tcp_ssl="check_simap check_spop check_jabber check_nntps"
393     AC_SUBST(check_tcp_ssl)
394     AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
395     with_openssl="yes"
397     # Needed for subsequent compiled programs
398     LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$OPENSSL/lib"
399     export LD_LIBRARY_PATH
400   fi
401 fi
403 AC_CHECK_HEADERS(unistd.h)
405 dnl Check for AF_INET6 support - unistd.h required for Darwin
406 AC_CACHE_CHECK([for IPv6 support], with_ipv6, [
407         AC_TRY_COMPILE([#ifdef HAVE_UNISTD_H
408                         #include <unistd.h>
409                         #endif
410                         #include <netinet/in.h>
411                         #include <sys/socket.h>],
412                         [struct sockaddr_in6 sin6;
413                         void *p;
415                         sin6.sin6_family = AF_INET6;
416                         sin6.sin6_port = 587;
417                         p = &sin6.sin6_addr;],
418                         [with_ipv6=yes], 
419                         [with_ipv6=no])
420         ])
422 if test x"$with_ipv6" != xno ; then
423         AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
424 fi
426 dnl #########################################################################
427 dnl Check if Posix getaddrinfo() is available.  It is also possible to use
428 dnl the version from the lwres library distributed with BIND.
429 dnl #########################################################################
430 AC_ARG_ENABLE([emulate-getaddrinfo],
431               ACX_HELP_STRING([--enable-emulate-getaddrinfo],
432                              [enable getaddrinfo emulation (default=no)]),
433               ,
434               enable_emulate_getaddrinfo=no)
436 AC_ARG_WITH(lwres,
437             ACX_HELP_STRING([--with-lwres=DIR],
438                            [use lwres library for getaddrinfo (default=no)]),
439             ,
440             with_lwres=no)
442 dnl ## enable force to test getaddrinfo.c
443 if test x$enable_emulate_getaddrinfo = xforce ; then
444         enable_emulate_getaddrinfo=yes
445         have_getaddrinfo=no
446 else
448 have_getaddrinfo=no
449 if test x$with_lwres != xno ; then
450         if test "$with_lwres" != yes ; then
451                    CPPFLAGS="-I${with_lwres}/include $CPPFLAGS"
452                    LDFLAGS="-L${with_lwres}/lib $LDFLAGS"
453         fi
454         AC_CHECK_HEADERS(lwres/netdb.h, ,
455                         [AC_MSG_ERROR([cannot find <lwres/netdb.h>])])
456         AC_CHECK_LIB(lwres, lwres_getaddrinfo, ,
457                      [AC_MSG_ERROR([cannot find the lwres library])],
458                      -lnsl -lpthread)
459         have_getaddrinfo=yes
460 fi
462 if test x$have_getaddrinfo != xyes ; then
463         AC_SEARCH_LIBS(getaddrinfo, socket resolv bind nsl c_r cr, have_getaddrinfo=yes)
464 fi
466 dnl # Special nonsense for systems that actually have getaddrinfo but
467 dnl # redefine the name to something else, e.g. OSF
468 if test x$have_getaddrinfo != xyes ; then
469         AC_MSG_CHECKING(if getaddrinfo is redefined in netdb.h)
470         AC_TRY_LINK([
471 #               include <netdb.h>
472         ], [
473                 struct addrinfo hints, *res;
474                 int err;
476                 err = getaddrinfo ("host", "service", &hints, &res);
477         ], [
478                 have_getaddrinfo=yes
479                 AC_MSG_RESULT(yes)
480         ], [AC_MSG_RESULT(no)])
481 fi
483 fi
485 if test x$have_getaddrinfo != xno ; then
486         if test x$enable_emulate_getaddrinfo != xno ; then
487                 AC_MSG_ERROR([getaddrinfo found but emulate-getaddrinfo was enabled])
488         fi
489         AC_DEFINE(HAVE_GETADDRINFO, 1,
490                   [Does system provide RFC 2553/Posix getaddrinfo?])
491 else
492         if test x$enable_emulate_getaddrinfo != xyes ; then
493 dnl                AC_MSG_ERROR([getaddrinfo not found: try --with-lwres or --enable-emulate-getaddrinfo])
494                enable_emulate_getaddrinfo=yes
495                AC_MSG_WARN([enabling getaddrinfo emulation])
496         fi
497         EXTRA_NETOBJS="$EXTRA_NETOBJS getaddrinfo.o"
498 fi
500 if test x"$enable_emulate_getaddrinfo" != xno ; then
501     have_resolver=no
503   dnl  Try for getipnodebyname
504     AC_SEARCH_LIBS(getipnodebyname, resolv bind nsl c_r cr, have_resolver=yes)
505     if test x"$have_resolver" != xno ; then
506          AC_DEFINE(HAVE_GETIPNODEBYNAME, 1,
507                    [Set when getipnodebyname is available])
508     fi
510   dnl  Try for gethostbyname_r
511     if test x"$have_resolver" = xno ; then
512         AC_SEARCH_LIBS(gethostbyname_r, resolv bind nsl c_r cr,
513                        [have_resolver=yes
514                         ACX_WHICH_GETHOSTBYNAME_R])
515     fi
517   dnl  Try for gethostbyname
518     if test x"$have_resolver" = xno ; then
519         if test x"$enable_pthreads" != xno ; then
520             AC_MSG_WARN([using threads but cannot find gethostbyname_r or getipnodebyname])
521         fi
522         AC_SEARCH_LIBS(gethostbyname, resolv bind nsl, ,
523                        [AC_MSG_ERROR([cannot find gethostbyname])])
524     fi
525     EXTRA_NETOBJS="$EXTRA_NETOBJS gethostbyname.o"
527 fi
529 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
530 if test "$FOUNDINCLUDE" = "no"; then
531   _SAVEDCPPFLAGS="$CPPFLAGS"
532   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
533   unset ac_cv_header_krb5_h
534   AC_CHECK_HEADERS(krb5.h,
535                    KRB5INCLUDE="-I/usr/kerberos/include"
536                    FOUNDINCLUDE=yes,
537                    FOUNDINCLUDE=no)
538 fi
539 AC_SUBST(KRBINCLUDE)
540 if test "$FOUNDINCLUDE" = "no"; then
541   CPPFLAGS="$_SAVEDCPPFLAGS"
542 fi
544 dnl
545 dnl Checks for header files.
546 dnl
548 AC_HEADER_STDC
549 AC_HEADER_TIME
550 AC_HEADER_SYS_WAIT
551 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)
552 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h stdlib.h)
553 AC_CHECK_HEADERS(limits.h sys/param.h)
554 AC_CHECK_HEADERS([sys/mount.h],[],[],[
555 #ifdef HAVE_SYS_PARAM_H
556 #include <sys/param.h>
557 #endif
558 ])
559 AC_CHECK_HEADERS(sys/vfs.h sys/fs/s5param.h sys/filsys.h fcntl.h sys/statfs.h sys/dustat.h sys/statvfs.h)
561 # glibc 2.3.2 stdlib.h does not define HUGE_VAL (see man strtod)
562 AC_MSG_CHECKING([for HUGE_VAL in <stdlib.h>])
563 AC_TRY_COMPILE([#include <stdlib.h>],
564                [double x = HUGE_VAL;],
565                [AC_MSG_RESULT(yes)],
566                [AC_MSG_RESULT(no)
567                 AC_MSG_CHECKING([for HUGE_VAL in <math.h>])
568                 AC_TRY_COMPILE([#include <math.h>],
569                                [double x = HUGE_VAL;],
570                                [AC_MSG_RESULT(yes)
571                                 AC_DEFINE_UNQUOTED(HUGE_VAL_NEEDS_MATH_H, 1,
572                                                   [Define if <math.h> is required for HUGE_VAL])],
573                                [AC_MSG_RESULT(no)])])
575 # Define HAVE_INTTYPES_H if <inttypes.h> exists,
576 # doesn't clash with <sys/types.h>, and declares uintmax_t.
578 AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
579 [AC_TRY_COMPILE(
580   [#include <sys/types.h>
581 #include <inttypes.h>],
582   [uintmax_t i = (uintmax_t) -1;],
583   jm_ac_cv_header_inttypes_h=yes,
584   jm_ac_cv_header_inttypes_h=no)])
586 if test $jm_ac_cv_header_inttypes_h = yes; then
587   AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1,
588 [Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
589    and declares uintmax_t. ])
590 fi
592 # Check for SunOS statfs brokenness wrt partitions 2GB and larger.
593 # If <sys/vfs.h> exists and struct statfs has a member named f_spare,
594 # enable the work-around code in fsusage.c.
595 AC_MSG_CHECKING([for statfs that truncates block counts])
596 AC_CACHE_VAL(fu_cv_sys_truncating_statfs,
597 [AC_TRY_COMPILE([
598 #if !defined(sun) && !defined(__sun)
599 choke -- this is a workaround for a Sun-specific problem
600 #endif
601 #include <sys/types.h>
602 #include <sys/vfs.h>],
603 [struct statfs t; long c = *(t.f_spare);],
604 fu_cv_sys_truncating_statfs=yes
605 AC_MSG_RESULT(yes),
606 fu_cv_sys_truncating_statfs=no
607 AC_MSG_RESULT(no),
608 )])
609 if test $fu_cv_sys_truncating_statfs = yes; then
610   AC_DEFINE(STATFS_TRUNCATES_BLOCK_COUNTS, 1,
611 [  Define if the block counts reported by statfs may be truncated to 2GB
612    and the correct values may be stored in the f_spare array.
613    (SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem.
614    SunOS 4.1.1 seems not to be affected.)])
615 fi
617 dnl Checks for typedefs, structures, and compiler characteristics.
618 AC_C_CONST
619 AC_STRUCT_TM
620 AC_TYPE_PID_T
621 AC_TYPE_SIZE_T
622 AC_TYPE_SIGNAL
624 AC_CHECK_SIZEOF(int,cross)
625 AC_CHECK_SIZEOF(long,cross)
626 AC_CHECK_SIZEOF(short,cross)
628 AC_CACHE_CHECK([for long long],ac_cv_have_longlong,[
629 AC_TRY_RUN([#include <stdio.h>
630 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
631 ac_cv_have_longlong=yes,ac_cv_have_longlong=no,ac_cv_have_longlong=cross)])
632 if test x"$ac_cv_have_longlong" = x"yes"; then
633     AC_DEFINE(HAVE_LONGLONG,1,[Define if system has long long type])
634 fi
637 # Check if the compiler supports the LL prefix on long long integers.
638 # AIX needs this.
640 AC_CACHE_CHECK([for LL suffix on long long integers],ac_cv_compiler_supports_ll, [
641     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
642         ac_cv_compiler_supports_ll=yes,ac_cv_compiler_supports_ll=no)])
643 if test x"$ac_cv_compiler_supports_ll" = x"yes"; then
644    AC_DEFINE(COMPILER_SUPPORTS_LL,1,[Define if compiler support long long])
645 fi
647 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
648 AC_TRY_LINK([#include <stdarg.h>
649 va_list ap1,ap2;], [va_copy(ap1,ap2);],
650 ac_cv_HAVE_VA_COPY=yes,
651 ac_cv_HAVE_VA_COPY=no)])
652 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
653     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
654 else    
655     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
656     AC_TRY_LINK([#include <stdarg.h>
657     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
658     ac_cv_HAVE___VA_COPY=yes,
659     ac_cv_HAVE___VA_COPY=no)])
660     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
661         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
662     fi
663 fi
665 AC_CHECK_FUNCS(vsnprintf snprintf asprintf vasprintf)
666 AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[
667 AC_TRY_RUN([
668 #include <sys/types.h>
669 #include <stdarg.h>
670 void foo(const char *format, ...) { 
671        va_list ap;
672        int len;
673        char buf[5];
675        va_start(ap, format);
676        len = vsnprintf(buf, 0, format, ap);
677        va_end(ap);
678        if (len != 5) exit(1);
680        va_start(ap, format);
681        len = vsnprintf(0, 0, format, ap);
682        va_end(ap);
683        if (len != 5) exit(1);
685        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
687        exit(0);
689 main() { foo("hello"); }
690 ],
691 ac_cv_HAVE_C99_VSNPRINTF=yes,ac_cv_HAVE_C99_VSNPRINTF=no,ac_cv_HAVE_C99_VSNPRINTF=cross)])
692 if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
693     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Define if system has C99 compatible vsnprintf])
694 fi
696 AC_TRY_COMPILE([#include <sys/time.h>],
697                [struct timeval *tv;
698                 struct timezone *tz;],
699                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
700                AC_TRY_COMPILE([#include <sys/time.h>],
701                               [struct timeval *tv;
702                                struct timezone *tz;
703                                gettimeofday(tv, tz);],
704                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
705                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
707 dnl Checks for library functions.
708 AC_CHECK_FUNCS(memmove select socket strdup strstr strtod strtol strtoul)
710 AC_MSG_CHECKING(return type of socket size)
711 AC_TRY_COMPILE([#include <stdlib.h>
712                 #include <sys/types.h>
713                 #include <sys/socket.h>],
714                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
715                ac_cv_socket_size_type=["size_t"]
716                 AC_MSG_RESULT(size_t),
717                ac_cv_socket_size_type=["int"]
718                 AC_MSG_RESULT(int))
720 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
721         [Define type of socket size])
723 if test -f "/proc/loadavg"
724 then
725   AC_DEFINE(HAVE_PROC_LOADAVG,1,[Define if /proc/loadavg or similar exists])
726   AC_DEFINE_UNQUOTED(PROC_LOADAVG,"/proc/loadavg",[Location of /proc/loadavg])
727 fi
729 dnl #### Process table test
731 AC_PATH_PROG(PATH_TO_PS,ps)
733 AC_MSG_CHECKING(for ps syntax)
734 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
735 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
736 if ps -axwo 'stat comm vsz rss user uid ppid args' 2>/dev/null | \
737         egrep -i ["^ *STAT +UCOMM +VSZ +RSS +USER +UID +PPID +COMMAND"] > /dev/null
738 then
739         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
740         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid ppid vsz rss pcpu comm args'"
741         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
742         ac_cv_ps_cols=8
743         AC_MSG_RESULT([$ac_cv_ps_command])
745 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
746 elif ps -weo 'stat comm vsz rss user uid ppid etime args' 2>/dev/null | \
747         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
748 then
749         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
750         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid ppid vsz rss pcpu etime comm args'"
751         ac_cv_ps_format="%s %d %d %d %d %f %s %s %n"
752         ac_cv_ps_cols=9
753         AC_MSG_RESULT([$ac_cv_ps_command])
755 dnl FreeBSD
756 elif ps waxco 'state command vsz rss uid user ppid' 2>/dev/null | \
757         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PPID"] >/dev/null
758 then
759         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
760         ac_cv_ps_command="$PATH_TO_PS waxco 'state uid ppid vsz rss pcpu command command'"
761         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
762         ac_cv_ps_cols=8
763         AC_MSG_RESULT([$ac_cv_ps_command])
765 dnl BSD-like mode in RH 6.1
766 elif ps waxno 'state comm vsz rss uid user ppid args' 2>/dev/null | \
767         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null
768 then
769         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
770         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid ppid vsz rss pcpu comm args'"
771         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
772         ac_cv_ps_cols=8
773         AC_MSG_RESULT([$ac_cv_ps_command])
775 dnl SunOS 4.1.3:
776 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
777 dnl Need the head -1 otherwise test will work because arguments are found
778 elif ps -laxnwww 2>/dev/null | head -1 | \
779         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
780 then
781         ac_cv_ps_varlist="[&procuid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
782         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
783         ac_cv_ps_format="%*s %d %*s %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
784         ac_cv_ps_cols=8
785         AC_MSG_RESULT([$ac_cv_ps_command])
787 dnl Debian Linux / procps v1.2.9:
788 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
789 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
790 dnl
791 elif ps laxnwww 2>/dev/null | \
792         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
793 then
794         ac_cv_ps_varlist="[&procuid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
795         ac_cv_ps_command="$PATH_TO_PS laxnwww"
796         ac_cv_ps_format="%*s %d %*s %d %*s %*s %d %d %*s %s %*s %*s %n%s"
797         ac_cv_ps_cols=8
798         AC_MSG_RESULT([$ac_cv_ps_command])
800 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
801 elif ps -axo 'stat comm vsz rss user uid ppid args' 2>/dev/null | \
802         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
803 then
804         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
805         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid ppid vsz rss pcpu comm args'"
806         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
807         ac_cv_ps_cols=8
808         AC_MSG_RESULT([$ac_cv_ps_command])
810 dnl Tru64 - needs %*[ +] in PS_FORMAT
811 elif ps -ao 'stat comm vsz rss user uid ppid args' 2>/dev/null | \
812         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
813 then
814         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
815         ac_cv_ps_command="$PATH_TO_PS -ao 'stat uid ppid vsz rss pcpu comm args'"
816         ac_cv_ps_format=["%s%*[ +] %d %d %d %d %f %s %n"]
817         ac_cv_ps_cols=8
818         AC_MSG_RESULT([$ac_cv_ps_command])
820 elif ps -eo 's comm vsz rss user uid ppid args' 2>/dev/null | \
821         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
822 then
823         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
824         ac_cv_ps_command="$PATH_TO_PS -eo 's uid ppid vsz rss pcpu comm args'"
825         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
826         ac_cv_ps_cols=8
827         AC_MSG_RESULT([$ac_cv_ps_command])
829 dnl AIX 4.3.3 and 5.1 do not have an rss field
830 elif ps -eo 'stat uid ppid vsz pcpu comm args' 2>/dev/null | \
831         egrep -i ["^ *S[TAUES]* +UID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
832 then
833         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
834         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid ppid vsz pcpu comm args'"
835         ac_cv_ps_format="%s %d %d %d %f %s %n"
836         ac_cv_ps_cols=7
837         AC_MSG_RESULT([$ac_cv_ps_command - with no RSS])
839 dnl Solaris 2.6
840 elif ps -Ao 's comm vsz rss uid user ppid args' 2>/dev/null | \
841         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null
842 then
843         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
844         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid ppid vsz rss pcpu comm args'"
845         # There must be no space between the %s and %n due to a wierd problem in sscanf where
846         # it will return %n as longer than the line length
847         ac_cv_ps_format="%s %d %d %d %d %f %s%n"
848         ac_cv_ps_cols=8
849         AC_MSG_RESULT([$ac_cv_ps_command])
851 elif ps -Ao 'status comm vsz rss uid user ppid args' 2>/dev/null | \
852         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null
853 then
854         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
855         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid ppid vsz rss pcpu comm args'"
856         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
857         ac_cv_ps_cols=8
858         AC_MSG_RESULT([$ac_cv_ps_command])
860 elif ps -Ao 'state comm vsz rss uid user ppid args' 2>/dev/null | \
861         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null
862 then
863         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
864         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid ppid vsz rss pcpu comm args'"
865         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
866         ac_cv_ps_cols=8
867         AC_MSG_RESULT([$ac_cv_ps_command])
869 dnl wonder who takes state instead of stat
870 elif ps -ao 'state command vsz rss user ppid args' 2>/dev/null | \
871         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null
872 then
873         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
874         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid ppid vsz rss pcpu command args'"
875         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
876         ac_cv_ps_cols=7
877         AC_MSG_RESULT([$ac_cv_ps_command])
879 dnl IRIX 53
880 elif ps -el 2>/dev/null | \
881         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
882 then
883         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&pos,procprog]"
884         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
885         ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
886         ac_cv_ps_cols=7
887         AC_MSG_RESULT([$ac_cv_ps_command])
889 dnl IRIX 63
890 elif ps -el 2>/dev/null | \
891         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
892 then
893         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&pos,procprog]"
894         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
895         ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
896         ac_cv_ps_cols=5
897         AC_MSG_RESULT([$ac_cv_ps_command])
899 dnl AIX 4.1:
900 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
901 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
902 elif ps -el 2>/dev/null | \
903         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
904 then
905         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&pos,procprog]"
906         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
907         ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
908         ac_cv_ps_cols=5
909         AC_MSG_RESULT([$ac_cv_ps_command])
911 dnl AIX?
912 elif ps glaxen 2>/dev/null | \
913         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
914 then
915         ac_cv_ps_varlist="[&procuid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
916         ac_cv_ps_command="$PATH_TO_PS glaxen"
917         ac_cv_ps_format="%*s %d %*s %d %*s %*s %d %d %*s %s %*s %*s %n%s"
918         ac_cv_ps_cols=7
919         AC_MSG_RESULT([$ac_cv_ps_command])
921 dnl MacOSX / Darwin
922 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
923 dnl Some truncation will happen in UCOMM column
924 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
925 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
926 elif ps wwaxo 'state vsz rss uid ppid pcpu ucomm command' 2>/dev/null | \
927         egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
928 then
929         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid ppid pcpu ucomm command'"
930         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procppid,&procpcpu,procprog,&pos]"
931         ac_cv_ps_format="%s %d %d %d %d %f %s %n"
932         ac_cv_ps_cols=7
933         AC_MSG_RESULT([$ac_cv_ps_command])
935 dnl UnixWare 
936 elif ps -Al 2>/dev/null | \
937         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
938 then
939         ac_cv_ps_varlist="[procstat,&procuid,&procppid,&pos,procprog]"
940         ac_cv_ps_command="$PATH_TO_PS -Al"
941         ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
942         ac_cv_ps_cols=7
943         AC_MSG_RESULT([$ac_cv_ps_command])
945 else
946         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
947 fi
949 if test -n "$ac_cv_ps_varlist" ; then
950         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
951                 [Variable list for sscanf of 'ps' output])
952         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
953                 [Verbatim command to execute for ps in check_procs])
954         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
955                 [Format string for scanning ps output in check_procs])
956         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
957                 [Number of columns in ps command])
958         EXTRAS="$EXTRAS check_procs check_nagios"
959 fi
961 dnl jm_AFS
962 jm_LIST_MOUNTED_FILESYSTEMS([list_mounted_fs=yes], [list_mounted_fs=no])
963 jm_FSTYPENAME
964 jm_FILE_SYSTEM_USAGE([space=yes], [space=no])
966 AC_PATH_PROG(PATH_TO_PING,ping)
967 AC_PATH_PROG(PATH_TO_PING6,ping6)
969 AC_ARG_WITH(ping_command,
970         ACX_HELP_STRING([--with-ping-command=SYNTAX],
971                 [sets syntax for ICMP ping]),
972         with_ping_command=$withval,)
974 AC_MSG_CHECKING(for ICMP ping syntax)
975 ac_cv_ping_packets_first=no
976 ac_cv_ping_has_timeout=no
977 if test -n "$with_ping_command"
978 then
979         AC_MSG_RESULT([(command-line) $with_ping_command])
980         if test -n "$ac_cv_ping_packets_first"
981         then
982                 ac_cv_ping_packets_first=yes
983         fi
985 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
986         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
987         egrep -i "^round-trip|^rtt" >/dev/null
988 then
989         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
990         ac_cv_ping_packets_first=yes
991         AC_MSG_RESULT([$with_ping_command])
993 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
994         egrep -i "^round-trip|^rtt" >/dev/null
995 then
996         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
997         ac_cv_ping_packets_first=yes
998   ac_cv_ping_has_timeout=yes
999         AC_MSG_RESULT([$with_ping_command])
1001 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
1002         egrep -i "^round-trip|^rtt" >/dev/null
1003 then
1004         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
1005         ac_cv_ping_packets_first=yes
1006         AC_MSG_RESULT([$with_ping_command])
1008 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1009         egrep -i "^round-trip|^rtt" >/dev/null
1010 then
1011         with_ping_command="$PATH_TO_PING -n -c %d %s"
1012         ac_cv_ping_packets_first=yes
1013         AC_MSG_RESULT([$with_ping_command])
1015 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
1016         egrep -i "^round-trip|^rtt" >/dev/null
1017 then
1018         with_ping_command="$PATH_TO_PING -n %s -c %d"
1019         AC_MSG_RESULT([$with_ping_command])
1021 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
1022         egrep -i "^round-trip|^rtt" >/dev/null
1023 then
1024         with_ping_command="$PATH_TO_PING %s -n %d"
1025         AC_MSG_RESULT([$with_ping_command])
1027 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
1028         egrep -i "^round-trip|^rtt" >/dev/null
1029 then
1030         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
1031         AC_MSG_RESULT([$with_ping_command])
1033 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
1034         egrep -i "^round-trip|^rtt" >/dev/null
1035 then
1036         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
1037         AC_MSG_RESULT([$with_ping_command])
1039 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
1040         egrep -i "^round-trip|^rtt" >/dev/null
1041 then
1042         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
1043         ac_cv_ping_packets_first=yes
1044         AC_MSG_RESULT([$with_ping_command])
1046 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1047         egrep -i "^round-trip|^rtt" >/dev/null
1048 then
1049         with_ping_command="$PATH_TO_PING -n -c %d %s"
1050         ac_cv_ping_packets_first=yes
1051         AC_MSG_RESULT([$with_ping_command])
1053 else
1054         AC_MSG_WARN([unable to find usable ping syntax])
1055 fi
1057 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
1058         [path and args for ICMP ping command])
1060 if test "x$ac_cv_ping_packets_first" != "xno"
1061 then
1062         AC_DEFINE(PING_PACKETS_FIRST,1,
1063                 [Define if packet count must precede host])
1064 fi
1066 if test "x$ac_cv_ping_has_timeout" != "xno"
1067 then
1068         AC_DEFINE(PING_HAS_TIMEOUT,1,
1069                 [Define if ping has its own timeout option that should be set])
1070 fi
1072 AC_ARG_WITH(ping6_command,
1073         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
1074                 [sets syntax for ICMPv6 ping]),
1075         with_ping6_command=$withval,)
1077 if test x"$with_ipv6" != xno ; then
1078 AC_MSG_CHECKING(for ICMPv6 ping syntax)
1079 ac_cv_ping6_packets_first=no
1080 if test -n "$with_ping6_command"
1081 then
1082         AC_MSG_RESULT([(command-line) $with_ping6_command])
1083         if test -n "$ac_cv_ping6_packets_first"
1084         then
1085                 ac_cv_ping6_packets_first=yes
1086         fi
1088 elif test "x$PATH_TO_PING6" != "x"; then
1089         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1090                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1091                 egrep -i "^round-trip|^rtt" >/dev/null
1092         then
1093                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1094                 ac_cv_ping6_packets_first=yes
1095                 AC_MSG_RESULT([$with_ping6_command])
1097         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1098                 egrep -i "^round-trip|^rtt" >/dev/null
1099         then
1100                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1101                 ac_cv_ping6_packets_first=yes
1102                 AC_MSG_RESULT([$with_ping6_command])
1104         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1105                 egrep -i "^round-trip|^rtt" >/dev/null
1106         then
1107                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1108                 ac_cv_ping6_packets_first=yes
1109                 AC_MSG_RESULT([$with_ping6_command])
1111         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1112                 egrep -i "^round-trip|^rtt" >/dev/null
1113         then
1114                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1115                 AC_MSG_RESULT([$with_ping6_command])
1117         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1118                 egrep -i "^round-trip|^rtt" >/dev/null
1119         then
1120                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1121                 AC_MSG_RESULT([$with_ping6_command])
1123         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1124                 egrep -i "^round-trip|^rtt" >/dev/null
1125         then
1126                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1127                 AC_MSG_RESULT([$with_ping6_command])
1129         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1130                 egrep -i "^round-trip|^rtt" >/dev/null
1131         then
1132                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1133                 AC_MSG_RESULT([$with_ping6_command])
1135         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1136                 egrep -i "^round-trip|^rtt" >/dev/null
1137         then
1138                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1139                 ac_cv_ping6_packets_first=yes
1140                 AC_MSG_RESULT([$with_ping_command])
1142         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1143                 egrep -i "^round-trip|^rtt" >/dev/null
1144         then
1145                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1146                 ac_cv_ping6_packets_first=yes
1147                 AC_MSG_RESULT([$with_ping6_command])
1149         fi
1151 elif test "x$PATH_TO_PING" != "x"; then
1152         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1153                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1154                 egrep -i "^round-trip|^rtt" >/dev/null
1155         then
1156                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1157                 ac_cv_ping6_packets_first=yes
1158                 AC_MSG_RESULT([$with_ping6_command])
1160         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1161                 egrep -i "^round-trip|^rtt" >/dev/null
1162         then
1163                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1164                 ac_cv_ping6_packets_first=yes
1165                 AC_MSG_RESULT([$with_ping6_command])
1167         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1168                 egrep -i "^round-trip|^rtt" >/dev/null
1169         then
1170                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1171                 ac_cv_ping6_packets_first=yes
1172                 AC_MSG_RESULT([$with_ping6_command])
1174         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1175                 egrep -i "^round-trip|^rtt" >/dev/null
1176         then
1177                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1178                 AC_MSG_RESULT([$with_ping6_command])
1180         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1181                 egrep -i "^round-trip|^rtt" >/dev/null
1182         then
1183                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1184                 AC_MSG_RESULT([$with_ping6_command])
1186         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1187                 egrep -i "^round-trip|^rtt" >/dev/null
1188         then
1189                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1190                 AC_MSG_RESULT([$with_ping6_command])
1192         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1193                 egrep -i "^round-trip|^rtt" >/dev/null
1194         then
1195                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1196                 AC_MSG_RESULT([$with_ping6_command])
1198         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1199                 egrep -i "^round-trip|^rtt" >/dev/null
1200         then
1201                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1202                 ac_cv_ping6_packets_first=yes
1203                 AC_MSG_RESULT([$with_ping_command])
1205         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1206                 egrep -i "^round-trip|^rtt" >/dev/null
1207         then
1208                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1209                 ac_cv_ping6_packets_first=yes
1210                 AC_MSG_RESULT([$with_ping6_command])
1212         fi
1214 fi
1216 if test "x$with_ping6_command" != "x"; then
1217         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1218                 [path and args for ICMPv6 ping command])
1219 else
1220         AC_MSG_RESULT([none])
1221 fi
1223 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1224         AC_DEFINE(PING6_PACKETS_FIRST,1,
1225                 [Define if packet count must precede host])
1226 fi
1227 fi
1229 AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1231 AC_MSG_CHECKING(for nslookup syntax)
1232 if test -n "$PATH_TO_NSLOOKUP"
1233 then
1234         if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1235         then
1236                 ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1237                 AC_MSG_RESULT([$ac_cv_nslookup_command])
1239         else
1240                 ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1241                 AC_MSG_RESULT([$ac_cv_nslookup_command])
1243         fi
1244         EXTRAS="$EXTRAS check_dns"
1246 else
1247         AC_MSG_WARN([nslookup command not found])
1248 fi
1250 AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command",
1251         [path and args for nslookup])
1253 AC_PATH_PROG(PATH_TO_HOST,host)
1254 if test -n "$ac_cv_path_PATH_TO_HOST"
1255 then
1256         EXTRAS="$EXTRAS check_dns"
1257 fi
1259 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1260 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1262 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1263 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1265 AC_PATH_PROG(PATH_TO_NTPDATE,ntpdate)
1266 AC_PATH_PROGS(PATH_TO_NTPDC,ntpdc xntpdc)
1267 AC_PATH_PROGS(PATH_TO_NTPQ,ntpq)
1268 if (test -x "$PATH_TO_NTPDATE" || test -x "$PATH_TO_NTPQ")
1269 then
1270         AC_DEFINE_UNQUOTED(PATH_TO_NTPQ,"$PATH_TO_NTPQ",[path to ntpq binary])
1271         AC_DEFINE_UNQUOTED(PATH_TO_NTPDATE,"$PATH_TO_NTPDATE",[path to ntpdate binary])
1272 else
1273         AC_MSG_WARN([Install NTP programs (http://www.ntp.org) if you want to monitor time synchronization])
1274 fi
1276 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1277 if test -x "$PATH_TO_LMSTAT"
1278 then
1279         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1280 else
1281         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1282 fi
1284 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1285 if test -x "$PATH_TO_SMBCLIENT"
1286 then
1287         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1288 else
1289         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1290 fi
1293 AC_PATH_PROG(PATH_TO_WHO,who)
1295 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1296 then
1297         ac_cv_path_to_who="$PATH_TO_WHO -q"
1298 else
1299         ac_cv_path_to_who="$PATH_TO_WHO"
1300 fi
1302 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1303         [path and arguments for invoking 'who'])
1305 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1306 if test -x "$PATH_TO_SNMPGET"
1307 then
1308         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1309         EXTRAS="$EXTRAS check_hpjd check_snmp"
1310 else
1311         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1312 fi
1314 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1315 if test -x "$PATH_TO_SNMPGETNEXT"
1316 then
1317         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1318 fi
1320 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1321 then
1322         AC_MSG_CHECKING(for Net::SNMP perl module)
1323         AC_MSG_RESULT([found])
1324 else
1325         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1326 fi
1328 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1329 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1331 if test -x "$PATH_TO_QUAKESTAT"
1332 then
1333         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1334         EXTRAS="$EXTRAS check_game"
1336 elif test -x "$PATH_TO_QSTAT"
1337 then
1338         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1339         EXTRAS="$EXTRAS check_game"
1340 else
1341         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1342 fi
1344 if test $ac_cv_path_to_qstat 
1345 then
1346         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1347                 [path to qstat/quakestat])
1348 fi
1350 AC_PATH_PROG(PATH_TO_FPING,fping)
1351 if test -x "$PATH_TO_FPING"
1352 then
1353         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1354         EXTRAS="$EXTRAS check_fping"
1355 else
1356         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1357 fi
1359 AC_PATH_PROG(PATH_TO_SSH,ssh)
1361 if test -x "$PATH_TO_SSH"
1362 then
1363         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1364         EXTRAS="$EXTRAS check_by_ssh"
1365 else
1366         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1367 fi
1370 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1371 if test -x "$PATH_TO_MAILQ"
1372 then
1373         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1374 else
1375         AC_MSG_WARN([Could not find mailq or eqivalent])
1376 fi
1378 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1379 if test -x "$PATH_TO_QMAIL_QSTAT"
1380 then
1381         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1382 else
1383         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1384 fi
1386 dnl SWAP info required is amount allocated/available and amount free
1387 dnl The plugin works through all the swap devices and adds up the total swap
1388 dnl available.
1389 AC_PATH_PROG(PATH_TO_SWAP,swap)
1390 if (test -n "$PATH_TO_SWAP")
1391 then
1392 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1393 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1394 then
1395         ac_cv_have_swap=yes
1396         ac_cv_swap_command="$PATH_TO_SWAP -l"
1397         if [$PATH_TO_SWAP -l 2>/dev/null | \
1398                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1399                 >/dev/null]
1400         then
1401                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %d %d"]
1402                 ac_cv_swap_conv=2048
1403                 AC_MSG_RESULT([using IRIX format swap])
1405         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1406         then
1407                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %d %d"]
1408                 ac_cv_swap_conv=2048
1409                 AC_MSG_RESULT([using Unixware format swap])
1410         else
1411                 dnl if we don't know what format swap's output is
1412                 dnl we might as well pretend we didn't see it
1413                 ac_cv_have_swap=""
1414                 ac_cv_swap_command=""
1415         fi
1416 fi
1417 dnl end if for PATH_TO_SWAP
1418 fi
1420 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1421 if (test -n "$PATH_TO_SWAPINFO")
1422 then
1423 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1424 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1425 then
1426         ac_cv_have_swap=yes
1427         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1429         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1430         then
1431                 ac_cv_swap_format=["%*s %d %*d %d"]
1432                 ac_cv_swap_conv=1024
1433                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1434         fi
1436 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1437 then
1438         ac_cv_have_swap=yes
1439         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM",
1440         ac_cv_swap_format=["%*s %d %*d %d"]
1441         ac_cv_swap_conv=1024
1442         AC_MSG_RESULT([using HP-UX format swapinfo])
1443 fi
1444 dnl end if for PATH_TO_SWAPINFO
1445 fi
1447 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1448 if (test -n "$PATH_TO_LSPS")
1449 then
1450 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1451 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1452 then
1453         ac_cv_have_swap=yes
1454         ac_cv_swap_command="$PATH_TO_LSPS -a"
1455         ac_cv_swap_format=["%*s %*s %*s %d%*s %d %*s"]
1456         ac_cv_swap_conv=1
1457         AC_MSG_RESULT([using AIX lsps])
1458 fi
1459 dnl end if for PATH_TO_SWAPINFO
1460 fi
1462 dnl
1463 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1464 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1465 dnl in the various BSD's
1466 dnl
1468 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1469 #ifdef HAVE_SYS_PARAM_H
1470 #include <sys/param.h>
1471 #endif
1472 ])
1473 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1474 AC_CHECK_DECLS([swapctl],,,[
1475                #include <unistd.h>
1476                #include <sys/types.h>
1477                #include <sys/param.h>
1478                #include <sys/stat.h>
1479                #include <sys/swap.h>
1480                ])
1481 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1482                #include <sys/types.h>
1483                #include <sys/param.h>
1484                #include <sys/stat.h>
1485                #include <sys/swap.h>
1486                ])
1487 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1488                #include <unistd.h>
1489                #include <sys/types.h>
1490                #include <sys/param.h>
1491                #include <sys/stat.h>
1492                #include <sys/swap.h>
1493                ])
1495 if test "$ac_cv_have_decl_swapctl" = "yes"; 
1496 then
1497         EXTRAS="$EXTRAS check_swap"
1498         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1499         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1500                 "$ac_cv_type_swapent_t" = "yes"; 
1501         then
1502                 AC_MSG_RESULT([yes])
1503                 ac_cv_check_swap_swapctl_svr4="1";
1504                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1505                           [Define if 2-argument SVR4 swapctl exists])
1506         else
1507                 AC_MSG_RESULT([no])
1508                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1509                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes"; 
1510                 then
1511                         AC_MSG_RESULT([yes])
1512                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1513                                   [Define if 3-argument BSD swapctl exists])
1514                 else
1515                         AC_MSG_RESULT([no])
1516                 fi
1517         fi
1518         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1519         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1520         then
1521                 dnl
1522                 dnl the SVR4 spec returns values in pages
1523                 dnl
1524                 AC_MSG_RESULT([page])
1525                 AC_CHECK_DECLS([sysconf])
1526                 AC_MSG_CHECKING([for system page size])
1527                 if test "$ac_cv_have_decl_sysconf" = "yes";
1528                 then
1529                         AC_MSG_RESULT([determined by sysconf(3)])
1530                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1531                 else
1532                         AC_MSG_WARN([don't know. guessing 4096k])
1533                         ac_cv_swap_conv=256
1534                 fi
1535         else
1536                 dnl
1537                 dnl the BSD spec returns values in blocks
1538                 dnl
1539                 AC_MSG_RESULT([blocks (assuming 512b)])
1540                 ac_cv_swap_conv=2048
1541         fi
1542         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1543                 [Conversion factor to MB])
1544 fi
1545 dnl
1546 dnl end tests for the swapctl system calls
1547 dnl
1550 if test "x$ac_cv_have_swap" != "x" 
1551 then
1552         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1553         EXTRAS="$EXTRAS check_swap"
1554 fi
1555 if test "x$ac_cv_swap_command" != "x" 
1556 then
1557         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1558                 [Path to swap/swapinfo binary, with any args])
1559         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1560                 [Format string for parsing swap output])
1561         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1562                 [Conversion factor to MB])
1563 fi
1565 dnl dunno why this does not work below - use hack (kbd)
1566 dnl fine on linux, broken on solaris
1567 dnl if /bin/test -e "/proc/meminfo"
1568 AC_MSG_CHECKING([for /proc/meminfo])
1569 if [cat /proc/meminfo > /dev/null 2>&1]
1570 then
1571         AC_MSG_RESULT([found /proc/meminfo])
1572         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1573         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"/proc/meminfo",[path to /proc/meminfo if name changes])
1574         EXTRAS="$EXTRAS check_swap"
1575 else
1576         AC_MSG_RESULT([no])
1577 fi
1579 AC_PATH_PROG(PATH_TO_DIG,dig)
1580 AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1581 if test -n "$PATH_TO_DIG"; then
1582         EXTRAS="$EXTRAS check_dig"
1583 fi
1585 if test -f plugins/check_nt.c ; then
1586   EXTRAS="$EXTRAS check_nt"
1587 elif test -f ../plugins/check_nt.c ; then
1588   EXTRAS="$EXTRAS check_nt"
1589 fi
1591 AC_MSG_CHECKING(for va_list)
1592 AC_TRY_COMPILE([#ifdef __STDC__
1593                 #include <stdio.h>
1594                 #include <stdlib.h>
1595                 #include <stdarg.h>
1596                 #else
1597                 #include <sys/types.h>
1598                 #include <stdio.h>
1599                 #include <varargs.h>
1600                 #endif],
1601                 [va_list args;],
1602                 [AC_MSG_RESULT(yes)],
1603                 [NEED_VA_LIST=-DNEED_VA_LIST AC_SUBST(NEED_VA_LIST) AC_MSG_RESULT(no)])
1605 AC_SUBST(EXTRAS)
1606 AC_SUBST(EXTRA_NETOBJS)
1607 AC_SUBST(DEPLIBS)
1609 AM_GNU_GETTEXT_VERSION(0.11.5)
1610 AM_GNU_GETTEXT([no-libtool], [need-ngettext])
1612 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 )
1614 ACX_FEATURE([with],[cgiurl])
1615 ACX_FEATURE([with],[nagios-user])
1616 ACX_FEATURE([with],[nagios-group])
1617 ACX_FEATURE([with],[trusted-path])
1618 ACX_FEATURE([with],[ping-command])
1619 ACX_FEATURE([with],[ping6-command])
1620 ACX_FEATURE([with],[lwres])
1621 ACX_FEATURE([with],[ipv6])
1622 ACX_FEATURE([with],[openssl])
1623 ACX_FEATURE([enable],[emulate-getaddrinfo])