Code

Fix compile errors when looking for openssl
[nagiosplug.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_REVISION ($Revision$)
3 AC_PREREQ(2.58)
4 AC_INIT(nagios-plugins,1.4-beta1)
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 dnl Must come very early on due to coreutils requirement
20 dnl Takes care of AC_GNU_SOURCE, AC_AIX and AC_MINIX
21 gl_USE_SYSTEM_EXTENSIONS
23 AC_PROG_CC
24 AC_PROG_CPP
25 AC_PROG_GCC_TRADITIONAL
26 AC_PROG_RANLIB
28 AC_PROG_MAKE_SET
29 AC_PROG_AWK
31 AC_FUNC_MALLOC
32 AC_FUNC_REALLOC
33 AC_FUNC_ERROR_AT_LINE
35 AC_CONFIG_LIBOBJ_DIR(lib)
36 AC_FUNC_GETLOADAVG([lib])
38 ifdef([AC_FUNC_STRTOD],[AC_FUNC_STRTOD],[AM_FUNC_STRTOD])
39 dnl AM_WITH_REGEX
41 PLUGIN_TEST=`echo $srcdir/plugins/t/*.t|sed -e 's,\.*/plugins/,,g'`
42 AC_SUBST(PLUGIN_TEST)dnl
44 SCRIPT_TEST=`echo $srcdir/plugins-scripts/t/*.t|sed -e 's,\.*/plugins-scripts/,,g'`
45 AC_SUBST(SCRIPT_TEST)dnl
47 WARRANTY="The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\ncopies of the plugins under the terms of the GNU General Public License.\nFor more information about these matters, see the file named COPYING.\n"
48 AC_SUBST(WARRANTY)
50 SUPPORT="Send email to nagios-users@lists.sourceforge.net if you have questions\nregarding use of this software. To submit patches or suggest improvements,\nsend email to nagiosplug-devel@lists.sourceforge.net.\nPlease include version information with all correspondence (when possible,\nuse output from the --version option of the plugin itself).\n"
51 AC_SUBST(SUPPORT)
53 dnl CGIURL has changed for Nagios with 1.0 beta
54 AC_ARG_WITH(cgiurl,
55         ACX_HELP_STRING([--with-cgiurl=DIR],
56                 [sets URL for cgi programs]),
57         with_cgiurl=$withval,
58         with_cgiurl=/nagios/cgi-bin)
59 CGIURL="$with_cgiurl"
60 AC_DEFINE_UNQUOTED(CGIURL,"$CGIURL",[URL of CGI programs])
62 AC_ARG_WITH(nagios_user,
63         ACX_HELP_STRING([--with-nagios-user=USER],
64                 [set user name to run nagios]),
65         with_nagios_user=$withval,
66         with_nagios_user=nagios)
67 AC_ARG_WITH(nagios_group,
68         ACX_HELP_STRING([--with-nagios-group=GROUP],
69                 [set group name to run nagios]),
70         with_nagios_group=$withval,
71         with_nagios_group=nagios)
72 AC_SUBST(with_nagios_user)
73 AC_SUBST(with_nagios_group)
74 INSTALL_OPTS="-o $with_nagios_user -g $with_nagios_group"
75 AC_SUBST(INSTALL_OPTS)
77 AC_ARG_WITH(trusted_path,
78         ACX_HELP_STRING([--with-trusted-path=PATH],
79                 [sets trusted path for executables called by scripts (default=/bin:/sbin:/usr/bin:/usr/sbin)]),
80         with_trusted_path=$withval,
81         with_trusted_path=/bin:/sbin:/usr/bin:/usr/sbin)
82 AC_SUBST(with_trusted_path)
84 EXTRAS=
85 dnl PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/etc:/usr/local/bin:/usr/local/sbin:$PATH
87 LDFLAGS="$LDFLAGS -L."
89 ac_cv_uname_m=`uname -m`
90 ac_cv_uname_s=`uname -s`
91 ac_cv_uname_r=`uname -r`
92 ac_cv_uname_v=`uname -v`
94 PKG_ARCH=`uname -p`
95 REV_DATESTAMP=`date '+%Y.%m.%d.%H.%M'`
96 REV_TIMESTAMP=`date '+%Y%m%d%H%M%S'`
98 AC_SUBST(PKG_ARCH)
99 AC_SUBST(REV_DATESTAMP)
100 AC_SUBST(REV_TIMESTAMP)
102 dnl Checks for programs.
103 AC_PATH_PROG(PYTHON,python)
104 AC_PATH_PROG(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     dnl The /usr checks need to be done so that the right area is include'd
297     if test "$OPENSSL" = "/usr/bin/openssl"; then
298       OPENSSL=/usr
299     elif test "$OPENSSL" = "/usr/sbin/openssl"; then
300       OPENSSL=/usr
301     elif 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     if test "$PKGTEST" ="yes"; then
390       AC_MSG_WARN([OpenSSL libs could not be found])
391     else
392       AC_MSG_WARN([OpenSSL libs and/or directories were not found where specified!])
393     fi
394     with_openssl="no"
395   else
396     check_tcp_ssl="check_simap check_spop check_jabber check_nntps"
397     AC_SUBST(check_tcp_ssl)
398     AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
399     with_openssl="yes"
401     # Needed for subsequent compiled programs
402     LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$OPENSSL/lib$libsuff"
403     export LD_LIBRARY_PATH
404   fi
405 fi
407 AC_CHECK_HEADERS(unistd.h)
409 dnl Check for AF_INET6 support - unistd.h required for Darwin
410 AC_CACHE_CHECK([for IPv6 support], with_ipv6, [
411         AC_TRY_COMPILE([#ifdef HAVE_UNISTD_H
412                         #include <unistd.h>
413                         #endif
414                         #include <netinet/in.h>
415                         #include <sys/socket.h>],
416                         [struct sockaddr_in6 sin6;
417                         void *p;
419                         sin6.sin6_family = AF_INET6;
420                         sin6.sin6_port = 587;
421                         p = &sin6.sin6_addr;],
422                         [with_ipv6=yes], 
423                         [with_ipv6=no])
424         ])
426 if test x"$with_ipv6" != xno ; then
427         AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
428 fi
430 dnl #########################################################################
431 dnl Check if Posix getaddrinfo() is available.  It is also possible to use
432 dnl the version from the lwres library distributed with BIND.
433 dnl #########################################################################
434 AC_ARG_ENABLE([emulate-getaddrinfo],
435               ACX_HELP_STRING([--enable-emulate-getaddrinfo],
436                              [enable getaddrinfo emulation (default=no)]),
437               ,
438               enable_emulate_getaddrinfo=no)
440 AC_ARG_WITH(lwres,
441             ACX_HELP_STRING([--with-lwres=DIR],
442                            [use lwres library for getaddrinfo (default=no)]),
443             ,
444             with_lwres=no)
446 dnl ## enable force to test getaddrinfo.c
447 if test x$enable_emulate_getaddrinfo = xforce ; then
448         enable_emulate_getaddrinfo=yes
449         have_getaddrinfo=no
450 else
452 have_getaddrinfo=no
453 if test x$with_lwres != xno ; then
454         if test "$with_lwres" != yes ; then
455                    CPPFLAGS="-I${with_lwres}/include $CPPFLAGS"
456                    LDFLAGS="-L${with_lwres}/lib $LDFLAGS"
457         fi
458         AC_CHECK_HEADERS(lwres/netdb.h, ,
459                         [AC_MSG_ERROR([cannot find <lwres/netdb.h>])])
460         AC_CHECK_LIB(lwres, lwres_getaddrinfo, ,
461                      [AC_MSG_ERROR([cannot find the lwres library])],
462                      -lnsl -lpthread)
463         have_getaddrinfo=yes
464 fi
466 if test x$have_getaddrinfo != xyes ; then
467         AC_SEARCH_LIBS(getaddrinfo, socket resolv bind nsl c_r cr, have_getaddrinfo=yes)
468 fi
470 dnl # Special nonsense for systems that actually have getaddrinfo but
471 dnl # redefine the name to something else, e.g. OSF
472 if test x$have_getaddrinfo != xyes ; then
473         AC_MSG_CHECKING(if getaddrinfo is redefined in netdb.h)
474         AC_TRY_LINK([
475 #               include <netdb.h>
476         ], [
477                 struct addrinfo hints, *res;
478                 int err;
480                 err = getaddrinfo ("host", "service", &hints, &res);
481         ], [
482                 have_getaddrinfo=yes
483                 AC_MSG_RESULT(yes)
484         ], [AC_MSG_RESULT(no)])
485 fi
487 fi
489 if test x$have_getaddrinfo != xno ; then
490         if test x$enable_emulate_getaddrinfo != xno ; then
491                 AC_MSG_ERROR([getaddrinfo found but emulate-getaddrinfo was enabled])
492         fi
493         AC_DEFINE(HAVE_GETADDRINFO, 1,
494                   [Does system provide RFC 2553/Posix getaddrinfo?])
495 else
496         if test x$enable_emulate_getaddrinfo != xyes ; then
497 dnl                AC_MSG_ERROR([getaddrinfo not found: try --with-lwres or --enable-emulate-getaddrinfo])
498                enable_emulate_getaddrinfo=yes
499                AC_MSG_WARN([enabling getaddrinfo emulation])
500         fi
501         EXTRA_NETOBJS="$EXTRA_NETOBJS getaddrinfo.o"
502 fi
504 if test x"$enable_emulate_getaddrinfo" != xno ; then
505     have_resolver=no
507   dnl  Try for getipnodebyname
508     AC_SEARCH_LIBS(getipnodebyname, resolv bind nsl c_r cr, have_resolver=yes)
509     if test x"$have_resolver" != xno ; then
510          AC_DEFINE(HAVE_GETIPNODEBYNAME, 1,
511                    [Set when getipnodebyname is available])
512     fi
514   dnl  Try for gethostbyname_r
515     if test x"$have_resolver" = xno ; then
516         AC_SEARCH_LIBS(gethostbyname_r, resolv bind nsl c_r cr,
517                        [have_resolver=yes
518                         ACX_WHICH_GETHOSTBYNAME_R])
519     fi
521   dnl  Try for gethostbyname
522     if test x"$have_resolver" = xno ; then
523         if test x"$enable_pthreads" != xno ; then
524             AC_MSG_WARN([using threads but cannot find gethostbyname_r or getipnodebyname])
525         fi
526         AC_SEARCH_LIBS(gethostbyname, resolv bind nsl, ,
527                        [AC_MSG_ERROR([cannot find gethostbyname])])
528     fi
529     EXTRA_NETOBJS="$EXTRA_NETOBJS gethostbyname.o"
531 fi
533 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
534 if test "$FOUNDINCLUDE" = "no"; then
535   _SAVEDCPPFLAGS="$CPPFLAGS"
536   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
537   unset ac_cv_header_krb5_h
538   AC_CHECK_HEADERS(krb5.h,
539                    KRB5INCLUDE="-I/usr/kerberos/include"
540                    FOUNDINCLUDE=yes,
541                    FOUNDINCLUDE=no)
542 fi
543 AC_SUBST(KRBINCLUDE)
544 if test "$FOUNDINCLUDE" = "no"; then
545   CPPFLAGS="$_SAVEDCPPFLAGS"
546 fi
548 dnl
549 dnl Checks for header files.
550 dnl
552 AC_HEADER_STDC
553 AC_HEADER_TIME
554 AC_HEADER_SYS_WAIT
555 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)
556 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h stdlib.h)
558 dnl Checks for typedefs, structures, and compiler characteristics.
559 AC_C_CONST
560 AC_STRUCT_TM
561 AC_TYPE_PID_T
562 AC_TYPE_SIZE_T
563 AC_TYPE_SIGNAL
565 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
566 AC_TRY_LINK([#include <stdarg.h>
567 va_list ap1,ap2;], [va_copy(ap1,ap2);],
568 ac_cv_HAVE_VA_COPY=yes,
569 ac_cv_HAVE_VA_COPY=no)])
570 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
571     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
572 else    
573     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
574     AC_TRY_LINK([#include <stdarg.h>
575     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
576     ac_cv_HAVE___VA_COPY=yes,
577     ac_cv_HAVE___VA_COPY=no)])
578     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
579         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
580     fi
581 fi
583 AC_CHECK_FUNCS(vsnprintf snprintf asprintf vasprintf)
584 AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[
585 AC_TRY_RUN([
586 #include <sys/types.h>
587 #include <stdarg.h>
588 void foo(const char *format, ...) { 
589        va_list ap;
590        int len;
591        char buf[5];
593        va_start(ap, format);
594        len = vsnprintf(buf, 0, format, ap);
595        va_end(ap);
596        if (len != 5) exit(1);
598        va_start(ap, format);
599        len = vsnprintf(0, 0, format, ap);
600        va_end(ap);
601        if (len != 5) exit(1);
603        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
605        exit(0);
607 main() { foo("hello"); }
608 ],
609 ac_cv_HAVE_C99_VSNPRINTF=yes,ac_cv_HAVE_C99_VSNPRINTF=no,ac_cv_HAVE_C99_VSNPRINTF=cross)])
610 if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
611     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Define if system has C99 compatible vsnprintf])
612 fi
614 AC_TRY_COMPILE([#include <sys/time.h>],
615                [struct timeval *tv;
616                 struct timezone *tz;],
617                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
618                AC_TRY_COMPILE([#include <sys/time.h>],
619                               [struct timeval *tv;
620                                struct timezone *tz;
621                                gettimeofday(tv, tz);],
622                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
623                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
625 dnl Checks for library functions.
626 AC_CHECK_FUNCS(memmove select socket strdup strstr strtod strtol strtoul)
628 AC_MSG_CHECKING(return type of socket size)
629 AC_TRY_COMPILE([#include <stdlib.h>
630                 #include <sys/types.h>
631                 #include <sys/socket.h>],
632                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
633                ac_cv_socket_size_type=["size_t"]
634                 AC_MSG_RESULT(size_t),
635                ac_cv_socket_size_type=["int"]
636                 AC_MSG_RESULT(int))
638 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
639         [Define type of socket size])
641 if test -f "/proc/loadavg"
642 then
643   AC_DEFINE(HAVE_PROC_LOADAVG,1,[Define if /proc/loadavg or similar exists])
644   AC_DEFINE_UNQUOTED(PROC_LOADAVG,"/proc/loadavg",[Location of /proc/loadavg])
645 fi
647 dnl #### Process table test
649 AC_PATH_PROG(PATH_TO_PS,ps)
651 AC_MSG_CHECKING(for ps syntax)
652 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
653 dnl Should also work for FreeBSD 5.2.1 and 5.3
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 +[UCOMAND]+ +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 AC_PATH_PROG(PATH_TO_PING,ping)
881 AC_PATH_PROG(PATH_TO_PING6,ping6)
883 AC_ARG_WITH(ping_command,
884         ACX_HELP_STRING([--with-ping-command=SYNTAX],
885                 [sets syntax for ICMP ping]),
886         with_ping_command=$withval,)
888 AC_MSG_CHECKING(for ICMP ping syntax)
889 ac_cv_ping_packets_first=no
890 ac_cv_ping_has_timeout=no
891 if test -n "$with_ping_command"
892 then
893         AC_MSG_RESULT([(command-line) $with_ping_command])
894         if test -n "$ac_cv_ping_packets_first"
895         then
896                 ac_cv_ping_packets_first=yes
897         fi
899 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
900         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
901         egrep -i "^round-trip|^rtt" >/dev/null
902 then
903         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
904         ac_cv_ping_packets_first=yes
905         AC_MSG_RESULT([$with_ping_command])
907 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
908         egrep -i "^round-trip|^rtt" >/dev/null
909 then
910         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
911         ac_cv_ping_packets_first=yes
912   ac_cv_ping_has_timeout=yes
913         AC_MSG_RESULT([$with_ping_command])
915 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
916         egrep -i "^round-trip|^rtt" >/dev/null
917 then
918         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
919         ac_cv_ping_packets_first=yes
920         AC_MSG_RESULT([$with_ping_command])
922 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
923         egrep -i "^round-trip|^rtt" >/dev/null
924 then
925         with_ping_command="$PATH_TO_PING -n -c %d %s"
926         ac_cv_ping_packets_first=yes
927         AC_MSG_RESULT([$with_ping_command])
929 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
930         egrep -i "^round-trip|^rtt" >/dev/null
931 then
932         with_ping_command="$PATH_TO_PING -n %s -c %d"
933         AC_MSG_RESULT([$with_ping_command])
935 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
936         egrep -i "^round-trip|^rtt" >/dev/null
937 then
938         with_ping_command="$PATH_TO_PING %s -n %d"
939         AC_MSG_RESULT([$with_ping_command])
941 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
942         egrep -i "^round-trip|^rtt" >/dev/null
943 then
944         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
945         AC_MSG_RESULT([$with_ping_command])
947 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
948         egrep -i "^round-trip|^rtt" >/dev/null
949 then
950         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
951         AC_MSG_RESULT([$with_ping_command])
953 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
954         egrep -i "^round-trip|^rtt" >/dev/null
955 then
956         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
957         ac_cv_ping_packets_first=yes
958         AC_MSG_RESULT([$with_ping_command])
960 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
961         egrep -i "^round-trip|^rtt" >/dev/null
962 then
963         with_ping_command="$PATH_TO_PING -n -c %d %s"
964         ac_cv_ping_packets_first=yes
965         AC_MSG_RESULT([$with_ping_command])
967 else
968         AC_MSG_WARN([unable to find usable ping syntax])
969 fi
971 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
972         [path and args for ICMP ping command])
974 if test "x$ac_cv_ping_packets_first" != "xno"
975 then
976         AC_DEFINE(PING_PACKETS_FIRST,1,
977                 [Define if packet count must precede host])
978 fi
980 if test "x$ac_cv_ping_has_timeout" != "xno"
981 then
982         AC_DEFINE(PING_HAS_TIMEOUT,1,
983                 [Define if ping has its own timeout option that should be set])
984 fi
986 AC_ARG_WITH(ping6_command,
987         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
988                 [sets syntax for ICMPv6 ping]),
989         with_ping6_command=$withval,)
991 if test x"$with_ipv6" != xno ; then
992 AC_MSG_CHECKING(for ICMPv6 ping syntax)
993 ac_cv_ping6_packets_first=no
994 if test -n "$with_ping6_command"
995 then
996         AC_MSG_RESULT([(command-line) $with_ping6_command])
997         if test -n "$ac_cv_ping6_packets_first"
998         then
999                 ac_cv_ping6_packets_first=yes
1000         fi
1002 elif test "x$PATH_TO_PING6" != "x"; then
1003         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1004                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1005                 egrep -i "^round-trip|^rtt" >/dev/null
1006         then
1007                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1008                 ac_cv_ping6_packets_first=yes
1009                 AC_MSG_RESULT([$with_ping6_command])
1011         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1012                 egrep -i "^round-trip|^rtt" >/dev/null
1013         then
1014                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1015                 ac_cv_ping6_packets_first=yes
1016                 AC_MSG_RESULT([$with_ping6_command])
1018         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1019                 egrep -i "^round-trip|^rtt" >/dev/null
1020         then
1021                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1022                 ac_cv_ping6_packets_first=yes
1023                 AC_MSG_RESULT([$with_ping6_command])
1025         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1026                 egrep -i "^round-trip|^rtt" >/dev/null
1027         then
1028                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1029                 AC_MSG_RESULT([$with_ping6_command])
1031         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1032                 egrep -i "^round-trip|^rtt" >/dev/null
1033         then
1034                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1035                 AC_MSG_RESULT([$with_ping6_command])
1037         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1038                 egrep -i "^round-trip|^rtt" >/dev/null
1039         then
1040                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1041                 AC_MSG_RESULT([$with_ping6_command])
1043         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1044                 egrep -i "^round-trip|^rtt" >/dev/null
1045         then
1046                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1047                 AC_MSG_RESULT([$with_ping6_command])
1049         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1050                 egrep -i "^round-trip|^rtt" >/dev/null
1051         then
1052                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1053                 ac_cv_ping6_packets_first=yes
1054                 AC_MSG_RESULT([$with_ping_command])
1056         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1057                 egrep -i "^round-trip|^rtt" >/dev/null
1058         then
1059                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1060                 ac_cv_ping6_packets_first=yes
1061                 AC_MSG_RESULT([$with_ping6_command])
1063         fi
1065 elif test "x$PATH_TO_PING" != "x"; then
1066         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1067                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1068                 egrep -i "^round-trip|^rtt" >/dev/null
1069         then
1070                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1071                 ac_cv_ping6_packets_first=yes
1072                 AC_MSG_RESULT([$with_ping6_command])
1074         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1075                 egrep -i "^round-trip|^rtt" >/dev/null
1076         then
1077                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1078                 ac_cv_ping6_packets_first=yes
1079                 AC_MSG_RESULT([$with_ping6_command])
1081         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1082                 egrep -i "^round-trip|^rtt" >/dev/null
1083         then
1084                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1085                 ac_cv_ping6_packets_first=yes
1086                 AC_MSG_RESULT([$with_ping6_command])
1088         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1089                 egrep -i "^round-trip|^rtt" >/dev/null
1090         then
1091                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1092                 AC_MSG_RESULT([$with_ping6_command])
1094         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1095                 egrep -i "^round-trip|^rtt" >/dev/null
1096         then
1097                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1098                 AC_MSG_RESULT([$with_ping6_command])
1100         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1101                 egrep -i "^round-trip|^rtt" >/dev/null
1102         then
1103                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1104                 AC_MSG_RESULT([$with_ping6_command])
1106         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1107                 egrep -i "^round-trip|^rtt" >/dev/null
1108         then
1109                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1110                 AC_MSG_RESULT([$with_ping6_command])
1112         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1113                 egrep -i "^round-trip|^rtt" >/dev/null
1114         then
1115                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1116                 ac_cv_ping6_packets_first=yes
1117                 AC_MSG_RESULT([$with_ping_command])
1119         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1120                 egrep -i "^round-trip|^rtt" >/dev/null
1121         then
1122                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1123                 ac_cv_ping6_packets_first=yes
1124                 AC_MSG_RESULT([$with_ping6_command])
1126         fi
1128 fi
1130 if test "x$with_ping6_command" != "x"; then
1131         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1132                 [path and args for ICMPv6 ping command])
1133 else
1134         AC_MSG_RESULT([none])
1135 fi
1137 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1138         AC_DEFINE(PING6_PACKETS_FIRST,1,
1139                 [Define if packet count must precede host])
1140 fi
1141 fi
1143 AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1145 AC_MSG_CHECKING(for nslookup syntax)
1146 if test -n "$PATH_TO_NSLOOKUP"
1147 then
1148         if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1149         then
1150                 ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1151                 AC_MSG_RESULT([$ac_cv_nslookup_command])
1153         else
1154                 ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1155                 AC_MSG_RESULT([$ac_cv_nslookup_command])
1157         fi
1158         EXTRAS="$EXTRAS check_dns"
1160 else
1161         AC_MSG_WARN([nslookup command not found])
1162 fi
1164 AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command",
1165         [path and args for nslookup])
1167 AC_PATH_PROG(PATH_TO_HOST,host)
1168 if test -n "$ac_cv_path_PATH_TO_HOST"
1169 then
1170         EXTRAS="$EXTRAS check_dns"
1171 fi
1173 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1174 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1176 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1177 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1179 AC_PATH_PROG(PATH_TO_NTPDATE,ntpdate)
1180 AC_PATH_PROGS(PATH_TO_NTPDC,ntpdc xntpdc)
1181 AC_PATH_PROGS(PATH_TO_NTPQ,ntpq)
1182 if (test -x "$PATH_TO_NTPDATE" || test -x "$PATH_TO_NTPQ")
1183 then
1184         AC_DEFINE_UNQUOTED(PATH_TO_NTPQ,"$PATH_TO_NTPQ",[path to ntpq binary])
1185         AC_DEFINE_UNQUOTED(PATH_TO_NTPDATE,"$PATH_TO_NTPDATE",[path to ntpdate binary])
1186 else
1187         AC_MSG_WARN([Install NTP programs (http://www.ntp.org) if you want to monitor time synchronization])
1188 fi
1190 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1191 if test -x "$PATH_TO_LMSTAT"
1192 then
1193         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1194 else
1195         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1196 fi
1198 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1199 if test -x "$PATH_TO_SMBCLIENT"
1200 then
1201         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1202 else
1203         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1204 fi
1207 AC_PATH_PROG(PATH_TO_WHO,who)
1209 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1210 then
1211         ac_cv_path_to_who="$PATH_TO_WHO -q"
1212 else
1213         ac_cv_path_to_who="$PATH_TO_WHO"
1214 fi
1216 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1217         [path and arguments for invoking 'who'])
1219 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1220 if test -x "$PATH_TO_SNMPGET"
1221 then
1222         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1223         EXTRAS="$EXTRAS check_hpjd check_snmp"
1224 else
1225         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1226 fi
1228 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1229 if test -x "$PATH_TO_SNMPGETNEXT"
1230 then
1231         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1232 fi
1234 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1235 then
1236         AC_MSG_CHECKING(for Net::SNMP perl module)
1237         AC_MSG_RESULT([found])
1238 else
1239         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1240 fi
1242 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1243 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1245 if test -x "$PATH_TO_QUAKESTAT"
1246 then
1247         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1248         EXTRAS="$EXTRAS check_game"
1250 elif test -x "$PATH_TO_QSTAT"
1251 then
1252         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1253         EXTRAS="$EXTRAS check_game"
1254 else
1255         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1256 fi
1258 if test $ac_cv_path_to_qstat 
1259 then
1260         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1261                 [path to qstat/quakestat])
1262 fi
1264 AC_PATH_PROG(PATH_TO_FPING,fping)
1265 if test -x "$PATH_TO_FPING"
1266 then
1267         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1268         EXTRAS="$EXTRAS check_fping"
1269 else
1270         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1271 fi
1273 AC_PATH_PROG(PATH_TO_SSH,ssh)
1275 if test -x "$PATH_TO_SSH"
1276 then
1277         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1278         EXTRAS="$EXTRAS check_by_ssh"
1279 else
1280         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1281 fi
1284 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1285 if test -x "$PATH_TO_MAILQ"
1286 then
1287         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1288 else
1289         AC_MSG_WARN([Could not find mailq or eqivalent])
1290 fi
1292 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1293 if test -x "$PATH_TO_QMAIL_QSTAT"
1294 then
1295         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1296 else
1297         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1298 fi
1300 dnl SWAP info required is amount allocated/available and amount free
1301 dnl The plugin works through all the swap devices and adds up the total swap
1302 dnl available.
1303 AC_PATH_PROG(PATH_TO_SWAP,swap)
1304 if (test -n "$PATH_TO_SWAP")
1305 then
1306 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1307 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1308 then
1309         ac_cv_have_swap=yes
1310         ac_cv_swap_command="$PATH_TO_SWAP -l"
1311         if [$PATH_TO_SWAP -l 2>/dev/null | \
1312                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1313                 >/dev/null]
1314         then
1315                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %d %d"]
1316                 ac_cv_swap_conv=2048
1317                 AC_MSG_RESULT([using IRIX format swap])
1319         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1320         then
1321                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %d %d"]
1322                 ac_cv_swap_conv=2048
1323                 AC_MSG_RESULT([using Unixware format swap])
1324         else
1325                 dnl if we don't know what format swap's output is
1326                 dnl we might as well pretend we didn't see it
1327                 ac_cv_have_swap=""
1328                 ac_cv_swap_command=""
1329         fi
1330 fi
1331 dnl end if for PATH_TO_SWAP
1332 fi
1334 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1335 if (test -n "$PATH_TO_SWAPINFO")
1336 then
1337 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1338 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1339 then
1340         ac_cv_have_swap=yes
1341         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1343         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1344         then
1345                 ac_cv_swap_format=["%*s %d %*d %d"]
1346                 ac_cv_swap_conv=1024
1347                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1348         fi
1350 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1351 then
1352         ac_cv_have_swap=yes
1353         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM",
1354         ac_cv_swap_format=["%*s %d %*d %d"]
1355         ac_cv_swap_conv=1024
1356         AC_MSG_RESULT([using HP-UX format swapinfo])
1357 fi
1358 dnl end if for PATH_TO_SWAPINFO
1359 fi
1361 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1362 if (test -n "$PATH_TO_LSPS")
1363 then
1364 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1365 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1366 then
1367         ac_cv_have_swap=yes
1368         ac_cv_swap_command="$PATH_TO_LSPS -a"
1369         ac_cv_swap_format=["%*s %*s %*s %d%*s %d %*s"]
1370         ac_cv_swap_conv=1
1371         AC_MSG_RESULT([using AIX lsps])
1372 fi
1373 dnl end if for PATH_TO_SWAPINFO
1374 fi
1376 dnl
1377 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1378 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1379 dnl in the various BSD's
1380 dnl
1382 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1383 #ifdef HAVE_SYS_PARAM_H
1384 #include <sys/param.h>
1385 #endif
1386 ])
1387 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1388 AC_CHECK_DECLS([swapctl],,,[
1389                #include <unistd.h>
1390                #include <sys/types.h>
1391                #include <sys/param.h>
1392                #include <sys/stat.h>
1393                #include <sys/swap.h>
1394                ])
1395 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1396                #include <sys/types.h>
1397                #include <sys/param.h>
1398                #include <sys/stat.h>
1399                #include <sys/swap.h>
1400                ])
1401 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1402                #include <unistd.h>
1403                #include <sys/types.h>
1404                #include <sys/param.h>
1405                #include <sys/stat.h>
1406                #include <sys/swap.h>
1407                ])
1409 if test "$ac_cv_have_decl_swapctl" = "yes"; 
1410 then
1411         EXTRAS="$EXTRAS check_swap"
1412         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1413         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1414                 "$ac_cv_type_swapent_t" = "yes"; 
1415         then
1416                 AC_MSG_RESULT([yes])
1417                 ac_cv_check_swap_swapctl_svr4="1";
1418                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1419                           [Define if 2-argument SVR4 swapctl exists])
1420         else
1421                 AC_MSG_RESULT([no])
1422                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1423                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes"; 
1424                 then
1425                         AC_MSG_RESULT([yes])
1426                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1427                                   [Define if 3-argument BSD swapctl exists])
1428                 else
1429                         AC_MSG_RESULT([no])
1430                 fi
1431         fi
1432         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1433         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1434         then
1435                 dnl
1436                 dnl the SVR4 spec returns values in pages
1437                 dnl
1438                 AC_MSG_RESULT([page])
1439                 AC_CHECK_DECLS([sysconf])
1440                 AC_MSG_CHECKING([for system page size])
1441                 if test "$ac_cv_have_decl_sysconf" = "yes";
1442                 then
1443                         AC_MSG_RESULT([determined by sysconf(3)])
1444                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1445                 else
1446                         AC_MSG_WARN([don't know. guessing 4096k])
1447                         ac_cv_swap_conv=256
1448                 fi
1449         else
1450                 dnl
1451                 dnl the BSD spec returns values in blocks
1452                 dnl
1453                 AC_MSG_RESULT([blocks (assuming 512b)])
1454                 ac_cv_swap_conv=2048
1455         fi
1456         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1457                 [Conversion factor to MB])
1458 fi
1459 dnl
1460 dnl end tests for the swapctl system calls
1461 dnl
1464 if test "x$ac_cv_have_swap" != "x" 
1465 then
1466         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1467         EXTRAS="$EXTRAS check_swap"
1468 fi
1469 if test "x$ac_cv_swap_command" != "x" 
1470 then
1471         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1472                 [Path to swap/swapinfo binary, with any args])
1473         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1474                 [Format string for parsing swap output])
1475         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1476                 [Conversion factor to MB])
1477 fi
1479 dnl dunno why this does not work below - use hack (kbd)
1480 dnl fine on linux, broken on solaris
1481 dnl if /bin/test -e "/proc/meminfo"
1482 AC_MSG_CHECKING([for /proc/meminfo])
1483 if [cat /proc/meminfo > /dev/null 2>&1]
1484 then
1485         AC_MSG_RESULT([found /proc/meminfo])
1486         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1487         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"/proc/meminfo",[path to /proc/meminfo if name changes])
1488         EXTRAS="$EXTRAS check_swap"
1489 else
1490         AC_MSG_RESULT([no])
1491 fi
1493 AC_PATH_PROG(PATH_TO_DIG,dig)
1494 AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1495 if test -n "$PATH_TO_DIG"; then
1496         EXTRAS="$EXTRAS check_dig"
1497 fi
1499 if test -f plugins/check_nt.c ; then
1500   EXTRAS="$EXTRAS check_nt"
1501 elif test -f ../plugins/check_nt.c ; then
1502   EXTRAS="$EXTRAS check_nt"
1503 fi
1505 AC_MSG_CHECKING(for va_list)
1506 AC_TRY_COMPILE([#ifdef __STDC__
1507                 #include <stdio.h>
1508                 #include <stdlib.h>
1509                 #include <stdarg.h>
1510                 #else
1511                 #include <sys/types.h>
1512                 #include <stdio.h>
1513                 #include <varargs.h>
1514                 #endif],
1515                 [va_list args;],
1516                 [AC_MSG_RESULT(yes)],
1517                 [NEED_VA_LIST=-DNEED_VA_LIST AC_SUBST(NEED_VA_LIST) AC_MSG_RESULT(no)])
1519 AC_SUBST(EXTRAS)
1520 AC_SUBST(EXTRA_NETOBJS)
1521 AC_SUBST(DEPLIBS)
1523 AM_GNU_GETTEXT([no-libtool], [need-ngettext])
1524 AM_GNU_GETTEXT_VERSION(0.11.5)
1526 dnl External libraries
1527 np_COREUTILS
1529 AC_OUTPUT(
1530   Makefile 
1531   lib/Makefile 
1532   m4/Makefile 
1533   plugins/Makefile 
1534   plugins-scripts/Makefile 
1535   plugins-scripts/subst 
1536   plugins-scripts/utils.pm 
1537   plugins-scripts/utils.sh 
1538   command.cfg 
1539   test.pl 
1540   pkg/solaris/pkginfo 
1541   intl/Makefile
1542   po/Makefile.in 
1545 ACX_FEATURE([with],[cgiurl])
1546 ACX_FEATURE([with],[nagios-user])
1547 ACX_FEATURE([with],[nagios-group])
1548 ACX_FEATURE([with],[trusted-path])
1549 ACX_FEATURE([with],[ping-command])
1550 ACX_FEATURE([with],[ping6-command])
1551 ACX_FEATURE([with],[lwres])
1552 ACX_FEATURE([with],[ipv6])
1553 ACX_FEATURE([with],[openssl])
1554 ACX_FEATURE([enable],[emulate-getaddrinfo])