# Contributor (MSYS2): David Macek <david.macek.0@gmail.com>
# Maintainer (Arch Linux): Alexander Rødseth <rodseth@gmail.com>
# Contributor (Arch Linux): Angel 'angvp' Velasquez <angvp[at]archlinux.com.ve>  
# Contributor (Arch Linux): djgera
# Contributor (Arch Linux): Patrick Melo <patrick@patrickmelo.eti.br>

_realname=geany-plugins
pkgbase="mingw-w64-${_realname}"
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.37.0
pkgrel=2
pkgdesc='Plugins for Geany (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url='https://plugins.geany.org/'
license=('GPL')
depends=("${MINGW_PACKAGE_PREFIX}-geany>=${pkgver}"
         "${MINGW_PACKAGE_PREFIX}-discount"
         "${MINGW_PACKAGE_PREFIX}-gtkspell3"
         "${MINGW_PACKAGE_PREFIX}-ctpl"
         "${MINGW_PACKAGE_PREFIX}-gpgme"
#         "${MINGW_PACKAGE_PREFIX}-vte"
         "${MINGW_PACKAGE_PREFIX}-lua51"
         "${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-libgit2"
         "${MINGW_PACKAGE_PREFIX}-gtk-update-icon-cache"
         "${MINGW_PACKAGE_PREFIX}-hicolor-icon-theme")
makedepends=('intltool'
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gdb"
             "${MINGW_PACKAGE_PREFIX}-gcc")
#             "${MINGW_PACKAGE_PREFIX}-cppcheck")
# optdepends=("${MINGW_PACKAGE_PREFIX}-hspell: hebrew spell checker")
source=(#"https://plugins.geany.org/${_realname}/${_realname}-${pkgver}.tar.bz2"
        ${_realname}-${pkgver}.tar.gz::https://github.com/geany/geany-plugins/archive/${pkgver}.tar.gz
        001-no-undefined.patch)
sha256sums=('14df1dda3760eedd3a28daba0788f3bee5b83ae31f042c57a78c20f37a77eb28'
            '8f1f6ddcdb180e44cafe2ed0b30a120ec5c89ff7ac8b7833d8da7fdb328a370a')
noextract=(${_realname}-${pkgver}.tar.gz)

prepare() {
  [[ -d ${srcdir}/${_realname}-${pkgver} ]] && rm -rf ${srcdir}/${_realname}-${pkgver}
  tar -xzvf ${srcdir}/${_realname}-${pkgver}.tar.gz -C ${srcdir} || true
  cd ${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/001-no-undefined.patch
  NOCONFIGURE=1 ./autogen.sh
}

build() {
  rm -rf "build-${MINGW_CHOST}"
  mkdir -p "build-${MINGW_CHOST}"
  cd "build-${MINGW_CHOST}"

  ../${_realname}-${pkgver}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --disable-geanypy \
    --disable-static

  make
}

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