%define ver 1.5.22
%define rel 1

%define from_git 0
%if %{from_git}
%define githash e388f558
%endif

Summary: a Japanese Kana Kanji input engine for IBus
Name: ibus-kkc
Version: %{ver}
%if %{from_git}
Release: %{rel}.git%{githash}%{_dist_release}
%else
Release: %{rel}%{_dist_release}
%endif
License: GPLv3
Group: System Environment/Libraries
URL: https://bitbucket.org/libkkc/
%if %{from_git}
Source0: %{name}-%{githash}.tar.gz
%else
Source0: https://github.com/ueno/ibus-kkc/releases/download/v%{version}/%{name}-%{version}.tar.gz
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
BuildRequires: gtk3-devel >= 3.12
BuildRequires: ibus-devel >= 1.4.0
BuildRequires: libkkc-devel >= 0.1.0
BuildRequires: desktop-file-utils
%if %{from_git}
BuildRequires: gnome-common
%endif
Requires: libkkc-data
Requires: skkdic

%description
a Japanese Kana Kanji input engine for IBus.

%prep
%if %{from_git}
%setup -q -n %{name}-%{githash}
%else
%setup -q
%endif

%build
%if %{from_git}
./autogen.sh
%endif
%configure --enable-shared
%__make

%install
%__rm -rf $RPM_BUILD_ROOT
%makeinstall

%{find_lang} %{name}

%clean
%__rm -rf $RPM_BUILD_ROOT

%check
%{_bindir}/desktop-file-validate %{buildroot}/%{_datadir}/applications/ibus-setup-kkc.desktop

%post
if [ -x %{_bindir}/update-desktop-database ] ; then
%{_bindir}/update-desktop-database %{_datadir}/applications
fi

%postun
if [ -x %{_bindir}/update-desktop-database ] ; then
%{_bindir}/update-desktop-database %{_datadir}/applications
fi

%files -f %{name}.lang
%defattr(-,root,root,-)
%doc README ChangeLog COPYING AUTHORS NEWS
%{_libexecdir}/ibus-engine-kkc
%{_libexecdir}/ibus-setup-kkc
%{_datadir}/applications/ibus-setup-kkc.desktop
%dir %{_datadir}/ibus-kkc
%dir %{_datadir}/ibus-kkc/icons
%{_datadir}/ibus-kkc/icons/ibus-kkc.svg
%{_datadir}/ibus/component/kkc.xml

%changelog
* Mon Dec 29 2014 IWAI, Masaharu <iwaim.sub@gmail.com> 1.5.22-1
- update to 1.5.22
- switch upstream source location to GitHub
- BuildRequires: gtk3-devel >= 3.12

* Mon Jul  7 2014 IWAI, Masaharu <iwaim.sub@gmail.com> 1.5.21-1
- update to 1.5.21

* Sun Jun 15 2014 IWAI, Masaharu <iwaim.sub@gmail.com> 1.5.20-1
- update to 1.5.20

* Wed Dec 18 2013 IWAI, Masaharu <iwaim.sub@gmail.com> 1.5.19-1
- update to 1.5.19

* Thu Nov  7 2013 IWAI, Masaharu <iwaim.sub@gmail.com> 1.5.18-1
- update to 1.5.18

* Sat Jul 27 2013 IWAI, Masaharu <iwaim.sub@gmail.com> 1.5.16-1
- update to 1.5.16
- update %%files

* Tue Jun 18 2013 IWAI, Masaharu <iwaim.sub@gmail.com> 1.5.14-1
- update to 1.5.14
- fix changelog: 1.15.10-1

* Tue Mar 26 2013 IWAI, Masaharu <iwai@alib.jp> 1.5.10-1
- update to 1.5.10

* Sat Mar 16 2013 IWAI, Masaharu <iwai@alib.jp> 1.5.9-1
- update to 1.5.9

* Sun Mar  3 2013 IWAI, Masaharu <iwai@alib.jp> 1.5.8-1
- update to 1.5.8

* Sat Feb 23 2013 IWAI, Masaharu <iwai@alib.jp> 1.5.7-1
- update to 1.5.7

* Mon Feb 11 2013 IWAI, Masaharu <iwai@alib.jp> 1.5.6-1
- update to 1.5.6

* Tue Feb  5 2013 IWAI, Masaharu <iwai@alib.jp> 1.5.5-1
- update to 1.5.5
- update Summary and description: sync README

* Fri Feb  1 2013 IWAI, Masaharu <iwai@alib.jp> 1.5.3-1
- update to 1.5.3
- update requires libkkc version: 0.1.0

* Fri Feb  1 2013 IWAI, Masaharu <iwai@alib.jp> 1.5.2-3.gite388f558
- update to git e388f558e3eff3e538fa48ee0c2275e7d743964c
- add requires package version:
  - ibus-devel  >= 1.4.0
  - libkkc-devel >= 0.0.3-3

* Tue Jan 29 2013 IWAI, Masaharu <iwai@alib.jp> 1.5.2-2.giteb042df4
- update to git eb042df479cdad0d037e16016fda3d2cae99aaa1
- add BuildRequires: gnome-common with git 
- add Requires: skkdic

* Mon Jan 28 2013 IWAI, Masaharu <iwai@alib.jp> 1.5.2-1
- initial build for Vine Linux

