File perf.spec of Package perf.36962

#
# spec file for package perf
#
# Copyright (c) 2018 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 http://bugs.opensuse.org/
#


# A bug in dwz leaves temporary trace-*.debug.#dwz#.* on 64 bits in place
# It was long ago fixed in OpenSUSE but somehow is now occuring on SLE15-SP6
# https://sourceware.org/bugzilla/show_bug.cgi?id=26645
# https://bugzilla.suse.com/show_bug.cgi?id=1180984

%define _find_debuginfo_dwz_opts %{nil}

Name:           perf
Version:        6.4.0.git26920.4570763476
Release:        0
Summary:        Performance Monitoring Tools for Linux
License:        GPL-2.0-only
Group:          Development/Tools/Debuggers
Url:            https://perf.wiki.kernel.org/
Source0:		%{name}-%{version}.tar.gz
BuildRequires:  asciidoc
BuildRequires:  audit-devel
BuildRequires:  binutils-devel
BuildRequires:  bison
BuildRequires:  fdupes
BuildRequires:  flex
BuildRequires:  gcc-c++
BuildRequires:  gtk2-devel
BuildRequires:  libdw-devel
BuildRequires:  libelf-devel
BuildRequires:  libtraceevent-devel
BuildRequires:  llvm
BuildRequires:  OpenCSD-devel
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
BuildRequires:  xz-devel
%ifarch aarch64 ia64 x86_64 ppc64 ppc64le ppc %sparc
BuildRequires:  libnuma-devel
%endif
%ifarch s390x s390
%define         _perf_unwind NO_LIBUNWIND=1
%else
%define         _perf_unwind %{nil}
BuildRequires:  libunwind-devel
%endif
BuildRequires:  newt-devel
BuildRequires:  openssl-devel
BuildRequires:  xmlto
BuildRequires:  zlib-devel
BuildRequires:  rubygem(asciidoctor)
# dl_open requirement so not autodetected
%ifarch ppc64 ppc64le
Requires:       libebl
%endif
%{perl_requires}
%{?libperl_requires}
# upstream patches
# non upstream patches

BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
This package provides a userspace tool 'perf', which monitors performance for
either unmodified binaries or the entire system. It requires a Linux kernel
which includes the Performance Counters for Linux (PCL) subsystem (>= 2.6.31).
This subsystem utilizes the Performance Monitoring Unit (PMU) / hardware
counters of the underlying cpu architecture (if supported).

%package devel
Summary:        Development headers for perf
Group:          Development/Libraries/Other
Requires:       %{name} = %{version}

%description devel
Development headers for perf. 

%package gtk
Summary:        Gtk browser for perf-report
Group:          Development/Tools/Other
Requires:       %{name} = %{version}

%description gtk
A GTK2 frontend for perf-report. (Use `perf report --gtk`.)

%package bash-completion
Summary:        Bash completion for perf
Group:          System/Shells
Requires:       %{name}
Requires:       bash-completion
Supplements:    (%{name} and bash-completion)

%description bash-completion
bash command line completion support for perf.

%prep
%setup -q
chmod +x tools/perf/util/generate-cmdlist.sh

# don't error out on deprecated definitions in gtk2.h
sed -i 's@ignored "-Wstrict-prototypes"@&\n#pragma GCC diagnostic ignored "-Wdeprecated-declarations"@' tools/build/feature/test-gtk2.c

# skip info-from-txt generation (it's the same as man anyway)
sed -i.old 's@\(all: .*\)info@\1@' tools/perf/Documentation/Makefile

# BPF_SKEL=1 requires clang, enable when we resolve CLANG in SLE issue
%define perf_options LIBTRACEEVENT_DYNAMIC=1 CORESIGHT=1 GTK2=1 PYTHON=python3 ASCIIDOC8=1 USE_ASCIIDOCTOR=1 EXTRA_CFLAGS="%{optflags}" feature-libbfd-liberty=1 feature-disassembler-four-args=1 prefix=/usr libdir=%{_libdir} perfexecdir=lib/%{name}-core %{_perf_unwind} tipdir=share/doc/packages/perf

%build
cd tools/perf
export WERROR=0
# PASS rpm optflags as EXTRA_FLAGS,  passing as CFLAGS overrides and breaks build

# Specifying "all doc" as one invocation when using -f Makefile.perf doesn't 
# work and all is deferred to later %install; so seperate into two 

make %{?_smp_mflags} -f Makefile.perf \
	V=0 VF=0 \
	%{perf_options} \
	all	

make %{?_smp_mflags} -f Makefile.perf \
	V=0 VF=0 \
	%{perf_options} \
	doc

%install
cd tools/perf
export WERROR=0

make -f Makefile.perf \
	%{perf_options} \
	DESTDIR=%{buildroot} \
	install install-doc

mkdir -p %{buildroot}%{_datadir}/bash-completion/completions/
mv %{buildroot}%{_sysconfdir}/bash_completion.d/perf %{buildroot}%{_datadir}/bash-completion/completions/

%fdupes %{buildroot}/%{_prefix}/lib/%{name}-core

%files
%defattr(-, root, root)
%attr(0644, root, root) %doc COPYING CREDITS README tools/perf/design.txt
%attr(0644, root, root) %doc %{_docdir}/perf/tips.txt
%{_bindir}/perf
%{_bindir}/trace
%{_libexecdir}/%{name}-core
%{_datarootdir}/%{name}-core
%{_mandir}/man1/perf*

%files devel
%dir %{_includedir}/perf/
%attr(0644, root, root) %{_includedir}/perf/*.h

%files gtk
%{_libdir}/libperf-gtk.so

%files bash-completion
%dir %{_datadir}/bash-completion
%dir %{_datadir}/bash-completion/completions
%{_datadir}/bash-completion/completions/perf

%changelog
openSUSE Build Service is sponsored by