%define pykde4_akonadi 1
%define pyqt4_version_min 4.8.2
%define sip_version_min 4.12

%global python_ver %(%{__python} -c "import sys ; print sys.version[:3]")
%global pyqt4_version %(%{__python} -c 'import PyQt4.pyqtconfig; print(PyQt4.pyqtconfig._pkg_config["pyqt_version_str"])' 2> /dev/null || echo %{pyqt4_version_min})

Name: PyKDE4 
Summary: Python bindings for KDE4 
Summary(ja): KDE4 の Python バインディング
Version: 4.7.4
Release: 1%{?_dist_release}

# http://techbase.kde.org/Policies/Licensing_Policy
License: LGPLv2+
Group: Development/Languages
URL: http://developer.kde.org/language-bindings/

Source0: ftp://ftp.kde.org/pub/kde/unstable/%{version}/src/pykde4-%{version}.tar.bz2

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires:  akonadi-devel
BuildRequires:  kdebase-workspace-devel >= %{version}
BuildRequires:  okular-devel >= %{version}
BuildRequires:  kdelibs4-devel >= %{version}
BuildRequires:  kdepimlibs-devel >= %{version}
BuildRequires:  kate-devel >= %{version}
BuildRequires:  python-devel
BuildRequires:  PyQt4-devel >= %{pyqt4_version_min}
BuildRequires:  sip-devel >= %{sip_version_min}
BuildRequires:  qscintilla-devel >= 2.4
BuildRequires:  qimageblitz-devel
BuildRequires:  shared-desktop-ontologies-devel
BuildRequires:  soprano-devel

Requires: kdelibs4 >= %{version}
Requires: PyQt4 >= %{pyqt4_version}

%description
%{summary}.

%package akonadi
Summary: Akonadi runtime support for PyKDE4 
Summary: PyKDE4 の Akonadi ランタイムサポート
Group: Development/Languages 
Requires: %{name} = %{version}-%{release}
Requires: kdepimlibs-akonadi >= %{version} 

%description akonadi 
%{summary}.

%package devel
Summary:  Files needed to build PyKDE4-based applications
Summary(ja): PyKDE4 ベースのアプリケーション開発に必要なファイル
Group:    Development/Libraries
Requires: PyQt4-devel
Requires: %{name} = %{version}-%{release}
Requires: %{name}-akonadi = %{version}-%{release}

%description devel
%{summary}.


%prep
%setup -q -n pykde4-%{version}

%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 \
    -DLIB_INSTALL_DIR:PATH=%{_libdir} \
    -DLIBEXEC_INSTALL_DIR:PATH=%{_libexecdir}/kde4 \
    -DSYSCONF_INSTALL_DIR:PATH=%{_sysconfdir} \
    -DPYTHON_LIBRARY=%{_libdir}/libpython%{python_ver}.so.1.0 \
    -DPYTHON_LIBRARIES=%{_libdir}/libpython%{python_ver}.so.1.0 \
    -DPYTHON_INCLUDE_PATH=%{_includedir}/python%{python_ver} \
    ..
popd
  
make %{?_smp_mflags} -C %{_target_platform} 


%install
rm -rf $RPM_BUILD_ROOT

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

# HACK: fix multilib conflict, similar to PyQt4's http://bugzilla.redhat.com/509415
rm -fv $RPM_BUILD_ROOT%{_bindir}/pykdeuic4
mv $RPM_BUILD_ROOT%{python_sitearch}/PyQt4/uic/pykdeuic4.py \
   $RPM_BUILD_ROOT%{_bindir}/pykdeuic4
ln -s %{_bindir}/pykdeuic4 \
      $RPM_BUILD_ROOT%{python_sitearch}/PyQt4/uic/pykdeuic4.py

# install pykde4 examples under correct dir
mkdir -p $RPM_BUILD_ROOT%{_docdir}
rm -fv $RPM_BUILD_ROOT%{_datadir}/kde4/apps/pykde4/examples/*.py?
mv $RPM_BUILD_ROOT%{_datadir}/kde4/apps/pykde4 $RPM_BUILD_ROOT%{_docdir}/


%clean
rm -rf $RPM_BUILD_ROOT


%files 
%defattr(-,root,root,-)
%{python_sitearch}/PyKDE4/
%exclude %{python_sitearch}/PyKDE4/akonadi.so
%{python_sitearch}/PyQt4/uic/widget-plugins/kde4.py*
%dir %{_docdir}/pykde4
%{_libdir}/kde4/kpythonpluginfactory.so

%files akonadi
%defattr(-,root,root,-)
%{python_sitearch}/PyKDE4/akonadi.so

%files devel
%defattr(-,root,root,-)
%{_bindir}/pykdeuic4
%{python_sitearch}/PyQt4/uic/pykdeuic4.py*
%{_datadir}/sip/PyKDE4/
%{_docdir}/pykde4/examples/

%changelog
* Sat Dec 24 2011 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 4.7.4-1
- new upstream release

* Sat Oct 29 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

* Fri Jul 08 2011 Rex Dieter <rdieter@fedoraproject.org> 4.6.95-1
- 4.6.95

* Thu Jul 07 2011 Rex Dieter <rdieter@fedoraproject.org> 4.6.90-1
- first try

