%global debug_package %{nil}
%global commit 2c9b67072b15d903fecde67c7f269abeafee4c25
%global commitdate 20230503
%global shortcommit %(c=%{commit}; echo ${c:0:7})

Name:           v4l2loopback
Summary:        Utils for V4L2 loopback devices
Version:        0.15.3
Release:        2%?dist
License:        GPL-2.0-or-later
URL:            https://github.com/v4l2loopback/v4l2loopback
Source0:        %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
Source1:        modprobe-d-98-v4l2loopback.conf
BuildRequires:  gcc
BuildRequires:  make
BuildRequires:  help2man
BuildRequires:  sed
BuildRequires:  systemd-rpm-macros
Requires:       (%{name}-kmod = %{?epoch:%{epoch}:}%{version} or dkms-%{name} = %{?epoch:%{epoch}:}%{version})
Provides:       %{name}-kmod-common = %{?epoch:%{epoch}:}%{version}
### For compatibility with older names
Provides:       %{name}-utils = %{version}-%{release}
Obsoletes:      %{name}-utils < 0.12.5-2
Packager:       Cappy Ishihara <cappy@fyralabs.com>


%description
Allows you to create "virtual video devices". Normal (v4l2) applications will read these devices as if they were ordinary video devices, but the video will not be read from e.g. a capture card but instead it is generated by another application.

%package        akmod-modules
Summary:        Modules for Akmods
Requires:       %{name}-kmod = %{?epoch:%{epoch}:}%{version}
BuildArch:      noarch

%description    akmod-modules
Akmods modules for the akmod-%{name} package.

%prep
%autosetup -p1 -n %{name}-%{version}

/usr/bin/sed -nE '/^PACKAGE_NAME/{s@^.+"(.+)"@\1@; s|-|_|g; p}' dkms.conf > %{name}.conf

%build
%{set_build_flags}
%make_build utils

%install
%{set_build_flags}
%make_build utils


make V=1 %{?_smp_mflags} install-utils DESTDIR=%{buildroot} PREFIX=%{_prefix}
make V=1 %{?_smp_mflags} install-man DESTDIR=%{buildroot} PREFIX=%{_prefix}
install -Dm644 %{SOURCE1} %{buildroot}%{_modprobedir}/98-v4l2loopback.conf
install -Dm644 %{name}.conf -t %{buildroot}%{_modulesloaddir}


%files
%doc README.md AUTHORS NEWS
%license COPYING
%attr(0755,root,root) %{_bindir}/v4l2loopback-ctl
%attr(0644,root,root) %{_mandir}/man1/v4l2loopback-ctl.1*
%{_modprobedir}/98-v4l2loopback.conf

%files akmod-modules
%{_modulesloaddir}/v4l2loopback.conf

%changelog
%autochangelog
