# Contributor: Grigory Kirillov <txgk@bk.ru>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=libm4ri
pkgver=20240729
pkgrel=2
pkgdesc="Library for fast arithmetic with dense matrices over F2"
url="https://github.com/malb/m4ri"
arch="all"
license="GPL-2.0-or-later"
makedepends="
	autoconf
	automake
	libpng-dev
	libtool
	"
subpackages="$pkgname-static $pkgname-dev"
source="https://github.com/malb/m4ri/archive/release-$pkgver/m4ri-$pkgver.tar.gz
	pkgconfig.patch
	"
builddir="$srcdir/m4ri-release-$pkgver"

prepare() {
	default_prepare
	autoreconf -fi
}

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

	./configure \
		--target=$CTARGET \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-thread-safe \
		--enable-openmp
	make
}

check() {
	make check
}

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

sha512sums="
afd74b0f9a1e3f16b313dca9a73fde85bd08aa431f0ad7064f09600434f27d6cabddc117cf99396dc8d83d245f81b7ed4185e305caad56dad79ecfefc11cf817  m4ri-20240729.tar.gz
bde17dea93c11d2d74a3f0c73f798535cec11424976ad6c581f679f1da7475cba7620792b39e6efbaa76eea72faae7722157797ad513e04473647c1554789fce  pkgconfig.patch
"
