Code

Clean compile of check_mysql_query on MacOSX
[nagiosplug.git] / configure.in
index cbc2f3c4e894d18c6dca307da1f2f9f61f61f918..16e22a68859216a52de712038cfeeb48c9db8fdb 100644 (file)
@@ -74,6 +74,17 @@ AC_SUBST(with_nagios_group)
 INSTALL_OPTS="-o $with_nagios_user -g $with_nagios_group"
 AC_SUBST(INSTALL_OPTS)
 
+AC_ARG_WITH(libtap-srcdir,
+       ACX_HELP_STRING([--with-libtap-srcdir=path],
+               [full path to a compiled libtap srcdir]),
+       EXTRA_TEST=test_utils
+       EXTRA_TAPOBJ=$withval/tap.o
+       AC_SUBST(EXTRA_TEST)
+       AC_SUBST(EXTRA_TAPOBJ)
+       LDFLAGS="$LDFLAGS -L$withval"
+       CPPFLAGS="$CPPFLAGS -I$withval"
+       )
+
 AC_ARG_WITH(trusted_path,
        ACX_HELP_STRING([--with-trusted-path=PATH],
                [sets trusted path for executables called by scripts (default=/bin:/sbin:/usr/bin:/usr/sbin)]),
@@ -103,6 +114,9 @@ dnl Checks for programs.
 AC_PATH_PROG(PYTHON,python)
 AC_PATH_PROG(SH,sh)
 AC_PATH_PROG(PERL,perl)
+AC_PATH_PROG(LIBGNUTLS_CONFIG,libgnutls-config)
+AC_PATH_PROG(HOSTNAME,hostname)
+AC_PATH_PROG(BASENAME,basename)
 
 dnl allow them to override the path of perl
 AC_ARG_WITH(perl,
@@ -111,8 +125,28 @@ AC_ARG_WITH(perl,
                        with_perl=$withval,with_perl=$PERL)
 AC_SUBST(PERL, $with_perl)
 
-AC_PATH_PROG(HOSTNAME,hostname)
-AC_PATH_PROG(BASENAME,basename)
+dnl openssl/gnutls
+AC_ARG_WITH(openssl,
+            AC_HELP_STRING([--with-openssl=DIR], 
+                           [path to openssl installation]),)
+
+AC_ARG_WITH(gnutls,
+            ACX_HELP_STRING([--with-gnutls=PATH],
+                            [path to gnutls installation root]),)
+
+dnl you can only have one or the other
+if test ! "$with_openssl" = "" && test ! "$with_openssl" = "no"; then
+       with_gnutls="no"
+fi
+if test ! "$with_gnutls" = "" && test ! "$with_gnutls" = "no"; then
+       with_openssl="no"
+fi
+
+dnl list of possible dirs to try to autodetect openssl
+dnl if $dir/include exists, we consider it found
+dnl the order should allow locally installed versions to override distros' ones
+OPENSSL_DIRS="/usr /usr/local /usr/slocal /usr/local/openssl /usr/local/ssl \
+              /opt /opt/openssl"
 
 dnl
 dnl Check for miscellaneous stuff
@@ -139,6 +173,7 @@ AC_SUBST(SOCKETLIBS)
 
 dnl
 dnl check for math-related functions needing -lm
+AC_CHECK_HEADERS(math.h)
 AC_CHECK_LIB(m,floor,MATHLIBS="-lm")
 AC_SUBST(MATHLIBS)
 
@@ -234,7 +269,7 @@ AC_ARG_WITH(mysql,
 if test -n "$MYSQL"; then
   MYSQLLIBDIR=$MYSQL/lib/mysql
   CPPFLAGS="-I$MYSQL/include"
-  AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L$MYSQLLIBDIR ",,-L$MYSQLLIBDIR -lz)
+  AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L$MYSQLLIBDIR " check_mysql_query_LDFLAGS="-L$MYSQLLIBDIR ",,-L$MYSQLLIBDIR -lz)
   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
 elif test -f /usr/lib/libmysqlclient.so; then
   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
@@ -243,19 +278,20 @@ elif test -f /usr/lib/libmysqlclient.a; then
   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
 elif test -f /usr/lib/mysql/libmysqlclient.so; then
-  AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
-  AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
+  AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql" check_mysql_query_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
+  AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql" check_mysql_query_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
 elif test -f /usr/lib/mysql/libmysqlclient.a; then
-  AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
-  AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
+  AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql" check_mysql_query_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
+  AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql" check_mysql_query_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
 fi
 if test "$ac_cv_lib_mysqlclient_mysql_init" = "yes" -o "$ac_cv_lib_mysqlclient_mysql_close" = "yes"; then
   AC_CHECK_HEADERS(mysql/mysql.h mysql/errmsg.h, MYSQLINCLUDE="-I$MYSQL/include" )
   if test "$ac_cv_header_mysql_mysql_h" = "yes" -a "$ac_cv_header_mysql_errmsg_h" = "yes"; then
-    EXTRAS="$EXTRAS check_mysql"
+    EXTRAS="$EXTRAS check_mysql check_mysql_query"
     AC_SUBST(MYSQLINCLUDE)
     AC_SUBST(MYSQLLIBS)
     AC_SUBST(check_mysql_LDFLAGS)
+    AC_SUBST(check_mysql_query_LDFLAGS)
   else
     AC_MSG_WARN([Skipping mysql plugin])
     AC_MSG_WARN([install mysql client headers to compile this plugin (see REQUIREMENTS).])
@@ -409,89 +445,98 @@ if test "$FOUNDINCLUDE" = "no"; then
   CPPFLAGS="$_SAVEDCPPFLAGS"
 fi
 
-dnl Check for OpenSSL location
-AC_PATH_PROG(OPENSSL,openssl)
-if test "$OPENSSL" = "/usr/bin/openssl"; then
-  OPENSSL=/usr
-elif test "$OPENSSL" = "/usr/sbin/openssl"; then
-  OPENSSL=/usr
-elif test "$OPENSSL" = "/opt/bin/openssl"; then
-  OPENSSL=/opt
-elif test "$OPENSSL" = "/opt/openssl/bin/openssl"; then
-  OPENSSL=/opt/openssl
-elif test "$OPENSSL" = "/usr/slocal/bin/openssl"; then
-  OPENSSL=/usr/slocal
-elif test "$OPENSSL" = "/usr/local/bin/openssl"; then
-  OPENSSL=/usr/local
-elif test "$OPENSSL" = "/usr/local/ssl/bin/openssl"; then
-  OPENSSL=/usr/local/ssl
-fi
-AC_ARG_WITH(openssl,
-AC_HELP_STRING([--with-openssl=DIR], [sets path to openssl installation])
-AC_HELP_STRING([--without-openssl], [disable openssl]),
-OPENSSL=$withval)
 
-_SAVEDCPPFLAGS="$CPPFLAGS"
-_SAVEDLDFLAGS="$LDFLAGS"
-if test X"$OPENSSL" = "Xno"; then
-  AC_MSG_WARN([openssl disabled, you will not be able to use ssl options in some plugins])
-  FOUNDSSL="dontbother"
-else
-  dnl Check for OpenSSL header files
-  unset FOUNDINCLUDE
-  if test "$OPENSSL" != "/usr"; then
-    CPPFLAGS="$CPPFLAGS -I$OPENSSL/include"
-    LDFLAGS="$LDFLAGS -R$OPENSSL/lib"
-  fi
-  AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
-                 SSLINCLUDE="-I$OPENSSL/include"
-                 FOUNDINCLUDE=yes,
-                 FOUNDINCLUDE=no)
-  if test "$FOUNDINCLUDE" = "no"; then
-    AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
-                   SSLINCLUDE="-I$OPENSSL/include"
-                   FOUNDINCLUDE=yes,
-                   FOUNDINCLUDE=no)
-  fi
-  AC_SUBST(SSLINCLUDE)
-  if test "$FOUNDINCLUDE" = "no"; then
-    CPPFLAGS="$_SAVEDCPPFLAGS"
-  fi
+dnl openssl detection/configuration
+if ! test "$with_openssl" = "no"; then
+       dnl Check for OpenSSL location if it wasn't already specified
+       if ! test -d "$with_openssl"; then
+               for d in $OPENSSL_DIRS; do
+                       if test -x ${d}/bin/openssl || test -x ${d}/sbin/openssl ; then
+                               with_openssl=$d
+                       fi
+               done
+       fi
 
-  dnl Check for crypto lib
-  _SAVEDLIBS="$LIBS"
-  AC_CHECK_LIB(crypto,CRYPTO_lock,,,-L$OPENSSL/lib)
-  if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
-    dnl Check for SSL lib
-    AC_CHECK_LIB(ssl,main,LDFLAGS="$LDFLAGS -L$OPENSSL/lib" SSLLIBS="-lssl -lcrypto",AC_CHECK_LIB(ssl,main,LDFLAGS="$LDFLAGS -L$OPENSSL/lib" SSLLIBS="-lssl -lcrypto"),-L$OPENSSL/lib -lcrypto)
-  fi
-  LIBS="$_SAVEDLIBS"
-
-  FOUNDSSL="no"
-  dnl test headers and libs to decide whether check_http should use SSL
-  if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
-    if test "$ac_cv_lib_ssl_main" = "yes"; then
-      if test "$FOUNDINCLUDE" = "yes"; then
-        FOUNDSSL="yes"
-      fi
-    fi
-  fi
+       _SAVEDCPPFLAGS="$CPPFLAGS"
+       _SAVEDLDFLAGS="$LDFLAGS"
+       dnl Check for OpenSSL header files
+       unset FOUNDINCLUDE
+       CPPFLAGS="$CPPFLAGS -I$OPENSSL/include"
+       LDFLAGS="$LDFLAGS -R$OPENSSL/lib"
+
+       dnl check for openssl in $dir/include/openssl
+       AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
+                        SSLINCLUDE="-I$OPENSSL/include"
+                        FOUNDINCLUDE=yes,
+                        FOUNDINCLUDE=no)
+       dnl else check to see if $dir/include has it
+       if test "$FOUNDINCLUDE" = "no"; then
+               AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
+                                SSLINCLUDE="-I$OPENSSL/include"
+                                FOUNDINCLUDE=yes,
+                                FOUNDINCLUDE=no)
+       fi
+       AC_SUBST(SSLINCLUDE)
+       dnl if we didn't find it, reset CPPFLAGS
+       if test "$FOUNDINCLUDE" = "no"; then
+               CPPFLAGS="$_SAVEDCPPFLAGS"
+               LDFLAGS="$_SAVEDLDFLAGS"
+       fi
+
+       dnl Check for crypto lib
+       _SAVEDLIBS="$LIBS"
+       LIBS="-L${with_openssl}/lib"
+       AC_CHECK_LIB(crypto,CRYPTO_lock)
+       if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
+               dnl Check for SSL lib
+               AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
+       fi
+       LIBS="$_SAVEDLIBS"
+
+       dnl test headers and libs to decide whether check_http should use SSL
+       if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
+               if test "$ac_cv_lib_ssl_main" = "yes"; then
+                       if test "$FOUNDINCLUDE" = "yes"; then
+                               FOUNDOPENSSL="yes"
+                       fi
+               fi
+       fi
 fi
 
