File perf.spec of Package perf.16341

#
# 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:  flex
BuildRequires:  gtk2-devel
BuildRequires:  kernel-source >= 2.6.31
BuildRequires:  libdw-devel
BuildRequires:  libelf-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-tools-add-itrace-option-o-to-synthesize-aux-output-events.patch
Patch2:         perf-tools-add-aux-output-config-term.patch
Patch3:         perf-tools-add-aux_output-attribute-flag.patch
Patch4:         perf-intel-pt-process-options-for-pebs-event-synthesis.patch
Patch5:         perf-intel-pt-add-brief-documentation-for-pebs-via-intel-pt.patch
Patch6:         perf-c2c-fix-report-with-offline-cpus.patch
Patch7:         perf-c2c-display-proper-cpu-count-in-nodes-column.patch
Patch8:         perf-vendor-events-amd-remove-redundant.patch
Patch9:         perf-list-allow-plurals-for-metric-metricgroup.patch
Patch10:        perf-vendor-events-remove-p8-hw-events-which-are-not-supported.patch
Patch11:        perf-vendor-events-s390-add-json-transaction-for-machine-type-8561.patch
Patch12:        perf-vendor-events-s390-use-s390-machine-name-instead-of-type-8561.patch
Patch13:        perf-script-allow-time-with-reltime.patch
Patch14:        perf-test-report-failure-for-mmap-events.patch
Patch15:        perf-vendor-events-arm64-fix-hisi-hip08-ddrc-pmu-eventname.patch
Patch16:        perf-probe-fix-to-find-range-only-function-instance.patch
Patch17:        perf-probe-walk-function-lines-in-lexical-blocks.patch
Patch18:        perf-probe-fix-wrong-address-verification.patch
Patch19:        perf-probe-fix-to-show-ranges-of-variables-in-functions-without-entry_pc.patch
Patch20:        perf-probe-fix-to-show-inlined-function-callsite-without-entry_pc.patch
Patch21:        perf-probe-fix-to-show-function-entry-line-as-probe-able.patch
Patch22:        perf-probe-fix-to-probe-an-inline-function-which-has-no-entry-pc.patch
Patch23:        perf-probe-fix-to-probe-a-function-which-has-no-entry-pc.patch
Patch24:        perf-probe-fix-to-list-probe-event-with-correct-line-number.patch
Patch25:        perf-jevents-fix-resource-leak-in-process_mapfile-and-main.patch
Patch26:        perf-vendor-events-intel-update-all-the-intel-json-metrics-from-tmam-3-6.patch
Patch27:        perf-probe-skip-end-of-sequence-and-non-statement-lines.patch
Patch28:        perf-probe-skip-overlapped-location-on-searching-variables.patch
Patch29:        perf-probe-fix-to-show-calling-lines-of-inlined-functions.patch
Patch30:        perf-probe-filter-out-instances-except-for-inlined-subroutine-and-subprogram.patch
Patch31:        perf-tests-fix-out-of-bounds-memory-access.patch
Patch32:        perf-map-no-need-to-adjust-the-long-name-of-modules.patch
Patch33:        perf-callchain-fix-segfault-in-thread__resolve_callchain_sample.patch
Patch34:        perf-diff-use-llabs-with-64-bit-values.patch
Patch35:        perf-script-fix-brstackinsn-for-auxtrace.patch
Patch36:        perf-regs-make-perf_reg_name-return-unknown-instead-of-null.patch
Patch37:        perf-vendor-events-s390-remove-name-from-l1d_ro_excl_writes-description.patch
Patch38:        perf-report-fix-incorrectly-added-dimensions-as-switch-perf-data-file.patch
Patch39:        perf-hists-fix-variable-name-s-inconsistency-in-hists__for_each-macro.patch
Patch40:        perf-hists-browser-restore-esc-as-zoom-out-of-dso-thread-etc.patch
Patch41:        perf-ui-gtk-add-missing-zalloc-object.patch
Patch42:        perf-make-perf-able-to-build-with-latest-libbfd.patch
Patch43:        perf-stat-don-t-report-a-null-stalled-cycles-per-insn-metric.patch
Patch44:        perf-env-do-not-return-pointers-to-local-variables.patch
Patch45:        perf-bench-futex-wake-restore-thread-count-default-to-online-cpu-count.patch
Patch46:        perf-map-fix-off-by-one-in-strncpy-size-argument.patch
Patch47:        perf-vendor-events-s390-add-new-deflate-counters-for-ibm-z15.patch
Patch48:        perf-record-fix-binding-of-aio-user-space-buffers-to-nodes.patch
Patch49:        perf-report-fix-no-branch-type-statistics-report-issue.patch
Patch50:        perf-cpumap-fix-snprintf-overflow-check.patch
Patch51:        perf-stat-honour-timeout-for-forked-workloads.patch
Patch52:        perf-stat-zero-all-the-ena-and-run-array-slot-stats-for-interval-mode.patch
Patch53:        perf-stat-improve-runtime-stat-for-interval-mode.patch
Patch54:        perf-test-session-topology-fix-data-path.patch
Patch55:        perf-tools-fix-reading-new-topology-attribute-core_cpus.patch
Patch56:        perf-cs-etm-move-definition-of-traceid_list-global-variable-from-header-file.patch
Patch57:        perf-probe-fix-to-check-blacklist-address-correctly.patch
Patch58:        perf-probe-do-not-show-the-skipped-events.patch
Patch59:        perf-probe-check-address-correctness-by-map-instead-of-etext.patch
Patch60:        perf-metrics-fix-parse-errors-in-skylake-metrics.patch
Patch61:        perf-metrics-fix-parse-errors-in-power9-metrics.patch
Patch62:        perf-metrics-fix-parse-errors-in-power8-metrics.patch
Patch63:        perf-stat-fix-duration_time-value-for-higher-intervals.patch
Patch64:        perf-stat-fix-wrong-per-thread-runtime-stat-for-interval-mode.patch
Patch65:        perf-bpf-loader-add-missing-for-key_scan_pos.patch
#Patch66:        perf-build-add-no_sdt-1-to-the-default-set-of-build-tests.patch
#Patch67:        perf-build-add-no_libcrypto-1-to-the-default-set-of-build-tests.patch
Patch68:        perf-stat-ensure-group-is-defined-on-top-of-the-same-cpu-mask.patch
Patch69:        perf-stat-fix-null-pointer-dereference.patch
Patch70:        perf-report-fix-null-pointer-dereference-in-hists__fprintf_nr_sample_events.patch
Patch71:        perf-parse-events-fix-an-incompatible-pointer.patch
Patch72:        perf-scripts-python-export-to-postgresql-py-fix-struct-pack-int-argument.patch
Patch73:        perf-scripts-python-exported-sql-viewer-py-fix-unexpanded-find-result.patch
Patch74:        perf-scripts-python-exported-sql-viewer-py-fix-zero-id-in-call-graph-find-result.patch
Patch75:        perf-scripts-python-exported-sql-viewer-py-fix-zero-id-in-call-tree-find-result.patch
Patch76:        perf-report-tui-fix-segmentation-fault-in-perf_evsel__hists_browse.patch
Patch77:        perf-intel-pt-fix-pebs-sample-for-xmm-registers.patch
Patch78:        perf-tools-fix-record-failure-when-mixed-with-arm-spe-event.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).

%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 PYTHON=python3 EXTRA_CFLAGS="%{optflags}" ASCIIDOC8=1 prefix=/usr libdir=%{_libdir} perfexecdir=lib/%{name}-core all doc %{_perf_unwind} tipdir=share/doc/packages/perf

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

%files
%defattr(-, root, root)
%attr(0644, root, root) %doc COPYING CREDITS README tools/perf/design.txt
%if 0%{?suse_version} > 1315
%attr(0644, root, root) %doc %{_docdir}/perf/tips.txt
%endif
%{_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 %{_docdir}/perf
%dir %{_docdir}/perf/examples
%dir %{_docdir}/perf/examples/bpf
%{_docdir}/perf/examples/bpf/*

%changelog
openSUSE Build Service is sponsored by