# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libspiro
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=20240903
pkgrel=1
epoch=1
pkgdesc="Simplifies the drawing of beautiful curves (mingw-w64)"
arch=(any)
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://libspiro.sourceforge.io/"
msys2_repository_url="https://github.com/fontforge/libspiro"
msys2_references=(
  "cpe: cpe:/a:libspiro_project:libspiro"
)
license=("spdx:GPL-3.0-or-later")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc" "${MINGW_PACKAGE_PREFIX}-autotools")
source=(https://github.com/fontforge/libspiro/archive/${pkgver}/${_realname}-${pkgver}.tar.gz)
sha256sums=('cf0251eb5f3545cce365b727a4a56a2f1292f1ef29245c2045c83e28f8a1df42')

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

build() {
  mkdir -p "build-${MSYSTEM}" && cd "build-${MSYSTEM}"

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

  make
}

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

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