# Contributor: Mehdi Chinoune <mehdi.chinoune@hotmail.com>

_realname=libstaroffice
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.0.7
pkgrel=1
pkgdesc="A library for reading StarOffice documents. (mingw-w64)"
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
url='https://github.com/fosnola/libstaroffice'
msys2_references=(
  'archlinux: libstaroffice'
)
license=('spdx:MPL-2.0 OR LGPL-2.1-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs"
         "${MINGW_PACKAGE_PREFIX}-librevenge"
         "${MINGW_PACKAGE_PREFIX}-zlib")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools")
source=("https://github.com/fosnola/libstaroffice/releases/download/${pkgver}/${_realname}-${pkgver}.tar.xz")
sha256sums=('f94fb0ad8216f97127bedef163a45886b43c62deac5e5b0f5e628e234220c8db')

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

  autoreconf -fiv
}

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

  ../"${_realname}-${pkgver}"/configure \
    --prefix="${MINGW_PREFIX}"

  make
}

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

  make check
}

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

  make install DESTDIR="${pkgdir}"

  install -d "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}"
  install -p -m644 "${srcdir}"/${_realname}-${pkgver}/COPYING* "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}"
}
