From 3bca573d4996d8519d75f64f2154e88a107f42a6 Mon Sep 17 00:00:00 2001 From: Emmanuel Bouthenot Date: Sun, 6 Nov 2005 11:38:07 +0000 Subject: [PATCH] auto detect perl multiplicity at compile time --- configure.in | 10 +--- src/plugins/scripts/perl/weechat-perl.c | 46 ++++++++++--------- weechat/configure.in | 10 +--- .../src/plugins/scripts/perl/weechat-perl.c | 46 ++++++++++--------- 4 files changed, 50 insertions(+), 62 deletions(-) diff --git a/configure.in b/configure.in index 2c76670d1..a6697e0fe 100644 --- a/configure.in +++ b/configure.in @@ -84,7 +84,6 @@ AH_VERBATIM([WEECHAT_LIBDIR], [#undef WEECHAT_LIBDIR]) AH_VERBATIM([WEECHAT_SHAREDIR], [#undef WEECHAT_SHAREDIR]) AH_VERBATIM([PLUGINS], [#undef PLUGINS]) AH_VERBATIM([PLUGIN_PERL], [#undef PLUGIN_PERL]) -AH_VERBATIM([PERL_NOTHREAD], [#undef PERL_NOTHREAD]) AH_VERBATIM([PLUGIN_PYTHON], [#undef PLUGIN_PYTHON]) AH_VERBATIM([PLUGIN_RUBY], [#undef PLUGIN_RUBY]) AH_VERBATIM([HAVE_GNUTLS], [#undef HAVE_GNUTLS]) @@ -98,7 +97,6 @@ AC_ARG_ENABLE(gtk, [ --enable-gtk Turn on Gtk+ interface ( AC_ARG_ENABLE(qt, [ --enable-qt Turn on Qt interface (default=no Qt)],enable_qt=$enableval,enable_qt=no) AC_ARG_ENABLE(plugins, [ --disable-plugins Turn off plugins support (default=plugins enabled)],enable_plugins=$enableval,enable_plugins=yes) AC_ARG_ENABLE(perl, [ --enable-perl Turn on Perl script plugin (default=no Perl plugin)],enable_perl=$enableval,enable_perl=no) -AC_ARG_ENABLE(perl_nothread, [ --enable-perl-nothread Turn on Perl script plugin with Perl compiled without threads support (like some *bsd)],enable_perl_nothread=$enableval,enable_perl_nothread=no) AC_ARG_ENABLE(python, [ --enable-python Turn on Python script plugin (default=no Python plugin)],enable_python=$enableval,enable_python=no) AC_ARG_ENABLE(ruby, [ --enable-ruby Turn on Ruby script plugin (default=no Ruby script)],enable_ruby=$enableval,enable_ruby=no) AC_ARG_ENABLE(gnutls, [ --disable-gnutls Turn off gnutls support (default=compiled if found)],enable_gnutls=$enableval,enable_gnutls=yes) @@ -109,7 +107,7 @@ AM_CONDITIONAL(GUI_WXWIDGETS, test "$enable_wxwidgets" = "yes") AM_CONDITIONAL(GUI_GTK, test "$enable_gtk" = "yes") AM_CONDITIONAL(GUI_QT, test "$enable_qt" = "yes") AM_CONDITIONAL(PLUGINS, test "$enable_plugins" = "yes") -AM_CONDITIONAL(PLUGIN_PERL, test "$enable_perl" = "yes" -o "$enable_perl_nothread" = "yes") +AM_CONDITIONAL(PLUGIN_PERL, test "$enable_perl" = "yes") AM_CONDITIONAL(PLUGIN_PYTHON, test "$enable_python" = "yes") AM_CONDITIONAL(PLUGIN_RUBY, test "$enable_ruby" = "yes") AM_CONDITIONAL(HAVE_GNUTLS, test "$enable_gnutls" = "yes") @@ -177,11 +175,6 @@ fi PLUGINS_LIBS= -if test "x$enable_perl_nothread" = "xyes" ; then - enable_perl="yes" - AC_DEFINE(PERL_NOTHREAD) -fi - if test "x$enable_perl" = "xyes" ; then enable_plugins="yes" @@ -440,7 +433,6 @@ echo "Interfaces.................................... :$listgui" echo "Build with GNUtls support..................... : $enable_gnutls" echo "Build with Plugin support..................... : $enable_plugins" echo " Perl plugin..................... : $enable_perl" -echo " Perl plugin (without threads)... : $enable_perl_nothread" echo " Python plugin................... : $enable_python" echo " Ruby plugin..................... : $enable_ruby" echo "Compile with debug info....................... : $msg_debug_compiler" diff --git a/src/plugins/scripts/perl/weechat-perl.c b/src/plugins/scripts/perl/weechat-perl.c index 26316a04d..48cc11bf8 100644 --- a/src/plugins/scripts/perl/weechat-perl.c +++ b/src/plugins/scripts/perl/weechat-perl.c @@ -28,10 +28,6 @@ #include "../../weechat-plugin.h" #include "../weechat-script.h" -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - char plugin_name[] = "Perl"; char plugin_version[] = "0.1"; char plugin_description[] = "Perl scripts support"; @@ -44,7 +40,11 @@ char *perl_current_script_filename = NULL; extern void boot_DynaLoader (pTHX_ CV* cv); -#ifdef PERL_NOTHREAD +#ifdef NO_PERL_MULTIPLICITY +#undef MULTIPLICITY +#endif + +#ifndef MULTIPLICITY #define PKG_NAME_PREFIX "WeechatPerlPackage" static PerlInterpreter *main_perl = NULL; int packnum = 0; @@ -52,7 +52,7 @@ int packnum = 0; char *weechat_perl_code = { -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY "package WeechatPerlScriptLoader;" #endif "$weechat_perl_load_eval_file_error = \"\";" @@ -67,7 +67,7 @@ char *weechat_perl_code = "}" "sub weechat_perl_load_eval_file" "{" -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY " my ($filename, $package) = @_;" #else " my $filename = shift;" @@ -77,7 +77,7 @@ char *weechat_perl_code = " {" " return 1;" " }" -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY " my $eval = qq{package $package; $content;};" #else " my $eval = $content;" @@ -112,7 +112,7 @@ weechat_perl_exec (t_weechat_plugin *plugin, int return_code; SV *sv; -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY int size = strlen(script->interpreter) + strlen(function) + 3; func = (char *) malloc ( size * sizeof(char)); if (func == NULL) @@ -161,7 +161,7 @@ weechat_perl_exec (t_weechat_plugin *plugin, FREETMPS; LEAVE; -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY free(func); #endif @@ -840,7 +840,7 @@ weechat_perl_load (t_weechat_plugin *plugin, char *filename) t_plugin_script tempscript; int eval; -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY char pkgname[64]; #else PerlInterpreter *perl_current_interpreter; @@ -850,7 +850,7 @@ weechat_perl_load (t_weechat_plugin *plugin, char *filename) plugin->printf_server (plugin, "Loading Perl script \"%s\"", filename); perl_current_script = NULL; -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY snprintf(pkgname, sizeof(pkgname), "%s%d", PKG_NAME_PREFIX, packnum); packnum++; tempscript.interpreter = "WeechatPerlScriptLoader"; @@ -883,7 +883,7 @@ weechat_perl_load (t_weechat_plugin *plugin, char *filename) filename); plugin->printf_server (plugin, "Perl error: %s", -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY SvPV(perl_get_sv("WeechatPerlScriptLoader::weechat_perl_load_eval_file_error", FALSE), len)); #else SvPV(perl_get_sv("weechat_perl_load_eval_file_error", FALSE), len)); @@ -900,7 +900,7 @@ weechat_perl_load (t_weechat_plugin *plugin, char *filename) "Perl error: unknown error while loading file \"%s\"", filename); } -#ifndef PERL_NOTHREAD +#ifdef MULTIPLICITY perl_destruct (perl_current_interpreter); perl_free (perl_current_interpreter); #endif @@ -917,14 +917,14 @@ weechat_perl_load (t_weechat_plugin *plugin, char *filename) "Perl error: function \"register\" not found " "in file \"%s\"", filename); -#ifndef PERL_NOTHREAD +#ifdef MULTIPLICITY perl_destruct (perl_current_interpreter); perl_free (perl_current_interpreter); #endif return 0; } -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY perl_current_script->interpreter = strdup(pkgname); #else perl_current_script->interpreter = (PerlInterpreter *) perl_current_interpreter; @@ -944,7 +944,7 @@ weechat_perl_unload (t_weechat_plugin *plugin, t_plugin_script *script) "Unloading Perl script \"%s\"", script->name); -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY eval_pv(script->interpreter, TRUE); #else PERL_SET_CONTEXT (script->interpreter); @@ -953,7 +953,7 @@ weechat_perl_unload (t_weechat_plugin *plugin, t_plugin_script *script) if (script->shutdown_func[0]) weechat_perl_exec (plugin, script, script->shutdown_func, "", ""); -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY if (script->interpreter) free (script->interpreter); #else @@ -1161,10 +1161,12 @@ int weechat_plugin_init (t_weechat_plugin *plugin) { perl_plugin = plugin; - - plugin->printf_server (plugin, "Loading Perl module \"weechat\""); -#ifdef PERL_NOTHREAD +#ifdef MULTIPLICITY + plugin->printf_server (plugin, "Loading Perl module \"weechat\""); +#else + plugin->printf_server (plugin, "Loading Perl module \"weechat\" (without multiplicity)"); + char *perl_args[] = { "", "-e", "0" }; main_perl = perl_alloc (); @@ -1207,7 +1209,7 @@ weechat_plugin_end (t_weechat_plugin *plugin) /* unload all scripts */ weechat_perl_unload_all (plugin); -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY /* free perl intepreter */ if (main_perl) { diff --git a/weechat/configure.in b/weechat/configure.in index 2c76670d1..a6697e0fe 100644 --- a/weechat/configure.in +++ b/weechat/configure.in @@ -84,7 +84,6 @@ AH_VERBATIM([WEECHAT_LIBDIR], [#undef WEECHAT_LIBDIR]) AH_VERBATIM([WEECHAT_SHAREDIR], [#undef WEECHAT_SHAREDIR]) AH_VERBATIM([PLUGINS], [#undef PLUGINS]) AH_VERBATIM([PLUGIN_PERL], [#undef PLUGIN_PERL]) -AH_VERBATIM([PERL_NOTHREAD], [#undef PERL_NOTHREAD]) AH_VERBATIM([PLUGIN_PYTHON], [#undef PLUGIN_PYTHON]) AH_VERBATIM([PLUGIN_RUBY], [#undef PLUGIN_RUBY]) AH_VERBATIM([HAVE_GNUTLS], [#undef HAVE_GNUTLS]) @@ -98,7 +97,6 @@ AC_ARG_ENABLE(gtk, [ --enable-gtk Turn on Gtk+ interface ( AC_ARG_ENABLE(qt, [ --enable-qt Turn on Qt interface (default=no Qt)],enable_qt=$enableval,enable_qt=no) AC_ARG_ENABLE(plugins, [ --disable-plugins Turn off plugins support (default=plugins enabled)],enable_plugins=$enableval,enable_plugins=yes) AC_ARG_ENABLE(perl, [ --enable-perl Turn on Perl script plugin (default=no Perl plugin)],enable_perl=$enableval,enable_perl=no) -AC_ARG_ENABLE(perl_nothread, [ --enable-perl-nothread Turn on Perl script plugin with Perl compiled without threads support (like some *bsd)],enable_perl_nothread=$enableval,enable_perl_nothread=no) AC_ARG_ENABLE(python, [ --enable-python Turn on Python script plugin (default=no Python plugin)],enable_python=$enableval,enable_python=no) AC_ARG_ENABLE(ruby, [ --enable-ruby Turn on Ruby script plugin (default=no Ruby script)],enable_ruby=$enableval,enable_ruby=no) AC_ARG_ENABLE(gnutls, [ --disable-gnutls Turn off gnutls support (default=compiled if found)],enable_gnutls=$enableval,enable_gnutls=yes) @@ -109,7 +107,7 @@ AM_CONDITIONAL(GUI_WXWIDGETS, test "$enable_wxwidgets" = "yes") AM_CONDITIONAL(GUI_GTK, test "$enable_gtk" = "yes") AM_CONDITIONAL(GUI_QT, test "$enable_qt" = "yes") AM_CONDITIONAL(PLUGINS, test "$enable_plugins" = "yes") -AM_CONDITIONAL(PLUGIN_PERL, test "$enable_perl" = "yes" -o "$enable_perl_nothread" = "yes") +AM_CONDITIONAL(PLUGIN_PERL, test "$enable_perl" = "yes") AM_CONDITIONAL(PLUGIN_PYTHON, test "$enable_python" = "yes") AM_CONDITIONAL(PLUGIN_RUBY, test "$enable_ruby" = "yes") AM_CONDITIONAL(HAVE_GNUTLS, test "$enable_gnutls" = "yes") @@ -177,11 +175,6 @@ fi PLUGINS_LIBS= -if test "x$enable_perl_nothread" = "xyes" ; then - enable_perl="yes" - AC_DEFINE(PERL_NOTHREAD) -fi - if test "x$enable_perl" = "xyes" ; then enable_plugins="yes" @@ -440,7 +433,6 @@ echo "Interfaces.................................... :$listgui" echo "Build with GNUtls support..................... : $enable_gnutls" echo "Build with Plugin support..................... : $enable_plugins" echo " Perl plugin..................... : $enable_perl" -echo " Perl plugin (without threads)... : $enable_perl_nothread" echo " Python plugin................... : $enable_python" echo " Ruby plugin..................... : $enable_ruby" echo "Compile with debug info....................... : $msg_debug_compiler" diff --git a/weechat/src/plugins/scripts/perl/weechat-perl.c b/weechat/src/plugins/scripts/perl/weechat-perl.c index 26316a04d..48cc11bf8 100644 --- a/weechat/src/plugins/scripts/perl/weechat-perl.c +++ b/weechat/src/plugins/scripts/perl/weechat-perl.c @@ -28,10 +28,6 @@ #include "../../weechat-plugin.h" #include "../weechat-script.h" -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - char plugin_name[] = "Perl"; char plugin_version[] = "0.1"; char plugin_description[] = "Perl scripts support"; @@ -44,7 +40,11 @@ char *perl_current_script_filename = NULL; extern void boot_DynaLoader (pTHX_ CV* cv); -#ifdef PERL_NOTHREAD +#ifdef NO_PERL_MULTIPLICITY +#undef MULTIPLICITY +#endif + +#ifndef MULTIPLICITY #define PKG_NAME_PREFIX "WeechatPerlPackage" static PerlInterpreter *main_perl = NULL; int packnum = 0; @@ -52,7 +52,7 @@ int packnum = 0; char *weechat_perl_code = { -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY "package WeechatPerlScriptLoader;" #endif "$weechat_perl_load_eval_file_error = \"\";" @@ -67,7 +67,7 @@ char *weechat_perl_code = "}" "sub weechat_perl_load_eval_file" "{" -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY " my ($filename, $package) = @_;" #else " my $filename = shift;" @@ -77,7 +77,7 @@ char *weechat_perl_code = " {" " return 1;" " }" -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY " my $eval = qq{package $package; $content;};" #else " my $eval = $content;" @@ -112,7 +112,7 @@ weechat_perl_exec (t_weechat_plugin *plugin, int return_code; SV *sv; -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY int size = strlen(script->interpreter) + strlen(function) + 3; func = (char *) malloc ( size * sizeof(char)); if (func == NULL) @@ -161,7 +161,7 @@ weechat_perl_exec (t_weechat_plugin *plugin, FREETMPS; LEAVE; -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY free(func); #endif @@ -840,7 +840,7 @@ weechat_perl_load (t_weechat_plugin *plugin, char *filename) t_plugin_script tempscript; int eval; -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY char pkgname[64]; #else PerlInterpreter *perl_current_interpreter; @@ -850,7 +850,7 @@ weechat_perl_load (t_weechat_plugin *plugin, char *filename) plugin->printf_server (plugin, "Loading Perl script \"%s\"", filename); perl_current_script = NULL; -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY snprintf(pkgname, sizeof(pkgname), "%s%d", PKG_NAME_PREFIX, packnum); packnum++; tempscript.interpreter = "WeechatPerlScriptLoader"; @@ -883,7 +883,7 @@ weechat_perl_load (t_weechat_plugin *plugin, char *filename) filename); plugin->printf_server (plugin, "Perl error: %s", -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY SvPV(perl_get_sv("WeechatPerlScriptLoader::weechat_perl_load_eval_file_error", FALSE), len)); #else SvPV(perl_get_sv("weechat_perl_load_eval_file_error", FALSE), len)); @@ -900,7 +900,7 @@ weechat_perl_load (t_weechat_plugin *plugin, char *filename) "Perl error: unknown error while loading file \"%s\"", filename); } -#ifndef PERL_NOTHREAD +#ifdef MULTIPLICITY perl_destruct (perl_current_interpreter); perl_free (perl_current_interpreter); #endif @@ -917,14 +917,14 @@ weechat_perl_load (t_weechat_plugin *plugin, char *filename) "Perl error: function \"register\" not found " "in file \"%s\"", filename); -#ifndef PERL_NOTHREAD +#ifdef MULTIPLICITY perl_destruct (perl_current_interpreter); perl_free (perl_current_interpreter); #endif return 0; } -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY perl_current_script->interpreter = strdup(pkgname); #else perl_current_script->interpreter = (PerlInterpreter *) perl_current_interpreter; @@ -944,7 +944,7 @@ weechat_perl_unload (t_weechat_plugin *plugin, t_plugin_script *script) "Unloading Perl script \"%s\"", script->name); -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY eval_pv(script->interpreter, TRUE); #else PERL_SET_CONTEXT (script->interpreter); @@ -953,7 +953,7 @@ weechat_perl_unload (t_weechat_plugin *plugin, t_plugin_script *script) if (script->shutdown_func[0]) weechat_perl_exec (plugin, script, script->shutdown_func, "", ""); -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY if (script->interpreter) free (script->interpreter); #else @@ -1161,10 +1161,12 @@ int weechat_plugin_init (t_weechat_plugin *plugin) { perl_plugin = plugin; - - plugin->printf_server (plugin, "Loading Perl module \"weechat\""); -#ifdef PERL_NOTHREAD +#ifdef MULTIPLICITY + plugin->printf_server (plugin, "Loading Perl module \"weechat\""); +#else + plugin->printf_server (plugin, "Loading Perl module \"weechat\" (without multiplicity)"); + char *perl_args[] = { "", "-e", "0" }; main_perl = perl_alloc (); @@ -1207,7 +1209,7 @@ weechat_plugin_end (t_weechat_plugin *plugin) /* unload all scripts */ weechat_perl_unload_all (plugin); -#ifdef PERL_NOTHREAD +#ifndef MULTIPLICITY /* free perl intepreter */ if (main_perl) {