# Template file for 'SuiteSparse'
pkgname=SuiteSparse
version=7.8.3
revision=1
build_style=cmake
hostmakedepends="cmake gcc-fortran"
makedepends="libgomp-devel mpfr-devel
 $(vopt_if openblas 'openblas-devel' 'lapack-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=ce39b28d4038a09c14f21e02c664401be73c0cb96a9198418d6a98a7db73a259

build_options="openblas"

case "$XBPS_TARGET_MACHINE" in
	x86_64*|i686*|aarch64*|armv[67]*|ppc64*)
		# Prefer accelerated routines where available
		build_options_default="openblas"
		;;
	*) ;;
esac

if [ "$CROSS_BUILD" ]; then
	# the JIT causes some trouble when cross-building
	configure_args+=" -DGRAPHBLAS_USE_JIT=off"
fi

post_install() {
	vlicense LICENSE.txt
}

SuiteSparse-devel_package() {
	depends="${makedepends} ${sourcepkg}>=${version}_${revision}"
	short_desc+=" - development files"
	# conflict for /usr/lib/libmongoose.{a,so}
	conflicts="mongoose-devel"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/cmake
		vmove usr/lib/pkgconfig
		vmove "usr/lib/*.a"
		vmove "usr/lib/*.so"
	}
}
