%define qt4_ver 4.7.1
# Qt4 version auto-detection
%define _qt4_version %(pkg-config --modversion --silence-errors Qt 2>/dev/null || echo %{qt4_ver})
%define _qt4_prefix %(pkg-config --variable prefix --silence-errors Qt 2>/dev/null || echo %{_libdir}/qt-%{qt4_ver})
%define _qt4_headerdir %(pkg-config --variable headerdir --silence-errors Qt 2>/dev/null || echo %{_qt4_prefix}/include)

%global pulseaudio_version %(pkg-config --modversion libpulse 2>/dev/null || echo 0.9.15)

Name: phonon
Summary: Multimedia framework api
Summary(ja): マルチメディアフレームワーク API
Version: 4.4.4
Release: 1%{?_dist_release}

Group: System Environment/Libraries
License: LGPLv2+
URL: http://phonon.kde.org/

Source0: ftp://ftp.kde.org/pub/kde/stable/phonon/4.4.4/phonon-%{version}.tar.bz2

Patch1: phonon-4.4.4-no_rpath.patch
## Mandriva/upstreamable patches
Patch53: phonon-4.3.50-phonon-allow-stop-empty-source.patch

## Upstream patches

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: automoc4 >= 0.9.86
BuildRequires: cmake >= 2.6.2
BuildRequires: glib2-devel
BuildRequires: libxcb-devel
BuildRequires: libxml2-devel
BuildRequires: qt4-devel >= 4.6.0
BuildRequires: pulseaudio-libs-devel >= 0.9.15

# TODO: enable the following Requires in next release
#Requires: phonon-backend >= 4.4
Requires: pulseaudio-libs >= %{pulseaudio_version}
Requires: qt4 >= %{_qt4_version}

%description
Phonon is a cross-platform portable Multimedia Support Abstraction,
which allows you to play multiple audio or video formats with the same
quality on all platforms, no matter which underlying architecture is
used.

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

%description devel
Header files for developing applications using phonon

%prep
%setup -q

%patch1 -p1 -b .no_rpath
%patch53 -p1 -b .phonon-allow-stop-empty-source


%build
%ifarch x86_64
PATH="$PATH:`/usr/bin/pkg-config --variable=bindir Qt`"
%endif

mkdir -p %{_target_platform}
pushd %{_target_platform}
unset QTDIR || : ; . /etc/profile.d/qt4.sh
%cmake \
    ..
popd

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

%install
rm -rf $RPM_BUILD_ROOT

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

# symlink for qt/phonon compatibility
ln -s ../KDE/Phonon $RPM_BUILD_ROOT%{_includedir}/phonon/Phonon

# own these dirs
mkdir -p $RPM_BUILD_ROOT%{_libdir}/kde4/plugins/phonon_backend/
mkdir -p $RPM_BUILD_ROOT%{_datadir}/kde4/services/phononbackends/

mkdir -p $RPM_BUILD_ROOT%{_qt4_headerdir}
pushd $RPM_BUILD_ROOT%{_qt4_headerdir}
ln -sf %{_includedir}/phonon phonon
popd

%clean
rm -rf $RPM_BUILD_ROOT

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%defattr(-,root,root)
%doc COPYING.LIB
%{_libdir}/*.so.*
%{_datadir}/dbus-1/interfaces/*
# kde4-specific dirs
%dir %{_libdir}/kde4/plugins/phonon_backend
%dir %{_datadir}/kde4/services/phononbackends

%files devel
%defattr(-,root,root)
%dir %{_includedir}/KDE
%{_includedir}/KDE/Phonon/
%{_includedir}/phonon/
%{_qt4_headerdir}/phonon
%{_qt4_prefix}/mkspecs/modules/qt_phonon.pri
%{_libdir}/*.so
%{_libdir}/pkgconfig/*.pc
%{_datadir}/phonon-buildsystem/

%changelog
* Sat Jan 29 2011 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 4.4.4-1
- new upstream release
- rebuilt with qt4-4.7.1 on VineSeed

* Mon Dec 13 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.4.3-1
- new upstream release

* Sun Oct 17 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 4.4.2-2
- added sybolic link in %%{_qt4_headerdir}

* Mon Sep 20 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 4.4.2-1
- new upstream release
- dropt Patch51 and 57
- rebuilt with rpm-4.8.1

* Sat Mar 14 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 4.4.0-1
- new upstream release
- dropt Patch1, 50, 54 and 100
- added Patch57
  * Fri Jan 22 2010 Rex Dieter <rdieter@fedoraproject.org> - 4.3.80-5.2
  - F11: patch/modularize pa device-manager bits 

* Sun Feb 14 2010 Shu KONNO <owa@bg.wakwak.com> 4.3.80-2
- added qmake path to PATH (if x86_64)

* Sat Feb 13 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 4.3.80-1
- new upstream release
- built with new toolchain

* Sat Aug 29 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 4.3.1-3
- added Patch102 and 103 from FC
  * Thu Jun 18 2009 Rex Dieter <rdieter@fedoraproject.org> - 4.3.1-11
  - fix for '#' in filenames
  * Fri Jun 05 2009 Kevin Kofler <Kevin@tigcc.ticalc.org> - 4.3.1-8
  - restore patches to the xine backend

* Fri Aug 14 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 4.3.1-2
- added Patch100 and 101 from FC
  * Tue Mar  3 2009 Lukáš Tinkl <ltinkl@redhat.com> - 4.3.1-2
  - backport GStreamer backend bugfixes (UTF-8 file handling, volume fader)
- added backend sub-pakcages

* Thu Mar 26 2009 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 4.3.1-1
- new upstream release
- add BuildPrereq: cmake

* Sat Jan 24 2009 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 4.3.0-1
- new upstream release

* Wed Jan 14 2009 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 4.2.96-1
- new upstream release
- update %%files
- add BuildPrereq: xine-lib-devel libxcb-devel

* Wed Nov 26 2008 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 4.2.80-1
- new upstream release

* Thu Oct 09 2008 Shu KONNO <owa@bg.wakwak.com> 4.2.0-2
- added script to append qmake path
- added option -DLIB_INSTALL_DIR at cmake

* Tue Oct  7 2008 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 4.2.0-1
- initial release for VineSeed
