# Maintainer: fauxpark <fauxpark@gmail.com>

_realname=mdloader
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=1.0.7
pkgrel=1
pkgdesc='Massdrop keyboard firmware loader (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
license=('spdx:GPL-3.0-or-later')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc")
url='https://github.com/Massdrop/mdloader'
source=("https://github.com/Massdrop/mdloader/archive/${pkgver}/${_realname}-${pkgver}.tar.gz"
        "0001-incbin-mangle.patch")
sha256sums=('a3c47ed285aaa94e9a5c00c84a15798e6d90f1bb13db846cc71cad6eb4a2d7c4'
            '4d6daa3880347c280a5e57b1899831cd807f4fbe1e235c2b7ff37d185f2c2b9b')

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

  patch -Nbp1 -i "${srcdir}/0001-incbin-mangle.patch"
}

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

  make CC=${CC}
}

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

  install -Dm755 mdloader.exe "${pkgdir}${MINGW_PREFIX}/bin/mdloader.exe"
}
