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

pkgname=yelp-tools
pkgver=3.28.0
pkgrel=1
pkgdesc="Tools for creating Yelp documentation"
arch=('any')
license=('GPL')
url="https://www.gnome.org"
depends=("yelp-xsl" "itstool" "libxslt-python" "libxml2-python")
options=('strip' '!libtool' 'staticlibs')
makedepends=("libxml2-python" "libxslt-python" "intltool" "itstool")
source=(https://download.gnome.org/sources/${pkgname}/${pkgver:0:4}/${pkgname}-$pkgver.tar.xz
        yelp-no-symlinks.patch)
sha256sums=('82dbfeea2359dfef8ee92c7580c7f03768d12f9bf67d839f03a5e9b0686dc1ac'
            'f5cdcdc450d2689196e37855f1fa3bcd2b4459563b1bf147c8b01e7e8b735979')

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

build() {
  mkdir -p ${srcdir}/build-${CHOST} && cd ${srcdir}/build-${CHOST}
  export PYTHON=/usr/bin/python2
  ${srcdir}/${pkgname}-${pkgver}/configure \
    --prefix=/usr \
    --build=${CHOST} \
    --host=${CHOST}

  make
}

check() {
  cd ${srcdir}/build-${CHOST}
  make -k check
}

package() {
  cd ${srcdir}/build-${CHOST}
  make DESTDIR="${pkgdir}" install
  for ff in yelp-build yelp-check yelp-new; do
    sed -e "s| xsltproc| /usr/bin/xsltproc|g" -i ${pkgdir}/usr/bin/$ff
  done
}
