# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.pro>

_realname=winfile
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=10.1.4.0
pkgrel=1
pkgdesc="Original Windows File Manager (winfile) with enhancements (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://github.com/microsoft/winfile"
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=(!strip staticlibs !buildflags)
source=("${_realname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz"
        "001-winfile-10.1.4.0-fix-mingw.patch")
sha256sums=("7cf45d9279c2338b6d3bc019b0c2ff01b4152dc247e7dbf8ad2f977111e92dcc"
            "a82cba41aa054666337d8b5991f47ee6690fc89d5867c8e9f1fa58a08909e771")

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"

  patch -p1 -i "${srcdir}/001-winfile-10.1.4.0-fix-mingw.patch"
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  cp -r "${srcdir}/${_realname}-${pkgver}" "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"

  make
}

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

  mkdir -p "${pkgdir}${MINGW_PREFIX}"/bin
  cp winfile.exe "${pkgdir}${MINGW_PREFIX}"/bin/

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