Name:    okular 
Summary: A document viewer
Summary(ja): 文章ビューア
Version: 4.9.5
Release: 1%{?_dist_release}

License: GPLv2
Group:   Applications/Publishing
URL:     https://projects.kde.org/projects/kde/kdegraphics/okular

Source0: ftp://ftp.kde.org/pub/kde/stable/%{version}/src/%{name}-%{version}.tar.xz

## upstreamable patches
# okular.desktop : Categories=-Office,+VectorGraphics (http://bugzilla.redhat.com/591089)
Patch50: kdegraphics-4.5.1-okular_dt.patch
# don't hardcode paths in OkularConfig.cmake
Patch51: kdegraphics-4.5.80-OkularConfig-dont-hardcode-paths.patch

BuildRequires: chmlib-devel
BuildRequires: desktop-file-utils
BuildRequires: djvulibre-devel
BuildRequires: ebook-tools-devel
BuildRequires: kdelibs4-devel >= %{version}
BuildRequires: libkipi-devel >= %{version} 
BuildRequires: libspectre-devel
BuildRequires: libtiff-devel
BuildRequires: poppler-qt4-devel
BuildRequires: qca2-devel
BuildRequires: qimageblitz-devel
BuildRequires: soprano-devel

Requires: %{name}-libs = %{version}-%{release}
Requires: kio_msits = %{version}-%{release}
Requires: kdebase-runtime%{?_kde4_version: >= %{_kde4_version}}
# when split occurred
Conflicts: kdegraphics < 4.6.95-10

%description
%{summary}.

%package devel
Summary:  Development files for %{name}
Summary(ja): %{name} の開発用ファイル
Group:    Development/Libraries
Requires: %{name}-libs = %{version}-%{release}
Requires: kdelibs4-devel

%description devel
%{summary}.

%package  libs 
Summary:  Runtime files for %{name} 
Summary(ja): %{name} のランタイムライブラリ 
Group:    System Environment/Libraries
#Requires: %{name} = %{version}-%{release}

%description libs 
%{summary}.

%package -n kio_msits
#Epoch: %{kio_msits_epoch} 
Summary: A kioslave for displaying WinHelp files
Group: System Environment/Libraries

%description -n kio_msits
%{summary}.


%prep
%setup -q

%patch50 -p2 -b .okular_dt
%patch51 -p2 -b .OkularConfig


%build
mkdir -p %{_target_platform}
pushd %{_target_platform}
%cmake \
    -DCMAKE_BUILD_TYPE=release \
    -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \
    -DDATA_INSTALL_DIR:PATH=%{_datadir}/kde4/apps \
    -DINCLUDE_INSTALL_DIR:PATH=%{_includedir}/kde4 \
    -DLIBEXEC_INSTALL_DIR:PATH=%{_libexecdir}/kde4 \
    -DSYSCONF_INSTALL_DIR:PATH=%{_sysconfdir} \
    ..
popd

make %{?_smp_mflags} -C %{_target_platform}


%install
rm -rf $RPM_BUILD_ROOT

make install/fast DESTDIR=$RPM_BUILD_ROOT -C %{_target_platform}


%check
desktop-file-validate $RPM_BUILD_ROOT%{_datadir}/applications/kde4/%{name}.desktop


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

%posttrans
gtk-update-icon-cache %{_datadir}/icons/hicolor &> /dev/null || :
update-desktop-database -q &> /dev/null ||:

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

%post libs -p /sbin/ldconfig
%postun libs -p /sbin/ldconfig


%files
%doc COPYING 
%{_bindir}/%{name}*
%{_datadir}/kde4/apps/%{name}/
%{_datadir}/applications/kde4/%{name}.desktop
%{_datadir}/applications/kde4//%{name}Application_*.desktop
%{_datadir}/config.kcfg/*.kcfg
%{_datadir}/kde4/services/lib%{name}Generator*.desktop
%{_datadir}/kde4/services/%{name}[A-Z]*.desktop
%{_datadir}/icons/hicolor/*/*/*
%{_datadir}/doc/HTML/en/%{name}/
%{_libdir}/kde4/%{name}Generator*.so
%{_datadir}/kde4/services/%{name}_part.desktop
%{_datadir}/kde4/servicetypes/%{name}Generator.desktop
%{_libdir}/kde4/%{name}part.so

%files devel
%{_includedir}/kde4/okular/
%{_libdir}/libokularcore.so
%{_libdir}/cmake/Okular/

%files libs
%{_libdir}/libokularcore.so.1*

%files -n kio_msits
%{_libdir}/kde4/kio_msits.so
%{_datadir}/kde4/services/msits.protocol


%changelog
* Fri Jan 04 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.9.5-1
- new upstream release

* Sat Nov 10 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.9.3-1
- new upstream release

* Sun Oct 07 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.9.2-1
- new upstream release

* Sun Sep 30 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.9.1-2
- rebuild with poppler-0.20.4

* Thu Sep 06 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.9.1-1
- new upstream release

* Sun Aug 12 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.9.0-1
- new upstream release
- remove Patch54 (kdegraphics-4.6.90-okular-landscape.patch)

* Sun Dec 18 2011 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 4.7.4-1
- new upstream release

* Tue Oct 25 2011 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 4.7.2-1
- new upstream release

* Tue Aug  2 2011 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 4.7.0-2
- Initial build for Vine Linux

* Tue Jul 26 2011 Jaroslav Reznik <jreznik@redhat.com> 4.7.0-1
- 4.7.0

* Mon Jul 18 2011 Rex Dieter <rdieter@fedoraproject.org> 4.6.95-4
- %%postun: +update-desktop-database

* Mon Jul 18 2011 Rex Dieter <rdieter@fedoraproject.org> 4.6.95-3
- BR: pkgconfig(qca2)

* Fri Jul 15 2011 Rex Dieter <rdieter@fedoraproject.org> 4.6.95-2
- bump release

* Mon Jul 11 2011 Rex Dieter <rdieter@fedoraproject.org> 4.6.95-1
- 4.6.95
- fix URL

* Wed Jul 06 2011 Rex Dieter <rdieter@fedoraproject.org> 4.6.90-3
- fix Source URL
- Conflicts: kdegraphics < 7:4.6.90-10

* Tue Jul 05 2011 Rex Dieter <rdieter@fedoraproject.org>  4.6.90-2
- first try

