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

pkgname=yelp-tools
pkgver=42.1
pkgrel=2
pkgdesc="Tools for creating Yelp documentation"
arch=('any')
license=('GPL')
url="https://gitlab.gnome.org/GNOME/yelp-tools"
msys2_references=(
  "anitya: 8420"
)
depends=("yelp-xsl" "python-lxml" "itstool" "docbook-xsl" "python-mallard-ducktype")
options=('strip' '!libtool' 'staticlibs')
makedepends=("intltool" "meson")
source=(https://download.gnome.org/sources/${pkgname}/${pkgver%.*}/${pkgname}-${pkgver}.tar.xz
        yelp-no-symlinks.patch)
sha256sums=('3e496a4020d4145b99fd508a25fa09336a503a4e8900028421e72c6a4b11f905'
            '276286ade313f9c31a990e77742b20a34c59d50f84a21e5d05c38e5a8ee654be')

prepare() {
  cd ${srcdir}/${pkgname}-${pkgver}
  patch -p1 -i ${srcdir}/yelp-no-symlinks.patch
}

build() {
  cd ${srcdir}/${pkgname}-${pkgver}

  meson build-${CARCH} \
    --buildtype=plain \
    --prefix=/usr \
    -D help=true

  meson compile -C build-${CARCH}
}

check() {
  cd ${srcdir}/${pkgname}-${pkgver}
  meson test -C build-${CARCH}
}

package() {
  cd ${srcdir}/${pkgname}-${pkgver}
  DESTDIR=${pkgdir} meson install -C build-${CARCH}

  for ff in yelp-build yelp-check yelp-new; do
    sed -e "s| xsltproc| /usr/bin/xsltproc|g" -i ${pkgdir}/usr/bin/$ff
  done
}
