# Maintainer: fauxpark <fauxpark@gmail.com>

_realname=teensy_loader_cli
pkgbase=mingw-w64-${_realname//_/-}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname//_/-}
pkgver=2.1
pkgrel=1
pkgdesc='Command line loader for PJRC Teensy microcontrollers (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('GPL3')
url='https://www.pjrc.com/teensy/loader_cli.html'
depends=("${MINGW_PACKAGE_PREFIX}-libusb-compat")
source=(
    "https://github.com/PaulStoffregen/teensy_loader_cli/archive/${pkgver}/teensy-loader-cli-${pkgver}.tar.gz"
    01-libusb-compat-header.patch
    02-win32-checks.patch
)
sha256sums=(
    '5c36fe45b9a3a71ac38848b076cd692bf7ca8826a69941c249daac3a1d95e388'
    '04e92ebbe9b60551d32d579d6c346c994e0ada8828c1953034ac13552b773521'
    '45bc4a7459216c4924331acb905400424420d3b2f10f4b3883628fd426367973'
)

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

    patch -p1 -i ../01-libusb-compat-header.patch
    patch -p1 -i ../02-win32-checks.patch

    OS=LINUX make teensy_loader_cli
}

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

    install -Dm755 teensy_loader_cli ${pkgdir}${MINGW_PREFIX}/bin/teensy_loader_cli
}
