# jemalloc - General-purpose malloc implementation
# Generated from manifest.tsv by gen-ports.py. Edit the manifest, not this file,
# unless the package needs something the template cannot express - in which case
# drop a `recipe.local` beside it and it will be preserved.
name=jemalloc
version=5.3.0
release=2
desc="General-purpose malloc implementation"
url="https://jemalloc.net/"
license="BSD-2-Clause"
depend="glibc"
makedepend=""
source="https://github.com/jemalloc/jemalloc/releases/download/5.3.0/jemalloc-5.3.0.tar.bz2"
sha256="SKIP"

build() {
	cd "jemalloc-5.3.0"
	# Not every configure script accepts the same options - sqlite rejects
	# --disable-nls outright, for instance - so only pass the ones this one
	# actually advertises. Guessing wrong fails the whole build.
	_opts="--prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib"
	_help=$(./configure --help 2>/dev/null)
	case "$_help" in *--disable-static*)  _opts="$_opts --disable-static" ;; esac
	case "$_help" in *--disable-nls*)     _opts="$_opts --disable-nls" ;; esac
	# No C++ integration. jemalloc is a malloc; the C++ part is an optional
	# operator new/delete wrapper, and building it makes libjemalloc.so.2
	# link libc++ - which on this distribution means the whole LLVM package
	# gets dragged onto anything that needs a malloc, 350 MiB of compiler to
	# satisfy one runtime library.
	case "$_help" in *--disable-cxx*)     _opts="$_opts --disable-cxx" ;; esac
	# shellcheck disable=SC2086
	./configure $_opts
	make -j"$JOBS"
}

package() {
	cd "jemalloc-5.3.0"
	make DESTDIR="$pkgdir" install
}
