# Maintainer: Jürgen Pfeifer <juergen@familiepfeifer.de>

_realname=gtkada
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=3.8.2
pkgrel=2
pkgdesc="GtkAda is a Gtk3+ binding for Ada using the OOP and other features of this programming language (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
conflicts=("${MINGW_PACKAGE_PREFIX}-GtkAda-svn")
url="https://libre.adacore.com/tools/gtkada/"
options=('!staticlibs' 'strip')
license=('GPL3' 'custom')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc-ada"
             "${MINGW_PACKAGE_PREFIX}-gprbuild-bootstrap")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-ada"
         "${MINGW_PACKAGE_PREFIX}-gtk3")
source=("http://www.pfeifers-software.de/files/GNAT/${_realname}-gpl-${pkgver}-src.tgz"
        "gtkada-mingw.diff"
        "space_issue.patch")
sha256sums=('1c0062e1ec80225d6d39f85e664a84e8be95196d8348acee2dc18e0c6e296ec5'
            '292eed321ceadd5814f42d0a1483de32ee8c13d5a006b9a8c87d092bd4d993ca'
            'c1d134ea9f91b6720965d8be0516196657f5aab06139f3c601696ed3cd8e7975')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}-src
  patch -p0 < contrib/gtkada-3-win32.diff
  patch -p1 < ${srcdir}/gtkada-mingw.diff
  patch -p1 < ${srcdir}/space_issue.patch
}

build() {
  cd ${srcdir}/${_realname}-${pkgver}-src
  if [ -f Makefile ]; then
    make distclean
  fi
  ./configure \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --enable-shared \
    --disable-static \
    --with-GL=no

    make -j1
}

package() {
  cd ${srcdir}/${_realname}-${pkgver}-src
  make DESTDIR="${pkgdir}" install
  rm -rf ${pkgdir}${MINGW_PREFIX}/share/examples
  rm -rf ${pkgdir}${MINGW_PREFIX}/share/doc

  # Copy License Files
  mkdir -p ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}
  cp -pf ${srcdir}/${_realname}-${pkgver}-src/COPYING* \
    ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}
}
