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

pkgbase=libtasn1
pkgname=('libtasn1' 'libtasn1-devel')
pkgver=4.20.0
pkgrel=1
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/"
msys2_repository_url="https://gitlab.com/gnutls/libtasn1"
msys2_references=(
  "cpe: cpe:/a:free_software_foundation_inc.:libtasn1"
  "cpe: cpe:/a:gnu:libtasn1"
)
makedepends=('gcc' 'patch' 'gtk-doc' 'autotools')
source=(https://ftp.gnu.org/gnu/libtasn1/${pkgname}-${pkgver}.tar.gz{,.sig})
sha256sums=('92e0e3bd4c02d4aeee76036b2ddd83f0c732ba4cda5cb71d583272b23587a76c'
            'SKIP')
validpgpkeys=('B1D2BD1375BECB784CF4F8C4D73CF638C53C06BE') # Simon Josefsson <simon@josefsson.org>

prepare() {
  cd ${pkgname}-${pkgver}
  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')

  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/
}
