%define ver 4.2.8.6
%define rel 1

Summary: an input method framework with extension support
Name: fcitx
Version: %{ver}
Release: %{rel}%{?_dist_release}
License: GPLv2+
Group: System Environment/Libraries
URL: https://fcitx-im.org/
Source0: http://download.fcitx-im.org/fcitx/%{name}-%{version}.tar.xz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
BuildRequires: cmake
BuildRequires: wget
BuildRequires: libX11-devel
BuildRequires: dbus-glib-devel
BuildRequires: xorg-x11-proto-devel
BuildRequires: xorg-x11-xtrans-devel
BuildRequires: libxkbfile-devel 
BuildRequires: pango-devel
BuildRequires: cairo-devel
BuildRequires: dbus-devel
BuildRequires: libicu-devel
BuildRequires: iso-codes
BuildRequires: libxml2-devel
BuildRequires: gtk2-devel
BuildRequires: gtk3-devel
BuildRequires: qt4-devel
BuildRequires: enchant-devel
BuildRequires: lua-devel
BuildRequires: gobject-introspection-devel
Requires: %{name}-libs = %{version}-%{release}
Requires: %{name}-data = %{version}-%{release}

Distribution: Vine Linux
Vendor:       Project Vine
Packager:     iwaim

%description
Fcitx [ˈfaɪtɪks] is an input method framework with extension support. 
Currently it supports Linux and Unix systems like freebsd. 
It has three built-in Input Method Engine, Pinyin, QuWei and Table-based 
input methods. 

%package data
Summary: Data files for Fcitx
Group: System Environment/Libraries
Requires: hicolor-icon-theme
Requires: dbus

%description data
This package provides shared datas for Fxitx.

%package libs
Summary: Shared libraries for Fcitx
Group: System Environment/Libraries

%description libs
This package provides shared libraries for Fcitx.

%package devel
Summary: Development files for Fcitx
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}

%description devel
This package contains libraries and header files necessary for
developing programs using Fcitx libraries.

%package gtk2
Summary: Fcitx IM module for GTK2
Group: System Environment/Libraries
Requires: %{name} = %{version}-%{release}

%description gtk2
This package contains Fcitx IM module for GTK2.

%package gtk3
Summary: Fcitx IM module for GTK3
Group: System Environment/Libraries
Requires: %{name} = %{version}-%{release}

%description gtk3
This package contains Fcitx IM module for GTK3.

%package qt4
Summary: Fcitx IM module for Qt4
Group: System Environment/Libraries
Requires: %{name} = %{version}-%{release}

%description qt4
This package contains Fcitx IM module for Qt4.

%prep
%setup -q

%build
%__mkdir build
pushd build
cmake .. \
  -DCMAKE_VERBOSE_MAKEFILE=ON \
  -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \
  -DCMAKE_INSTALL_LIBDIR:PATH=%{_libdir} \
  -DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \
  -DLIB_INSTALL_DIR:PATH=%{_libdir} \
  -DSYSCONF_INSTALL_DIR:PATH=%{_sysconfdir} \
  -DSHARE_INSTALL_PREFIX:PATH=%{_datadir} \
  -DENABLE_GTK3_IM_MODULE=On \
  -DENABLE_QT_IM_MODULE=On \
  -DENABLE_OPENCC=Off \
  -DENABLE_LUA=On \
  -DENABLE_GIR=On \
  -DENABLE_XDGAUTOSTART=Off \
  -DENABLE_PRESAGE=Off

make %{?_smp_mflags}
popd

%install
%__rm -rf $RPM_BUILD_ROOT
pushd build
make install INSTALL="install -p" DESTDIR=$RPM_BUILD_ROOT
rm -f %{buildroot}%{_libdir}/*.la
popd
%{find_lang} %{name}

%clean
%__rm -rf $RPM_BUILD_ROOT

%post
update-desktop-database %{_datadir}/applications &>/dev/null || :

%postun
update-desktop-database %{_datadir}/applications &>/dev/null || :

%post libs -p /sbin/ldconfig

%postun libs -p /sbin/ldconfig

%post data
/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :

%postun data
if [ $1 -eq 0 ] ; then
  /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null
  /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
fi

%posttrans data
/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :

%post gtk2
%{_bindir}/gtk-query-immodules-2.0 > %{_sysconfdir}/gtk-2.0/%{_arch}/gtk.immodules || :

%postun gtk2
%{_bindir}/gtk-query-immodules-2.0 > %{_sysconfdir}/gtk-2.0/%{_arch}/gtk.immodules || :

%post gtk3
%{_bindir}/gtk-query-immodules-3.0 --update-cache || :

%postun gtk3
%{_bindir}/gtk-query-immodules-3.0 --update-cache || :

%files -f %{name}.lang
%defattr(-,root,root,-)
%doc README
%{_bindir}/fcitx*
%exclude %{_bindir}/fcitx4-config
%{_bindir}/createPYMB
%{_bindir}/mb2org
%{_bindir}/mb2txt
%{_bindir}/readPYBase
%{_bindir}/readPYMB
%{_bindir}/scel2org
%{_bindir}/txt2mb
%{_datadir}/applications/fcitx-configtool.desktop
%{_datadir}/applications/fcitx-skin-installer.desktop
%{_datadir}/applications/fcitx.desktop
%{_datadir}/doc/fcitx
%{_mandir}/man1/*.1*
%{_datadir}/mime/packages/x-fskin.xml

%files devel
%defattr(-,root,root,-)
%{_bindir}/fcitx4-config
%{_libdir}/libfcitx*.so
%{_libdir}/pkgconfig/fcitx-config.pc
%{_libdir}/pkgconfig/fcitx-gclient.pc
%{_libdir}/pkgconfig/fcitx-qt.pc
%{_libdir}/pkgconfig/fcitx-utils.pc
%{_libdir}/pkgconfig/fcitx.pc
%{_includedir}/fcitx*
%{_datadir}/cmake/fcitx
%{_datadir}/gir-1.0/Fcitx-1.0.gir

%files libs
%defattr(-,root,root,-)
%{_libdir}/fcitx
%{_libdir}/libfcitx*.so.*
%{_libdir}/girepository-1.0/Fcitx-1.0.typelib

%files data
%defattr(-,root,root,-)
%{_datadir}/icons/hicolor/*/*/*.png
%{_datadir}/icons/hicolor/scalable/apps/fcitx.svg
%{_datadir}/icons/hicolor/scalable/apps/fcitx-*.svg
%{_datadir}/fcitx
%{_datadir}/dbus-1/services/org.fcitx.Fcitx.service

%files gtk2
%defattr(-,root,root,-)
%{_libdir}/gtk-2.0/*/immodules/im-fcitx.so

%files gtk3
%defattr(-,root,root,-)
%{_libdir}/gtk-3.0/*/immodules/im-fcitx.so

%files qt4
%defattr(-,root,root,-)
%{_libdir}/qt4/plugins/inputmethods/qtim-fcitx.so

%changelog
* Tue Apr 28 2015 IWAI, Masaharu <iwaim.sub@gmail.com> 4.2.8.6-1
- update to 4.2.8.6

* Mon Nov 24 2014 IWAI, Masaharu <iwaim.sub@gmail.com> 4.2.8.5-1
- update to 4.2.8.5

* Sun Oct 26 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.2.8.4-2
- rebuild with icu-54.1

* Tue Dec 31 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.2.8.3-2
- rebuild with icu-52.1
- move pkgconfig files to %%{name}-devel

* Tue Nov  5 2013 IWAI, Masaharu <iwaim.sub@gmail.com> 4.2.8.3-1
- initial release
