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

pkgname=autoconf2.13
pkgver=2.13
pkgrel=3
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')
# for test-suite
install=autoconf.install
source=(https://ftp.gnu.org/pub/gnu/autoconf/autoconf-${pkgver}.tar.gz
        0001-autoconf-2.13-version-specific-share-directory.patch
        autoconf2.1-texinfo.patch
        autoconf-2.13-msys2.patch)
sha256sums=('f0611136bee505811e9ca11ca7ac188ef5323a8e2ef19cffd3edb3cf08fd791e'
            '85257fad008fff943942e676fcc45df76d38429d5807fa59eb3eb1812dcd3a77'
            'bb987bcd817988830d77c7acf377d14ca89629fb1e5dcea4cf193a7b0d44d62f'
            '4d57e9ab72c5084233fce61bc0d9edb177971de5dd2ec376300dd224b029f87e')

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

  patch -p2 -i ${srcdir}/autoconf2.1-texinfo.patch
  patch -p1 -i ${srcdir}/autoconf-2.13-msys2.patch
  patch -p1 -i ${srcdir}/0001-autoconf-2.13-version-specific-share-directory.patch
}

build() {
  cd ${srcdir}/autoconf-${pkgver}
  ./configure --prefix=/usr --program-suffix=-2.13
  make
}

check() {
  cd ${srcdir}/autoconf-${pkgver}
  # autoconf 2.13: 4 out of 255 unexpected failures
  make check || exit 0
}

package() {
  cd ${srcdir}/autoconf-${pkgver}
  make prefix=${pkgdir}/usr install

  makeinfo --no-split -I ${srcdir}/autoconf-${pkgver} -o autoconf2.13.info autoconf.texi
  # license exception
  install -Dm644 COPYING \
    $pkgdir/usr/share/licenses/autoconf${pkgver}/COPYING

  rm -rf ${pkgdir}/usr/info
  mkdir -p ${pkgdir}/usr/share/info
  cp autoconf2.13.info ${pkgdir}/usr/share/info/autoconf2.13.info
}
