%define akonadi_version 1.2.60

Name: kdepim-runtime
Summary: KDE PIM Runtime Environment
Version: 4.4.2
Release: 1%{?_dist_release}

License: GPLv2
Group: Applications/Productivity
URL: http://www.kde.org/
Source0: ftp://ftp.kde.org/pub/kde/stable/%{version}/src/%{name}-%{version}.tar.bz2

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: akonadi-devel >= %{akonadi_version}
BuildRequires: desktop-file-utils
BuildRequires: kdepimlibs-devel >= %{version}
BuildRequires: kdelibs4-devel >= %{version}
BuildRequires: zlib-devel
BuildRequires: soprano-devel
BuildRequires: libxslt-devel
BuildRequires: libxml2-devel
Requires: %{name}-libs = %{version}-%{release}

%description
%{summary}


%package libs
Summary: %{name} runtime libraries
Group: System Environment/Libraries
Requires: %{name} = %{version}-%{release}
Requires: akonadi >= %{akonadi_version}

%description libs
%{summary}.


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

%description devel
%{summary}.
Install %{name}-devel if you want to write or compile %{name} plugins.


%prep
%setup -q

%build
mkdir -p %{_target_platform}
pushd %{_target_platform}
unset QTDIR || : ; . /etc/profile.d/qt4.sh
%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 \
    ..
popd

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


%install
rm -rf $RPM_BUILD_ROOT

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

# make symlinks relative
mkdir -p $RPM_BUILD_ROOT%{_docdir}/HTML/en/common
pushd $RPM_BUILD_ROOT%{_docdir}/HTML/en
for i in *; do
   if [ -d $i -a -L $i/common ]; then
      rm -f $i/common
      ln -nfs ../common $i
   fi
done
popd

%check
for f in $RPM_BUILD_ROOT%{_datadir}/applications/kde4/*.desktop ; do
   desktop-file-validate $f
done

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

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

%postun
if [ $1 -eq 0 ] ; then
  update-mime-database %{_datadir}/mime &> /dev/null ||:
  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

%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root,-)
%{_bindir}/*
%{_libdir}/kde4/*.so
%{_datadir}/autostart/*
%{_datadir}/akonadi/agents/*
%{_datadir}/applications/kde4/*
%{_datadir}/config/*rc
%{_datadir}/dbus-1/interfaces/*.xml
%{_datadir}/kde4/services/*
%{_datadir}/mime/packages/*
%{_datadir}/icons/hicolor/*/*/*
%{_datadir}/kde4/apps/*

%files devel
%defattr(-,root,root,-)
#{_includedir}/kde4/akonadi/xml
%{_libdir}/lib*.so

%files libs
%defattr(-,root,root,-)
%{_libdir}/lib*.so.*

%changelog
* Mon Apr 12 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 4.4.2-1
- new upstream release

* Sun Mar  7 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 4.4.1-1
- new upstream release

* Tue Mar  2 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 4.4.0-1
- new upstream release
- built with new toolchain

* Mon Nov 23 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 4.3.3-1
- new upstream release

* Sun Oct 25 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 4.3.2-1
- new upstream release

* Sat Sep  5 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 4.3.1-1
- new upstream release
- used %%cmake macro

* Sun Aug 30 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 4.3.0-2
- Initial build for Vine Linux

* Thu Jul 30 2009 Than Ngo <than@redhat.com> - 4.3.0-1
- 4.3.0

* Wed Jul 22 2009 Than Ngo <than@redhat.com> - 4.2.98-1
- 4.3rc3

* Sat Jul 11 2009 Than Ngo <than@redhat.com> - 4.2.96-1
- 4.3rc2

* Thu Jul 02 2009 Rex Dieter <rdieter@fedoraproject.org> 4.2.95-3
- -devel: Requires: kdepimlibs-devel
- Req: akonadi >= 1.1.95

* Mon Jun 29 2009 Than Ngo <than@redhat.com> - 4.2.95-2
- cleanup

* Fri Jun 26 2009 Than Ngo <than@redhat.com> - 4.2.95-1
- first try
