File bpftool.spec of Package bpftool.34001

#
# spec file for package bpftool
#
# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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/
#

# Use default LLVM on openSUSE unless it is not yet supported
%if 0%{?suse_version} >= 1600 || 0%{?is_opensuse}
 %if 0%{?product_libs_llvm_ver} > 17
 %define llvm_major_version 17
 %else
 %define llvm_major_version %{nil}
 %endif
%else
 # Hard-code latest LLVM for SLES, the default version is too old
 %if 0%{?sle_version} == 150600
  %define llvm_major_version 17
 %else
 %if 0%{?sle_version} == 150500
  %define llvm_major_version 15
 %else
 %if 0%{?sle_version} == 150400
  %define llvm_major_version 11
 %endif
 %endif
 %endif
%endif

Name:           bpftool
%define version %(rpm -q --qf '%%{VERSION}' kernel-source)
Version:        %{version}
Release:        0
Summary:        Tool for inspection and manipulation of BPF programs and maps
License:        GPL-2.0-only
Group:          Development/Tools/Other
Url:            http://www.kernel.org/
# Needed for compiling included BPF program (i.e. skeletons)
BuildRequires:  clang%{llvm_major_version}
BuildRequires:  docutils
BuildRequires:  dwarves
BuildRequires:  kernel-source
BuildRequires:  libelf-devel
# llvm-strip is needed for the included BPF program (i.e. skeletons)
BuildRequires:  llvm%{llvm_major_version}

%description
bpftool allows for inspection and simple modification of BPF objects (programs
and maps) on the system.

%prep
(cd /usr/src/linux ; tar -cf - COPYING CREDITS README tools include scripts Kbuild Makefile arch/*/{include,lib,Makefile} kernel/bpf lib) | tar -xf -
cp /usr/src/linux/LICENSES/preferred/GPL-2.0 .
sed -i -e 's/CFLAGS += -O2/CFLAGS = $(RPM_OPT_FLAGS)/' Makefile

%build
cd tools/bpf/bpftool
%make_build V=1 feature-reallocarray=1 all doc

%install
cd tools/bpf/bpftool
make install doc-install DESTDIR=%{buildroot} prefix=%{_prefix} mandir=%{_mandir}

%files
%license GPL-2.0
%{_sbindir}/bpftool
%{_datadir}/bash-completion/completions/bpftool
%{_mandir}/man?/*.gz

%changelog
openSUSE Build Service is sponsored by