SUMMARY="Fast C/C++ prime number generator library"
DESCRIPTION="primegen is a small, fast library to generate prime numbers \
in order. It generates the 50847534 primes up to 1000000000 in just 8 \
seconds on a Pentium II-350; it prints them in decimal in just 35 seconds. \
primegen can generate primes up to 1000000000000000, although it is not \
optimized for primes past 32 bits. It uses the Sieve of Atkin instead of the \
traditional Sieve of Eratosthenes."
HOMEPAGE="https://cr.yp.to/primegen.html"
COPYRIGHT="1999, D. J. Bernstein"
LICENSE="Public Domain"
REVISION="2"
SOURCE_URI="https://cr.yp.to/primegen/primegen-$portVersion.tar.gz"
CHECKSUM_SHA256="54285baf8eed9e421ff2220a2112d38cfb20c1ebef6014ef3f0004c22c95f40d"
PATCHES="primegen-$portVersion.patchset"

ARCHITECTURES="all"

PROVIDES="
	primegen = $portVersion
	cmd:primegaps = $portVersion
	cmd:primes = $portVersion
	cmd:primespeed = $portVersion
	lib:libprimegen
	"
REQUIRES="
	haiku
	"

PROVIDES_devel="
	primegen_devel = $portVersion
	devel:libprimegen
	"
REQUIRES_devel="
	primegen == $portVersion base
	"

BUILD_REQUIRES="
	haiku_devel
	"
BUILD_PREREQUIRES="
	cmd:gcc
	cmd:make
	cmd:nroff
	"

TEST_REQUIRES="
	cmd:md5sum
	"

BUILD()
{
	make
}

INSTALL()
{
	install -d $binDir $docDir $manDir/man1 $manDir/man3
	install -d $includeDir/primegen $developLibDir $libDir
	install -t $binDir primegaps primes primespeed
	install -t $docDir BLURB README
	install -t $manDir/man1 primegaps.1 primes.1 primespeed.1
	install -t $manDir/man3 primegen.3
	install -t $includeDir/primegen primegen.h uint32.h uint64.h
	install -T primegen.a $developLibDir/libprimegen.a
	install -T primegen.so $libDir/libprimegen.so
	prepareInstalledDevelLib libprimegen
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir \
		$manDir/man3
}

TEST()
{
	[ "$(./primes 1 1000000 | md5sum | cut -d " " -f1)" = c13929ee9d2aea8f83aa076236079e94 ]
}
