%{expand: %%define kver %(rpm -q --qf '%%{version}' kernel-source | head -1)}

Summary: System wide profiler for ix86 processors.
Name: oprofile
Version: 0.4
Release: 44
License: GPL
Group: Development/System
Source: http://unc.dl.sourceforge.net/sourceforge/oprofile/oprofile-0.4.tar.gz
Requires: binutils
Patch0: oprofile-0.4cvs-jbj.patch
Patch1: oprofile-0.3cvs-wec.patch
Patch2: oprofile-0.4cvs-wec2.patch
#Patch3: oprofile-0.3cvs-wec3.patch
Patch4: oprofile-0.3cvs-ia64.patch
Patch5: oprofile-0.3cvs-warn_error.patch
#Patch6: oprofile-0.3cvs-new.patch
Patch7: oprofile-0.4cvs-hack.patch
#Patch8: oprofile-0.3cvs-hz.patch
#Patch9: oprofile-0.3cvs-guess.patch
Patch10: oprofile-0.4-guess2.patch
#Patch11: oprofile-0.3cvs-ia64dummy.patch
#Patch12: oprofile-0.3cvs-nr_counter.patch
#Patch13: oprofile-0.3cvs-ia64arch.patch
#Patch14: oprofile-0.4-order.patch
#Patch15: oprofile-0.4-sys_call.patch
Patch16: oprofile-0.4-opcontrol.patch
Patch17: oprofile-0.4-opcontroldoc.patch
Patch18: oprofile-0.4-dump.patch
Patch19: oprofile-0.4-opvisualise.patch
Patch20: oprofile-0.4-ia64.patch
Patch21: oprofile-0.4-ia64comments.patch
Patch22: oprofile-0.4-ia64doc.patch
Patch23: oprofile-0.4-dump2.patch
Patch24: oprofile-0.4-debug.patch
#Patch25: oprofile-0.4-opvisualise2.patch
Patch26: oprofile-0.4-timerkernelonly.patch
Patch27: oprofile-0.4-fixcputypes.patch
Patch28: oprofile-0.4-newint.patch
Patch29: oprofile-0.4-kernelrange.patch
Patch30: oprofile-0.4-cpuspeedest1.patch
Patch31: oprofile-0.4-daemon64.patch
Patch32: oprofile-0.4-opvisualise3.patch
Patch33: oprofile-0.4-hammer.patch
Patch34: oprofile-0.4-p4ht.patch
Patch35: oprofile-0.4-separatedebug.patch
Patch36: oprofile-0.4-cookie.patch
Patch37: oprofile-0.4-timeevent.patch
Patch38: oprofile-0.4-hammer2.patch
Patch39: oprofile-0.4-timerint.patch
Patch40: oprofile-0.4-deprecate.patch
Patch41: oprofile-0.4-man.patch
Patch42: oprofile-0.4-doc.patch
Patch43: oprofile-0.4-64cookie.patch
Patch44: oprofile-0.4-opcontrol2.patch
Patch45: oprofile-0.4-seplib.patch
Patch46: oprofile-0.4-ldorder.patch
Patch47: oprofile-0.4-opcontstale.patch
Patch48: oprofile-0.4-opcontrtc.patch
Patch49: oprofile-0.4-man2.patch
URL: http://oprofile.sf.net
ExclusiveArch: %{ix86} ia64 x86_64 ppciseries ppcpseries ppc64
BuildPreReq: kernel-source
BuildPreReq: qt-devel
BuildPreReq: libxslt
BuildPreReq: docbook-style-xsl
BuildPreReq: docbook-utils

# XXX adjust to taste, turn on when the kernel has matching Provide:
# Requires: kernel(oprofile) = 1.2-3
# XXX but for now let's use the specific kernel version.
Requires: kernel = %{kver}
BuildRoot: %{_tmppath}/%{name}-root

oprofile is a profiling system for x86 systems running Linux 2.2/2.4.
Profiling runs transparently during the background, and profile data
can be collected at any time. oprofile makes use of the hardware performance
counters provided on Intel P6, and AMD Athlon family processors, and can use
the RTC for profiling on othe x86 processor types.

See the HTML documentation for further details.

