# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

_realname=libunibreak
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=6.1
pkgrel=1
pkgdesc="An implementation of the line breaking algorithm as described in Unicode 5.2.0 Standard Annex 14, Revision 24 (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/adah1972/libunibreak/'
license=('spdx:Zlib')
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-cc")
source=("https://github.com/adah1972/libunibreak/archive/libunibreak_${pkgver//./_}/$_realname-$pkgver.tar.gz")
sha256sums=('890674996168ef5ba143d80d49ab8b61594a4eb70198dcac76caf6e1bd264a41')

prepare() {
  mv "${srcdir}/${_realname}-${_realname}_${pkgver//./_}" "${srcdir}/${_realname}-${pkgver}"
  cd "${srcdir}/${_realname}-${pkgver}"

  ./bootstrap
}

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

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

  make
}

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

  make check
}

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

  make install DESTDIR="${pkgdir}"

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