# Template file for 'FlintQS'
pkgname=FlintQS
version=1.0
revision=1
build_style=gnu-configure
hostmakedepends="automake"
makedepends="gmp-devel"
checkdepends="bc"
short_desc="Multi-polynomial quadratic sieve for integer factorization"
maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
license="GPL-2.0-or-later"
homepage="https://github.com/sagemath/FlintQS"
distfiles="https://github.com/sagemath/FlintQS/archive/v${version}.tar.gz"
checksum=b983052f267988192c9ec59c9d2754470e5f2db74b45e364cf7ad62f349bc9eb

pre_configure() {
	touch ChangeLog
	autoreconf -fi
}

_check_factor() {
	echo -n "Factor $1 ... "
	factors=$(echo "$1" | src/QuadraticSieve | awk 'x{print}/FACTORS:/{x=1}' | sort -u)
	echo -n $factors | sed -e 's/ / * /'
	prod=$(echo $factors | sed -e 's/ /*/' | bc)
	if [ "$prod" == "$1" ] ; then
		echo " - OK"
		return 0
	else
		echo " - FAIL"
		return 1
	fi
}

do_check() {
	# check that it can factor
	_check_factor 7115311179635024735652627015068546182713648318529
	_check_factor 55100662978045942257527719411373552579109062399339
	_check_factor 179926028483627295233062780598576300117675953698228811539221
}
