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

pkgname=itstool
pkgver=2.0.7
pkgrel=2
pkgdesc="XML to PO and back again"
arch=('i686' 'x86_64')
url="https://itstool.org/"
msys2_repository_url="https://github.com/itstool/itstool"
license=("spdx:GPL-3.0-or-later")
depends=("python" "python-lxml")
makedepends=('autotools' 'gcc')
source=(https://files.itstool.org/itstool/${pkgname}-${pkgver}.tar.bz2
        https://github.com/itstool/itstool/commit/32c7d07664dc37765100285d1202d488cd6a27e8.patch
        57.patch)
sha256sums=('6b9a7cd29a12bb95598f5750e8763cee78836a1a207f85b74d8b3275b27e87ca'
            '4e64a2e884f9d4cbc493732fcbde9f1d5bed534f9a66330bbcc1cbeb54808c1e'
            'ad89a36fd36b985daeec87003c9cc8c98abee3f2de84644aa10241b2d22098cf')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p1 -i ${srcdir}/32c7d07664dc37765100285d1202d488cd6a27e8.patch

  # https://github.com/itstool/itstool/pull/57 - squashed without tests
  patch -p1 -i ${srcdir}/57.patch

  autoreconf -fi
}

build() {
  mkdir -p "${srcdir}/build-${CHOST}"
  cd "${srcdir}/build-${CHOST}"
    PYTHON=/usr/bin/python \
    ../${pkgname}-${pkgver}/configure \
    --prefix=/usr \
    --build=${CHOST} \
    --host=${CHOST} \
    --target=${CHOST}
    make
}

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

package() {
  cd "${srcdir}/build-${CHOST}"
  make DESTDIR="${pkgdir}" install
}
