# Maintainer: Ariadne Conill <ariadne@dereferenced.org>
# Contributor: Fabian Affolter <fabian@affolter-engineering.ch>
# Contributor: Duncan Bellamy <dunk@denkimushi.com>
# Contributor: doitwithnotepad <doitwithnotepad@proton.me>
pkgname=jemalloc
pkgver=5.3.0
pkgrel=6
pkgdesc="general purpose malloc(3) implementation that emphasizes fragmentation avoidance and scalable concurrency support"
url="http://jemalloc.net"
arch="all"
license="BSD-2-Clause"
makedepends="autoconf"
subpackages="$pkgname-static $pkgname-dev $pkgname-doc"
source="https://github.com/jemalloc/jemalloc/releases/download/$pkgver/jemalloc-$pkgver.tar.bz2
		musl-exception-specification-errors.patch
		pkgconf.patch
		"

build() {
	local _pgs
	case "$CARCH" in
		x86|x86_64)	_pgs=12 ;;
		ppc64le)	export CPPFLAGS="$CPPFLAGS -maltivec -mabi=altivec" && _pgs=16 ;;
		*)		_pgs=16 ;;
	esac

	echo "$pkgver" > VERSION
	./autogen.sh \
		--enable-xmalloc \
		--prefix=/usr \
		--localstatedir=/var \
		--sysconfdir=/etc \
		--with-lg-page="$_pgs" \
		--with-lg-hugepage=21
	make all dist
}

check() {
	make tests
}

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

sha512sums="
22907bb052096e2caffb6e4e23548aecc5cc9283dce476896a2b1127eee64170e3562fa2e7db9571298814a7a2c7df6e8d1fbe152bd3f3b0c1abec22a2de34b1  jemalloc-5.3.0.tar.bz2
7f52287019a02eef434ecd9f07b4f9bdb5349eced1c09f57db0c6c394d173e8deee20b646431264494a0b985eec3208889547cdd48cd7de6844f2b64c441e34b  musl-exception-specification-errors.patch
04688e1afb8380a61d55292527550b6f26706bed7ec7aeafa3958d52a4d407584aca215bc209e0dd353850756207a0c6bb906643499571be2b34586640314e1f  pkgconf.patch
"
