%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}

Summary: Direct Rendering Manager runtime library
Summary(ja): Direct Rendering Manager ランタイムライブラリ
Name: libdrm
Version: 2.4.30
Release: 1%{?_dist_release}
License: MIT
Group: System Environment/Libraries
URL: http://dri.sourceforge.net

Source0: http://dri.freedesktop.org/libdrm/%{name}-%{version}.tar.bz2
Source2: 91-drm-modeset.rules
Patch3: libdrm-make-dri-perms-okay.patch
Patch5: libdrm-2.4.25-libkms_against_in_tree_drm.patch
Patch10: libdrm-2.4.30-no-pthread-stubs.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: pkgconfig automake autoconf libtool
BuildRequires: libxcb-devel
BuildRequires: libpciaccess-devel
BuildRequires: libudev-devel
BuildRequires: kernel-headers >= 2.6.27-1

Vendor: Project Vine
Distribution: Vine Linux
Packager: daisuke

%description
Direct Rendering Manager runtime library

%package devel
Summary: Direct Rendering Manager development package
Summary(ja): Direct Rendering Manager 開発パッケージ
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: kernel-headers >= 2.6.27-7

%description devel
Direct Rendering Manager development package

# compat32
%package -n compat32-%{name}
Summary: Direct Rendering Manager runtime library
Summary(ja): Direct Rendering Manager ランタイムライブラリ
Group: System Environment/Libraries
Requires: %{name} = %{version}-%{release}

%description -n compat32-%{name}
Direct Rendering Manager runtime library

%package -n compat32-%{name}-devel
Summary: Direct Rendering Manager development package
Summary(ja): Direct Rendering Manager 開発パッケージ
Group: Development/Libraries
Requires: compat32-%{name} = %{version}-%{release}
Requires: %{name}-devel = %{version}-%{release}

%description -n compat32-%{name}-devel
Direct Rendering Manager development package

%prep
%setup -q
%patch3 -p1 -b .forceperms
%patch5 -p1 -b .libkms-build-against-in-tree-drm
%patch10 -p1 -b .no-pthread-stubs

%build
autoreconf -v --install || exit 1
%configure \
  --enable-udev \
  --enable-intel \
  --enable-radeon \
  --enable-nouveau-experimental-api \
  --enable-vmwgfx-experimental-api
make

%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT

mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/udev/rules.d/
install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/udev/rules.d/

# NOTE: We intentionally don't ship *.la files
find $RPM_BUILD_ROOT -type f -name '*.la' | xargs rm -f -- || :
for i in r300_reg.h via_3d_reg.h
do
rm -f $RPM_BUILD_ROOT/usr/include/libdrm/$i
done

%clean
rm -rf $RPM_BUILD_ROOT

%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig

%post -n compat32-%{name} -p /sbin/ldconfig
%postun -n compat32-%{name} -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%doc README
%{_libdir}/libdrm.so.*
%{_libdir}/libdrm_intel.so.*
%{_libdir}/libdrm_radeon.so.*
%{_libdir}/libdrm_nouveau.so.*
%{_libdir}/libkms.so.*
%{_sysconfdir}/udev/rules.d/91-drm-modeset.rules