%setup -q -n %{name}-0.4
#%patch0 -p1 -b .jbj
%patch1 -p1 -b .wec
#%patch2 -p1 -b .wec2
#%patch3 -p1 -b .wec3
#%patch4 -p1 -b .ia64
%ifarch ia64
%patch5 -p1 -b .warn_error
#%patch6 -p1 -b .new
#%patch7 -p1 -b .hack
#%patch8 -p1 -b .hz
#%patch9 -p1 -b .guess
%patch10 -p1 -b .guess2
#%patch11 -p1
#%patch12 -p1 -b .nr_counter
#%patch13 -p1 -b .ia64arch
#%patch14 -p1 -b .order
#%patch15 -p1 -b .sys_call
%patch16 -p1 -b .opcontrol
%patch17 -p1 -b .opcontroldoc
#%patch18 -p1 -b .dump
%ifnarch ia64
%patch19 -p1 -b .opvisualise
%patch20 -p1 -b .ia64
%patch21 -p1 -b .ia64comments
%patch22 -p1 -b .ia64doc
%patch23 -p1 -b .dump2
%patch24 -p1 -b .debug
#%patch25 -p1 -b .opvisualise2
%patch26 -p1 -b .timerkernelonly
%patch27 -p1 -b .fixcputypes
%patch28 -p1 -b .newint
%patch29 -p1 -b .kernelrange
%patch30 -p1 -b .cpuspeedest1
%patch31 -p1 -b .daemon64
%ifnarch ia64
%patch32 -p1 -b .opvisualise3
%patch33 -p1 -b .hammer
%patch34 -p1 -b .p4ht
%patch35 -p1 -b .separate
%patch36 -p1 -b .cookie
#%patch37 -p1 -b .timeevent
%patch38 -p1 -b .hammer2
%patch39 -p1 -b .timerint
%patch40 -p1 -b .deprecate
%patch41 -p1 -b .man
%patch42 -p1 -b .doc
%patch43 -p1 -b .64cookie
%patch44 -p1 -b .opcontrol2
%patch45 -p1 -b .seplib
%ifnarch ia64
%patch46 -p1 -b .ldorder
%patch47 -p1 -b .opcontstale
%patch48 -p1 -b .opcontrtc
%patch49 -p1 -b .man2


%ifarch %{ix86}
QTDIR=/usr/lib/qt-3.1;     export QTDIR

# XXX shorten when autoconf gets sorted out
KVER="%{kver}";         export KVER
./configure --with-linux=`echo /usr/src/linux-$KVER-*` \
        --with-kernel-support \
        --host=%{_host} --target=%{_target_platform} --build=%{_build} \
        --program-prefix= \
        --prefix=%{_prefix} \
        --exec-prefix=%{_exec_prefix} \
        --bindir=%{_bindir} \
        --sbindir=%{_sbindir} \
        --sysconfdir=%{_sysconfdir} \
        --datadir=%{_datadir} \
        --includedir=%{_includedir} \
        --libdir=%{_libdir} \
        --libexecdir=%{_libexecdir} \
        --localstatedir=%{_localstatedir} \
        --sharedstatedir=%{_sharedstatedir} \
        --mandir=%{_mandir} \
        --infodir=%{_infodir} \


rm -rf ${RPM_BUILD_ROOT}

mkdir -p ${RPM_BUILD_ROOT}%{_bindir}
mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man1

make DESTDIR=${RPM_BUILD_ROOT} install

rm -rf ${RPM_BUILD_ROOT}/usr/share/doc/oprofile

rm -rf ${RPM_BUILD_ROOT}

%doc doc/oprofile.html


* Fri Feb 14 2003 Will Cohen <wcohen@redhat.com>
- Requires binutils not perl.

* Thu Feb 13 2003 Will Cohen <wcohen@redhat.com>
- correct x86_64 sys_lookup_dcookie.
- correct applications of patches.

* Mon Feb 10 2003 Will Cohen <wcohen@redhat.com>
- rebuilt.
- handle stale locks
- opcontrol rtc patch
- update manpage info

