mozc-1.10.1390.102-r1.ebuild 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. inherit elisp-common eutils multilib multiprocessing python-single-r1 toolchain-funcs
  6. DESCRIPTION="The Mozc engine for IBus Framework"
  7. HOMEPAGE="https://github.com/google/mozc"
  8. PROTOBUF_VER="2.5.0"
  9. GMOCK_VER="1.6.0"
  10. GTEST_VER="1.6.0"
  11. JSONCPP_VER="0.6.0-rc2"
  12. MOZC_URL="https://mozc.googlecode.com/files/${P}.tar.bz2"
  13. PROTOBUF_URL="https://protobuf.googlecode.com/files/protobuf-${PROTOBUF_VER}.tar.bz2"
  14. GMOCK_URL="https://googlemock.googlecode.com/files/gmock-${GMOCK_VER}.zip"
  15. GTEST_URL="https://googletest.googlecode.com/files/gtest-${GTEST_VER}.zip"
  16. JSONCPP_URL="mirror://sourceforge/jsoncpp/jsoncpp-src-${JSONCPP_VER}.tar.gz"
  17. SRC_URI="${MOZC_URL} ${PROTOBUF_URL}
  18. test? ( ${GMOCK_URL} ${GTEST_URL} ${JSONCPP_URL} )"
  19. LICENSE="BSD ipadic public-domain unicode"
  20. SLOT="0"
  21. KEYWORDS="~amd64 ~x86"
  22. IUSE="emacs +ibus +qt4 renderer test"
  23. RDEPEND="dev-libs/glib:2
  24. dev-libs/openssl
  25. x11-libs/libxcb
  26. emacs? ( virtual/emacs )
  27. ibus? ( >=app-i18n/ibus-1.4.1 )
  28. renderer? ( x11-libs/gtk+:2 )
  29. qt4? (
  30. dev-qt/qtgui:4
  31. app-i18n/zinnia
  32. )
  33. ${PYTHON_DEPS}"
  34. DEPEND="${RDEPEND}
  35. virtual/pkgconfig"
  36. BUILDTYPE="${BUILDTYPE:-Release}"
  37. RESTRICT="test"
  38. SITEFILE=50${PN}-gentoo.el
  39. src_unpack() {
  40. unpack $(basename ${MOZC_URL})
  41. cd "${S}"/protobuf
  42. unpack $(basename ${PROTOBUF_URL})
  43. mv protobuf-${PROTOBUF_VER} files || die
  44. if use test; then
  45. cd "${S}"/third_party
  46. unpack $(basename ${GMOCK_URL}) $(basename ${GTEST_URL}) \
  47. $(basename ${JSONCPP_URL})
  48. mv gmock-${GMOCK_VER} gmock || die
  49. mv gtest-${GTEST_VER} gtest || die
  50. mv jsoncpp-src-${JSONCPP_VER} jsoncpp || die
  51. fi
  52. }
  53. src_prepare() {
  54. epatch "${FILESDIR}"/${P}-drop-Werror.patch
  55. epatch "${FILESDIR}"/${PN}-ibus-1.5.4.patch
  56. epatch_user
  57. }
  58. src_configure() {
  59. local myconf="--server_dir=/usr/$(get_libdir)/mozc"
  60. if ! use qt4 ; then
  61. myconf+=" --noqt"
  62. export GYP_DEFINES="use_libzinnia=0"
  63. fi
  64. if ! use renderer ; then
  65. export GYP_DEFINES="${GYP_DEFINES} enable_gtk_renderer=0"
  66. fi
  67. # export GYP_DEFINES="${GYP_DEFINES} use_libprotobuf=1"
  68. "${PYTHON}" build_mozc.py gyp ${myconf} || die "gyp failed"
  69. }
  70. src_compile() {
  71. tc-export CC CXX AR AS RANLIB LD
  72. local my_makeopts=$(makeopts_jobs)
  73. # This is for a safety. -j without a number, makeopts_jobs returns 999.
  74. local myjobs=-j${my_makeopts/999/1}
  75. local mytarget="server/server.gyp:mozc_server"
  76. use emacs && mytarget="${mytarget} unix/emacs/emacs.gyp:mozc_emacs_helper"
  77. use ibus && mytarget="${mytarget} unix/ibus/ibus.gyp:ibus_mozc"
  78. use renderer && mytarget="${mytarget} renderer/renderer.gyp:mozc_renderer"
  79. if use qt4 ; then
  80. export QTDIR="${EPREFIX}/usr"
  81. mytarget="${mytarget} gui/gui.gyp:mozc_tool"
  82. fi
  83. V=1 "${PYTHON}" build_mozc.py build_tools -c "${BUILDTYPE}" ${myjobs} || die
  84. V=1 "${PYTHON}" build_mozc.py build -c "${BUILDTYPE}" ${mytarget} ${myjobs} || die
  85. if use emacs ; then
  86. elisp-compile unix/emacs/*.el || die
  87. fi
  88. }
  89. src_test() {
  90. tc-export CC CXX AR AS RANLIB LD
  91. V=1 "${PYTHON}" build_mozc.py runtests -c "${BUILDTYPE}" || die
  92. }
  93. src_install() {
  94. if use emacs ; then
  95. dobin "out_linux/${BUILDTYPE}/mozc_emacs_helper" || die
  96. elisp-install ${PN} unix/emacs/*.{el,elc} || die
  97. elisp-site-file-install "${FILESDIR}/${SITEFILE}" ${PN} || die
  98. fi
  99. if use ibus ; then
  100. exeinto /usr/libexec || die
  101. newexe "out_linux/${BUILDTYPE}/ibus_mozc" ibus-engine-mozc || die
  102. insinto /usr/share/ibus/component || die
  103. doins "out_linux/${BUILDTYPE}/obj/gen/unix/ibus/mozc.xml" || die
  104. insinto /usr/share/ibus-mozc || die
  105. (
  106. cd data/images/unix
  107. newins ime_product_icon_opensource-32.png product_icon.png || die
  108. for f in ui-*
  109. do
  110. newins ${f} ${f/ui-} || die
  111. done
  112. )
  113. fi
  114. exeinto "/usr/$(get_libdir)/mozc" || die
  115. doexe "out_linux/${BUILDTYPE}/mozc_server" || die
  116. if use qt4 ; then
  117. exeinto "/usr/$(get_libdir)/mozc" || die
  118. doexe "out_linux/${BUILDTYPE}/mozc_tool" || die
  119. fi
  120. if use renderer ; then
  121. exeinto "/usr/$(get_libdir)/mozc" || die
  122. doexe "out_linux/${BUILDTYPE}/mozc_renderer" || die
  123. fi
  124. }
  125. pkg_postinst() {
  126. if use emacs ; then
  127. elisp-site-regen
  128. elog "You can use mozc-mode via LEIM (Library of Emacs Input Method)."
  129. elog "Write the following settings into your init file (~/.emacs.d/init.el"
  130. elog "or ~/.emacs) in order to use mozc-mode by default, or you can call"
  131. elog "\`set-input-method' and set \"japanese-mozc\" anytime you have loaded"
  132. elog "mozc.el"
  133. elog
  134. elog " (require 'mozc)"
  135. elog " (set-language-environment \"Japanese\")"
  136. elog " (setq default-input-method \"japanese-mozc\")"
  137. elog
  138. elog "Having the above settings, just type C-\\ which is bound to"
  139. elog "\`toggle-input-method' by default."
  140. fi
  141. }
  142. pkg_postrm() {
  143. use emacs && elisp-site-regen
  144. }