# Maintainer: Peter Budai <peterbudai at hotmail dot com>

_realname=osm-gps-map
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.2.0
pkgrel=6
pkgdesc="A Gtk+ Widget for Displaying OpenStreetMap tiles. (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://nzjrs.github.io/osm-gps-map/"
msys2_repository_url="https://github.com/nzjrs/osm-gps-map"
license=("spdx:GPL-2.0-only")
depends=(
    "${MINGW_PACKAGE_PREFIX}-cairo"
    "${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2"
    "${MINGW_PACKAGE_PREFIX}-gettext-runtime"
    "${MINGW_PACKAGE_PREFIX}-glib2"
    "${MINGW_PACKAGE_PREFIX}-gtk3"
    "${MINGW_PACKAGE_PREFIX}-libsoup3"
)
makedepends=(
    "${MINGW_PACKAGE_PREFIX}-cc"
    "${MINGW_PACKAGE_PREFIX}-autotools"
    "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
    "${MINGW_PACKAGE_PREFIX}-gtk-doc"
)
source=(https://github.com/nzjrs/osm-gps-map/releases/download/${pkgver}/${_realname}-${pkgver}.tar.gz
        https://raw.githubusercontent.com/void-linux/void-packages/f6b0cf8ca04678301773327b9a2d5efb043dae3d/srcpkgs/libosmgpsmap/patches/libsoup-3.patch
        https://github.com/nzjrs/osm-gps-map/commit/639ea5e02d2cb47cbc15554d61b1ba6b0ee073b6.patch)
sha256sums=('ddec11449f37b5dffb4bca134d024623897c6140af1f9981a8acc512dbf6a7a5'
            '045c8c9a6a317aea89158154818399815525f5b5cb0340332f92b250d73e5bc6'
            '6315db12928f4d3ff982e15c6de1c4c84c9607ca440f7d75e1548686eae96c7c')

prepare() {
    cd "${srcdir}/${_realname}-${pkgver}"
    # https://github.com/nzjrs/osm-gps-map/issues/96 (rebased by Void Linux)
    patch -p1 -i "${srcdir}/libsoup-3.patch"
    # https://github.com/nzjrs/osm-gps-map/issues/106
    patch -p1 -i "${srcdir}/639ea5e02d2cb47cbc15554d61b1ba6b0ee073b6.patch"
    # autoreconf to get updated libtool files for clang
    autoreconf -fiv
}

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

    export lt_cv_deplibs_check_method='pass_all'

    CFLAGS+=" -DG_DISABLE_ASSERT"
    ../${_realname}-${pkgver}/configure \
        --prefix="${MINGW_PREFIX}"      \
        --enable-gtk-doc=no

  make
}

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