# Maintainer: AndyRTR <andyrtr@archlinux.org>

_realname=opengl-man-pages
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=20191114
_commit=8acb9c72a30d36a6f7e89b9b2de0635c50773cdb
pkgrel=1
pkgdesc="OpenGL Man Pages - OpenGL 4.x (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://github.com/KhronosGroup/OpenGL-Refpages"
license=('custom')
makedepends=("${MINGW_PACKAGE_PREFIX}-docbook5-xml"
    "${MINGW_PACKAGE_PREFIX}-docbook-xsl"
    "${MINGW_PACKAGE_PREFIX}-libxslt"
    "${MINGW_PACKAGE_PREFIX}-docbook-mathml"
    "${MINGW_PACKAGE_PREFIX}-w3c-mathml2"
    "${MINGW_PACKAGE_PREFIX}-python3" 'git')
source=(${_realname}::git+https://github.com/KhronosGroup/OpenGL-Refpages#commit=$_commit
        'LICENSE')
sha256sums=('SKIP'
            'a7b2f6669d7ead91dcaf5a03620cdf9d37c54d83fd1899b4ef84683c7e6d4024')

pkgver() {
  date +%Y%m%d
}

build() {
  for manpages in gl4; do
    cd "${srcdir}/${_realname}/${manpages}"
      for file in *.xml; do
        ${MINGW_PREFIX}/bin/xsltproc --xinclude --noout --nonet ${MINGW_PREFIX}/share/xml/docbook/xsl-stylesheets-*/manpages/docbook.xsl ${file}
      done
  done
}

package() {
  install -d "${pkgdir}${MINGW_PREFIX}/share/man/man3"
  for manpages in gl4; do
    cd "${srcdir}/${_realname}/${manpages}"
    install -m644 *.3G "${pkgdir}${MINGW_PREFIX}/share/man/man3/"
  done
  # license
  install -D -m644 "${srcdir}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
