# git tag
%global git_commit 7fd3b7bd68b7cfc0b8932ac351ac14a0c58993d4
%global git_commitdate 20220307.013214
%global git_shortcommit 7fd3b7b
%global git_organization vmware

%global srcversion 0.2.0

# So we want to make sure we can pull the source from upstream
%global _disable_source_fetch 0

# This is slightly obnoxious, but need a way to redefine what CFLAGS
# get passed to change flto=auto to flto

%global _lto_cflags -flto -ffat-lto-objects -flto-partition=one

Name: trace-cruncher
Version: %{srcversion}
Release: 202209071942%{?dist}
License: LGPLv2
Summary: NumPy based tracing interface
Requires: libtracefs
Requires: libtraceevent
Requires: libtracecmd-1
Requires: libkshark
Requires: python3-numpy
Requires: json-c

URL: https://github.com/vmware/trace-cruncher
# If upstream does not provide tarballs, to generate:
# git clone https://github.com/vmware/trace-cruncher.git
# cd trace-cruncher
# git archive --prefix=trace-cruncher-%%{version}/ -o trace-cruncher-%%{version}.tar.gz %%{git_commit}
#Source0: https://github.com/vmware/trace-cruncher.git
Source0: trace-cruncher-%%{version}.tar.gz
Patch0: trace-cruncher-cythonize.patch
BuildRequires: gcc
BuildRequires: python3-devel
BuildRequires: libtracefs-devel
BuildRequires: libtraceevent-devel
BuildRequires: libtracecmd-1-devel
BuildRequires: libkshark-devel
BuildRequires: python3-Cython
BuildRequires: python3-numpy
BuildRequires: python3-pkgconfig
BuildRequires: strace
BuildRequires: python3-pip
BuildRequires: json-c-devel
BuildRequires: python3-setuptools
BuildRequires: chrpath
BuildRequires: binutils-devel

%description
Trace-Cruncher provides an interface between the existing instrumentation
for collection and visualization of Linux kernel tracing data and the
ecosystem of instruments for data analysis available in Python.
The interface is based on NumPy.

%prep
%autosetup -p1 -n %{name}-%{version}

%build
%make_build
%py3_build

%install
%py3_install
chrpath --delete $RPM_BUILD_ROOT%{python3_sitearch}/tracecruncher/*.so

%files
#<percent>doc COPYING COPYING.LIB README
#<percent>{_bindir}/trace-cmd
#<percent>{_mandir}/man1/%{name}*
#<percent>{_mandir}/man5/%{name}*
#<percent>{_sysconfdir}/bash_completion.d/trace-cmd.bash
%{python3_sitearch}/tracecruncher*

%changelog
* Fri Mar 25 2022 John 'Warthog9' Hawley (VMware) <warthog9@eaglescrag.net> 0.2.0-1
- Updating to 0.2.0
- Adding the _lto_cflags
- chrpathing the .so's - this is effectively a requirement of Fedora

* Mon Jul 12 2021 John 'Warthog9' Hawley (VMware) <warthog9@eaglescrag.net> 0.01-1
- Initial build at 0.01-1  @ 3fc44e4d189f18ece905c2668aadc27765a73574