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

pkgname=findutils
pkgver=4.6.0
pkgrel=2
pkgdesc="GNU utilities to locate files"
arch=('i686' 'x86_64')
license=('GPL3')
groups=('base')
depends=('libiconv' 'libintl')
makedepends=('libiconv-devel' 'gettext-devel')
url="https://www.gnu.org/software/findutils"
source=(https://ftp.gnu.org/pub/gnu/findutils/${pkgname}-${pkgver}.tar.gz{,.sig}
        findutils-4.5.12-msys2.patch)
install=findutils.install
sha256sums=('ded4c9f73731cd48fec3b6bdaccce896473b6d8e337e9612e16cf1431bb1169d'
            'SKIP'
            'e3cafb7905dfa8a5e1688a9235c59dc6d357baef8fa38693a47164c25cb1dd73')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p1 -i $srcdir/findutils-4.5.12-msys2.patch

  autoreconf -fi
}

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

  # Don't build or install locate because we use mlocate,
  # which is a secure version of locate.
  # sed -i '/^SUBDIRS/s/locate//' Makefile.in

  ./configure \
    --build=${CHOST} \
    --prefix=/usr \
    --without-libiconv-prefix \
    --without-libintl-prefix \
    DEFAULT_ARG_SIZE="(32u*1024)"

  make
}

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

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