po \
$(NULL)
+DISTCHECK_CONFIGURE_FLAGS = \
+ --enable-google \
+ --enable-db-open-phrase \
+ $(NULL)
+
ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST = \
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION(0.16.1)
-AC_ARG_VAR(DATABASE, AS_HELP_STRING([pinyin database google or open-phrase, the default is google]))
-
-test x"$DATABASE" != x"open-phrase" && DATABASE=google
-# --enable-build-db
-# AC_ARG_ENABLE(pinyin-database,
-# AS_HELP_STRING([--enable-pinyin-database=[google,open-phrase]],
-# [do not build pinyin database]),
-# [enable_pinyin_database=$enableval],
-# [enable_pinyin_database=google]
-# )
-AM_CONDITIONAL(IBUS_BUILD_DB_GOOGLE, [test x"$DATABASE" = x"google" ])
-AM_CONDITIONAL(IBUS_BUILD_DB_OPEN_PHRASE, [test x"$DATABASE" = x"open-phrase" ])
+
+
+# --enable-db-google
+AC_ARG_ENABLE(db-google,
+ AS_HELP_STRING([--disable-db-google],
+ [do not build database from google android pinyin]),
+ [enable_db_google=$enableval],
+ [enable_db_google=yes]
+)
+AM_CONDITIONAL(IBUS_BUILD_DB_GOOGLE, [test x"$enable_db_google" = x"yes" ])
+
+# --enable-db-open-phrase
+AC_ARG_ENABLE(db-open-phrase,
+ AS_HELP_STRING([--enable-db-open-phrase],
+ [build open-phrase database]),
+ [enable_db_open_phrase=$enableval],
+ [enable_db_open_phrase=no]
+)
+AM_CONDITIONAL(IBUS_BUILD_DB_OPEN_PHRASE, [test x"$enable_db_open_phrase" = x"yes" ])
# OUTPUT files
AC_CONFIG_FILES([ po/Makefile.in
setup/Makefile
setup/ibus-setup-pinyin
data/Makefile
-data/google/Makefile
+data/db/Makefile
+data/db/google/Makefile
+data/db/open-phrase/Makefile
data/icons/Makefile
m4/Makefile
])
AC_MSG_RESULT([
Build options:
- Version $VERSION
- Install prefix $prefix
- Build pinyin database $enable_pinyin_database
- Pinyin datatbase $DATABASE
+ Version $VERSION
+ Install prefix $prefix
+ Build database google $enable_db_google
+ Build database open-phrase $enable_db_open_phrase
])
SUBDIRS = \
- google \
+ db \
icons \
$(NULL)
-if IBUS_BUILD_DB_OPEN_PHRASE
-main_db_DATA = \
- db/main.db \
- db/COPYING \
- db/create_index.sql \
- $(NULL)
-main_dbdir = $(pkgdatadir)/db
-
-install-data-hook:
- @( \
-if test "$(NO_INDEX)" = ""; then \
- cd $(DESTDIR)$(main_dbdir); \
- echo "Create INDEX"; \
- sqlite3 main.db ".read create_index.sql"; \
-fi)
-
-DBVER = 1.2.99
-DBTAR = pinyin-database-$(DBVER).tar.bz2
-
-$(DBTAR):
- wget http://ibus.googlecode.com/files/$(DBTAR)
-
-stamp-db: $(DBTAR)
- tar jxvfm $(DBTAR)
- touch $@
-
-$(main_db_DATA): stamp-db
-
-CLEANFILES = \
- stamp-db \
- db/* \
- $(NULL)
-
-DISTCLEANFILES = \
- $(DBTAR) \
- $(NULL)
-endif
-
--- /dev/null
+# vim:set noet ts=4:
+#
+# ibus-pinyin - The Chinese PinYin engine for IBus
+#
+# Copyright (c) 2007-2008 Peng Huang <shawn.p.huang@gmail.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+SUBDIRS = \
+ google \
+ open-phrase \
+ $(NULL)
+
+main_db_DATA = \
+ create_index.sql \
+ $(NULL)
+main_dbdir = $(pkgdatadir)/db
+
+install-data-hook:
+ @( \
+if test "$(NO_INDEX)" = ""; then \
+ cd $(DESTDIR)$(main_dbdir); \
+ echo "Create INDEX"; \
+ sqlite3 main.db ".read create_index.sql"; \
+fi)
+
+EXTRA_DIST = \
+ create_index.sql \
+ $(NULL)
+
--- /dev/null
+../../../scripts/id.py
\ No newline at end of file
--- /dev/null
+../../../scripts/pydict.py
\ No newline at end of file
--- /dev/null
+# vim:set noet ts=4:
+#
+# ibus-pinyin - The Chinese PinYin engine for IBus
+#
+# Copyright (c) 2007-2008 Peng Huang <shawn.p.huang@gmail.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+if IBUS_BUILD_DB_OPEN_PHRASE
+db_file = open-phrase.db
+main_db_DATA = \
+ db/$(db_file) \
+ db/COPYING \
+ $(NULL)
+main_dbdir = $(pkgdatadir)/db
+
+install-data-hook:
+ @( \
+if test "$(NO_INDEX)" = ""; then \
+ cd $(DESTDIR)$(main_dbdir); \
+ echo "Create INDEX"; \
+ sqlite3 $(db_file) ".read create_index.sql"; \
+fi)
+
+DBVER = 1.2.99
+DBTAR = pinyin-database-$(DBVER).tar.bz2
+
+$(DBTAR):
+ wget http://ibus.googlecode.com/files/$(DBTAR)
+
+stamp-db: $(DBTAR)
+ tar jxvfm $(DBTAR)
+ mv db/main.db db/$(db_file)
+ touch $@
+
+$(main_db_DATA): stamp-db
+
+CLEANFILES = \
+ stamp-db \
+ db/* \
+ $(NULL)
+
+DISTCLEANFILES = \
+ $(DBTAR) \
+ $(NULL)
+endif
+
+++ /dev/null
-../../scripts/id.py
\ No newline at end of file
+++ /dev/null
-../../scripts/pydict.py
\ No newline at end of file
sqlite3_initialize ();
#endif
- if (sqlite3_open_v2 (PKGDATADIR"/db/main.db", &m_db,
- SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL) != SQLITE_OK) {
- if (sqlite3_open_v2 ("main.db", &m_db,
- SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL) != SQLITE_OK)
- goto _failed;
+ static const gchar * maindb [] = {
+ PKGDATADIR"/db/open-phrase.db",
+ PKGDATADIR"/db/google.db",
+ "main.db",
+ NULL
+ };
+
+ guint i;
+ for (i = 0; maindb[i] != NULL; i++) {
+ if (sqlite3_open_v2 (maindb[i], &m_db,
+ SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL) == SQLITE_OK)
+ break;
+ }
+
+ if (maindb[i] == NULL) {
+ g_warning ("can not open main database");
+ goto _failed;
}
m_sql.truncate (0);