# Maintainer (MSYS2): Michael Hansen <zrax0111@gmail.com>

_variant=-${KF5_VARIANT:-shared}
source "$(dirname ${BASH_SOURCE[0]})"/../mingw-w64-PKGBUILD-common/kde-frameworks5
_realname=kate
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-kate"
pkgver=20.08.2
pkgrel=1
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
license=('GPL' 'LGPL' 'FDL')
url="https://www.kde.org/applications/utilities/kate/"
pkgdesc="Advanced Text Editor"
groups=(kde-applications kdebase)
makedepends=("${MINGW_PACKAGE_PREFIX}-extra-cmake-modules")
depends=("${MINGW_PACKAGE_PREFIX}-knewstuff-qt5${_namesuff}"
         "${MINGW_PACKAGE_PREFIX}-ktexteditor-qt5${_namesuff}"
         "${MINGW_PACKAGE_PREFIX}-threadweaver-qt5${_namesuff}"
         "${MINGW_PACKAGE_PREFIX}-kitemmodels-qt5${_namesuff}"
         "${MINGW_PACKAGE_PREFIX}-kactivities-qt5${_namesuff}"
         "${MINGW_PACKAGE_PREFIX}-plasma-framework-qt5${_namesuff}"
         "${MINGW_PACKAGE_PREFIX}-hicolor-icon-theme")
optdepends=("${MINGW_PACKAGE_PREFIX}-breeze-icons-qt5${_namesuff}: application icon theme"
            "${MINGW_PACKAGE_PREFIX}-kinit-qt5${_namesuff}: file system browser plugin")
source=(https://download.kde.org/stable/release-service/${pkgver}/src/${_realname}-${pkgver}.tar.xz{,.sig})
sha256sums=('718e8230edfa16f93f54380c4e214a0f25f8a398fe74ad23f12b7dcffae419d0'
            'SKIP')
validpgpkeys=('F23275E4BF10AFC1DF6914A6DBD2CE893E2D1C87')

prepare() {
  mkdir -p build-${CARCH}${_variant}
}

build() {
  local -a extra_config
  cd build-${CARCH}${_variant}
  if [ "${_variant}" = "-static" ]; then
    extra_config+=( -DBUILD_SHARED_LIBS=NO )
  fi

  _kde_f5_build_env
  cmake ../${_realname}-${pkgver} \
    -DCMAKE_BUILD_TYPE=$(_kde_f5_CMAKE_BUILD_TYPE) \
    "${_kde_f5_KDE_INSTALL_DIRS[@]}" \
    -DBUILD_QCH=OFF \
    -DBUILD_TESTING=OFF \
    -DECM_DIR=${MINGW_PREFIX}/share/ECM \
    "${extra_config[@]}" \
    -G'MSYS Makefiles'
  make
}

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