SUMMARY="Subset of LAPACK routines redesigned for heterogenous (MPI) computing"
DESCRIPTION="The ScaLAPACK (or Scalable LAPACK) library includes a subset \
of LAPACK routines redesigned for distributed memory MIMD parallel computers. \
It is currently written in a Single-Program-Multiple-Data style using \
explicit message passing for interprocessor communication. It assumes \
matrices are laid out in a two-dimensional block cyclic decomposition."
HOMEPAGE="http://www.netlib.org/scalapack/"
COPYRIGHT="1992-2011 The University of Tennessee and The University of \
		Tennessee Research Foundation
	2000-2011 The University of California Berkeley
	2006-2011 The University of Colorado Denver"
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="http://netlib.org/scalapack/scalapack-$portVersion.tgz"
CHECKSUM_SHA256="61d9216cf81d246944720cfce96255878a3f85dec13b9351f1fa0fd6768220a6"

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

PROVIDES="
	scalapack$secondaryArchSuffix = $portVersion
	lib:libscalapack$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libevent_2.1$secondaryArchSuffix
	lib:libevent_pthreads$secondaryArchSuffix
	lib:libexecinfo$secondaryArchSuffix
	lib:libgfortran$secondaryArchSuffix
	lib:libhwloc$secondaryArchSuffix
	lib:liblapack$secondaryArchSuffix
	lib:libmpi$secondaryArchSuffix
	lib:libopenblas$secondaryArchSuffix
	lib:libquadmath$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	scalapack${secondaryArchSuffix}_devel = $portVersion
	devel:libscalapack$secondaryArchSuffix = $portVersion
	"
REQUIRES_devel="
	scalapack$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libevent_2.1$secondaryArchSuffix
	devel:libevent_pthreads$secondaryArchSuffix
	devel:libexecinfo$secondaryArchSuffix
	devel:libgfortran$secondaryArchSuffix
	devel:libhwloc$secondaryArchSuffix
	devel:liblapack$secondaryArchSuffix
	devel:libmpi$secondaryArchSuffix
	devel:libopenblas$secondaryArchSuffix
	devel:libquadmath$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:g++$secondaryArchSuffix
	cmd:gfortran$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage scalapack$secondaryArchSuffix \
	$libDir/libscalapack.so

BUILD()
{
	mkdir -p build && cd "$_"

	# Static lib
	cmake .. \
		-DCMAKE_INSTALL_PREFIX=$prefix \
		-DBUILD_SHARED_LIBS=OFF

	make $jobArgs

	# Shared lib
	cmake .. \
		-DCMAKE_INSTALL_PREFIX=$prefix \
		-DBUILD_SHARED_LIBS=ON

	make $jobArgs
}

INSTALL()
{
	cd build

	make install $jobArgs

	# Install the static lib
	install -m 0644 -t "$libDir" lib/libscalapack.a

	prepareInstalledDevelLib libscalapack

	fixPkgconfig

	packageEntries devel \
		$developDir \
		$libDir/cmake
}

TEST()
{
	cd build
	make test
}
