# Maintainer: Alexey Kasatkin <alexeikasatkin@gmail.com>
# ArchLinux maintainer: Brian Galey <bkgaley@gmail.com>

_realname=readosm
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
_pkgver=1.1.0a
pkgver=1.1.0.a
pkgrel=3
pkgdesc="Library to extract valid data from within an Open Street Map input file (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://www.gaia-gis.it/fossil/readosm/index"
license=('MPL')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc" "${MINGW_PACKAGE_PREFIX}-autotools")
depends=("${MINGW_PACKAGE_PREFIX}-expat" "${MINGW_PACKAGE_PREFIX}-zlib")
source=("https://www.gaia-gis.it/gaia-sins/${_realname}-sources/${_realname}-${_pkgver}.tar.gz")
sha256sums=('db7c051d256cec7ecd4c3775ab9bc820da5a4bf72ffd4e9f40b911d79770f145')

prepare() {
  cd "${srcdir}/${_realname}-${_pkgver}"
  # autoreconf to get updated libtool files with clang support
  autoreconf -fiv
}

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

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

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make DESTDIR="${pkgdir}" install
}
