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

pkgname=findutils
pkgver=4.10.0
pkgrel=3
pkgdesc="GNU utilities to locate files"
arch=('i686' 'x86_64')
license=('GPL3')
depends=('libiconv' 'libintl')
makedepends=('libiconv-devel' 'gettext-devel' 'autotools' 'gcc')
url="https://www.gnu.org/software/findutils"
msys2_repository_url="https://git.savannah.gnu.org/cgit/findutils.git"
msys2_references=(
  "cpe: cpe:/a:gnu:findutils"
)
source=(https://ftp.gnu.org/pub/gnu/findutils/${pkgname}-${pkgver}.tar.xz{,.sig})
sha256sums=('1387e0b67ff247d2abde998f90dfbf70c1491391a59ddfecb8ae698789f0a4f5'
            'SKIP')
validpgpkeys=('A5189DB69C1164D33002936646502EF796917195')

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

  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

  local -a extra_config
  # 32-bit cygwin only has 32-bit time_t
  # https://github.com/msys2/MSYS2-packages/issues/4078
  if [[ "$CARCH" == "i686" ]]; then
    extra_config+=("--disable-year2038")
  fi

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

  make
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  #19 Test Failures... wird schon gehen...
  #make check
}

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