SUMMARY="Finds new Mersenne primes"
DESCRIPTION="GIMPS stands for the \"Great Internet Mersenne Prime Search\". \
It's a collaborative project of volunteers who use freely available software \
to search for Mersenne prime numbers. To perform its testing, the project \
relies primarily on Lucas-Lehmer primality test, an algorithm that is both \
specialized to testing Mersenne primes and particularly efficient on binary \
computer architectures. They also have a trial division phase, used to rapidly \
eliminate Mersenne numbers with small factors which make up a large proportion \
of candidates. Pollard's p - 1 algorithm is also used to search for larger \
factors."
HOMEPAGE="https://www.mersenne.org/"
COPYRIGHT="1996-2018 Mersenne Research, Inc."
LICENSE="GIMPS"
REVISION="2"
SOURCE_URI="https://www.mersenne.org/ftp_root/gimps/p95v${portVersion//.}.source.zip"
CHECKSUM_SHA256="15682e9587af2b86647de9786f97dc8c5d7a4a679a0440f7d1d1936a48c5aa45"
SOURCE_FILENAME="gimps-prime95-v${portVersion//.}.source.zip"
SOURCE_DIR=""

ARCHITECTURES="!all x86"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	gimps$secondaryArchSuffix = $portVersion
	cmd:mprime$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libcurl$secondaryArchSuffix
	lib:libgmp$secondaryArchSuffix
	lib:libhwloc$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcurl$secondaryArchSuffix
	devel:libgmp$secondaryArchSuffix
	devel:libhwloc$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:grep
	cmd:make
	cmd:sed
	"

defineDebugInfoPackage gimps$secondaryArchSuffix \
	$binDir/mprime

BUILD()
{
	#dirty workaround
	mkdir -p arch
	ln -sf `finddir B_SYSTEM_HEADERS_DIRECTORY`/posix/arch/$effectiveTargetArchitecture/signal.h arch/signal.h

	make -C gwnum -f makehaiku $jobArgs
	make -C linux -f makehaikugcc4 $jobArgs
}

INSTALL()
{
	install -d $binDir
	install -t $binDir linux/mprime
}
