SUMMARY="Arnoldi package library to solve large scale eigenvalue problems"
DESCRIPTION="ARPACK-NG is a collection of Fortran77 subroutines designed to \
solve large scale eigenvalue problems.

Important Features:

* Reverse Communication Interface.
* Single and Double Precision Real Arithmetic Versions for Symmetric, \
Non-symmetric, Standard or Generalized Problems.
* Single and Double Precision Complex Arithmetic Versions for Standard or \
Generalized Problems.
* Routines for Banded Matrices - Standard or Generalized Problems.
* Routines for The Singular Value Decomposition.
* Example driver routines that may be used as templates to implement numerous \
Shift-Invert strategies for all problem types, data types and precision."
HOMEPAGE="https://github.com/opencollab/arpack-ng"
COPYRIGHT="1996-2008 Rice University
	2001-2011 Scilab Enterprises
	2010 Jordi Guti\érrez Hermoso
	2007 S\ébastien Fabbro"
LICENSE="BSD (3-clause)"
REVISION="3"
SOURCE_URI="https://github.com/opencollab/arpack-ng/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="972e3fc3cd0b9d6b5a737c9bf6fd07515c0d6549319d4ffb06970e64fa3cc2d6"
SOURCE_DIR="arpack-ng-$portVersion"

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

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

PROVIDES="
	arpack$secondaryArchSuffix = $portVersion
	lib:libarpack$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libgfortran$secondaryArchSuffix
	lib:liblapack$secondaryArchSuffix
	lib:libopenblas$secondaryArchSuffix
	lib:libquadmath$secondaryArchSuffix
	"

PROVIDES_devel="
	arpack${secondaryArchSuffix}_devel = $portVersion
	devel:libarpack$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	arpack$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libgfortran$secondaryArchSuffix
	devel:liblapack$secondaryArchSuffix
	devel:libopenblas$secondaryArchSuffix
	devel:libquadmath$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:g++$secondaryArchSuffix
	cmd:gfortran$secondaryArchSuffix
	cmd:make
	"

defineDebugInfoPackage arpack$secondaryArchSuffix \
	$libDir/libarpack.so.$libVersion

BUILD()
{
	mkdir -p build
	cd build
	cmake .. \
		-DBUILD_SHARED_LIBS=ON \
		$cmakeDirArgs

	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	# Cleanup
	mkdir -p $includeDir
	mv $prefix/include/* $includeDir
	rmdir $prefix/include

	prepareInstalledDevelLib libarpack

	packageEntries devel \
		$developDir
}

TEST()
{
	cd build
	make test
}
