# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.pro>

_realname=librttopo
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.1.0
pkgrel=1
pkgdesc="RT Topology Library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://git.osgeo.org/gitea/rttopo/librttopo"
license=('GPL2')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkgconf" "automake" "autoconf")
depends=("${MINGW_PACKAGE_PREFIX}-geos")
options=('strip')
source=("${_realname}-${pkgver}.tar.gz::${url}/archive/${_realname}-${pkgver}.tar.gz")
sha256sums=('2e2fcabb48193a712a6c76ac9a9be2a53f82e32f91a2bc834d9f1b4fa9cd879f')

prepare() {
  cd "${srcdir}/${_realname}"

  ./autogen.sh
}

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

  make
}

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

  make check
}

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