Code

Fixed libtap dependency issue. Warning: will install tap into lib directories
[nagiosplug.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_REVISION ($Revision$)
3 AC_PREREQ(2.59)
4 AC_INIT(nagios-plugins,1.4.13)
5 AC_CONFIG_SRCDIR(NPTest.pm)
6 AC_CONFIG_FILES(gl/Makefile)
7 AC_CONFIG_AUX_DIR(build-aux)
8 AM_INIT_AUTOMAKE([1.8.3])
9 AM_CONFIG_HEADER(config.h)
10 AC_CANONICAL_HOST
12 RELEASE=1
13 AC_SUBST(RELEASE)
15 AC_PREFIX_DEFAULT(/usr/local/nagios)
17 dnl Deprecated configure options
20 dnl Append user (-o), group (-g), mode (-m) to install command
21 dnl There is an assumption that this is possible with ./configure's chosen install command
22 extra_install_args=""
23 AC_ARG_WITH(nagios_user,
24         ACX_HELP_STRING([--with-nagios-user=USER],
25                 [Installs executables with this user. Defaults to install user]),
26         extra_install_args="-o $withval")
27 AC_ARG_WITH(nagios_group,
28         ACX_HELP_STRING([--with-nagios-group=GROUP],
29                 [Installs executables with this group. Defaults to install user]),
30         extra_install_args="$extra_install_args -g $withval")
31 AC_ARG_WITH(world_permissions,
32         ACX_HELP_STRING([--without-world-permissions],
33                 [Installs executables without world permissions]))
35 if test "x$with_world_permissions" = xno ; then
36         extra_install_args="$extra_install_args -m 0550"
37 fi
39 INSTALL="$INSTALL $extra_install_args"
40 INSTALL_STRIP_PROGRAM="$INSTALL_STRIP_PROGRAM $extra_install_args"
41 AC_SUBST(INSTALL)
43 AC_PROG_CC
44 gl_EARLY
45 AC_PROG_GCC_TRADITIONAL
46 AC_PROG_LIBTOOL
48 AM_PROG_CC_C_O
50 AC_FUNC_ERROR_AT_LINE
51 AC_SYS_LARGEFILE
53 ifdef([AC_FUNC_STRTOD],[AC_FUNC_STRTOD],[AM_FUNC_STRTOD])
55 PLUGIN_TEST=`echo $srcdir/plugins/t/*.t|sed -e 's,\.*/plugins/,,g'`
56 AC_SUBST(PLUGIN_TEST)dnl
58 SCRIPT_TEST=`echo $srcdir/plugins-scripts/t/*.t|sed -e 's,\.*/plugins-scripts/,,g'`
59 AC_SUBST(SCRIPT_TEST)dnl
61 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"
62 AC_SUBST(WARRANTY)
64 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"
65 AC_SUBST(SUPPORT)
67 dnl CGIURL has changed for Nagios with 1.0 beta
68 AC_ARG_WITH(cgiurl,
69         ACX_HELP_STRING([--with-cgiurl=DIR],
70                 [sets URL for cgi programs]),
71         with_cgiurl=$withval,
72         with_cgiurl=/nagios/cgi-bin)
73 CGIURL="$with_cgiurl"
74 AC_DEFINE_UNQUOTED(CGIURL,"$CGIURL",[URL of CGI programs])
76 AC_ARG_WITH(trusted_path,
77         ACX_HELP_STRING([--with-trusted-path=PATH],
78                 [sets trusted path for executables called by scripts (default=/bin:/sbin:/usr/bin:/usr/sbin)]),
79         with_trusted_path=$withval,
80         with_trusted_path=/bin:/sbin:/usr/bin:/usr/sbin)
81 AC_SUBST(with_trusted_path)
83 EXTRAS=
84 EXTRAS_ROOT=
85 dnl PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/etc:/usr/local/bin:/usr/local/sbin:$PATH
87 LDFLAGS="$LDFLAGS -L."
89 ac_cv_uname_m=`uname -m`
90 ac_cv_uname_s=`uname -s`
91 ac_cv_uname_r=`uname -r`
92 ac_cv_uname_v=`uname -v`
94 PKG_ARCH=`uname -p`
95 REV_DATESTAMP=`date '+%Y.%m.%d.%H.%M'`
96 REV_TIMESTAMP=`date '+%Y%m%d%H%M%S'`
98 AC_SUBST(PKG_ARCH)
99 AC_SUBST(REV_DATESTAMP)
100 AC_SUBST(REV_TIMESTAMP)
102 dnl Checks for programs.
103 AC_PATH_PROG(PYTHON,python)
104 AC_PATH_PROG(SH,sh)
105 AC_PATH_PROG(PERL,perl)
106 AC_PATH_PROG(LIBGNUTLS_CONFIG,libgnutls-config)
107 AC_PATH_PROG(HOSTNAME,hostname)
108 AC_PATH_PROG(BASENAME,basename)
110 dnl allow them to override the path of perl
111 AC_ARG_WITH(perl,
112         ACX_HELP_STRING([--with-perl=PATH],
113                         [sets path to perl executable]),
114                         with_perl=$withval,with_perl=$PERL)
115 AC_SUBST(PERL, $with_perl)
117 dnl openssl/gnutls
118 AC_ARG_WITH(openssl,
119             AC_HELP_STRING([--with-openssl=DIR], 
120                            [path to openssl installation]),)
122 AC_ARG_WITH(gnutls,
123             ACX_HELP_STRING([--with-gnutls=PATH],
124                             [path to gnutls installation root]),)
126 dnl you can only have one or the other
127 if test ! "$with_openssl" = "" && test ! "$with_openssl" = "no"; then
128         with_gnutls="no"
129 fi
130 if test ! "$with_gnutls" = "" && test ! "$with_gnutls" = "no"; then
131         with_openssl="no"
132 fi
134 dnl list of possible dirs to try to autodetect openssl
135 dnl if $dir/include exists, we consider it found
136 dnl the order should allow locally installed versions to override distros' ones
137 OPENSSL_DIRS="/usr /usr/local /usr/slocal /usr/local/openssl /usr/local/ssl \
138               /opt /opt/openssl"
141 dnl
142 dnl Checks for libraries.
143 dnl
145 AC_CHECK_LIB(dce,main,SOCKETLIBS="$SOCKETLIBS -ldce")
146 AC_CHECK_LIB(nsl,main,SOCKETLIBS="$SOCKETLIBS -lnsl")
147 AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket")
148 AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv")
149 AC_SUBST(SOCKETLIBS)
151 dnl
152 dnl check for math-related functions needing -lm
153 AC_CHECK_HEADERS(math.h)
154 AC_CHECK_LIB(m,floor,MATHLIBS="-lm")
155 AC_SUBST(MATHLIBS)
157 dnl Add libtap for tests
158 AC_ARG_ENABLE(libtap,
159   AC_HELP_STRING([--enable-libtap], 
160                 [Enables configuring of libtap in external/tap/. Run "make tap" to compile (default: no)]),
161         [enable_libtap=$enableval],
162         [enable_libtap=no])
163 dnl Have to define TAP_DIR so that Makefile can pull it as an extra dist
164 TAP_DIR=external/tap-1.01
165 AC_SUBST(TAP_DIR)
166 if test "$enable_libtap" = yes; then
167         dnl Have to have AC_CONFIG_SUBDIRS as a literal
168         AC_CONFIG_SUBDIRS([external/tap-1.01])
169         dnl This is required so that TAP stuff is compiled before the libs and tests
170         dnl A make install will also install the tap library, but as this is a development tool, this should be okay
171         INCLUDE_TAP_DIR=$TAP_DIR
172         AC_SUBST(INCLUDE_TAP_DIR)
173         EXTRA_TEST="test_utils test_disk test_tcp test_cmd test_base64"
174         AC_SUBST(EXTRA_TEST)
175 fi
177 dnl INI Parsing
178 AC_ARG_ENABLE(extra-opts,
179   AC_HELP_STRING([--enable-extra-opts], 
180                 [Enables parsing of plugins ini config files for extra options (default: no)]),
181         [enable_extra_opts=$enableval],
182         [enable_extra_opts=no])
183 AM_CONDITIONAL([USE_PARSE_INI],[test "$enable_extra_opts" = "yes"])
184 if test "$enable_extra_opts" = "yes" ; then
185         AC_DEFINE(NP_EXTRA_OPTS,[1],[Enable INI file parsing.])
186         if test "$enable_libtap" = yes; then
187                 EXTRA_TEST="$EXTRA_TEST test_ini test_opts"
188                 AC_SUBST(EXTRA_TEST)
189         fi
190 fi
192 dnl Check for PostgreSQL libraries
193 _SAVEDLIBS="$LIBS"
194 _SAVEDCPPFLAGS="$CPPFLAGS"
195 AC_ARG_WITH(pgsql,
196         ACX_HELP_STRING([--with-pgsql=DIR],
197                 [sets path to pgsql installation]),
198         PGSQL=$withval,)
199 AC_CHECK_LIB(crypt,main)
200 if test "$ac_cv_lib_crypt_main" = "yes" -a "x$PGSQL" != "xno"; then
201   if test -n "$PGSQL"; then
202     LDFLAGS="$LDFLAGS -L$PGSQL/lib"
203     CPPFLAGS="$CPPFLAGS -I$PGSQL/include"
204   fi
205   AC_CHECK_LIB(pq,PQsetdbLogin,,,-lcrypt)
206   if test "$ac_cv_lib_pq_PQsetdbLogin" = "yes"; then
207     AC_CHECK_HEADERS(pgsql/libpq-fe.h)
208     AC_CHECK_HEADERS(postgresql/libpq-fe.h)
209     AC_CHECK_HEADERS(libpq-fe.h)
210     if [[ -n "$PGSQL" -a "$ac_cv_header_libpq_fe_h" = "yes" ]]; then
211       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
212       PGINCLUDE="-I$PGSQL/include"
213     elif test  "$ac_cv_header_pgsql_libpq_fe_h" = "yes"; then
214       PGLIBS="-lpq -lcrypt"
215       PGINCLUDE="-I/usr/include/pgsql"
216     elif test  "$ac_cv_header_postgresql_libpq_fe_h" = "yes"; then
217       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
218       PGINCLUDE="-I/usr/include/postgresql"
219     elif test  "$ac_cv_header_libpq_fe_h" = "yes"; then
220       PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
221       PGINCLUDE="-I$PGSQL/include"
222     fi
223     if test -z "$PGINCLUDE"; then
224       AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
225       AC_MSG_WARN([install PostgreSQL headers to compile this plugin (see REQUIREMENTS).])
226     else
227       AC_SUBST(PGLIBS)
228       AC_SUBST(PGINCLUDE)
229       EXTRAS="$EXTRAS check_pgsql"
230     fi
231   else
232     AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
233     AC_MSG_WARN([LIBS="$LIBS" CPPFLAGS="$CPPFLAGS"])
234     AC_MSG_WARN([install PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
235   fi
236 else
237   AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
238   AC_MSG_WARN([install lib crypt and PostgreSQL libs to compile this plugin (see REQUIREMENTS).])
239 fi
240 LIBS="$_SAVEDLIBS"
241 CPPFLAGS="$_SAVEDCPPFLAGS"
243 dnl Check for radius libraries
244 _SAVEDLIBS="$LIBS"
245 AC_CHECK_LIB(radiusclient,rc_read_config)
246 if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
247   EXTRAS="$EXTRAS check_radius"
248         RADIUSLIBS="-lradiusclient"
249   AC_SUBST(RADIUSLIBS)
250 else
251   AC_CHECK_LIB(radiusclient-ng,rc_read_config)
252   if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then
253     EXTRAS="$EXTRAS check_radius"
254           RADIUSLIBS="-lradiusclient-ng"
255     AC_SUBST(RADIUSLIBS)
256   else
257     AC_MSG_WARN([Skipping radius plugin])
258     AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
259   fi
260 fi
261 LIBS="$_SAVEDLIBS"
263 dnl Check for LDAP libraries
264 _SAVEDLIBS="$LIBS"
265 AC_CHECK_LIB(ldap,main,,,-llber)
266 if test "$ac_cv_lib_ldap_main" = "yes"; then
267   LDAPLIBS="-lldap -llber"\
268   LDAPINCLUDE="-I/usr/include/ldap"
269   AC_SUBST(LDAPLIBS)
270   AC_SUBST(LDAPINCLUDE)
271   AC_CHECK_FUNCS(ldap_set_option)
272   EXTRAS="$EXTRAS check_ldap"
273         AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
274 else
275   AC_MSG_WARN([Skipping LDAP plugin])
276   AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
277 fi
278 LIBS="$_SAVEDLIBS"
280 dnl Check for headers used by check_ide_smart
281 AC_CHECK_HEADER(linux/hdreg.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
282 if test "$FOUNDINCLUDE" = "yes" ; then
283         AC_CHECK_HEADER(linux/types.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
284 fi
286 if test "$FOUNDINCLUDE" = "yes" ; then
287         EXTRAS="$EXTRAS check_ide_smart"
288 else
289         AC_MSG_WARN([Skipping check_ide_smart plugin.]) 
290         AC_MSG_WARN([check_ide_smart is linux specific. It requires linux/hdreg.h and linux/types.h.]) 
291 fi
293 dnl Check for mysql libraries
294 np_mysqlclient
295 if test $with_mysql = "no" ; then
296   AC_MSG_WARN([Skipping mysql plugin])
297   AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
298 else
299   EXTRAS="$EXTRAS check_mysql check_mysql_query"
300   MYSQLINCLUDE="$np_mysql_include"
301   MYSQLLIBS="$np_mysql_libs"
302   MYSQLCFLAGS="$np_mysql_cflags"
303   AC_SUBST(MYSQLINCLUDE)
304   AC_SUBST(MYSQLLIBS)
305   AC_SUBST(MYSQLCFLAGS)
306 fi
308 AC_ARG_WITH([ipv6],
309         [AS_HELP_STRING([--with-ipv6], [support IPv6 @<:@default=check@:>@])],
310         [], [with_ipv6=check])
312 dnl Check for AF_INET6 support - unistd.h required for Darwin
313 if test "$with_ipv6" != "no"; then
314         AC_CACHE_CHECK([for IPv6 support], np_cv_sys_ipv6, [
315                 AC_TRY_COMPILE(
316                         [#ifdef HAVE_UNISTD_H
317                         #include <unistd.h>
318                         #endif
319                         #include <netinet/in.h>
320                         #include <sys/socket.h>],
321                         [struct sockaddr_in6 sin6;
322                         void *p;
324                         sin6.sin6_family = AF_INET6;
325                         sin6.sin6_port = 587;
326                         p = &sin6.sin6_addr;],
327                         [np_cv_sys_ipv6=yes],
328                         [np_cv_sys_ipv6=no])
329                 ])
330         if test "$np_cv_sys_ipv6" = "no" -a "$with_ipv6" != "check"; then
331                 AC_MSG_FAILURE([--with-ipv6 was given, but test for IPv6 support failed])
332         fi
333         if test "$np_cv_sys_ipv6" = "yes"; then
334                 AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
335         fi
336         with_ipv6="$np_cv_sys_ipv6"
337 fi
340 dnl Checks for Kerberos. Must come before openssl checks for Redhat EL 3
341 AC_CHECK_HEADERS(krb5.h,FOUNDINCLUDE=yes,FOUNDINCLUDE=no)
342 if test "$FOUNDINCLUDE" = "no"; then
343   _SAVEDCPPFLAGS="$CPPFLAGS"
344   CPPFLAGS="$_SAVEDCPPFLAGS -I/usr/kerberos/include"
345   unset ac_cv_header_krb5_h
346   AC_CHECK_HEADERS(krb5.h,
347                    KRB5INCLUDE="-I/usr/kerberos/include"
348                    FOUNDINCLUDE=yes,
349                    FOUNDINCLUDE=no)
350 fi
351 AC_SUBST(KRBINCLUDE)
352 if test "$FOUNDINCLUDE" = "no"; then
353   CPPFLAGS="$_SAVEDCPPFLAGS"
354 fi
356 dnl *** The following block comes from wget configure.ac ***
357 dnl Unfortunately, as of this writing (OpenSSL 0.9.6), the libcrypto
358 dnl shared library doesn't record its dependency on libdl, so we
359 dnl need to check for it ourselves so we won't fail to link due to a
360 dnl lack of -ldl.  Most OSes use dlopen(), but HP-UX uses
361 dnl shl_load().
362 AC_CHECK_LIB(dl,dlopen)
363 AC_CHECK_LIB(dl,shl_load)
365 dnl openssl detection/configuration
366 if ! test x"$with_openssl" = x"no"; then
367         dnl Check for OpenSSL location if it wasn't already specified
368         if ! test -d "$with_openssl"; then
369                 for d in $OPENSSL_DIRS; do
370                         if test -x ${d}/bin/openssl || test -x ${d}/sbin/openssl ; then
371                                 with_openssl=$d
372                         fi
373                 done
374         fi
376         _SAVEDCPPFLAGS="$CPPFLAGS"
377         _SAVEDLDFLAGS="$LDFLAGS"
378         dnl Check for OpenSSL header files
379         unset FOUNDINCLUDE
380         if test x"$with_openssl" != x"/usr" ; then
381                 CPPFLAGS="$CPPFLAGS -I$with_openssl/include"
382                 LDFLAGS="$LDFLAGS -L$with_openssl/lib"
383         fi
385         dnl check for openssl in $dir/include/openssl
386         AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
387                          SSLINCLUDE="-I$with_openssl/include"
388                          FOUNDINCLUDE=yes,
389                          FOUNDINCLUDE=no)
390         dnl else check to see if $dir/include has it
391         if test "$FOUNDINCLUDE" = "no"; then
392                 AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
393                                  SSLINCLUDE="-I$with_openssl/include"
394                                  FOUNDINCLUDE=yes,
395                                  FOUNDINCLUDE=no)
396         fi
397         AC_SUBST(SSLINCLUDE)
398         dnl if we didn't find it, reset CPPFLAGS
399         if test "$FOUNDINCLUDE" = "no"; then
400                 CPPFLAGS="$_SAVEDCPPFLAGS"
401                 LDFLAGS="$_SAVEDLDFLAGS"
402         fi
404         dnl Check for crypto lib
405         _SAVEDLIBS="$LIBS"
406         LIBS="-L${with_openssl}/lib"
407         AC_CHECK_LIB(crypto,CRYPTO_lock)
408         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
409                 dnl Check for SSL lib
410                 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
411         fi
412         LIBS="$_SAVEDLIBS"
414         dnl test headers and libs to decide whether check_http should use SSL
415         if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
416                 if test "$ac_cv_lib_ssl_main" = "yes"; then
417                         if test "$FOUNDINCLUDE" = "yes"; then
418                                 FOUNDOPENSSL="yes"
419                         fi
420                 fi
421         fi
422 fi
425 dnl check for gnutls if openssl isn't found (or is disabled)
426 if test ! "$FOUNDOPENSSL" = "yes" && test ! "$with_gnutls" = "no"; then
427         if test ! "$with_gnutls" = ""; then
428                 CPPFLAGS="$CPPFLAGS -I${with_gnutls}/include"
429         elif test ! "$LIBGNUTLS_CONFIG" = ""; then
430                 CPPFLAGS="$CPPFLAGS -I`$LIBGNUTLS_CONFIG --prefix`"
431         fi
432         AC_CHECK_HEADERS([gnutls/openssl.h],FOUNDGNUTLS="yes",)
433         if test "$FOUNDGNUTLS" = "yes"; then
434                 AC_CHECK_LIB(gnutls-openssl,main,SSLLIBS="-lgnutls-openssl")
435         fi
436 fi
437 dnl end check for gnutls
439 if test "$FOUNDOPENSSL" = "yes" || test "$FOUNDGNUTLS" = "yes"; then
440         check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
441         AC_SUBST(check_tcp_ssl)
442         AC_SUBST(SSLLIBS)
443         AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
444         if test "$FOUNDOPENSSL" = "yes"; then
445                 AC_DEFINE(USE_OPENSSL,1,[Define if using OpenSSL libraries])
446                 with_openssl="yes"
447                 with_gnutls="no"
448         else
449                 AC_DEFINE(USE_GNUTLS,1,[Define if using gnutls libraries])
450                 with_gnutls="yes"
451                 with_openssl="no"
452         fi
453 else
454         dnl else deliberately disabled or no ssl support available
455         AC_MSG_WARN([OpenSSL or GnuTLS libs could not be found or were disabled])
456         with_openssl="no"
457         with_gnutls="no"
458 fi
460 dnl
461 dnl Checks for header files.
462 dnl
464 AC_HEADER_TIME
465 AC_HEADER_SYS_WAIT
466 AC_CHECK_HEADERS(signal.h syslog.h uio.h errno.h sys/time.h sys/socket.h sys/un.h sys/poll.h)
467 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h)
469 dnl Checks for typedefs, structures, and compiler characteristics.
470 AC_C_CONST
471 AC_STRUCT_TM
472 AC_TYPE_PID_T
473 AC_TYPE_SIZE_T
474 AC_TYPE_SIGNAL
475 AC_TYPE_MBSTATE_T
477 AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
478 AC_TRY_LINK([#include <stdarg.h>
479 va_list ap1,ap2;], [va_copy(ap1,ap2);],
480 ac_cv_HAVE_VA_COPY=yes,
481 ac_cv_HAVE_VA_COPY=no)])
482 if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
483     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
484 else    
485     AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
486     AC_TRY_LINK([#include <stdarg.h>
487     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
488     ac_cv_HAVE___VA_COPY=yes,
489     ac_cv_HAVE___VA_COPY=no)])
490     if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
491         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
492     fi
493 fi
495 AC_TRY_COMPILE([#include <sys/time.h>],
496                [struct timeval *tv;
497                 struct timezone *tz;],
498                AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
499                AC_TRY_COMPILE([#include <sys/time.h>],
500                               [struct timeval *tv;
501                                struct timezone *tz;
502                                gettimeofday(tv, tz);],
503                               AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
504                               AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
506 dnl Checks for library functions.
507 AC_CHECK_FUNCS(memmove select socket strdup strstr strtol strtoul floor)
508 AC_CHECK_FUNCS(poll)
510 AC_MSG_CHECKING(return type of socket size)
511 AC_TRY_COMPILE([#include <stdlib.h>
512                 #include <sys/types.h>
513                 #include <sys/socket.h>],
514                [int a = send(1, (const void *) buffer, (size_t *) 0, (int *) 0);],
515                ac_cv_socket_size_type=["size_t"]
516                 AC_MSG_RESULT(size_t),
517                ac_cv_socket_size_type=["int"]
518                 AC_MSG_RESULT(int))
520 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
521         [Define type of socket size])
524 dnl #### Process table test
526 AC_PATH_PROG(PATH_TO_PS,ps)
528 AC_MSG_CHECKING(for ps syntax)
529 AC_ARG_WITH(ps_command,
530             ACX_HELP_STRING([--with-ps-command=PATH], 
531                             [Verbatim command to execute for ps]),
532             PS_COMMAND=$withval)
533 AC_ARG_WITH(ps_format,
534             ACX_HELP_STRING([--with-ps-format=FORMAT],
535                             [Format string for scanning ps output]),
536             PS_FORMAT=$withval)
537 AC_ARG_WITH(ps_cols,
538             ACX_HELP_STRING([--with-ps-cols=NUM], 
539                             [Number of columns in ps command]),
540             PS_COLS=$withval)
541 AC_ARG_WITH(ps_varlist,
542             ACX_HELP_STRING([--with-ps-varlist=LIST],
543                             [Variable list for sscanf of 'ps' output]),
544             PS_VARLIST=$withval)
546 if test -n "$PS_COMMAND" && test -n "$PS_FORMAT" && test -n "$PS_COLS" && test -n "$PS_VARLIST"; then 
547         ac_cv_ps_command="$PS_COMMAND"
548         ac_cv_ps_format="$PS_FORMAT"
549         ac_cv_ps_varlist="$PS_VARLIST"
550         ac_cv_ps_cols="$PS_COLS"
551         AC_MSG_RESULT([(command-line) $ac_cv_ps_command])
553 dnl Now using the pst3/kmem hack for solaris systems to avoid truncation
554 elif test "$ac_cv_uname_s" = "SunOS"; then
555         #
556         # this is a very, very ugly hack, to hardcode the location for plugins
557         #
558         if test "$libexecdir" = '${exec_prefix}/libexec'; then
559                 if test "$exec_prefix" = "NONE"; then
560                         if test "$prefix" = "NONE"; then
561                                 pst3="$ac_default_prefix/libexec/pst3"
562                         else
563                                 pst3="$prefix/libexec/pst3"
564                         fi
565                 else
566                         pst3="$exec_prefix/libexec/pst3"
567                 fi
568         else
569                 pst3="$libexecdir/pst3"
570         fi
571         ac_cv_ps_command="$pst3"
572         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
573         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
574         ac_cv_ps_cols=9
575         AC_MSG_RESULT([using nagios-plugins internal ps command (pst3) for solaris])
576         if test `isainfo -b` = 64 ; then
577                 PST3CFLAGS="-m64"
578                 AC_SUBST(PST3CFLAGS)
579                 AC_MSG_NOTICE([using 64bit pst3])       
580         else
581                 AC_MSG_NOTICE([using 32bit pst3])
582         fi
583         EXTRAS_ROOT="$EXTRAS_ROOT pst3"
585 dnl Removing this for the moment - Ton
586 dnl Using /usr/ucb/ps on Solaris systems, to avoid truncation
587 dnl Limitation that command name is not available
588 dnl elif test "$ac_cv_uname_s" = "SunOS" && /usr/ucb/ps -alxwwn 2>/dev/null | \
589 dnl     egrep -i ["^ *F +UID +PID +PPID +%C +PRI +NI +SZ +RSS +WCHAN +S +TT +TIME +COMMAND"] > /dev/null
590 dnl then
591 dnl     ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procpcpu,&procvsz,&procrss,procstat,&pos]"
592 dnl     ac_cv_ps_command="/usr/ucb/ps -alxwwn"
593 dnl     ac_cv_ps_format=["%*s %d %d %d %d %*d %*d %d %d%*[ 0123456789abcdef]%[OSRZT]%*s %*s %n"]
594 dnl     ac_cv_ps_cols=8
595 dnl     AC_MSG_RESULT([$ac_cv_ps_command])
597 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
598 dnl so test for this first...
599 elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
600         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
601 then
602         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
603         ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
604         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
605         ac_cv_ps_cols=9
606         AC_MSG_RESULT([$ac_cv_ps_command])
608 dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
609 dnl Should also work for FreeBSD 5.2.1 and 5.3
610 dnl  STAT UCOMM              VSZ   RSS USER      PPID COMMAND
611 elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
612         egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
613 then
614         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
615         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
616         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
617         ac_cv_ps_cols=9
618         AC_MSG_RESULT([$ac_cv_ps_command])
620 dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4. 
621 dnl Limitation: Only first 16 chars returned for ucomm field
622 dnl Must come before ps -weo
623 elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
624         egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
625 then
626         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
627         ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
628         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
629         ac_cv_ps_cols=9
630         AC_MSG_RESULT([$ac_cv_ps_command])
632 dnl  STAT UCOMM              VSZ   RSS USER       UID  PPID COMMAND
633 elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
634         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
635 then
636         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
637         ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
638         ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
639         ac_cv_ps_cols=10
640         AC_MSG_RESULT([$ac_cv_ps_command])
642 dnl FreeBSD
643 elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
644         egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
645 then
646         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
647         ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
648         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
649         ac_cv_ps_cols=9
650         AC_MSG_RESULT([$ac_cv_ps_command])
652 dnl BSD-like mode in RH 6.1
653 elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
654         egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
655 then
656         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
657         ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
658         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
659         ac_cv_ps_cols=9
660         AC_MSG_RESULT([$ac_cv_ps_command])
662 dnl SunOS 4.1.3:
663 dnl  F  UID  PID  PPID  CP  PRI  NI  SZ  RSS  WCHAN  STAT  TT  TIME  COMMAND
664 dnl Need the head -1 otherwise test will work because arguments are found
665 elif ps -laxnwww 2>/dev/null | head -1 | \
666         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
667 then
668         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
669         ac_cv_ps_command="$PATH_TO_PS -laxnwww"
670         ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s"
671         ac_cv_ps_cols=9
672         AC_MSG_RESULT([$ac_cv_ps_command])
674 dnl Debian Linux / procps v1.2.9:
675 dnl  FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
676 dnl    100     0     1     0   0   0    776    76  c0131c8c   S  ffff  0:11 init [2]
677 dnl
678 elif ps laxnwww 2>/dev/null | \
679         egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
680 then
681         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
682         ac_cv_ps_command="$PATH_TO_PS laxnwww"
683         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
684         ac_cv_ps_cols=9
685         AC_MSG_RESULT([$ac_cv_ps_command])
687 dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
688 elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
689         egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
690 then
691         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
692         ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
693         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
694         ac_cv_ps_cols=9
695         AC_MSG_RESULT([$ac_cv_ps_command])
697 dnl Tru64 - needs %*[ +<>] in PS_FORMAT. 
698 dnl Has /usr/bin/ps and /sbin/ps - force sbin version
699 dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead 
700 dnl of 1500). Will need big changes to check_procs to support
701 elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
702         egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
703 then
704         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
705         ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
706         ac_cv_ps_format=["%s%*[ +<>] %d %d %d %f %s %s %n"]
707         ac_cv_ps_cols=8
708         AC_MSG_RESULT([$ac_cv_ps_command])
710 elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
711         egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
712 then
713         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
714         ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
715         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
716         ac_cv_ps_cols=9
717         AC_MSG_RESULT([$ac_cv_ps_command])
719 dnl AIX 4.3.3 and 5.1 do not have an rss field
720 elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
721         egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
722 then
723         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
724         ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz 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 - with no RSS])
729 dnl Solaris 2.6
730 elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
731         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
732 then
733         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
734         ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
735         # There must be no space between the %s and %n due to a wierd problem in sscanf where
736         # it will return %n as longer than the line length
737         ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
738         ac_cv_ps_cols=9
739         AC_MSG_RESULT([$ac_cv_ps_command])
741 elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
742         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
743 then
744         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
745         ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
746         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
747         ac_cv_ps_cols=9
748         AC_MSG_RESULT([$ac_cv_ps_command])
750 elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
751         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
752 then
753         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
754         ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
755         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
756         ac_cv_ps_cols=9
757         AC_MSG_RESULT([$ac_cv_ps_command])
759 dnl wonder who takes state instead of stat
760 elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
761         egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
762 then
763         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
764         ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
765         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
766         ac_cv_ps_cols=8
767         AC_MSG_RESULT([$ac_cv_ps_command])
769 dnl IRIX 53
770 elif ps -el 2>/dev/null | \
771         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
772 then
773         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
774         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
775         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s"
776         ac_cv_ps_cols=8
777         AC_MSG_RESULT([$ac_cv_ps_command])
779 dnl IRIX 63
780 elif ps -el 2>/dev/null | \
781         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
782 then
783         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
784         ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
785         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
786         ac_cv_ps_cols=6
787         AC_MSG_RESULT([$ac_cv_ps_command])
789 dnl AIX 4.1:
790 dnl     F S      UID   PID  PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
791 dnl    303 A        0     0     0 120  16 -- 1c07  20   24              -  0:45 swapper
792 elif ps -el 2>/dev/null | \
793         egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
794 then
795         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
796         ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
797         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
798         ac_cv_ps_cols=6
799         AC_MSG_RESULT([$ac_cv_ps_command])
801 dnl AIX?
802 elif ps glaxen 2>/dev/null | \
803         egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
804 then
805         ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
806         ac_cv_ps_command="$PATH_TO_PS glaxen"
807         ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s"
808         ac_cv_ps_cols=8
809         AC_MSG_RESULT([$ac_cv_ps_command])
811 dnl MacOSX / Darwin
812 dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT
813 dnl Some truncation will happen in UCOMM column
814 dnl STAT      VSZ    RSS   UID  PPID %CPU UCOMM            COMMAND
815 dnl Ss      52756  22496   501     1   6.9 Window Manager   /System/Library/CoreServices/WindowServer -daemon
816 elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
817         egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
818 then
819         ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
820         ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
821         ac_cv_ps_format="%s %d %d %d %d %d %f %s %n"
822         ac_cv_ps_cols=8
823         AC_MSG_RESULT([$ac_cv_ps_command])
825 dnl UnixWare 
826 elif ps -Al 2>/dev/null | \
827         egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
828 then
829         ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
830         ac_cv_ps_command="$PATH_TO_PS -Al"
831         ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s"
832         ac_cv_ps_cols=8
833         AC_MSG_RESULT([$ac_cv_ps_command])
835 else
836         AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled])
837 fi
839 if test -n "$ac_cv_ps_varlist" ; then
840         AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist,
841                 [Variable list for sscanf of 'ps' output])
842         AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command",
843                 [Verbatim command to execute for ps in check_procs])
844         AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format",
845                 [Format string for scanning ps output in check_procs])
846         AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
847                 [Number of columns in ps command])
848         EXTRAS="$EXTRAS check_procs check_nagios"
849         if echo "$ac_cv_ps_varlist" | grep "procetime" >/dev/null; then
850                 AC_DEFINE(PS_USES_PROCETIME,"yes",
851                           [Whether the ps utility uses the "procetime" field])
852         fi
853 fi
855 AC_PATH_PROG(PATH_TO_PING,ping)
856 AC_PATH_PROG(PATH_TO_PING6,ping6)
858 AC_ARG_WITH(ping_command,
859         ACX_HELP_STRING([--with-ping-command=SYNTAX],
860                 [sets syntax for ICMP ping]),
861         with_ping_command=$withval,)
863 AC_MSG_CHECKING(for ICMP ping syntax)
864 ac_cv_ping_packets_first=no
865 ac_cv_ping_has_timeout=no
866 if test -n "$with_ping_command"
867 then
868         AC_MSG_RESULT([(command-line) $with_ping_command])
869         if test -n "$ac_cv_ping_packets_first"
870         then
871                 ac_cv_ping_packets_first=yes
872                 ac_cv_ping_has_timeout=yes
873         fi
875 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
876         $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
877         egrep -i "^round-trip|^rtt" >/dev/null
878 then
879         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
880         ac_cv_ping_packets_first=yes
881         AC_MSG_RESULT([$with_ping_command])
883 elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
884         egrep -i "^round-trip|^rtt" >/dev/null
885 then
886         with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
887         ac_cv_ping_packets_first=yes
888   ac_cv_ping_has_timeout=yes
889         AC_MSG_RESULT([$with_ping_command])
891 elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
892         egrep -i "^round-trip|^rtt" >/dev/null
893 then
894         with_ping_command="$PATH_TO_PING -n -U -c %d %s"
895         ac_cv_ping_packets_first=yes
896         AC_MSG_RESULT([$with_ping_command])
898 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
899         egrep -i "^round-trip|^rtt" >/dev/null
900 then
901         with_ping_command="$PATH_TO_PING -n -c %d %s"
902         ac_cv_ping_packets_first=yes
903         AC_MSG_RESULT([$with_ping_command])
905 elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
906         egrep -i "^round-trip|^rtt" >/dev/null
907 then
908         with_ping_command="$PATH_TO_PING -n %s -c %d"
909         AC_MSG_RESULT([$with_ping_command])
911 elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
912         egrep -i "^round-trip|^rtt" >/dev/null
913 then
914         with_ping_command="$PATH_TO_PING %s -n %d"
915         AC_MSG_RESULT([$with_ping_command])
917 elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
918         egrep -i "^round-trip|^rtt" >/dev/null
919 then
920         with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
921         AC_MSG_RESULT([$with_ping_command])
923 elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
924         egrep -i "^round-trip|^rtt" >/dev/null
925 then
926         with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
927         AC_MSG_RESULT([$with_ping_command])
929 elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
930         egrep -i "^round-trip|^rtt" >/dev/null
931 then
932         with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
933         ac_cv_ping_packets_first=yes
934         AC_MSG_RESULT([$with_ping_command])
936 elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
937         egrep -i "^round-trip|^rtt" >/dev/null
938 then
939         with_ping_command="$PATH_TO_PING -n -c %d %s"
940         ac_cv_ping_packets_first=yes
941         AC_MSG_RESULT([$with_ping_command])
943 else
944         AC_MSG_WARN([unable to find usable ping syntax])
945 fi
947 AC_DEFINE_UNQUOTED(PING_COMMAND,"$with_ping_command",
948         [path and args for ICMP ping command])
950 if test "x$ac_cv_ping_packets_first" != "xno"
951 then
952         AC_DEFINE(PING_PACKETS_FIRST,1,
953                 [Define if packet count must precede host])
954 fi
956 if test "x$ac_cv_ping_has_timeout" != "xno"
957 then
958         AC_DEFINE(PING_HAS_TIMEOUT,1,
959                 [Define if ping has its own timeout option that should be set])
960 fi
962 AC_ARG_WITH(ping6_command,
963         ACX_HELP_STRING([--with-ping6-command=SYNTAX],
964                 [sets syntax for ICMPv6 ping]),
965         with_ping6_command=$withval,)
967 if test x"$with_ipv6" != xno ; then
968 AC_MSG_CHECKING(for ICMPv6 ping syntax)
969 ac_cv_ping6_packets_first=no
970 if test -n "$with_ping6_command"
971 then
972         AC_MSG_RESULT([(command-line) $with_ping6_command])
973         if test -n "$ac_cv_ping6_packets_first"
974         then
975                 ac_cv_ping6_packets_first=yes
976         fi
978 elif test "x$PATH_TO_PING6" != "x"; then
979         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
980                 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
981                 egrep -i "^round-trip|^rtt" >/dev/null
982         then
983                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
984                 ac_cv_ping6_packets_first=yes
985                 AC_MSG_RESULT([$with_ping6_command])
987         elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
988                 egrep -i "^round-trip|^rtt" >/dev/null
989         then
990                 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
991                 ac_cv_ping6_packets_first=yes
992                 ac_cv_ping_has_timeout=yes
993                 AC_MSG_RESULT([$with_ping6_command])
995         elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
996                 egrep -i "^round-trip|^rtt" >/dev/null
997         then
998                 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
999                 ac_cv_ping6_packets_first=yes
1000                 AC_MSG_RESULT([$with_ping6_command])
1002         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1003                 egrep -i "^round-trip|^rtt" >/dev/null
1004         then
1005                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1006                 ac_cv_ping6_packets_first=yes
1007                 AC_MSG_RESULT([$with_ping6_command])
1009         elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1010                 egrep -i "^round-trip|^rtt" >/dev/null
1011         then
1012                 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1013                 AC_MSG_RESULT([$with_ping6_command])
1015         elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1016                 egrep -i "^round-trip|^rtt" >/dev/null
1017         then
1018                 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1019                 AC_MSG_RESULT([$with_ping6_command])
1021         elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1022                 egrep -i "^round-trip|^rtt" >/dev/null
1023         then
1024                 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1025                 AC_MSG_RESULT([$with_ping6_command])
1027         elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1028                 egrep -i "^round-trip|^rtt" >/dev/null
1029         then
1030                 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1031                 AC_MSG_RESULT([$with_ping6_command])
1033         elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1034                 egrep -i "^round-trip|^rtt" >/dev/null
1035         then
1036                 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1037                 ac_cv_ping6_packets_first=yes
1038                 AC_MSG_RESULT([$with_ping_command])
1040         elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1041                 egrep -i "^round-trip|^rtt" >/dev/null
1042         then
1043                 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1044                 ac_cv_ping6_packets_first=yes
1045                 AC_MSG_RESULT([$with_ping6_command])
1047         fi
1049 elif test "x$PATH_TO_PING" != "x"; then
1050         if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1051                 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1052                 egrep -i "^round-trip|^rtt" >/dev/null
1053         then
1054                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1055                 ac_cv_ping6_packets_first=yes
1056                 AC_MSG_RESULT([$with_ping6_command])
1058         elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1059                 egrep -i "^round-trip|^rtt" >/dev/null
1060         then
1061                 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1062                 ac_cv_ping6_packets_first=yes
1063                 AC_MSG_RESULT([$with_ping6_command])
1065         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1066                 egrep -i "^round-trip|^rtt" >/dev/null
1067         then
1068                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1069                 ac_cv_ping6_packets_first=yes
1070                 AC_MSG_RESULT([$with_ping6_command])
1072         elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1073                 egrep -i "^round-trip|^rtt" >/dev/null
1074         then
1075                 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1076                 AC_MSG_RESULT([$with_ping6_command])
1078         elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1079                 egrep -i "^round-trip|^rtt" >/dev/null
1080         then
1081                 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1082                 AC_MSG_RESULT([$with_ping6_command])
1084         elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1085                 egrep -i "^round-trip|^rtt" >/dev/null
1086         then
1087                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1088                 AC_MSG_RESULT([$with_ping6_command])
1090         elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1091                 egrep -i "^round-trip|^rtt" >/dev/null
1092         then
1093                 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1094                 AC_MSG_RESULT([$with_ping6_command])
1096         elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1097                 egrep -i "^round-trip|^rtt" >/dev/null
1098         then
1099                 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1100                 ac_cv_ping6_packets_first=yes
1101                 AC_MSG_RESULT([$with_ping_command])
1103         elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1104                 egrep -i "^round-trip|^rtt" >/dev/null
1105         then
1106                 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1107                 ac_cv_ping6_packets_first=yes
1108                 AC_MSG_RESULT([$with_ping6_command])
1110         fi
1112 fi
1114 if test "x$with_ping6_command" != "x"; then
1115         AC_DEFINE_UNQUOTED(PING6_COMMAND,"$with_ping6_command",
1116                 [path and args for ICMPv6 ping command])
1117 else
1118         AC_MSG_RESULT([none])
1119 fi
1121 if test "x$ac_cv_ping6_packets_first" != "xno"; then
1122         AC_DEFINE(PING6_PACKETS_FIRST,1,
1123                 [Define if packet count must precede host])
1124 fi
1125 fi
1128 AC_ARG_WITH(nslookup_command,
1129             ACX_HELP_STRING([--with-nslookup-command=PATH],
1130                             [sets path to nslookup executable]),
1131             ac_cv_nslookup_command=$withval)
1132 if test -n "$ac_cv_nslookup_command"; then
1133         AC_MSG_NOTICE([Using specific nslookup at $ac_cv_nslookup_command])
1134 else
1135         AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
1136         if test -n "$PATH_TO_NSLOOKUP"
1137         then
1138                 AC_MSG_CHECKING(for nslookup syntax)
1139                 if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
1140                 then
1141                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
1142                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1144                 else
1145                         ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
1146                         AC_MSG_RESULT([$ac_cv_nslookup_command])
1148                 fi
1149         else
1150                 AC_MSG_WARN([nslookup command not found])
1151         fi
1152 fi
1154 if test -n "$ac_cv_nslookup_command"; then
1155         EXTRAS="$EXTRAS check_dns"
1156         AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
1157 fi
1159 AC_MSG_CHECKING([for number of cpus])
1160 AC_TRY_COMPILE([#include <unistd.h>],
1161         [sysconf(_SC_NPROCESSORS_CONF) > 0;],
1162         AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_CONF,1,[Define if sysconf returns number of cpus])
1163         AC_MSG_RESULT([sysconf(_SC_NPROCESSORS_CONF)]),
1164         AC_MSG_RESULT([cannot calculate])
1165         )
1167 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
1168 AC_ARG_WITH(uptime_command,
1169             ACX_HELP_STRING([--with-uptime-command=PATH],
1170                             [sets path to uptime]), PATH_TO_UPTIME=$withval)
1171 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
1173 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
1174 AC_ARG_WITH(rpcinfo_command,
1175             ACX_HELP_STRING([--with-rpcinfo-command=PATH],
1176                             [sets path to rpcinfo]), PATH_TO_RPCINFO=$withval)
1177 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
1179 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
1180 if test -x "$PATH_TO_LMSTAT"
1181 then
1182         AC_DEFINE_UNQUOTED(PATH_TO_LMSTAT,"$PATH_TO_LMSTAT",[path to lmstat])
1183 else
1184         AC_MSG_WARN([Get lmstat from Globetrotter Software to monitor flexlm licenses])
1185 fi
1187 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1188 AC_ARG_WITH(smbclient_command,
1189             ACX_HELP_STRING([--with-smbclient-command=PATH],
1190                             [sets path to smbclient]), 
1191             PATH_TO_SMBCLIENT=$withval)
1192 if test -n "$PATH_TO_SMBCLIENT"
1193 then
1194         AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
1195 else
1196         AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
1197 fi
1200 AC_PATH_PROG(PATH_TO_WHO,who)
1202 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
1203 then
1204         ac_cv_path_to_who="$PATH_TO_WHO -q"
1205 else
1206         ac_cv_path_to_who="$PATH_TO_WHO"
1207 fi
1209 AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
1210         [path and arguments for invoking 'who'])
1212 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
1213 AC_ARG_WITH(snmpget_command,
1214             ACX_HELP_STRING([--with-snmpget-command=PATH],
1215                             [Path to snmpget command]),
1216             PATH_TO_SNMPGET=$withval)
1217 if test -n "$PATH_TO_SNMPGET"
1218 then
1219         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
1220         EXTRAS="$EXTRAS check_hpjd check_snmp"
1221 else
1222         AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins])
1223 fi
1225 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
1226 AC_ARG_WITH(snmpgetnext_command,
1227             ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
1228                             [Path to snmpgetnext command]),
1229             PATH_TO_SNMPGETNEXT=$withval)
1230 if test -n "$PATH_TO_SNMPGETNEXT"
1231 then
1232         AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
1233 fi
1235 if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
1236 then
1237         AC_MSG_CHECKING(for Net::SNMP perl module)
1238         AC_MSG_RESULT([found])
1239 else
1240         AC_MSG_WARN([Tried $PERL - install Net::SNMP perl module if you want to use the perl snmp plugins])
1241 fi
1243 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1244 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1245 AC_ARG_WITH(qstat_command,
1246             ACX_HELP_STRING([--with-qstat-command=PATH], 
1247                             [Path to qstat command]), PATH_TO_QSTAT=$withval)
1249 if test -x "$PATH_TO_QUAKESTAT"
1250 then
1251         ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
1252         EXTRAS="$EXTRAS check_game"
1254 elif test -n "$PATH_TO_QSTAT"
1255 then
1256         ac_cv_path_to_qstat="$PATH_TO_QSTAT"
1257         EXTRAS="$EXTRAS check_game"
1258 else
1259         AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1260 fi
1262 if test $ac_cv_path_to_qstat 
1263 then
1264         AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1265                 [path to qstat/quakestat])
1266 fi
1268 AC_PATH_PROG(PATH_TO_FPING,fping)
1269 AC_ARG_WITH(fping_command,
1270             ACX_HELP_STRING([--with-fping-command=PATH],
1271                             [Path to fping command]), PATH_TO_FPING=$withval)
1272 if test -n "$PATH_TO_FPING"
1273 then
1274         AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
1275         EXTRAS="$EXTRAS check_fping"
1276 else
1277         AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
1278 fi
1280 AC_PATH_PROG(PATH_TO_SSH,ssh)
1281 AC_ARG_WITH(ssh_command,
1282             ACX_HELP_STRING([--with-ssh-command=PATH],
1283                             [sets path for ssh]), PATH_TO_SSH=$withval)
1284 if test -n "$PATH_TO_SSH"
1285 then
1286         AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
1287         EXTRAS="$EXTRAS check_by_ssh"
1288 else
1289         AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin])
1290 fi
1293 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
1294 AC_ARG_WITH(mailq_command,
1295             ACX_HELP_STRING([--with-mailq-command=PATH],
1296                             [sets path to mailq]), PATH_TO_MAILQ=$withval)
1297 if test -n "$PATH_TO_MAILQ"
1298 then
1299         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1300 else
1301         AC_MSG_WARN([Could not find mailq or eqivalent])
1302 fi
1304 AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1305 if test -x "$PATH_TO_QMAIL_QSTAT"
1306 then
1307         AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1308 else
1309         AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1310 fi
1312 dnl SWAP info required is amount allocated/available and amount free
1313 dnl The plugin works through all the swap devices and adds up the total swap
1314 dnl available.
1315 AC_PATH_PROG(PATH_TO_SWAP,swap)
1316 if (test -n "$PATH_TO_SWAP")
1317 then
1318 AC_MSG_CHECKING([for $PATH_TO_SWAP format])
1319 if [$PATH_TO_SWAP -l 2>&1 >/dev/null]
1320 then
1321         ac_cv_have_swap=yes
1322         ac_cv_swap_command="$PATH_TO_SWAP -l"
1323         if [$PATH_TO_SWAP -l 2>/dev/null | \
1324                 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1325                 >/dev/null]
1326         then
1327                 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1328                 ac_cv_swap_conv=2048
1329                 AC_MSG_RESULT([using IRIX format swap])
1331         elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
1332         then
1333                 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1334                 ac_cv_swap_conv=2048
1335                 AC_MSG_RESULT([using Unixware format swap])
1336         else
1337                 dnl if we don't know what format swap's output is
1338                 dnl we might as well pretend we didn't see it
1339                 ac_cv_have_swap=""
1340                 ac_cv_swap_command=""
1341         fi
1342 fi
1343 dnl end if for PATH_TO_SWAP
1344 fi
1346 AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1347 if (test -n "$PATH_TO_SWAPINFO")
1348 then
1349 AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1350 if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null]
1351 then
1352         ac_cv_have_swap=yes
1353         ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1355         if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1356         then
1357                 ac_cv_swap_format=["%*s %f %*d %f"]
1358                 ac_cv_swap_conv=1024
1359                 AC_MSG_RESULT([using FreeBSD format swapinfo])
1360         fi
1362 elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1363 then
1364         ac_cv_have_swap=yes
1365         ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM"
1366         ac_cv_swap_format=["%*s %f %*d %f"]
1367         ac_cv_swap_conv=1024
1368         AC_MSG_RESULT([using HP-UX format swapinfo])
1369 fi
1370 dnl end if for PATH_TO_SWAPINFO
1371 fi
1373 AC_PATH_PROG(PATH_TO_LSPS,lsps)
1374 if (test -n "$PATH_TO_LSPS")
1375 then
1376 AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1377 if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null]
1378 then
1379         ac_cv_have_swap=yes
1380         ac_cv_swap_command="$PATH_TO_LSPS -a"
1381         ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
1382         ac_cv_swap_conv=1
1383         AC_MSG_RESULT([using AIX lsps])
1384 fi
1385 dnl end if for PATH_TO_SWAPINFO
1386 fi
1388 dnl
1389 dnl test for swapctl system call, both the 2-arg and 3-arg variants
1390 dnl fwict, the 2-arg is an SVR4 standard, whereas the 3-arg is shared
1391 dnl in the various BSD's
1392 dnl
1394 AC_CHECK_HEADERS([sys/stat.h sys/param.h])
1395 AC_CHECK_HEADERS([sys/swap.h], [], [], [
1396 #ifdef HAVE_SYS_PARAM_H
1397 #include <sys/param.h>
1398 #endif
1399 ])
1400 AC_CHECK_DECLS([swapctl],,,[
1401                #include <unistd.h>
1402                #include <sys/types.h>
1403                #include <sys/param.h>
1404                #include <sys/stat.h>
1405                #include <sys/swap.h>
1406                ])
1407 AC_CHECK_TYPES([swaptbl_t, swapent_t],,,[
1408                #include <sys/types.h>
1409                #include <sys/param.h>
1410                #include <sys/stat.h>
1411                #include <sys/swap.h>
1412                ])
1413 AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1414                #include <unistd.h>
1415                #include <sys/types.h>
1416                #include <sys/param.h>
1417                #include <sys/stat.h>
1418                #include <sys/swap.h>
1419                ])
1421 if test "$ac_cv_have_decl_swapctl" = "yes"; 
1422 then
1423         EXTRAS="$EXTRAS check_swap"
1424         AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1425         if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1426                 "$ac_cv_type_swapent_t" = "yes"; 
1427         then
1428                 AC_MSG_RESULT([yes])
1429                 ac_cv_check_swap_swapctl_svr4="1";
1430                 AC_DEFINE([CHECK_SWAP_SWAPCTL_SVR4],1,
1431                           [Define if 2-argument SVR4 swapctl exists])
1432         else
1433                 AC_MSG_RESULT([no])
1434                 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1435                 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes"; 
1436                 then
1437                         AC_MSG_RESULT([yes])
1438                         AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
1439                                   [Define if 3-argument BSD swapctl exists])
1440                 else
1441                         AC_MSG_RESULT([no])
1442                 fi
1443         fi
1444         AC_MSG_CHECKING([for whether swapctl uses blocks or pages])
1445         if test "$ac_cv_check_swap_swapctl_svr4" = "1";
1446         then
1447                 dnl
1448                 dnl the SVR4 spec returns values in pages
1449                 dnl
1450                 AC_MSG_RESULT([page])
1451                 AC_CHECK_DECLS([sysconf])
1452                 AC_MSG_CHECKING([for system page size])
1453                 if test "$ac_cv_have_decl_sysconf" = "yes";
1454                 then
1455                         AC_MSG_RESULT([determined by sysconf(3)])
1456                         ac_cv_swap_conv="(1048576/sysconf(_SC_PAGESIZE))"
1457                 else
1458                         AC_MSG_WARN([don't know. guessing 4096k])
1459                         ac_cv_swap_conv=256
1460                 fi
1461         else
1462                 dnl
1463                 dnl the BSD spec returns values in blocks
1464                 dnl
1465                 AC_MSG_RESULT([blocks (assuming 512b)])
1466                 ac_cv_swap_conv=2048
1467         fi
1468         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1469                 [Conversion factor to MB])
1470 fi
1471 dnl
1472 dnl end tests for the swapctl system calls
1473 dnl
1476 if test "x$ac_cv_have_swap" != "x" 
1477 then
1478         AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1479         EXTRAS="$EXTRAS check_swap"
1480 fi
1481 if test "x$ac_cv_swap_command" != "x" 
1482 then
1483         AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1484                 [Path to swap/swapinfo binary, with any args])
1485         AC_DEFINE_UNQUOTED(SWAP_FORMAT,"$ac_cv_swap_format",
1486                 [Format string for parsing swap output])
1487         AC_DEFINE_UNQUOTED(SWAP_CONVERSION,$ac_cv_swap_conv,
1488                 [Conversion factor to MB])
1489 fi
1491 AC_ARG_WITH(proc-meminfo,
1492             ACX_HELP_STRING([--with-proc-meminfo=PATH],
1493                             [path to /proc/meminfo or equivalent]),
1494                             ac_cv_proc_meminfo=$withval)
1495 dnl dunno why this does not work below - use hack (kbd)
1496 dnl fine on linux, broken on solaris
1497 dnl if /bin/test -e "/proc/meminfo"
1498 AC_MSG_CHECKING([for /proc/meminfo])
1499 if test -n "$ac_cv_proc_meminfo"; then
1500         AC_MSG_RESULT([(command line) $ac_cv_proc_meminfo])
1501 elif [cat /proc/meminfo > /dev/null 2>&1]; then
1502         AC_MSG_RESULT([found /proc/meminfo])
1503         ac_cv_proc_meminfo="/proc/meminfo"
1504 else
1505         AC_MSG_RESULT([no])
1506 fi
1508 if test -n "$ac_cv_proc_meminfo"; then
1509         AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
1510         AC_DEFINE_UNQUOTED(PROC_MEMINFO,"$ac_cv_proc_meminfo",[path to /proc/meminfo if name changes])
1511         EXTRAS="$EXTRAS check_swap"
1512 fi
1514 AC_PATH_PROG(PATH_TO_DIG,dig)
1515 AC_ARG_WITH(dig_command,
1516             ACX_HELP_STRING([--with-dig-command=PATH],
1517                             [Path to dig command]), PATH_TO_DIG=$withval)
1518 if test -n "$PATH_TO_DIG"; then
1519         EXTRAS="$EXTRAS check_dig"
1520         AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
1521 fi
1523 AC_PATH_PROG(PATH_TO_APTGET,apt-get)
1524 AC_ARG_WITH(apt-get_command,
1525             ACX_HELP_STRING([--with-apt-get-command=PATH],
1526                             [Path to apt-get command]), 
1527                             with_apt_get_command=$withval,
1528                             with_apt_get_command=$PATH_TO_APTGET)
1529 AC_DEFINE_UNQUOTED(PATH_TO_APTGET,"$PATH_TO_APTGET",[Path to apt-get command, if present])
1530 if test -n "$PATH_TO_APTGET" ; then
1531         EXTRAS="$EXTRAS check_apt"
1532 fi
1535 if test -f plugins/check_nt.c ; then
1536   EXTRAS="$EXTRAS check_nt"
1537 elif test -f ../plugins/check_nt.c ; then
1538   EXTRAS="$EXTRAS check_nt"
1539 fi
1542 dnl used in check_dhcp
1543 AC_CHECK_HEADERS(sys/sockio.h)
1545 case $host in
1546         *bsd*)
1547                 AC_DEFINE(__bsd__,1,[bsd specific code in check_dhcp.c])
1548         ;;
1549         *linux*)
1550                 AC_DEFINE(__linux__,1,[linux specific code in check_dhcp.c])
1551         ;;
1552         *sun* | *solaris*)
1553                 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1554         ;;
1555         *hpux*)  
1556                 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1557         ;;
1558 esac
1560 AC_SUBST(EXTRAS)
1561 AC_SUBST(EXTRAS_ROOT)
1562 AC_SUBST(EXTRA_NETOBJS)
1563 AC_SUBST(DEPLIBS)
1565 AM_GNU_GETTEXT([external], [need-ngettext])
1566 AM_GNU_GETTEXT_VERSION(0.15)
1568 dnl Check for Redhat spopen problem
1569 dnl Wierd problem where ECHILD is returned from a wait call in error
1570 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1571 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1572 dnl We patch plugins/popen.c
1573 dnl Need to add smp because uname different on those
1574 dnl Can force patch to be applied with --enable-redhat-pthread-workaround
1575 AC_ARG_ENABLE(redhat-pthread-workaround, 
1576         AC_HELP_STRING([--enable-redhat-pthread-workaround], 
1577                 [force Redhat patch to be applied (default: test system)]),
1578         [ac_cv_enable_redhat_pthread_workaround=$enableval],
1579         [ac_cv_enable_redhat_pthread_workaround=test])
1580 if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1581         if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then
1582                 AC_MSG_NOTICE([See http://nagiosplugins.org/faq/compile/configure_appears_to_hang if this next part takes a long time])
1583                 AC_MSG_CHECKING(for redhat spopen problem)
1584                 ( cd config_test && make && make test ) > /dev/null 2>&1
1585                 if test $? -eq 0 ; then
1586                         AC_MSG_RESULT(okay)
1587                 else
1588                         AC_MSG_RESULT(error)
1589                         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Workaround on redhat in spopen])
1590                 fi
1591         fi
1592 elif test "$ac_cv_enable_redhat_pthread_workaround" = "yes" ; then
1593         AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Forced workaround on redhat in spopen])
1594 fi
1596 dnl Perl modules
1597 AC_ARG_ENABLE(perl-modules,
1598         AC_HELP_STRING([--enable-perl-modules], 
1599                 [Enables installation of Nagios::Plugin and its dependencies (default: no)]),
1600         [enable_perl_modules=$enableval],
1601         [enable_perl_modules=no])
1602 if test "$enable_perl_modules" = "yes" ; then
1603   AC_SUBST(PERLMODS_DIR,perlmods)
1604 fi
1606 dnl External libraries - see ACKNOWLEDGEMENTS
1607 gl_INIT
1609 dnl Some helpful common compile errors checked here
1610 if test "$ac_cv_uname_s" = 'SunOS' -a \( "x$ac_cv_prog_ac_ct_AR" = "x" -o "$ac_cv_prog_ac_ct_AR" = 'false' \) ; then
1611         AC_MSG_ERROR(No ar found for Solaris - is /usr/ccs/bin in PATH?)
1612 fi
1614 AC_OUTPUT(
1615   Makefile 
1616   lib/Makefile 
1617   plugins/Makefile 
1618   lib/tests/Makefile
1619   plugins-root/Makefile
1620   plugins-scripts/Makefile 
1621   plugins-scripts/subst 
1622   plugins-scripts/utils.pm 
1623   plugins-scripts/utils.sh 
1624   perlmods/Makefile
1625   command.cfg 
1626   test.pl 
1627   pkg/solaris/pkginfo 
1628   po/Makefile.in 
1632 dnl the ones below that are commented out need to be cleaned up 
1633 dnl in the configure code above to use with_foo instead of ac_cv_foo
1634 dnl if we want them to show up here.  it'd also make the code cleaner.
1635 dnl i'll get to that on another rainy day :) -sf
1636 ACX_FEATURE([with],[apt-get-command])
1637 dnl ACX_FEATURE([with],[dig-command])
1638 dnl ACX_FEATURE([with],[fping-command])
1639 dnl ACX_FEATURE([with],[mailq-command])
1640 dnl ACX_FEATURE([with],[nslookup-command])
1641 ACX_FEATURE([with],[ping6-command])
1642 ACX_FEATURE([with],[ping-command])
1643 dnl ACX_FEATURE([with],[qstat-command])
1644 dnl ACX_FEATURE([with],[rpcinfo-command])
1645 dnl ACX_FEATURE([with],[smbclient-command])
1646 dnl ACX_FEATURE([with],[snmpget-command])
1647 dnl ACX_FEATURE([with],[snmpgetnext-command])
1648 dnl ACX_FEATURE([with],[ssh-command])
1649 dnl ACX_FEATURE([with],[uptime-command])
1651 dnl ACX_FEATURE([with],[proc-meminfo])
1652 dnl ACX_FEATURE([with],[ps-command])
1653 dnl ACX_FEATURE([with],[ps-format])
1654 dnl ACX_FEATURE([with],[ps-cols])
1655 dnl ACX_FEATURE([with],[ps-varlist])
1657 ACX_FEATURE([with],[ipv6])
1658 ACX_FEATURE([with],[mysql])
1659 ACX_FEATURE([with],[openssl])
1660 ACX_FEATURE([with],[gnutls])
1661 ACX_FEATURE([enable],[extra-opts])
1662 ACX_FEATURE([with],[perl])
1663 ACX_FEATURE([enable],[perl-modules])
1664 ACX_FEATURE([with],[cgiurl])
1665 ACX_FEATURE([with],[trusted-path])