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

_realname=cogl
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.22.8
pkgrel=5
pkgdesc="An object oriented GL/GLES Abstraction/Utility Layer (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64')
url="https://blogs.gnome.org/clutter"
license=('GPL2')
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs"
         "${MINGW_PACKAGE_PREFIX}-cairo"
         "${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2"
         "${MINGW_PACKAGE_PREFIX}-gettext-runtime"
         "${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-pango")
         #"${MINGW_PACKAGE_PREFIX}-gstreamer"
         #"${MINGW_PACKAGE_PREFIX}-gst-plugins-base")
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-autotools"
  "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
  "${MINGW_PACKAGE_PREFIX}-gtk-doc"
  "${MINGW_PACKAGE_PREFIX}-yelp-tools"
  "${MINGW_PACKAGE_PREFIX}-itstool"
  "intltool")
source=(https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz
        "0002-windows-gl-headers.patch")
sha256sums=('a805b2b019184710ff53d0496f9f0ce6dcca420c141a0f4f6fcc02131581d759'
            'd5884677fa5c3d73b9b34cabbc3af8768158ea233872b596271e894011bca2d4')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i "${srcdir}"/0002-windows-gl-headers.patch
  autoreconf -fiv
}

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

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

  CFLAGS+=" -Wno-error=maybe-uninitialized -Wno-implicit-function-declaration -Wno-incompatible-pointer-types" \
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --disable-static \
    --enable-shared \
    --enable-silent-rules \
    --enable-introspection \
    --disable-cogl-gst

  make
}

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

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