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

pkgname=automake1.11
pkgver=1.11.6
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.xz
        automake-1.11-msys2.patch
        automake1.11-documentation.patch
        automake-1.11-makeinfo-fix.patch
        automake-1.11-perl-escape-curly-bracket.patch)
sha256sums=('1ffbc6cc41f0ea6c864fbe9485b981679dc5e350f6c4bc6c3512f5a4226936b5'
            '41cbfaa428a8e7a90836df4fcfc76f5eeb32d04a4cac446bdb8eb712d51a3f89'
            '0d003623915b7580b170008a3070e100645ff6d4f28887ad1af7058bfa214a39'
            '9161475f1ae3fe4905f6e537d233f04bd55d86e7d79ce4626f38d9516fdac284'
            'dc3566c450efe446799800b88185101f625ef4091d7f39bcb05325eaf4604f5c')

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

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

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

  (cd doc && makeinfo -I ${srcdir}/automake-${pkgver}/doc -o automake1.11.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
}
