SUMMARY="Library of Iterative Solvers for Linear Systems"
DESCRIPTION="Lis is a parallel software library for solving linear equations \
and eigenvalue problems that arise in the numerical solution of partial \
differential equations using iterative methods."
HOMEPAGE="https://www.ssisc.org/lis/"
COPYRIGHT="2005 The Scalable Software Infrastructure Project"
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="https://github.com/anishida/lis/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="fa1b2878548e00509973681fd18cb45d48fdcb4b92347ba08b654eb79daab9c4"
SOURCE_FILENAME="lis-$portVersion.tar.gz"

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="
	lis$secondaryArchSuffix = $portVersion
	cmd:esolve$commandSuffix = $portVersion
	cmd:esolver$commandSuffix = $portVersion
	cmd:gesolve$commandSuffix = $portVersion
	cmd:gesolver$commandSuffix = $portVersion
	cmd:hpcg_kernel$commandSuffix = $portVersion
	cmd:hpcg_spmvtest$commandSuffix = $portVersion
	cmd:lsolve$commandSuffix = $portVersion
	cmd:spmvtest1$commandSuffix = $portVersion
	cmd:spmvtest2$commandSuffix = $portVersion
	cmd:spmvtest2b$commandSuffix = $portVersion
	cmd:spmvtest3$commandSuffix = $portVersion
	cmd:spmvtest3b$commandSuffix = $portVersion
	cmd:spmvtest4$commandSuffix = $portVersion
	cmd:spmvtest5$commandSuffix = $portVersion
	lib:liblis$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libgomp$secondaryArchSuffix
	"

PROVIDES_devel="
	lis${secondaryArchSuffix}_devel = $portVersion
	devel:liblis$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	lis$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:autoreconf
	cmd:awk
	cmd:find
	cmd:gcc$secondaryArchSuffix
	cmd:gfortran$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage lis$secondaryArchSuffix \
	$commandBinDir/esolve \
	$commandBinDir/esolver \
	$commandBinDir/gesolve \
	$commandBinDir/gesolver \
	$commandBinDir/hpcg_kernel \
	$commandBinDir/hpcg_spmvtest \
	$commandBinDir/lsolve \
	$commandBinDir/spmvtest1 \
	$commandBinDir/spmvtest2 \
	$commandBinDir/spmvtest2b \
	$commandBinDir/spmvtest3 \
	$commandBinDir/spmvtest3b \
	$commandBinDir/spmvtest4 \
	$commandBinDir/spmvtest5 \
	$libDir/liblis.so.$libVersion

BUILD()
{
	autoreconf -vfi

	runConfigure --omit-dirs binDir ./configure \
		--bindir=$commandBinDir \
		--enable-f90 \
		--enable-shared
	make $jobArgs
}

INSTALL()
{
	make install

	rm $libDir/liblis.la
	mkdir -p $developDocDir
	mv $prefix/share/examples $developDocDir
	rm -rf $prefix/share

	prepareInstalledDevelLib liblis
	fixPkgconfig

	packageEntries devel \
		$developDir
}

TEST()
{
	make check
}
