# Template file for 'SuiteSparse'
pkgname=SuiteSparse
version=5.12.0
revision=1
# XXX: re-enable TBB=-ltbb -DSPQR_CONFIG=-DHAVE_TBB when updating, if possible
make_build_args="BLAS=-lblas LAPACK=-llapack"
hostmakedepends="cmake chrpath"
makedepends="libgomp-devel lapack-devel mpfr-devel"
short_desc="Suite of sparse matrix software"
maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
license="custom:multiple"
homepage="https://people.engr.tamu.edu/davis/suitesparse.html"
changelog="https://raw.githubusercontent.com/DrTimothyAldenDavis/SuiteSparse/master/ChangeLog"
distfiles="https://github.com/DrTimothyAldenDavis/SuiteSparse/archive/refs/tags/v${version}.tar.gz"
checksum=5fb0064a3398111976f30c5908a8c0b40df44c6dd8f0cc4bfa7b9e45d8c647de

do_build() {
	make config library $make_build_args JOBS=$XBPS_MAKEJOBS
}

do_check() {
	make go $make_build_args LD_LIBRARY_PATH=$wrksrc/lib JOBS=$XBPS_MAKEJOBS
}

do_install() {
	make install $make_build_args INSTALL=$DESTDIR/usr
	vlicense LICENSE.txt

	# remove invalid rpath
	chrpath -d $DESTDIR/usr/lib/lib*.so
}

SuiteSparse-devel_package() {
	depends="${makedepends} ${sourcepkg}>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove "usr/lib/*.a"
		# do not vmove libmetis.so
		vmove "usr/lib/lib[a-ln-z]*.so"
		vmove "usr/lib/libmo*.so"
		vmove usr/share/doc
	}
}
