Code

cleaning help and usage
[nagiosplug.git] / configure.in
index d56501acedb4066e12654f3a7ce407f96274ff8e..27b2b40edfc2987522e2cf4f3d3c4b74ecc063a9 100644 (file)
@@ -1,9 +1,9 @@
 dnl Process this file with autoconf to produce a configure script.
 AC_REVISION ($Revision$)
 AC_PREREQ(2.58)
-AC_INIT(nagios-plugins,1.4.2)
+AC_INIT(nagios-plugins,1.4.3)
 AC_CONFIG_SRCDIR(NPTest.pm)
-AM_INIT_AUTOMAKE
+AM_INIT_AUTOMAKE([1.8.3])
 AM_CONFIG_HEADER(config.h)
 AC_CANONICAL_HOST
 
@@ -12,6 +12,8 @@ AC_SUBST(RELEASE)
 
 AC_PREFIX_DEFAULT(/usr/local/nagios)
 
+dnl Deprecated configure options
+
 dnl Figure out how to invoke "install" and what install options to use.
 AC_PROG_INSTALL
 AC_SUBST(INSTALL)
@@ -23,7 +25,7 @@ gl_USE_SYSTEM_EXTENSIONS
 AC_PROG_CC
 AC_PROG_CPP
 AC_PROG_GCC_TRADITIONAL
-AC_PROG_RANLIB
+AC_PROG_LIBTOOL
 
 AC_PROG_MAKE_SET
 AC_PROG_AWK
@@ -36,7 +38,6 @@ AC_CONFIG_LIBOBJ_DIR(lib)
 AC_FUNC_GETLOADAVG([lib])
 
 ifdef([AC_FUNC_STRTOD],[AC_FUNC_STRTOD],[AM_FUNC_STRTOD])
-dnl AM_WITH_REGEX
 
 PLUGIN_TEST=`echo $srcdir/plugins/t/*.t|sed -e 's,\.*/plugins/,,g'`
 AC_SUBST(PLUGIN_TEST)dnl
@@ -74,17 +75,6 @@ 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)]),
@@ -93,6 +83,7 @@ AC_ARG_WITH(trusted_path,
 AC_SUBST(with_trusted_path)
 
 EXTRAS=
+EXTRAS_ROOT=
 dnl PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/etc:/usr/local/bin:/usr/local/sbin:$PATH
 
 LDFLAGS="$LDFLAGS -L."
@@ -153,9 +144,6 @@ dnl Check for miscellaneous stuff
 dnl 
 
 case $host_vender-$host_os in
-sun*)
-       AC_DEFINE(__EXTENSIONS__,1,[Sun's netdb.h needs this for getaddrinfo])
-       ;;
 osf*)
        AC_DEFINE(_OSF_SOURCE,1,[OSF needs this for getaddrinfo])
        ;;
@@ -177,6 +165,12 @@ AC_CHECK_HEADERS(math.h)
 AC_CHECK_LIB(m,floor,MATHLIBS="-lm")
 AC_SUBST(MATHLIBS)
 
+dnl Check for libtap, to run perl-like tests
+AC_CHECK_LIB(tap, plan_tests, 
+       EXTRA_TEST=test_utils
+       AC_SUBST(EXTRA_TEST)
+       )
+
 dnl Check for PostgreSQL libraries
 _SAVEDLIBS="$LIBS"
 _SAVEDCPPFLAGS="$CPPFLAGS"
@@ -258,49 +252,38 @@ else
 fi
 LIBS="$_SAVEDLIBS"
 
-
 dnl Check for mysql libraries
-_SAVEDLIBS="$LIBS"
-_SAVEDCPPFLAGS="$CPPFLAGS"
+dnl Default is to search path for mysql_config
 AC_ARG_WITH(mysql,
        ACX_HELP_STRING([--with-mysql=DIR],
-               [sets path to mysql installation (assumes lib/mysql and include subdirs]),
-       MYSQL=$withval,)
-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_close,MYSQLLIBS="-lmysqlclient")
-elif test -f /usr/lib/libmysqlclient.so; then
-  AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
-  AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
-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)
-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)
-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"
-    AC_SUBST(MYSQLINCLUDE)
-    AC_SUBST(MYSQLLIBS)
-    AC_SUBST(check_mysql_LDFLAGS)
+               [Compiles mysql plugins. Expects DIR/bin/mysql_config]),
+       with_mysql=$withval,
+       with_mysql=yes)
+if test $with_mysql != "no" ; then
+  if test -x $with_mysql/bin/mysql_config ; then
+    MYSQLCONFIG="$with_mysql/bin/mysql_config"
   else
