From 5395a6d43d4cc4a654d64d5bf2b298e7c99401e3 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 8 Jul 2009 14:07:49 +0200 Subject: [PATCH] Build system: Improve detection of the tokyotyrant library. --- configure.in | 102 ++++++++++++++++++++++++++++++++++++++++---------------- src/Makefile.am | 6 +++- 2 files changed, 78 insertions(+), 30 deletions(-) diff --git a/configure.in b/configure.in index ec84d5b1..4ef308e2 100644 --- a/configure.in +++ b/configure.in @@ -1095,35 +1095,6 @@ then fi AM_CONDITIONAL(BUILD_WITH_LIBKVM_OPENFILES, test "x$with_kvm_openfiles" = "xyes") -# --with-libtokyotyrant {{{ -with_libtokyotyrant_cflags="" -with_libtokyotyrant_libs="" -AC_ARG_WITH(libtokyotyrant, [AS_HELP_STRING([--with-libtokyotyrant@<:@=PREFIX@:>@], [Path to libtokyotyrant.])], -[ - if test "x$withval" = "xno" - then - with_libtokyotyrant="no" - else if test "x$withval" = "xyes" - then - with_libtokyotyrant="yes" - fi; fi -], -[ - with_libtokyotyrant="yes" -]) - -if test "x$with_libtokyotyrant" = "xyes" -then - with_libtokyotyrant_cflags="`$PKG_CONFIG --cflags tokyotyrant`" - with_libtokyotyrant_libs="`$PKG_CONFIG --libs tokyotyrant`" - - - BUILD_WITH_LIBTOKYOTYRANT_LIBS="$with_libtokyotyrant_libs" - AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_LIBS) -fi -AM_CONDITIONAL(BUILD_WITH_LIBTOKYOTYRANT, test "x$with_libtokyotyrant" = "xyes") -# }}} - # --with-libcurl {{{ with_curl_config="curl-config" with_curl_cflags="" @@ -2792,6 +2763,79 @@ then fi # }}} +# --with-libtokyotyrant {{{ +with_libtokyotyrant_cppflags="" +with_libtokyotyrant_ldflags="" +with_libtokyotyrant_libs="" +AC_ARG_WITH(libtokyotyrant, [AS_HELP_STRING([--with-libtokyotyrant@<:@=PREFIX@:>@], [Path to libtokyotyrant.])], +[ + if test "x$withval" = "xno" + then + with_libtokyotyrant="no" + else if test "x$withval" = "xyes" + then + with_libtokyotyrant="yes" + else + with_libtokyotyrant_cppflags="-I$withval/include" + with_libtokyotyrant_ldflags="-L$withval/include" + with_libtokyotyrant_libs="-ltokyotyrant" + with_libtokyotyrant="yes" + fi; fi +], +[ + with_libtokyotyrant="yes" +]) + +if test "x$with_libtokyotyrant" = "xyes" +then + if $PKG_CONFIG --exists tokyotyrant + then + with_libtokyotyrant_cppflags="$with_libtokyotyrant_cppflags `$PKG_CONFIG --cflags tokyotyrant`" + with_libtokyotyrant_ldflags="$with_libtokyotyrant_ldflags `pkg-config --libs-only-L tokyotyrant`" + with_libtokyotyrant_libs="$with_libtokyotyrant_libs `pkg-config --libs-only-l tokyotyrant`" + fi +fi + +SAVE_CPPFLAGS="$CPPFLAGS" +SAVE_LDFLAGS="$LDFLAGS" +CPPFLAGS="$CPPFLAGS $with_libtokyotyrant_cppflags" +LDFLAGS="$LDFLAGS $with_libtokyotyrant_ldflags" + +if test "x$with_libtokyotyrant" = "xyes" +then + AC_CHECK_HEADERS(tcrdb.h, + [ + AC_DEFINE(HAVE_TCRDB_H, 1, + [Define to 1 if you have the header file.]) + ], [with_libtokyotyrant="no (tcrdb.h not found)"]) +fi + +if test "x$with_libtokyotyrant" = "xyes" +then + AC_CHECK_LIB(tokyotyrant, tcrdbrnum, + [ + AC_DEFINE(HAVE_LIBTOKYOTYRANT, 1, + [Define to 1 if you have the tokyotyrant library (-ltokyotyrant).]) + ], + [with_libtokyotyrant="no (symbol tcrdbrnum not found)"], + [$with_libtokyotyrant_libs]) +fi + +CPPFLAGS="$SAVE_CPPFLAGS" +LDFLAGS="$SAVE_LDFLAGS" + +if test "x$with_libtokyotyrant" = "xyes" +then + BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS="$with_libtokyotyrant_cppflags" + BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS="$with_libtokyotyrant_ldflags" + BUILD_WITH_LIBTOKYOTYRANT_LIBS="$with_libtokyotyrant_libs" + AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS) + AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS) + AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_LIBS) +fi +AM_CONDITIONAL(BUILD_WITH_LIBTOKYOTYRANT, test "x$with_libtokyotyrant" = "xyes") +# }}} + # --with-libupsclient {{{ with_libupsclient_config="" with_libupsclient_cflags="" diff --git a/src/Makefile.am b/src/Makefile.am index 30b0710c..e6d9073c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -941,8 +941,12 @@ endif if BUILD_PLUGIN_TOKYOTYRANT pkglib_LTLIBRARIES += tokyotyrant.la tokyotyrant_la_SOURCES = tokyotyrant.c -tokyotyrant_la_LDFLAGS = -module -avoid-version +tokyotyrant_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS) +tokyotyrant_la_LDFLAGS = -module -avoid-version $(BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS) tokyotyrant_la_LIBADD = $(BUILD_WITH_LIBTOKYOTYRANT_LIBS) +if BUILD_WITH_LIBSOCKET +tokyotyrant_la_LIBADD += -lsocket +endif collectd_LDADD += "-dlopen" tokyotyrant.la collectd_DEPENDENCIES += tokyotyrant.la endif -- 2.11.0