File perf.spec of Package perf.26488

#
# 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/
#


Name:           perf
%define version %(rpm -q --qf '%{VERSION}' kernel-source)
Version:        %{version}
Release:        0
Summary:        Performance Monitoring Tools for Linux
License:        GPL-2.0-only
Group:          Development/Tools/Debuggers
Url:            https://perf.wiki.kernel.org/
BuildRequires:  asciidoc
BuildRequires:  audit-devel
BuildRequires:  binutils-devel
BuildRequires:  bison
BuildRequires:  fdupes
BuildRequires:  flex
BuildRequires:  gtk2-devel
BuildRequires:  kernel-source >= 2.6.31
BuildRequires:  libdw-devel
BuildRequires:  libelf-devel
BuildRequires:  OpenCSD-devel
BuildRequires:  python3-devel
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
# dl_open requirement so not autodetected
%ifarch ppc64 ppc64le
Requires:       libebl
%endif
%{perl_requires}
%{?libperl_requires}
# upstream patches
Patch1:         perf-tests-attr-Add-missing-topdown-metrics-events.patch
Patch2:         perf-bpf-Avoid-memory-leak-from-perf_env__insert_btf.patch
Patch3:         perf-tests-Remove-bash-construct-from-record-zstd_comp_decomp.sh.patch
Patch4:         perf-bench-Fix-two-memory-leaks-detected-with-ASan.patch
Patch5:         perf-tools-Fix-SMT-detection-fast-read-path.patch
Patch6:         tools-build-Remove-needless-libpython-version-feature-check-that-breaks-test-all-fast-path.patch
Patch7:         perf-bpf-Fix-building-perf-with-BUILD_BPF_SKEL-1-by-default-in-more-distros.patch
Patch8:         perf-bpf_skel-Do-not-use-typedef-to-avoid-error-on-old-clang.patch
Patch9:         perf-intel-pt-Fix-some-PGE-packet-generation-enable-control-flow-packets-usage.patch
Patch10:        perf-intel-pt-Fix-sync-state-when-a-PSB-synchronization-packet-is-found.patch
Patch11:        perf-intel-pt-Fix-intel_pt_fup_event-assumptions-about-setting-state-type.patch
Patch12:        perf-intel-pt-Fix-state-setting-when-receiving-overflow-OVF-packet.patch
Patch13:        perf-intel-pt-Fix-next-err-value-walking-trace.patch
Patch14:        perf-intel-pt-Fix-missing-instruction-events-with-q-option.patch
Patch15:        perf-intel-pt-Fix-error-timestamp-setting-on-the-decoder-error-path.patch
Patch16:        perf-inject-Fix-segfault-due-to-close-without-open.patch
Patch17:        perf-intel-pt-Fix-parsing-of-VM-time-correlation-arguments.patch
Patch18:        perf-script-Fix-CPU-filtering-of-a-script-s-switch-events.patch
Patch19:        perf-scripts-python-intel-pt-events.py-Fix-printing-of-switch-events.patch
Patch20:        perf-script-Fix-hex-dump-character-output.patch
Patch21:        perf-probe-Fix-ppc64-perf-probe-add-events-failed-case.patch
Patch22:        perf-evsel-Override-attr-sample_period-for-non-libpfm4-events.patch
Patch23:        perf-stat-Fix-display-of-grouped-aliased-events.patch
Patch24:        perf-bpf-Defer-freeing-string-after-possible-strlen-on-it.patch
Patch25:        perf-data-Fix-double-free-in-perf_session__delete.patch
Patch26:        perf-symbols-Fix-symbol-size-calculation-condition.patch
Patch27:        perf-stat-Fix-forked-applications-enablement-of-counters.patch
Patch28:        perf-arm-spe-Fix-perf-report-mem-mode.patch
Patch29:        perf-tools-Fix-perf-s-libperf_print-callback.patch
Patch30:        perf-session-Remap-buf-if-there-is-no-space-for-event.patch
Patch31:        perf-tools-Fix-misleading-add-event-PMU-debug-message.patch
Patch32:        perf-bench-Fix-numa-testcase-to-check-if-CPU-used-to-bind-task-is-online.patch
Patch33:        perf-bench-Fix-numa-bench-to-fix-usage-of-affinity-for-machines-with-CPUs-1K.patch
Patch34:        perf-script-Always-allow-field-data_src-for-auxtrace.patch
Patch35:        perf-report-Set-PERF_SAMPLE_DATA_SRC-bit-for-Arm-SPE-event.patch
Patch36:        perf-arm-spe-Fix-addresses-of-synthesized-SPE-events.patch
# non upstream patches

