# Contributor: Alex Yam <alex@alexyam.com>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=pari
pkgver=2.17.0
pkgrel=0
pkgdesc="Computer algebra system designed for fast computations in number theory"
url="https://pari.math.u-bordeaux.fr/"
arch="all"
license="GPL-2.0-or-later"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="gmp-dev readline-dev perl"
checkdepends="diffutils" # BusyBox diff: unrecognized option: c
subpackages="$pkgname-dev $pkgname-libs:_lib $pkgname-doc"
source="https://pari.math.u-bordeaux.fr/pub/pari/unix/pari-$pkgver.tar.gz"

build() {
	export CFLAGS="$CFLAGS -O2 -flto=auto"
	export CPPFLAGS="$CPPFLAGS -O2 -flto=auto"
	./Configure \
		--prefix=/usr \
		--mt=pthread \
		--with-readline \
		--with-gmp \
		--graphic=svg
	make all
}

check() {
	make dobench
}

package() {
	make DESTDIR="$pkgdir" install
}

_lib() {
	pkgdesc="$pkgdesc (libraries)"

	# symlink is backwards so it doesn't move otherwise
	amove usr/lib/libpari*
}

doc() {
	default_doc

	amove usr/share/pari/doc \
		usr/share/pari/examples
}

sha512sums="
8e16cc5f338e305d6daec74b7346676f58b247dabe819fc72fbd141c912df3fdd18f32f20842256a4ff56004d6979d73257fd567bc77b03874c6fa4500aac3f4  pari-2.17.0.tar.gz
"
