# Maintainer: umarcor <unai.martinezcorral@ehu.eus>

_realname=openFPGALoader
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.4.0
pkgrel=1
pkgdesc="openFPGALoader: universal utility for programming FPGA (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://github.com/trabucayre/openFPGALoader"
license=('AGPLv3.0')
groups=("${MINGW_PACKAGE_PREFIX}-eda")
depends=("${MINGW_PACKAGE_PREFIX}-libftdi")
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-gcc"
  "${MINGW_PACKAGE_PREFIX}-cmake"
)

source=("${_realname}::https://codeload.github.com/trabucayre/openFPGALoader/tar.gz/v${pkgver}")
sha256sums=('f2a67761a6fc66b5f1ba61618ea73852e3d4d7ea7166f32ea0a3274a908c6d11')

build() {
  cd "${srcdir}/${_realname}-${pkgver}"
  mkdir build
  cd build
  MSYS2_ARG_CONV_EXCL=- cmake \
    -G "MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
    ../
  cmake --build .
}

check() {
  "${srcdir}/${_realname}-${pkgver}"/build/openFPGALoader.exe --help
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"/build
  make DESTDIR="${pkgdir}" install

  _licenses="${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}"
  mkdir -p "${_licenses}"
  install -m 644 "${srcdir}/${_realname}-${pkgver}"/LICENSE "${_licenses}"
}
