# 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=2.1
pkgrel=4
pkgdesc='Plugins for Geany (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://plugins.geany.org/'
msys2_repository_url="https://github.com/geany/geany-plugins"
msys2_references=(
  'archlinux: geany-plugins'
)
license=('spdx:GPL-2.0-or-later AND GPL-3.0-or-later AND BSD-2-Clause')
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}-lua51"
         "${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-libgit2"
         "${MINGW_PACKAGE_PREFIX}-gettext-runtime"
         "${MINGW_PACKAGE_PREFIX}-gtk-update-icon-cache"
         "${MINGW_PACKAGE_PREFIX}-hicolor-icon-theme")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gettext-tools"
             'intltool')
#             "${MINGW_PACKAGE_PREFIX}-cppcheck")
# optdepends=("${MINGW_PACKAGE_PREFIX}-hspell: hebrew spell checker")
source=("https://plugins.geany.org/geany-plugins/${_realname}-${pkgver}.tar.gz")
sha256sums=('77ec3da07be809357ba9c986e9b72d2eca343008ccc0793673c9dcac2ad8dae1')

apply_patch_with_msg() {
  for _patch in "$@"
  do
    msg2 "Applying ${_patch}"
    patch -Nbp1 -i "${srcdir}/${_patch}"
  done
}

prepare() {
  cd "${_realname}-${pkgver}"
}

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

  export lt_cv_deplibs_check_method='pass_all'

  CFLAGS+=" -Wno-deprecated-declarations" \
  CXXFLAGS+=" -Wno-deprecated-declarations" \
  ../${_realname}-${pkgver}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --with-geany-libdir=${MINGW_PREFIX}/lib \
    --disable-static

  make
}

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