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

pkgname=automake1.10
pkgver=1.10.3
pkgrel=4
pkgdesc="A GNU tool for automatically creating Makefiles"
arch=('any')
license=('GPL')
url="https://www.gnu.org/software/automake"
groups=('base-devel')
depends=('perl' 'bash')
makedepends=('autoconf')
checkdepends=('dejagnu')
install=automake.install
source=(https://ftp.gnu.org/gnu/automake/automake-${pkgver}.tar.bz2
        automake-1.10-msys2.patch
        automake1.10-documentation.patch
        automake-1.10-makeinfo-fix.patch
        automake-1.10-perl-escape-curly-bracket.patch)
sha256sums=('e98ab43bb839c31696a4202e5b6ff388b391659ef2387cf9365019fad17e1adc'
            'f5e091d83ed5e9451148ce6629f7f8bf92d17890d132aacb7eba1ca6662547fb'
            '9cafa4e6a652331a56780ea5941413eaae96a9b8c8c9abbf9f68bd01ea07aaf1'
            '1378dc7c1ffd88730aabed052b1843cfd3fb55040c10a988171a5a37a1efa612'
            'dc3566c450efe446799800b88185101f625ef4091d7f39bcb05325eaf4604f5c')

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

  patch -p2 -i ${srcdir}/automake1.10-documentation.patch
  patch -p1 -i ${srcdir}/automake-1.10-makeinfo-fix.patch
  patch -p1 -i ${srcdir}/automake-1.10-msys2.patch
  patch -p1 -i ${srcdir}/automake-1.10-perl-escape-curly-bracket.patch
}

build() {
  cd ${srcdir}/automake-${pkgver}
  ./configure --prefix=/usr
  make

  (cd doc && makeinfo -I ${srcdir}/automake-${pkgver}/doc -o automake1.10.info automake.texi)
}

check() {
  cd ${srcdir}/automake-${pkgver}

  # expect 2 failures due to perl-5.18 incompatibility
  make -k check || true
}

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

  # install the 1.11 versioned info files
  for f in `find ${pkgdir}/usr/share/info -name "*.info*"` ; do
    rm -f ${f}
  done
  for f in `find ${srcdir}/automake-${pkgver} -name "*.info*"` ; do
    bf=`basename $f`
    cp $f ${pkgdir}/usr/share/info/
  done

  # remove the unversioned executables
  rm -f ${pkgdir}/usr/bin/automake ${pkgdir}/usr/bin/aclocal

  # remove the unversioned man pages
  rm -f ${pkgdir}/usr/share/man/man1/automake.1
  rm -f ${pkgdir}/usr/share/man/man1/aclocal.1

  # remove the unversioned info files
  rm -f ${pkgdir}/usr/share/info/automake.info*

  rm -rf ${pkgdir}/usr/share/doc
}
