_kde_f5_init_package() {
  _VARIANT=$1; shift
  _PKG=$1; shift
  if [ "${_VARIANT}" = "-static" ]; then
    _namesuff="-static"
  else
    _namesuff=
  fi
  _basename=${_PKG}
  _realname=${_PKG}-qt5${_namesuff}
  pkgbase=mingw-w64-${_realname}
  pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
  url=https://projects.kde.org/projects/frameworks/${_PKG}
}

_kde_f5_add_depends() {
  _VARIANT=$1; shift
  while (( "$#" )); do
    if [ "${_VARIANT}" = "-static" ]; then
      makedepends+=("$1")
    else
      depends+=("$1")
    fi
    shift
  done
}

_kde_f5_CMAKE_BUILD_TYPE() {
  if check_option "debug" "y"; then
    echo "Debug"
  else
    echo "Release"
  fi
}

_kde_f5_build_env() {
  export MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=;-DECM_MKSPECS_INSTALL_DIR="
  if [ "${_variant}" = "-static" ]; then
    export QT5_PREFIX=${MINGW_PREFIX}/qt5-static
    export PATH=${QT5_PREFIX}/bin:"$PATH"
  else
    export QT5_PREFIX=${MINGW_PREFIX}
  fi

  export _kde_f5_KDE_INSTALL_DIRS=(
    -DCMAKE_INSTALL_PREFIX=${QT5_PREFIX}
    -DKDE_INSTALL_LIBDIR=lib
    -DKDE_INSTALL_QMLDIR=share/qt5/qml
    -DKDE_INSTALL_QTPLUGINDIR=share/qt5/plugins
    -DKDE_INSTALL_DBUSDIR=share/dbus-1
    -DKDE_INSTALL_MANDIR=share/man
    -DKDE_INSTALL_APPDIR=share/applications
    -DKDE_INSTALL_MIMEDIR=share/mime/packages
    -DECM_MKSPECS_INSTALL_DIR=${QT5_PREFIX}/share/qt5/mkspecs/modules
  )
}
