%define		ver	1.3.931.102
%define		rel	1

# if you want to make scim-mozc package, rpm --define with_scim:1
%define		with_scim	0

%if %{with_scim}
%define		scim_dir		%(pkg-config --variable=moduledir scim)
%endif
%define		mozc_el			mozc-el

Name:		mozc
Summary:	Japanese Input Method Editor designed for multi-platform
Summary(ja):	マルチプラットホームで動くように設計された日本語インプットメソッドエディタ
Version:	%{ver}
Release:	%{rel}%{?_dist_release}
Group:		System Environment/Libraries
License:	BSD-like
URL:		http://code.google.com/p/mozc/

Source0:	http://mozc.googlecode.com/files/%{name}-%{version}.tar.bz2
## svn debian/copyright
Source1:	mozc-copyright
# for mozc-el
Source2:	%{name}-install.sh
Source3:	%{name}-remove.sh
Source4:	vine-default-%{name}.el
Source5:	%{name}-init.el


# Vine Lunux
Source10:	README.vine
Patch10:	mozc-1.3.911.102-ibus-japanese.patch

BuildRoot:	%{_tmppath}/%{name}-%{version}-root
BuildRequires:	python, ibus-devel, dbus-devel
BuildRequires:	openssl-devel, zlib-devel
BuildRequires:	curl-devel
BuildRequires:	protobuf-devel, gtest-devel
BuildRequires:	qt4-devel
BuildRequires:  gyp
%if %{with_scim}
# for scim-mozc
BuildRequires:	pkgconfig
BuildRequires:  gtk2-devel
BuildRequires:  scim-devel
%endif
# for 1.1.690.102+
BuildRequires:	zinnia-devel

Requires:	mozc-server = %{version}-%{release}
Requires:	mozc-utils-gui = %{version}-%{release}
Requires:	ibus-mozc = %{version}-%{release}

Packager:	kazutaka

%description
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.

%description -l ja
Mozc は日本語入力用の IME (Imput Method Editor)です。
Chromium OS や Windows、Mac、Linux といったマルチプラット
フォームで利用できるようにデザインされており、「Google日本語
入力」のオープンソース版です。

%package server
Summary:	Server part of the Mozc input method
Summary(ja):	Mozc インプットメソッドのサーバ部分
Group: 		Applications/System

%description server
Server part of the Mozc input method, used by Mozc clients such as 
ibus-mozc.

%description server -l ja
Mozc インプットメソッドのサーバ部分。ibus-mozcなどのMozcクライアントから
使うことができます。

%package -n ibus-mozc
Summary:	iBus engine module for Mozc
Summary(ja):	Mozc 用 iBus エンジンモジュール
Group:		System Environment/Libraries 
Requires:	mozc-server = %{version}-%{release}

%description -n ibus-mozc
iBus engine module for Mozc.

%description -n ibus-mozc -l ja
Mozc 用 iBus エンジンモジュール。

%if %{with_scim}
%package -n scim-mozc
Summary:	SCIM IMEngine module for Mozc
Summary(ja):	Mozc 用 SCIM IMEngine モジュール
Group:		System Environment/Libraries 
Requires:	mozc-server = %{version}-%{release}
Requires:	scim gtk2

%description -n scim-mozc
SCIM IMEngine module for Mozc.

%description -n scim-mozc -l ja
Mozc 用 SCIM IMエンジンモジュール

%endif

%package utils-gui
Summary:	Mozc GUI utilities
Summary(ja):	Mozc GUI ユーティリティー
Group:		Applications/System
Requires:	qt4
Requires:	mozc-server = %{version}-%{release}
Requires:	tegaki-zinnia-japanese

%description utils-gui
Mozc GUI uitilities, such as the configuration dialog, user dictionary 
tool and about dialog.

%description utils-gui -l ja
Mozc GUI ユーティリティー。設定ツールやユーザ辞書ツールなどが含まれます。

%package -n %{mozc_el}
Summary:	Emacs Lisp frontend for Mozc
Summary(ja): 	Mozc 用 Emacs Lisp フロントエンド
Group: 		Applications/Editors/Emacs
BuildRequires: 	emacs
Requires(post,preun): emacsen, emacsen-common >= 0.1
Requires:	mozc-server = %{version}-%{release}

%description -n %{mozc_el}
Emacs Lisp frontend for Mozc

%description -n %{mozc_el} -l ja
Mozc のための Emacs-lisp フロントエンド

%prep
%setup -q
%patch10 -p1 -b.japanese
%{__cp} -p %{SOURCE1} COPYING

