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

_realname=qalculate-qt
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=5.8.1
pkgrel=1
pkgdesc="Qt frontend for libqalculate (mingw-w64)"
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
url='https://qalculate.github.io/'
msys2_repository_url='https://github.com/Qalculate/qalculate-qt'
license=('spdx:GPL-2.0-or-later')
depends=(
  "${MINGW_PACKAGE_PREFIX}-libqalculate"
  "${MINGW_PACKAGE_PREFIX}-libwinpthread"
  "${MINGW_PACKAGE_PREFIX}-qt6-base"
  "${MINGW_PACKAGE_PREFIX}-qt6-svg"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-pkgconf"
  "${MINGW_PACKAGE_PREFIX}-qt6-tools"
  "${MINGW_PACKAGE_PREFIX}-winpthreads"
)
source=("https://github.com/Qalculate/qalculate-qt/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.gz"
        0001-qmake-add-pthread.patch)
sha256sums=('3cfc08bdf46bb88db004d73be4f462825d5fb90345e645cd302bfe8f0feccdb4'
            '1e2994244bee6e3b4e58a3e4d7e2cb23629cec3b8fc5ca9ff958860e89626c5e')

prepare() {
  cd "${_realname}-${pkgver}"
  patch -p1 -i "${srcdir}"/0001-qmake-add-pthread.patch
}

build() {
  cd "${_realname}-${pkgver}"
  "${MINGW_PREFIX}/bin/qmake6.exe" PREFIX="${MINGW_PREFIX}"
  make
}

package() {
  cd "${_realname}-${pkgver}"
  install -Dm755 release/qalculate-qt.exe "${pkgdir}${MINGW_PREFIX}"/bin/qalculate-qt.exe
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
