# Maintainer: @naveen521kk on Github, Naveen M K <naveen521kk@gmail.com>

_perlname=Win32-API
_realname="${_perlname,,}"
pkgbase=mingw-w64-perl-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-perl-${_realname}")
pkgver=0.84
pkgrel=7
pkgdesc="Perl Win32 API Import Facility (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64')
url="https://metacpan.org/release/Win32-API"
msys2_references=(
  'purl: pkg:cpan/BULKDD/Win32-API'
)
msys2_repository_url="https://github.com/bulk88/perl5-win32-api"
license=('spdx:Artistic-1.0-Perl OR GPL-1.0-or-later')
groups=("${MINGW_PACKAGE_PREFIX}-perl-modules")
depends=("${MINGW_PACKAGE_PREFIX}-perl"
         "${MINGW_PACKAGE_PREFIX}-perl-encode-compat"
         "${MINGW_PACKAGE_PREFIX}-perl-math-int64")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-python"
             "${MINGW_PACKAGE_PREFIX}-make")
options=('!emptydirs')
source=("https://cpan.metacpan.org/authors/id/B/BU/BULKDD/Win32/${_perlname}-${pkgver}.tar.gz"
        "patchmakefile.py"
        "0001-clang-as-defines.patch")
sha256sums=('839b30b01b9b1bc260b5e6a0c8956d90438d8c301180069c515613d76d501f50'
            '9b3a852cfb38c05aaea3a6dff4625b038c1d889ed99bb292d8b73e4fb83ff676'
            '9245c2c25d93c9cb8ac236f01a92be228cd9afff603d8168261467ee1a0f8ac7')

prepare() {
  cd "$srcdir/${_perlname}-${pkgver}"
  patch -Np1 -i "${srcdir}/0001-clang-as-defines.patch"
}

build() {
  cd "$srcdir/${_perlname}-${pkgver}"
  PERL_MM_USE_DEFAULT=1 perl Makefile.PL
  export pkgdir=$pkgdir
  python $srcdir/patchmakefile.py
  mingw32-make
}

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