-if test "$FOUNDSSL" = "yes"; then
-  check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
-  AC_SUBST(check_tcp_ssl)
-  AC_SUBST(SSLLIBS)
-  AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
-  with_openssl="yes"
+
+dnl check for gnutls if openssl isn't found (or is disabled)
+if test ! "$FOUNDOPENSSL" = "yes" && test ! "$with_gnutls" = "no"; then
+       if test ! "$with_gnutls" = ""; then
+               CPPFLAGS="$CPPFLAGS -I${with_gnutls}/include"
+       elif test ! "$LIBGNUTLS_CONFIG" = ""; then
+               CPPFLAGS="$CPPFLAGS -I`$LIBGNUTLS_CONFIG --prefix`"
+       fi
+       AC_CHECK_HEADERS([gnutls/openssl.h],FOUNDGNUTLS="yes",)
+       if test "$FOUNDGNUTLS" = "yes"; then
+               AC_CHECK_LIB(gnutls-openssl,main,SSLLIBS="-lgnutls-openssl")
+       fi
+fi
+dnl end check for gnutls
+
+if test "$FOUNDOPENSSL" = "yes" || test "$FOUNDGNUTLS" = "yes"; then
+       check_tcp_ssl="check_simap check_spop check_jabber check_nntps check_ssmtp"
+       AC_SUBST(check_tcp_ssl)
+       AC_SUBST(SSLLIBS)
+       AC_DEFINE(HAVE_SSL,1,[Define if SSL libraries are found])
+       if test "$FOUNDOPENSSL" = "yes"; then
+               AC_DEFINE(USE_OPENSSL,1,[Define if using OpenSSL libraries])
+               with_openssl="yes"
+               with_gnutls="no"
+       else
+               AC_DEFINE(USE_GNUTLS,1,[Define if using gnutls libraries])
+               with_gnutls="yes"
+               with_openssl="no"
+       fi
 else
