%global git_date  20241204
%global git_hash  38ec7dbd

%global git_ver  2.4.124
%global rel  1
%global src_name drm-%{git_date}-%{git_hash}.tar.xz

Name:           libdrm
Summary:        Direct Rendering Manager runtime library
Version:	%{git_ver}^%{git_date}g%{git_hash}
Release:	%{rel}%{?dist}
License:        MIT

URL:            https://gitlab.freedesktop.org/mesa/drm
Source0:        %{url}/%{src_name}
#Source1:        README.rst
Source2:        91-drm-modeset.rules

BuildRequires:  meson
BuildRequires:  gcc cmake
BuildRequires:  libatomic_ops-devel
BuildRequires:  kernel-headers
BuildRequires:  pkgconfig(pciaccess)
BuildRequires:  pkgconfig(udev)
BuildRequires:  chrpath
#BuildRequires:  pkgconfig(cairo)
BuildRequires:  pkgconfig(cunit)


# hardcode the 666 instead of 660 for device nodes
Patch1001:      libdrm-make-dri-perms-okay.patch
# remove backwards compat not needed on Fedora
#Patch1002:      libdrm-2.4.0-no-bc.patch

%description
Direct Rendering Manager runtime library

%package devel
Summary:        Direct Rendering Manager development package
Requires:       %{name}%{?_isa} = %{version}-%{release}
Requires:       kernel-headers

%description devel
Direct Rendering Manager development package.

%prep
%autosetup -n drm -p1

%build
%meson 	-D vc4=disabled \
	-D intel=enabled \
	-D radeon=enabled \
	-D amdgpu=enabled \
	-D nouveau=enabled \
	-D vmwgfx=disabled \
	-D omap=disabled \
	-D exynos=disabled \
	-D freedreno=disabled \
	-D tegra=disabled \
	-D etnaviv=disabled \
	-D freedreno-kgsl=false \
	-D install-test-programs=false \
	-D udev=false \
	-D tests=false \
	-D valgrind=disabled \
	-D cairo-tests=disabled \
	-D man-pages=disabled
%meson_build

%install
%meson_install
install -Dpm0644 -t %{buildroot}%{_udevrulesdir} %{S:2}

%ldconfig_scriptlets

%files
%doc README.rst
%{_libdir}/libdrm.so.2
%{_libdir}/libdrm.so.2.*
%dir %{_datadir}/libdrm
%{_libdir}/libdrm_intel.so.1
%{_libdir}/libdrm_intel.so.1.*
%{_libdir}/libdrm_radeon.so.1
%{_libdir}/libdrm_radeon.so.1.*
%{_libdir}/libdrm_amdgpu.so.1
%{_libdir}/libdrm_amdgpu.so.1.*
%{_datadir}/libdrm/amdgpu.ids
%{_libdir}/libdrm_nouveau.so.2
%{_libdir}/libdrm_nouveau.so.2.*
%{_udevrulesdir}/91-drm-modeset.rules

%files devel
%dir %{_includedir}/libdrm
%{_includedir}/libdrm/drm.h
%{_includedir}/libdrm/drm_fourcc.h
%{_includedir}/libdrm/drm_mode.h
%{_includedir}/libdrm/drm_sarea.h
%{_includedir}/libdrm/*_drm.h
%{_libdir}/libdrm.so
%{_libdir}/pkgconfig/libdrm.pc
%{_includedir}/libdrm/intel_*.h
%{_libdir}/libdrm_intel.so
%{_libdir}/pkgconfig/libdrm_intel.pc
%{_includedir}/libdrm/radeon_{bo,cs,surface}*.h
%{_includedir}/libdrm/r600_pci_ids.h
%{_libdir}/libdrm_radeon.so
%{_libdir}/pkgconfig/libdrm_radeon.pc
%{_includedir}/libdrm/amdgpu.h
%{_libdir}/libdrm_amdgpu.so
%{_libdir}/pkgconfig/libdrm_amdgpu.pc
%{_includedir}/libsync.h
%{_includedir}/xf86drm.h
%{_includedir}/xf86drmMode.h
%{_libdir}/libdrm_nouveau.so
%{_includedir}/libdrm/nouveau/nvif/*.h
%{_includedir}/libdrm/nouveau/nouveau.h
%{_libdir}/pkgconfig/libdrm_nouveau.pc

%changelog
%autochangelog