# Packager = Tuxcore <dev@tuxcore.org> 
pkgname=jemalloc
epoch=1
pkgver=5.3.0
pkgrel=4
pkgdesc='General-purpose scalable concurrent malloc implementation'
arch=('x86_64')
license=('BSD')
url='http://www.canonware.com/jemalloc/'
depends=('glibc')
makedepends=('clang')
options=('!lto')
provides=('libjemalloc.so')
optdepends=('perl: for jeprof')
source=("https://github.com/jemalloc/jemalloc/releases/download/${pkgver}/${pkgname}-${pkgver}.tar.bz2")
sha256sums=('2db82d1e7119df3e71b7640219b6dfe84789bc0537983c3b7ac4f7189aecfeaa')

build() {
  cd $pkgname-$pkgver

  # FS#71745: GCC-built jemalloc causes telegram-desktop to crash a lot. The reason is still not clear.
  export CC=clang
  export CXX=clang++

  ./configure \
    --enable-prof \
    --enable-autogen \
    --prefix=/usr
  make
}

package() {
  cd $pkgname-$pkgver

  make DESTDIR="$pkgdir" install

  install -Dm644 COPYING "$pkgdir/usr/share/licenses/$pkgname/COPYING"
  chmod 644 "$pkgdir/usr/lib/libjemalloc_pic.a"
}
