File perf.spec of Package perf.7825

#
# spec file for package perf
#
# Copyright (c) 2017 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
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
# Use of Python2 authorized by behlert@suse.com for SLE15GA
# https://bugzilla.suse.com/show_bug.cgi?id=1082197#c18
BuildRequires:  python-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
%{perl_requires}
%{?libperl_requires}
Patch1:         perf-provide-definition-for-einval-on-32bit.patch
Patch2:         perf-report-remove-unnecessary-check-in-annotate_browser_write.patch
Patch3:         perf-annotate-browser-display-titles-in-left-frame.patch
Patch4:         perf-ftrace-move-setup_pager-before-opening-trace_pipe.patch
Patch5:         perf-evsel-set-attr-exclude_kernel-when-probing-max-attr-precise_ip.patch
Patch6:         perf-test-sdt-handle-realpath-failure.patch
Patch7:         perf-tests-attr-fix-no-delay-test.patch
Patch8:         perf-annotate-introduce-struct-sym_hist_entry.patch
Patch9:         perf-annotate-rename-sum-to-nr_samples-in-struct-sym_hist.patch
Patch10:        perf-hists-pass-perf_sample-to-_symbol__inc_addr_samples.patch
Patch11:        perf-annotate-store-the-sample-period-in-each-histogram-bucket.patch
Patch12:        perf-annotate-do-not-overwrite-sample-period.patch
Patch13:        perf-annotate-stdio-fix-show-total-period.patch
Patch14:        perf-jvmti-fix-linker-error-when-libelf-config-is-disabled.patch
Patch15:        perf-annotate-stdio-fix-column-header-when-using-show-total-period.patch
Patch16:        perf-annotate-tui-use-sym_hist_entry-in-disasm_line_samples.patch
Patch17:        perf-annotate-fix-storing-per-line-sym_hist_entry.patch
Patch18:        perf-annotate-stdio-set-enough-columns-for-show-total-period.patch
Patch19:        perf-annotate-tui-fix-show-total-period.patch
Patch20:        perf-annotate-tui-clarify-calculation-of-column-header-widths.patch
Patch21:        perf-annotate-tui-fix-column-header-when-toggling-period-percent.patch
Patch22:        perf-annotate-tui-set-appropriate-column-width-for-period-percent.patch
Patch23:        perf-test-make-list-subcommand-match-main-perf-test-numbering-matching.patch
Patch24:        perf-scripts-python-fix-missing-call_path_id-in-export-to-postgresql-script.patch
Patch25:        perf-trace-fix-off-by-one-string-allocation-problem.patch
Patch26:        perf-annotate-stdio-support-show-nr-samples-option.patch
Patch27:        perf-annotate-document-show-total-period-option.patch
Patch28:        perf-tools-really-install-manpages-via-make-install-man.patch
Patch29:        perf-probe-fix-kprobe-blacklist-checking-condition.patch
Patch30:        perf-symbols-fix-memory-corruption-because-of-zero-length-symbols.patch
Patch31:        perf-vendor-events-powerpc-update-power9-events.patch
Patch32:        perf-test-powerpc-fix-object-code-reading-test.patch
Patch33:        perf-pmu-extract-function-to-get-json-alias-map.patch
Patch34:        perf-vendor-events-use-more-flexible-pattern-matching-for-cpu-identification-for-mapfile-csv.patch
Patch35:        perf-evsel-allow-asking-for-max-precise_ip-in-new_cycles.patch
Patch36:        perf-evsel-fix-attr-exclude_kernel-setting-for-default-cycles-p.patch
Patch37:        perf-vendor-events-update-power9-events.patch
Patch38:        perf-script-show-hw-cache-events.patch
Patch39:        perf-vendor-events-add-goldmont-plus-v1-event-file.patch
Patch40:        perf-vendor-events-add-core-event-list-for-skylake-server.patch
Patch41:        perf-vendor-events-add-skylake-server-uncore-event-list.patch
Patch42:        perf-jevents-support-fcmask-and-portmask.patch

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
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p1
%patch24 -p1
%patch25 -p1
%patch26 -p1
%patch27 -p1
%patch28 -p1
%patch29 -p1
%patch30 -p1
%patch31 -p1
%patch32 -p1
%patch33 -p1
%patch34 -p1
%patch35 -p1
%patch36 -p1
%patch37 -p1
%patch38 -p1
%patch39 -p1
%patch40 -p1
%patch41 -p1
%patch42 -p1

%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 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 EXTRA_CFLAGS="%{optflags}" prefix=/usr libdir=%{_libdir} perfexecdir=lib/%{name}-core DESTDIR=%{buildroot} install install-doc %{_perf_unwind} tipdir=share/doc/packages/perf

%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*

%changelog
openSUSE Build Service is sponsored by