# Maintainer: fauxpark <fauxpark@gmail.com>

_realname=teensy_loader_cli
pkgbase=mingw-w64-${_realname//_/-}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname//_/-}
pkgver=2.3
pkgrel=1
pkgdesc='Command line loader for PJRC Teensy microcontrollers (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://www.pjrc.com/teensy/loader_cli.html'
msys2_repository_url="https://github.com/PaulStoffregen/teensy_loader_cli"
license=('spdx:GPL-3.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-libusb-compat")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc")
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=('d9c5357d7e8b99e9a9ae93f5e921c35a133a4a5d399f57eec10f3a606be5d89f'
            '8feabd9bb57f6fb6836e5656995340495221e5b94a4af7434f1c7ec504a4d016'
            '05ef2838758d7b98c586c1840052f57eedc79e1e360bf5daba7c4e7e173e8ea4')

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

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

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

    OS=LINUX make teensy_loader_cli
}

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

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