# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Sébastien Luttringer
# Contributor: Lawrence Lee <valheru@facticius.net>
# Contributor: Phillip Marvin <phillip.marvin@gmail.com>
# Contributor: keystone <phillip.marvin@gmail.com>

pkgname=libunwind
pkgver=1.8.1
pkgrel=2.1
pkgdesc="Determine and manipulate the call-chain of a program"
url="https://www.nongnu.org/libunwind/"
arch=(x86_64 aarch64)
license=(GPL)
depends=(
  glibc
  xz
  zlib
)
makedepends=(base-devel) # texlive-binextra
provides=(
  libunwind-{coredump,ptrace,setjmp}.so
  libunwind.so
)
provides_x86_64=(
    libunwind-x86_64.so
)
provides_aarch64=(
    libunwind-aarch64.so
)
source=(
  https://github.com/libunwind/libunwind/releases/download/v$pkgver/libunwind-$pkgver.tar.gz{,.asc}
)
b2sums=('936e70f2428d8f6ada3b4d58b3c9e3a9738eb2f7aee1ad5fb4e44dbb7400186d1bd1ead86a698e53d199d5944b102f8380d08b48104a138021286a79fb006ec3'
        'SKIP')
validpgpkeys=(
  F86EB09F72717426F20D36470A0FF845B7DB3427  # Stephen M. Webb <stephen.webb@bregmasoft.ca>
)

prepare() {
  cd libunwind-$pkgver
}

build() {
  local configure_options=(
    --prefix=/usr
    --sysconfdir=/etc
    --localstatedir=/var
  )

  [[ x"$CARCH" == x"aarch64" ]] && CFLAGS="$CFLAGS -mno-outline-atomics"

  cd libunwind-$pkgver
  ./configure "${configure_options[@]}"
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd libunwind-$pkgver
  make check
}

package() {
  cd libunwind-$pkgver
  make DESTDIR="$pkgdir" install
  rm -r "$pkgdir"/usr/libexec
}

# vim:set sw=2 sts=-1 et:
