Name:		gperftools
Version:	2.0
Release:        2%{?_dist_release}
License:	BSD
Group:		Development/Tools
Summary:	Very fast malloc and performance analysis tools
Summary(ja):    超高速な malloc と性能分析ツール
URL:		http://code.google.com/p/gperftools/
Source0:	http://gperftools.googlecode.com/files/%{name}-%{version}.tar.gz
# http://code.google.com/p/gperftools/issues/detail?id=444
Patch0:		gperftools-2.0-glibc216.patch
# ppc64 still broken, bz 238390
ExclusiveArch:	%{ix86} x86_64 ppc %{arm}
%ifnarch ppc ppc64
BuildRequires:	libunwind-devel >= 1.0.1
%endif

%description
Perf Tools is a collection of performance analysis tools, including a 
high-performance multi-threaded malloc() implementation that works
particularly well with threads and STL, a thread-friendly heap-checker,
a heap profiler, and a cpu-profiler.

%package devel
Summary:	Development libraries and headers for gperftools
Summary(ja):	gperftools の開発用ライブラリとヘッダ
Group:		Development/Libraries
Requires:	%{name}-libs = %{version}-%{release}
Provides:	google-perftools-devel = %{version}-%{release}
Obsoletes:	google-perftools-devel < 2.0

%description devel
Libraries and headers for developing applications that use gperftools.

%package libs
Summary:	Libraries provided by gperftools
Summary(ja):	gperftools ライブラリ
Provides:	google-perftools = %{version}-%{release}
Obsoletes:	google-perftools < 2.0

%description libs
Libraries provided by gperftools, including libtcmalloc and libprofiler.

%package -n pprof
Summary:	CPU and Heap Profiler tool
Summary(ja):	CPU および Heap プロファイルツール
Requires:	gv, graphviz
BuildArch:	noarch
Provides:	google-perftools = %{version}-%{release}
Obsoletes:	google-perftools < 2.0

%description -n pprof 
Pprof is a heap and CPU profiler tool, part of the gperftools suite.

%prep
%setup -q
%patch0 -p1 -b .glibc216

# Fix end-of-line encoding
sed -i 's/\r//' README_windows.txt

# No need to have exec permissions on source code
chmod -x src/sampler.h src/sampler.cc

%build
CXXFLAGS=`echo $RPM_OPT_FLAGS -DTCMALLOC_LARGE_PAGES| sed -e 's/-Wp,-D_FORTIFY_SOURCE=2//g'`
%configure --disable-static 

# Bad rpath!
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
# Can't build with smp_mflags
make 

%install
make DESTDIR=%{buildroot} docdir=%{_docdir}/%{name}-%{version}/ install
find %{buildroot} -type f -name "*.la" -exec rm -f {} ';'

# Zero files
rm -rf %{buildroot}%{_docdir}/%{name}-%{version}/NEWS

# Delete useless files
rm -rf %{buildroot}%{_docdir}/%{name}-%{version}/INSTALL

%check
# http://code.google.com/p/google-perftools/issues/detail?id=153
%ifnarch ppc
# Their test suite is junk. Disabling.
# LD_LIBRARY_PATH=./.libs make check
%endif

%post libs -p /sbin/ldconfig
%postun libs -p /sbin/ldconfig

%files -n pprof
%{_bindir}/pprof
%{_mandir}/man1/*

%files devel
%{_docdir}/%{name}-%{version}/
%{_includedir}/google/
%{_includedir}/gperftools/
%{_libdir}/*.so
%{_libdir}/pkgconfig/*.pc

%files libs
%{_libdir}/*.so.*

%changelog
* Wed Oct 24 2012 Daisuke SUZUKI <daisuke@linux.or.jp> 	2.0-2
- rebuild with libunwind-1.0.1

* Wed Oct 24 2012 Daisuke SUZUKI <daisuke@linux.or.jp> 	2.0-1
- update to 2.0, rename to gperftools

* Wed Oct 14 2009 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 1.4-1
- new upstream release

* Tue Jun 19 2007 Daisuke SUZUKI <daisuke@linux.or.jp> 0.91-0vl1
- initial build for Vine Linux

* Sun Apr 29 2007 Tom "spot" Callaway <tcallawa@redhat.com> 0.91-3
- The tests work fine for me locally, but some of them fail inside mock.

* Sun Apr 29 2007 Tom "spot" Callaway <tcallawa@redhat.com> 0.91-2
- no support for ppc yet

* Mon Apr 23 2007 Tom "spot" Callaway <tcallawa@redhat.com> 0.91-1
- alright, lets see if this works now.

* Wed Oct 13 2005 Tom "spot" Callaway <tcallawa@redhat.com> 0.3-2
- change group to Development/Tools

* Mon Oct 10 2005 Tom "spot" Callaway <tcallawa@redhat.com> 0.3-1
- initial package for Fedora Extras
