# Contributor: Grigory Kirillov <txgk@bk.ru>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=singular
pkgver=4.4.1
pkgrel=2
_pkgbase="${pkgver%%_p*}"
pkgdesc="Computer algebra system for polynomial computations"
url="https://www.singular.uni-kl.de/"
arch="all"
license="GPL-2.0-only OR GPL-3.0-only"
depends="python3"
makedepends="
	cddlib-dev
	gmp-dev
	flint-dev
	perl
	"
subpackages="
	$pkgname-static
	$pkgname-dev
	$pkgname-emacs::noarch
	$pkgname-doc
	"
source="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${_pkgbase//./-}/singular-${pkgver/_p/p}.tar.gz"

build() {
	export CXXFLAGS="${CXXFLAGS/-Os/-O3}" # gotta go fast

	./configure \
		--target=$CTARGET \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--libexecdir=/usr/lib \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-bigintm-module \
		--enable-Order-module \
		--enable-python-module \
		--enable-gfanlib-module \
		--enable-polymake-module
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	# Perhaps it is better to get rid of 36mb of HTML and images.
	rm -rf "$pkgdir"/usr/share/doc
}

emacs() {
	pkgdesc="Emacs plugins for $pkgname"

	amove usr/share/singular/emacs
}

sha512sums="
6c3e8d1b697c75fbbc90626d90e11d3109780ef129344b63b63ecebef635ca7e7d1f93f3c843cab46fcbff75d2806b56305b287007236cc85b7145e93f0a9531  singular-4.4.1.tar.gz
"
