[collectd] [PATCH] Link against liboconfig statically or use external shared library.

Sebastian Harl sh<span style="display: none;">.trailing-username</span>(a)<span style="display: none;">leading-domain.</span>tokkee.org
Sun Apr 22 15:48:20 CEST 2007


There is no point in linking against liboconfig dynamically if it is only used
in one place.

Signed-off-by: Sebastian Harl <sh.trailing-username(a)leading-domain.tokkee.org>
---
 configure.in               |   48 ++++++++++++++++++++++++++++++++++++++++++++
 src/Makefile.am            |   15 +++++++++++--
 src/liboconfig/Makefile.am |    5 +--
 3 files changed, 62 insertions(+), 6 deletions(-)

diff --git a/configure.in b/configure.in
index 2cb067b..74d1543 100644
--- a/configure.in
+++ b/configure.in
@@ -984,6 +984,53 @@ AC_DEFINE_UNQUOTED(COLLECT_LIBMYSQL, [$collect_libmysql],
 	[Wether or not to use mysql library])
 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
 
+with_own_liboconfig="no"
+liboconfig_LDFLAGS="$LDFLAGS"
+liboconfig_CPPFLAGS="$CPPFLAGS"
+AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
+[
+	if test "x$withval" != "xno" && test "x$withval" != "xyes"
+	then
+		if test -d "$withval/lib"
+		then
+			liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
+		fi
+		if test -d "$withval/include"
+		then
+			liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
+		fi
+	fi
+	if test "x$withval" = "xno"
+	then
+		AC_MSG_ERROR("liboconfig is required")
+	fi
+],
+[
+	with_liboconfig="yes"
+])
+
+save_LDFLAGS="$LDFLAGS"
+save_CPPFLAGS="$CPPFLAGS"
+LDFLAGS="$liboconfig_LDFLAGS"
+CPPFLAGS="$liboconfig_CPPFLAGS"
+AC_CHECK_LIB(oconfig, oconfig_parse_fh,
+[
+	with_liboconfig="yes"
+	with_own_liboconfig="no"
+],
+[
+	with_liboconfig="yes"
+	with_own_liboconfig="yes"
+	LDFLAGS="$save_LDFLAGS"
+	CPPFLAGS="$save_CPPFLAGS"
+])
+
+AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
+if test "x$with_own_liboconfig" = "xyes"
+then
+	with_liboconfig="yes (shipped version)"
+fi
+
 #with_liboping="yes"
 with_own_liboping="no"
 liboping_LDFLAGS="$LDFLAGS"
@@ -1326,6 +1373,7 @@ Configuration:
     libiptc . . . . . . $with_libiptc
     libkstat  . . . . . $with_kstat
     libmysql  . . . . . $with_libmysql
+    liboconfig  . . . . $with_liboconfig
     liboping  . . . . . $with_liboping
     libpcap . . . . . . $with_libpcap
     libperl . . . . . . $with_libperl
diff --git a/src/Makefile.am b/src/Makefile.am
index 72d67b3..2c356ad 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,7 @@
-SUBDIRS = liboconfig
+SUBDIRS =
+if BUILD_WITH_OWN_LIBOCONFIG
+SUBDIRS += liboconfig
+endif
 if BUILD_WITH_OWN_LIBOPING
 SUBDIRS += liboping
 endif
@@ -59,8 +62,14 @@ collectd_LDFLAGS += -lstatgrab
 endif
 
 
-collectd_LDADD = $(LIBLTDL) liboconfig/liboconfig.la "-dlopen" self
-collectd_DEPENDENCIES = $(LIBLTDL) liboconfig/liboconfig.la
+collectd_LDADD =
+collectd_DEPENDENCIES =
+if BUILD_WITH_OWN_LIBOCONFIG
+collectd_LDADD += $(LIBLTDL) liboconfig/liboconfig.la
+collectd_DEPENDENCIES += $(LIBLTDL) liboconfig/liboconfig.la
+else
+collectd_LDFLAGS += -loconfig
+endif
 
 collectd_nagios_SOURCES = collectd-nagios.c
 collectd_nagios_LDFLAGS =
diff --git a/src/liboconfig/Makefile.am b/src/liboconfig/Makefile.am
index d21de47..f3e7657 100644
--- a/src/liboconfig/Makefile.am
+++ b/src/liboconfig/Makefile.am
@@ -4,8 +4,7 @@ BUILT_SOURCES = parser.h
 CLEANFILES = parser.[ch] scanner.c
 AM_YFLAGS = -d
 
-include_HEADERS = oconfig.h
-lib_LTLIBRARIES = liboconfig.la
+noinst_LTLIBRARIES = liboconfig.la
 
-liboconfig_la_LDFLAGS = -version-info 0:0:0 $(LEXLIB)
+liboconfig_la_LDFLAGS = -avoid-version $(LEXLIB)
 liboconfig_la_SOURCES = oconfig.c oconfig.h aux_types.h scanner.l parser.y
-- 
1.4.4.4

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20070422/240eb86e/attachment.pgp


More information about the collectd mailing list