* Fri Feb 7 2003 Will Cohen <wcohen@redhat.com>
- turn on build for ppc64
- change order op_visualise searches lib directories.
- revise oprofile-0.4-deprecate patch.
- utils/oprofile kernel range check, --save, and do_dump corrections.
- update gui to use "--separate=library".

* Thu Feb 6 2003 Will Cohen <wcohen@redhat.com>
- Fix dumping.

* Fri Jan 31 2003 Will Cohen <wcohen@redhat.com>
- Syscall value for x86_64.
- Update manpage and documentation.
- Revise utils/* to deprecate old.
- Include CPU_P4_HT2 in op_help.c
- Revise how CPU_TIMER_INT handled.
- Apply cookie patch for all archs.
- Correct autogen.sh location.

* Mon Jan 27 2003 Will Cohen <wcohen@redhat.com>
- Add Hammer specific events.

* Fri Jan 24 2003 Will Cohen <wcohen@redhat.com>
- Hack to get correct syscall for ia64.
- Hack to get get timer interupt data.

* Wed Jan 22 2003 Will Cohen <wcohen@redhat.com>
- Add patch for separate debug infomation.

* Wed Jan 22 2003 Tim Powers <timp@redhat.com>
- rebuilt

* Thu Jan 16 2003 Will Cohen <wcohen@redhat.com>
- Add support for P4 HT.

* Wed Jan 15 2003 Will Cohen <wcohen@redhat.com>
- Add support for x86_64.

* Tue Jan 07 2003 Will Cohen <wcohen@redhat.com>
- Revise op_visualise patch to check opendir() results.

* Mon Jan 06 2003 Will Cohen <wcohen@redhat.com>
- Patch to fix op_visualise seg fault on startup.

* Thu Jan 02 2003 Will Cohen <wcohen@redhat.com>
- Correct argument type in daemon/oprofiled.c.
- Correct QTDIR.

* Wed Dec 18 2002 Will Cohen <wcohen@redhat.com>
- Correct reporting of interrupts in oprof_start.

* Wed Dec 18 2002 Will Cohen <wcohen@redhat.com>
- Rebuilt against new kernel

* Fri Dec 13 2002 Will Cohen <wcohen@redhat.com>
- Use opcontrol in oprof_start.

* Thu Dec 12 2002 Will Cohen <wcohen@redhat.com>
- Correct opvisualise problem.

* Tue Dec 10 2002 Will Cohen <wcohen@redhat.com>
- Add opcontrol, op_dump, op_visualise, ia64 support,
  and debugging information.

* Fri Dec 06 2002 Will Cohen <wcohen@redhat.com>
- Change to use OProfile 0.4 release and kernel support.

* Sat Nov 30 2002 Tim Powers <timp@redhat.com> 0.3-0.20021108.1
- rebuild against current version of libbfd

* Tue Aug 06 2002 Will Cohen <wcohen@redhat.com>
- Change to avoid assumption on executable name

* Fri Aug 02 2002 Will Cohen <wcohen@redhat.com>
- Move to 0.4cvs sources.

* Mon Jul 29 2002 Will Cohen <wcohen@redhat.com>
- localize nr_counter code
- add ia64 arch
- guess path to vmlinux.

* Sun Jul 28 2002 Will Cohen <wcohen@redhat.com>
- adjust structure to fit ia64 oprofile module.

* Thu Jul 25 2002 Will Cohen <wcohen@redhat.com>
- recognize ia64 cpu and events.

* Tue Jul 23 2002 Will Cohen <wcohen@redhat.com>
- changes to turn of warning as error on ia64.

* Tue Jul 23 2002 Will Cohen <wcohen@redhat.com>
- changes to allow compilation on ia64.

* Mon Jul 22 2002 Will Cohen <wcohen@redhat.com>
- pick better Red Hat Linux default image file in /boot.

* Tue Jul 14 2002 Will Cohen <wcohen@redhat.com>
- use older OProfile 0.2 kernel<->daemon API.

* Tue Jul 11 2002 Will Cohen <wcohen@redhat.com>
- avoid oprof_start installing the oprofile module

* Tue Jul 02 2002 Will Cohen <wcohen@redhat.com>
- avoid building and installing the oprofile module

* Tue May 28 2002 Jeff Johnson <jbj@redhat.com>
- create package.