# Maintainer: Balló György <ballogyor+arch at gmail dot com>
# Contributor: Dave Reisner <dreisner@archlinux.org>
# Contributor: Alexander Rødseth <rodseth@gmail.com>
# Contributor: Thomas Jost <schnouki@schnouki.net>
# Contributor: JaDa <jada@archlinux.us>
# Contributor: Joaquim Pedro <osmano807@gmail.com>
# Contributor: Jan Rüegg <rggjan@gmail.com>

pkgname=gperftools
pkgver=2.17.2
pkgrel=1
pkgdesc='Fast, multi-threaded malloc and nifty performance analysis tools'
arch=(x86_64 aarch64)
url='https://github.com/gperftools/gperftools'
license=(BSD-3-Clause)
depends=(
  gcc-libs
  glibc
  libunwind
)
makedepends=(
  asciidoctor
  git
)
source=("git+https://github.com/gperftools/gperftools.git#tag=$pkgname-$pkgver")
b2sums=(5ae15f6d12150351bc12d462905840a816bfbec8e81ce42e589cfc7e79aeeebb460d68e12aa2fce7f73e7148d03f92b0f3cf47fdf104f2434b4c7bfa89d78ddc)

prepare() {
  cd $pkgname
  autoreconf -fi
}

build() {
  cd $pkgname
  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --enable-frame-pointers \
    --enable-libunwind
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd $pkgname
  make check
}

package() {
  cd $pkgname
  make DESTDIR="$pkgdir" install
  install -Dm644 -t "$pkgdir/usr/share/licenses/$pkgname/" COPYING
}
