# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

pkgname=patchutils
pkgver=0.4.2
pkgrel=2
pkgdesc="Utilities to work with patches"
arch=('i686' 'x86_64')
url="http://cyberelk.net/tim/software/patchutils/"
license=('GPL')
groups=('base-devel')
source=(http://cyberelk.net/tim/data/patchutils/stable/${pkgname}-${pkgver}.tar.xz)
sha256sums=('8875b0965fe33de62b890f6cd793be7fafe41a4e552edbf641f1fed5ebbf45ed')
depends=('pcre2')
makedepends=('pcre2-devel')

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

  autoreconf -vfi
}

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

  ../${pkgname}-${pkgver}/configure -C \
    --build=${CHOST} \
    --host=${CHOST} \
    --target=${CHOST} \
    --prefix=/usr \
    --with-pcre2

  make
}

check() {
  cd ${srcdir}/build-${pkgname}-${pkgver}
  # patchutils 0.4.2: all tests succeed.
  make check
}

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

  # license
  mkdir -p ${pkgdir}/usr/share/licenses/${pkgname}/
  cd ${srcdir}/${pkgname}-${pkgver}/
  cp -v COPYING ${pkgdir}/usr/share/licenses/${pkgname}/
}
