# Maintainer: Jan de Groot <jgc@archlinux.org>
# Maintainer (MSYS2): Ray Donnelly <mingw.android@gmail.com>

_realname=gdl
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=3.40.0
pkgrel=5
pkgdesc="GNOME Docking Library (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
license=('LGPL 2')
url="https://gitlab.gnome.org/GNOME/gdl"
depends=("${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-libxml2")
makedepends=("${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "intltool"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools")
source=(https://download.gnome.org/sources/${_realname}/${pkgver:0:4}/${_realname}-${pkgver}.tar.xz)
sha256sums=('3641d4fd669d1e1818aeff3cf9ffb7887fc5c367850b78c28c775eba4ab6a555')

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

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

  mkdir -p docs/reference/html
  cp -rf ../${_realname}-${pkgver}/docs/reference/html/* docs/reference/html

  CFLAGS+=" -Wno-incompatible-pointer-types"

  INTLTOOL_PERL=/usr/bin/perl \
  ../${_realname}-${pkgver}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --enable-introspection

  make
}

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

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