From c64b3f3bc82e24fc5685bf7e69e2798e9144a084 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sun, 22 Apr 2007 15:48:20 +0200 Subject: [PATCH] Link against liboconfig statically or use external shared library. There is no point in linking against liboconfig dynamically if it is only used in one place. Signed-off-by: Sebastian Harl --- 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 2cb067b7..74d15432 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 a2302832..bbbd8dc6 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 d21de47d..f3e7657a 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 -- 2.30.2