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

_realname=Alien-Build
pkgname=perl-${_realname}
pkgver=2.41
pkgrel=1
pkgdesc="Build external dependencies for use in CPAN"
arch=('any')
license=('PerlArtistic')
url="https://metacpan.org/release/Alien-Build"
groups=('perl-modules')
depends=('perl-Capture-Tiny' 'perl-FFI-CheckLib' 'perl-File-chdir' 'perl-File-Which' 'perl-Path-Tiny')
makedepends=('perl-Test2-Suite' 'perl-devel')
#checkdepends=('perl-Alien-Base-ModuleBuild' 'perl-Alien-cmake3' 'perl-Env-ShellWords'
#              'perl-PkgConfig' 'perl-PkgConfig-LibPkgConf' 'perl-Readonly' 'perl-Sort-Versions')
options=(!emptydirs)
source=("https://cpan.metacpan.org/authors/id/P/PL/PLICEASE/${_realname}-${pkgver}.tar.gz"
        01-msysize.patch)
options=(!emptydirs)
sha256sums=('aaa738117131b016f17f103b167deae2588f03bb72aa3fe15cbb1bad344cf2a4'
            '483769e64ca04e7005fb743e3500561ab8fd49ca9ee239fd5dd96045dc9677a2')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/01-msysize.patch
}

build() {
  cd ${srcdir}/${_realname}-${pkgver}

  # install module in vendor directories.
  perl Makefile.PL -- INSTALLDIRS=vendor
  make
}

check() {
  cd ${_realname}-${pkgver}
  make test
}

package() {
  cd ${srcdir}/${_realname}-${pkgver}

  make install DESTDIR=${pkgdir}
  # Remove .packlist and perllocal.pod files.
  find "$pkgdir" -name '.packlist' -delete
  find "$pkgdir" -name 'perllocal.pod' -delete
}
