File oprofile.spec of Package oprofile

#
# spec file for package oprofile
#
# Copyright (c) 2014 SUSE LINUX Products 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:           oprofile
BuildRequires:  binutils-devel
BuildRequires:  fdupes
BuildRequires:  java2-devel-packages
BuildRequires:  libtool
BuildRequires:  libxslt
BuildRequires:  popt-devel
BuildRequires:  qt-devel
BuildRequires:  update-desktop-files
%ifarch ppc ppc64 ppc64le
BuildRequires:  libpfm-devel >= 4.3.0
%endif
Url:            http://oprofile.sourceforge.net/
PreReq:         /usr/sbin/groupadd /usr/sbin/useradd
Version:        0.9.9
Release:        0
Summary:        System-Wide Profiler for Linux Systems
License:        GPL-2.0+ and LGPL-2.1+
Group:          Development/Tools/Other
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Source:         %{name}-%{version}.tar.bz2
Source1:        %{name}.desktop
Source2:        %{name}.rpmlintrc
Source3:        baselibs.conf
Source4:        jvmpi.h
Source5:        README-BEFORE-ADDING-PATCHES
Patch1:         %{name}-compressed-kernel.patch
Patch2:         %{name}-no-libjvm-version.patch
Patch3:         %{name}-configure-error-message-for-missing-libpfm-is-not-informative-enough.patch
Patch4:         %{name}-enable-for-new-ppc64le-architecture.patch
Patch5:         %{name}-fix-unable-to-open-cpu_type-file-for-reading-for-ibm-power7.patch
Patch6:         %{name}-make-cpu-type-power8e-equivalent-to-power8.patch
Patch7:         %{name}-pfm-ppc.patch
Patch8:         %{name}-add-support-for-intel-silvermont-processor.patch
Patch9:         %{name}-update-the-silvermont-event-files.patch

%description
OProfile is a system-wide profiler for Linux systems, capable of
profiling all running code at low overhead. OProfile is released under
the GNU GPL.

It consists of a kernel module and a daemon for collecting sample data,
and several post-profiling tools for turning data into information.

OProfile leverages the CPU hardware performance counters to enable
profiling of a wide variety of interesting statistics, which can also
be used for basic time-spent profiling. All code is profiled: hardware
and software interrupt handlers, kernel modules, the kernel, shared
libraries, and applications (the only exception being the oprofile
interrupt handler itself).

OProfile is currently in alpha status; however it has proven stable
over a large number of differing configurations. As always, there is no
warranty.

This is the package containing the userspace tools.

%package devel
Summary:        System-Wide Profiler for Linux Systems
Group:          Development/Libraries/C and C++
Requires:       binutils-devel
Requires:       libopagent1 = %{version}-%{release}

%description devel
OProfile is a system-wide profiler for Linux systems, capable of
profiling all running code at low overhead. OProfile is released under
the GNU GPL.

This package contains the files needed to develop JIT agents for other
virtual machines.

%package -n libopagent1
Summary:        System-Wide Profiler for Linux Systems
Group:          Development/Libraries/C and C++

%description -n libopagent1
OProfile is a system-wide profiler for Linux systems, capable of
profiling all running code at low overhead. OProfile is released under
the GNU GPL.

This package contains the library needed at runtime when profiling JITed code 
from supported virtual machines.

%prep
%setup -q
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1

mkdir -p java/include
# copy files necessary to build Java agent libraries
# libjvmpi_oprofile.so and libjvmti_oprofile.so
# %S:4 is rpm speak for Source4 (jvmpi.h)
ln -s %_libdir/jvm/java/include/* java/include
test -f java/include/jvmpi.h || ln -s %{S:4} java/include

%build
sh autogen.sh
./configure CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" \
  --prefix=/usr --mandir=%{_mandir} --libdir=%{_libdir} \
  --with-java=$PWD/java --enable-gui=qt4 
# Change DATE/TIME macros to use last change time of oprofile.changes
# See http://lists.opensuse.org/opensuse-factory/2011-05/msg00304.html
modified="$(sed -n '/^----/n;s/ - .*$//;p;q' "%{_sourcedir}/%{name}.changes")"
DATE="\"$(date -d "${modified}" "+%%b %%e %%Y")\""
TIME="\"$(date -d "${modified}" "+%%R")\""
find . -type f -regex ".*\.c\|.*\.cpp\|.*\.h" -exec grep -E -e __DATE__ -e __TIME__ {} +
find . -type f -regex ".*\.c\|.*\.cpp\|.*\.h" -exec sed -i "s/__DATE__/${DATE}/g;s/__TIME__/${TIME}/g" {} +
make %{?jobs:-j%jobs}

%install
make DESTDIR=$RPM_BUILD_ROOT htmldir=%{_docdir}/oprofile install
%suse_update_desktop_file -i %name Development Profiling
rm -f $RPM_BUILD_ROOT%{_libdir}/oprofile/libopagent.*a
# Hardlink duplicate files automatically (from package fdupes):
# It doesn't save much, but it keeps rpmlint from breaking the package build.
%fdupes $RPM_BUILD_ROOT

%pre
/usr/sbin/groupadd -r oprofile 2>/dev/null || :
/usr/sbin/useradd -r -g oprofile -d /var/lib/empty -s /bin/false -c "Special user account to be used by OProfile" oprofile 2>/dev/null || :

%post -n libopagent1 -p /sbin/ldconfig

%postun -n libopagent1 -p /sbin/ldconfig

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
/usr/bin/*
/usr/share/applications/*.desktop
/usr/share/oprofile
%{_mandir}/man1/*
%{_libdir}/oprofile/libjvm[tp]i_oprofile.so
%exclude %{_libdir}/oprofile/libjvm[tp]i_oprofile.*a
%doc doc/oprofile.html doc/internals.html doc/opreport.xsd
%doc COPYING README TODO ChangeLog-*

%files devel
%defattr(-,root,root)
/usr/include/*
%doc doc/op-jit-devel.html 
%dir %{_libdir}/oprofile
%{_libdir}/oprofile/libopagent.so

%files -n libopagent1
%defattr(-,root,root)
%dir %{_libdir}/oprofile
%{_libdir}/oprofile/libopagent.so.1*

%changelog
openSUSE Build Service is sponsored by