File xdp-tools.spec of Package xdp-tools
%define realname xdp-tools
%define realver 1.4.1
%define srcext tar.gz
%define so_ver 1
# turn off the generation of debuginfo rpm (RH9) ??
%global debug_package %{nil}
%if 0%{?rhel}
# Disable stripping by brp-strip
%global __strip /bin/true
%endif
# Common info
Name: %{realname}
Version: %{realver}
Release: %{?extraver:0.}1%{?dist}
License: GPL-2.0
Group: Productivity/Networking/Other
URL: https://github.com/xdp-project/xdp-tools
Summary: Utilities and example programs for use with XDP
# Install-time parameters
# Build-time parameters
BuildRequires: clang llvm
BuildRequires: m4
BuildRequires: pkg-config
BuildRequires: pkgconfig(zlib)
BuildRequires: pkgconfig(libelf)
BuildRequires: pkgconfig(libpcap)
BuildRequires: pkgconfig(libcap-ng)
BuildRequires: pkgconfig(libbpf)
Source0: https://codeload.github.com/xdp-project/xdp-tools/%{srcext}/refs/tags/v%{realver}#/%{realname}-%{realver}%{?extraver}.%{srcext}
%description
A collection of utilities for use with XDP.
%package -n libxdp%{so_ver}
License: LGPL-2.1 or BSD-2-Clause
Group: System/Libraries
Summary: XDP library
%description -n libxdp%{so_ver}
Library for working with the eXpress Data Path facility of the Linux kernel.
%package -n libxdp-devel
License: LGPL-2.1 or BSD-2-Clause
Group: Development/Languages/C and C++
Summary: Development files for libxdp
Requires: libxdp%{so_ver} = %{version}-%{release}
Provides: %{name}-devel = %{version}-%{release}
Provides: libxdp%{so_ver}-devel = %{version}-%{release}
%description -n libxdp-devel
Development files for libxdp.
# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{realver}%{?extraver}
%build
_CFLAGS='%{optflags}'
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro'
_GCCINC="-I$(gcc -print-search-dirs | awk '$1 == "install:" {print $2}')include"
PRODUCTION=1 DYNAMIC_LIBXDP=1 ./configure
%{__sed} -ri \
-e "s|^(CFLAGS\s*.?=\s*)(.*)$|\1$_CFLAGS \2|" \
-e "s|^(LDLIBS\s*.?=\s*)(.*)$|\1$_LDFLAGS \2|" \
-e "s|^(ARCH_INCLUDES\s*.?=\s*)(.*)$|\1$_GCCINC \2|" \
config.mk
%{__make} %{?_smp_mflags} V=1
%install
%{__make} install DESTDIR=%{buildroot} \
SBINDIR=%{_sbindir} \
DATADIR=%{_datadir} \
HDRDIR=%{_includedir}/xdp \
LIBDIR=%{_libdir} \
BPF_OBJECT_DIR=%{_libdir}/bpf \
MANDIR=%{_mandir}
%clean
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
%files
%defattr(-,root,root)
%license LICENSES/GPL-2.0
%doc README.org
%{_sbindir}/xdp*
%{_datadir}/xdp-tools/
%doc %{_mandir}/man8/*
%files -n libxdp%{so_ver}
%defattr(-,root,root)
%license LICENSES/LGPL-2.1 LICENSES/BSD-2-Clause
%{_libdir}/libxdp.so.%{so_ver}*
%if 0%{?suse_version}
%dir %{_libdir}/bpf
%endif
%{_libdir}/bpf/*
%files -n libxdp-devel
%defattr(-,root,root)
%dir %{_includedir}/xdp/
%{_includedir}/xdp/*.h
%{_libdir}/libxdp.so
%{_libdir}/libxdp.a
%{_libdir}/pkgconfig/libxdp.pc
%doc %{_mandir}/man3/*
%post -n libxdp%{so_ver} -p /sbin/ldconfig
%postun -n libxdp%{so_ver} -p /sbin/ldconfig
%changelog