Code

Merge branch 'collectd-4.5'
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 16 Feb 2009 11:48:22 +0000 (12:48 +0100)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 16 Feb 2009 11:48:22 +0000 (12:48 +0100)
Conflicts:

configure.in

1  2 
configure.in
src/collectd.conf.pod

diff --cc configure.in
index bd8ca1dd08541d1427e1f61a8f8c11ea437fd42d,2bab6b32cab6f2cbbd7390d1fbdd06f9bf226f38..2b4ab7361adb3fe2330353ac345b4ae3c3a4442e
@@@ -2028,147 -1833,164 +2028,148 @@@ AC_ARG_WITH(libpq, [AS_HELP_STRING([--w
  [
        if test "x$withval" = "xno"
        then
 -              with_libnetsnmp="no"
 +              with_libpq="no"
        else if test "x$withval" = "xyes"
        then
 -              with_libnetsnmp="yes"
 +              with_libpq="yes"
        else
 -              if test -x "$withval"
 +              if test -f "$withval" && test -x "$withval";
                then
 -                      with_snmp_config="$withval"
 -                      with_libnetsnmp="yes"
 -              else
 -                      with_snmp_config="$withval/bin/net-snmp-config"
 -                      with_libnetsnmp="yes"
 -              fi
 +                      with_pg_config="$withval"
 +              else if test -x "$withval/bin/pg_config"
 +              then
 +                      with_pg_config="$withval/bin/pg_config"
 +              fi; fi
 +              with_libpq="yes"
        fi; fi
  ],
 -[with_libnetsnmp="yes"])
 -if test "x$with_libnetsnmp" = "xyes"
 +[
 +      with_libpq="yes"
 +])
 +if test "x$with_libpq" = "xyes"
  then
 -      with_snmp_cflags=`$with_snmp_config --cflags 2>/dev/null`
 -      snmp_config_status=$?
 +      with_libpq_includedir=`$with_pg_config --includedir 2> /dev/null`
 +      pg_config_status=$?
  
 -      if test $snmp_config_status -ne 0
 +      if test $pg_config_status -eq 0
        then
 -              with_libnetsnmp="no ($with_snmp_config failed)"
 +              if test -n "$with_libpq_includedir"; then
 +                      for dir in $with_libpq_includedir; do
 +                              with_libpq_cppflags="$with_libpq_cppflags -I$dir"
 +                      done
 +              fi
        else
 -              SAVE_CPPFLAGS="$CPPFLAGS"
 -              CPPFLAGS="$CPPFLAGS $with_snmp_cflags"
 -              
 -              AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
 -
 -              CPPFLAGS="$SAVE_CPPFLAGS"
 +              AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
        fi
 +
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_libpq_cppflags"
 +
 +      AC_CHECK_HEADERS(libpq-fe.h, [],
 +              [with_libpq="no (libpq-fe.h not found)"], [])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
  fi
 -if test "x$with_libnetsnmp" = "xyes"
 +if test "x$with_libpq" = "xyes"
  then
 -      with_snmp_libs=`$with_snmp_config --libs 2>/dev/null`
 -      snmp_config_status=$?
 +      with_libpq_libdir=`$with_pg_config --libdir 2> /dev/null`
 +      pg_config_status=$?
  
 -      if test $snmp_config_status -ne 0
 +      if test $pg_config_status -eq 0
        then
 -              with_libnetsnmp="no ($with_snmp_config failed)"
 +              if test -n "$with_libpq_libdir"; then
 +                      for dir in $with_libpq_libdir; do
 +                              with_libpq_ldflags="$with_libpq_ldflags -L$dir"
 +                      done
 +              fi
        else
 -              AC_CHECK_LIB(netsnmp, init_snmp,
 -              [with_libnetsnmp="yes"],
 -              [with_libnetsnmp="no (libnetsnmp not found)"],
 -              [$with_snmp_libs])
 +              AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
        fi
 +
 +      SAVE_LDFLAGS="$LDFLAGS"
 +      LDFLAGS="$LDFLAGS $with_libpq_ldflags"
 +
 +      AC_CHECK_LIB(pq, PQconnectdb,
 +              [with_libpq="yes"],
 +              [with_libpq="no (symbol 'PQconnectdb' not found)"])
 +
 +      LDFLAGS="$SAVE_LDFLAGS"
  fi
 -if test "x$with_libnetsnmp" = "xyes"
 +if test "x$with_libpq" = "xyes"
  then
 -      BUILD_WITH_LIBSNMP_CFLAGS="$with_snmp_cflags"
 -      BUILD_WITH_LIBSNMP_LIBS="$with_snmp_libs"
 -      AC_SUBST(BUILD_WITH_LIBSNMP_CFLAGS)
 -      AC_SUBST(BUILD_WITH_LIBSNMP_LIBS)
 +      BUILD_WITH_LIBPQ_CPPFLAGS="$with_libpq_cppflags"
 +      BUILD_WITH_LIBPQ_LDFLAGS="$with_libpq_ldflags"
 +      AC_SUBST(BUILD_WITH_LIBPQ_CPPFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBPQ_LDFLAGS)
  fi
 -AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")
 -
 -PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
 -              [with_libnotify="yes"],
 -              [with_libnotify="no ($LIBNOTIFY_PKG_ERRORS)"])
 +AM_CONDITIONAL(BUILD_WITH_LIBPQ, test "x$with_libpq" = "xyes")
 +# }}}
  
 -with_libupsclient_config=""
 -with_libupsclient_cflags=""
 -with_libupsclient_libs=""
 -AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
 -[
 -      if test "x$withval" = "xno"
 -      then
 -              with_libupsclient="no"
 -      else if test "x$withval" = "xyes"
 +# --with-libpthread {{{
 +AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
 +[     if test "x$withval" != "xno" \
 +              && test "x$withval" != "xyes"
        then
 -              with_libupsclient="use_pkgconfig"
 +              LDFLAGS="$LDFLAGS -L$withval/lib"
 +              CPPFLAGS="$CPPFLAGS -I$withval/include"
 +              with_libpthread="yes"
        else
 -              if test -x "$withval"
 -              then
 -                      with_libupsclient_config="$withval"
 -                      with_libupsclient="use_libupsclient_config"
 -              else if test -x "$withval/bin/libupsclient-config"
 +              if test "x$withval" = "xno"
                then
 -                      with_libupsclient_config="$withval/bin/net-snmp-config"
 -                      with_libupsclient="use_libupsclient_config"
 -              else
 -                      AC_MSG_NOTICE([Not checking for libupsclient: Manually configured])
 -                      with_libupsclient_cflags="-I$withval/include"
 -                      with_libupsclient_libs="-L$withval/lib -lupsclient"
 -                      with_libupsclient="yes"
 -              fi; fi
 -      fi; fi
 -],
 -[with_libupsclient="use_pkgconfig"])
 -
 -# configure using libupsclient-config
 -if test "x$with_libupsclient" = "xuse_libupsclient_config"
 -then
 -      AC_MSG_NOTICE([Checking for libupsclient using $with_libupsclient_config])
 -      with_libupsclient_cflags="`$with_libupsclient_config --cflags`"
 -      if test $? -ne 0
 -      then
 -              with_libupsclient="no ($with_libupsclient_config failed)"
 -      fi
 -      with_libupsclient_libs="`$with_libupsclient_config --libs`"
 -      if test $? -ne 0
 -      then
 -              with_libupsclient="no ($with_libupsclient_config failed)"
 +                      with_libpthread="no (disabled)"
 +              fi
        fi
 -fi
 -if test "x$with_libupsclient" = "xuse_libupsclient_config"
 +], [with_libpthread="yes"])
 +if test "x$with_libpthread" = "xyes"
  then
 -      with_libupsclient="yes"
 +      AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
  fi
 -# configure using pkg-config
 -if test "x$with_libupsclient" = "xuse_pkgconfig"
 +if test "x$with_libpthread" = "xyes"
  then
 -      if test "x$PKG_CONFIG" = "x"
 -      then
 -              with_libupsclient="no (Don't have pkg-config)"
 -      fi
 +      AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
  fi
 -if test "x$with_libupsclient" = "xuse_pkgconfig"
 +if test "x$with_libpthread" = "xyes"
  then
 -      AC_MSG_NOTICE([Checking for libupsclient using $PKG_CONFIG])
 -      $PKG_CONFIG --exists 'libupsclient' 2>/dev/null
 -      if test $? -ne 0
 +      collect_pthread=1
 +else
 +      collect_pthread=0
 +fi
 +AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
 +      [Wether or not to use pthread (POSIX threads) library])
 +AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
 +# }}}
 +
 +# --with-librrd {{{
 +# AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
 +librrd_cflags=""
 +librrd_ldflags=""
 +librrd_threadsafe="yes"
 +librrd_rrdc_update="no"
 +AC_ARG_WITH(librrd, [AS_HELP_STRING([--with-librrd@<:@=PREFIX@:>@], [Path to rrdtool.])],
 +[     if test "x$withval" != "xno" && test "x$withval" != "xyes"
        then
 -              with_libupsclient="no (pkg-config doesn't know library)"
 +              librrd_cflags="-I$withval/include"
 +              librrd_ldflags="-L$withval/lib"
 +              with_librrd="yes"
 +      else
 +              with_librrd="$withval"
        fi
 -fi
 -if test "x$with_libupsclient" = "xuse_pkgconfig"
 -then
 -      with_libupsclient_cflags="`$PKG_CONFIG --cflags 'libupsclient'`"
 -      if test $? -ne 0
 -      then
 -              with_libupsclient="no ($PKG_CONFIG failed)"
 -      fi
 -      with_libupsclient_libs="`$PKG_CONFIG --libs 'libupsclient'`"
 -      if test $? -ne 0
 -      then
 -              with_libupsclient="no ($PKG_CONFIG failed)"
 -      fi
 -fi
 -if test "x$with_libupsclient" = "xuse_pkgconfig"
 -then
 -      with_libupsclient="yes"
 -fi
 -
 -# with_libupsclient_cflags and with_libupsclient_libs are set up now, let's do
 -# the actual checks.
 -if test "x$with_libupsclient" = "xyes"
 +], [with_librrd="yes"])
 +if test "x$with_librrd" = "xyes"
  then
        SAVE_CPPFLAGS="$CPPFLAGS"
 -      CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
 +      SAVE_LDFLAGS="$LDFLAGS"
  
 -      AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])
 +      CPPFLAGS="$CPPFLAGS $librrd_cflags"
 +      LDFLAGS="$LDFLAGS $librrd_ldflags"
 +
 +      AC_CHECK_HEADERS(rrd.h,, [with_librrd="no (rrd.h not found)"])
  
        CPPFLAGS="$SAVE_CPPFLAGS"
 +      LDFLAGS="$SAVE_LDFLAGS"
  fi
 -if test "x$with_libupsclient" = "xyes"
 +if test "x$with_librrd" = "xyes"
  then
        SAVE_CPPFLAGS="$CPPFLAGS"
        SAVE_LDFLAGS="$LDFLAGS"
        CPPFLAGS="$SAVE_CPPFLAGS"
        LDFLAGS="$SAVE_LDFLAGS"
  fi
 -if test "x$with_libupsclient" = "xyes"
 +if test "x$with_librrd" = "xyes"
  then
 -      SAVE_CPPFLAGS="$CPPFLAGS"
 -      CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
 -
 -      AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [],
 -[#include <stdlib.h>
 -#include <stdio.h>
 -#include <upsclient.h>])
 -
 -      CPPFLAGS="$SAVE_CPPFLAGS"
 +      BUILD_WITH_LIBRRD_CFLAGS="$librrd_cflags"
 +      BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
 +      AC_SUBST(BUILD_WITH_LIBRRD_CFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBRRD_LDFLAGS)
  fi
 -if test "x$with_libupsclient" = "xyes"
 +if test "x$librrd_threadsafe" = "xyes"
  then
 -      BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_libupsclient_cflags"
 -      BUILD_WITH_LIBUPSCLIENT_LIBS="$with_libupsclient_libs"
 -      AC_SUBST(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
 -      AC_SUBST(BUILD_WITH_LIBUPSCLIENT_LIBS)
 +      AC_DEFINE(HAVE_THREADSAFE_LIBRRD, 1, [Define to 1 if you have the threadsafe rrd library (-lrrd_th).])
  fi
 +# }}}
  
 -### BEGIN of check for libxmms ###
 -with_xmms_config="xmms-config"
 -with_xmms_cflags=""
 -with_xmms_libs=""
 -AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
 +# --with-libsensors {{{
 +with_sensors_cflags=""
 +with_sensors_ldflags=""
 +AC_ARG_WITH(libsensors, [AS_HELP_STRING([--with-libsensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
  [
 -      if test "x$withval" != "xno" \
 -              && test "x$withval" != "xyes"
 -      then
 -              if test -f "$withval" && test -x "$withval";
 -              then
 -                      with_xmms_config="$withval"
 -              else if test -x "$withval/bin/xmms-config"
 -              then
 -                      with_xmms_config="$withval/bin/xmms-config"
 -              fi; fi
 -              with_libxmms="yes"
 -      else if test "x$withval" = "xno"
 +      if test "x$withval" = "xno"
        then
 -              with_libxmms="no"
 +              with_libsensors="no"
        else
 -              with_libxmms="yes"
 -      fi; fi
 +              with_libsensors="yes"
 +              if test "x$withval" != "xyes"
 +              then
 +                      with_sensors_cflags="-I$withval/include"
 +                      with_sensors_ldflags="-L$withval/lib"
 +                      with_libsensors="yes"
 +              fi
 +      fi
  ],
  [
 -      with_libxmms="yes"
 -])
 -if test "x$with_libxmms" = "xyes"
 -then
 -      with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
 -      xmms_config_status=$?
 -
 -      if test $xmms_config_status -ne 0
 +      if test "x$ac_system" = "xLinux"
        then
 -              with_libxmms="no"
 +              with_libsensors="yes"
 +      else
 +              with_libsensors="no (Linux only library)"
        fi
 -fi
 -if test "x$with_libxmms" = "xyes"
 +])
 +if test "x$with_libsensors" = "xyes"
  then
 -      with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
 -      xmms_config_status=$?
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
  
 -      if test $xmms_config_status -ne 0
 -      then
 -              with_libxmms="no"
 -      fi
 +#     AC_CHECK_HEADERS(sensors/sensors.h,
 +#     [
 +#             AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
 +#     ],
 +#     [with_libsensors="no (sensors/sensors.h not found)"])
 +      AC_CHECK_HEADERS(sensors/sensors.h, [], [with_libsensors="no (sensors/sensors.h not found)"])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
  fi
 -if test "x$with_libxmms" = "xyes"
 +if test "x$with_libsensors" = "xyes"
  then
 -      AC_CHECK_LIB(xmms, xmms_remote_get_info,
 -      [
 -              BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
 -              BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
 -              AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
 -              AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
 -      ],
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      SAVE_LDFLAGS="$LDFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
 +      LDFLAGS="$LDFLAGS $with_sensors_ldflags"
 +
 +      AC_CHECK_LIB(sensors, sensors_init,
        [
 -              with_libxmms="no"
 +              AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
        ],
 -      [$with_xmms_libs])
 +      [with_libsensors="no (libsensors not found)"])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +      LDFLAGS="$SAVE_LDFLAGS"
  fi
 -with_libxmms_numeric=0
 -if test "x$with_libxmms" = "xyes"
 +if test "x$with_libsensors" = "xyes"
  then
 -      with_libxmms_numeric=1
 +      BUILD_WITH_LIBSENSORS_CFLAGS="$with_sensors_cflags"
 +      BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
 +      AC_SUBST(BUILD_WITH_LIBSENSORS_CFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBSENSORS_LDFLAGS)
  fi
 -AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
 -AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
 -### END of check for libxmms ###
 +AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_libsensors" = "xyes")
 +# }}}
  
 -with_libnetlink_cflags=""
 -with_libnetlink_libs="-lnetlink"
 -AC_ARG_WITH(libnetlink, [AS_HELP_STRING([--with-libnetlink@<:@=PREFIX@:>@], [Path to libnetlink.])],
 +# --with-libstatgrab {{{
 +with_libstatgrab_cflags=""
 +with_libstatgrab_ldflags=""
 +AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
  [
 - echo "libnetlink: withval = $withval"
 - if test "x$withval" = "xyes"
 - then
 -       with_libnetlink="yes"
 - else if test "x$withval" = "xno"
 - then
 -       with_libnetlink="no"
 - else
 -       if test -d "$withval/include"
 -       then
 -               with_libnetlink_cflags="-I$withval/include"
 -               with_libnetlink_libs="-L$withval/lib -lnetlink"
 -               with_libnetlink="yes"
 -       else
 -               AC_MSG_ERROR("no such directory: $withval/include")
 -       fi
 - fi; fi
 +      if test "x$withval" != "xno" \
 +              && test "x$withval" != "xyes"
 +      then
 +              with_libstatgrab_cflags="-I$withval/include"
 +              with_libstatgrab_ldflags="-L$withval/lib"
 +              with_libstatgrab="yes"
 +      else
 +              with_libstatgrab="$withval"
 +      fi
  ],
  [
 - if test "x$ac_system" = "xLinux"
 - then
 -       with_libnetlink="yes"
 - else
 -       with_libnetlink="no (Linux only library)"
 - fi
 +      if test "x$ac_system" = "xunknown"
 +      then
 +              with_libstatgrab="yes"
 +      else
 +              with_libstatgrab="no"
 +      fi
  ])
 -if test "x$with_libnetlink" = "xyes"
 +with_libstatgrab_pkg_config="yes"
 +if test "x$with_libstatgrab" = "xyes" \
 +  && test "x$PKG_CONFIG" != "x"
  then
 -      SAVE_CFLAGS=$CFLAGS
 -      CFLAGS="$CFLAGS $with_libnetlink_cflags"
 -
 -      with_libnetlink="no (libnetlink.h not found)"
 -
 -      AC_CHECK_HEADERS(libnetlink.h iproute/libnetlink.h linux/libnetlink.h,
 -      [
 -       with_libnetlink="yes"
 -       break
 -      ], [],
 -[#include <stdio.h>
 -#include <sys/types.h>
 -#include <asm/types.h>
 -#include <sys/socket.h>
 -#include <linux/netlink.h>
 -#include <linux/rtnetlink.h>])
 -      AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
 -[#include <stdio.h>
 -#include <sys/types.h>
 -#include <asm/types.h>
 -#include <sys/socket.h>])
 +  AC_MSG_CHECKING([pkg-config for libstatgrab])
 +  temp_result="found"
 +  $PKG_CONFIG --exists libstatgrab 2>/dev/null
 +  if test "$?" != "0"
 +  then
 +    with_libstatgrab_pkg_config="no"
 +    temp_result="not found"
 +  fi
 +  AC_MSG_RESULT([$temp_result])
 +else
 +  AC_MSG_NOTICE([pkg-config not available, trying to guess flags for the statgrab library.])
 +  with_libstatgrab_pkg_config="no"
 +  with_libstatgrab_ldflags="$with_libstatgrab_ldflags -lstatgrab"
 +fi
  
 -      AC_COMPILE_IFELSE(
 -[#include <stdio.h>
 -#include <sys/types.h>
 -#include <asm/types.h>
 -#include <sys/socket.h>
 -#include <linux/netlink.h>
 -#include <linux/rtnetlink.h>
 +if test "x$with_libstatgrab" = "xyes" \
 +  && test "x$with_libstatgrab_pkg_config" = "xyes" \
 +  && test "x$with_libstatgrab_cflags" = "x"
 +then
 +  AC_MSG_CHECKING([for libstatgrab CFLAGS])
 +  temp_result="`$PKG_CONFIG --cflags libstatgrab`"
 +  if test "$?" = "0"
 +  then
 +    with_libstatgrab_cflags="$temp_result"
 +  else
 +    with_libstatgrab="no ($PKG_CONFIG --cflags libstatgrab failed)"
 +    temp_result="$PKG_CONFIG --cflags libstatgrab failed"
 +  fi
 +  AC_MSG_RESULT([$temp_result])
 +fi
  
 -int main (void)
 -{
 -      int retval = TCA_STATS2;
 -      return (retval);
 -}],
 -      [AC_DEFINE([HAVE_TCA_STATS2], 1, [True if the enum-member TCA_STATS2 exists])]
 -      []);
 +if test "x$with_libstatgrab" = "xyes" \
 +  && test "x$with_libstatgrab_pkg_config" = "xyes" \
 +  && test "x$with_libstatgrab_ldflags" = "x"
 +then
 +  AC_MSG_CHECKING([for libstatgrab LDFLAGS])
 +  temp_result="`$PKG_CONFIG --libs libstatgrab`"
 +  if test "$?" = "0"
 +  then
 +    with_libstatgrab_ldflags="$temp_result"
 +  else
 +    with_libstatgrab="no ($PKG_CONFIG --libs libstatgrab failed)"
 +    temp_result="$PKG_CONFIG --libs libstatgrab failed"
 +  fi
 +  AC_MSG_RESULT([$temp_result])
 +fi
  
 -      AC_COMPILE_IFELSE(
 -[#include <stdio.h>
 -#include <sys/types.h>
 -#include <asm/types.h>
 -#include <sys/socket.h>
 -#include <linux/netlink.h>
 -#include <linux/rtnetlink.h>
 +if test "x$with_libstatgrab" = "xyes"
 +then
 +  SAVE_CPPFLAGS="$CPPFLAGS"
 +  CPPFLAGS="$CPPFLAGS $with_libstatgrab_cflags"
  
 -int main (void)
 -{
 -      int retval = TCA_STATS;
 -      return (retval);
 -}],
 -      [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
 -      []);
 +  AC_CHECK_HEADERS(statgrab.h,
 +                 [with_libstatgrab="yes"],
 +                 [with_libstatgrab="no (statgrab.h not found)"])
  
 -      CFLAGS="$SAVE_CFLAGS"
 +  CPPFLAGS="$SAVE_CPPFLAGS"
  fi
 -if test "x$with_libnetlink" = "xyes"
 +
 +if test "x$with_libstatgrab" = "xyes"
  then
 -      AC_CHECK_LIB(netlink, rtnl_open,
 -                   [with_libnetlink="yes"],
 -                   [with_libnetlink="no (symbol 'rtnl_open' not found)"],
 -                   [$with_libnetlink_libs])
 +  SAVE_CFLAGS="$CFLAGS"
 +  SAVE_LDFLAGS="$LDFLAGS"
 +
 +  CFLAGS="$CFLAGS $with_libstatgrab_cflags"
 +  LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
 +
 +  AC_CHECK_LIB(statgrab, sg_init,
 +             [with_libstatgrab="yes"],
 +             [with_libstatgrab="no (symbol sg_init not found)"])
 +
 +  CFLAGS="$SAVE_CFLAGS"
 +  LDFLAGS="$SAVE_LDFLAGS"
  fi
 -if test "x$with_libnetlink" = "xyes"
 +
 +AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
 +if test "x$with_libstatgrab" = "xyes"
  then
 -      BUILD_WITH_LIBNETLINK_CFLAGS="$with_libnetlink_cflags"
 -      BUILD_WITH_LIBNETLINK_LIBS="$with_libnetlink_libs"
 -      AC_SUBST(BUILD_WITH_LIBNETLINK_CFLAGS)
 -      AC_SUBST(BUILD_WITH_LIBNETLINK_LIBS)
 +  AC_DEFINE(HAVE_LIBSTATGRAB, 1, [Define to 1 if you have the 'statgrab' library (-lstatgrab)])
 +  BUILD_WITH_LIBSTATGRAB_CFLAGS="$with_libstatgrab_cflags"
 +  BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
 +  AC_SUBST(BUILD_WITH_LIBSTATGRAB_CFLAGS)
 +  AC_SUBST(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
  fi
 -AM_CONDITIONAL(BUILD_WITH_LIBNETLINK, test "x$with_libnetlink" = "xyes")
 +# }}}
  
- # --with-libxmms {{{
- with_xmms_config="xmms-config"
- with_xmms_cflags=""
- with_xmms_libs=""
- AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
 -with_libopenipmipthread="yes"
 -with_libopenipmipthread_cflags=""
 -with_libopenipmipthread_libs=""
++# --with-libupsclient {{{
++with_libupsclient_config=""
++with_libupsclient_cflags=""
++with_libupsclient_libs=""
++AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
 +[
-       if test "x$withval" != "xno" \
-               && test "x$withval" != "xyes"
++      if test "x$withval" = "xno"
 +      then
-               if test -f "$withval" && test -x "$withval";
++              with_libupsclient="no"
++      else if test "x$withval" = "xyes"
++      then
++              with_libupsclient="use_pkgconfig"
++      else
++              if test -x "$withval"
 +              then
-                       with_xmms_config="$withval"
-               else if test -x "$withval/bin/xmms-config"
++                      with_libupsclient_config="$withval"
++                      with_libupsclient="use_libupsclient_config"
++              else if test -x "$withval/bin/libupsclient-config"
 +              then
-                       with_xmms_config="$withval/bin/xmms-config"
++                      with_libupsclient_config="$withval/bin/net-snmp-config"
++                      with_libupsclient="use_libupsclient_config"
++              else
++                      AC_MSG_NOTICE([Not checking for libupsclient: Manually configured])
++                      with_libupsclient_cflags="-I$withval/include"
++                      with_libupsclient_libs="-L$withval/lib -lupsclient"
++                      with_libupsclient="yes"
 +              fi; fi
-               with_libxmms="yes"
-       else if test "x$withval" = "xno"
-       then
-               with_libxmms="no"
-       else
-               with_libxmms="yes"
 +      fi; fi
 +],
- [
-       with_libxmms="yes"
- ])
- if test "x$with_libxmms" = "xyes"
- then
-       with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
-       xmms_config_status=$?
++[with_libupsclient="use_pkgconfig"])
  
-       if test $xmms_config_status -ne 0
 -AC_MSG_CHECKING([for pkg-config])
 -temp_result="no"
 -if test "x$PKG_CONFIG" = "x"
++# configure using libupsclient-config
++if test "x$with_libupsclient" = "xuse_libupsclient_config"
+ then
 -      with_libopenipmipthread="no"
 -      temp_result="no"
 -else
 -      temp_result="$PKG_CONFIG"
++      AC_MSG_NOTICE([Checking for libupsclient using $with_libupsclient_config])
++      with_libupsclient_cflags="`$with_libupsclient_config --cflags`"
++      if test $? -ne 0
 +      then
-               with_libxmms="no"
++              with_libupsclient="no ($with_libupsclient_config failed)"
 +      fi
- fi
- if test "x$with_libxmms" = "xyes"
- then
-       with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
-       xmms_config_status=$?
-       if test $xmms_config_status -ne 0
++      with_libupsclient_libs="`$with_libupsclient_config --libs`"
++      if test $? -ne 0
 +      then
-               with_libxmms="no"
++              with_libupsclient="no ($with_libupsclient_config failed)"
 +      fi
 +fi
- if test "x$with_libxmms" = "xyes"
++if test "x$with_libupsclient" = "xuse_libupsclient_config"
 +then
-       AC_CHECK_LIB(xmms, xmms_remote_get_info,
-       [
-               BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
-               BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
-               AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
-               AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
-       ],
-       [
-               with_libxmms="no"
-       ],
-       [$with_xmms_libs])
++      with_libupsclient="yes"
  fi
- with_libxmms_numeric=0
- if test "x$with_libxmms" = "xyes"
 -AC_MSG_RESULT([$temp_result])
 -if test "x$with_libopenipmipthread" = "xyes"
++# configure using pkg-config
++if test "x$with_libupsclient" = "xuse_pkgconfig"
  then
-       with_libxmms_numeric=1
 -      AC_MSG_CHECKING([for libOpenIPMIpthread])
 -      $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
 -      if test "$?" != "0"
++      if test "x$PKG_CONFIG" = "x"
+       then
 -              with_libopenipmipthread="no ($PKG_CONFIG doesn't know OpenIPMIpthread)"
++              with_libupsclient="no (Don't have pkg-config)"
+       fi
 -      AC_MSG_RESULT([$with_libopenipmipthread])
  fi
- AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
- AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
- # }}}
--
- # pkg-config --exists 'libupsclient' {{{
- with_libupsclient="no (pkg-config isn't available)"
- with_libupsclient_cflags=""
- with_libupsclient_libs=""
- if test "x$PKG_CONFIG" != "x"
 -if test "x$with_libopenipmipthread" = "xyes"
++if test "x$with_libupsclient" = "xuse_pkgconfig"
  then
-       pkg-config --exists 'libupsclient' 2>/dev/null
 -      AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS])
 -      temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`"
--      if test "$?" = "0"
++      AC_MSG_NOTICE([Checking for libupsclient using $PKG_CONFIG])
++      $PKG_CONFIG --exists 'libupsclient' 2>/dev/null
++      if test $? -ne 0
        then
-               with_libupsclient="yes"
 -              with_libopenipmipthread_cflags="$temp_result"
--      else
 -              with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)"
 -              temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed"
 +              with_libupsclient="no (pkg-config doesn't know library)"
        fi
 -      AC_MSG_RESULT([$temp_result])
  fi
- if test "x$with_libupsclient" = "xyes"
 -
 -if test "x$with_libopenipmipthread" = "xyes"
++if test "x$with_libupsclient" = "xuse_pkgconfig"
  then
-       with_libupsclient_cflags="`pkg-config --cflags 'libupsclient'`"
 -      AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS])
 -      temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`"
 -      if test "$?" = "0"
++      with_libupsclient_cflags="`$PKG_CONFIG --cflags 'libupsclient'`"
 +      if test $? -ne 0
        then
-               with_libupsclient="no"
 -              with_libopenipmipthread_ldflags="$temp_result"
 -      else
 -              with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)"
 -              temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed"
++              with_libupsclient="no ($PKG_CONFIG failed)"
        fi
-       with_libupsclient_libs="`pkg-config --libs 'libupsclient'`"
 -      AC_MSG_RESULT([$temp_result])
++      with_libupsclient_libs="`$PKG_CONFIG --libs 'libupsclient'`"
 +      if test $? -ne 0
 +      then
-               with_libupsclient="no"
++              with_libupsclient="no ($PKG_CONFIG failed)"
 +      fi
 +fi
++if test "x$with_libupsclient" = "xuse_pkgconfig"
++then
++      with_libupsclient="yes"
++fi
++
++# with_libupsclient_cflags and with_libupsclient_libs are set up now, let's do
++# the actual checks.
 +if test "x$with_libupsclient" = "xyes"
 +then
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
 +
 +      AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
  fi
 -
 -if test "x$with_libopenipmipthread" = "xyes"
 +if test "x$with_libupsclient" = "xyes"
  then
        SAVE_CPPFLAGS="$CPPFLAGS"
 -      CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags"
 +      SAVE_LDFLAGS="$LDFLAGS"
  
 -      AC_CHECK_HEADERS(OpenIPMI/ipmi_smi.h,
 -                       [with_libopenipmipthread="yes"],
 -                       [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"],
 -[#include <OpenIPMI/ipmiif.h>
 -#include <OpenIPMI/ipmi_err.h>
 -#include <OpenIPMI/ipmi_posix.h>
 -#include <OpenIPMI/ipmi_conn.h>
 -])
 +      CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
 +      LDFLAGS="$LDFLAGS $with_libupsclient_libs"
 +
 +      AC_CHECK_LIB(upsclient, upscli_connect,
 +                   [with_libupsclient="yes"],
 +                   [with_libupsclient="no (symbol upscli_connect not found)"])
  
        CPPFLAGS="$SAVE_CPPFLAGS"
 +      LDFLAGS="$SAVE_LDFLAGS"
  fi
 +if test "x$with_libupsclient" = "xyes"
 +then
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
  
 -if test "x$with_libopenipmipthread" = "xyes"
 +      AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [],
 +[#include <stdlib.h>
 +#include <stdio.h>
 +#include <upsclient.h>])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +fi
 +if test "x$with_libupsclient" = "xyes"
  then
 -      BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags"
 -      BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags"
 -      AC_SUBST(BUILD_WITH_OPENIPMI_CFLAGS)
 -      AC_SUBST(BUILD_WITH_OPENIPMI_LIBS)
 +      BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_libupsclient_cflags"
 +      BUILD_WITH_LIBUPSCLIENT_LIBS="$with_libupsclient_libs"
 +      AC_SUBST(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBUPSCLIENT_LIBS)
  fi
 +# }}}
  
 -dnl Check for libpq.
 -with_pg_config="pg_config"
 -with_libpq_includedir=""
 -with_libpq_libdir=""
 -with_libpq_cppflags=""
 -with_libpq_ldflags=""
 -AC_ARG_WITH(libpq, [AS_HELP_STRING([--with-libpq@<:@=PREFIX@:>@],
 -      [Path to libpq.])],
++# --with-libxmms {{{
++with_xmms_config="xmms-config"
++with_xmms_cflags=""
++with_xmms_libs=""
++AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
+ [
 -      if test "x$withval" = "xno"
 -      then
 -              with_libpq="no"
 -      else if test "x$withval" = "xyes"
++      if test "x$withval" != "xno" \
++              && test "x$withval" != "xyes"
+       then
 -              with_libpq="yes"
 -      else
+               if test -f "$withval" && test -x "$withval";
+               then
 -                      with_pg_config="$withval"
 -              else if test -x "$withval/bin/pg_config"
++                      with_xmms_config="$withval"
++              else if test -x "$withval/bin/xmms-config"
+               then
 -                      with_pg_config="$withval/bin/pg_config"
++                      with_xmms_config="$withval/bin/xmms-config"
+               fi; fi
 -              with_libpq="yes"
++              with_libxmms="yes"
++      else if test "x$withval" = "xno"
++      then
++              with_libxmms="no"
++      else
++              with_libxmms="yes"
+       fi; fi
+ ],
+ [
 -      with_libpq="yes"
++      with_libxmms="yes"
+ ])
 -if test "x$with_libpq" = "xyes"
++if test "x$with_libxmms" = "xyes"
+ then
 -      with_libpq_includedir=`$with_pg_config --includedir 2> /dev/null`
 -      pg_config_status=$?
++      with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
++      xmms_config_status=$?
 -      if test $pg_config_status -eq 0
++      if test $xmms_config_status -ne 0
+       then
 -              if test -n "$with_libpq_includedir"; then
 -                      for dir in $with_libpq_includedir; do
 -                              with_libpq_cppflags="$with_libpq_cppflags -I$dir"
 -                      done
 -              fi
 -      else
 -              AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
++              with_libxmms="no"
+       fi
 -
 -      SAVE_CPPFLAGS="$CPPFLAGS"
 -      CPPFLAGS="$CPPFLAGS $with_libpq_cppflags"
 -
 -      AC_CHECK_HEADERS(libpq-fe.h, [],
 -              [with_libpq="no (libpq-fe.h not found)"], [])
 -
 -      CPPFLAGS="$SAVE_CPPFLAGS"
+ fi
 -if test "x$with_libpq" = "xyes"
++if test "x$with_libxmms" = "xyes"
+ then
 -      with_libpq_libdir=`$with_pg_config --libdir 2> /dev/null`
 -      pg_config_status=$?
++      with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
++      xmms_config_status=$?
 -      if test $pg_config_status -eq 0
++      if test $xmms_config_status -ne 0
+       then
 -              if test -n "$with_libpq_libdir"; then
 -                      for dir in $with_libpq_libdir; do
 -                              with_libpq_ldflags="$with_libpq_ldflags -L$dir"
 -                      done
 -              fi
 -      else
 -              AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
++              with_libxmms="no"
+       fi
 -
 -      SAVE_LDFLAGS="$LDFLAGS"
 -      LDFLAGS="$LDFLAGS $with_libpq_ldflags"
 -
 -      AC_CHECK_LIB(pq, PQconnectdb,
 -              [with_libpq="yes"],
 -              [with_libpq="no (symbol 'PQconnectdb' not found)"])
 -
 -      LDFLAGS="$SAVE_LDFLAGS"
+ fi
 -if test "x$with_libpq" = "xyes"
++if test "x$with_libxmms" = "xyes"
+ then
 -      BUILD_WITH_LIBPQ_CPPFLAGS="$with_libpq_cppflags"
 -      BUILD_WITH_LIBPQ_LDFLAGS="$with_libpq_ldflags"
 -      AC_SUBST(BUILD_WITH_LIBPQ_CPPFLAGS)
 -      AC_SUBST(BUILD_WITH_LIBPQ_LDFLAGS)
++      AC_CHECK_LIB(xmms, xmms_remote_get_info,
++      [
++              BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
++              BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
++              AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
++              AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
++      ],
++      [
++              with_libxmms="no"
++      ],
++      [$with_xmms_libs])
+ fi
 -AM_CONDITIONAL(BUILD_WITH_LIBPQ, test "x$with_libpq" = "xyes")
++with_libxmms_numeric=0
++if test "x$with_libxmms" = "xyes"
++then
++      with_libxmms_numeric=1
++fi
++AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
++AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
++# }}}
 -dnl Check for libvirt and libxml2 libraries.
 +# pkg-config --exists 'libxml-2.0'; pkg-config --exists libvirt {{{
  with_libxml2="no (pkg-config isn't available)"
  with_libxml2_cflags=""
  with_libxml2_ldflags=""
Simple merge