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

pkgbase=libtasn1
pkgname=('libtasn1' 'libtasn1-devel')
pkgver=4.17.0
pkgrel=2
pkgdesc="A library for Abstract Syntax Notation One (ASN.1) and Distinguish Encoding Rules (DER) manipulation"
arch=('i686' 'x86_64')
license=('GPL3' 'LGPL')
url="https://www.gnu.org/software/libtasn1/"
makedepends=('gcc' 'texinfo' 'make' 'patch' 'gtk-doc')
source=(https://ftp.gnu.org/gnu/libtasn1/${pkgname}-${pkgver}.tar.gz{,.sig}
        libtasn1-3.3-msys2.patch)
sha256sums=('ece7551cea7922b8e10d7ebc70bc2248d1fdd73351646a2d6a8d68a9421c45a5'
            'SKIP'
            '68815336dcbbcf98cd62451bda5e2be97c01a22d8d7455cd8d7616d614a5e60e')
validpgpkeys=('9AA9BDB11BB1B99A21285A330664A76954265E8C') # Simon Josefsson <simon@josefsson.org>

prepare() {
  cd ${pkgname}-${pkgver}
  patch -p1 -i $srcdir/libtasn1-3.3-msys2.patch
  autoreconf -fiv
}

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

  make
  make DESTDIR=$srcdir/dest install
}

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

package_libtasn1() {
  depends=('info')
  groups=('libraries')
  install=libtasn1.install

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

package_libtasn1-devel() {
  pkgdesc="Libtasn1 headers and libraries"
  groups=('development')
  depends=("libtasn1=${pkgver}")

  mkdir -p ${pkgdir}/usr/bin
  cp -f ${srcdir}/dest/usr/bin/*.exe ${pkgdir}/usr/bin/
  cp -rf ${srcdir}/dest/usr/include ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/lib ${pkgdir}/usr/
}
