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

_realname=xvidcore
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.3.7
pkgrel=2
pkgdesc="XviD is an open source MPEG-4 video codec (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('GPL')
url="http://www.xvid.com/"
options=('strip' '!libtool' 'staticlibs')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-yasm")
source=(http://downloads.xvid.com/downloads/${_realname}-${pkgver}.tar.bz2
        0001-remove-dll-option-clang.patch)
sha256sums=('aeeaae952d4db395249839a3bd03841d6844843f5a4f84c271ff88f7aa1acff7'
            'e100d96f183bf0e7334ab6ae12ded47a72157fc3976c10db32377ab8cda22715')

prepare() {
  cd "${srcdir}/${_realname}"
  patch -Np1 -i "${srcdir}/0001-remove-dll-option-clang.patch"
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  cp -rf ${srcdir}/${_realname} ${srcdir}/build-${MINGW_CHOST}

  cd ${srcdir}/build-${MINGW_CHOST}/build/generic
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST}

  make
}

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