# Template file for 'gap'
pkgname=gap
version=4.14.0
revision=1
build_style=gnu-configure
makedepends="gmp-devel zlib-devel readline-devel"
checkdepends="perl"
short_desc="Groups, Algorithms, Programming - computational discrete algebra"
maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
license="GPL-2.0-or-later"
homepage="https://www.gap-system.org/"
changelog="https://raw.githubusercontent.com/gap-system/gap/master/CHANGES.md"
distfiles="https://github.com/gap-system/gap/releases/download/v${version}/gap-${version}.tar.gz"
checksum=845f5272c26feb1b8eb9ef294bf0545f264c1fe5a19b0601bbc65d79d9506487

if [ "$XBPS_CHECK_PKGS" = full ]; then
	do_check() {
		# disable failing test
		rm -f tst/teststandard/testLuxPahlings/example_4.4.18.tst
		# about 5 minutes single core
		./gap tst/teststandard.g
	}
fi

_GAPROOT=/usr/share/gap/

# minimal required packages
_GAPPKGS="autodoc gapdoc primgrp smallgrp transgrp"

# other expected packages
_GAPPKGS+=" atlasrep autpgrp alnuth crisp ctbllib factint fga irredsol laguna
 polenta polycyclic radiroot resclasses sophus tomlib utils"

post_extract() {
	# keep around only the packages that we want to install
	mkdir pkg.install
	for p in ${_GAPPKGS}; do
		mv "pkg/$p" pkg.install
	done
	mv pkg pkg.orig
	mv pkg.install pkg
}

post_install() {
	vmkdir ${_GAPROOT}
	vcopy pkg ${_GAPROOT}
}

pre_check() {
	msg_normal "Check that loading packages works\n"
	for p in ${_GAPPKGS}; do
		cat <<-EOF
		if LoadPackage("$p") <> true then
		    Error("loading package '$p'");
		fi;
		EOF
	done | ./gap --quitonbreak -b -q -r
}

gap-devel_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove "usr/lib/*.so"
	}
}
