# Maintainer: Jeremy Tan <jtanx@outlook.com>

_realname=libuninameslist
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=20240910
pkgrel=1
pkgdesc="Library of Unicode annotation data (mingw-w64)"
arch=(any)
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://libuninameslist.sourceforge.io/"
msys2_repository_url="https://github.com/fontforge/libuninameslist"
license=("spdx:BSD-3-Clause")
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools" "${MINGW_PACKAGE_PREFIX}-cc")
source=(https://github.com/fontforge/libuninameslist/releases/download/${pkgver}/libuninameslist-dist-${pkgver}.tar.gz)
sha256sums=('e59aab324ca0a3a713fe85c09a56c40c680a8458438d90624597920b3ef0be26')

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

build() {
  [[ -d "${srcdir}"/build-${MSYSTEM} ]] && rm -rf "${srcdir}"/build-${MSYSTEM}
  cp -rf "${srcdir}"/${_realname}-${pkgver} "${srcdir}"/build-${MSYSTEM}
  cd "${srcdir}"/build-${MSYSTEM}

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --enable-static

  make
}

check() {
  cd "${srcdir}/build-${MSYSTEM}"
  make test || true
}

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

  install -Dm644 "${srcdir}"/${_realname}-${pkgver}/LICENSE \
    "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}
