# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: Ray Donnelly <mingw.android@gmail.com>

pkgname=autoconf
pkgver=2.71
pkgrel=1
pkgdesc="A GNU tool for automatically configuring source code"
arch=('any')
license=('GPL2' 'GPL3' 'custom')
url="https://www.gnu.org/software/autoconf"
groups=('base-devel')
depends=('awk' 'm4' 'diffutils' 'bash' 'perl' 'sed')
# for test-suite
makedepends=('gcc-fortran')
install=autoconf.install
source=(https://ftp.gnu.org/pub/gnu/${pkgname}/${pkgname}-${pkgver}.tar.xz
        0001-autoconf-2.70-MSYS2-specifics-AC_CYGWIN.patch
        0002-autoconf-2.70-MSYS2-Autotest-Unify-EOLs-By-Default.patch
        0003-autoconf-2.70-MSYS2-specifics-config.guess.patch)
sha256sums=('f14c83cfebcc9427f2c3cea7258bd90df972d92eb26752da4ddad81c87a0faa4'
            '3a5337e2269407405ee4c7feb12dbe2ae711610c3144c07cd085272676005db6'
            'c4e4952cc63a2ddaf7bf539f6e59353c4fadbf04cd48c3cfa789f8b175d0bd27'
            'a7671bef559a5f3edbd811a7cf9b557f216f1d3e9502dc046fd3a0ea665da7da')

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

  patch -p1 -i ${srcdir}/0001-autoconf-2.70-MSYS2-specifics-AC_CYGWIN.patch
  patch -p1 -i ${srcdir}/0002-autoconf-2.70-MSYS2-Autotest-Unify-EOLs-By-Default.patch
  patch -p1 -i ${srcdir}/0003-autoconf-2.70-MSYS2-specifics-config.guess.patch

  # NB: Do not run auto(re)conf and friends to avoid any self-dependency of the package.
}

build() {
  mkdir -p build-${pkgname}-${pkgver}
  cd build-${pkgname}-${pkgver}
  ../${pkgname}-${pkgver}/configure --prefix=/usr
  make
}

check() {
  cd build-${pkgname}-${pkgver}
  # CAUTION: The tests run very very long, even on a server.
  make check TESTSUITEFLAGS='-j16'
}

package() {
  make -C build-${pkgname}-${pkgver} DESTDIR=${pkgdir} install

  # license exception
  install -Dm644 ${pkgname}-${pkgver}/COPYING.EXCEPTION \
    $pkgdir/usr/share/licenses/autoconf/COPYING.EXCEPTION

  # conflict with bintuils
  rm -f ${pkgdir}/usr/share/info/standards.info
}
