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

_realname=libxml++
pkgbase=mingw-w64-${_realname}2.6
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}2.6"
pkgver=2.42.0
pkgrel=4
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
pkgdesc="C++ wrapper for the libxml2 XML parser library (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-glibmm")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-doxygen"
             "${MINGW_PACKAGE_PREFIX}-graphviz"
             "${MINGW_PACKAGE_PREFIX}-pkg-config")
options=('strip' 'staticlibs')
license=('LGPL')
url="https://libxmlplusplus.sourceforge.io/"
source=("https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz")
sha256sums=('3d032aede98a033eb5e815b4bfa9fa7b4e745268e6fd1ce8b1d0f70bcaf4736d')

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

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  meson \
      --prefix="${MINGW_PREFIX}" \
      --buildtype plain \
      --auto-features=enabled \
      -Dbuild-documentation=true \
      ../${_realname}-${pkgver}

  ninja
}

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

  install -Dm644 ${srcdir}/${_realname}-${pkgver}/COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}2.6/COPYING"
}