# update execute files path
%{__sed} -i -e"s|/usr/lib/mozc|%{_libexecdir}|g" base/util.cc


%build
unset QTDIR
%{__python} build_mozc.py gyp --gypdir=%{_bindir} --channel_dev=0
%{__python} build_mozc.py build_tools -c Release
%{__python} build_mozc.py build -c Release unix/ibus/ibus.gyp:ibus_mozc \
%if %{with_scim}
	    unix/scim/scim.gyp:scim_mozc unix/scim/scim.gyp:scim_mozc_setup \
%endif
	    unix/emacs/emacs.gyp:mozc_emacs_helper server/server.gyp:mozc_server \
            gui/gui.gyp:mozc_tool

%install
%{__rm} -rf %{buildroot}
%{__mkdir_p} %{buildroot}%{_libdir}
%{__mkdir_p} %{buildroot}%{_libexecdir}

%define output_dir out_linux/Release

# main

# ibus-mozc
%{__cp} -p %{output_dir}/ibus_mozc %{buildroot}%{_libdir}/ibus-engine-mozc
%{__mkdir_p} %{buildroot}%{_datadir}/ibus/component/
%{__sed} 's|/usr/libexec|%{_libdir}|' < %{output_dir}/obj/gen/unix/ibus/mozc.xml > %{buildroot}%{_datadir}/ibus/component/mozc.xml
## install icons
%{__mkdir_p} %{buildroot}%{_datadir}/ibus-mozc/setup
%{__cp} -p data/images/unix/ime_product_icon_opensource-32.png %{buildroot}%{_datadir}/ibus-mozc/product_icon.png
%{__cp} -p data/images/unix/ui-tool.png %{buildroot}%{_datadir}/ibus-mozc/tool.png
%{__cp} -p data/images/unix/ui-properties.png %{buildroot}%{_datadir}/ibus-mozc/properties.png
%{__cp} -p data/images/unix/ui-dictionary.png %{buildroot}%{_datadir}/ibus-mozc/dictionary.png
%{__cp} -p data/images/unix/ui-direct.png %{buildroot}%{_datadir}/ibus-mozc/direct.png
%{__cp} -p data/images/unix/ui-hiragana.png %{buildroot}%{_datadir}/ibus-mozc/hiragana.png
%{__cp} -p data/images/unix/ui-katakana_half.png %{buildroot}%{_datadir}/ibus-mozc/katakana_half.png
%{__cp} -p data/images/unix/ui-katakana_full.png %{buildroot}%{_datadir}/ibus-mozc/katakana_full.png
%{__cp} -p data/images/unix/ui-alpha_half.png %{buildroot}%{_datadir}/ibus-mozc/alpha_half.png
%{__cp} -p data/images/unix/ui-alpha_full.png %{buildroot}%{_datadir}/ibus-mozc/alpha_full.png

%if %{with_scim}
# scim-mozc
%{__mkdir_p} %{buildroot}%{scim_dir}/{IMEngine,SetupUI}
%{__cp} -p %{output_dir}/lib.target/libscim_mozc.so \
                                  %{buildroot}%{scim_dir}/IMEngine/mozc.so
%{__cp} -p %{output_dir}/lib.target/libscim_mozc_setup.so \
                                  %{buildroot}%{scim_dir}/SetupUI/mozc-setup.so
## install icons
%{__mkdir_p} %{buildroot}%{_datadir}/scim/icons
%{__cp} -p data/images/unix/ime_product_icon_opensource-32.png %{buildroot}%{_datadir}/scim/icons/scim-mozc.png
%{__cp} -p data/images/unix/ui-tool.png %{buildroot}%{_datadir}/scim/icons/scim-mozc-tool.png
%{__cp} -p data/images/unix/ui-properties.png %{buildroot}%{_datadir}/scim/icons/scim-mozc-properties.png
%{__cp} -p data/images/unix/ui-dictionary.png %{buildroot}%{_datadir}/scim/icons/scim-mozc-dictionary.png
%{__cp} -p data/images/unix/ui-direct.png %{buildroot}%{_datadir}/scim/icons/scim-mozc-direct.png
%{__cp} -p data/images/unix/ui-hiragana.png %{buildroot}%{_datadir}/scim/icons/scim-mozc-hiragana.png
%{__cp} -p data/images/unix/ui-katakana_half.png %{buildroot}%{_datadir}/scim/icons/scim-mozc-katakana_half.png
%{__cp} -p data/images/unix/ui-katakana_full.png %{buildroot}%{_datadir}/scim/icons/scim-mozc-katakana_full.png
%{__cp} -p data/images/unix/ui-alpha_half.png %{buildroot}%{_datadir}/scim/icons/scim-mozc-alpha_half.png
%{__cp} -p data/images/unix/ui-alpha_full.png %{buildroot}%{_datadir}/scim/icons/scim-mozc-alpha_full.png
%endif


