# Maintainer: Alexey Pavlov <Alexpux@gmail.com>

_realname=farstream
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.2.8
pkgrel=3
pkgdesc="Farstream (formerly Farsight) - Audio/Video Communications Framework (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://www.freedesktop.org/wiki/Software/Farstream"
license=('LGPL')
options=('staticlibs' 'strip')
depends=("${MINGW_PACKAGE_PREFIX}-gst-plugins-base"
         "${MINGW_PACKAGE_PREFIX}-libnice")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "gtk-doc")
source=(https://freedesktop.org/software/${_realname}/releases/${_realname}/${_realname}-${pkgver}.tar.gz{,.asc}
        farstream-make-4.3.patch::"https://gitlab.freedesktop.org/farstream/farstream/-/merge_requests/4.patch"
        0001-farstream-0.2.4.patch
        0002-give-cc-to-gir-scanner.all.patch)
sha256sums=('2b3b9c6b4f64ace8c83e03d1da5c5a2884c1cae10b35471072b574201ab38908'
            'SKIP'
            '036c2e3d410dd82dc43f04e457742f7b8048a3df18a22197b8e50c804c7fa011'
            '3d85a6c236ce5af088e98c5afc95e5969cac27050cffcc4b1963ccfb004dbbfe'
            'd6001b52ababf3358a4ddfd710dffc1c75e79e662c618de80efacb5806314544')
validpgpkeys=('DB30B086FAF86CE7296FADC51D388E5A4ED9A2BB') # Olivier Crête <olivier.crete@ocrete.ca>

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i "${srcdir}/farstream-make-4.3.patch"
  patch -p1 -i "${srcdir}/0001-farstream-0.2.4.patch"
  patch -p1 -i "${srcdir}/0002-give-cc-to-gir-scanner.all.patch"

  WANT_AUTOMAKE=latest autoreconf --force --install
}

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

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --enable-static \
    --enable-introspection

  make
}

check() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make check || true
}

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

  rm -f ${pkgdir}${MINGW_PREFIX}/lib/gstreamer*/*.a
  rm -f ${pkgdir}${MINGW_PREFIX}/lib/farstream*/*.a
}
