# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

_realname=adwaita-icon-theme-legacy
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=46.2
pkgrel=1
pkgdesc="Icon theme that provides fallback icons for old apps relying on global icon themes (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://gitlab.gnome.org/GNOME/adwaita-icon-theme-legacy"
license=("spdx:LGPL-3.0-or-later OR CC-BY-SA-3.0")
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-meson"
  "${MINGW_PACKAGE_PREFIX}-ninja"
  "${MINGW_PACKAGE_PREFIX}-pkgconf"
)
depends=(
  "${MINGW_PACKAGE_PREFIX}-hicolor-icon-theme"
  "${MINGW_PACKAGE_PREFIX}-gtk-update-icon-cache"
)
source=(
  "https://download.gnome.org/sources/${_realname}/${pkgver:0:2}/${_realname}-${pkgver}.tar.xz"
)
sha256sums=('548480f58589a54b72d18833b755b15ffbd567e3187249d74e2e1f8f99f22fb4')

build() {
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    "${MINGW_PREFIX}"/bin/meson.exe setup \
      --prefix="${MINGW_PREFIX}" \
      --wrap-mode=nodownload \
      --auto-features=enabled \
      --buildtype=plain \
      "${_realname}-${pkgver}" \
      "build-${MSYSTEM}"

  "${MINGW_PREFIX}"/bin/meson.exe compile -C "build-${MSYSTEM}"
}

package() {
  "${MINGW_PREFIX}"/bin/meson.exe install -C "build-${MSYSTEM}" --destdir "${pkgdir}"

  # https://gitlab.gnome.org/GNOME/adwaita-icon-theme-legacy/-/issues/3
  mv "${pkgdir}${MINGW_PREFIX}/share/licenses/adwaita-icon-theme" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}"
}
