updated on Mon Jan 23 20:11:11 UTC 2012
[aur-mirror.git] / mozc-ut / PKGBUILD
blobfcab72b1bf5b17121c0ecc30b5997801fe7e2237
1 # Maintainer: ponsfoot <cabezon dot hashimoto at gmail dot com>
3 ##
4 ## Build configuration 
5 ##
6 ## You can choose the input method framework to use either ibus, scim, uim or both.
7 ## If you will not be using ibus, comment out below.
8 _ibus_mozc="yes"
9 ## If you will be using scim, uncomment below.
10 #_scim_mozc="yes"
11 ## If you will be using uim, uncomment below.
12 #_uim_mozc="yes"
14 ## If you will be using mozc.el on Emacs, uncomment below.
15 #_emacs_mozc="yes"
17 ## $QTDIR is changed temporarily and forcibly by default for Qt3 users.
18 ## If you install Qt4 on your custom and set $QTDIR for Qt4, uncomment below.
19 #_qtdir="$QTDIR"
21 ## Generate dictionary seeds from UT dictionary oneself.
22 ## (Requires more build time)
23 _gendic="yes"
25 ## ニコニコ大百科IME辞書 (NICONICOPEDIA IME dictionary)
26 ## if you want to make redistributable mozc-ut,
27 ## keep **DISABLE** _NICODIC="yes" please.
28 ## This is ignored if $_gendic != "yes".
29 #_NICODIC="yes"
31 ## Mozc compile option
32 _bldtype=Release
33 #_bldtype=Debug
35 #*************************************************************
36 # Upstreams:
38 # mozc
39 # http://code.google.com/p/mozc/
41 # Japanese zip code data by Japan Post
42 # http://www.post.japanpost.jp/zipcode/download.html
44 # Additional dictionary by UTSUMI
45 # http://www.geocities.jp/ep3797/mozc_01.html
47 # uim-mozc by macuim
48 # http://code.google.com/p/macuim/
50 #*************************************************************
52 pkgbase=mozc-ut
53 pkgname=mozc-ut
54 true && pkgname=('mozc-ut')
55 _mozcver=1.3.931.102
56 _utdicver=20111125
57 pkgrel=2
58 _zipcoderel=201112
59 _uimmozcrev=300
60 _protobuf_ver=2.4.1
61 arch=('i686' 'x86_64')
62 url="http://www.geocities.jp/ep3797/mozc_01.html"
63 license=('BSD' 'GPL' 'CC-BY-SA' 'custom')
64 makedepends=('pkg-config' 'python2' 'gtest' 'zinnia')
65 changelog=ChangeLog
66 if [[ "$_gendic" != "yes" ]]; then
67   # Patched source from UT
68   pkgver=1.2.855.102.20111125
69   source=(http://downloads.sourceforge.net/mdk-ut/mozc-ut-${pkgver}.7z)
70   sha1sums=('8bf4fc499048995283d1c33d1642fc0cd8a92ddd')
71   makedepends+=('p7zip')
72 else
73   pkgver=${_mozcver}.${_utdicver}
74   source=(http://mozc.googlecode.com/files/mozc-${_mozcver}.tar.bz2
75           http://downloads.sourceforge.net/mdk-ut/mozcdic-ut-${_utdicver}.tar.bz2)
76   sha1sums=('41f349b9b4ea87dda19d42653d5f4b584da16c37'
77             'd0aba35246b3f51797a98edf05ee675b5d14d0ca')
78   makedepends+=('ruby')
80 source+=(EDICT_license.html
81          http://downloads.sourceforge.net/pnsft-aur/ken_all-${_zipcoderel}.zip
82          http://downloads.sourceforge.net/pnsft-aur/jigyosyo-${_zipcoderel}.zip)
83 sha1sums+=('e0ba18e67c1be8e3cfb8ecb30760597b215da255'
84            '099fd4323f0dbd345431a003e718bd978b1f2679'
85            '003d424b788a6d6b1b9f86c30733c5b3083c1a6d'
88 if [[ "$_ibus_mozc" = "yes" ]]; then
89     true && pkgname+=('ibus-mozc-ut')
90     makedepends+=('ibus')
92 if [[ "$_scim_mozc" = "yes" ]]; then
93     true && pkgname+=('scim-mozc-ut')
94     makedepends+=('scim')
96 if [[ "$_emacs_mozc" = "yes" ]]; then
97     true && pkgname+=('emacs-mozc-ut')
100 if [[ "$_uim_mozc"  = "yes" ]]; then
101     true && pkgname+=('uim-mozc-ut')
102     makedepends+=('uim')
103     source+=(http://downloads.sourceforge.net/project/pnsft-aur/mozc/uim-mozc-${_uimmozcrev}.tar.xz
104              http://protobuf.googlecode.com/files/protobuf-${_protobuf_ver}.tar.bz2)
105     sha1sums+=('9761fb2eddf2dc7545305cc114d81feb7cb2ff88'
106                'df5867e37a4b51fb69f53a8baf5b994938691d6d')
107 else
108     depends+=('protobuf')
111 build() {
112   if [[ "$_ibus_mozc" != "yes" && "$_scim_mozc" != "yes" && "$_uim_mozc" != "yes" ]]; then
113     msg "*****************************************************"
114     msg " Please choose either one of ibus, scim or uim"
115     msg " at least. See PKGBUILD."
116     msg "*****************************************************"
117     return 1
118   fi
120   if [[ "$QTDIR" && -z "$_qtdir" ]]; then
121     msg '====================================================='
122     msg '                *** CAUTION ***'
123     msg ' $QTDIR will be replaced temporarily and forcibly'
124     msg ' for Qt3 users.'
125     msg ' If it is inconvenient for you, please edit'
126     msg ' PKGBUILD. (Please see it for datail)'
127     msg '====================================================='
128   fi
130   msg '====================================================='
131   msg '               *** Build Info ***'
132   msg ' The following package files will be generated:'
133   for _p in ${pkgname[@]}
134   do
135     msg "  * ${_p}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}"
136   done
137   msg '====================================================='
139   cd $srcdir
141   if [[ "$_gendic" = "yes" ]]; then
142     # Generate mozc-ut dictionary seeds
143     cd "${srcdir}/mozcdic-ut-${_utdicver}"
144     # Adjust for Ruby>=1.9, makepkg, etc.
145     find . -name \*.rb -type f \
146       -exec sed -i -e "2i #-*- encoding: utf-8 -*-" -e "s/\]\.length /\]\.bytesize /g" {} +
147     sed -i -e "s|^MOZCVER=.*|MOZCVER=\"${_mozcver}\"|" \
148            -e "s|^DATE=.*|DATE=\"${_utdicver}\"|" \
149            -e 's|^rm -rf \.\./mozc-$MOZCVER|#&|' \
150            -e 's|^tar jxf mozc-$MOZCVER\.tar\.bz2|#&|' \
151            -e "s/^ruby.*/& || exit 1/g" \
152            -e 's|^svn.*|#&|' \
153       generate-mozc-ut.sh
154     [[ "$_NICODIC" = "yes" ]] && sed -i 's/NICODIC="false"/NICODIC="true"/' generate-mozc-ut.sh
155     msg "Generating UT dictionary seed..."
156     sh ./generate-mozc-ut.sh
157     msg "Done."
158   else
159     7z x -y mozc-ut-${pkgver}.7z
160   fi
162   cd "${srcdir}/${pkgbase}-${pkgver}"
164   # uim-mozc
165   if [[ "$_uim_mozc" = "yes" ]]; then
166       # patch to link protobuf statically
167       cp -rf "${srcdir}/protobuf-${_protobuf_ver}" protobuf/files
168       patch -p0 -i "${srcdir}/uim-mozc-${_uimmozcrev}/mozc-linux-protobuf.diff"
169       cp -rf "${srcdir}/uim-mozc-${_uimmozcrev}/uim" unix/
170       patch -p0 -i "${srcdir}/uim-mozc-${_uimmozcrev}/mozc-kill-line.diff"
171       # Extract license part of uim-mozc
172       head -n 32 unix/uim/mozc.cc > unix/uim/LICENSE
173   fi
175   # Adjust for python2
176   find . -name  \*.py        -type f -exec sed -i -e "1s|python.*$|python2|"  {} +
177   find . -regex ".*\.gypi?$" -type f -exec sed -i -e "s|'python'|'python2'|g" {} +
179   # Add zip code
180   msg "Generating zip code seed..."
181   python2 dictionary/gen_zip_code_seed.py --zip_code="${srcdir}/KEN_ALL.CSV" --jigyosyo="${srcdir}/JIGYOSYO.CSV" >> data/dictionary/dictionary09.txt
182   msg "Done."
184   msg "Starting make..."
186   # Get make -j option from $MAKEFLAGS
187   _jobs=`sed -n -e "s/.*--jobs=\([0-9]\+\).*/\1/p" -e "s/.*-j *\([0-9]\+\).*/\1/p" <<< "$MAKEFLAGS"`
188   _jobs=${_jobs:-1}
190   _targets="server/server.gyp:mozc_server gui/gui.gyp:mozc_tool "
191   [[ "$_emacs_mozc" = "yes" ]] && _targets+="unix/emacs/emacs.gyp:mozc_emacs_helper "
192   [[ "$_ibus_mozc"  = "yes" ]] && _targets+="unix/ibus/ibus.gyp:ibus_mozc "
193   [[ "$_scim_mozc"  = "yes" ]] && _targets+="unix/scim/scim.gyp:scim_mozc unix/scim/scim.gyp:scim_mozc_setup "
194   [[ "$_uim_mozc"   = "yes" ]] && _targets+="unix/uim/uim.gyp:uim-mozc "
196   QTDIR="$_qtdir" python2 build_mozc.py gyp --channel_dev=0
197   python2 build_mozc.py build_tools -c $_bldtype -j $_jobs
198   python2 build_mozc.py build -c $_bldtype -j $_jobs $_targets
200   [[ "$_ibus_mozc" = "yes" ]] && sed -i 's|/usr/libexec/|/usr/lib/ibus-mozc/|g' out_linux/${_bldtype}/obj/gen/unix/ibus/mozc.xml
202   if [[ "$_emacs_mozc" = "yes" ]]; then
203     cd unix/emacs
204     emacs -batch -f batch-byte-compile mozc.el
205     cd ~-
206   fi
208   # Extract liccense part of mozc
209   head -n 28 server/mozc_server.cc > LICENSE
212 package_mozc-ut() {
213   pkgdesc="Mozc the Japanese Input Method containing Mozc UT Dictionary (additional dictionary) and uim-mozc (optional)"
214   arch=('i686' 'x86_64')
215   groups=('mozc-im')
216   depends=('curl')
217   [[ "$_uim_mozc" != "yes" ]] && depends+=('protobuf')
218   provides=('mozc')
219   replaces=('mozc-server-ut' 'mozc-utils-gui-ut')
220   conflicts=('mozc' 'mozc-server' 'mozc-utils-gui')
221   optdepends=('zinnia: hand-writing recognition support'
222               'tegaki-models-zinnia-japanese: hand-writing recognition support')
224   cd "${srcdir}/${pkgbase}-${pkgver}"
225   install -D -m 755 out_linux/${_bldtype}/mozc_server "${pkgdir}/usr/lib/mozc/mozc_server"
226   install -D -m 755 out_linux/${_bldtype}/mozc_tool "${pkgdir}/usr/lib/mozc/mozc_tool"
227   install -d "${pkgdir}/usr/lib/mozc/documents/"
228   install    -m 644 data/installer/*.html "${pkgdir}/usr/lib/mozc/documents/"
230   _licpath="${pkgdir}/usr/share/licenses/${pkgbase}"
231   install -D -m 644 LICENSE "${_licpath}/LICENSE_MOZC"
232   cd doc-ut
233   install -D -m 644 README "${_licpath}/README_MOZC-UT"
234   _dics="skk jinmei hatena edict altcanna"
235   [[ "$_gendic" = "yes" && "$_NICODIC" = "yes" ]] && _dics+=" niconico"
236   for d in $_dics
237   do
238     install -d "${_licpath}/dictionary/${d}"
239     install -m 644 dictionary/${d}/* "${_licpath}/dictionary/${d}"
240   done
241   install -m 644 ${srcdir}/EDICT_license.html "${_licpath}/dictionary/edict/license.html"
244 package_emacs-mozc-ut() {
245   pkgdesc="Mozc for Emacs"
246   arch=('i686' 'x86_64')
247   groups=('mozc-im')
248   depends=("mozc-ut=${pkgver}" 'emacs')
249   install=emacs-mozc.install
250   replaces=('emacs-mozc-bin')
251   provides=('emacs-mozc')
252   conflicts=('emacs-mozc' 'emacs-mozc-bin')
254   cd "${srcdir}/${pkgbase}-${pkgver}"
255   install -D -m 755 out_linux/${_bldtype}/mozc_emacs_helper "${pkgdir}/usr/bin/mozc_emacs_helper"
256   install -d "${pkgdir}/usr/share/emacs/site-lisp/emacs-mozc/"
257   install -m 644 unix/emacs/mozc.el{,c} "${pkgdir}/usr/share/emacs/site-lisp/emacs-mozc"
260 package_ibus-mozc-ut() {
261   pkgdesc="IBus engine module for Mozc"
262   arch=('i686' 'x86_64')
263   groups=('mozc-im')
264   depends=("mozc-ut=${pkgver}" 'ibus')
265   provides=('ibus-mozc')
266   conflicts=('ibus-mozc')
268   cd "${srcdir}/${pkgbase}-${pkgver}"
269   install -D -m 755 out_linux/${_bldtype}/ibus_mozc       "${pkgdir}/usr/lib/ibus-mozc/ibus-engine-mozc"
270   install -D -m 644 out_linux/${_bldtype}/obj/gen/unix/ibus/mozc.xml "${pkgdir}/usr/share/ibus/component/mozc.xml"
271   install -D -m 644 data/images/unix/ime_product_icon_opensource-32.png "${pkgdir}/usr/share/ibus-mozc/product_icon.png"
272   install    -m 644 data/images/unix/ui-tool.png          "${pkgdir}/usr/share/ibus-mozc/tool.png"
273   install    -m 644 data/images/unix/ui-properties.png    "${pkgdir}/usr/share/ibus-mozc/properties.png"
274   install    -m 644 data/images/unix/ui-dictionary.png    "${pkgdir}/usr/share/ibus-mozc/dictionary.png"
275   install    -m 644 data/images/unix/ui-direct.png        "${pkgdir}/usr/share/ibus-mozc/direct.png"
276   install    -m 644 data/images/unix/ui-hiragana.png      "${pkgdir}/usr/share/ibus-mozc/hiragana.png"
277   install    -m 644 data/images/unix/ui-katakana_half.png "${pkgdir}/usr/share/ibus-mozc/katakana_half.png"
278   install    -m 644 data/images/unix/ui-katakana_full.png "${pkgdir}/usr/share/ibus-mozc/katakana_full.png"
279   install    -m 644 data/images/unix/ui-alpha_half.png    "${pkgdir}/usr/share/ibus-mozc/alpha_half.png"
280   install    -m 644 data/images/unix/ui-alpha_full.png    "${pkgdir}/usr/share/ibus-mozc/alpha_full.png"
283 package_scim-mozc-ut() {
284   pkgdesc="SCIM IMEngine module for Mozc"
285   arch=('i686' 'x86_64')
286   groups=('mozc-im')
287   depends=("mozc-ut=${pkgver}" 'scim')
288   provides=('scim-mozc')
289   conflicts=('scim-mozc')
291   cd "${srcdir}/${pkgbase}-${pkgver}"
292   _moduledir=`pkg-config scim --variable=moduledir`
293   install -D -m 755 out_linux/${_bldtype}/lib.target/libscim_mozc.so       "${pkgdir}${_moduledir}/IMEngine/mozc.so"
294   install -D -m 755 out_linux/${_bldtype}/lib.target/libscim_mozc_setup.so "${pkgdir}${_moduledir}/SetupUI/mozc-setup.so"
295   _icondir=`pkg-config scim --variable=icondir`
296   install -D -m 644 data/images/unix/ime_product_icon_opensource-32.png "${pkgdir}${_icondir}/scim-mozc.png"
297   install    -m 644 data/images/unix/ui-tool.png          "${pkgdir}${_icondir}/scim-mozc-tool.png"
298   install    -m 644 data/images/unix/ui-properties.png    "${pkgdir}${_icondir}/scim-mozc-properties.png"
299   install    -m 644 data/images/unix/ui-dictionary.png    "${pkgdir}${_icondir}/scim-mozc-dictionary.png"
300   install    -m 644 data/images/unix/ui-direct.png        "${pkgdir}${_icondir}/scim-mozc-direct.png"
301   install    -m 644 data/images/unix/ui-hiragana.png      "${pkgdir}${_icondir}/scim-mozc-hiragana.png"
302   install    -m 644 data/images/unix/ui-katakana_half.png "${pkgdir}${_icondir}/scim-mozc-katakana_half.png"
303   install    -m 644 data/images/unix/ui-katakana_full.png "${pkgdir}${_icondir}/scim-mozc-katakana_full.png"
304   install    -m 644 data/images/unix/ui-alpha_half.png    "${pkgdir}${_icondir}/scim-mozc-alpha_half.png"
305   install    -m 644 data/images/unix/ui-alpha_full.png    "${pkgdir}${_icondir}/scim-mozc-alpha_full.png"
308 package_uim-mozc-ut() {
309   pkgdesc="uim IMEngine module for Mozc"
310   arch=('i686' 'x86_64')
311   groups=('mozc-im')
312   depends=("mozc-ut=${pkgver}" 'uim')
313   install=uim-mozc.install
314   provides=('uim-mozc')
315   conflicts=('uim-mozc')
317   cd "${srcdir}/${pkgbase}-${pkgver}"
318   install -D -m 755 out_linux/${_bldtype}/libuim-mozc.so  "${pkgdir}/usr/lib/uim/plugin/libuim-mozc.so"
319   install -d "${pkgdir}/usr/share/uim"
320   install    -m 644 ${srcdir}/uim-mozc-${_uimmozcrev}/scm/*.scm       "${pkgdir}/usr/share/uim/"
321   install -D -m 644 data/images/unix/ime_product_icon_opensource-32.png "${pkgdir}/usr/share/uim/pixmaps/mozc.png"
322   install    -m 644 data/images/unix/ui-tool.png       "${pkgdir}/usr/share/uim/pixmaps/mozc_tool_selector.png"
323   install    -m 644 data/images/unix/ui-properties.png "${pkgdir}/usr/share/uim/pixmaps/mozc_tool_config_dialog.png"
324   install    -m 644 data/images/unix/ui-dictionary.png "${pkgdir}/usr/share/uim/pixmaps/mozc_tool_dictionary_tool.png"
326   install -D -m 644 unix/uim/LICENSE "${pkgdir}/usr/share/licenses/${pkgbase}/uim-mozc/LICENSE"
329 # Global pkgdesc and depends are here so that they will be picked up by AUR
330 pkgdesc="Mozc the Japanese Input Method containing Mozc UT Dictionary (additional dictionary) and uim-mozc (optional)"
331 depends=('curl' 'qt')