-  if test "$FOUNDSSL" = "no"; then
-    AC_MSG_WARN([OpenSSL libs could not be found])
-  dnl else deliberately disabled
-  fi
-  with_openssl="no"
-  CPPFLAGS="$_SAVEDCPPFLAGS"
-  LDFLAGS="$_SAVEDLDFLAGS"
+       dnl else deliberately disabled or no ssl support available
+       AC_MSG_WARN([OpenSSL or GnuTLS libs could not be found or were disabled])
+       with_openssl="no"
+       with_gnutls="no"
 fi
 
 dnl
@@ -501,7 +546,7 @@ dnl
 AC_HEADER_STDC
 AC_HEADER_TIME
 AC_HEADER_SYS_WAIT
-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)
+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 sys/un.h)
 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h stdlib.h)
 
 dnl Checks for typedefs, structures, and compiler characteristics.
@@ -587,8 +632,21 @@ AC_TRY_COMPILE([#include <stdlib.h>
 AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type ,
        [Define type of socket size])
 
-if test -f "/proc/loadavg"
-then
+AC_ARG_WITH(proc-loadavg,
+            ACX_HELP_STRING([--with-proc-loadavg=PATH],
+                            [path to /proc/loadavg or equivalent]),
+            ac_cv_proc_loadavg=$withval)
+AC_MSG_CHECKING([for /proc/loadavg])
+if test -n "$ac_cv_proc_loadavg"; then
+  AC_MSG_RESULT([(command line) $ac_cv_proc_loadavg])
+elif test -f "/proc/loadavg"; then
+  AC_MSG_RESULT([found /proc/loadavg])
+  ac_cv_proc_loadavg="/proc/loadavg"
+else
+  AC_MSG_RESULT([no])
+fi
+
+if test -n "$ac_cv_proc_loadavg"; then
   AC_DEFINE(HAVE_PROC_LOADAVG,1,[Define if /proc/loadavg or similar exists])
   AC_DEFINE_UNQUOTED(PROC_LOADAVG,"/proc/loadavg",[Location of /proc/loadavg])
 fi
@@ -598,9 +656,34 @@ dnl #### Process table test
 AC_PATH_PROG(PATH_TO_PS,ps)
 
 AC_MSG_CHECKING(for ps syntax)
+AC_ARG_WITH(ps_command,
+            ACX_HELP_STRING([--with-ps-command=PATH], 
+                            [Verbatim command to execute for ps]),
+            PS_COMMAND=$withval)
+AC_ARG_WITH(ps_format,
+            ACX_HELP_STRING([--with-ps-format=FORMAT],
+                            [Format string for scanning ps output]),
+            PS_FORMAT=$withval)
+AC_ARG_WITH(ps_cols,
+            ACX_HELP_STRING([--with-ps-cols=NUM], 
+                            [Number of columns in ps command]),
+            PS_COLS=$withval)
+AC_ARG_WITH(ps_varlist,
+            ACX_HELP_STRING([--with-ps-varlist=LIST],
+                            [Variable list for sscanf of 'ps' output]),
+            PS_VARLIST=$withval)
+
+AM_CONDITIONAL(WANT_PST3, false)
+
+if test -n "$PS_COMMAND" && test -n "$PS_FORMAT" && test -n "$PS_COLS" && test -n "$PS_VARLIST"; then 
+       ac_cv_ps_command="$PS_COMMAND"
+       ac_cv_ps_format="$PS_FORMAT"
+       ac_cv_ps_varlist="$PS_VARLIST"
+       ac_cv_ps_cols="$PS_COLS"
+       AC_MSG_RESULT([(command-line) $ac_cv_ps_command])
 
 dnl Now using the pst3/kmem hack for solaris systems to avoid truncation
-if test "$ac_cv_uname_s" = "SunOS"; then
+elif test "$ac_cv_uname_s" = "SunOS"; then
        #
        # this is a very, very ugly hack, to hardcode the location for plugins
        #
@@ -622,6 +705,7 @@ if test "$ac_cv_uname_s" = "SunOS"; then
        ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
        ac_cv_ps_cols=8
        AC_MSG_RESULT([using nagios-plugins internal ps for solaris])
+       AM_CONDITIONAL(WANT_PST3, true)
 
 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
 dnl so test for this first...
@@ -875,6 +959,10 @@ if test -n "$ac_cv_ps_varlist" ; then
        AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
                [Number of columns in ps command])
        EXTRAS="$EXTRAS check_procs check_nagios"
