#
# Conditional build:
%bcond_with tests # build with tests. tests need active internet connection
+%bcond_without qt4 # Qt4
+%bcond_without qt5 # Qt5
Summary: C++ wrapper for the Echo Nest API
Name: libechonest
-Version: 2.1.0
+Version: 2.3.1
Release: 1
License: GPL v2+
-Source0: http://files.lfranchi.com/%{name}-%{version}.tar.bz2
-# Source0-md5: 96d98dbc5b3b155b277a9901d1133c5e
Group: Libraries
+Source0: http://files.lfranchi.com/%{name}-%{version}.tar.bz2
+# Source0-md5: d8c60545b056145dc66882971a0acf9c
URL: https://projects.kde.org/projects/playground/libs/libechonest
-BuildRequires: QtNetwork-devel
BuildRequires: cmake
+BuildRequires: libstdc++-devel
BuildRequires: pkgconfig
+%if %{with qt4}
+BuildRequires: QtCore-devel
+BuildRequires: QtNetwork-devel
BuildRequires: qjson-devel
BuildRequires: qt4-build
+BuildRequires: qt4-qmake
+%endif
+%if %{with qt5}
+BuildRequires: Qt5Network-devel
+BuildRequires: Qt5Xml-devel
+BuildRequires: qt5-build
+BuildRequires: qt5-qmake
+%endif
BuildRequires: rpmbuild(macros) >= 1.605
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%endif
%description
-libechonest is a collection of C++/Qt classes designed to make a
+libechonest is a collection of Qt4 classes designed to make a
developer's life easy when trying to use the APIs provided by The Echo
Nest.
-%package devel
+%package devel
Summary: Development files for %{name}
+Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
-%description devel
+%description devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.
+%package -n libechonest-qt5
+Summary: libechonest Qt5 bindings
+Group: Libraries
+
+%description -n libechonest-qt5
+libechonest is a collection of Qt5 classes designed to make a
+developer's life easy when trying to use the APIs provided by The Echo
+Nest.
+
+%package -n libechonest-qt5-devel
+Summary: Development files for libechonest-qt5
+Group: Development/Libraries
+Requires: libechonest-qt5 = %{version}-%{release}
+
+%description -n libechonest-qt5-devel
+Development files for libechonest-qt5.
+
%prep
%setup -q
%build
-install -d %{_target_platform}
-cd %{_target_platform}
-%cmake ..
+%if %{with qt4}
+install -d build-qt4
+cd build-qt4
+%cmake \
+ -DBUILD_WITH_QT4:BOOL=ON \
+ -DECHONEST_BUILD_TESTS:BOOL=%{?with_tests:ON}%{!?with_tests:OFF} \
+ ..
%{__make}
%if %{with tests}
-export PKG_CONFIG_PATH=$RPM_BUILD_ROOT%{_npkgconfigdir}:$RPM_BUILD_ROOT%{_pkgconfigdir}
+export PKG_CONFIG_PATH=$(pwd)
test "$(pkg-config --modversion libechonest)" = "%{version}"
-%{__make} test
+%{__make} test ARGS="--timeout 300 --output-on-failure"
+%endif
+
+cd ..
+%endif
+
+%if %{with qt5}
+install -d build-qt5
+cd build-qt5
+%cmake \
+ -DBUILD_WITH_QT4:BOOL=OFF \
+ -DECHONEST_BUILD_TESTS:BOOL=%{?with_tests:ON}%{!?with_tests:OFF} \
+ ..
+%{__make}
+
+%if %{with tests}
+export PKG_CONFIG_PATH=$(pwd)
+test "$(pkg-config --modversion libechonest5)" = "%{version}"
+%{__make} test ARGS="--timeout 300 --output-on-failure"
+%endif
%endif
%install
rm -rf $RPM_BUILD_ROOT
-%{__make} -C %{_target_platform} install/fast \
+%if %{with qt4}
+%{__make} -C build-qt4 install/fast \
+ DESTDIR=$RPM_BUILD_ROOT
+%endif
+
+%if %{with qt5}
+%{__make} -C build-qt5 install/fast \
DESTDIR=$RPM_BUILD_ROOT
+%endif
%clean
rm -rf $RPM_BUILD_ROOT
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
+%post -n libechonest-qt5 -p /sbin/ldconfig
+%postun -n libechonest-qt5 -p /sbin/ldconfig
+
+%if %{with qt4}
%files
%defattr(644,root,root,755)
-%doc AUTHORS COPYING README TODO
+%doc AUTHORS README TODO
%attr(755,root,root) %{_libdir}/libechonest.so.*.*.*
-# yes, SONAME is "libechonest.so.2.1"
-%ghost %{_libdir}/libechonest.so.2.1
+# yes, SONAME is "libechonest.so.2.3"
+%ghost %{_libdir}/libechonest.so.2.3
%files devel
%defattr(644,root,root,755)
-%{_includedir}/echonest/
+%{_includedir}/echonest
%{_libdir}/libechonest.so
%{_pkgconfigdir}/libechonest.pc
+%endif
+
+%if %{with qt5}
+%files -n libechonest-qt5
+%defattr(644,root,root,755)
+%doc AUTHORS README TODO
+%attr(755,root,root) %{_libdir}/libechonest5.so.*.*.*
+# yes, SONAME is "libechonest5.so.2.3"
+%ghost %{_libdir}/libechonest5.so.2.3
+
+%files -n libechonest-qt5-devel
+%defattr(644,root,root,755)
+%{_includedir}/echonest5
+%{_libdir}/libechonest5.so
+%{_pkgconfigdir}/libechonest5.pc
+%endif