# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=libspectre
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.2.12
pkgrel=2
pkgdesc='Small library for rendering Postscript documents (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://www.freedesktop.org/wiki/Software/libspectre/"
license=('spdx:GPL-2.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-ghostscript"
         "${MINGW_PACKAGE_PREFIX}-cairo")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-libidn"
             "${MINGW_PACKAGE_PREFIX}-autotools")
source=("https://libspectre.freedesktop.org/releases/${_realname}-${pkgver}.tar.gz"{,.sig}
        libspectre-0.2.9-mingw-fix-decoration.patch
        libspectre-0.2.9-fix-include-dirs.patch)
sha256sums=('55a7517cd3572bd2565df0cf450944a04d5273b279ebb369a895391957f0f960'
            'SKIP'
            '88a3ed9d3175f88255fc91b0651eb61a75a1168f329be864b7c235b9d9834f0b'
            '2d1a01a512d66b2cd60b0505f9b80a036461a2f549d28a4de980b1b015d70dd5')
validpgpkeys=('CA262C6C83DE4D2FB28A332A3A6A4DB839EAA6D7') # Albert Astals Cid <aacid@kde.org>

prepare() {
  cd ${_realname}-${pkgver}
  patch -p1 -i "${srcdir}"/libspectre-0.2.9-mingw-fix-decoration.patch
  patch -p1 -i "${srcdir}"/libspectre-0.2.9-fix-include-dirs.patch
  autoreconf -fiv
}

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

  ../${_realname}-${pkgver}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib

  make
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}
  make DESTDIR="${pkgdir}" install
  install -Dm644 "${srcdir}"/${_realname}-${pkgver}/COPYING "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
}
