File tbb.spec of Package tbb

%define releasedate 20130314
%define major 4
%define minor 1
%define update 3
%define dotver %{major}.%{minor}
%define sourcebasename tbb%{major}%{minor}_%{releasedate}oss

%define sourcefilename %{sourcebasename}_src.tgz

Summary: The Threading Building Blocks library abstracts low-level threading details
Name: tbb
Version: %{dotver}
Release: 9.%{releasedate}%{?dist}
License: GPLv2 with exceptions
Group: Development/Tools

# These two are downstream sources.
Source6: tbb.pc
Source7: tbbmalloc.pc
Source8: tbbmalloc_proxy.pc

# Propagate CXXFLAGS variable into flags used when compiling C++.
# This so that RPM_OPT_FLAGS are respected.
Patch1: tbb-3.0-cxxflags.patch

# Replace mfence with xchg (for 32-bit builds only) so that TBB
# compiles and works supported hardware.  mfence was added with SSE2,
# which we still don't assume.
Patch2: tbb-4.0-mfence.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: libstdc++-devel gcc-c++

Threading Building Blocks (TBB) is a C++ runtime library that
abstracts the low-level threading details necessary for optimal
multi-core performance.  It uses common C++ templates and coding style
to eliminate tedious threading implementation work.

TBB requires fewer lines of code to achieve parallelism than other
threading models.  The applications you write are portable across
platforms.  Since the library is also inherently scalable, no code
maintenance is required as more processor cores become available.

%package devel
Summary: The Threading Building Blocks C++ headers and shared development libraries
Group: Development/Libraries
Requires: %{name}%{?_isa} = %{version}-%{release}

%description devel
Header files and shared object symlinks for the Threading Building
Blocks (TBB) C++ libraries.

%package doc
Summary: The Threading Building Blocks documentation
Group: Documentation

%description doc
PDF documentation for the user of the Threading Building Block (TBB)
C++ library.

%setup -q -n %{sourcebasename}
%patch1 -p1
%patch2 -p1

make %{?_smp_mflags} CXXFLAGS="$RPM_OPT_FLAGS" tbb_build_prefix=obj
for file in %{SOURCE6} %{SOURCE7} %{SOURCE8}; do
    sed 's/_FEDORA_VERSION/%{major}.%{minor}.%{update}/' ${file} \
        > $(basename ${file})

mkdir -p $RPM_BUILD_ROOT/%{_libdir}
mkdir -p $RPM_BUILD_ROOT/%{_includedir}

pushd build/obj_release
    for file in libtbb{,malloc{,_proxy}}; do
        install -p -D -m 755 ${file}.so.2 $RPM_BUILD_ROOT/%{_libdir}
        ln -s $ $RPM_BUILD_ROOT/%{_libdir}/$

pushd include
    find tbb -type f ! -name \*.htm\* -exec \
        install -p -D -m 644 {} $RPM_BUILD_ROOT/%{_includedir}/{} \

for file in %{SOURCE6} %{SOURCE7} %{SOURCE8}; do
    install -p -D -m 644 $(basename ${file}) \
	$RPM_BUILD_ROOT/%{_libdir}/pkgconfig/$(basename ${file})

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

rm -rf ${RPM_BUILD_ROOT}

%doc COPYING doc/Release_Notes.txt

%files devel

%files doc
%doc doc/Release_Notes.txt
%doc doc/html