+    AC_PATH_PROG(MYSQLCONFIG, mysql_config)
+  fi
+  if test -z "$MYSQLCONFIG"; then
+    with_mysql="not found"
     AC_MSG_WARN([Skipping mysql plugin])
-    AC_MSG_WARN([install mysql client headers to compile this plugin (see REQUIREMENTS).])
+    AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
+  else
+    with_mysql=$MYSQLCONFIG
+    EXTRAS="$EXTRAS check_mysql check_mysql_query"
+    MYSQLINCLUDE=`$MYSQLCONFIG --include`
+    # Mysql 3 does not support --include. --cflags should be sufficient
+    if test $? -ne 0 ; then
+      MYSQLINCLUDE=""
+    fi
+    MYSQLLIBS=`$MYSQLCONFIG --libs`
+    MYSQLCFLAGS=`$MYSQLCONFIG --cflags`
+    AC_SUBST(MYSQLINCLUDE)
+    AC_SUBST(MYSQLLIBS)
+    AC_SUBST(MYSQLCFLAGS)
   fi
-else
-  AC_MSG_WARN([Skipping mysql plugin])
-  AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
 fi
-CPPFLAGS="$_SAVEDCPPFLAGS $MYSQLINCLUDE"
-LIBS="$_SAVEDLIBS"
 
 AC_CHECK_HEADERS(unistd.h)
 
@@ -446,7 +429,7 @@ fi
 
 
 dnl openssl detection/configuration
-if ! test "$with_openssl" = "no"; then
+if ! test x"$with_openssl" = x"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
@@ -460,18 +443,20 @@ if ! test "$with_openssl" = "no"; then
        _SAVEDLDFLAGS="$LDFLAGS"
        dnl Check for OpenSSL header files
        unset FOUNDINCLUDE
-       CPPFLAGS="$CPPFLAGS -I$OPENSSL/include"
-       LDFLAGS="$LDFLAGS -R$OPENSSL/lib"
+       if test x"$with_openssl" != x"/usr" ; then
+               CPPFLAGS="$CPPFLAGS -I$with_openssl/include"
+               LDFLAGS="$LDFLAGS -L$with_openssl/lib"
+       fi
 
        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"
+                        SSLINCLUDE="-I$with_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"
+                                SSLINCLUDE="-I$with_openssl/include"
                                 FOUNDINCLUDE=yes,
                                 FOUNDINCLUDE=no)
        fi
@@ -545,7 +530,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 sys/un.h)
+AC_CHECK_HEADERS(signal.h strings.h string.h syslog.h uio.h errno.h sys/types.h sys/time.h sys/socket.h sys/loadavg.h sys/un.h sys/poll.h)
 AC_CHECK_HEADERS(features.h stdarg.h sys/unistd.h ctype.h stdlib.h)
 
 dnl Checks for typedefs, structures, and compiler characteristics.