%files devel
%defattr(-,root,root,-)
%{_includedir}/xf86drm.h
%{_includedir}/xf86drmMode.h
%dir %{_includedir}/libdrm
%{_includedir}/libdrm/drm.h
%{_includedir}/libdrm/drm_fourcc.h
%{_includedir}/libdrm/drm_mode.h
%{_includedir}/libdrm/drm_sarea.h
%{_includedir}/libdrm/intel_bufmgr.h
%{_includedir}/libdrm/intel_debug.h
%{_includedir}/libdrm/radeon_bo*.h
%{_includedir}/libdrm/radeon_cs*.h
%{_includedir}/libdrm/nouveau_drmif.h
%{_includedir}/libdrm/*_drm.h
%dir %{_includedir}/nouveau
%{_includedir}/nouveau/nouveau_*.h
%{_includedir}/nouveau/nv04_*.h
%{_includedir}/nouveau/nvc0_pushbuf.h
%dir %{_includedir}/libkms
%{_includedir}/libkms/libkms.h
%{_libdir}/libdrm.so
%{_libdir}/libdrm_intel.so
%{_libdir}/libdrm_radeon.so
%{_libdir}/libdrm_nouveau.so
%{_libdir}/libkms.so
%{_libdir}/pkgconfig/libdrm.pc
%{_libdir}/pkgconfig/libdrm_intel.pc
%{_libdir}/pkgconfig/libdrm_radeon.pc
%{_libdir}/pkgconfig/libdrm_nouveau.pc
%{_libdir}/pkgconfig/libkms.pc

# compat32
%if %{build_compat32}
%files -n compat32-%{name}
%defattr(-,root,root,-)
%{_libdir}/libdrm.so.*
%{_libdir}/libdrm_intel.so.*
%{_libdir}/libdrm_radeon.so.*
%{_libdir}/libdrm_nouveau.so.*
%{_libdir}/libkms.so.*

%files -n compat32-%{name}-devel
%defattr(-,root,root,-)
%{_libdir}/libdrm.so
%{_libdir}/libdrm_intel.so
%{_libdir}/libdrm_radeon.so
%{_libdir}/libdrm_nouveau.so
%{_libdir}/libkms.so
%{_libdir}/pkgconfig/libdrm.pc
%{_libdir}/pkgconfig/libkms.pc
%{_libdir}/pkgconfig/libdrm_intel.pc
%{_libdir}/pkgconfig/libdrm_radeon.pc
%{_libdir}/pkgconfig/libdrm_nouveau.pc
%endif

%changelog
* Sun Jan 29 2012 Yoji TOYODA <bsyamato@aea.plala.or.jp> 2.4.30-1
- new upstream release
- update Patch10 (libdrm-2.4.30-no-pthread-stubs.patch)

* Fri Dec 16 2011 Yoji TOYODA <bsyamato@aea.plala.or.jp> 2.4.29-1
- new upstream release

* Tue Nov 01 2011 Yoji TOYODA <bsyamato@aea.plala.or.jp> 2.4.27-1
- new upstream release

* Sat Jul 09 2011 Yoji TOYODA <bsyamato@aea.plala.or.jp> 2.4.26-1
- new upstream release
- add BuildRequires: libpciaccess-devel
- change BuildRequires: libudev-devel instead of udev
- update Patch10

* Mon May 16 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.25-2
- add patch5 to build libkms with in-tree libdrm
- add --enable-vmwgfx-experimental-api

* Fri Apr 15 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.25-1
- new upstream release

* Sun Mar 06 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.4.24-2
- fix %%files devel (add %%{_includedir}/nouveau/nvc0_pushbuf.h)

* Sun Mar 06 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.24-1
- new upstream release

* Fri Jan 28 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.23-1
- new upstream release

* Thu Nov 25 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.22-1
- new upstream release

* Sun Sep 26 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.4.21-2
- rebuild with rpm-4.8.1 for pkg-config file

* Tue Aug 17 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.21-1
- new upstream release

* Fri Apr 30 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.20-1
- new upstream release
- move include files to new location which are not conflict with kernel.

* Tue Mar 23 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.19-2
- add libkms

* Mon Mar 15 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.19-1
- new upstream release

* Thu Mar 11 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.18-1
- new upstream release

* Mon Jan 04 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.17-1
- new upstream release

* Sat Dec 05 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.16-1
- new upstream release
- drop Patch5
- add BR: libatomic_ops-devel

* Sat Nov 28 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.12-2
- ad Patch5, pull in intel bo busy.

* Fri Jul 24 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.12-1
- new upstream release
- drop upstream patch

* Sun Jun 28 2009 NAKAMURA Kenta <kenta@vinelinux.org> 2.4.9-4
- added compat32 package for x86_64 arch support

* Mon May 04 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.9-3
- add /dev/dri/card* rule to 91-drm-modeset.rules 

* Mon May 04 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.9-2
- build libdrm_nouveau
- add Patch9 to update nouveau code
- move /etc/udev/rules.d/91-drm-modeset.rules to /lib/udev/rules.d/
- remove i915modeset

* Thu Apr 30 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.9-1
- new upstream release

* Thu Apr 30 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.7-1
- new upstream release

* Sun Mar 22 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.5-1
- new upstream release

* Thu Dec 25 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.3-1
- new upstream release

* Sat Dec 13 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.0-4
- remove kernel header files from -devel package.
- add BR: kernel-headers >= 2.6.27-1
- add Requires; kernel-headers >= 2.6.27-1 to -devel package

* Tue Oct 21 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.0-3
- update to libdrm-2.4.0 release

* Tue Jul 01 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.0-2.20080303
- update to new git snapshot

* Sun May 18 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.0-1
- new versioning policy

* Fri Jan 18 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.0-0vl0.1
- update to upstream snapshot

* Thu Jan 17 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 2.3.0-0vl1
- new upstream release

* Wed Feb 15 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 2.0-0vl1
- initial build for Vine Linux partially based on FC package

* Fri Feb 10 2006 Jesse Keating <jkeating@redhat.com> - 2.0-2.2
- bump again for double-long bug on ppc(64)

* Tue Feb 07 2006 Jesse Keating <jkeating@redhat.com> 2.0-2.1
- rebuilt for new gcc4.1 snapshot and glibc changes

* Wed Jan 11 2006 Mike A. Harris <mharris@redhat.com> 2.0-2
- Replaced the temporary tongue-in-cheek humourous package summary and
  description with the proper package descriptions, as many people didn't get
  the joke, while others felt it was getting old.  Ah well, I had my fun for
  a while anyway.  ;o)

* Wed Nov 30 2005 Mike A. Harris <mharris@redhat.com> 2.0-1
- Updated libdrm to version 2.0 from dri.sf.net.  This is an ABI incompatible
  release, meaning everything linked to it needs to be recompiled.

* Tue Nov 01 2005 Mike A. Harris <mharris@redhat.com> 1.0.5-1
- Updated libdrm to version 1.0.5 from dri.sf.net upstream to work around
  mesa unichrome dri driver compile failure.

* Mon Oct 24 2005 Mike A. Harris <mharris@redhat.com> 1.0.4-1
- Updated libdrm to version 1.0.4 from X11R7 RC1
- Remove i915_drv.h, imagine_drv.h, mach64_drv.h, mga_drv.h, mga_ucode.h,
  r128_drv.h, radeon_drv.h, savage_drv.h, sis_drv.h, sis_ds.h, tdfx_drv.h,
  via_drv.h, via_ds.h, via_mm.h, via_verifier.h from file manifest.

* Tue Oct 04 2005 Mike A. Harris <mharris@redhat.com> 1.0.3-3
- Update BuildRoot to use Fedora Packaging Guidelines.
- Add missing "BuildRequires: libX11-devel, pkgconfig"

* Thu Sep 29 2005 Mike A. Harris <mharris@redhat.com> 1.0.3-2
- Add missing documentation to doc macro
- Fix spec file project URL

* Sat Sep 03 2005 Mike A. Harris <mharris@redhat.com> 1.0.3-1
- Initial build.
