# Template file for 'gap'
pkgname=gap
version=4.12.2
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=672308745eb78a222494ee8dd6786edd5bc331456fcc6456ac064bdb28d587a8

if [ "$XBPS_CHECK_PKGS" = full ]; then
	# not sure about this -- takes about 25 minutes
	make_check_target=teststandard
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"
	}
}
