# $Id$
# Maintainer:  J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=libaacs
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.11.0
pkgrel=1
pkgdesc="Advanced Access Content System (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('LGPL')
url="https://www.videolan.org/developers/libaacs.html"
depends=("${MINGW_PACKAGE_PREFIX}-libgcrypt")
source=("https://download.videolan.org/pub/videolan/${_realname}/${pkgver}/${_realname}-${pkgver}.tar.bz2")
sha256sums=('6d884381fbb659e2a565eba91e72499778635975e4b3d6fd94ab364a25965387')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  ./bootstrap
}

build() {
  cd "$srcdir"/${_realname}-${pkgver}
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make install DESTDIR="${pkgdir}"
  install -Dm644 "$srcdir"/${_realname}-${pkgver}/COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}"/COPYING
  install -Dm644 "$srcdir"/${_realname}-${pkgver}/KEYDB.cfg "${pkgdir}${MINGW_PREFIX}/share/doc/${_realname}"/KEYDB.cfg
  install -Dm644 "$srcdir"/${_realname}-${pkgver}/README.md "${pkgdir}${MINGW_PREFIX}/share/doc/${_realname}"/README.md
}
