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

_realname=gtkada
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=26.0.0
pkgrel=1
pkgdesc="Ada bindings for the GTK+ graphical library. (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64')
conflicts=("${MINGW_PACKAGE_PREFIX}-GtkAda-svn")
url="https://github.com/AdaCore/gtkada/"
msys2_references=(
  'aur: gtkada'
)
license=('spdx:GPL-3.0-or-later with GCC-exception-3.1')
depends=("${MINGW_PACKAGE_PREFIX}-cairo"
         "${MINGW_PACKAGE_PREFIX}-gcc-ada"
         "${MINGW_PACKAGE_PREFIX}-cc-libs"
         "${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2"
         "${MINGW_PACKAGE_PREFIX}-gettext-runtime"
         "${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-pango")
makedepends=("${MINGW_PACKAGE_PREFIX}-gprbuild"
             "${MINGW_PACKAGE_PREFIX}-autotools")
source=("https://github.com/AdaCore/gtkada/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('8c0d71655bba58c3a7a0644fe6200126c452af82124eb3ba36e9f84050c2a939')

build() {
  [[ -d "${srcdir}"/build-${MSYSTEM} ]] && rm -rf "${srcdir}"/build-${MSYSTEM}
  cp -r "${srcdir}"/${_realname}-${pkgver} "${srcdir}"/build-${MSYSTEM}
  cd "${srcdir}"/build-${MSYSTEM}

  if [ -f Makefile ]; then
    make distclean
  fi
  CFLAGS+=" -Wno-int-conversion -Wno-implicit-function-declaration"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --enable-shared \
    --disable-static \
    --disable-gtktest \
    --with-GL=no

  make || make -j1
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}
  make -j1 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}/COPYING* \
    "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}
}
