# Maintainer: Dominic Sisneros <dsisnero@gmail.com>

_realname=lasem
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.4.4
pkgrel=2
pkgdesc="Lasem aims to be a C/Gobject based SVG/Mathml renderer (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://wiki.gnome.org/Projects/Lasem"
license=('LGPL')
license=('GPL' 'MPL' 'LGPL')
makedepends=("${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2"
             "${MINGW_PACKAGE_PREFIX}-glib2"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-cairo"
             "${MINGW_PACKAGE_PREFIX}-pango"
             "${MINGW_PACKAGE_PREFIX}-libxml2")
source=("https://download.gnome.org/sources/${_realname}/${pkgver:0:3}/${_realname}-${pkgver}.tar.xz"
        001-fix-doc-install.patch
        002-no-undefined.patch)
sha256sums=('9bf01fcfdc913ebc05989ac1f5902d52e28e7c31f797e2b6d3d413d4b51bba39'
            '9c9321e4f2c841d3b348204519b5e508492521f4c2c512ecfb8a083a06dca1e3'
            '7f98e6d191c53ffe80235258c5114c78e3e7af889c5c07c79ed4134e2be7e3b8')

prepare() {
  cd "${_realname}-${pkgver}"
  patch -p1 -i ${srcdir}/001-fix-doc-install.patch
  patch -p1 -i ${srcdir}/002-no-undefined.patch
  autoreconf -fiv
}

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} \
    --target=${MINGW_CHOST} \
    --sysconfdir=${MINGW_PREFIX}/etc \
    --enable-gtk-doc

  make
}

# check() {
#  #   make check
# }

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

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