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

_realname=YAML-Syck
pkgname=perl-YAML-Syck
pkgver=1.36
pkgrel=1
pkgdesc="Fast, lightweight YAML loader and dumper"
arch=('i686' 'x86_64')
url="https://metacpan.org/release/YAML-Syck"
msys2_references=(
  "purl: pkg:cpan/TODDR/YAML-Syck"
)
license=('BSD' 'custom')
depends=('perl')
makedepends=('perl-devel' 'make' 'gcc')
groups=('perl-modules')
options=('!emptydirs')
source=(https://cpan.metacpan.org/authors/id/T/TO/TODDR/YAML-Syck-${pkgver}.tar.gz)
sha256sums=('4dcd9d9b3b0ce3c65a2ff2b9b4c6fff8b649fdf243bfd7e1889543becdb91a52')

prepare() {
  cd YAML-Syck-${pkgver}
}

build() {
  cd YAML-Syck-${pkgver}

  # https://github.com/cpan-authors/YAML-Syck/issues/61
  perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="$CFLAGS -std=gnu17"
  make
}

check() {
  cd YAML-Syck-${pkgver}
  make test
}

package() {
  cd YAML-Syck-${pkgver}
  make install DESTDIR="${pkgdir}"
  install -D -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/COPYING"

  # fix permissons
  find ${pkgdir}/usr -type f \( -name *.dll -o -name *.exe \) | xargs chmod 0755
}
