%define qt4_ver 4.8.0
# 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}/qt4)
%define _qt4_import %(pkg-config --variable importdir --silence-errors Qt 2>/dev/null || echo %{_qt4_prefix}/imports)

Name:    libqzeitgeist
Summary: Qt Zeitgeist Library
Version: 0.8.0
Release: 2%{?_dist_release}

License: LGPLv2+
Group:   System Environment/Libraries
URL:     http://projects.kde.org/projects/kdesupport/libqzeitgeist 

Vendor:  Project Vine
Distribution: Vine Linux

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

## upstreamable patches
# reduce linking in libqzeitgeist 
Patch50: libqzeitgeist-0.8.0-reduced_linking.patch

## upstream patches
# fix linking (don't link the Qt world, including QtWebkit, only use QT_DECLARATIVE_LIBRARIES)
# consistently use QT_IMPORTS_DIR
Patch100: libqzeitgeist-0.8.0-declarative.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: automoc4
BuildRequires: cmake
BuildRequires: qt4-devel >= 4.7.0
BuildRequires: zeitgeist

%description
%{summary}.

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

%description devel
%{summary}


%prep
%setup -q 

%patch50 -p1 -b .reduced_linking
%patch100 -p1 -b .declarative

%build
mkdir -p %{_target_platform}
pushd %{_target_platform}
%cmake ..
popd

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


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


%check
export PKG_CONFIG_PATH=$RPM_BUILD_ROOT%{_datadir}/pkgconfig:$RPM_BUILD_ROOT%{_libdir}/pkgconfig
test "$(pkg-config --modversion QZeitgeist)" = "%{version}"


%clean
rm -rf $RPM_BUILD_ROOT

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig


%files
%doc COPYING README
%{_libdir}/libqzeitgeist.so.*
%dir %{_qt4_import}/org
%dir %{_qt4_import}/org/gnome
%dir %{_qt4_import}/org/gnome/zeitgeist
%{_qt4_import}/org/gnome/zeitgeist/*

%files devel
%{_includedir}/QZeitgeist/
%{_libdir}/libqzeitgeist.so
%dir %{_libdir}/cmake/QZeitgeist
%{_libdir}/cmake/QZeitgeist/*
%{_libdir}/pkgconfig/QZeitgeist.pc


%changelog
* Thu Jun 30 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.8.0-2
- rebuilt with new toolchain.

* Sun Jan  8 2012 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.8.0-1
- new upstream release
- added BR: automoc4

* Sun Jun  5 2011 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.7.0-2
- Initial build for Vine Linux

* Fri May 20 2011 Rex Dieter <rdieter@fedoraproject.org> 0.7.0-1
- first try

