From 0aa63f0c02299e5c6bf297ed464509e1debab5d8 Mon Sep 17 00:00:00 2001 From: octo Date: Fri, 28 Apr 2006 17:56:23 +0000 Subject: [PATCH] Changed the build system to - only check for libkvm and libdevstat if libstatgrab is installed - only link against the above libraries if libstatgrab is present. --- configure.in | 14 +++++++++--- src/Makefile.am | 59 ++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 64 insertions(+), 9 deletions(-) diff --git a/configure.in b/configure.in index 3f3e7de4..54c144b3 100644 --- a/configure.in +++ b/configure.in @@ -587,6 +587,9 @@ AC_CHECK_LIB(IOKit, IOServiceGetMatchingServices, AC_DEFINE_UNQUOTED(COLLECT_LIBIOKIT, [$collect_libiokit], [Wether or not to use the IOKit library]) AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes") +with_libstatgrab="yes" +with_libdevstat="no" +with_libkvm="no" AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])], [ if test "x$withval" != "xno" -a "x$withval" != "xyes" @@ -606,15 +609,18 @@ AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [P ]) if test "x$with_libstatgrab" = "xyes" then - AC_CHECK_LIB(devstat, getdevs) - AC_CHECK_LIB(kvm, kvm_getargv) - AC_CHECK_LIB(statgrab, sg_init,, [with_libstatgrab="no (libstatgrab not found)"]) + AC_CHECK_LIB(statgrab, sg_init, [with_libstatgrab="yes"], [with_libstatgrab="no (libstatgrab not found)"]) fi if test "x$with_libstatgrab" = "xyes" then AC_CHECK_HEADERS(statgrab.h,, [with_libstatgrab="no (statgrab.h not found)"]) fi if test "x$with_libstatgrab" = "xyes" +then + AC_CHECK_LIB(devstat, getdevs, [with_libdevstat="yes"], [with_libdevstat="no"]) + AC_CHECK_LIB(kvm, kvm_getargv, [with_libkvm="yes"], [with_libkvm="no"]) +fi +if test "x$with_libstatgrab" = "xyes" then collect_libstatgrab=1 else @@ -623,6 +629,8 @@ fi AC_DEFINE_UNQUOTED(COLLECT_LIBSTATGRAB, [$collect_libstatgrab], [Wether or not to use statgrab library]) AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes") +AM_CONDITIONAL(BUILD_WITH_LIBDEVSTAT, test "x$with_libdevstat" = "xyes") +AM_CONDITIONAL(BUILD_WITH_LIBKVM, test "x$with_libkvm" = "xyes") AC_ARG_WITH(lm-sensors, [AS_HELP_STRING([--with-lm-sensors@<:@=PREFIX@:>@], [Path to lm_sensors.])], [ diff --git a/src/Makefile.am b/src/Makefile.am index bd0f080f..b281232c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -48,6 +48,17 @@ if BUILD_WITH_LIBDEVINFO collectd_LDFLAGS += -ldevinfo endif +if BUILD_WITH_LIBSTATGRAB +if BUILD_WITH_LIBKVM +collectd_LDFLAGS += -lkvm +endif +if BUILD_WITH_LIBDEVSTAT +collectd_LDFLAGS += -ldevstat +endif +collectd_LDFLAGS += -lstatgrab +endif + + collectd_LDADD = $(LIBLTDL) libconfig/libconfig.la "-dlopen" self collectd_DEPENDENCIES = $(LIBLTDL) libconfig/libconfig.la @@ -161,20 +172,38 @@ load_la_SOURCES = load.c load_la_LDFLAGS = -module -avoid-version collectd_LDADD += "-dlopen" load.la collectd_DEPENDENCIES += load.la +if BUILD_WITH_LIBSTATGRAB +if BUILD_WITH_LIBKVM +load_la_LDFLAGS += -lkvm +endif +if BUILD_WITH_LIBDEVSTAT +load_la_LDFLAGS += -ldevstat +endif +load_la_LDFLAGS += -lstatgrab +endif endif if BUILD_MODULE_MEMORY pkglib_LTLIBRARIES += memory.la memory_la_SOURCES = memory.c memory_la_LDFLAGS = -module -avoid-version +collectd_LDADD += "-dlopen" memory.la +collectd_DEPENDENCIES += memory.la if BUILD_WITH_LIBKSTAT memory_la_LDFLAGS += -lkstat endif if BUILD_WITH_LIBDEVINFO memory_la_LDFLAGS += -ldevinfo endif -collectd_LDADD += "-dlopen" memory.la -collectd_DEPENDENCIES += memory.la +if BUILD_WITH_LIBSTATGRAB +if BUILD_WITH_LIBKVM +memory_la_LDFLAGS += -lkvm +endif +if BUILD_WITH_LIBDEVSTAT +memory_la_LDFLAGS += -ldevstat +endif +memory_la_LDFLAGS += -lstatgrab +endif endif if BUILD_MODULE_MYSQL @@ -237,14 +266,23 @@ if BUILD_MODULE_SWAP pkglib_LTLIBRARIES += swap.la swap_la_SOURCES = swap.c swap_la_LDFLAGS = -module -avoid-version +collectd_LDADD += "-dlopen" swap.la +collectd_DEPENDENCIES += swap.la if BUILD_WITH_LIBKSTAT swap_la_LDFLAGS += -lkstat endif if BUILD_WITH_LIBDEVINFO swap_la_LDFLAGS += -ldevinfo endif -collectd_LDADD += "-dlopen" swap.la -collectd_DEPENDENCIES += swap.la +if BUILD_WITH_LIBSTATGRAB +if BUILD_WITH_LIBKVM +swap_la_LDFLAGS += -lkvm +endif +if BUILD_WITH_LIBDEVSTAT +swap_la_LDFLAGS += -ldevstat +endif +swap_la_LDFLAGS += -lstatgrab +endif endif if BUILD_MODULE_TAPE @@ -265,14 +303,23 @@ if BUILD_MODULE_TRAFFIC pkglib_LTLIBRARIES += traffic.la traffic_la_SOURCES = traffic.c traffic_la_LDFLAGS = -module -avoid-version +collectd_LDADD += "-dlopen" traffic.la +collectd_DEPENDENCIES += traffic.la if BUILD_WITH_LIBKSTAT traffic_la_LDFLAGS += -lkstat endif if BUILD_WITH_LIBDEVINFO traffic_la_LDFLAGS += -ldevinfo endif -collectd_LDADD += "-dlopen" traffic.la -collectd_DEPENDENCIES += traffic.la +if BUILD_WITH_LIBSTATGRAB +if BUILD_WITH_LIBKVM +traffic_la_LDFLAGS += -lkvm +endif +if BUILD_WITH_LIBDEVSTAT +traffic_la_LDFLAGS += -ldevstat +endif +traffic_la_LDFLAGS += -lstatgrab +endif endif if BUILD_MODULE_USERS -- 2.30.2