From be9269dfc2132e53d7a777877f4da6af993eba22 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sun, 17 Nov 2013 20:51:10 +0100 Subject: [PATCH] aspell: display aspell/enchant version on signal "debug_libs" --- cmake/FindAspell.cmake | 7 +++- config.h.cmake | 1 + configure.ac | 64 +++++++++++++++++------------ src/plugins/aspell/weechat-aspell.c | 35 ++++++++++++++++ 4 files changed, 80 insertions(+), 27 deletions(-) diff --git a/cmake/FindAspell.cmake b/cmake/FindAspell.cmake index ffc21040a..6551ed843 100644 --- a/cmake/FindAspell.cmake +++ b/cmake/FindAspell.cmake @@ -42,7 +42,12 @@ FIND_LIBRARY(ASPELL_LIBRARY ) IF (ASPELL_INCLUDE_PATH AND ASPELL_LIBRARY) - SET(ASPELL_FOUND TRUE) + SET(CMAKE_REQUIRED_INCLUDES ${ASPELL_INCLUDE_PATH}) + SET(CMAKE_REQUIRED_LIBRARIES ${ASPELL_LIBRARY}) + CHECK_SYMBOL_EXISTS(aspell_version_string "aspell.h" HAVE_ASPELL_VERSION_STRING) + SET(CMAKE_REQUIRED_INCLUDES) + SET(CMAKE_REQUIRED_LIBRARIES) + SET(ASPELL_FOUND TRUE) ENDIF (ASPELL_INCLUDE_PATH AND ASPELL_LIBRARY) MARK_AS_ADVANCED( diff --git a/config.h.cmake b/config.h.cmake index 6e1fd067f..a7cdd0a81 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -6,6 +6,7 @@ #cmakedefine ICONV_2ARG_IS_CONST 1 #cmakedefine HAVE_MALLINFO #cmakedefine HAVE_EAT_NEWLINE_GLITCH +#cmakedefine HAVE_ASPELL_VERSION_STRING #define PACKAGE_VERSION "@VERSION@" #define PACKAGE "@PROJECT_NAME@" #define PACKAGE_NAME "@PROJECT_NAME@" diff --git a/configure.ac b/configure.ac index 9befa8654..6e6d62502 100644 --- a/configure.ac +++ b/configure.ac @@ -94,32 +94,33 @@ AC_CHECK_FUNCS([mallinfo]) # Variables in config.h -AH_VERBATIM([PREFIX], [#undef PREFIX]) -AH_VERBATIM([WEECHAT_LIBDIR], [#undef WEECHAT_LIBDIR]) -AH_VERBATIM([WEECHAT_SHAREDIR], [#undef WEECHAT_SHAREDIR]) -AH_VERBATIM([HAVE_GNUTLS], [#undef HAVE_GNUTLS]) -AH_VERBATIM([HAVE_FLOCK], [#undef HAVE_FLOCK]) +AH_VERBATIM([PREFIX], [#undef PREFIX]) +AH_VERBATIM([WEECHAT_LIBDIR], [#undef WEECHAT_LIBDIR]) +AH_VERBATIM([WEECHAT_SHAREDIR], [#undef WEECHAT_SHAREDIR]) +AH_VERBATIM([HAVE_GNUTLS], [#undef HAVE_GNUTLS]) +AH_VERBATIM([HAVE_FLOCK], [#undef HAVE_FLOCK]) AH_VERBATIM([HAVE_EAT_NEWLINE_GLITCH], [#undef HAVE_EAT_NEWLINE_GLITCH]) -AH_VERBATIM([PLUGIN_ALIAS], [#undef PLUGIN_ALIAS]) -AH_VERBATIM([PLUGIN_ASPELL], [#undef PLUGIN_ASPELL]) -AH_VERBATIM([PLUGIN_CHARSET], [#undef PLUGIN_CHARSET]) -AH_VERBATIM([PLUGIN_FIFO], [#undef PLUGIN_FIFO]) -AH_VERBATIM([PLUGIN_IRC], [#undef PLUGIN_IRC]) -AH_VERBATIM([PLUGIN_LOGGER], [#undef PLUGIN_LOGGER]) -AH_VERBATIM([PLUGIN_RELAY], [#undef PLUGIN_RELAY]) -AH_VERBATIM([PLUGIN_RMODIFIER], [#undef PLUGIN_RMODIFIER]) -AH_VERBATIM([PLUGIN_SCRIPT], [#undef PLUGIN_SCRIPT]) -AH_VERBATIM([PLUGIN_PERL], [#undef PLUGIN_PERL]) -AH_VERBATIM([PLUGIN_PYTHON], [#undef PLUGIN_PYTHON]) -AH_VERBATIM([PLUGIN_RUBY], [#undef PLUGIN_RUBY]) -AH_VERBATIM([PLUGIN_LUA], [#undef PLUGIN_LUA]) -AH_VERBATIM([PLUGIN_TCL], [#undef PLUGIN_TCL]) -AH_VERBATIM([PLUGIN_GUILE], [#undef PLUGIN_GUILE]) -AH_VERBATIM([PLUGIN_XFER], [#undef PLUGIN_XFER]) -AH_VERBATIM([MAN], [#undef MAN]) -AH_VERBATIM([DOC], [#undef DOC]) -AH_VERBATIM([WEECHAT_HOME], [#define WEECHAT_HOME "~/.weechat"]) -AH_VERBATIM([CA_FILE], [#define CA_FILE "/etc/ssl/certs/ca-certificates.crt"]) +AH_VERBATIM([HAVE_ASPELL_VERSION_STRING], [#undef HAVE_ASPELL_VERSION_STRING]) +AH_VERBATIM([PLUGIN_ALIAS], [#undef PLUGIN_ALIAS]) +AH_VERBATIM([PLUGIN_ASPELL], [#undef PLUGIN_ASPELL]) +AH_VERBATIM([PLUGIN_CHARSET], [#undef PLUGIN_CHARSET]) +AH_VERBATIM([PLUGIN_FIFO], [#undef PLUGIN_FIFO]) +AH_VERBATIM([PLUGIN_IRC], [#undef PLUGIN_IRC]) +AH_VERBATIM([PLUGIN_LOGGER], [#undef PLUGIN_LOGGER]) +AH_VERBATIM([PLUGIN_RELAY], [#undef PLUGIN_RELAY]) +AH_VERBATIM([PLUGIN_RMODIFIER], [#undef PLUGIN_RMODIFIER]) +AH_VERBATIM([PLUGIN_SCRIPT], [#undef PLUGIN_SCRIPT]) +AH_VERBATIM([PLUGIN_PERL], [#undef PLUGIN_PERL]) +AH_VERBATIM([PLUGIN_PYTHON], [#undef PLUGIN_PYTHON]) +AH_VERBATIM([PLUGIN_RUBY], [#undef PLUGIN_RUBY]) +AH_VERBATIM([PLUGIN_LUA], [#undef PLUGIN_LUA]) +AH_VERBATIM([PLUGIN_TCL], [#undef PLUGIN_TCL]) +AH_VERBATIM([PLUGIN_GUILE], [#undef PLUGIN_GUILE]) +AH_VERBATIM([PLUGIN_XFER], [#undef PLUGIN_XFER]) +AH_VERBATIM([MAN], [#undef MAN]) +AH_VERBATIM([DOC], [#undef DOC]) +AH_VERBATIM([WEECHAT_HOME], [#define WEECHAT_HOME "~/.weechat"]) +AH_VERBATIM([CA_FILE], [#define CA_FILE "/etc/ssl/certs/ca-certificates.crt"]) # Arguments for ./configure @@ -296,7 +297,6 @@ fi if test "x$enable_aspell" = "xyes" ; then ac_found_enchant_lib="no" if test "x$enable_enchant" = "xyes" ; then - #PKG_CHECK_MODULES(ENCHANT, [enchant], [CFLAGS="$CFLAGS -DUSE_ENCHANT"], PKG_CHECK_MODULES(ENCHANT, [enchant], ac_found_enchant_lib="yes", ac_found_enchant_lib="no") fi if test "x$ac_found_enchant_lib" = "xyes" ; then @@ -322,6 +322,18 @@ if test "x$enable_aspell" = "xyes" ; then AC_MSG_RESULT(yes) ASPELL_LFLAGS="$ASPELL_LFLAGS -laspell" ASPELL_LIB_USED="aspell" + ac_save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $ASPELL_LFLAGS" + AC_CACHE_CHECK([for aspell_version_string() support], ac_cv_have_aspell_version_string, [ + AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ #include ]], + [[ const char *version = aspell_version_string(); ]])], + [ ac_have_aspell_version_string="yes" ], + [ ac_have_aspell_version_string="no" ])]) + LDFLAGS="$ac_save_LDFLAGS" + if test "x$ac_have_aspell_version_string" = "xyes"; then + AC_DEFINE(HAVE_ASPELL_VERSION_STRING) + fi fi fi else diff --git a/src/plugins/aspell/weechat-aspell.c b/src/plugins/aspell/weechat-aspell.c index 570a14424..e453ce85b 100644 --- a/src/plugins/aspell/weechat-aspell.c +++ b/src/plugins/aspell/weechat-aspell.c @@ -21,6 +21,10 @@ * along with WeeChat. If not, see . */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -916,6 +920,35 @@ weechat_aspell_buffer_closed_cb (void *data, const char *signal, return WEECHAT_RC_OK; } +/* + * Display infos about external libraries used. + */ + +int +weechat_aspell_debug_libs_cb (void *data, const char *signal, + const char *type_data, void *signal_data) +{ + /* make C compiler happy */ + (void) data; + (void) signal; + (void) type_data; + (void) signal_data; + +#ifdef USE_ENCHANT + weechat_printf (NULL, " %s: enchant v%s", + ASPELL_PLUGIN_NAME, enchant_get_version ()); +#else +#ifdef HAVE_ASPELL_VERSION_STRING + weechat_printf (NULL, " %s: aspell v%s", + ASPELL_PLUGIN_NAME, aspell_version_string ()); +#else + weechat_printf (NULL, " %s: aspell (?)", ASPELL_PLUGIN_NAME); +#endif +#endif /* USE_ENCHANT */ + + return WEECHAT_RC_OK; +} + /* * Initializes aspell plugin. */ @@ -966,6 +999,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) &weechat_aspell_window_switch_cb, NULL); weechat_hook_signal ("buffer_closed", &weechat_aspell_buffer_closed_cb, NULL); + weechat_hook_signal ("debug_libs", + &weechat_aspell_debug_libs_cb, NULL); return WEECHAT_RC_OK; }