# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

_realname=libvterm
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.3.3
pkgrel=1
pkgdesc='Abstract library implementation of a VT220/xterm/ECMA-48 terminal emulator (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://www.leonerd.org.uk/code/libvterm/'
msys2_references=(
  "cpe: cpe:/a:leonerd:libvterm"
)
license=('spdx:MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc" "${MINGW_PACKAGE_PREFIX}-libtool")
source=("https://launchpad.net/libvterm/trunk/v0.3/+download/libvterm-${pkgver}.tar.gz"
        0001-make-remove-bin-sources.patch
        0002-no-undefined.patch)
sha256sums=('09156f43dd2128bd347cbeebe50d9a571d32c64e0cf18d211197946aff7226e0'
            '6ca3142bcd4cf520c1f565038c9fb5b9d928f90a68d446660917812449393712'
            'de203d2c7b4cfc1d1a676887303690388cebdccbd0120ddcf255b612f6614554')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i "${srcdir}/0001-make-remove-bin-sources.patch"
  patch -p1 -i "${srcdir}/0002-no-undefined.patch"
}

build() {
  cp -rf "${_realname}-${pkgver}" "build-${MSYSTEM}"
  cd "build-${MSYSTEM}"

  make PREFIX="${MINGW_PREFIX}"
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  make PREFIX="${MINGW_PREFIX}" DESTDIR="${pkgdir}" install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
