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

_realname=libsystre
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
provides=("${MINGW_PACKAGE_PREFIX}-libgnurx")
conflicts=("${MINGW_PACKAGE_PREFIX}-libgnurx")
replaces=("${MINGW_PACKAGE_PREFIX}-libgnurx")
pkgver=1.0.1
pkgrel=4
pkgdesc="Wrapper library around TRE that provides POSIX API (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url=""
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-libtre")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config")
source=(systre-${pkgver}.tar.xz)
sha256sums=('909a058a01f3df3af3f030342a7283032b8b240c0fd66f22af80eee674fd39a2')

prepare() {
  cd systre-${pkgver}
  autoreconf -fiv
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"
  ../systre-${pkgver}/configure\
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --enable-static

  make
}

package() {
  cd build-${MINGW_CHOST}
  make DESTDIR="${pkgdir}" install
  install -D -m644 "${srcdir}/systre-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
