

_realname=rtl_433
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=25.12
pkgrel=1
pkgdesc="Program to decode radio transmissions from devices on the ISM bands (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/merbanan/rtl_433"
license=('spdx:GPL-2.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-soapysdr"
         "${MINGW_PACKAGE_PREFIX}-rtl-sdr"
         "${MINGW_PACKAGE_PREFIX}-libusb")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "git")
source=("https://github.com/merbanan/${_realname}/archive/${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('d283ec7a41a02d398e8918b20b65df3bf684cf4478371830662004005dadcdd2')

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  declare -a extra_config
  if check_option "debug" "n"; then
    extra_config+=("-DCMAKE_BUILD_TYPE=Release")
  else
    extra_config+=("-DCMAKE_BUILD_TYPE=Debug")
  fi

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
    "${MINGW_PREFIX}"/bin/cmake.exe \
      -DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
      "${extra_config[@]}" \
      -GNinja \
      -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
      "../${_realname}-${pkgver}"

  "${MINGW_PREFIX}"/bin/cmake.exe --build .
}

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

  DESTDIR="${pkgdir}" "${MINGW_PREFIX}"/bin/cmake.exe --install .
}
