SUMMARY="Recursive Sparse Blocks Matrix computations library"
DESCRIPTION="A library for sparse matrix computations featuring the Recursive \
Sparse Blocks (RSB) matrix format. This format allows cache efficient and multi\
-threaded (that is, shared memory parallel) operations on large sparse \
matrices. It provides the most common operations necessary to iterative \
solvers, like matrix-vector multiplication, triangular solution, rows/columns \
scaling,  diagonal extraction / setting, blocks extraction, norm computation, \
formats conversion.  The RSB format is especially well suited for symmetric \
and transposed multiplication variants."
HOMEPAGE="https://sourceforge.net/projects/librsb/"
COPYRIGHT="2008-2020 Michele Martone"
LICENSE="GNU LGPL v3"
REVISION="2"
SOURCE_URI="https://downloads.sourceforge.net/librsb/librsb-${portVersion/\~/-}.tar.gz"
CHECKSUM_SHA256="f421f5d572461601120933e3c1cfee2ca69e6ecc92cbb11baa4e86bdedd3d9fa"
SOURCE_DIR="librsb-${portVersion/\~/-}"
PATCHES="librsb-$portVersion.patchset"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

libVersion="0.0.0"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	librsb$secondaryArchSuffix = $portVersion
	cmd:rsbench$commandSuffix
	lib:librsb$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libgfortran$secondaryArchSuffix
	lib:libgomp$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	librsb${secondaryArchSuffix}_devel = $portVersion
	cmd:librsb_config$commandSuffix
	devel:librsb$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	librsb$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libgomp$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:gfortran$secondaryArchSuffix
	cmd:grep
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:sed
	"

defineDebugInfoPackage librsb$secondaryArchSuffix \
	$libDir/librsb.so.$libVersion

BUILD()
{
	runConfigure --omit-dirs binDir ./configure \
		--bindir="$commandBinDir" \
		--with-zlib \
		--enable-pkg-config-install

	make $jobArgs
}

INSTALL()
{
	make install

	rm $libDir/librsb.la

	prepareInstalledDevelLib librsb
	fixPkgconfig

	packageEntries devel \
		$developDir \
		$docDir \
		$prefix/bin/librsb-config
}

TEST()
{
	make tests
}