+       if echo "$ac_cv_ps_varlist" | grep -q "procetime"; then
+               AC_DEFINE(PS_USES_PROCETIME,"yes",
+                         [Whether the ps utility uses the "procetime" field])
+       fi
 fi
 
 AC_PATH_PROG(PATH_TO_PING,ping)
@@ -894,6 +982,7 @@ then
        if test -n "$ac_cv_ping_packets_first"
        then
                ac_cv_ping_packets_first=yes
+               ac_cv_ping_has_timeout=yes
        fi
 
 elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
@@ -1148,29 +1237,37 @@ if test "x$ac_cv_ping6_packets_first" != "xno"; then
 fi
 fi
 
-AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
 
 AC_MSG_CHECKING(for nslookup syntax)
-if test -n "$PATH_TO_NSLOOKUP"
-then
-       if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
+AC_ARG_WITH(nslookup_command,
+            ACX_HELP_STRING([--with-nslookup-command=PATH],
+                            [sets path to nslookup executable]),
+            ac_cv_nslookup_command=$withval)
+if test -n "$ac_cv_nslookup_command"; then
+       AC_MSG_RESULT([(command line) $ac_cv_nslookup_command])
+else
+       AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
+       if test -n "$PATH_TO_NSLOOKUP"
        then
-               ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
-               AC_MSG_RESULT([$ac_cv_nslookup_command])
+               if $PATH_TO_NSLOOKUP -sil 127.0.0.1 2>&1 | grep ["Invalid option: sil"] >/dev/null
+               then
+                       ac_cv_nslookup_command="$PATH_TO_NSLOOKUP"
+                       AC_MSG_RESULT([$ac_cv_nslookup_command])
 
