# Maintainer: Renato Silva <br.renatosilva@gmail.com>

pkgname=colordiff
pkgver=1.0.21
pkgrel=1
pkgdesc='Diff wrapper with pretty syntax highlighting'
url='https://www.colordiff.org/'
msys2_repository_url="https://github.com/daveewart/colordiff"
license=('GPL2')
arch=('any')
depends=('diffutils' 'perl')
makedepends=(w3m xmlto docbook-xsl)
backup=(etc/colordiffrc)
source=(${pkgname}-${pkgver}.tar.gz::"https://github.com/daveewart/colordiff/archive/v${pkgver}.tar.gz"
        002-build-fix.patch)
sha256sums=('d8df6fa5d06690765fda420b44589e1d26d91664746867edd5171620c8189ade'
            '8d2f99a79126763babdf93ff1691c9e037a843f94afe5e631e1e7fcfae22713d')

prepare() {
  cd "${pkgname}-${pkgver}"
  patch -p1 -i "${srcdir}/002-build-fix.patch"
  
  # xmlto txt conversion apparently does not work even with w3m
  # anyhow only man page is packaged
  sed -i "s/xmlto -vv txt colordiff.xml//" makefile
  sed -i "s/mv colordiff.txt README//" makefile
}

package() {
  cd "${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" MAN_DIR='/usr/share/man/man1' INSTALL_DIR='/usr/bin' install doc
  install -Dm644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/COPYING"
}
