File netmap.spec of Package netmap

%define realname netmap
%define srcext   tar.bz2

# See `grep -F 'call default' netmap/LINUX/default-config.mak.in_`
%define intel_driver_ixgbe_ver   5.15.2
%define intel_driver_ixgbevf_ver 4.15.1
%define intel_driver_e1000e_ver  3.8.7
%define intel_driver_igb_ver     5.10.2
%define intel_driver_i40e_ver    2.19.3
%define intel_driver_ice_ver     1.9.11
%define mlnx_driver_ver          5.3-1.0.0.1
# See `grep -F virtio_net.c@fetch netmap/LINUX/default-config.mak.in_`
%define virtio_net_ver           4.9

# turn off the generation of debuginfo rpm  (RH9) ??
%global debug_package %{nil}

# Common info
Name:          %{realname}
Version:       11.1
Release:       wiz%{?extraver:0.}1%{?dist}
License:       BSD-2-Clause
Group:         Productivity/Networking/System
URL:           http://info.iet.unipi.it/~luigi/netmap/
Summary:       The fast packet I/O framework

# Build-time parameters
ExclusiveOS:   Linux
%if 0%{?suse_version}
BuildRequires: %kernel_module_package_buildreqs
BuildRequires: kernel-source
%else
BuildRequires: kernel-headers kernel-devel kernel-rpm-macros kmod
BuildRequires: elfutils-libelf-devel
%endif
# Needed for rpmlint
%if 0%{?opensuse_bs}
BuildRequires: dkms
%endif
BuildRoot:     %{_tmppath}/%{name}-root
Source0:       %{realname}-%{version}%{?extraver}.%{srcext}
Source1:       https://sourceforge.net/projects/e1000/files/ixgbe%20stable/%{intel_driver_ixgbe_ver}/ixgbe-%{intel_driver_ixgbe_ver}.tar.gz
Source2:       https://sourceforge.net/projects/e1000/files/ixgbevf%20stable/%{intel_driver_ixgbevf_ver}/ixgbevf-%{intel_driver_ixgbevf_ver}.tar.gz
Source3:       https://sourceforge.net/projects/e1000/files/e1000e%20historic%20archive/%{intel_driver_e1000e_ver}/e1000e-%{intel_driver_e1000e_ver}.tar.gz
Source4:       https://sourceforge.net/projects/e1000/files/igb%20stable/%{intel_driver_igb_ver}/igb-%{intel_driver_igb_ver}.tar.gz
Source5:       https://sourceforge.net/projects/e1000/files/i40e%20stable/%{intel_driver_i40e_ver}/i40e-%{intel_driver_i40e_ver}.tar.gz
Source6:       https://sourceforge.net/projects/e1000/files/ice%20stable/%{intel_driver_ice_ver}/ice-%{intel_driver_ice_ver}.tar.gz
Source7:       http://content.mellanox.com/ofed/MLNX_EN-%{mlnx_driver_ver}/mlnx-en-%{mlnx_driver_ver}-ubuntu18.04-x86_64.tgz
Source8:       https://raw.githubusercontent.com/torvalds/linux/v%{virtio_net_ver}/drivers/net/virtio_net.c
Source11:      kbuild-makefile

%description
NETMAP is a framework for very fast packet I/O from userspace.
VALE is an equally fast in-kernel software switch using the netmap API.
Both are implemented as a single kernel module for FreeBSD, Linux and
since summer 2015, also for Windows.
Netmap/VALE can handle tens of millions of packets per second, matching
the speed of 10G and 40G ports even with minimum sized frames.

%kernel_module_package %{?suse_version:-p %_sourcedir/preamble} -x kdump -x um -x ec2 -x debug

%package KMP
Group:         System/Kernel
Summary:       Kernel module for netmap

%description KMP
Kernel module for netmap

%package tools
Group:         Productivity/Networking/System
Summary:       Diagnostic tools for netmap

%description tools
NETMAP is a framework for very fast packet I/O from userspace.
VALE is an equally fast in-kernel software switch using the netmap API.
Both are implemented as a single kernel module for FreeBSD, Linux and
since summer 2015, also for Windows.
Netmap/VALE can handle tens of millions of packets per second, matching
the speed of 10G and 40G ports even with minimum sized frames.

This package contains diagnostic tools for netmap

%package devel
Group:         Development/Languages/C and C++
Summary:       Development files for netmap

%description devel
NETMAP is a framework for very fast packet I/O from userspace.
VALE is an equally fast in-kernel software switch using the netmap API.
Both are implemented as a single kernel module for FreeBSD, Linux and
since summer 2015, also for Windows.
Netmap/VALE can handle tens of millions of packets per second, matching
the speed of 10G and 40G ports even with minimum sized frames.

This package contains development files for netmap

%package dkms
Group:         System/Kernel
Summary:       Kernel module for netmap for DKMS
Requires:      dkms kernel-devel

%description dkms
NETMAP is a framework for very fast packet I/O from userspace.
VALE is an equally fast in-kernel software switch using the netmap API.
Both are implemented as a single kernel module for FreeBSD, Linux and
since summer 2015, also for Windows.
Netmap/VALE can handle tens of millions of packets per second, matching
the speed of 10G and 40G ports even with minimum sized frames.

This package contains DKMS-prepared kernel module sources.

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{version}%{?extraver}
# Copy driver sources
%{__install} -m0644 %{S:1} %{S:2} %{S:3} %{S:4} %{S:5} %{S:6} %{S:7} %{S:8} LINUX/ext-drivers/
# Do not download driver sources
%{__sed} -ri 's/wget/true/' LINUX/default-config.mak.in_

%build
export EXTRA_CFLAGS=-fno-pie
./configure \
 --kernel-dir=%{kernel_source default} \
 --kernel-opts='KBUILD_CPPFLAGS=-fno-pie' \
 \
 --enable-vale \
 --enable-pipe \
 --enable-monitor \
 --enable-generic \
 --enable-ptnetmap \
 --enable-sink \
 --enable-extmem \
 \
 --prefix=%{_prefix}
%{__make} %{?_smp_mflags} apps

%install
%{__make} install-apps install-headers DESTDIR=%{buildroot}

%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}

%files tools
%defattr(-,root,root)
%license LICENSE
%doc README.md
%{_bindir}/*
%doc %{_mandir}/man4/*
%doc %{_mandir}/man8/*

# Development stuff
%files devel
%defattr(-,root,root)
%license LICENSE
%doc README.md
%dir %{_includedir}/net/
%{_includedir}/net/*.h
%{_includedir}/libnetmap.h

%files dkms
%defattr(-,root,root)
%license LICENSE
%doc README.md
%dir /usr/src/%{name}-%{version}
/usr/src/%{name}-%{version}/*

%post dkms
/usr/sbin/dkms add -q -m %{name} -v %{version} || :

%preun dkms
/usr/sbin/dkms remove -q --all -m %{name} -v %{version} || :

%changelog
openSUSE Build Service is sponsored by