Skip to content

Commit

Permalink
guile: fix compilation with Guile < 2.0.4 (closes #198)
Browse files Browse the repository at this point in the history
  • Loading branch information
flashcode committed Sep 20, 2014
1 parent 1801e0d commit 6a2bef6
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions ChangeLog.asciidoc
Expand Up @@ -41,6 +41,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
* aspell: fix crash with command "/aspell addword" if no word is given
(closes #164, closes #165)
* irc: fix translation of CTCP PING reply (closes #137)
* guile: fix compilation with Guile < 2.0.4 (closes #198)
* perl: fix detection of Perl >= 5.20 with autotools
* script: fix crash on "/script update" if a script detail is displayed in
buffer (closes #177)
Expand Down
8 changes: 8 additions & 0 deletions cmake/FindGuile.cmake
Expand Up @@ -34,4 +34,12 @@ endif()
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_search_module(GUILE guile-2.0)
if(GUILE_FOUND)
# check if variable "scm_install_gmp_memory_functions" exists
set(CMAKE_REQUIRED_INCLUDES ${GUILE_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${GUILE_LDFLAGS})
check_symbol_exists(scm_install_gmp_memory_functions "libguile.h" HAVE_GUILE_GMP_MEMORY_FUNCTIONS)
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_LIBRARIES)
endif()
endif()
1 change: 1 addition & 0 deletions config.h.cmake
Expand Up @@ -8,6 +8,7 @@
#cmakedefine HAVE_EAT_NEWLINE_GLITCH
#cmakedefine HAVE_ASPELL_VERSION_STRING
#cmakedefine HAVE_ENCHANT_GET_VERSION
#cmakedefine HAVE_GUILE_GMP_MEMORY_FUNCTIONS
#define PACKAGE_VERSION "@VERSION@"
#define PACKAGE "@PROJECT_NAME@"
#define PACKAGE_NAME "@PROJECT_NAME@"
Expand Down
20 changes: 19 additions & 1 deletion configure.ac
Expand Up @@ -103,6 +103,7 @@ AH_VERBATIM([HAVE_FLOCK], [#undef HAVE_FLOCK])
AH_VERBATIM([HAVE_EAT_NEWLINE_GLITCH], [#undef HAVE_EAT_NEWLINE_GLITCH])
AH_VERBATIM([HAVE_ASPELL_VERSION_STRING], [#undef HAVE_ASPELL_VERSION_STRING])
AH_VERBATIM([HAVE_ENCHANT_GET_VERSION], [#undef HAVE_ENCHANT_GET_VERSION])
AH_VERBATIM([HAVE_GUILE_GMP_MEMORY_FUNCTIONS], [#undef HAVE_GUILE_GMP_MEMORY_FUNCTIONS])
AH_VERBATIM([PLUGIN_ALIAS], [#undef PLUGIN_ALIAS])
AH_VERBATIM([PLUGIN_ASPELL], [#undef PLUGIN_ASPELL])
AH_VERBATIM([PLUGIN_CHARSET], [#undef PLUGIN_CHARSET])
Expand Down Expand Up @@ -814,7 +815,24 @@ if test "x$enable_guile" = "xyes" ; then
fi
done

if test "x$guile_found" = "xno" ; then
if test "x$guile_found" = "xyes" ; then
# check if variable "scm_install_gmp_memory_functions" exists
ac_save_CFLAGS="$CFLAGS"
ac_save_LDFLAGS="$LDFLAGS"
CFLAGS="$CFLAGS $GUILE_CFLAGS"
LDFLAGS="$LDFLAGS $GUILE_LFLAGS"
AC_CACHE_CHECK([for variable scm_install_gmp_memory_functions], ac_cv_have_guile_gmp_memory_functions, [
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[ #include <libguile.h>]],
[[ scm_install_gmp_memory_functions = 0; ]])],
[ ac_have_guile_gmp_memory_functions="yes" ],
[ ac_have_guile_gmp_memory_functions="no" ])])
CFLAGS="$ac_save_CFLAGS"
LDFLAGS="$ac_save_LDFLAGS"
if test "x$ac_have_guile_gmp_memory_functions" = "xyes"; then
AC_DEFINE(HAVE_GUILE_GMP_MEMORY_FUNCTIONS)
fi
else
AC_MSG_WARN([
*** Guile >= 2.0 couldn't be found on your system.
*** WeeChat will be built without Guile (scheme) support.])
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/guile/weechat-guile.c
Expand Up @@ -19,6 +19,10 @@
* along with WeeChat. If not, see <http://www.gnu.org/licenses/>.
*/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#undef _

#include <libguile.h>
Expand Down Expand Up @@ -971,12 +975,14 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])

guile_stdout = NULL;

#ifdef HAVE_GUILE_GMP_MEMORY_FUNCTIONS
/*
* prevent guile to use its own gmp allocator, because it can conflict
* with other plugins using GnuTLS like relay, which can crash WeeChat
* on unload (or exit)
*/
scm_install_gmp_memory_functions = 0;
#endif

scm_init_guile ();

Expand Down

0 comments on commit 6a2bef6

Please sign in to comment.