@@ -617,6 +602,7 @@ AC_TRY_COMPILE([#include <sys/time.h>],
 
 dnl Checks for library functions.
 AC_CHECK_FUNCS(memmove select socket strdup strstr strtod strtol strtoul floor)
+AC_CHECK_FUNCS(basename poll)
 
 AC_MSG_CHECKING(return type of socket size)
 AC_TRY_COMPILE([#include <stdlib.h>
@@ -672,8 +658,6 @@ AC_ARG_WITH(ps_varlist,
                             [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"
@@ -704,7 +688,7 @@ elif 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)
+       EXTRAS_ROOT="$EXTRAS_ROOT pst3"
 
 dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
 dnl so test for this first...
@@ -1237,17 +1221,17 @@ fi
 fi
 
 
-AC_MSG_CHECKING(for nslookup syntax)
 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])
+       AC_MSG_NOTICE([Using specific nslookup at $ac_cv_nslookup_command])
 else
        AC_PATH_PROG(PATH_TO_NSLOOKUP,nslookup)
        if test -n "$PATH_TO_NSLOOKUP"
        then
+               AC_MSG_CHECKING(for nslookup syntax)
                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"
@@ -1268,12 +1252,6 @@ if test -n "$ac_cv_nslookup_command"; then
        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"
-then
-       EXTRAS="$EXTRAS check_dns"
-fi
-
 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
 AC_ARG_WITH(uptime_command,
             ACX_HELP_STRING([--with-uptime-command=PATH],
@@ -1286,20 +1264,6 @@ AC_ARG_WITH(rpcinfo_command,
                             [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 -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])
-else
-       AC_MSG_WARN([Install NTP programs (http://www.ntp.org) if you want to monitor time synchronization])
-fi
-
 AC_PATH_PROG(PATH_TO_LMSTAT,lmstat)
 if test -x "$PATH_TO_LMSTAT"
 then
@@ -1644,6 +1608,18 @@ if test -n "$PATH_TO_DIG"; then
        AC_DEFINE_UNQUOTED(PATH_TO_DIG,"$PATH_TO_DIG",[Path to dig command, if present])
 fi
 
+AC_PATH_PROG(PATH_TO_APTGET,apt-get)
+AC_ARG_WITH(apt-get_command,
+            ACX_HELP_STRING([--with-apt-get-command=PATH],
+                            [Path to apt-get command]), 
+                            with_apt_get_command=$withval,
+                            with_apt_get_command=$PATH_TO_APTGET)
+AC_DEFINE_UNQUOTED(PATH_TO_APTGET,"$PATH_TO_APTGET",[Path to apt-get command, if present])
+if test -n "$PATH_TO_APTGET" ; then
+       EXTRAS="$EXTRAS check_apt"
+fi
+
+
 if test -f plugins/check_nt.c ; then
   EXTRAS="$EXTRAS check_nt"
 elif test -f ../plugins/check_nt.c ; then
@@ -1680,11 +1656,12 @@ case $host in
 esac
 
 AC_SUBST(EXTRAS)
+AC_SUBST(EXTRAS_ROOT)
 AC_SUBST(EXTRA_NETOBJS)
 AC_SUBST(DEPLIBS)
 
-AM_GNU_GETTEXT([no-libtool], [need-ngettext])
-AM_GNU_GETTEXT_VERSION(0.11.5)
+AM_GNU_GETTEXT([external], [need-ngettext])
+AM_GNU_GETTEXT_VERSION(0.13.1)
 
 dnl Check for Redhat spopen problem
 dnl Wierd problem where ECHILD is returned from a wait call in error
@@ -1731,7 +1708,6 @@ AC_OUTPUT(
   command.cfg 
   test.pl 
   pkg/solaris/pkginfo 
-  intl/Makefile
   po/Makefile.in 
 )
 
@@ -1740,11 +1716,11 @@ 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
+ACX_FEATURE([with],[apt-get-command])
 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])
@@ -1764,6 +1740,7 @@ dnl ACX_FEATURE([with],[ps-varlist])
 
 ACX_FEATURE([with],[lwres])
 ACX_FEATURE([with],[ipv6])
+ACX_FEATURE([with],[mysql])
 ACX_FEATURE([with],[openssl])
 ACX_FEATURE([with],[gnutls])
 ACX_FEATURE([enable],[emulate-getaddrinfo])