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

pkgbase=libxslt
pkgname=('libxslt' 'libxslt-devel')
pkgver=1.1.43
pkgrel=2
pkgdesc="XML stylesheet transformation library"
arch=('i686' 'x86_64')
url="https://gitlab.gnome.org/GNOME/libxslt/-/wikis/"
msys2_references=(
  "cpe: cpe:/a:xmlsoft:libxslt"
)
license=('custom')
makedepends=('gcc' 'libxml2-devel' 'libgcrypt-devel' 'autotools')
checkdepends=('docbook-xml')
source=("https://download.gnome.org/sources/libxslt/${pkgver%.*}/${pkgbase}-${pkgver}.tar.xz")
sha256sums=('5a3d6b383ca5afc235b171118e90f5ff6aa27e9fea3303065231a6d403f0183a')

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

  autoreconf -fi
}

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

  export lt_cv_deplibs_check_method='pass_all'
  ./configure \
    --build=${CHOST} \
    --host=${CHOST} \
    --target=${CHOST} \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --enable-shared \
    --enable-static \
    --with-crypto \
    --with-debugger \
    --with-python=no

  make
  make DESTDIR=${srcdir}/dest install
}

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

package_libxslt() {
  depends=('libxml2' 'libgcrypt')
  groups=('libraries')

  mkdir -p ${pkgdir}/usr/share
  cp -rf ${srcdir}/dest/usr/bin ${pkgdir}/usr/
  rm -f ${pkgdir}/usr/bin/*-config
  cp -rf ${srcdir}/dest/usr/share/man ${pkgdir}/usr/share/
  install -Dm644 ${srcdir}/${pkgbase}-${pkgver}/Copyright "${pkgdir}/usr/share/licenses/${pkgbase}/Copyright"
}

package_libxslt-devel() {
  pkgdesc="Libxslt headers and libraries"
  groups=('development')
  options=('staticlibs')
  depends=("libxslt=${pkgver}" 'libxml2-devel' 'libgcrypt-devel')

  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/doc ${pkgdir}/usr/share/
  rm -rf ${pkgdir}/usr/share/doc/libxslt-python-${pkgver}
}
