diff --git a/honoka/configure.ac b/honoka/configure.ac index 9e00c1e..eda7514 100644 --- a/honoka/configure.ac +++ b/honoka/configure.ac @@ -67,70 +67,86 @@ AC_SUBST(SCIM_BUILD_SETUP) -AC_CHECK_LIB(crypt, crypt) +# �ʲ����Ԥ����פ����� +AC_CHECK_HEADER([dlfcn.h],[],[AC_MSG_ERROR(dlfcn.h was not found.)]) +AC_CHECK_LIB([dl],[dlopen],[],[AC_MSG_ERROR(libdl was not found.)]) AC_ARG_ENABLE(wnn, -[ --enable-wnn Turn on WnnConversion], -[case "${enableval}" in - yes) wnn=true ;; - no) wnn=false ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-wnn) ;; -esac],[wnn=true]) + [ --enable-wnn Turn on WnnConversion], + [case "${enableval}" in + yes) wnn=true ;; + no) wnn=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-wnn) ;; + esac],[wnn=true]) AM_CONDITIONAL(WNNCONVERSION, [test "x$wnn" = "xtrue"]) if test "x$wnn" = "xtrue"; then -AC_CHECK_LIB(wnn7, jl_yosoku_init,, [AC_MSG_RESULT(libwnn7 not found.)]) -if echo $LIBS | grep -v "wnn7" > /dev/null; then - AC_CHECK_LIB(wnn, jl_yosoku_init,, [AC_MSG_RESULT(libwnn for Wnn7 not found.)]) -fi - -if echo $LIBS | grep "wnn.*" > /dev/null; then - AC_DEFINE([HAVE_LIBWNN7],1,[]) -else - AC_CHECK_LIB(wnn6, jl_optimize_fi,, [AC_MSG_RESULT(libwnn6 not found.)]) - if echo $LIBS | grep -v "wnn6" > /dev/null; then - AC_CHECK_LIB(wnn, jl_optimize_fi,, [AC_MSG_RESULT(libwnn for Wnn6 not found.)]) + BU_LIBS="$LIBS" + AC_CHECK_LIB(crypt, crypt) + AC_CHECK_LIB(wnn7, jl_yosoku_init,[ + WNN_LIBS="-lcrypt -lwnn7" + ], [AC_MSG_RESULT(libwnn7 not found.)]) + if echo $WNN_LIBS | grep -v "wnn7" > /dev/null; then + AC_CHECK_LIB(wnn, jl_yosoku_init,[ + WNN_LIBS="-lcrypt -lwnn" + ], [AC_MSG_RESULT(libwnn for Wnn7 not found.)]) fi - - if echo $LIBS | grep "wnn.*" > /dev/null; then - AC_DEFINE([HAVE_LIBWNN6],1,[]) + + if echo $WNN_LIBS | grep "wnn" > /dev/null; then + AC_DEFINE([HAVE_LIBWNN7],[1],[Wnn7]) else - AC_MSG_RESULT(Wnn6 or Wnn7 library not found.) - WNNCONVERSION="false" + AC_CHECK_LIB(wnn6, jl_optimize_fi,[ + WNN_LIBS="-lcrypt -lwnn6" + ], [AC_MSG_RESULT(libwnn6 not found.)]) + if echo $WNN_LIBS | grep -v "wnn6" > /dev/null; then + AC_CHECK_LIB(wnn, jl_optimize_fi,[ + WNN_LIBS="-lcrypt -lwnn" + ], [AC_MSG_RESULT(libwnn for Wnn6 not found.)]) + fi + + if echo $WNN_LIBS | grep "wnn" > /dev/null; then + AC_DEFINE([HAVE_LIBWNN6],[1],[Wnn6]) + else + AC_MSG_RESULT(Wnn6 or Wnn7 library not found.) + WNNCONVERSION="false" + fi fi -fi -if echo $LIBS | grep "wnn.*" > /dev/null; then - AC_DEFINE([HAVE_LIBWNN],1,[]) -fi + if echo $WNN_LIBS | grep "wnn" > /dev/null; then + AC_DEFINE([HAVE_LIBWNN],[1],[Wnn]) + fi + LIBS="$BU_LIBS" fi AC_SUBST(WNNCONVERSION) AC_ARG_ENABLE(anthy, -[ --enable-anthy Turn on AnthyConversion], -[case "${enableval}" in - yes) anthy=true ;; - no) anthy=false ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-anthy) ;; -esac],[anthy=true]) + [ --enable-anthy Turn on AnthyConversion], + [case "${enableval}" in + yes) anthy=true ;; + no) anthy=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-anthy) ;; + esac],[anthy=true]) AM_CONDITIONAL(ANTHYCONVERSION, [test "x$anthy" = "xtrue"]) if test "x$anthy" = "xtrue"; then -AC_CHECK_HEADER([anthy/anthy.h], [ - LIBS="$LIBS -lanthy -lanthydic" -],[]) -if echo $LIBS | grep "anthy" > /dev/null; then - AC_DEFINE([HAVE_LIBANTHY],[1],[Anthy]) -else - ANTHYCONVERSION="false" -fi + AC_CHECK_HEADER([anthy/anthy.h], [ + ANTHY_LIBS="-lanthy -lanthydic" + ],[]) + if echo $ANTHY_LIBS | grep "anthy" > /dev/null; then + AC_DEFINE([HAVE_LIBANTHY],[1],[Anthy]) + else + ANTHYCONVERSION="false" + fi fi AC_SUBST(ANTHYCONVERSION) -if echo $LIBS | grep -v "wnn" > /dev/null; then - if echo $LIBS | grep -v "anthy" > /dev/null; then - AC_MSG_ERROR(Wnn or Anthy library not found.) - fi -fi +AC_SUBST(WNN_LIBS) +AC_SUBST(ANTHY_LIBS) + +#if echo $LIBS | grep -v "wnn" > /dev/null; then +# if echo $LIBS | grep -v "anthy" > /dev/null; then +# AC_MSG_ERROR(Wnn or Anthy library not found.) +# fi +#fi # Checks for header files. diff --git a/honoka/m4/Makefile b/honoka/m4/Makefile index 4c0e56e..4e43678 100644 --- a/honoka/m4/Makefile +++ b/honoka/m4/Makefile @@ -69,6 +69,7 @@ ANTHYCONVERSION = ANTHYCONVERSION_FALSE = # ANTHYCONVERSION_TRUE = +ANTHY_LIBS = -lanthy -lanthydic AR = ar AUTOCONF = ${SHELL} /home/tamra/ANef/honoka/missing --run autoconf AUTOHEADER = ${SHELL} /home/tamra/ANef/honoka/missing --run autoheader @@ -127,7 +128,7 @@ LIBICONV = LIBINTL = LIBOBJS = -LIBS = -lwnn -lcrypt -lanthy -lanthydic +LIBS = -ldl LIBTOOL = $(SHELL) $(top_builddir)/libtool LIBTOOL_DEPS = ./ltmain.sh LN_S = ln -s @@ -170,6 +171,7 @@ WNNCONVERSION = WNNCONVERSION_FALSE = # WNNCONVERSION_TRUE = +WNN_LIBS = -lcrypt -lwnn XGETTEXT = /usr/bin/xgettext ac_aux_dir = . ac_ct_AR = ar diff --git a/honoka/m4/Makefile.in b/honoka/m4/Makefile.in index 630d312..0bbd9d6 100644 --- a/honoka/m4/Makefile.in +++ b/honoka/m4/Makefile.in @@ -69,6 +69,7 @@ ANTHYCONVERSION = @ANTHYCONVERSION@ ANTHYCONVERSION_FALSE = @ANTHYCONVERSION_FALSE@ ANTHYCONVERSION_TRUE = @ANTHYCONVERSION_TRUE@ +ANTHY_LIBS = @ANTHY_LIBS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -170,6 +171,7 @@ WNNCONVERSION = @WNNCONVERSION@ WNNCONVERSION_FALSE = @WNNCONVERSION_FALSE@ WNNCONVERSION_TRUE = @WNNCONVERSION_TRUE@ +WNN_LIBS = @WNN_LIBS@ XGETTEXT = @XGETTEXT@ ac_aux_dir = @ac_aux_dir@ ac_ct_AR = @ac_ct_AR@ diff --git a/honoka/src/Makefile.am b/honoka/src/Makefile.am index 563adbd..75d2a34 100644 --- a/honoka/src/Makefile.am +++ b/honoka/src/Makefile.am @@ -23,32 +23,23 @@ -DSCIM_ICONDIR=\"@SCIM_ICONDIR@\" \ -DHONOKA_LOCALEDIR=\"$(datadir)/locale\" \ -DHONOKA_DATADIR=\"@SCIM_DATADIR@/honoka\" \ - -DHONOKA_ICON_FILE=\"@SCIM_ICONDIR@/honoka.png\" + -DHONOKA_ICON_FILE=\"@SCIM_ICONDIR@/honoka.png\" \ + -DHONOKA_PLUGINDIR=\"@SCIM_MODULEDIR@/honoka\" noinst_HEADERS = honoka_imengine.h wnnproto.h romkan.h romkan_table.h \ - wnnconversion.h honoka_def.h preeditor.h kanainput.h convertor.h anthyconversion.h \ - honokapluginbase.h - -if WNNCONVERSION -WNNSOURCE = wnnconversion.cpp -endif - -if ANTHYCONVERSION -ANTHYSOURCE = anthyconversion.cpp -endif + wnnconversion.h honoka_def.h kanainput.h anthyconversion.h moduledir = @SCIM_MODULEDIR@/IMEngine module_LTLIBRARIES = honoka.la -honoka_la_SOURCES = honoka_imengine.cpp romkan.cpp convertor.cpp preeditor.cpp \ - kanainput.cpp $(WNNSOURCE) $(ANTHYSOURCE) \ - honokapluginbase.cpp +honoka_la_SOURCES = honoka_imengine.cpp romkan.cpp kanainput.cpp honoka_la_CFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ honoka_la_CXXFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ honoka_la_LDFLAGS = -avoid-version -module -rpath $(moduledir) \ @LIBTOOL_EXPORT_OPTIONS@ @INTLLIBS@ @SCIM_LIBS@ +honoka_la_LIBADD = $(top_builddir)/src/libhonoka_plugin.la if SCIM_BUILD_SETUP @@ -72,4 +63,36 @@ @INTLLIBS@ \ @SCIM_LIBS@ +libhonokaincludedir = $(includedir)/honoka +libhonokainclude_HEADERS = convertor.h preeditor.h honokapluginbase.h + +lib_LTLIBRARIES = libhonoka_plugin.la +libhonoka_plugin_la_SOURCES = convertor.cpp honokapluginbase.cpp preeditor.cpp +libhonoka_plugin_la_CFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ +libhonoka_plugin_la_CXXFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ +libhonoka_plugin_la_LDFLAGS = @LIBTOOL_EXPORT_OPTIONS@ @INTLLIBS@ @SCIM_LIBS@ + + +if WNNCONVERSION +WNN_PLUGIN = plugin-wnn.la +endif + +if ANTHYCONVERSION +ANTHY_PLUGIN = plugin-anthy.la +endif + +plugindir = @SCIM_MODULEDIR@/honoka +plugin_LTLIBRARIES = $(ANTHY_PLUGIN) $(WNN_PLUGIN) + +plugin_anthy_la_SOURCES = anthyconversion.cpp +plugin_anthy_la_CFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ +plugin_anthy_la_CXXFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ +plugin_anthy_la_LDFLAGS = -avoid-version -module -rpath $(plugindir) @LIBTOOL_EXPORT_OPTIONS@ @INTLLIBS@ @SCIM_LIBS@ @ANTHY_LIBS@ +plugin_anthy_la_LIBADD = $(top_builddir)/src/libhonoka_plugin.la + +plugin_wnn_la_SOURCES = wnnconversion.cpp +plugin_wnn_la_CFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ +plugin_wnn_la_CXXFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ +plugin_wnn_la_LDFLAGS = -avoid-version -module -rpath $(plugindir) @LIBTOOL_EXPORT_OPTIONS@ @INTLLIBS@ @SCIM_LIBS@ @WNN_LIBS@ +plugin_wnn_la_LIBADD = $(top_builddir)/src/libhonoka_plugin.la diff --git a/honoka/src/anthyconversion.cpp b/honoka/src/anthyconversion.cpp index 86bae2f..eefc0de 100644 --- a/honoka/src/anthyconversion.cpp +++ b/honoka/src/anthyconversion.cpp @@ -35,6 +35,8 @@ #define bind_textdomain_codeset(domain,codeset) #endif +// �ץ饤�����󲽤Τ��ޤ��ʤ��Ǥ��� +HonokaPluginRegister(AnthyConversion); AnthyConversion::AnthyConversion(ConfigPointer cfg) : Convertor(cfg) diff --git a/honoka/src/honoka_imengine.cpp b/honoka/src/honoka_imengine.cpp index 1e9b995..f10e48f 100644 --- a/honoka/src/honoka_imengine.cpp +++ b/honoka/src/honoka_imengine.cpp @@ -29,6 +29,9 @@ #include #endif +#include +#include + // ��ݲ��Τ��ޤ��ʤ��� #ifdef HAVE_GETTEXT #include @@ -190,16 +193,32 @@ preeditors.push_back(new Romkan(_scim_config)); preeditors.push_back(new KanaInput(_scim_config)); m_preeditor = preeditors.at(0); - + DIR *dir = opendir(HONOKA_PLUGINDIR); + if (dir) { + struct dirent *entry; + while((entry = readdir(dir)) != NULL) { + String d = entry->d_name; + if ((d.substr(0,6) == "plugin") && (d.substr(d.length() - 3,3) == ".so")) { + d = String(HONOKA_PLUGINDIR) + "/" + d; + void* plugin = dlopen(d.c_str(), RTLD_LAZY); + if (!plugin) continue; + createInstanceFunc *getInstance = (createInstanceFunc *)dlsym(plugin,"getHonokaPluginInstance"); + if (!getInstance) continue; + convertors.push_back(static_cast(getInstance(_scim_config))); + } + } + } + if (!convertors.size()) convertors.push_back(new Convertor(_scim_config)); + /* #ifdef HAVE_LIBWNN convertors.push_back(new WnnConversion(_scim_config)); #endif #ifdef HAVE_LIBANTHY convertors.push_back(new AnthyConversion(_scim_config)); #endif + */ m_convertor = convertors.at(0); - init(); } diff --git a/honoka/src/honoka_imengine.h b/honoka/src/honoka_imengine.h index 8e18434..05d95b6 100644 --- a/honoka/src/honoka_imengine.h +++ b/honoka/src/honoka_imengine.h @@ -24,21 +24,20 @@ #include #endif +#include + #include #include #include #include #include -#ifdef HAVE_LIBWNN - #include -#endif -#ifdef HAVE_LIBANTHY - #include -#endif +#include +#include #define Uses_SCIM_ICONV #include #include +typedef HonokaPluginBase* createInstanceFunc(ConfigPointer); using namespace scim; using namespace std; diff --git a/honoka/src/honokapluginbase.h b/honoka/src/honokapluginbase.h index 0cb25fc..8a40f9b 100644 --- a/honoka/src/honokapluginbase.h +++ b/honoka/src/honokapluginbase.h @@ -25,6 +25,7 @@ #include #include #include +#define Uses_SCIM_CONFIG_BASE using namespace std; using namespace scim; @@ -32,6 +33,9 @@ /** @author TAM (Teppei Tamra) */ + +#define HonokaPluginRegister(pName) extern "C" {HonokaPluginBase *getHonokaPluginInstance(ConfigPointer cfg){return(new pName(cfg));}} + class HonokaPluginBase{ protected: HonokaPluginBase(const String pluginType); diff --git a/honoka/src/wnnconversion.cpp b/honoka/src/wnnconversion.cpp index 1b411ae..c0fe2fb 100644 --- a/honoka/src/wnnconversion.cpp +++ b/honoka/src/wnnconversion.cpp @@ -38,6 +38,9 @@ #define bind_textdomain_codeset(domain,codeset) #endif +// �ץ饤�����󲽤Τ��ޤ��ʤ��Ǥ��� +HonokaPluginRegister(WnnConversion); + WnnConversion::WnnConversion(ConfigPointer cfg) : Convertor(cfg) { // �Ȥꤢ������ᤦ���Ǥ����ޤ���