# mozc-server
%{__cp} -p %{output_dir}/mozc_server %{buildroot}%{_libexecdir}

# mozc_tool
%{__cp} -p %{output_dir}/mozc_tool %{buildroot}%{_libexecdir}

# mozc-el
%{__cp} -p %{output_dir}/mozc_emacs_helper %{buildroot}%{_libexecdir}
mkdir -p %{buildroot}%{_datadir}/emacs/site-lisp/%{name}/packages
mkdir -p %{buildroot}%{emacsen_pkgdir}/install
mkdir -p %{buildroot}%{emacsen_pkgdir}/remove
cp -p unix/emacs/mozc.el %{SOURCE4} %{SOURCE5} %{buildroot}%{_datadir}/emacs/site-lisp/%{name}
#
# install script (bytecompile el and install elc , remove)
#
%_installemacsenscript %{name} %{SOURCE2}

%_removeemacsenscript  %{name} %{SOURCE3}

# install document
%{__cp} %{SOURCE10} .

%clean
rm -rf $RPM_BUILD_ROOT


%post -n %{mozc_el}
#
# bytecompile and install
#
if [ "$1" = 2 ]; then

%_emacsenPackageRemove %{name}

fi

%_addemacsenlist %{name}

%_emacsenPackageInstall %{name}


%preun -n %{mozc_el}
if [ "$1" = 0 ]; then

%_emacsenPackageRemove %{name}

%_removeemacsenlist %{name}

fi

%files
%defattr(-,root,root)
%doc COPYING README.vine CONTRIBUTORS

%files server
%defattr(-,root,root)
%doc COPYING README.vine
%{_libexecdir}/mozc_server

%files utils-gui
%defattr(-,root,root)
%doc COPYING
%{_libexecdir}/mozc_tool

