File dpdk.spec of Package dpdk

%define realname dpdk
%define realver  23.11
%define srcext   tar.xz

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

%define python3_pkg python3
%define python3     %{_bindir}/python3

# Common info
Name:          %{realname}
Version:       %{realver}
Release:       wiz%{?extraver:0.}1%{?dist}
License:       BSD-3-Clause and LGPL-2.1 and GPL-2.0
Group:         Development/Libraries/C and C++
URL:           http://dpdk.org/
Summary:       Set of libraries and drivers for fast packet processing

# Install-time parameters
Requires:      %{python3_pkg}%{?suse_version:-base}

# Build-time parameters
BuildRequires: xz
BuildRequires: pkg-config
BuildRequires: meson >= 0.53.2 ninja
# buildtools
BuildRequires: %{python3_pkg}-pyelftools
# config
BuildRequires: libnuma-devel
%ifnarch ix86 x86_64
BuildRequires: libfdt-devel
%endif
BuildRequires: pkgconfig(libarchive)
BuildRequires: pkgconfig(libbsd)
BuildRequires: pkgconfig(jansson)
BuildRequires: pkgconfig(openssl)
BuildRequires: pkgconfig(libpcap)
# drivers
BuildRequires: pkgconfig(libbpf)
BuildRequires: pkgconfig(zlib)

BuildRequires: doxygen
%if 0%{?suse_version}
BuildRequires: %{python3_pkg}-Sphinx
%else
BuildRequires: %{python3_pkg}-sphinx
%endif
BuildRequires: %{python3_pkg}-sphinx_rtd_theme
BuildRequires: pkgconfig(libelf)
BuildRoot:     %{_tmppath}/%{name}-root
Source:        http://fast.dpdk.org/rel/%{realname}-%{realver}%{?extraver}.%{srcext}

%description
DPDK is a set of libraries and drivers for fast packet processing. It was
designed to run on any processors. The first supported CPU was Intel x86 and it
is now extended to IBM Power 8, EZchip TILE-Gx and ARM. It runs mostly in Linux
userland. A FreeBSD port is available for a subset of DPDK features.

%package devel
Group:         Development/Languages/C and C++
Summary:       Development files for %{name}
Requires:      %{name} = %{version}-%{release}
Requires:      libpcap-devel
%if ( 0%{?suse_version} && ! 0%{?sles_version} ) && %{with xen}
Requires:      xen-devel libxenstore-devel
%endif

%description devel
Development files for %{name}

DPDK is a set of libraries and drivers for fast packet processing. It was
designed to run on any processors. The first supported CPU was Intel x86 and it
is now extended to IBM Power 8, EZchip TILE-Gx and ARM. It runs mostly in Linux
userland. A FreeBSD port is available for a subset of DPDK features.

%package devel-static
Group:         Development/Languages/C and C++
Summary:       %{name} statically built libraries
Requires:      %{name}-devel = %{version}-%{release}

%description devel-static
%{name} statically built libraries

DPDK is a set of libraries and drivers for fast packet processing. It was
designed to run on any processors. The first supported CPU was Intel x86 and it
is now extended to IBM Power 8, EZchip TILE-Gx and ARM. It runs mostly in Linux
userland. A FreeBSD port is available for a subset of DPDK features.

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{realver}%{?extraver}
# Disable mandb
%{__sed} -ri '/find_program.+mandb/,$ d' doc/api/meson.build

%build
_CFLAGS='%{optflags} -I%{_includedir}/bpf'
_LDFLAGS='-Wl,--strip-all -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro'
MACHINE=%(echo %{optflags} | %{__sed} -r 's/^.*-march=(\S+).*$/\1/' || echo default)
%if 0%{?suse_version}
export PYTHONPATH=/usr/lib/python3.6/site-packages
%endif
meson setup build \
 --buildtype=release \
 --strip \
 --optimization=2 \
 \
 --prefix=%{_prefix} \
 --libexecdir=%{_libexecdir} \
 --includedir=%{_includedir}/%{name} \
 \
 -Denable_docs=true \
 -Dibverbs_link=dlopen \
 -Dmachine=$MACHINE \
 -Dtests=false \
 \
 -Db_lto=%{?gcc_lto:true}%{!?gcc_lto:false} \
 -Db_ndebug=if-release \
 -Dc_args="$_CFLAGS" \
 -Dc_link_args="$_LDFLAGS"
ninja -v -C build %{?_smp_mflags}

%install
DESTDIR=%{buildroot} ninja -v -C build install
# Fix shebang lines
[ "%{buildroot}" != "/" ] && sed -ri '1 s|^#!.*$|#!%{python3}|' %{buildroot}%{_bindir}/*.py
# Move docs
if [ "%{_datadir}/doc" != "%{_defaultdocdir}" ] && [ "%{buildroot}" != "/" ]; then
  mkdir -p %{buildroot}%{_defaultdocdir}
  mv %{buildroot}%{_datadir}/doc/dpdk %{buildroot}%{_defaultdocdir}/
fi

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

%files
%defattr(-,root,root)
%doc MAINTAINERS README
%docdir %{_defaultdocdir}/dpdk
%doc %{_defaultdocdir}/dpdk/*
%{_bindir}/*
%{_libdir}/*.so.*
%{_libdir}/dpdk/

# Development stuff
%files devel
%defattr(-,root,root)
%doc MAINTAINERS README
%{_datadir}/%{name}/
%{_includedir}/%{name}/
%{_libdir}/pkgconfig/*.pc
%{_libdir}/*.so
%doc %{_mandir}/man3/
# conflicts with file from package libattr-devel
%exclude %{_mandir}/man3/attr_get.3*
%exclude %{_mandir}/man3/attr_set.3*

# Static libs
%files devel-static
%defattr(-,root,root)
%doc MAINTAINERS README
%{_libdir}/*.a

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

%changelog
openSUSE Build Service is sponsored by