# Maintainer: Ricky Wu <rickleaf.wu@gmail.com>

_realname=glade
pkgbase="mingw-w64-${_realname}-gtk2"
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-gtk2"
pkgver=3.8.6
pkgrel=4
pkgdesc="User interface builder for GTK+ and GNOME (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://glade.gnome.org/"
license=("GPL" "LGPL")
options=('strip' '!debug' 'staticlibs')
replaces=("${MINGW_PACKAGE_PREFIX}-glade3")
conflicts=("${MINGW_PACKAGE_PREFIX}-glade3")
depends=("${MINGW_PACKAGE_PREFIX}-gtk2"
         "${MINGW_PACKAGE_PREFIX}-gtk-update-icon-cache"
         "${MINGW_PACKAGE_PREFIX}-libxml2")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-itstool"
             "${MINGW_PACKAGE_PREFIX}-docbook-xsl"
             "${MINGW_PACKAGE_PREFIX}-gnome-common"
             "intltool")
source=(https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}3-${pkgver}.tar.xz
        'disable-yelp.patch')
sha256sums=('aaeeebffaeb3068fb23757a2eede46adeb4c7cecc740feed7654e065491f5449'
            '3e94072e1968a16247e0c35cea853316ef531e6c257a957d3d3e5b76137ed1b8')

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

  # itstool segfaults for some reason..
  patch -p1 -i ${srcdir}/disable-yelp.patch

  autoreconf -fi
}

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 data/icons
  cp -rf ../${_realname}3-${pkgver}/data/icons/* data/icons

  ../${_realname}3-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --disable-static \
    --enable-shared \
    --disable-gtk-doc \
    --disable-python \
    --enable-compile-warnings=minimum

  make VERBOSE=1
}

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