realname=qtav
pkgname="${MINGW_PACKAGE_PREFIX}-${realname}"
pkgver=r3368.39e6eafe
pkgrel=1
pkgdesc="Multimedia framework based on Qt and FFmpeg (mingw-w64)"
arch=('any')
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-uchardet"
         "${MINGW_PACKAGE_PREFIX}-ffmpeg"
         "${MINGW_PACKAGE_PREFIX}-openal"
         "${MINGW_PACKAGE_PREFIX}-qt5")
makedepends=('git')
source=("${realname}::git://github.com/wang-bin/QtAV.git")
md5sums=('SKIP')

pkgver() {
  cd "${srcdir}/${realname}"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd "${srcdir}/${realname}"
  git submodule update --init
}

build() {
  cd "${srcdir}/${realname}"
  
  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  cmake \
    -G"MSYS Makefiles" \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
    -DBUILD_EXAMPLES=OFF \
    -DBUILD_PLAYERS=ON \
    -DBUILD_TESTS=OFF \
    ../${realname}

  make
}

package() {
  cd "${srcdir}/${realname}"
  
  make DESTDIR="${pkgdir}" install
  
  mkdir -p "${pkgdir}${MINGW_PREFIX}/share/licenses/${realname}"
  cp lgpl-2.1.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/${realname}/LICENSE"
}
