# Maintainer: Erich Eckner <arch at eckner dot net>
# Contributor: Piotr Rogoża <rogoza dot piotr at gmail dot com>
# vim:set ts=2 sw=2 et ft=sh tw=100: expandtab

_author=Z/ZE/ZEFRAM
_perlmod=Data-Alias
pkgname=perl-data-alias
pkgver=1.21
pkgrel=4
pkgdesc='Data::Alias - Comprehensive set of aliasing operations'
arch=('i686' 'pentium4' 'x86_64')
url="http://search.cpan.org/dist/Data-Alias/"
license=('GPL' 'PerlArtistic')
groups=()
depends=(
  'perl>=5.30'
  'perl<5.31'
  'perl>=5.8.1')
makedepends=(
  'perl-module-install')
checkdepends=(
  'perl-test-pod'
  'perl-test-pod-coverage'
  'perl-devel-callparser')
replaces=()
backup=()
options=(!emptydirs)
install=
_distdir="${_perlmod}-${pkgver}"
source=("http://search.cpan.org/CPAN/authors/id/$_author/${_distdir}.tar.gz")
noextract=()

prepare() {
  cd "$srcdir/${_distdir}"
  
  sed -i 's|\([a-zA-Z]\+\)->op_sibling|OpSIBLING(\1)|' *.xs
}

build() {
  cd "$srcdir/${_distdir}"
  
  # Setting these env variables overwrites any command-line-options we don't want...
  export PERL_MM_USE_DEFAULT=1 PERL_AUTOINSTALL=--skipdeps \
    PERL_MM_OPT="INSTALLDIRS=vendor DESTDIR='$pkgdir'" \
    PERL_MB_OPT="--installdirs vendor --destdir '$pkgdir'" \
    MODULEBUILDRC=/dev/null

  # If using Makefile.PL
  if [ -r Makefile.PL ]; then
    /usr/bin/perl Makefile.PL
    make
  # If using Build.PL
  elif [ -r Build.PL ]; then
    /usr/bin/perl Build.PL
    perl Build
  fi
}
check(){
  cd "$srcdir/${_distdir}"

  # If using Makefile.PL
  if [ -r Makefile.PL ]; then
    make test
  # If using Build.PL
  elif [ -r Build.PL ]; then
    perl Build test
  fi
}
package(){
  cd "$srcdir/${_distdir}"
  
  # If using Makefile.PL
  if [ -r Makefile.PL ]; then
    make install
  # If using Build.PL
  elif [ -r Build.PL ]; then
    perl Build install
  fi

  # remove perllocal.pod and .packlist
  find "$pkgdir" -name .packlist -o -name perllocal.pod -delete
}
sha512sums=('19714402da3b0930c23407872d8122fb3f45a4d4a974a8afd4c4edf4d452748529619bfed3be592daa511f91e145084d177383937ef17dfc7c3a3b87512b5831')