%files -n ibus-mozc
%defattr(-,root,root)
%doc COPYING
%{_libdir}/ibus-engine-mozc
%{_datadir}/ibus/component/mozc.xml
%dir %{_datadir}/ibus-mozc
%dir %{_datadir}/ibus-mozc/setup
%{_datadir}/ibus-mozc/*.png

%if %{with_scim}
%files -n scim-mozc
%defattr(-,root,root)
%doc COPYING
%{scim_dir}/SetupUI/mozc-setup.so
%{scim_dir}/IMEngine/mozc.so
%{_datadir}/scim/icons/*.png
%endif

%files -n %{mozc_el}
%defattr(-,root,root)
%doc COPYING
%{_libexecdir}/mozc_emacs_helper
%{_datadir}/emacs/site-lisp/%{name}
%{emacsen_pkgdir}/install/%{name}
%{emacsen_pkgdir}/remove/%{name}


%changelog
* Sat Dec 24 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 1.3.931.102-1
- new upstream release

* Fri Dec 02 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 1.3.911.102-1
- new upstream release
- drop patch0
- add patch10 to translate panel menu

* Wed Nov 30 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 1.2.855.102-1
- new upstram release

* Tue Aug 23 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 1.1.773.102-1
- new upstram release

* Fri Jul 22 2011 IWAI, Masaharu <iwai@alib.jp> 1.1.717.102-2
- fix typo in ibus lang panel patch (Patch0): <BTS:VineLinux:1161>
- stop built scim-mozc package by default

* Fri May 20 2011 IWAI, Masaharu <iwai@alib.jp> 1.1.717.102-1
- new upstream release

* Tue Apr 19 2011 IWAI, Masaharu <iwai@alib.jp> 1.1.690.102-2
- add Requires: tegaki-zinnia-japanese for utils-gui
- build with "--channel_dev=0" option
- fix License: droped mozcdic-ut dictionary in 0.12.402.102-1

* Fri Apr 15 2011 IWAI, Masaharu <iwai@alib.jp> 1.1.690.102-1
- new upstream release
- add BuildRequires: zinnia-devel

* Fri Mar 25 2011 IWAI, Masaharu <iwai@alib.jp> 1.1.626.102-1
- new upstream release

* Sun Jan 30 2011 IWAI, Masaharu <iwai@alib.jp> 1.0.558.102-2vl6
- build with openssl 1.0.0c

* Sat Dec 18 2010 IWAI, Masaharu <iwai@alib.jp> 1.0.558.102-1
- new upstream release
- add CONTRIBUTORS in main package %%doc

* Sat Nov  6 2010 IWAI, Masaharu <iwai@alib.jp> 0.13.523.102-1
- new upstream release
- drop unnecessary fixed compile error for Vine5 patch (Patch1)

* Mon Oct 11 2010 IWAI, Masaharu <iwai@alib.jp> 0.13.499.102-1
- new upstream release
- new elisp sub-package: mozc-el: upstream released

* Fri Sep 10 2010 IWAI, Masaharu <iwai@alib.jp> 0.13.464.102-1
- new upstream release

* Sun Aug 15 2010 IWAI, Masaharu <iwai@alib.jp> 0.12.434.102-1
- new upstream release
- replace icons: using official icons
  - drop AWASHIRO Ikuya's icons (Source3,4,5,6)

* Mon Jul 12 2010 IWAI, Masaharu <iwai@alib.jp> 0.12.402.102-2
- drop obsolete x86_64 libdir patch (Patch2)
- replace source tarball: using upstream tarball
- add mozc-copyright (Source1) from SVN debian/copyright

* Fri Jul  2 2010 IWAI, Masaharu <iwai@alib.jp> 0.12.402.102-1
- new upstream release
- drop mozcdic-ut dictionary
- update README.vine (Source10)
- defined output_dir macro for %%install section

* Thu Jun 24 2010 IWAI, Masaharu <iwai@alib.jp> 0.11.383.102-3
- add x86_64 libdir patch (Patch2): based openSUSE by kazukado

* Mon Jun 21 2010 IWAI, Masaharu <iwai@alib.jp> 0.11.383.102-2
- create new package scim-mozc
  - add icons (Source5, Source6)
- update icons (Source3, Source4)

* Fri Jun 18 2010 IWAI, Masaharu <iwai@alib.jp> 0.11.383.102-1
- update to 0.11.383.102 (svn rev.30)

* Wed Jun  9 2010 IWAI, Masaharu <iwai@alib.jp> 0.11.0-9.svn28
- update execute files path: <BTS:VineLinux:998>

* Fri Jun  4 2010 IWAI, Masaharu <iwai@alib.jp> 0.11.0-8.svn28
- disable all mozcdic-ut dictionary (disable jinmei and zipcode)
- update README.vine
- add BuildRequires: gyp
- drop BuildRequires: subversion

* Wed Jun  2 2010 IWAI, Masaharu <iwai@alib.jp> 0.11.0-7.svn28
- add mozc_tool's icon (Source4)
- rename Source0: fixed created directory name "src"

* Tue Jun  1 2010 IWAI, Masaharu <iwai@alib.jp> 0.11.0-6.svn28
- update mozcdic-ut 20100601 (Source10)
- include documents for all dictionaries
- add BuildRequires: qt4-devel

* Tue Jun  1 2010 IWAI, Masaharu <iwai@alib.jp> 0.11.0-5.svn28
- rename base name: mozc
- add new sub packages:
   - mozc-server
   - mozc-utils-gui
- update source to revision 28
- replace icon (Source3)
- drop mozc-config: upstream implement same tool

* Sun May 23 2010 Kazutaka HARADA <kazutaka@vinelinux.org> 0.11.0-4
- update source to revision 23
- add BuildRequires protobuf-devel, gtest-devel
- drop Patch0 (ibus-mozc-fix-for-x86_64.diff)
- add mozc-config as Source10 and desktop entry as Source11

* Sat May 15 2010 IWAI, Masaharu <iwai@alib.jp> 0.11.0-3
- rebuild with ibus-1.3.3

* Fri May 14 2010 Kazutaka HARADA <kazutaka@vinelinux.org> 0.11.0-2
- add Patch1 to fix compile error on i386 (workaround patch)

* Thu May 13 2010 Kazutaka HARADA <kazutaka@vinelinux.org> 0.11.0-1
- initial build for Vine Liux based on custom mandriva package made by UTUMI-san

* Thu May 13 2010 UTUMI Hirosi <utuhiro78@yahoo.co.jp> 0.11.0-2.20110511.1mdv2010.1
- add some dictionaries

* Wed May 12 2010 UTUMI Hirosi <utuhiro78@yahoo.co.jp> 0.11.0-1.20110511.1mdv2010.1
- first release

