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

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

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

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

  # Do not add --host and --target options, otherwise
  # executables are installed with target triplet prefixes
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}
  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
}
