# Maintainer: Frederik Carlier <frederik.carlier@keysight.com>

_realname=apps-systempreferences
pkgbase=mingw-w64-${_realname}
# Using same naming convention as Ubuntu: https://packages.ubuntu.com/noble/libpreferencepanes1
pkgname=("${MINGW_PACKAGE_PREFIX}-libpreferencepanes")
pkgver=1.2.1
pkgrel=5
pkgdesc="GNUstep preferences library - runtime library (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://gnustep.github.org/'
msys2_repository_url="https://github.com/gnustep/${_realname}"
license=('spdx:LGPL-2.1-or-later')
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-clang"
             "${MINGW_PACKAGE_PREFIX}-lld"
             "${MINGW_PACKAGE_PREFIX}-gnustep-make"
             rsync)
depends=("${MINGW_PACKAGE_PREFIX}-gnustep-gui")
source=("${msys2_repository_url}/archive/systempreferences-${pkgver//./_}.tar.gz")
sha256sums=('40125db52808abef4a08433c43ab856dcad3c24f909531655fc794145fd2c8ab')

build() {
  rsync --recursive --times --links "${srcdir}/${_realname}-systempreferences-${pkgver//./_}"/* "${srcdir}/build-${MSYSTEM}"
  cd "${srcdir}/build-${MSYSTEM}"

  CC="$MINGW_PREFIX/bin/clang" \
  CXX="$MINGW_PREFIX/bin/clang++" \
  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  make install DESTDIR="${pkgdir}"
  rm -rf "${pkgdir}"${MINGW_PREFIX}/lib/GNUstep/Bundles/
  rm -rf "${pkgdir}"${MINGW_PREFIX}/lib/GNUstep/Applications/

  install -Dm644 "${srcdir}/${_realname}-systempreferences-${pkgver//./_}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
