SUMMARY="A library for solution of nonsymmetric systems of linear equations"
DESCRIPTION="SuperLU is a general purpose library for the direct solution \
of large, sparse, nonsymmetric systems of linear equations. The library is \
written in C and is callable from either C or Fortran program. It uses MPI, \
OpenMP and CUDA to support various forms of parallelism. It supports both \
real and complex datatypes, both single and double precision, and 64-bit \
integer indexing. The library routines performs an LU decomposition with \
partial pivoting and triangular system solves through forward and back \
substitution. The LU factorization routines can handle non-square matrices \
but the triangular solves are performed only for square matrices. The matrix \
columns may be preordered (before factorization) either through library or \
user supplied routines. This preordering for sparsity is completely separate \
from the factorization. Working precision iterative refinement subroutines \
are provided for improved backward stability. Routines are also provided \
to equilibrate the system, estimate the condition number, calculate the \
relative backward error, and estimate error bounds for the refined solutions. \
Serial SuperLU package also contains ILU routines, using numerical \
threshold-based dropping, with partial pivoting (ILUTP)."
HOMEPAGE="https://crd.lbl.gov/~xiaoye/SuperLU/"
COPYRIGHT="2003 The Regents of the University of California"
LICENSE="BSD (3-clause)"
# TODO: see "External software" in License.txt
REVISION="3"
SOURCE_URI="http://crd-legacy.lbl.gov/~xiaoye/SuperLU/superlu_5.2.1.tar.gz"
CHECKSUM_SHA256="28fb66d6107ee66248d5cf508c79de03d0621852a0ddeba7301801d3d859f463"
SOURCE_DIR="SuperLU_$portVersion"
PATCHES="superlu-$portVersion.patchset"

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

PROVIDES="
	superlu$secondaryArchSuffix = $portVersion
	lib:libsuperlu$secondaryArchSuffix = 5.2.1 compat >= 5
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	superlu${secondaryArchSuffix}_devel = $portVersion
	devel:libsuperlu$secondaryArchSuffix = 5.2.1 compat >= 5
	"
REQUIRES_devel="
	superlu$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:g++$secondaryArchSuffix
	#cmd:gfortran
	cmd:make
	"

BUILD()
{
	mkdir -p build
	cd build
	cmake .. -DCMAKE_INSTALL_PREFIX=$prefix \
		-DCMAKE_INSTALL_NAME_DIR=$libDir \
		-DCMAKE_INSTALL_LIBDIR=$libDir \
		-DCMAKE_INSTALL_INCLUDEDIR=$includeDir \

#TODO: use shared lib, but it seems to also build libblas.so but not install it
#		-DBUILD_SHARED_LIBS=TRUE
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	prepareInstalledDevelLib libsuperlu

	packageEntries devel \
		$developDir
}
