# Maintainer: Lubosz Sarnecki <lubosz@gmail.com>

_realname=clutter
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.26.4
pkgrel=2
pkgdesc="A GObject based library for creating fast, visually rich graphical user interfaces (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://blogs.gnome.org/clutter"
license=("LGPL")
makedepends=('automake' 'libtool' 'intltool' 'itstool' 'gtk-doc' 'gnome-doc-utils' 'yelp-tools'
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-pkg-config")
depends=("${MINGW_PACKAGE_PREFIX}-atk"
         "${MINGW_PACKAGE_PREFIX}-cogl"
         "${MINGW_PACKAGE_PREFIX}-json-glib"
         "${MINGW_PACKAGE_PREFIX}-gobject-introspection-runtime"
         "${MINGW_PACKAGE_PREFIX}-gtk3")
options=(!libtool strip staticlibs)
source=(https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz
        #"git+https://git.gnome.org/browse/$_realname#tag=${pkgver}"
        "0001-msys2-add-header-for-BOOL-defintion.patch"
        "0002-install-gtk-doc.patch")
sha256sums=('8b48fac159843f556d0a6be3dbfc6b083fc6d9c58a20a49a6b4919ab4263c4e6'
            '19276acef0e53d1c55797b1ab64358cca989521b739a450efe76b45889a4c22b'
            'bdd6affe84755c2686427930048901fe167963b95c6d0722358804d0e4e1f1ec')

prepare() {
  cd ${_realname}-${pkgver}

  patch -p1 -i ${srcdir}/0001-msys2-add-header-for-BOOL-defintion.patch
  patch -p1 -i ${srcdir}/0002-install-gtk-doc.patch

  autoreconf -fvi
  #NOCONFIGURE=1 ./autogen.sh
}

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

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

  CFLAGS+=" -fcommon"

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --disable-static \
    --enable-shared \
    --enable-silent-rules \
    --enable-introspection

  make
}

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

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