+%bcond_with x
+%bcond_with wayland
+%define UTEST_PACKAGE 1
+%define UTEST_GCOV 0
+
Name: libtbm
-Version: 1.0.4
-Release: 2
+Version: 2.5.0
+Release: 1
License: MIT
-Summary: the library for Tizen Buffer Manager
+Summary: The library for Tizen Buffer Manager
Group: System/Libraries
Source0: %{name}-%{version}.tar.gz
+Source1001: %name.manifest
-BuildRequires: pkgconfig(pthread-stubs)
BuildRequires: pkgconfig(libdrm)
+BuildRequires: pkgconfig(wayland-server)
+BuildRequires: pkgconfig(wayland-client)
+BuildRequires: pkgconfig(capi-base-common)
+BuildRequires: pkgconfig(libpng)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(pixman-1)
+BuildRequires: gtest-devel
%description
Description: %{summary}
%package devel
-Summary: the library for Tizen Buffer Manager
+Summary: Tizen Buffer Manager Library - Development
Group: Development/Libraries
-Requires: libdrm2
+Requires: libtbm = %{version}
+Requires: pkgconfig(capi-base-common)
%description devel
-the library for Tizen Buffer Manager
+The library for Tizen Buffer Manager.
+
+Development Files.
+
+%if "%{UTEST_PACKAGE}" == "1"
+%package utests
+Summary: Tizen Buffer Manager unit tests package
+Group: System/Libraries
+
+%description utests
+Test module for testing libtbm APIs
+%endif
+
+%global TZ_SYS_RO_SHARE %{?TZ_SYS_RO_SHARE:%TZ_SYS_RO_SHARE}%{!?TZ_SYS_RO_SHARE:/usr/share}
%prep
%setup -q
+cp %{SOURCE1001} .
%build
+UTEST="no"
+
+%if "%{UTEST_PACKAGE}" == "1"
+UTEST="yes"
+%endif
-%reconfigure --prefix=%{_prefix} \
+%if "%{UTEST_GCOV}" == "1"
+CFLAGS+=" -fprofile-arcs -ftest-coverage -DTIZEN_TEST_GCOV"
+CXXFLAGS+=" -fprofile-arcs -ftest-coverage -DTIZEN_TEST_GCOV"
+LDFLAGS+=" -lgcov"
+%endif
+
+%if %{with wayland}
+%reconfigure --prefix=%{_prefix} --with-tbm-platform=WAYLAND --with-utests=${UTEST} \
+ CFLAGS="${CFLAGS} -Wall -Werror" LDFLAGS="${LDFLAGS} -Wl,--hash-style=both -Wl,--as-needed"
+%else
+%reconfigure --prefix=%{_prefix} --with-tbm-platform=X11 --with-utests=${UTEST} \
CFLAGS="${CFLAGS} -Wall -Werror" LDFLAGS="${LDFLAGS} -Wl,--hash-style=both -Wl,--as-needed"
+%endif
make %{?_smp_mflags}
%install
rm -rf %{buildroot}
-mkdir -p %{buildroot}/usr/share/license
-cp -af COPYING %{buildroot}/usr/share/license/%{name}
%make_install
+%__mkdir_p %{buildroot}%{_unitdir_user}
+install -m 644 service/tbm-drm-auth-user.service %{buildroot}%{_unitdir_user}
+install -m 644 service/tbm-drm-auth-user.path %{buildroot}%{_unitdir_user}
%clean
rm -rf %{buildroot}
+%pre
+%__mkdir_p %{_unitdir_user}/basic.target.wants
+ln -sf ../tbm-drm-auth-user.path %{_unitdir_user}/basic.target.wants/
+
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
-
+rm -f %{_unitdir_user}/basic.target.wants/tbm-drm-auth-user.path
%files
+%manifest %{name}.manifest
%defattr(-,root,root,-)
-/usr/share/license/%{name}
+%license COPYING
%{_libdir}/libtbm.so.*
-%{_libdir}/libdrm_slp.so.*
+%{_unitdir_user}/tbm-drm-auth-user.path
+%{_unitdir_user}/tbm-drm-auth-user.service
%files devel
+%manifest %{name}.manifest
%defattr(-,root,root,-)
%dir %{_includedir}
%{_includedir}/tbm_bufmgr.h
+%{_includedir}/tbm_surface.h
+%{_includedir}/tbm_surface_internal.h
+%{_includedir}/tbm_surface_queue.h
%{_includedir}/tbm_bufmgr_backend.h
+%{_includedir}/tbm_type.h
+%{_includedir}/tbm_type_int.h
+%{_includedir}/tbm_drm_helper.h
+%{_includedir}/tbm_sync.h
+%{_includedir}/tbm_bo.h
+%{_includedir}/tbm_log.h
%{_libdir}/libtbm.so
-%{_libdir}/libdrm_slp.so
%{_libdir}/pkgconfig/libtbm.pc
+%if "%{UTEST_PACKAGE}" == "1"
+%files utests
+%defattr(-,root,root,-)
+%{_bindir}/tbm-utests
+%endif