# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           meson 1.0

name                libgweather
version             3.36.2
revision            0
set branch          [join [lrange [split ${version} .] 0 1] .]
maintainers         {devans @dbevans} openmaintainer
categories          net gnome
license             GPL-2+ LGPL-2.1+
description         Library to accessing online weather informations.

long_description    libgweather is a library to access weather \
                    information from online services for numerous \
                    locations.

homepage            https://wiki.gnome.org/Projects/LibGWeather
master_sites        gnome:sources/${name}/${branch}/

use_xz              yes

checksums           rmd160  dbc2ad4ea7867b25323f1262881a6a578509029c \
                    sha256  ee1201a8fc25c14e940d3b26db49a34947c8aebf67dee01ee67fbcb06ecb37a0 \
                    size    2707976

depends_build       port:pkgconfig \
                    port:gettext \
                    port:gtk-doc \
                    port:python310 \
                    path:bin/vala:vala

depends_lib         port:geocode-glib \
                    port:gettext-runtime \
                    path:lib/pkgconfig/gobject-introspection-1.0.pc:gobject-introspection \
                    path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                    port:libxml2 \
                    port:libsoup-2.4

post-patch {
    reinplace -W ${worksrcpath} "s|^#!.*python3|#!${prefix}/bin/python3.10|" \
        data/update-locations.py \
        data/check-observations.py \
        data/locations_diff.py \
        meson/meson_post_install.py
}

configure.args      -Dglade_catalog=false \
                    -Dgtk_doc=true \
                    -Dzoneinfo_dir=${prefix}/share/zoneinfo

platform darwin 8 {
    # meson on Tiger cannot use rpaths, so we workaround with this to find dylib
    destroot.env-append "DYLD_LIBRARY_PATH=${build_dir}/${name}"
}

# uses g-ir-scanner, which uses $CC from env
if {${universal_possible} && [variant_isset universal]} {
    foreach arch ${configure.universal_archs} {
        lappend merger_build_env(${arch})  "CC=${configure.cc} -arch ${arch}"
        lappend merger_destroot_env(${arch})  "CC=${configure.cc} -arch ${arch}"
    }
} else {
    build.env-append       "CC=${configure.cc} ${configure.cc_archflags}"
    destroot.env-append    "CC=${configure.cc} ${configure.cc_archflags}"
}

variant glade description {Enable building of glade catalog items} {
    depends_lib-append  port:glade
    configure.args-replace -Dglade_catalog=false -Dglade_catalog=true
}

# glade expects catalog modules and libraries to have a .so suffix
post-destroot {
    if {[variant_isset glade]} {
        set libdir ${prefix}/lib
        ln -s ${libdir}/libgweather-3.dylib ${destroot}${libdir}/libgweather-3.so
    }
}

post-activate {
    system "${prefix}/bin/glib-compile-schemas ${prefix}/share/glib-2.0/schemas"
}

livecheck.type      gnome