Requires:       kernel >= 2.6.31
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. 

%prep
# copy necessary files from kernel-source since we need to modify them
(cd /usr/src/linux ; tar -cf - COPYING CREDITS README tools include scripts Kbuild Makefile arch/*/{include,lib,Makefile} lib) | tar -xf - 
chmod +x tools/perf/util/generate-cmdlist.sh

%autopatch -p1

# 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

%build
cd tools/perf
export WERROR=0
# PASS rpm optflags as EXTRA_FLAGS,  passing as CFLAGS overrides and breaks build
make %{?_smp_mflags} -f Makefile.perf VF=1 GTK2=1 CORESIGHT=1 PYTHON=python3 EXTRA_CFLAGS="%{optflags}" ASCIIDOC8=1 prefix=/usr libdir=%{_libdir} perfexecdir=lib/%{name}-core %{_perf_unwind} tipdir=share/doc/packages/perf all
make %{?_smp_mflags} -f Makefile.perf VF=1 GTK2=1 CORESIGHT=1 PYTHON=python3 EXTRA_CFLAGS="%{optflags}" ASCIIDOC8=1 prefix=/usr libdir=%{_libdir} perfexecdir=lib/%{name}-core %{_perf_unwind} tipdir=share/doc/packages/perf doc

%install
cd tools/perf
export WERROR=0
make -f Makefile.perf GTK2=1 CORESIGHT=1 PYTHON=python3 EXTRA_CFLAGS="%{optflags}" prefix=/usr libdir=%{_libdir} perfexecdir=lib/%{name}-core DESTDIR=%{buildroot} %{_perf_unwind} tipdir=share/doc/packages/perf install
make -f Makefile.perf GTK2=1 CORESIGHT=1 PYTHON=python3 EXTRA_CFLAGS="%{optflags}" prefix=/usr libdir=%{_libdir} perfexecdir=lib/%{name}-core DESTDIR=%{buildroot} install %{_perf_unwind} tipdir=share/doc/packages/perf install-doc
mkdir -p %{buildroot}/%{_docdir}/perf/examples/bpf
mv %{buildroot}/usr/lib/perf/examples/bpf/* %{buildroot}/%{_docdir}/perf/examples/bpf

%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
%{_libdir}/libperf-gtk.so
%ifnarch armv7l
%dir %{_libdir}/traceevent
%dir %{_libdir}/traceevent/plugins
%{_libdir}/traceevent/plugins/plugin_*.so
%endif
%attr(0644, -, -) %{_sysconfdir}/bash_completion.d/perf
%{_libexecdir}/%{name}-core
%{_datarootdir}/%{name}-core
%{_mandir}/man1/perf*
%dir /usr/lib/perf

%files devel
%dir %{_includedir}/perf/
%attr(0644, root, root) %{_includedir}/perf/*.h
%dir /usr/lib/perf/include
%dir /usr/lib/perf/include/bpf
%attr(0644, root, root) /usr/lib/perf/include/bpf/*.h
%dir /usr/lib/perf/include/bpf/linux
%attr(0644, root, root) /usr/lib/perf/include/bpf/linux/*.h
%dir %{_docdir}/perf/examples
%dir %{_docdir}/perf/examples/bpf
%attr(0644, root, root) %{_docdir}/perf/examples/bpf/*

%changelog
openSUSE Build Service is sponsored by