File evdi.spec of Package evdi-new

#
# spec file for package evdi
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#

%bcond_without dkms

%define lname   libevdi1
Name:           evdi
Version:        1.14.0
Release:        0
Summary:        Extensible Virtual Display Interface (EVDI) is a Linux Kernel Module
License:        GPL-2.0-only AND LGPL-2.1-only
Group:          System/Kernel
URL:            https://github.com/DisplayLink/evdi
Source0:        https://github.com/DisplayLink/evdi/archive/refs/tags/evdi-%{version}.tar
Patch0:         Delete-not-needed-includes.patch
Patch1:         delete-unused-include.patch
Patch2:         evdi_gem-enalble-compilation-against-SL.patch
BuildRequires:  %{kernel_module_package_buildreqs}
BuildRequires:  dkms
BuildRequires:  linux-glibc-devel
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(libdrm)
BuildRequires:  pkgconfig(libsystemd)
%kernel_module_package -p %_sourcedir/preamble

%description
The Extensible Virtual Display Interface (EVDI) is a Linux kernel module
that enables management of multiple screens, allowing user-space programs
to take control over what happens with the image. It is essentially
a virtual display you can add, remove and receive screen updates for, in
an application that uses the libevdi library.

%package -n %{lname}
Summary:        LibEVDI Library
Group:          System/Libraries

%description -n %{lname}
The Extensible Virtual Display Interface (EVDI) is a Linux kernel module
that enables management of multiple screens, allowing user-space programs
to take control over what happens with the image. It is essentially
a virtual display you can add, remove and receive screen updates for, in
an application that uses the libevdi library.

%package devel
Summary:        Development files for libevdi Library
Group:          Development/Libraries/C and C++
Requires:       %{lname} = %{version}

%description devel
The Extensible Virtual Display Interface (EVDI) is a Linux kernel module
that enables management of multiple screens, allowing user-space programs
to take control over what happens with the image. It is essentially
a virtual display you can add, remove and receive screen updates for, in
an application that uses the libevdi library.


#%package -n dkms-%{name}
#Summary:        DKMS EVDI module
#Group:          System/Kernel
#Requires:       dkms
#
#%description -n dkms-%{name}
#The Extensible Virtual Display Interface (EVDI) is a Linux kernel module
#that enables management of multiple screens, allowing user-space programs
#to take control over what happens with the image. It is essentially
#a virtual display you can add, remove and receive screen updates for, in
#an application that uses the libevdi library.

%prep
#%autosetup -p1
%setup -q
%patch0 -p1 
%patch1 -p1

%if 0%{?sle_version} == 150500
%patch2 -p1
%endif

%build
pushd library
%make_build
mv LICENSE LICENSE.library
popd
pushd module
sed -i 's:include/drm:/usr/src/linux/include/drm:' Makefile
sed -i 's:/kernel/drivers/gpu/drm/evdi:/extra:' Makefile
popd
for flavor in %{flavors_to_build}; do
    rm -rf obj/$flavor
    mkdir -p obj/$flavor
    cp -r module obj/$flavor
    cd obj/$flavor/module
    make KDIR=%{kernel_source $flavor} module
    cd ../../..
done
mv LICENSE LICENSE.module

%install
pushd library
%make_install PREFIX=%{_prefix} LIBDIR=%{_libdir} CFLAGS="%{optflags}"
install -m644 -D evdi_lib.h %{buildroot}%{_includedir}/%{name}/evdi_lib.h
popd
for flavor in %{flavors_to_build}; do
        pushd obj/$flavor/module
        make DESTDIR=%{buildroot} \
             KDIR=%{kernel_source $flavor} install
        popd
done
#%if %{with dkms}
#mkdir -p %{buildroot}%{_prefix}/src
#cp -r module %{buildroot}%{_prefix}/src/%{name}-%{version}
#%endif

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

#%if %{with dkms}
#%post -n dkms-%{name}
#if ! %{_sbindir}/dkms status %{name}/%{version} | grep 'installed'; then
#  %{_sbindir}/dkms add evdi/%{version} --rpm_safe_upgrade
#fi
#%{_sbindir}/dkms build evdi/%{version}
#%{_sbindir}/dkms install evdi/%{version}
#
#
#%preun -n dkms-%{name}
#if %{_sbindir}/dkms status %{name}/%{version} | grep 'installed'; then
#  %{_sbindir}/dkms remove evdi/%{version} --all --rpm_safe_upgrade
#fi
#%endif

%files
%license {library,module}/LICENSE*
%doc README.md docs

%files -n %{lname}
%{_libdir}/libevdi.so.1*

%files devel
%{_libdir}/libevdi.so
%{_includedir}/%{name}

#%if %{with dkms}
#%files -n dkms-%{name} 
#%{_prefix}/src/evdi-%{version}
#%endif

%changelog


openSUSE Build Service is sponsored by