mozc-2.16.2037.102.ebuild 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. # Copyright 1999-2015 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI="5"
  4. PYTHON_COMPAT=( python2_7 )
  5. PLOCALES="de ja zh_CN zh_TW"
  6. inherit elisp-common eutils l10n multilib multiprocessing python-single-r1 toolchain-funcs
  7. DESCRIPTION="The Mozc engine for IBus Framework"
  8. HOMEPAGE="https://github.com/google/mozc"
  9. PROTOBUF_VER="2.5.0"
  10. GMOCK_VER="1.6.0"
  11. GTEST_VER="1.6.0"
  12. JSONCPP_VER="0.6.0-rc2"
  13. GYP_DATE="20140602"
  14. JAPANESE_USAGE_DICT_VER="10"
  15. FCITX_PATCH_VER="2"
  16. FCITX_PATCH="fcitx-mozc-${PV}.${FCITX_PATCH_VER}.patch"
  17. MOZC_URL="https://dev.gentoo.org/~naota/files/${P}.tar.bz2"
  18. PROTOBUF_URL="https://protobuf.googlecode.com/files/protobuf-${PROTOBUF_VER}.tar.bz2"
  19. GMOCK_URL="https://googlemock.googlecode.com/files/gmock-${GMOCK_VER}.zip"
  20. GTEST_URL="https://googletest.googlecode.com/files/gtest-${GTEST_VER}.zip"
  21. JSONCPP_URL="mirror://sourceforge/jsoncpp/jsoncpp-src-${JSONCPP_VER}.tar.gz"
  22. GYP_URL="https://dev.gentoo.org/~naota/files/gyp-${GYP_DATE}.tar.bz2"
  23. JAPANESE_USAGE_DICT_URL="https://dev.gentoo.org/~naota/files/japanese-usage-dictionary-${JAPANESE_USAGE_DICT_VER}.tar.bz2"
  24. FCITX_PATCH_URL="http://download.fcitx-im.org/fcitx-mozc/${FCITX_PATCH}"
  25. SRC_URI="${MOZC_URL} ${PROTOBUF_URL} ${GYP_URL} ${JAPANESE_USAGE_DICT_URL}
  26. fcitx? ( ${FCITX_PATCH_URL} )
  27. test? ( ${GMOCK_URL} ${GTEST_URL} ${JSONCPP_URL} )"
  28. LICENSE="BSD ipadic public-domain unicode"
  29. SLOT="0"
  30. KEYWORDS="~amd64 ~x86"
  31. IUSE="emacs fcitx +ibus +qt4 renderer test"
  32. RDEPEND="app-i18n/tegaki-zinnia-japanese
  33. dev-libs/glib:2
  34. >=dev-libs/protobuf-2.5.0
  35. x11-libs/libxcb
  36. emacs? ( virtual/emacs )
  37. fcitx? ( app-i18n/fcitx )
  38. ibus? (
  39. >=app-i18n/ibus-1.4.1
  40. qt4? ( app-i18n/ibus-qt )
  41. )
  42. renderer? ( x11-libs/gtk+:2 )
  43. qt4? (
  44. dev-qt/qtgui:4
  45. app-i18n/zinnia
  46. )
  47. ${PYTHON_DEPS}"
  48. DEPEND="${RDEPEND}
  49. dev-util/ninja
  50. virtual/pkgconfig"
  51. BUILDTYPE="${BUILDTYPE:-Release}"
  52. RESTRICT="test"
  53. SITEFILE=50${PN}-gentoo.el
  54. src_unpack() {
  55. unpack $(basename ${MOZC_URL})
  56. unpack $(basename ${GYP_URL})
  57. unpack $(basename ${JAPANESE_USAGE_DICT_URL})
  58. mv gyp-${GYP_DATE} "${S}"/third_party/gyp || die
  59. mv japanese-usage-dictionary-${JAPANESE_USAGE_DICT_VER} "${S}"/third_party/japanese_usage_dictionary || die
  60. cd "${S}"/protobuf
  61. unpack $(basename ${PROTOBUF_URL})
  62. mv protobuf-${PROTOBUF_VER} files || die
  63. if use test; then
  64. cd "${S}"/third_party
  65. unpack $(basename ${GMOCK_URL}) $(basename ${GTEST_URL}) \
  66. $(basename ${JSONCPP_URL})
  67. mv gmock-${GMOCK_VER} gmock || die
  68. mv gtest-${GTEST_VER} gtest || die
  69. mv jsoncpp-src-${JSONCPP_VER} jsoncpp || die
  70. fi
  71. }
  72. src_prepare() {
  73. # verbose build
  74. sed -i -e "/RunOrDie(\[make_command\]/s/build_args/build_args + [\"-v\"]/" \
  75. build_mozc.py || die
  76. sed -i -e "s/<!(which clang)/$(tc-getCC)/" \
  77. -e "s/<!(which clang++)/$(tc-getCXX)/" \
  78. gyp/common.gypi || die
  79. if use fcitx; then
  80. EPATCH_OPTS="-p2" epatch "${DISTDIR}/${FCITX_PATCH}"
  81. fi
  82. epatch_user
  83. }
  84. src_configure() {
  85. local myconf="--server_dir=/usr/$(get_libdir)/mozc"
  86. if ! use qt4 ; then
  87. myconf+=" --noqt"
  88. export GYP_DEFINES="use_libzinnia=0"
  89. fi
  90. if ! use renderer ; then
  91. export GYP_DEFINES="${GYP_DEFINES} enable_gtk_renderer=0"
  92. fi
  93. export GYP_DEFINES="${GYP_DEFINES} use_libprotobuf=1 compiler_target=gcc compiler_host=gcc"
  94. tc-export CC CXX AR AS RANLIB LD NM
  95. "${PYTHON}" build_mozc.py gyp -v ${myconf} || die "gyp failed"
  96. }
  97. src_compile() {
  98. tc-export CC CXX AR AS RANLIB LD
  99. local my_makeopts=$(makeopts_jobs)
  100. # This is for a safety. -j without a number, makeopts_jobs returns 999.
  101. local myjobs=-j${my_makeopts/999/1}
  102. local mytarget="server/server.gyp:mozc_server"
  103. use emacs && mytarget="${mytarget} unix/emacs/emacs.gyp:mozc_emacs_helper"
  104. use fcitx && mytarget="${mytarget} unix/fcitx/fcitx.gyp:fcitx-mozc"
  105. use ibus && mytarget="${mytarget} unix/ibus/ibus.gyp:ibus_mozc"
  106. use renderer && mytarget="${mytarget} renderer/renderer.gyp:mozc_renderer"
  107. if use qt4 ; then
  108. export QTDIR="${EPREFIX}/usr"
  109. mytarget="${mytarget} gui/gui.gyp:mozc_tool"
  110. fi
  111. # V=1 "${PYTHON}" build_mozc.py build_tools -c "${BUILDTYPE}" ${myjobs} || die
  112. "${PYTHON}" build_mozc.py build -v -c "${BUILDTYPE}" ${mytarget} ${myjobs} || die
  113. if use emacs ; then
  114. elisp-compile unix/emacs/*.el || die
  115. fi
  116. }
  117. src_test() {
  118. tc-export CC CXX AR AS RANLIB LD
  119. V=1 "${PYTHON}" build_mozc.py runtests -c "${BUILDTYPE}" || die
  120. }
  121. src_install() {
  122. install_fcitx_locale() {
  123. lang=$1
  124. insinto "/usr/share/locale/${lang}/LC_MESSAGES/"
  125. newins out_linux/${BUILDTYPE}/gen/unix/fcitx/po/${lang}.mo fcitx-mozc.mo
  126. }
  127. if use emacs ; then
  128. dobin "out_linux/${BUILDTYPE}/mozc_emacs_helper" || die
  129. elisp-install ${PN} unix/emacs/*.{el,elc} || die
  130. elisp-site-file-install "${FILESDIR}/${SITEFILE}" ${PN} || die
  131. fi
  132. if use fcitx; then
  133. exeinto /usr/$(get_libdir)/fcitx
  134. doexe "out_linux/${BUILDTYPE}/fcitx-mozc.so"
  135. insinto /usr/share/fcitx/addon
  136. doins "unix/fcitx/fcitx-mozc.conf"
  137. insinto /usr/share/fcitx/inputmethod
  138. doins "unix/fcitx/mozc.conf"
  139. insinto /usr/share/fcitx/mozc/icon
  140. (
  141. cd data/images
  142. newins product_icon_32bpp-128.png mozc.png
  143. cd unix
  144. for f in ui-* ; do
  145. newins ${f} mozc-${f/ui-}
  146. done
  147. )
  148. l10n_for_each_locale_do install_fcitx_locale
  149. fi
  150. if use ibus ; then
  151. exeinto /usr/$(get_libdir)/ibus-mozc || die
  152. newexe "out_linux/${BUILDTYPE}/ibus_mozc" ibus-engine-mozc || die
  153. insinto /usr/share/ibus/component || die
  154. doins "out_linux/${BUILDTYPE}/gen/unix/ibus/mozc.xml" || die
  155. insinto /usr/share/ibus-mozc || die
  156. (
  157. cd data/images/unix
  158. newins ime_product_icon_opensource-32.png product_icon.png || die
  159. for f in ui-*
  160. do
  161. newins ${f} ${f/ui-} || die
  162. done
  163. )
  164. fi
  165. exeinto "/usr/$(get_libdir)/mozc" || die
  166. doexe "out_linux/${BUILDTYPE}/mozc_server" || die
  167. if use qt4 ; then
  168. exeinto "/usr/$(get_libdir)/mozc" || die
  169. doexe "out_linux/${BUILDTYPE}/mozc_tool" || die
  170. fi
  171. if use renderer ; then
  172. exeinto "/usr/$(get_libdir)/mozc" || die
  173. doexe "out_linux/${BUILDTYPE}/mozc_renderer" || die
  174. fi
  175. }
  176. pkg_postinst() {
  177. if use emacs ; then
  178. elisp-site-regen
  179. elog "You can use mozc-mode via LEIM (Library of Emacs Input Method)."
  180. elog "Write the following settings into your init file (~/.emacs.d/init.el"
  181. elog "or ~/.emacs) in order to use mozc-mode by default, or you can call"
  182. elog "\`set-input-method' and set \"japanese-mozc\" anytime you have loaded"
  183. elog "mozc.el"
  184. elog
  185. elog " (require 'mozc)"
  186. elog " (set-language-environment \"Japanese\")"
  187. elog " (setq default-input-method \"japanese-mozc\")"
  188. elog
  189. elog "Having the above settings, just type C-\\ which is bound to"
  190. elog "\`toggle-input-method' by default."
  191. fi
  192. }
  193. pkg_postrm() {
  194. use emacs && elisp-site-regen
  195. }