summaryrefslogtreecommitdiff
path: root/inputmethod
diff options
context:
space:
mode:
Diffstat (limited to 'inputmethod')
-rw-r--r--inputmethod/ibus-mozc/DESCR3
-rw-r--r--inputmethod/ibus-mozc/Makefile31
-rw-r--r--inputmethod/ibus-mozc/Makefile.common71
-rw-r--r--inputmethod/ibus-mozc/PLIST14
-rw-r--r--inputmethod/ibus-mozc/distinfo52
-rw-r--r--inputmethod/ibus-mozc/patches/patch-DEPS14
-rw-r--r--inputmethod/ibus-mozc/patches/patch-base_base.gyp41
-rw-r--r--inputmethod/ibus-mozc/patches/patch-base_const.h13
-rw-r--r--inputmethod/ibus-mozc/patches/patch-base_cpu__stats.cc46
-rw-r--r--inputmethod/ibus-mozc/patches/patch-base_crash__report__util.cc16
-rw-r--r--inputmethod/ibus-mozc/patches/patch-base_iconv.cc16
-rw-r--r--inputmethod/ibus-mozc/patches/patch-base_logging.cc38
-rw-r--r--inputmethod/ibus-mozc/patches/patch-base_mutex.cc31
-rw-r--r--inputmethod/ibus-mozc/patches/patch-base_mutex.h17
-rw-r--r--inputmethod/ibus-mozc/patches/patch-base_password__manager.cc13
-rw-r--r--inputmethod/ibus-mozc/patches/patch-base_process.cc58
-rw-r--r--inputmethod/ibus-mozc/patches/patch-base_run__level.cc13
-rw-r--r--inputmethod/ibus-mozc/patches/patch-base_thread.h14
-rw-r--r--inputmethod/ibus-mozc/patches/patch-base_util.cc71
-rw-r--r--inputmethod/ibus-mozc/patches/patch-base_util__test.cc13
-rw-r--r--inputmethod/ibus-mozc/patches/patch-build__mozc.py237
-rw-r--r--inputmethod/ibus-mozc/patches/patch-build__tools_mozc__version.py12
-rw-r--r--inputmethod/ibus-mozc/patches/patch-build__tools_util.py15
-rw-r--r--inputmethod/ibus-mozc/patches/patch-client_client.cc22
-rw-r--r--inputmethod/ibus-mozc/patches/patch-config_stats__config__util__test.cc20
-rw-r--r--inputmethod/ibus-mozc/patches/patch-gui_base_locale__util.cc13
-rw-r--r--inputmethod/ibus-mozc/patches/patch-gui_config__dialog_config__dialog.cc57
-rw-r--r--inputmethod/ibus-mozc/patches/patch-gui_config__dialog_keybinding__editor.cc40
-rw-r--r--inputmethod/ibus-mozc/patches/patch-gui_config__dialog_keymap__editor.cc13
-rw-r--r--inputmethod/ibus-mozc/patches/patch-gui_dictionary__tool_dictionary__tool.cc13
-rw-r--r--inputmethod/ibus-mozc/patches/patch-gui_gui.gyp13
-rw-r--r--inputmethod/ibus-mozc/patches/patch-gui_qt__libraries.gypi13
-rw-r--r--inputmethod/ibus-mozc/patches/patch-gui_word__register__dialog_word__register__dialog.cc13
-rw-r--r--inputmethod/ibus-mozc/patches/patch-gui_zinnia.gyp13
-rw-r--r--inputmethod/ibus-mozc/patches/patch-gyp_common.gypi54
-rw-r--r--inputmethod/ibus-mozc/patches/patch-handwriting_handwriting.gyp13
-rw-r--r--inputmethod/ibus-mozc/patches/patch-handwriting_zinnia__handwriting.cc15
-rw-r--r--inputmethod/ibus-mozc/patches/patch-ipc_ipc__path__manager.cc69
-rw-r--r--inputmethod/ibus-mozc/patches/patch-ipc_ipc__path__manager__test.cc13
-rw-r--r--inputmethod/ibus-mozc/patches/patch-ipc_named__event.cc15
-rw-r--r--inputmethod/ibus-mozc/patches/patch-ipc_unix__ipc.cc77
-rw-r--r--inputmethod/ibus-mozc/patches/patch-languages_chewing_chewing.gyp13
-rw-r--r--inputmethod/ibus-mozc/patches/patch-languages_hangul_hangul.gyp13
-rw-r--r--inputmethod/ibus-mozc/patches/patch-net_net.gyp13
-rw-r--r--inputmethod/ibus-mozc/patches/patch-protobuf_genproto.gypi20
-rw-r--r--inputmethod/ibus-mozc/patches/patch-protobuf_protobuf.gyp31
-rw-r--r--inputmethod/ibus-mozc/patches/patch-session_session.cc13
-rw-r--r--inputmethod/ibus-mozc/patches/patch-session_session__converter__interface.h13
-rw-r--r--inputmethod/ibus-mozc/patches/patch-session_session__test.cc31
-rw-r--r--inputmethod/ibus-mozc/patches/patch-third__party_gyp_buildbot_buildbot__run.py13
-rw-r--r--inputmethod/ibus-mozc/patches/patch-unix_ibus_gen__mozc__xml.py51
-rw-r--r--inputmethod/ibus-mozc/patches/patch-unix_ibus_mozc__engine.cc15
52 files changed, 1561 insertions, 0 deletions
diff --git a/inputmethod/ibus-mozc/DESCR b/inputmethod/ibus-mozc/DESCR
new file mode 100644
index 00000000000..065bd0f8305
--- /dev/null
+++ b/inputmethod/ibus-mozc/DESCR
@@ -0,0 +1,3 @@
+Mozc is a Japanese Input Method Editor (IME) designed for multi-platform
+such as Chromium OS, Windows, Mac and Linux. This open-source
+project originates from Google Japanese Input.
diff --git a/inputmethod/ibus-mozc/Makefile b/inputmethod/ibus-mozc/Makefile
new file mode 100644
index 00000000000..b9abdbe273c
--- /dev/null
+++ b/inputmethod/ibus-mozc/Makefile
@@ -0,0 +1,31 @@
+# $NetBSD: Makefile,v 1.1 2013/01/18 11:36:39 ryoon Exp $
+#
+
+PKGNAME= ibus-${DISTNAME}
+
+INSTALLATION_DIRS+= libexec share/ibus share/icons share/ibus/component \
+ share/ibus-mozc
+
+DEPENDS+= xdg-utils-[0-9]*:../../misc/xdg-utils
+
+do-build:
+ cd ${WRKSRC} && env ${MAKE_ENV} \
+ ${PYTHONBIN} build_mozc.py build -c Release -j ${MAKE_JOBS} \
+ unix/ibus/ibus.gyp:ibus_mozc
+
+do-install:
+ ${INSTALL_PROGRAM} ${WRKSRC}/out_${OSDEST}/Release/ibus_mozc \
+ ${DESTDIR}${PREFIX}/libexec/ibus-engine-mozc
+ ${INSTALL_DATA} ${WRKSRC}/out_${OSDEST}/Release/obj/gen/unix/ibus/mozc.xml \
+ ${DESTDIR}${PREFIX}/share/ibus/component
+.for f in ui-alpha_full ui-alpha_half ui-dictionary ui-direct \
+ ui-hiragana ui-katakana_full ui-katakana_half ui-properties ui-tool
+ ${INSTALL_DATA} ${WRKSRC}/data/images/unix/${f}.png \
+ ${DESTDIR}${PREFIX}/share/icons/${f:S/^ui-/mozc-/}.png
+.endfor
+ ${INSTALL_DATA} ${WRKSRC}/data/images/product_icon_32bpp-128.png \
+ ${DESTDIR}${PREFIX}/share/icons/mozc.png
+ ${INSTALL_DATA} ${WRKSRC}/data/images/unix/ime_product_icon_opensource-32.png \
+ ${DESTDIR}${PREFIX}/share/ibus-mozc/product_icon.png
+
+.include "Makefile.common"
diff --git a/inputmethod/ibus-mozc/Makefile.common b/inputmethod/ibus-mozc/Makefile.common
new file mode 100644
index 00000000000..675796349c6
--- /dev/null
+++ b/inputmethod/ibus-mozc/Makefile.common
@@ -0,0 +1,71 @@
+# $NetBSD: Makefile.common,v 1.1 2013/01/18 11:36:39 ryoon Exp $
+# used by inputmethod/mozc-server/Makefile
+# used by inputmethod/mozc-tool/Makefile
+#
+
+DISTNAME= mozc-1.6.1187.102
+CATEGORIES= inputmethod
+MASTER_SITES= http://mozc.googlecode.com/files/
+EXTRACT_SUFX= .tar.bz2
+
+MAINTAINER= ryoon@NetBSD.org
+HOMEPAGE= http://code.google.com/p/mozc/
+COMMENT= Japanese inputmethod Mozc engine for IBus
+LICENSE= modified-bsd
+
+DISTINFO_FILE= ${.CURDIR}/../../inputmethod/ibus-mozc/distinfo
+PATCHDIR= ${.CURDIR}/../../inputmethod/ibus-mozc/patches
+
+BUILD_DEPENDS+= ${PYPKGPREFIX}-gyp-[0-9]*:../../devel/gyp
+
+USE_LANGUAGES= c c++
+
+USE_TOOLS+= gmake pkg-config
+
+FIND_PREFIX:= GYPDIR=${PYPKGPREFIX}-gyp
+.include "../../mk/find-prefix.mk"
+
+OPENSSL_CFLAGS= -I${BUILDLINK_PREFIX.openssl}/include
+OPENSSL_INC= -I${BUILDLINK_PREFIX.openssl}/include
+OPENSSL_LDFLAGS= -L${BUILDLINK_PREFIX.openssl}/lib -lssl -lcrypto
+OPENSSL_LIBS= -lssl -lcrypto
+
+SUBST_CLASSES+= gyp
+SUBST_STAGE.gyp= pre-configure
+SUBST_MESSAGE.gyp= Fix gyp defaults
+SUBST_FILES.gyp+= base/base.gyp
+SUBST_FILES.gyp+= base/process.cc
+SUBST_FILES.gyp+= handwriting/zinnia_handwriting.cc
+SUBST_FILES.gyp+= unix/ibus/gen_mozc_xml.py
+SUBST_FILES.gyp+= gui/qt_rcc.gypi
+SUBST_FILES.gyp+= gui/qt_moc.gypi
+SUBST_FILES.gyp+= gui/qt_uic.gypi
+SUBST_FILES.gyp+= gui/qt_libraries.gypi
+SUBST_FILES.gyp+= base/const.h
+SUBST_FILES.gyp+= build_mozc.py
+SUBST_VARS.gyp+= OPENSSL_CFLAGS OPENSSL_INC OPENSSL_LDFLAGS OPENSSL_LIBS
+SUBST_VARS.gyp+= PREFIX QTDIR
+
+.include "../../mk/bsd.prefs.mk"
+.if ${OPSYS} == "NetBSD"
+OSDEST= bsd
+.elif ${OPSYS} == "Linux"
+OSDEST= linux
+.endif
+
+do-configure:
+ cd ${WRKSRC} && env ${MAKE_ENV} \
+ GYP_DEFINES="use_libprotobuf=1" \
+ ${PYTHONBIN} build_mozc.py gyp --os=netbsd && \
+ ${PYTHONBIN} build_mozc.py build_tools -c Release -j ${MAKE_JOBS}
+
+.include "../../devel/glib2/buildlink3.mk"
+.include "../../devel/protobuf/buildlink3.mk"
+# gmock is not used yet...
+#.include "../../devel/gmock/buildlink3.mk"
+.include "../../inputmethod/ibus/buildlink3.mk"
+.include "../../inputmethod/zinnia/buildlink3.mk"
+.include "../../x11/gtk2/buildlink3.mk"
+
+.include "../../lang/python/tool.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/inputmethod/ibus-mozc/PLIST b/inputmethod/ibus-mozc/PLIST
new file mode 100644
index 00000000000..6df9cc96ff9
--- /dev/null
+++ b/inputmethod/ibus-mozc/PLIST
@@ -0,0 +1,14 @@
+@comment $NetBSD: PLIST,v 1.1 2013/01/18 11:36:39 ryoon Exp $
+libexec/ibus-engine-mozc
+share/ibus-mozc/product_icon.png
+share/ibus/component/mozc.xml
+share/icons/mozc-alpha_full.png
+share/icons/mozc-alpha_half.png
+share/icons/mozc-dictionary.png
+share/icons/mozc-direct.png
+share/icons/mozc-hiragana.png
+share/icons/mozc-katakana_full.png
+share/icons/mozc-katakana_half.png
+share/icons/mozc-properties.png
+share/icons/mozc-tool.png
+share/icons/mozc.png
diff --git a/inputmethod/ibus-mozc/distinfo b/inputmethod/ibus-mozc/distinfo
new file mode 100644
index 00000000000..7618ad44a9f
--- /dev/null
+++ b/inputmethod/ibus-mozc/distinfo
@@ -0,0 +1,52 @@
+$NetBSD: distinfo,v 1.1 2013/01/18 11:36:39 ryoon Exp $
+
+SHA1 (mozc-1.6.1187.102.tar.bz2) = 341e0edd1f5c8593b8936792975a4856e1c9c89e
+RMD160 (mozc-1.6.1187.102.tar.bz2) = 4997cba2b8db9d14ec085142947c92fc789f79cb
+Size (mozc-1.6.1187.102.tar.bz2) = 54828375 bytes
+SHA1 (patch-DEPS) = e86c43a1b55aec4296b9fc6d21683a0f87630828
+SHA1 (patch-base_base.gyp) = eb16f96503998e9f33bdf99474f63eec7975c7f9
+SHA1 (patch-base_const.h) = 30f4fcccc5ba9bdb969697b807ec548d53fd6c60
+SHA1 (patch-base_cpu__stats.cc) = cda8bbcbc963d8ed635435375cc80ee5e7ca2191
+SHA1 (patch-base_crash__report__util.cc) = b745c0ac69e06a222df8398af425e9d697f6ce68
+SHA1 (patch-base_iconv.cc) = 1bf65dfc6152bf152cbe2714835a61436df2a48b
+SHA1 (patch-base_logging.cc) = fff656a611dc4eec91dfac7b035cc0fc628e3706
+SHA1 (patch-base_mutex.cc) = 48e5f3e7eacabd6d5a1aceec3e63e1c952be556e
+SHA1 (patch-base_mutex.h) = bf77404ad2d105ef975fc0f9c4086d8dcdc428ea
+SHA1 (patch-base_password__manager.cc) = cb11b9b707ab0c361c969eefd4d7c805c0b4b06a
+SHA1 (patch-base_process.cc) = cf7e086d35d1bd0c640ceda6b39a9e12103979e8
+SHA1 (patch-base_run__level.cc) = 738b263a334977038629d24bef96b365c42fca57
+SHA1 (patch-base_thread.h) = b0560c13b2670dc645f3587cfd56ecab0a7fe850
+SHA1 (patch-base_util.cc) = e4c335570b51ab52a620cbbfc0112b769f07e630
+SHA1 (patch-base_util__test.cc) = 219027850ae06a5cac3c21c7a3f4555dbe19b19c
+SHA1 (patch-build__mozc.py) = dc6cfa50c588d799ac2f6b09fe3e80ea0afe2cb1
+SHA1 (patch-build__tools_mozc__version.py) = 47460ca750d8d28652c5c55e5df9b786af4d33c7
+SHA1 (patch-build__tools_util.py) = 17560bc77282ae4f1fe9f9f208b087961f808276
+SHA1 (patch-client_client.cc) = 0b7e60a9222acc8360de573ec0c0e110e461bc3e
+SHA1 (patch-config_stats__config__util__test.cc) = db51e6619c5c04ac8fa50890825206ea922dccf2
+SHA1 (patch-gui_base_locale__util.cc) = 2900424ef4a937e24dbb0e1c618f04fec14a9cc2
+SHA1 (patch-gui_config__dialog_config__dialog.cc) = b009d4c40a03f838ff08b85f159c8f76f9282d54
+SHA1 (patch-gui_config__dialog_keybinding__editor.cc) = 00a6e4bb2c07e3340e188f108f0285a3aa2aceb9
+SHA1 (patch-gui_config__dialog_keymap__editor.cc) = b1c799e9e9aa3ca876a302ccffc1ad820662b6f9
+SHA1 (patch-gui_dictionary__tool_dictionary__tool.cc) = 860b9331fc4c9df4ee20ab24406008ece66eb672
+SHA1 (patch-gui_gui.gyp) = a27d0a0a3fb6893a691450917cf2798ace1647ed
+SHA1 (patch-gui_qt__libraries.gypi) = 7db5480dc8bd244b168a8977c3103e5f09308cd8
+SHA1 (patch-gui_word__register__dialog_word__register__dialog.cc) = 82c814154badd33af3d5e6d07498d887c76136c1
+SHA1 (patch-gui_zinnia.gyp) = 0eaad35b829d2c25e751ce6e99207781306934d5
+SHA1 (patch-gyp_common.gypi) = 7f6f2c79980fb2a4aee5be1bde5350e708499682
+SHA1 (patch-handwriting_handwriting.gyp) = 951ac70a188ff640a0d526d83fd4304e8ee07d0c
+SHA1 (patch-handwriting_zinnia__handwriting.cc) = 9f6a857571a6d13f722d0503e232943d8dd2915e
+SHA1 (patch-ipc_ipc__path__manager.cc) = a13646db4419e6c906146ecab3dcaa938edc34d0
+SHA1 (patch-ipc_ipc__path__manager__test.cc) = 000acabea50faf3d192ee219313c4c4ebfc4e330
+SHA1 (patch-ipc_named__event.cc) = 92283261e7580569587e43156f13567b593c9a32
+SHA1 (patch-ipc_unix__ipc.cc) = 31d02af16375edaa3b8b562225a3c41cf9ed4f45
+SHA1 (patch-languages_chewing_chewing.gyp) = 26fa18398911609a53cff003943436f003772e64
+SHA1 (patch-languages_hangul_hangul.gyp) = 685964cd31e91c96f0d41e729441b17ed9ac24f8
+SHA1 (patch-net_net.gyp) = 60cb23882d81c8222337888dd735f3c6c72aee0f
+SHA1 (patch-protobuf_genproto.gypi) = b31dacd4e7e5a3f7baed8e1ab0d2d6983a244119
+SHA1 (patch-protobuf_protobuf.gyp) = 32639f8052e53b88c4e460f211292967fc915873
+SHA1 (patch-session_session.cc) = 477779cb73448b8ddc71eff02627f96c2469607c
+SHA1 (patch-session_session__converter__interface.h) = 93bda6e51b9a9ac7146aa23ac0aa28bb017a4465
+SHA1 (patch-session_session__test.cc) = 1258b334c77b08c5b423a35cfef452587f5b6db6
+SHA1 (patch-third__party_gyp_buildbot_buildbot__run.py) = 21375df1c6c19233c66b24da4dc23ddad5515b72
+SHA1 (patch-unix_ibus_gen__mozc__xml.py) = c5c352b8039cb9625af54aa95582ef48c579577d
+SHA1 (patch-unix_ibus_mozc__engine.cc) = 0ae1220c1253c4d5d0d5eb97e584c12ea38b5c96
diff --git a/inputmethod/ibus-mozc/patches/patch-DEPS b/inputmethod/ibus-mozc/patches/patch-DEPS
new file mode 100644
index 00000000000..fe4c3f0e4fb
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-DEPS
@@ -0,0 +1,14 @@
+$NetBSD: patch-DEPS,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- DEPS.orig 2012-08-31 05:36:42.000000000 +0000
++++ DEPS
+@@ -91,3 +91,9 @@ deps_os = {
+ Var("clang_helper_in_chromium_revision"),
+ },
+ }
++ "netbsd": {
++ "src/third_party/clang/scripts":
++ "https://src.chromium.org/chrome/trunk/src/tools/clang/scripts@" +
++ Var("clang_helper_in_chromium_revision"),
++ },
++}
diff --git a/inputmethod/ibus-mozc/patches/patch-base_base.gyp b/inputmethod/ibus-mozc/patches/patch-base_base.gyp
new file mode 100644
index 00000000000..1664511eaa8
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-base_base.gyp
@@ -0,0 +1,41 @@
+$NetBSD: patch-base_base.gyp,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- base/base.gyp.orig 2012-08-31 05:37:06.000000000 +0000
++++ base/base.gyp
+@@ -98,7 +98,7 @@
+ # shared among *host* binaries and *target* binaries. This means that
+ # you should implement *host* binaries by using limited libraries
+ # which are also available on NDK.
+- ['OS=="linux" and target_platform!="Android" and '
++ ['OS=="netbsd" or (OS=="linux" and target_platform!="Android") and '
+ 'not (target_platform=="NaCl" and _toolset=="target")', {
+ 'defines': [
+ 'HAVE_LIBRT=1',
+@@ -260,22 +260,22 @@
+ ],
+ }
+ }],
+- ['OS=="linux" and target_platform!="Android"', {
++ ['OS=="netbsd" or (OS=="linux" and target_platform!="Android")', {
+ 'cflags': [
+- '<!@(<(pkg_config_command) --cflags-only-other openssl)',
++ '@OPENSSL_CFLAGS@',
+ ],
+ 'defines': [
+ 'HAVE_OPENSSL=1',
+ ],
+ 'include_dirs': [
+- '<!@(<(pkg_config_command) --cflags-only-I openssl)',
++ '@OPENSSL_INC@',
+ ],
+ 'link_settings': {
+ 'ldflags': [
+- '<!@(<(pkg_config_command) --libs-only-L openssl)',
++ '@OPENSSL_LDFLAGS@',
+ ],
+ 'libraries': [
+- '<!@(<(pkg_config_command) --libs-only-l openssl)',
++ '@OPENSSL_LIBS@',
+ ],
+ },
+ }],
diff --git a/inputmethod/ibus-mozc/patches/patch-base_const.h b/inputmethod/ibus-mozc/patches/patch-base_const.h
new file mode 100644
index 00000000000..b2723efe28a
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-base_const.h
@@ -0,0 +1,13 @@
+$NetBSD: patch-base_const.h,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- base/const.h.orig 2012-08-31 05:37:06.000000000 +0000
++++ base/const.h
+@@ -146,7 +146,7 @@ const char kMozcTool[] = "mozc_tool";
+ #ifdef MOZC_SERVER_DIRECTORY
+ const char kMozcServerDirectory[] = MOZC_SERVER_DIRECTORY;
+ #else
+-const char kMozcServerDirectory[] = "/usr/lib/mozc";
++const char kMozcServerDirectory[] = "@PREFIX@/libexec";
+ #endif // MOZC_SERVER_DIRECTORY
+ #ifdef OS_ANDROID
+ #ifndef MOZC_ANDROID_APPLICATION_ID
diff --git a/inputmethod/ibus-mozc/patches/patch-base_cpu__stats.cc b/inputmethod/ibus-mozc/patches/patch-base_cpu__stats.cc
new file mode 100644
index 00000000000..f0c97ac2dc5
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-base_cpu__stats.cc
@@ -0,0 +1,46 @@
+$NetBSD: patch-base_cpu__stats.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- base/cpu_stats.cc.orig 2012-08-31 05:37:06.000000000 +0000
++++ base/cpu_stats.cc
+@@ -123,13 +123,13 @@ float CPUStats::GetSystemCPULoad() {
+
+ #endif // OS_MACOSX
+
+-#ifdef OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ // NOT IMPLEMENTED
+ // TODO(taku): implement Linux version
+ // can take the info from /proc/stats
+ const uint64 total_times = 0;
+ const uint64 cpu_times = 0;
+-#endif // OS_LINUX
++#endif // OS_LINUX || OS_NETBSD
+
+ return UpdateCPULoad(total_times,
+ cpu_times,
+@@ -178,11 +178,11 @@ float CPUStats::GetCurrentProcessCPULoad
+ TimeValueTToInt64(task_times_info.system_time);
+ #endif // OS_MACOSX
+
+-#ifdef OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ // not implemented
+ const uint64 total_times = 0;
+ const uint64 cpu_times = 0;
+-#endif // OS_LINUX
++#endif // OS_LINUX || OS_NETBSD
+
+ return UpdateCPULoad(total_times,
+ cpu_times,
+@@ -210,9 +210,9 @@ size_t CPUStats::GetNumberOfProcessors()
+ return static_cast<size_t>(basic_info.avail_cpus);
+ #endif // OS_MACOSX
+
+-#ifdef OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ // Not implemented
+ return 1;
+-#endif // OS_LINUX
++#endif // OS_LINUX || OS_NETBSD
+ }
+ } // namespace mozc
diff --git a/inputmethod/ibus-mozc/patches/patch-base_crash__report__util.cc b/inputmethod/ibus-mozc/patches/patch-base_crash__report__util.cc
new file mode 100644
index 00000000000..8b75b786115
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-base_crash__report__util.cc
@@ -0,0 +1,16 @@
+$NetBSD: patch-base_crash__report__util.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- base/crash_report_util.cc.orig 2012-08-31 05:37:06.000000000 +0000
++++ base/crash_report_util.cc
+@@ -51,9 +51,9 @@ namespace mozc {
+
+ void CrashReportUtil::InstallBreakpad() {
+ // TODO(nona): Support breakpad for official branding build on Linux.
+-#if defined(GOOGLE_JAPANESE_INPUT_BUILD) && !defined(OS_LINUX)
++#if defined(GOOGLE_JAPANESE_INPUT_BUILD) && (!defined(OS_LINUX) || !defined(OS_NETBSD))
+ CrashReportHandler::Initialize(false);
+-#endif // GOOGLE_JAPANESE_INPUT_BUILD && !OS_LINUX
++#endif // GOOGLE_JAPANESE_INPUT_BUILD && (!OS_LINUX || !OS_NETBSD)
+ }
+
+ string CrashReportUtil::GetCrashReportDirectory() {
diff --git a/inputmethod/ibus-mozc/patches/patch-base_iconv.cc b/inputmethod/ibus-mozc/patches/patch-base_iconv.cc
new file mode 100644
index 00000000000..ab52ab3a568
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-base_iconv.cc
@@ -0,0 +1,16 @@
+$NetBSD: patch-base_iconv.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- base/iconv.cc.orig 2012-08-31 05:37:06.000000000 +0000
++++ base/iconv.cc
+@@ -53,7 +53,11 @@ bool IconvHelper(iconv_t ic, const strin
+ size_t olen_org = olen;
+ iconv(ic, 0, &ilen, 0, &olen); // reset iconv state
+ while (ilen != 0) {
++#if defined(OS_NETBSD)
++ if (iconv(ic, (const char **)(&ibuf), &ilen, &obuf, &olen)
++#else
+ if (iconv(ic, reinterpret_cast<char **>(&ibuf), &ilen, &obuf, &olen)
++#endif
+ == static_cast<size_t>(-1)) {
+ return false;
+ }
diff --git a/inputmethod/ibus-mozc/patches/patch-base_logging.cc b/inputmethod/ibus-mozc/patches/patch-base_logging.cc
new file mode 100644
index 00000000000..869b821c30e
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-base_logging.cc
@@ -0,0 +1,38 @@
+$NetBSD: patch-base_logging.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- base/logging.cc.orig 2012-08-31 05:37:06.000000000 +0000
++++ base/logging.cc
+@@ -59,6 +59,10 @@
+ #include "base/singleton.h"
+ #include "base/util.h"
+
++#if defined(OS_NETBSD)
++#include <lwp.h>
++#endif
++
+ DEFINE_bool(colored_log, true, "Enables colored log messages on tty devices");
+ DEFINE_bool(logtostderr,
+ false,
+@@ -106,12 +110,7 @@ string Logging::GetLogMessageHeader() {
+ char buf[512];
+ snprintf(buf, sizeof(buf),
+ "%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d %u "
+-#if !defined(OS_LINUX) || defined(__native_client__)
+-// = OS_WINDOWS or OS_MACOSX or __native_client__
+- "%u",
+-#else
+ "%lu",
+-#endif
+ 1900 + tm_time.tm_year,
+ 1 + tm_time.tm_mon,
+ tm_time.tm_mday,
+@@ -124,6 +123,9 @@ string Logging::GetLogMessageHeader() {
+ #elif defined(OS_MACOSX)
+ ::getpid(),
+ reinterpret_cast<uint32>(pthread_self())
++#elif defined(OS_NETBSD)
++ ::getpid(),
++ _lwp_self()
+ #else // = OS_LINUX
+ ::getpid(),
+ // In NaCl it returns uint32, otherwise it returns unsigned long.
diff --git a/inputmethod/ibus-mozc/patches/patch-base_mutex.cc b/inputmethod/ibus-mozc/patches/patch-base_mutex.cc
new file mode 100644
index 00000000000..488375ae106
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-base_mutex.cc
@@ -0,0 +1,31 @@
+$NetBSD: patch-base_mutex.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- base/mutex.cc.orig 2012-08-31 05:37:06.000000000 +0000
++++ base/mutex.cc
+@@ -61,7 +61,7 @@ namespace mozc {
+
+ // Wrapper for Windows InterlockedCompareExchange
+ namespace {
+-#ifdef OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ // Linux doesn't provide InterlockedCompareExchange-like function.
+ inline int InterlockedCompareExchange(volatile int *target,
+ int new_value,
+@@ -80,7 +80,7 @@ inline int InterlockedCompareExchange(vo
+ pthread_mutex_unlock(&lock);
+ return result;
+ }
+-#endif // OS_LINUX
++#endif // OS_LINUX || OS_NETBSD
+
+ // Use OSAtomicCompareAndSwapInt on Mac OSX
+ // http://developer.apple.com/iphone/library/documentation/
+@@ -296,7 +296,7 @@ Mutex::Mutex() {
+ // PTHREAD_MUTEX_RECURSIVE_NP but Mac OS X 10.5 does not
+ pthread_mutexattr_t attr;
+ pthread_mutexattr_init(&attr);
+-#if defined(OS_MACOSX)
++#if defined(OS_MACOSX) || defined(OS_NETBSD)
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+ #elif defined(OS_LINUX)
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
diff --git a/inputmethod/ibus-mozc/patches/patch-base_mutex.h b/inputmethod/ibus-mozc/patches/patch-base_mutex.h
new file mode 100644
index 00000000000..021cab29e61
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-base_mutex.h
@@ -0,0 +1,17 @@
+$NetBSD: patch-base_mutex.h,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+* I am not sure.
+
+--- base/mutex.h.orig 2012-08-31 05:37:06.000000000 +0000
++++ base/mutex.h
+@@ -56,6 +56,10 @@ namespace mozc {
+ #define MOZC_RW_MUTEX_PTR_ARRAYSIZE 10
+ #endif
+
++#if defined(__FreeBSD__) || defined(__NetBSD__)
++#define PTHREAD_MUTEX_RECURSIVE_VALUE PTHREAD_MUTEX_RECURSIVE
++#endif
++
+ class LOCKABLE Mutex {
+ public:
+ Mutex();
diff --git a/inputmethod/ibus-mozc/patches/patch-base_password__manager.cc b/inputmethod/ibus-mozc/patches/patch-base_password__manager.cc
new file mode 100644
index 00000000000..74d3aaf6f80
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-base_password__manager.cc
@@ -0,0 +1,13 @@
+$NetBSD: patch-base_password__manager.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- base/password_manager.cc.orig 2012-08-31 05:37:06.000000000 +0000
++++ base/password_manager.cc
+@@ -366,7 +366,7 @@ class DeprecatedMacPasswordManager : pub
+ // this module to other Linux distro, you might want to implement
+ // a new password manager which adopts some secure mechanism such
+ // like gnome-keyring.
+-#if defined OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ typedef PlainPasswordManager DefaultPasswordManager;
+ #endif
+
diff --git a/inputmethod/ibus-mozc/patches/patch-base_process.cc b/inputmethod/ibus-mozc/patches/patch-base_process.cc
new file mode 100644
index 00000000000..b057c5412cb
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-base_process.cc
@@ -0,0 +1,58 @@
+$NetBSD: patch-base_process.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- base/process.cc.orig 2012-08-31 05:37:06.000000000 +0000
++++ base/process.cc
+@@ -50,7 +50,7 @@
+ #include "base/mac_process.h"
+ #endif // OS_MACOSX
+
+-#ifdef OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ #include <fcntl.h>
+ #include <signal.h>
+ #include <spawn.h> // for posix_spawn().
+@@ -120,7 +120,7 @@ bool Process::OpenBrowser(const string &
+ return ShellExecuteInSystemDir(L"open", wurl.c_str(), NULL, SW_SHOW);
+ #endif
+
+-#ifdef OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ static const char kBrowserCommand[] = "/usr/bin/xdg-open";
+ // xdg-open which uses kfmclient or gnome-open internally works both on KDE
+ // and GNOME environments.
+@@ -204,7 +204,7 @@ bool Process::SpawnProcess(const string
+ }
+ #endif
+
+-#ifdef OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ // Do not call posix_spawn() for obviously bad path.
+ if (!S_ISREG(statbuf.st_mode)) {
+ LOG(ERROR) << "Not a regular file: " << path;
+@@ -227,7 +227,7 @@ bool Process::SpawnProcess(const string
+ // (www.gnu.org/software/libc/manual/html_node/Heap-Consistency-Checking.html)
+ const int kOverwrite = 0; // Do not overwrite.
+ ::setenv("MALLOC_CHECK_", "2", kOverwrite);
+-#endif // OS_LINUX
++#endif // OS_LINUX || OS_NETBSD
+ pid_t tmp_pid = 0;
+
+ // Spawn new process.
+@@ -398,7 +398,7 @@ bool Process::LaunchErrorMessageDialog(c
+ }
+ #endif // OS_WINDOWS
+
+-#ifdef OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ const char kMozcTool[] = "mozc_tool";
+ const string arg = "--mode=error_message_dialog --error_type=" + error_type;
+ size_t pid = 0;
+@@ -406,7 +406,7 @@ bool Process::LaunchErrorMessageDialog(c
+ LOG(ERROR) << "cannot launch " << kMozcTool;
+ return false;
+ }
+-#endif // OS_LINUX
++#endif // OS_LINUX || OS_NETBSD
+
+ return true;
+ }
diff --git a/inputmethod/ibus-mozc/patches/patch-base_run__level.cc b/inputmethod/ibus-mozc/patches/patch-base_run__level.cc
new file mode 100644
index 00000000000..da49e241343
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-base_run__level.cc
@@ -0,0 +1,13 @@
+$NetBSD: patch-base_run__level.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- base/run_level.cc.orig 2012-08-31 05:37:06.000000000 +0000
++++ base/run_level.cc
+@@ -34,7 +34,7 @@
+ #include <aclapi.h>
+ #endif // OS_WINDOWS
+
+-#ifdef OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ #include <unistd.h>
+ #include <sys/types.h>
+ #endif // OS_LINUX
diff --git a/inputmethod/ibus-mozc/patches/patch-base_thread.h b/inputmethod/ibus-mozc/patches/patch-base_thread.h
new file mode 100644
index 00000000000..d4b537d3bdf
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-base_thread.h
@@ -0,0 +1,14 @@
+$NetBSD: patch-base_thread.h,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- base/thread.h.orig 2012-08-31 05:37:06.000000000 +0000
++++ base/thread.h
+@@ -55,7 +55,8 @@
+
+ // Andorid NDK and NaCl don't support TLS.
+ #if defined(OS_LINUX) && !defined(OS_ANDROID) && \
+- !defined(__native_client__) && (defined(__GNUC__) || defined(__clang__))
++ !defined(__native_client__) && (defined(__GNUC__) || defined(__clang__)) \
++ || defined(OS_NETBSD)
+ // GCC and Clang support TLS.
+ #define TLS_KEYWORD __thread
+ #define HAVE_TLS 1
diff --git a/inputmethod/ibus-mozc/patches/patch-base_util.cc b/inputmethod/ibus-mozc/patches/patch-base_util.cc
new file mode 100644
index 00000000000..b94b6850443
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-base_util.cc
@@ -0,0 +1,71 @@
+$NetBSD: patch-base_util.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- base/util.cc.orig 2012-08-31 05:37:06.000000000 +0000
++++ base/util.cc
+@@ -891,7 +891,7 @@ class ClockImpl : public Util::ClockInte
+ mach_timebase_info(&timebase_info);
+ return static_cast<uint64>(
+ 1.0e9 * timebase_info.denom / timebase_info.numer);
+-#elif defined(OS_LINUX)
++#elif defined(OS_LINUX) || defined(OS_NETBSD)
+ #if defined(HAVE_LIBRT)
+ return 1000000000uLL;
+ #else
+@@ -911,7 +911,7 @@ class ClockImpl : public Util::ClockInte
+ return static_cast<uint64>(timestamp.QuadPart);
+ #elif defined(OS_MACOSX)
+ return static_cast<uint64>(mach_absolute_time());
+-#elif defined(OS_LINUX)
++#elif defined(OS_LINUX) || defined(OS_NETBSD)
+ #if defined(HAVE_LIBRT)
+ struct timespec timestamp;
+ if (-1 == clock_gettime(CLOCK_REALTIME, &timestamp)) {
+@@ -1869,9 +1869,9 @@ string Util::GetServerDirectory() {
+ return MacUtil::GetServerDirectory();
+ #endif // OS_MACOSX
+
+-#ifdef OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ return kMozcServerDirectory;
+-#endif // OS_LINUX
++#endif // OS_LINUX || OS_NETBSD
+ }
+
+ string Util::GetServerPath() {
+@@ -2000,7 +2000,7 @@ bool GetCurrentSessionId(DWORD *session_
+ #endif // OS_WINDOWS
+
+ string Util::GetDesktopNameAsString() {
+-#ifdef OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ const char *display = getenv("DISPLAY");
+ if (display == NULL) {
+ return "";
+@@ -2514,7 +2514,7 @@ bool Util::IsPlatformSupported() {
+ #if defined(OS_MACOSX)
+ // TODO(yukawa): support Mac.
+ return true;
+-#elif defined(OS_LINUX)
++#elif defined(OS_LINUX) || defined(OS_NETBSD)
+ // TODO(yukawa): support Linux.
+ return true;
+ #elif defined(OS_WINDOWS)
+@@ -2873,6 +2873,9 @@ string Util::GetOSVersionString() {
+ #elif defined(OS_LINUX)
+ const string ret = "Linux";
+ return ret;
++#elif defined(OS_NETBSD)
++ const string ret = "NetBSD";
++ return ret;
+ #else
+ const string ret = "Unknown";
+ return ret;
+@@ -2910,7 +2913,7 @@ uint64 Util::GetTotalPhysicalMemory() {
+ return 0;
+ }
+ return total_memory;
+-#elif defined(OS_LINUX)
++#elif defined(OS_LINUX) || defined(OS_NETBSD)
+ #if defined(_SC_PAGESIZE) && defined(_SC_PHYS_PAGES)
+ const long page_size = sysconf(_SC_PAGESIZE);
+ const long number_of_phyisical_pages = sysconf(_SC_PHYS_PAGES);
diff --git a/inputmethod/ibus-mozc/patches/patch-base_util__test.cc b/inputmethod/ibus-mozc/patches/patch-base_util__test.cc
new file mode 100644
index 00000000000..2b5f84ce236
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-base_util__test.cc
@@ -0,0 +1,13 @@
+$NetBSD: patch-base_util__test.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- base/util_test.cc.orig 2012-08-31 05:37:06.000000000 +0000
++++ base/util_test.cc
+@@ -2210,7 +2210,7 @@ TEST(UtilTest, MacMaybeMLockTest) {
+ TEST(UtilTest, LinuxMaybeMLockTest) {
+ size_t data_len = 32;
+ void *addr = malloc(data_len);
+-#ifdef OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ #if defined(OS_ANDROID) || defined(__native_client__)
+ EXPECT_EQ(-1, Util::MaybeMLock(addr, data_len));
+ EXPECT_EQ(-1, Util::MaybeMUnlock(addr, data_len));
diff --git a/inputmethod/ibus-mozc/patches/patch-build__mozc.py b/inputmethod/ibus-mozc/patches/patch-build__mozc.py
new file mode 100644
index 00000000000..bc0d6574069
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-build__mozc.py
@@ -0,0 +1,237 @@
+$NetBSD: patch-build__mozc.py,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- build_mozc.py.orig 2012-08-31 05:36:42.000000000 +0000
++++ build_mozc.py
+@@ -60,6 +60,7 @@ from build_tools.util import GetRelPath
+ from build_tools.util import IsLinux
+ from build_tools.util import IsMac
+ from build_tools.util import IsWindows
++from build_tools.util import IsNetBSD
+ from build_tools.util import PrintErrorAndExit
+ from build_tools.util import RemoveDirectoryRecursively
+ from build_tools.util import RemoveFile
+@@ -111,6 +112,8 @@ def GetBuildBaseName(options, target_pla
+ build_base = 'out_mac'
+ elif target_platform == 'Linux' or target_platform == 'ChromeOS':
+ build_base = 'out_linux'
++ elif target_platform == 'NetBSD':
++ build_base = 'out_bsd'
+ elif target_platform == 'Android':
+ build_base = 'out_android'
+ elif target_platform == 'NaCl':
+@@ -208,7 +211,7 @@ def GetGypFileNames(options):
+ if IsWindows():
+ gyp_file_names.extend(glob.glob('%s/win32/*/*.gyp' % SRC_DIR))
+ gyp_file_names.extend(glob.glob('third_party/breakpad/*.gyp'))
+- elif IsLinux():
++ elif IsLinux() or IsNetBSD():
+ gyp_file_names.extend(glob.glob('%s/unix/*/*.gyp' % SRC_DIR))
+ # Add ibus.gyp if ibus version is >=1.4.1.
+ if not PkgExists('ibus-1.0 >= 1.4.1'):
+@@ -274,6 +277,7 @@ def AddCommonOptions(parser):
+ help='Specifies the base directory of the built binaries.')
+ parser.add_option('--language', dest='language', default='japanese',
+ help='Specify the target language to build.')
++ parser.add_option('--os', dest='os', default='linux')
+ return parser
+
+
+@@ -284,6 +288,8 @@ def AddTargetPlatformOption(parser):
+ # If you want Android build, specify "Android".
+ if IsLinux():
+ default_target = 'Linux'
++ elif IsNetBSD():
++ default_target = 'NetBSD'
+ elif IsWindows():
+ default_target = 'Windows'
+ elif IsMac():
+@@ -413,7 +419,7 @@ def ParseGypOptions(args=None, values=No
+ use_zinnia_default = True
+
+ parser.add_option('--server_dir', dest='server_dir',
+- default='/usr/lib/mozc',
++ default='@PREFIX@/libexec',
+ help='A path to the directory to be installed server '
+ 'executable. This option is only available for Linux.')
+
+@@ -467,6 +473,12 @@ def ExpandMetaTarget(meta_target_name):
+ '%s/gui/gui.gyp:mozc_tool']
+ if PkgExists('ibus-1.0 >= 1.4.1'):
+ targets.append('%s/unix/ibus/ibus.gyp:ibus_mozc')
++ elif target_platform == 'NetBSD':
++ targets = ['%s/server/server.gyp:mozc_server',
++ '%s/renderer/renderer.gyp:mozc_renderer',
++ '%s/gui/gui.gyp:mozc_tool']
++ if PkgExists('ibus-1.0 >= 1.4.1'):
++ targets.append('%s/unix/ibus/ibus.gyp:ibus_mozc')
+ elif target_platform == 'Mac':
+ targets = ['%s/mac/mac.gyp:DiskImage']
+ elif target_platform == 'Windows':
+@@ -481,7 +493,7 @@ def ParseBuildOptions(args=None, values=
+ """Parses command line options for the build command."""
+ parser = optparse.OptionParser(usage='Usage: %prog build [options]')
+ AddCommonOptions(parser)
+- if IsLinux():
++ if IsLinux() or IsNetBSD():
+ default_build_concurrency = GetNumberOfProcessors() * 2
+ parser.add_option('--jobs', '-j', dest='jobs',
+ default=('%d' % default_build_concurrency),
+@@ -501,7 +513,7 @@ def ParseRunTestsOptions(args=None, valu
+ parser = optparse.OptionParser(
+ usage='Usage: %prog runtests [options] [test_targets] [-- build options]')
+ AddCommonOptions(parser)
+- if IsLinux():
++ if IsLinux() or IsNetBSD():
+ default_build_concurrency = GetNumberOfProcessors() * 2
+ parser.add_option('--jobs', '-j', dest='jobs',
+ default=('%d' % default_build_concurrency),
+@@ -634,6 +646,8 @@ def GypMain(options, unused_args):
+ command_line.extend(['-D', 'wix_dir=%s' % options.wix_dir])
+ else:
+ command_line.extend(['-D', 'use_wix=NO'])
++ if options.os:
++ command_line.extend(['-D', 'OS=%s' % options.os])
+
+ command_line.extend(['-D', 'android_arch_abi=%s' % options.android_arch_abi])
+ command_line.extend(['-D', 'android_application_id=%s' %
+@@ -669,7 +683,7 @@ def GypMain(options, unused_args):
+
+ def SetCommandLineForFeature(option_name, windows=False, mac=False,
+ linux=False, chromeos=False, android=False,
+- nacl=False):
++ nacl=False, netbsd=False):
+ """Updates an option like '--enable_foober' and add a -D argument for gyp.
+
+ This function ensures an option like '--enable_foober' exists and it has a
+@@ -693,6 +707,8 @@ def GypMain(options, unused_args):
+ option on Android platform.
+ nacl: A boolean which replesents the default value of the target
+ option on NaCl.
++ netbsd: boolean which replesents the default value of the target option
++ on NetBSD platform.
+
+ Raises:
+ ValueError: An error occurred when 'option_name' is empty.
+@@ -706,6 +722,7 @@ def GypMain(options, unused_args):
+ 'Linux': linux,
+ 'ChromeOS': chromeos,
+ 'Android': android,
++ 'NetBSD' : netbsd,
+ 'NaCl': nacl}[options.target_platform]
+ enable_option_name = 'enable_%s' % option_name
+ enabled = options.ensure_value(enable_option_name, default_enabled)
+@@ -719,14 +736,17 @@ def GypMain(options, unused_args):
+ SetCommandLineForFeature(option_name='webservice_infolist')
+ SetCommandLineForFeature(option_name='cloud_sync',
+ linux=is_official_dev,
++ netbsd=is_official_dev,
+ windows=is_official_dev,
+ mac=is_official_dev)
+ SetCommandLineForFeature(option_name='cloud_handwriting',
+ linux=is_official_dev,
++ netbsd=is_official_dev,
+ windows=is_official_dev,
+ mac=is_official_dev)
+ SetCommandLineForFeature(option_name='http_client',
+ linux=is_official,
++ netbsd=is_official,
+ windows=is_official,
+ mac=is_official,
+ chromeos=False, # not supported.
+@@ -735,6 +755,7 @@ def GypMain(options, unused_args):
+ windows=True,
+ mac=True,
+ linux=True,
++ netbsd=True,
+ chromeos=True,
+ android=True,
+ nacl=True)
+@@ -769,7 +790,7 @@ def GypMain(options, unused_args):
+ else:
+ command_line.extend(['-D', 'use_zinnia=NO'])
+
+- if IsLinux():
++ if IsLinux() or IsNetBSD():
+ if '%s/unix/ibus/ibus.gyp' % SRC_DIR in gyp_file_names:
+ command_line.extend(['-D', 'use_libibus=1'])
+
+@@ -790,7 +811,7 @@ def GypMain(options, unused_args):
+ # command for pkg-config. Here we catch the environment variable
+ # and use the specified command instead of actual pkg-config
+ # command.
+- if IsLinux():
++ if IsLinux() or IsNetBSD():
+ command_line.extend(['-D', 'pkg_config_command=%s' % GetPkgConfigCommand()])
+ else:
+ command_line.extend(['-D', 'pkg_config_command='])
+@@ -927,6 +948,41 @@ def BuildOnMac(options, targets, origina
+ '-parallelizeTargets',
+ 'BUILD_WITH_GYP=1'])
+
++def BuildOnBSD(options, targets, unused_original_directory_name):
++ """Build the targets on *BSD."""
++ target_names = []
++ for target in targets:
++ (unused_gyp_file_name, target_name) = (
++ CanonicalTargetToGypFileAndTargetName(target))
++ target_names.append(target_name)
++
++ make_command = os.getenv('BUILD_COMMAND', 'gmake')
++
++ envvars = [
++ 'CFLAGS',
++ 'CXXFLAGS',
++ 'CXX',
++ 'CC',
++ 'AR',
++ 'AS',
++ 'RANLIB',
++ 'LD',
++ ]
++ for envvar in envvars:
++ if envvar in os.environ:
++ os.environ[envvar] = os.getenv(envvar)
++
++ # set output directory
++ os.environ['builddir_name'] = 'out_bsd'
++
++ build_args = ['-j%s' % options.jobs,
++ 'MAKE_JOBS=%s' % options.jobs,
++ 'BUILDTYPE=%s' % options.configuration]
++ build_args.append('builddir_name=%s' %
++ GetBuildBaseName(options,
++ GetMozcVersion().GetTargetPlatform()))
++
++ RunOrDie([make_command] + build_args + target_names)
+
+ def LocateMSBuildDir():
+ """Locate the directory where msbuild.exe exists.
+@@ -1079,6 +1135,8 @@ def BuildMain(options, targets, original
+ BuildOnMac(options, targets, original_directory_name)
+ elif IsLinux():
+ BuildOnLinux(options, targets, original_directory_name)
++ elif IsNetBSD():
++ BuildOnBSD(options, targets, original_directory_name)
+ elif IsWindows():
+ BuildOnWindows(options, targets, original_directory_name)
+ else:
+@@ -1350,7 +1408,7 @@ def CleanBuildFilesAndDirectories(option
+ elif IsMac():
+ directory_names.extend(glob.glob(os.path.join(gyp_directory_name,
+ '*.xcodeproj')))
+- elif IsLinux():
++ elif IsLinux() or IsNetBSD():
+ file_names.extend(glob.glob(os.path.join(gyp_directory_name,
+ '*.target.mk')))
+ file_names.extend(glob.glob(os.path.join(gyp_directory_name,
+@@ -1377,6 +1435,10 @@ def CleanBuildFilesAndDirectories(option
+ file_names.append('Makefile')
+ elif IsWindows():
+ file_names.append('third_party/breakpad/breakpad.gyp')
++ directory_names.append('out_win')
++ elif IsNetBSD():
++ file_names.append('Makefile')
++ directory_names.append('out_bsd')
+ # Remove files.
+ for file_name in file_names:
+ RemoveFile(file_name)
diff --git a/inputmethod/ibus-mozc/patches/patch-build__tools_mozc__version.py b/inputmethod/ibus-mozc/patches/patch-build__tools_mozc__version.py
new file mode 100644
index 00000000000..f1517c8e3d3
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-build__tools_mozc__version.py
@@ -0,0 +1,12 @@
+$NetBSD: patch-build__tools_mozc__version.py,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- build_tools/mozc_version.py.orig 2012-08-31 05:37:06.000000000 +0000
++++ build_tools/mozc_version.py
+@@ -65,6 +65,7 @@ TARGET_PLATFORM_TO_DIGIT = {
+ 'ChromeOS': '2',
+ 'Android': '3',
+ 'NaCl': '4',
++ 'NetBSD': '5',
+ }
+
+ VERSION_PROPERTIES = [
diff --git a/inputmethod/ibus-mozc/patches/patch-build__tools_util.py b/inputmethod/ibus-mozc/patches/patch-build__tools_util.py
new file mode 100644
index 00000000000..1104cec7e59
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-build__tools_util.py
@@ -0,0 +1,15 @@
+$NetBSD: patch-build__tools_util.py,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- build_tools/util.py.orig 2012-08-31 05:37:06.000000000 +0000
++++ build_tools/util.py
+@@ -56,6 +56,10 @@ def IsLinux():
+ """Returns true if the platform is Linux."""
+ return os.name == 'posix' and os.uname()[0] == 'Linux'
+
++def IsNetBSD():
++ """Returns true if the platform is Linux."""
++ return os.name == 'posix' and os.uname()[0] == 'NetBSD'
++
+
+ def GetNumberOfProcessors():
+ """Returns the number of CPU cores available.
diff --git a/inputmethod/ibus-mozc/patches/patch-client_client.cc b/inputmethod/ibus-mozc/patches/patch-client_client.cc
new file mode 100644
index 00000000000..9c6fae3b90f
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-client_client.cc
@@ -0,0 +1,22 @@
+$NetBSD: patch-client_client.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- client/client.cc.orig 2012-08-31 05:36:43.000000000 +0000
++++ client/client.cc
+@@ -934,7 +934,7 @@ bool Client::LaunchTool(const string &mo
+ return false;
+ }
+
+-#if defined(OS_WINDOWS) || defined(OS_LINUX)
++#if defined(OS_WINDOWS) || defined(OS_LINUX) || defined(OS_NETBSD)
+ string arg = "--mode=" + mode;
+ if (!extra_arg.empty()) {
+ arg += " ";
+@@ -944,7 +944,7 @@ bool Client::LaunchTool(const string &mo
+ LOG(ERROR) << "Cannot execute: " << kMozcTool << " " << arg;
+ return false;
+ }
+-#endif // OS_WINDOWS || OS_LINUX
++#endif // OS_WINDOWS || OS_LINUX || OS_NETBSD
+
+ // TODO(taku): move MacProcess inside SpawnMozcProcess.
+ // TODO(taku): support extra_arg.
diff --git a/inputmethod/ibus-mozc/patches/patch-config_stats__config__util__test.cc b/inputmethod/ibus-mozc/patches/patch-config_stats__config__util__test.cc
new file mode 100644
index 00000000000..1f108cc8676
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-config_stats__config__util__test.cc
@@ -0,0 +1,20 @@
+$NetBSD: patch-config_stats__config__util__test.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- config/stats_config_util_test.cc.orig 2012-08-31 05:36:42.000000000 +0000
++++ config/stats_config_util_test.cc
+@@ -708,13 +708,13 @@ TEST(StatsConfigUtilTestAndroid, Default
+ }
+ #endif // OS_ANDROID
+
+-#ifdef OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ #ifndef OS_ANDROID
+ TEST(StatsConfigUtilTestLinux, DefaultValueTest) {
+ EXPECT_FALSE(StatsConfigUtil::IsEnabled());
+ }
+ #endif // OS_ANDROID
+-#endif // OS_LINUX
++#endif // OS_LINUX || OS_NETBSD
+
+ #else // !GOOGLE_JAPANESE_INPUT_BUILD
+ TEST(StatsConfigUtilTestNonOfficialBuild, DefaultValueTest) {
diff --git a/inputmethod/ibus-mozc/patches/patch-gui_base_locale__util.cc b/inputmethod/ibus-mozc/patches/patch-gui_base_locale__util.cc
new file mode 100644
index 00000000000..d20ca3a99dc
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-gui_base_locale__util.cc
@@ -0,0 +1,13 @@
+$NetBSD: patch-gui_base_locale__util.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- gui/base/locale_util.cc.orig 2012-08-31 05:37:21.000000000 +0000
++++ gui/base/locale_util.cc
+@@ -206,7 +206,7 @@ TranslationDataImpl::TranslationDataImpl
+ qApp->installEventFilter(&window_title_modifier_);
+ #endif // MOZC_SHOW_BUILD_NUMBER_ON_TITLE
+
+-#ifdef OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ // Use system default messages.
+ // Even if the locale is not English nor Japanese, load translation
+ // file to translate common messages like "OK" and "Cancel".
diff --git a/inputmethod/ibus-mozc/patches/patch-gui_config__dialog_config__dialog.cc b/inputmethod/ibus-mozc/patches/patch-gui_config__dialog_config__dialog.cc
new file mode 100644
index 00000000000..60a8dbeb604
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-gui_config__dialog_config__dialog.cc
@@ -0,0 +1,57 @@
+$NetBSD: patch-gui_config__dialog_config__dialog.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- gui/config_dialog/config_dialog.cc.orig 2012-08-31 05:37:09.000000000 +0000
++++ gui/config_dialog/config_dialog.cc
+@@ -83,21 +83,21 @@ ConfigDialog::ConfigDialog()
+ miscAdministrationWidget->setVisible(false);
+ #endif // OS_MACOSX
+
+-#if defined(OS_LINUX)
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ miscDefaultIMEWidget->setVisible(false);
+ miscAdministrationWidget->setVisible(false);
+ miscStartupWidget->setVisible(false);
+-#endif // OS_LINUX
++#endif // OS_LINUX || OS_NETBSD
+
+ #ifdef NO_LOGGING
+ // disable logging options
+ miscLoggingWidget->setVisible(false);
+
+-#if defined(OS_LINUX)
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ // The last "misc" tab has no valid configs on Linux
+ const int kMiscTabIndex = 6;
+ configDialogTabWidget->removeTab(kMiscTabIndex);
+-#endif // OS_LINUX
++#endif // OS_LINUX || OS_NETBSD
+ #endif // NO_LOGGING
+
+ #ifndef ENABLE_CLOUD_SYNC
+@@ -322,7 +322,7 @@ ConfigDialog::ConfigDialog()
+ dictionaryPreloadingAndUACLabel->setVisible(false);
+ #endif // OS_WINDOWS
+
+-#ifdef OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ // On Linux, disable all fields for UsageStats
+ usageStatsLabel->setEnabled(false);
+ usageStatsLabel->setVisible(false);
+@@ -332,7 +332,7 @@ ConfigDialog::ConfigDialog()
+ usageStatsMessage->setVisible(false);
+ usageStatsCheckBox->setEnabled(false);
+ usageStatsCheckBox->setVisible(false);
+-#endif // OS_LINUX
++#endif // OS_LINUX || OS_NETBSD
+
+ webUsageDictionaryCheckBox->setVisible(false);
+ editWebServiceEntryButton->setVisible(false);
+@@ -438,7 +438,7 @@ bool ConfigDialog::Update() {
+ }
+
+
+-#if defined(OS_WINDOWS) || defined(OS_LINUX)
++#if defined(OS_WINDOWS) || defined(OS_LINUX) || defined(OS_NETBSD)
+ if (initial_preedit_method_ !=
+ static_cast<int>(config.preedit_method()) ||
+ initial_use_keyboard_to_change_preedit_method_ !=
diff --git a/inputmethod/ibus-mozc/patches/patch-gui_config__dialog_keybinding__editor.cc b/inputmethod/ibus-mozc/patches/patch-gui_config__dialog_keybinding__editor.cc
new file mode 100644
index 00000000000..2a8750940a5
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-gui_config__dialog_keybinding__editor.cc
@@ -0,0 +1,40 @@
+$NetBSD: patch-gui_config__dialog_keybinding__editor.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- gui/config_dialog/keybinding_editor.cc.orig 2012-08-31 05:37:09.000000000 +0000
++++ gui/config_dialog/keybinding_editor.cc
+@@ -33,7 +33,7 @@
+ #include <windows.h>
+ #include <imm.h>
+ #include <ime.h>
+-#elif OS_LINUX
++#elif defined(OS_LINUX) || defined(OS_NETBSD)
+ #define XK_MISCELLANY
+ #include <X11/keysymdef.h>
+ #endif
+@@ -121,7 +121,7 @@ const WinVirtualKeyEntry kWinVirtualKeyM
+ { VK_DBE_DBCSCHAR, "Hankaku/Zenkaku" }, // Zenkaku/hankaku
+ // { VK_KANJI, "Kanji" }, // Do not support Kanji
+ };
+-#elif OS_LINUX
++#elif defined(OS_LINUX) || defined(OS_NETBSD)
+ struct LinuxVirtualKeyEntry {
+ uint16 virtual_key;
+ const char *mozc_key_name;
+@@ -390,7 +390,7 @@ KeyBindingFilter::KeyState KeyBindingFil
+ return Encode(result);
+ }
+ }
+-#elif OS_LINUX
++#elif defined(OS_LINUX) || defined(OS_NETBSD)
+ const uint16 virtual_key = key_event.nativeVirtualKey();
+
+ // The XKB defines three types of logical key code: "xkb::Hiragana",
+@@ -500,7 +500,7 @@ bool KeyBindingFilter::eventFilter(QObje
+ KeyBindingEditor::KeyBindingEditor(QWidget *parent, QWidget *trigger_parent)
+ : QDialog(parent), trigger_parent_(trigger_parent) {
+ setupUi(this);
+-#ifdef OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ // Workaround for the issue http://code.google.com/p/mozc/issues/detail?id=9
+ // Seems that even after clicking the button for the keybinding dialog,
+ // the edit is not raised. This might be a bug of setFocusProxy.
diff --git a/inputmethod/ibus-mozc/patches/patch-gui_config__dialog_keymap__editor.cc b/inputmethod/ibus-mozc/patches/patch-gui_config__dialog_keymap__editor.cc
new file mode 100644
index 00000000000..0fdf0d1b99d
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-gui_config__dialog_keymap__editor.cc
@@ -0,0 +1,13 @@
+$NetBSD: patch-gui_config__dialog_keymap__editor.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- gui/config_dialog/keymap_editor.cc.orig 2012-08-31 05:37:12.000000000 +0000
++++ gui/config_dialog/keymap_editor.cc
+@@ -447,7 +447,7 @@ bool KeyMapEditorDialog::Update() {
+ *keymap_table += invisible_keymap_table_;
+
+ if (new_ime_switch_keymap != ime_switch_keymap_) {
+-#if defined(OS_WINDOWS) || defined(OS_LINUX)
++#if defined(OS_WINDOWS) || defined(OS_LINUX) || defined(OS_NETBSD)
+ QMessageBox::information(
+ this,
+ tr("Mozc settings"),
diff --git a/inputmethod/ibus-mozc/patches/patch-gui_dictionary__tool_dictionary__tool.cc b/inputmethod/ibus-mozc/patches/patch-gui_dictionary__tool_dictionary__tool.cc
new file mode 100644
index 00000000000..736fc20ee11
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-gui_dictionary__tool_dictionary__tool.cc
@@ -0,0 +1,13 @@
+$NetBSD: patch-gui_dictionary__tool_dictionary__tool.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- gui/dictionary_tool/dictionary_tool.cc.orig 2012-08-31 05:37:14.000000000 +0000
++++ gui/dictionary_tool/dictionary_tool.cc
+@@ -339,7 +339,7 @@ DictionaryTool::DictionaryTool(QWidget *
+ }
+
+ // main window
+-#ifndef OS_LINUX
++#if !defined(OS_LINUX) && !defined(OS_NETBSD)
+ // For some reason setCentralWidget crashes the dictionary_tool on Linux
+ // TODO(taku): investigate the cause of the crashes
+ setCentralWidget(splitter_);
diff --git a/inputmethod/ibus-mozc/patches/patch-gui_gui.gyp b/inputmethod/ibus-mozc/patches/patch-gui_gui.gyp
new file mode 100644
index 00000000000..fe195c6102c
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-gui_gui.gyp
@@ -0,0 +1,13 @@
+$NetBSD: patch-gui_gui.gyp,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- gui/gui.gyp.orig 2012-08-31 05:36:43.000000000 +0000
++++ gui/gui.gyp
+@@ -387,7 +387,7 @@
+ '../session/session_base.gyp:session_protocol',
+ ],
+ }],
+- ['use_libzinnia==1 and OS=="linux"', {
++ ['use_libzinnia==1 and (OS=="linux" or OS=="netbsd")', {
+ 'defines': [
+ 'USE_LIBZINNIA',
+ ],
diff --git a/inputmethod/ibus-mozc/patches/patch-gui_qt__libraries.gypi b/inputmethod/ibus-mozc/patches/patch-gui_qt__libraries.gypi
new file mode 100644
index 00000000000..cb1ab2a479f
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-gui_qt__libraries.gypi
@@ -0,0 +1,13 @@
+$NetBSD: patch-gui_qt__libraries.gypi,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- gui/qt_libraries.gypi.orig 2012-08-31 05:36:43.000000000 +0000
++++ gui/qt_libraries.gypi
+@@ -84,7 +84,7 @@
+ '$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
+ ]
+ }],
+- ['OS=="linux"', {
++ ['OS=="linux" or OS=="netbsd"', {
+ 'conditions': [
+ ['qt_dir', {
+ 'libraries': [
diff --git a/inputmethod/ibus-mozc/patches/patch-gui_word__register__dialog_word__register__dialog.cc b/inputmethod/ibus-mozc/patches/patch-gui_word__register__dialog_word__register__dialog.cc
new file mode 100644
index 00000000000..6f80dd8331e
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-gui_word__register__dialog_word__register__dialog.cc
@@ -0,0 +1,13 @@
+$NetBSD: patch-gui_word__register__dialog_word__register__dialog.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- gui/word_register_dialog/word_register_dialog.cc.orig 2012-08-31 05:37:28.000000000 +0000
++++ gui/word_register_dialog/word_register_dialog.cc
+@@ -81,7 +81,7 @@ QString GetEnv(const char *envname) {
+ }
+ return "";
+ #endif // OS_WINDOWS
+-#if defined(OS_MACOSX) || defined(OS_LINUX)
++#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_NETBSD)
+ return ::getenv(envname);
+ #endif // OS_MACOSX or OS_LINUX
+ // TODO(team): Support other platforms.
diff --git a/inputmethod/ibus-mozc/patches/patch-gui_zinnia.gyp b/inputmethod/ibus-mozc/patches/patch-gui_zinnia.gyp
new file mode 100644
index 00000000000..da0a1fc731f
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-gui_zinnia.gyp
@@ -0,0 +1,13 @@
+$NetBSD: patch-gui_zinnia.gyp,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- gui/zinnia.gyp.orig 2012-08-31 05:36:43.000000000 +0000
++++ gui/zinnia.gyp
+@@ -48,7 +48,7 @@
+ '-Wno-type-limits',
+ ],
+ 'conditions': [
+- ['OS=="linux"', {
++ ['OS=="linux" or OS=="netbsd"', {
+ 'conditions': [
+ ['use_libzinnia==1', {
+ 'link_settings': {
diff --git a/inputmethod/ibus-mozc/patches/patch-gyp_common.gypi b/inputmethod/ibus-mozc/patches/patch-gyp_common.gypi
new file mode 100644
index 00000000000..37fb09e76b8
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-gyp_common.gypi
@@ -0,0 +1,54 @@
+$NetBSD: patch-gyp_common.gypi,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- gyp/common.gypi.orig 2012-08-31 05:36:43.000000000 +0000
++++ gyp/common.gypi
+@@ -283,12 +283,12 @@
+ # additional suffix except for Japanese so that multiple
+ # converter processes can coexist. Note that Mozc on ChromeOS does
+ # not use IPC so this kind of special treatment is not required.
+- ['language!="japanese" and target_platform=="Linux"', {
++ ['language!="japanese" and target_platform=="Linux" or target_platform=="NetBSD"', {
+ 'defines': [
+ 'MOZC_LANGUAGE_SUFFIX_FOR_LINUX="_<(language)"',
+ ],
+ }],
+- ['OS=="linux"', {
++ ['OS=="linux" or OS=="netbsd"', {
+ 'ldflags': [
+ '<@(linux_ldflags)',
+ ],
+@@ -438,7 +438,7 @@
+ },
+ },
+ 'conditions': [
+- ['OS=="linux"', {
++ ['OS=="linux" or OS=="netbsd"', {
+ 'cflags': [
+ '<@(debug_extra_cflags)',
+ ],
+@@ -476,7 +476,7 @@
+ },
+ },
+ 'conditions': [
+- ['OS=="linux"', {
++ ['OS=="linux" or OS=="netbsd"', {
+ 'cflags': [
+ '<@(release_extra_cflags)',
+ ],
+@@ -789,6 +789,16 @@
+ }],
+ ],
+ }],
++ ['OS=="netbsd"', {
++ 'defines': [
++ 'OS_NETBSD',
++ ],
++ 'cflags': [
++ '<@(gcc_cflags)',
++ '-fPIC',
++ '-fno-exceptions',
++ ],
++ }],
+ ['OS=="mac"', {
+ 'defines': [
+ 'OS_MACOSX',
diff --git a/inputmethod/ibus-mozc/patches/patch-handwriting_handwriting.gyp b/inputmethod/ibus-mozc/patches/patch-handwriting_handwriting.gyp
new file mode 100644
index 00000000000..c0b2c1368e8
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-handwriting_handwriting.gyp
@@ -0,0 +1,13 @@
+$NetBSD: patch-handwriting_handwriting.gyp,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- handwriting/handwriting.gyp.orig 2012-08-31 05:37:06.000000000 +0000
++++ handwriting/handwriting.gyp
+@@ -39,7 +39,7 @@
+ '../base/base.gyp:base',
+ '../gui/zinnia.gyp:zinnia',
+ ],
+- 'conditions': [['use_libzinnia==1 and OS=="linux"', {
++ 'conditions': [['use_libzinnia==1 and OS=="linux" or OS=="netbsd"', {
+ 'defines': [
+ 'USE_LIBZINNIA',
+ ],
diff --git a/inputmethod/ibus-mozc/patches/patch-handwriting_zinnia__handwriting.cc b/inputmethod/ibus-mozc/patches/patch-handwriting_zinnia__handwriting.cc
new file mode 100644
index 00000000000..225e106b819
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-handwriting_zinnia__handwriting.cc
@@ -0,0 +1,15 @@
+$NetBSD: patch-handwriting_zinnia__handwriting.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+* Not confirmed yet.
+
+--- handwriting/zinnia_handwriting.cc.orig 2012-08-31 05:37:06.000000000 +0000
++++ handwriting/zinnia_handwriting.cc
+@@ -52,7 +52,7 @@ string GetModelFileName() {
+ #elif defined(USE_LIBZINNIA)
+ // On Linux, use the model for tegaki-zinnia.
+ const char kModelFile[] =
+- "/usr/share/tegaki/models/zinnia/handwriting-ja.model";
++ "@PREFIX@/share/tegaki/models/zinnia/handwriting-ja.model";
+ return kModelFile;
+ #else
+ const char kModelFile[] = "handwriting-ja.model";
diff --git a/inputmethod/ibus-mozc/patches/patch-ipc_ipc__path__manager.cc b/inputmethod/ibus-mozc/patches/patch-ipc_ipc__path__manager.cc
new file mode 100644
index 00000000000..443b01cd51d
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-ipc_ipc__path__manager.cc
@@ -0,0 +1,69 @@
+$NetBSD: patch-ipc_ipc__path__manager.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- ipc/ipc_path_manager.cc.orig 2012-08-31 05:37:07.000000000 +0000
++++ ipc/ipc_path_manager.cc
+@@ -48,6 +48,11 @@
+ #include "base/mac_util.h"
+ #endif
+
++#if defined(OS_NETBSD)
++#include <sys/param.h>
++#include <sys/sysctl.h>
++#endif
++
+ #include "base/base.h"
+ #include "base/const.h"
+ #include "base/file_stream.h"
+@@ -284,7 +289,7 @@ bool IPCPathManager::GetPathName(string
+ *ipc_name = kIPCPrefix;
+ #endif // OS_WINDOWS
+
+-#ifdef OS_LINUX
++#if defined(OS_LINUX)
+ // On Linux, use abstract namespace which is independent of the file system.
+ (*ipc_name)[0] = '\0';
+ #endif
+@@ -360,7 +365,7 @@ bool IPCPathManager::IsValidServer(uint3
+ }
+ #endif
+
+-#ifdef OS_MACOSX
++#if defined(OS_MACOSX)
+ int name[] = { CTL_KERN, KERN_PROCARGS, pid };
+ size_t data_len = 0;
+ if (sysctl(name, arraysize(name), NULL,
+@@ -377,7 +382,24 @@ bool IPCPathManager::IsValidServer(uint3
+ }
+ #endif
+
+-#ifdef OS_LINUX
++#if defined(OS_NETBSD)
++ int name[] = { CTL_KERN, KERN_PROC_ARGS, pid };
++ size_t data_len = 0;
++ if (sysctl(name, arraysize(name), NULL,
++ &data_len, NULL, 0) < 0) {
++ LOG(ERROR) << "sysctl KERN_PROC_ARGS failed";
++ return false;
++ }
++
++ server_path_.resize(data_len);
++ if (sysctl(name, arraysize(name), &server_path_[0],
++ &data_len, NULL, 0) < 0) {
++ LOG(ERROR) << "sysctl KERN_PROC_ARGS failed";
++ return false;
++ }
++#endif
++
++#if defined(OS_LINUX)
+ // load from /proc/<pid>/exe
+ char proc[128];
+ char filename[512];
+@@ -397,7 +419,7 @@ bool IPCPathManager::IsValidServer(uint3
+ return true;
+ }
+
+-#ifdef OS_LINUX
++#if defined(OS_LINUX)
+ if ((server_path + " (deleted)") == server_path_) {
+ LOG(WARNING) << server_path << " on disk is modified";
+ // If a user updates the server binary on disk during the server is running,
diff --git a/inputmethod/ibus-mozc/patches/patch-ipc_ipc__path__manager__test.cc b/inputmethod/ibus-mozc/patches/patch-ipc_ipc__path__manager__test.cc
new file mode 100644
index 00000000000..bf5fa31b69f
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-ipc_ipc__path__manager__test.cc
@@ -0,0 +1,13 @@
+$NetBSD: patch-ipc_ipc__path__manager__test.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- ipc/ipc_path_manager_test.cc.orig 2012-08-31 05:37:07.000000000 +0000
++++ ipc/ipc_path_manager_test.cc
+@@ -102,7 +102,7 @@ TEST_F(IPCPathManagerTest, IPCPathManage
+ EXPECT_FALSE(manager->GetServerProductVersion().empty());
+ EXPECT_GT(manager->GetServerProcessId(), 0);
+ EXPECT_EQ(t.path(), path);
+-#ifdef OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ // On Linux, |path| should be abstract (see man unix(7) for details.)
+ ASSERT_FALSE(path.empty());
+ EXPECT_EQ('\0', path[0]);
diff --git a/inputmethod/ibus-mozc/patches/patch-ipc_named__event.cc b/inputmethod/ibus-mozc/patches/patch-ipc_named__event.cc
new file mode 100644
index 00000000000..1900cc3360d
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-ipc_named__event.cc
@@ -0,0 +1,15 @@
+$NetBSD: patch-ipc_named__event.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+* sem_open(..., 0) is not supported for NetBSD at least.
+
+--- ipc/named_event.cc.orig 2012-08-31 05:37:07.000000000 +0000
++++ ipc/named_event.cc
+@@ -337,7 +337,7 @@ int NamedEventListener::WaitEventOrProce
+ NamedEventNotifier::NamedEventNotifier(const char *name)
+ : sem_(SEM_FAILED) {
+ const string key_filename = NamedEventUtil::GetEventPath(name);
+- sem_ = ::sem_open(key_filename.c_str(), 0);
++ sem_ = ::sem_open(key_filename.c_str(), O_CREAT);
+ if (sem_ == SEM_FAILED) {
+ LOG(ERROR) << "sem_open failed: " << ::strerror(errno);
+ }
diff --git a/inputmethod/ibus-mozc/patches/patch-ipc_unix__ipc.cc b/inputmethod/ibus-mozc/patches/patch-ipc_unix__ipc.cc
new file mode 100644
index 00000000000..5c96f1cb832
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-ipc_unix__ipc.cc
@@ -0,0 +1,77 @@
+$NetBSD: patch-ipc_unix__ipc.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- ipc/unix_ipc.cc.orig 2012-08-31 05:37:07.000000000 +0000
++++ ipc/unix_ipc.cc
+@@ -28,7 +28,7 @@
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ // skip all if non-Linux or Android.
+-#if defined(OS_LINUX) && !defined(OS_ANDROID)
++#if (defined(OS_LINUX) && !defined(OS_ANDROID)) || defined(OS_NETBSD)
+
+ #include "ipc/ipc.h"
+
+@@ -41,7 +41,7 @@
+ #include <sys/time.h>
+ #include <sys/types.h>
+ #include <sys/un.h>
+-#ifdef OS_MACOSX
++#if defined(OS_MACOSX) || defined(OS_NETBSD)
+ #include <sys/ucred.h>
+ #endif
+ #include <sys/wait.h>
+@@ -171,6 +171,22 @@ bool IsPeerValid(int socket, pid_t *pid)
+ #endif // __arm__
+ #endif
+
++#if defined(OS_NETBSD)
++ struct unpcbid peer_cred;
++ int peer_cred_len = sizeof(peer_cred);
++ if (getsockopt(socket, 0, LOCAL_PEEREID,
++ reinterpret_cast<void *>(&peer_cred),
++ reinterpret_cast<socklen_t *>(&peer_cred_len)) < 0) {
++ LOG(ERROR) << "cannot get peer credential. Not a Unix socket?";
++ return false;
++ }
++
++ if (peer_cred.unp_euid!= ::geteuid()) {
++ LOG(WARNING) << "uid mismatch." << peer_cred.unp_euid << "!=" << ::geteuid();
++ return false;
++ }
++#endif
++
+ return true;
+ }
+
+@@ -310,9 +326,11 @@ void IPCClient::Init(const string &name,
+ address.sun_family = AF_UNIX;
+ ::memcpy(address.sun_path, server_address.data(), server_address_length);
+ address.sun_path[server_address_length] = '\0';
+-#ifdef OS_MACOSX
++#if defined(OS_MACOSX)
+ address.sun_len = SUN_LEN(&address);
+ const size_t sun_len = sizeof(address);
++#elif defined(OS_NETBSD)
++ size_t sun_len = SUN_LEN(&address);
+ #else
+ const size_t sun_len = sizeof(address.sun_family) + server_address_length;
+ #endif
+@@ -435,9 +453,11 @@ IPCServer::IPCServer(const string &name,
+ SO_REUSEADDR,
+ reinterpret_cast<char *>(&on),
+ sizeof(on));
+-#ifdef OS_MACOSX
++#if defined(OS_MACOSX)
+ addr.sun_len = SUN_LEN(&addr);
+ const size_t sun_len = sizeof(addr);
++#elif defined(OS_NETBSD)
++ size_t sun_len = SUN_LEN(&addr);
+ #else
+ const size_t sun_len = sizeof(addr.sun_family) + server_address_.size();
+ #endif
+@@ -534,4 +554,4 @@ void IPCServer::Terminate() {
+
+ }; // namespace mozc
+
+-#endif // OS_LINUX && !OS_ANDROID
++#endif // (OS_LINUX && !OS_ANDROID) || OS_NETBSD
diff --git a/inputmethod/ibus-mozc/patches/patch-languages_chewing_chewing.gyp b/inputmethod/ibus-mozc/patches/patch-languages_chewing_chewing.gyp
new file mode 100644
index 00000000000..2e0fba43de0
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-languages_chewing_chewing.gyp
@@ -0,0 +1,13 @@
+$NetBSD: patch-languages_chewing_chewing.gyp,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- languages/chewing/chewing.gyp.orig 2012-08-31 05:36:42.000000000 +0000
++++ languages/chewing/chewing.gyp
+@@ -55,7 +55,7 @@
+ },
+ ],
+ 'conditions': [
+- ['OS=="linux"', {
++ ['OS=="linux" or OS=="netbsd"', {
+ 'targets': [
+ {
+ 'target_name': 'ibus_mozc_chewing',
diff --git a/inputmethod/ibus-mozc/patches/patch-languages_hangul_hangul.gyp b/inputmethod/ibus-mozc/patches/patch-languages_hangul_hangul.gyp
new file mode 100644
index 00000000000..015ff1f5ca9
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-languages_hangul_hangul.gyp
@@ -0,0 +1,13 @@
+$NetBSD: patch-languages_hangul_hangul.gyp,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- languages/hangul/hangul.gyp.orig 2012-08-31 05:36:42.000000000 +0000
++++ languages/hangul/hangul.gyp
+@@ -59,7 +59,7 @@
+ },
+ ],
+ 'conditions': [
+- ['OS=="linux"', {
++ ['OS=="linux" or OS=="netbsd"', {
+ 'targets': [
+ {
+ 'target_name': 'ibus_mozc_hangul',
diff --git a/inputmethod/ibus-mozc/patches/patch-net_net.gyp b/inputmethod/ibus-mozc/patches/patch-net_net.gyp
new file mode 100644
index 00000000000..23f527106db
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-net_net.gyp
@@ -0,0 +1,13 @@
+$NetBSD: patch-net_net.gyp,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- net/net.gyp.orig 2012-08-31 05:36:44.000000000 +0000
++++ net/net.gyp
+@@ -61,7 +61,7 @@
+ },
+ },
+ }],
+- ['target_platform=="Linux"', {
++ ['target_platform=="Linux" or OS=="netbsd"', {
+ # Enable libcurl
+ 'cflags': [
+ '<!@(<(pkg_config_command) --cflags libcurl)',
diff --git a/inputmethod/ibus-mozc/patches/patch-protobuf_genproto.gypi b/inputmethod/ibus-mozc/patches/patch-protobuf_genproto.gypi
new file mode 100644
index 00000000000..7c8edd1af96
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-protobuf_genproto.gypi
@@ -0,0 +1,20 @@
+$NetBSD: patch-protobuf_genproto.gypi,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- protobuf/genproto.gypi.orig 2012-08-31 05:37:07.000000000 +0000
++++ protobuf/genproto.gypi
+@@ -36,13 +36,13 @@
+ 'conditions': [
+ ['OS!="linux"', {
+ 'variables': {
+- 'protoc_command%': '<(relative_dir)/<(mozc_build_tools_dir)/protoc<(EXECUTABLE_SUFFIX)',
++ 'protoc_command%': 'protoc<(EXECUTABLE_SUFFIX)',
+ },
+ }, { # else
+ 'conditions': [
+ ['use_libprotobuf==0', {
+ 'variables': {
+- 'protoc_command%': '<(relative_dir)/<(mozc_build_tools_dir)/protoc<(EXECUTABLE_SUFFIX)',
++ 'protoc_command%': 'protoc<(EXECUTABLE_SUFFIX)',
+ },
+ }, { # else
+ 'variables': {
diff --git a/inputmethod/ibus-mozc/patches/patch-protobuf_protobuf.gyp b/inputmethod/ibus-mozc/patches/patch-protobuf_protobuf.gyp
new file mode 100644
index 00000000000..2d30a06c801
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-protobuf_protobuf.gyp
@@ -0,0 +1,31 @@
+$NetBSD: patch-protobuf_protobuf.gyp,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- protobuf/protobuf.gyp.orig 2012-08-31 05:37:07.000000000 +0000
++++ protobuf/protobuf.gyp
+@@ -138,7 +138,7 @@
+ },
+ 'conditions': [
+ # for gcc and clang
+- ['OS=="linux" or OS=="mac"', {
++ ['OS=="linux" or OS=="mac" or OS="netbsd"', {
+ 'cflags': [
+ '-Wno-conversion-null', # coded_stream.cc uses NULL to bool.
+ '-Wno-unused-function',
+@@ -159,7 +159,7 @@
+ '.',
+ ],
+ 'conditions': [
+- ['OS=="linux"', {
++ ['OS=="linux" or OS=="netbsd"', {
+ 'conditions': [
+ ['use_libprotobuf!=1', {
+ 'cflags': [
+@@ -196,7 +196,7 @@
+ },
+ 'conditions': [
+ # use system-installed protoc on Linux
+- ['OS!="linux"', {
++ ['OS!="linux" and OS!="netbsd"', {
+ 'includes' : [
+ '../gyp/install_build_tool.gypi',
+ ],
diff --git a/inputmethod/ibus-mozc/patches/patch-session_session.cc b/inputmethod/ibus-mozc/patches/patch-session_session.cc
new file mode 100644
index 00000000000..65c0d19a6b1
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-session_session.cc
@@ -0,0 +1,13 @@
+$NetBSD: patch-session_session.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- session/session.cc.orig 2012-08-31 05:36:43.000000000 +0000
++++ session/session.cc
+@@ -1091,7 +1091,7 @@ void Session::UpdateOperationPreferences
+ }
+
+ // Cascading Window.
+-#ifndef OS_LINUX
++#if !defined(OS_LINUX) || !defined(OS_NETBSD)
+ if (config.has_use_cascading_window()) {
+ operation_preferences.use_cascading_window = config.use_cascading_window();
+ }
diff --git a/inputmethod/ibus-mozc/patches/patch-session_session__converter__interface.h b/inputmethod/ibus-mozc/patches/patch-session_session__converter__interface.h
new file mode 100644
index 00000000000..a74a3f4beae
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-session_session__converter__interface.h
@@ -0,0 +1,13 @@
+$NetBSD: patch-session_session__converter__interface.h,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- session/session_converter_interface.h.orig 2012-08-31 05:36:43.000000000 +0000
++++ session/session_converter_interface.h
+@@ -68,7 +68,7 @@ struct OperationPreferences {
+ bool use_cascading_window;
+ string candidate_shortcuts;
+ OperationPreferences() {
+-#ifdef OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ // TODO(komatsu): Move this logic to the client code.
+ use_cascading_window = false;
+ #else
diff --git a/inputmethod/ibus-mozc/patches/patch-session_session__test.cc b/inputmethod/ibus-mozc/patches/patch-session_session__test.cc
new file mode 100644
index 00000000000..faf3b72768f
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-session_session__test.cc
@@ -0,0 +1,31 @@
+$NetBSD: patch-session_session__test.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- session/session_test.cc.orig 2012-08-31 05:36:43.000000000 +0000
++++ session/session_test.cc
+@@ -2417,7 +2417,7 @@ TEST_F(SessionTest, OutputAllCandidateWo
+
+ EXPECT_EQ(0, output.all_candidate_words().focused_index());
+ EXPECT_EQ(commands::CONVERSION, output.all_candidate_words().category());
+-#ifdef OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ // Cascading window is not supported on Linux, so the size of
+ // candidate words is different from other platform.
+ // TODO(komatsu): Modify the client for Linux to explicitly change
+@@ -2433,7 +2433,7 @@ TEST_F(SessionTest, OutputAllCandidateWo
+ // "aiueo" (t13n), "AIUEO" (t13n), "Aieuo" (t13n),
+ // "アイウエオ" (t13n) ]
+ EXPECT_EQ(11, output.all_candidate_words().candidates_size());
+-#endif // OS_LINUX
++#endif // OS_LINUX || OS_NETBSD
+ }
+
+ command.Clear();
+@@ -2445,7 +2445,7 @@ TEST_F(SessionTest, OutputAllCandidateWo
+
+ EXPECT_EQ(1, output.all_candidate_words().focused_index());
+ EXPECT_EQ(commands::CONVERSION, output.all_candidate_words().category());
+-#ifdef OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ // Cascading window is not supported on Linux, so the size of
+ // candidate words is different from other platform.
+ // TODO(komatsu): Modify the client for Linux to explicitly change
diff --git a/inputmethod/ibus-mozc/patches/patch-third__party_gyp_buildbot_buildbot__run.py b/inputmethod/ibus-mozc/patches/patch-third__party_gyp_buildbot_buildbot__run.py
new file mode 100644
index 00000000000..158eede4cfd
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-third__party_gyp_buildbot_buildbot__run.py
@@ -0,0 +1,13 @@
+$NetBSD: patch-third__party_gyp_buildbot_buildbot__run.py,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+--- third_party/gyp/buildbot/buildbot_run.py.orig 2012-02-23 21:18:54.000000000 +0000
++++ third_party/gyp/buildbot/buildbot_run.py
+@@ -74,6 +74,8 @@ def GypBuild():
+ retcode += GypTestFormat('ninja')
+ retcode += GypTestFormat('scons')
+ retcode += GypTestFormat('make')
++ elif sys.platform == 'netbsd':
++ retcode += GypTestFormat('make')
+ elif sys.platform == 'darwin':
+ retcode += GypTestFormat('ninja')
+ retcode += GypTestFormat('xcode')
diff --git a/inputmethod/ibus-mozc/patches/patch-unix_ibus_gen__mozc__xml.py b/inputmethod/ibus-mozc/patches/patch-unix_ibus_gen__mozc__xml.py
new file mode 100644
index 00000000000..95ea9b059cd
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-unix_ibus_gen__mozc__xml.py
@@ -0,0 +1,51 @@
+$NetBSD: patch-unix_ibus_gen__mozc__xml.py,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+* Fix for pkgsrc installation.
+
+--- unix/ibus/gen_mozc_xml.py.orig 2012-08-31 05:36:43.000000000 +0000
++++ unix/ibus/gen_mozc_xml.py
+@@ -48,7 +48,7 @@ IBUS_COMPONENT_PROPS = {
+ 'description': '%s Component',
+ # TODO(yusukes): Support Linux distributions other than Gentoo/ChromeOS.
+ # For example, Ubuntu uses /usr/lib/ibus-mozc/.
+- 'exec': '/usr/libexec/ibus-engine-mozc --ibus',
++ 'exec': '@PREFIX@/libexec/ibus-engine-mozc --ibus',
+ # TODO(mazda): Generate the version number.
+ 'version': '0.0.0.0',
+ 'author': 'Google Inc.',
+@@ -61,7 +61,7 @@ IBUS_COMPONENT_PROPS = {
+ IBUS_ENGINE_COMMON_PROPS = {
+ 'description': '%s (Japanese Input Method)',
+ 'language': 'ja',
+- 'icon': '/usr/share/ibus-mozc/product_icon.png',
++ 'icon': '@PREFIX@/share/ibus-mozc/product_icon.png',
+ 'rank': '80',
+ }
+
+@@ -76,6 +76,13 @@ IBUS_ENGINES_PROPS = {
+ 'longname': ['%s'],
+ 'layout': ['jp'],
+ },
++ 'NetBSD': {
++ # DO NOT change the engine name 'mozc-jp'. The names is referenced by
++ # unix/ibus/mozc_engine.cc.
++ 'name': ['mozc-jp'],
++ 'longname': ['%s'],
++ 'layout': ['jp'],
++ },
+ # On Chrome/Chromium OS, we provide three engines.
+ 'ChromeOS': {
+ # DO NOT change the engine name 'mozc-jp'. The names is referenced by
+@@ -193,7 +200,11 @@ def main():
+
+ setup_arg = []
+ if options.platform == 'Linux':
+- setup_arg.append(os.path.join(options.server_dir, 'mozc_tool'))
++ setup_arg.append(os.path.join("@PREFIX@/libexec", 'mozc_tool'))
++ setup_arg.append('--mode=config_dialog')
++
++ if options.platform == 'NetBSD':
++ setup_arg.append(os.path.join("@PREFIX@/libexec", 'mozc_tool'))
+ setup_arg.append('--mode=config_dialog')
+
+ if options.output_cpp:
diff --git a/inputmethod/ibus-mozc/patches/patch-unix_ibus_mozc__engine.cc b/inputmethod/ibus-mozc/patches/patch-unix_ibus_mozc__engine.cc
new file mode 100644
index 00000000000..38b134e245c
--- /dev/null
+++ b/inputmethod/ibus-mozc/patches/patch-unix_ibus_mozc__engine.cc
@@ -0,0 +1,15 @@
+$NetBSD: patch-unix_ibus_mozc__engine.cc,v 1.1 2013/01/18 11:36:40 ryoon Exp $
+
+* I am not sure.
+
+--- unix/ibus/mozc_engine.cc.orig 2012-08-31 05:36:43.000000000 +0000
++++ unix/ibus/mozc_engine.cc
+@@ -756,7 +756,7 @@ bool MozcEngine::ExecuteCallback(IBusEng
+ // on size_t, not uint32.
+ string selection_text;
+ const uint32 selection_start = min(cursor_pos, anchor_pos);
+- const uint32 selection_length = abs(relative_selected_length);
++ const uint32 selection_length = ::abs(relative_selected_length);
+ Util::SubString(surrounding_text,
+ selection_start,
+ selection_length,