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

_realname=schroedinger
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.0.11
pkgrel=5
pkgdesc="An implemenation of the Dirac video codec in ANSI C code (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="http://www.diracvideo.org/"
license=('GPL2' 'LGPL2.1' 'MPL' 'MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc")
depends=("${MINGW_PACKAGE_PREFIX}-orc")
options=('strip' 'staticlibs')
source=(#"http://www.diracvideo.org/download/schroedinger/${_realname}-${pkgver}.tar.gz"
        https://download.videolan.org/contrib/${_realname}-${pkgver}.tar.gz
        0001-builddir-not-srcdir.all.patch
        0002-link-testsuite-to-orc-tmp.mingw.patch)
sha256sums=('1e572a0735b92aca5746c4528f9bebd35aa0ccf8619b22fa2756137a8cc9f912'
            '215a8a964a1d7aaa8cb23aa5420892f6c970e4ecde1a55e7fcf13054749be73c'
            '4178960ea60e90917fc77d0dd231db83ba55a3621c3c40471a2bd9efa872ea6e')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i ${srcdir}/0001-builddir-not-srcdir.all.patch
  patch -p1 -i ${srcdir}/0002-link-testsuite-to-orc-tmp.mingw.patch
  autoreconf -fi
}

build() {
  [[ -d "build-${MINGW_CHOST}" ]] && rm -rf "build-${MINGW_CHOST}"
  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} \
    --with-opengl=${MINGW_PREFIX}

  make
}

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