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

pkgbase=npth
pkgname=('libnpth' 'libnpth-devel')
pkgver=1.6
pkgrel=1
pkgdesc="New portable threads library"
arch=('i686' 'x86_64')
url="https://gnupg.org/"
license=('LGPL')
depends=('gcc-libs')
options=('!libtool' '!emptydirs')
validpgpkeys=('D8692123C4065DEA5E0F3AB5249B39D24F25E3B6')
source=(https://gnupg.org/ftp/gcrypt/${pkgbase}/${pkgbase}-${pkgver}.tar.bz2{,.sig}
        npth-1.2-msysize.patch)
sha256sums=('1393abd9adcf0762d34798dc34fdcf4d0d22a8410721e76f1e3afcd1daa4e2d1'
            'SKIP'
            '6d08197e74f2c13a36d2f25bd5abb8b3708e52d1d5050f4ff2bdd6ff9c74c00d')

prepare() {
  cd ${srcdir}/${pkgbase}-${pkgver}
  patch -p1 -i ${srcdir}/npth-1.2-msysize.patch

  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 -f ${srcdir}/dest/usr/bin/*-config ${pkgdir}/usr/bin/
  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/
}
