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

pkgbase=libassuan
pkgname=('libassuan' 'libassuan-devel')
pkgver=2.5.5
pkgrel=1
pkgdesc="A IPC library used by some GnuPG related software"
arch=('i686' 'x86_64')
url="https://gnupg.org/related_software/libassuan"
license=('GPL')
makedepends=('libgpg-error-devel')
options=('strip' 'libtool')
source=(https://gnupg.org/ftp/gcrypt/${pkgname}/${pkgname}-${pkgver}.tar.bz2{,.sig}
        'msysize.patch')
sha256sums=('8e8c2fcc982f9ca67dcbb1d95e2dc746b1739a4668bc20b3a3c5be632edb34e4'
            'SKIP'
            '8cb6df3a2c4554e42139219dc56ee98a193948b61f3974d80ea8f38faf7db665')
validpgpkeys=('6DAA6E64A76D2840571B4902528897B826403ADA') # Werner Koch (dist signing 2020)

prepare() {
  cd "${pkgname}-${pkgver}"
  patch -Np1 -i "${srcdir}/msysize.patch"
  autoreconf -fi
}

build() {
  cd "${pkgname}-${pkgver}"
  ./configure \
    --prefix=/usr \
    --build=${CHOST} \
    --enable-shared \
    --enable-static

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

check() {
  cd "${pkgname}-${pkgver}"
  #make check
}

package_libassuan() {
  groups=('libraries')
  depends=('gcc-libs' 'libgpg-error')
  install=libassuan.install

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

  mkdir -p ${pkgdir}/usr/share
  cp -rf ${srcdir}/dest/usr/share/info ${pkgdir}/usr/share/

  install -D -m644 ${srcdir}/${pkgname}-${pkgver}/COPYING ${pkgdir}/usr/share/licenses/${pkgname}/COPYING
}

package_libassuan-devel() {
  pkgdesc="Libassuan headers and libraries"
  groups=('development')
  options=('staticlibs')
  depends=("libassuan=${pkgver}" 'libgpg-error-devel')

  mkdir -p ${pkgdir}/usr/bin
  cp -rf ${srcdir}/dest/usr/bin/libassuan-config ${pkgdir}/usr/bin/
  cp -rf ${srcdir}/dest/usr/include ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/lib ${pkgdir}/usr/

  mkdir -p ${pkgdir}/usr/share
  cp -rf ${srcdir}/dest/usr/share/aclocal ${pkgdir}/usr/share/
}
