# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgbase=npth
pkgname=('libnpth' 'libnpth-devel')
pkgver=1.8
pkgrel=1
pkgdesc="New portable threads library"
arch=('i686' 'x86_64')
url="https://gnupg.org/"
msys2_repository_url="https://git.gnupg.org/cgi-bin/gitweb.cgi?p=npth.git"
msys2_pgp_keys_url='https://gnupg.org/signature_key.html'
license=('LGPL')
depends=('gcc-libs')
makedepends=('autotools' 'gcc')
options=('!libtool' '!emptydirs')
validpgpkeys=(
  '5B80C5754298F0CB55D8ED6ABCEF7E294B092E28' # Andre Heinecke (Release Signing Key)
  '6DAA6E64A76D2840571B4902528897B826403ADA' # Werner Koch (dist signing 2020)
  'AC8E115BF73E2D8D47FA9908E98E9B2D19C6C8BD' # Niibe Yutaka (GnuPG Release Key)
  '02F38DFF731FF97CB039A1DA549E695E905BA208' # GnuPG.com (Release Signing Key 2021)
)
source=(https://gnupg.org/ftp/gcrypt/${pkgbase}/${pkgbase}-${pkgver}.tar.bz2{,.sig})
sha256sums=('8bd24b4f23a3065d6e5b26e98aba9ce783ea4fd781069c1b35d149694e90ca3e'
            'SKIP')

prepare() {
  cd ${srcdir}/${pkgbase}-${pkgver}

  autoreconf -fiv
}

build() {
  cd ${srcdir}/${pkgbase}-${pkgver}

  ./configure \
    --prefix=/usr \
    --build=${CHOST} \
    --host=${CHOST} \
    --target=${CHOST} \
    --enable-shared \
    --enable-static

  make no_undefined=-no-undefined
  make DESTDIR=${srcdir}/dest install
}

check() {
  cd ${srcdir}/${pkgbase}-${pkgver}
  #make check
}

package_libnpth() {
  groups=('libraries')

  mkdir -p ${pkgdir}/usr/{bin,share}
  cp -f ${srcdir}/dest/usr/bin/*.dll ${pkgdir}/usr/bin/
}

package_libnpth-devel() {
  pkgdesc="Libnpth headers and libraries"
  groups=('development')
  depends=("libnpth=${pkgver}")
  options=('staticlibs')

  mkdir -p ${pkgdir}/usr/{bin,share}
  cp -rf ${srcdir}/dest/usr/include ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/lib ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/share/aclocal ${pkgdir}/usr/share/
}