-       else
-               ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
-               AC_MSG_RESULT([$ac_cv_nslookup_command])
+               else
+                       ac_cv_nslookup_command="$PATH_TO_NSLOOKUP -sil"
+                       AC_MSG_RESULT([$ac_cv_nslookup_command])
 
+               fi
+       else
+               AC_MSG_WARN([nslookup command not found])
        fi
-       EXTRAS="$EXTRAS check_dns"
-
-else
-       AC_MSG_WARN([nslookup command not found])
 fi
 
-AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command",
-       [path and args for nslookup])
+if test -n "$ac_cv_nslookup_command"; then
+       EXTRAS="$EXTRAS check_dns"
+       AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
+fi
 
 AC_PATH_PROG(PATH_TO_HOST,host)
 if test -n "$ac_cv_path_PATH_TO_HOST"
@@ -1179,15 +1276,24 @@ then
 fi
 
 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
+AC_ARG_WITH(uptime_command,
+            ACX_HELP_STRING([--with-uptime-command=PATH],
+                            [sets path to uptime]), PATH_TO_UPTIME=$withval)
 AC_DEFINE_UNQUOTED(PATH_TO_UPTIME,"$PATH_TO_UPTIME",[path to uptime binary])
 
 AC_PATH_PROG(PATH_TO_RPCINFO,rpcinfo)
+AC_ARG_WITH(rpcinfo_command,
+            ACX_HELP_STRING([--with-rpcinfo-command=PATH],
+                            [sets path to rpcinfo]), PATH_TO_RPCINFO=$withval)
 AC_DEFINE_UNQUOTED(PATH_TO_RPCINFO,"$PATH_TO_RPCINFO",[path to rpcinfo binary])
 
 AC_PATH_PROG(PATH_TO_NTPDATE,ntpdate)
+AC_ARG_WITH(ntpdate_command,
+            ACX_HELP_STRING([--with-ntpdate-command=PATH],
+                            [sets path to ntpdate]), PATH_TO_NTPDATE=$withval)
 AC_PATH_PROGS(PATH_TO_NTPDC,ntpdc xntpdc)
 AC_PATH_PROGS(PATH_TO_NTPQ,ntpq)
-if (test -x "$PATH_TO_NTPDATE" || test -x "$PATH_TO_NTPQ")
+if (test -n "$PATH_TO_NTPDATE" || test -n "$PATH_TO_NTPQ")
 then
        AC_DEFINE_UNQUOTED(PATH_TO_NTPQ,"$PATH_TO_NTPQ",[path to ntpq binary])
        AC_DEFINE_UNQUOTED(PATH_TO_NTPDATE,"$PATH_TO_NTPDATE",[path to ntpdate binary])
@@ -1204,7 +1310,11 @@ else
 fi
 
 AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
-if test -x "$PATH_TO_SMBCLIENT"
+AC_ARG_WITH(smbclient_command,
+            ACX_HELP_STRING([--with-smbclient-command=PATH],
+                            [sets path to smbclient]), 
+            PATH_TO_SMBCLIENT=$withval)
+if test -n "$PATH_TO_SMBCLIENT"
 then
        AC_DEFINE_UNQUOTED(PATH_TO_SMBCLIENT,"$PATH_TO_SMBCLIENT",[path to smbclient binary])
 else
@@ -1225,7 +1335,11 @@ AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
        [path and arguments for invoking 'who'])
 
 AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
-if test -x "$PATH_TO_SNMPGET"
+AC_ARG_WITH(snmpget_command,
+            ACX_HELP_STRING([--with-snmpget-command=PATH],
+                            [Path to snmpget command]),
+            PATH_TO_SNMPGET=$withval)
+if test -n "$PATH_TO_SNMPGET"
 then
        AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary])
        EXTRAS="$EXTRAS check_hpjd check_snmp"
@@ -1234,7 +1348,11 @@ else
 fi
 
 AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
-if test -x "$PATH_TO_SNMPGETNEXT"
+AC_ARG_WITH(snmpgetnext_command,
+            ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
+                            [Path to snmpgetnext command]),
+            PATH_TO_SNMPGETNEXT=$withval)
+if test -n "$PATH_TO_SNMPGETNEXT"
 then
        AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary])
 fi
@@ -1249,13 +1367,16 @@ fi
 
 AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
 AC_PATH_PROG(PATH_TO_QSTAT,qstat)
+AC_ARG_WITH(qstat_command,
+            ACX_HELP_STRING([--with-qstat-command=PATH], 
+                            [Path to qstat command]), PATH_TO_QSTAT=$withval)
 
 if test -x "$PATH_TO_QUAKESTAT"
 then
        ac_cv_path_to_qstat="$PATH_TO_QUAKESTAT"
        EXTRAS="$EXTRAS check_game"
 
-elif test -x "$PATH_TO_QSTAT"
+elif test -n "$PATH_TO_QSTAT"
 then
        ac_cv_path_to_qstat="$PATH_TO_QSTAT"
        EXTRAS="$EXTRAS check_game"
