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

_realname=libdvdnav
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=6.1.0
pkgrel=2
pkgdesc="The library for xine-dvdnav plugin (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://dvdnav.mplayerhq.hu/"
license=("GPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-doxygen"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "git")
depends=("${MINGW_PACKAGE_PREFIX}-libdvdread")
options=('staticlibs' 'strip')
source=(#"${_realname}-${pkgver}"::"git+https://git.videolan.org/git/${_realname}.git#tag=${pkgver}"
        "https://www.videolan.org/pub/videolan/${_realname}/${pkgver}/${_realname}-${pkgver}.tar.bz2"{,.asc}
        001-no-undefined.patch)
sha256sums=('f697b15ea9f75e9f36bdf6ec3726308169f154e2b1e99865d0bbe823720cee5b'
            'SKIP'
            'c3329ad100f733786c8f263eff499b6dde97b186646db3494a03394c3eb7a0fa')
validpgpkeys=('65F7C6B4206BD057A7EB73787180713BE58D1ADC') # VideoLAN Release Signing Key

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/001-no-undefined.patch
  autoreconf -fvi
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/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} \
    --enable-shared \
    --enable-static
  make
}

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