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

pkgname=diffutils
pkgver=3.8
pkgrel=1
pkgdesc="Utility programs used for creating patch files"
arch=('i686' 'x86_64')
url="https://www.gnu.org/software/diffutils"
license=('GPL3')
groups=('base-devel')
depends=('sh')
install=diffutils.install
source=(https://ftp.gnu.org/gnu/${pkgname}/${pkgname}-${pkgver}.tar.xz{,.sig}
        diffutils-3.7-msys2.patch)
sha256sums=('a6bdd7d1b31266d11c4f4de6c1b748d4607ab0231af5188fc2533d0ae2438fec'
            'SKIP'
            '12f6d0546fff2eea842414630193380697b5a4d04aab6057d0226bd9dbf06441')
validpgpkeys=('155D3FC500C834486D1EEA677FD9FCCB000BEEEE') # Jim Meyering <jim@meyering.net>

prepare() {
  cd ${srcdir}/${pkgname}-${pkgver}
  patch -p1 -i ${srcdir}/diffutils-3.7-msys2.patch

  autoreconf -fiv
}

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

  # make sure tests are running OK
  sed -i "s/mkdir -m 0700/mkdir /" tests/init.sh

  ./configure --build=${CHOST} \
    --prefix=/usr \
    --without-libiconv-prefix \
    --without-libintl-prefix
  make
}

check() {
  cd ${srcdir}/${pkgname}-${pkgver}
  make check || true
}

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