@@ -1270,7 +1391,10 @@ then
 fi
 
 AC_PATH_PROG(PATH_TO_FPING,fping)
-if test -x "$PATH_TO_FPING"
+AC_ARG_WITH(fping_command,
+            ACX_HELP_STRING([--with-fping-command=PATH],
+                            [Path to fping command]), PATH_TO_FPING=$withval)
+if test -n "$PATH_TO_FPING"
 then
        AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
        EXTRAS="$EXTRAS check_fping"
@@ -1279,8 +1403,10 @@ else
 fi
 
 AC_PATH_PROG(PATH_TO_SSH,ssh)
-
-if test -x "$PATH_TO_SSH"
+AC_ARG_WITH(ssh_command,
+            ACX_HELP_STRING([--with-ssh-command=PATH],
+                            [sets path for ssh]), PATH_TO_SSH=$withval)
+if test -n "$PATH_TO_SSH"
 then
        AC_DEFINE_UNQUOTED(SSH_COMMAND,"$PATH_TO_SSH",[path to ssh binary])
        EXTRAS="$EXTRAS check_by_ssh"
@@ -1290,7 +1416,10 @@ fi
 
 
 AC_PATH_PROG(PATH_TO_MAILQ,mailq)
-if test -x "$PATH_TO_MAILQ"
+AC_ARG_WITH(mailq_command,
+            ACX_HELP_STRING([--with-mailq-command=PATH],
+                            [sets path to mailq]), PATH_TO_MAILQ=$withval)
+if test -n "$PATH_TO_MAILQ"
 then
        AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
 else
@@ -1484,24 +1613,36 @@ then
                [Conversion factor to MB])
 fi
 
+AC_ARG_WITH(proc-meminfo,
+            ACX_HELP_STRING([--with-proc-meminfo=PATH],
+                            [path to /proc/meminfo or equivalent]),
+                            ac_cv_proc_meminfo=$withval)
 dnl dunno why this does not work below - use hack (kbd)
 dnl fine on linux, broken on solaris
 dnl if /bin/test -e "/proc/meminfo"
 AC_MSG_CHECKING([for /proc/meminfo])
-if [cat /proc/meminfo > /dev/null 2>&1]
-then
+if test -n "$ac_cv_proc_meminfo"; then
+       AC_MSG_RESULT([(command line) $ac_cv_proc_meminfo])
+elif [cat /proc/meminfo > /dev/null 2>&1]; then
        AC_MSG_RESULT([found /proc/meminfo])
-       AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
-       AC_DEFINE_UNQUOTED(PROC_MEMINFO,"/proc/meminfo",[path to /proc/meminfo if name changes])
-       EXTRAS="$EXTRAS check_swap"
+       ac_cv_proc_meminfo="/proc/meminfo"
 else
        AC_MSG_RESULT([no])
 fi
 
+if test -n "$ac_cv_proc_meminfo"; then
+       AC_DEFINE(HAVE_PROC_MEMINFO,1,[Define if we have /proc/meminfo])
+       AC_DEFINE_UNQUOTED(PROC_MEMINFO,"$ac_cv_proc_meminfo",[path to /proc/meminfo if name changes])
+       EXTRAS="$EXTRAS check_swap"
+fi
+
 AC_PATH_PROG(PATH_TO_DIG,dig)
-AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
+AC_ARG_WITH(dig_command,
+            ACX_HELP_STRING([--with-dig-command=PATH],
+                            [Path to dig command]), PATH_TO_DIG=$withval)
 if test -n "$PATH_TO_DIG"; then
        EXTRAS="$EXTRAS check_dig"
+       AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
 fi
 
 if test -f plugins/check_nt.c ; then
@@ -1551,15 +1692,26 @@ dnl Wierd problem where ECHILD is returned from a wait call in error
 dnl Only appears to affect nslookup and dig calls. Only affects redhat around
 dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
 dnl We patch plugins/popen.c
