# Maintainer: Oscar Fuentes <ofv@wanadoo.es>

_realname=twapi
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=5.2
pkgrel=1
pkgdesc="Tcl Windows API (TWAPI) extension (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://twapi.magicsplat.com/"
msys2_repository_url="https://github.com/apnadkarni/twapi"
license=('spdx:BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-tcl")
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-cc")
source=("https://github.com/apnadkarni/twapi/archive/refs/tags/v${pkgver}.tar.gz")
sha256sums=('946e5bb7433aad14def33b56ce66a9d9423f00de775fa19fc9f71e134cfa7198')

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  [[ "${MINGW_CHOST}" = 'x86_64-w64-mingw32' ]] && enable64bit='--enable-64bit'
  [[ "${MINGW_CHOST}" = 'aarch64-w64-mingw32' ]] && enable64bit='--enable-64bit'

  ../${_realname}-${pkgver}/configure --enable-threads \
    --prefix=${MINGW_PREFIX} \
    $enable64bit

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make DESTDIR="${pkgdir}" install
}
