# Maintainer: Marcin Sielski <marcin.sielski@motorolasolutions.com>

_realname=libsrtp
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.7.0
pkgrel=1
pkgdesc="Library for SRTP (Secure Realtime Transport Protocol) (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/cisco/libsrtp'
msys2_references=(
  "cpe: cpe:2.3:a:cisco:libsrtp"
)
license=('spdx:BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-openssl")
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-meson"
  "${MINGW_PACKAGE_PREFIX}-ninja"
  "${MINGW_PACKAGE_PREFIX}-pkgconf"
)
source=("https://github.com/cisco/${_realname}/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('54facb1727a557c2a76b91194dcb2d0a453aaf8e2d0cbbf1e3c2848c323e28ad')

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

  # crypto-library-kdf only disabled because it fails to build with openssl
  MSYS2_ARG_CONV_EXCL="--prefix=" \
  ${MINGW_PREFIX}/bin/meson setup \
    --prefix="${MINGW_PREFIX}" \
    --wrap-mode=nodownload \
    --auto-features=enabled \
    --buildtype=plain \
    -Ddefault_library=both \
    -Dpcap-tests=disabled \
    -Dcrypto-library=openssl \
    -Dcrypto-library-kdf=disabled \
    -Ddoc=disabled \
    ../${_realname}-${pkgver}

  ${MINGW_PREFIX}/bin/meson compile
}

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

  ${MINGW_PREFIX}/bin/meson test
}

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

  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/meson install
}