-if echo $ac_cv_uname_r | egrep "\.EL$" >/dev/null 2>&1 ; then
-       AC_MSG_CHECKING(for redhat spopen problem)
-       ( cd config_test && make && make test ) > /dev/null 2>&1
-       if test $? -eq 0 ; then
-               AC_MSG_RESULT(okay)
-       else
-               AC_MSG_RESULT(error)
-               AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, "Problem on redhat with spopen")
+dnl Need to add smp because uname different on those
+dnl Can force patch to be applied with --enable-redhat-pthread-workaround
+AC_ARG_ENABLE(redhat-pthread-workaround, 
+       AC_HELP_STRING([--enable-redhat-pthread-workaround], 
+               [force Redhat patch to be applied (default: test system)]),
+       [ac_cv_enable_redhat_pthread_workaround=$enableval],
+       [ac_cv_enable_redhat_pthread_workaround=test])
+if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
+       if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then
+               AC_MSG_CHECKING(for redhat spopen problem)
+               ( cd config_test && make && make test ) > /dev/null 2>&1
+               if test $? -eq 0 ; then
+                       AC_MSG_RESULT(okay)
+               else
+                       AC_MSG_RESULT(error)
+                       AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Workaround on redhat in spopen])
+               fi
        fi
+elif test "$ac_cv_enable_redhat_pthread_workaround" = "yes" ; then
+       AC_DEFINE(REDHAT_SPOPEN_ERROR, 1, [Forced workaround on redhat in spopen])
 fi
 
 dnl External libraries - see ACKNOWLEDGEMENTS
@@ -1571,6 +1723,7 @@ AC_OUTPUT(
   lib/Makefile 
   m4/Makefile 
   plugins/Makefile 
+  plugins/tests/Makefile
   plugins-root/Makefile
   plugins-scripts/Makefile 
   plugins-scripts/subst 
@@ -1583,14 +1736,42 @@ AC_OUTPUT(
   po/Makefile.in 
 )
 
-ACX_FEATURE([with],[perl])
-ACX_FEATURE([with],[cgiurl])
-ACX_FEATURE([with],[nagios-user])
-ACX_FEATURE([with],[nagios-group])
-ACX_FEATURE([with],[trusted-path])
-ACX_FEATURE([with],[ping-command])
+
+dnl the ones below that are commented out need to be cleaned up 
+dnl in the configure code above to use with_foo instead of ac_cv_foo
+dnl if we want them to show up here.  it'd also make the code cleaner.
+dnl i'll get to that on another rainy day :) -sf
+dnl ACX_FEATURE([with],[dig-command])
+dnl ACX_FEATURE([with],[fping-command])
+dnl ACX_FEATURE([with],[mailq-command])
+dnl ACX_FEATURE([with],[nslookup-command])
+dnl ACX_FEATURE([with],[ntpdate-command])
 ACX_FEATURE([with],[ping6-command])
+ACX_FEATURE([with],[ping-command])
+dnl ACX_FEATURE([with],[qstat-command])
+dnl ACX_FEATURE([with],[rpcinfo-command])
+dnl ACX_FEATURE([with],[smbclient-command])
+dnl ACX_FEATURE([with],[snmpget-command])
+dnl ACX_FEATURE([with],[snmpgetnext-command])
+dnl ACX_FEATURE([with],[ssh-command])
+dnl ACX_FEATURE([with],[uptime-command])
+
+dnl ACX_FEATURE([with],[proc-loadavg])
+dnl ACX_FEATURE([with],[proc-meminfo])
+dnl ACX_FEATURE([with],[ps-command])
+dnl ACX_FEATURE([with],[ps-format])
+dnl ACX_FEATURE([with],[ps-cols])
+dnl ACX_FEATURE([with],[ps-varlist])
+
 ACX_FEATURE([with],[lwres])
 ACX_FEATURE([with],[ipv6])
 ACX_FEATURE([with],[openssl])
+ACX_FEATURE([with],[gnutls])
 ACX_FEATURE([enable],[emulate-getaddrinfo])
+ACX_FEATURE([with],[perl])
+ACX_FEATURE([with],[cgiurl])
+ACX_FEATURE([with],[nagios-user])
+ACX_FEATURE([with],[nagios-group])
+ACX_FEATURE([with],[trusted-path])
+
+