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

PortSystem          1.0
PortGroup           active_variants 1.1

name                glibmm-2.4
set my_name         glibmm
version             2.62.0
revision            0

categories          devel x11
license             LGPL-2.1+
maintainers         {devans @dbevans} {mascguy @mascguy} openmaintainer

description         C++ interface to glib
long_description    {*}${description}
homepage            http://www.gtkmm.org/

set branch          [join [lrange [split ${version} .] 0 1] .]
master_sites        gnome:sources/${my_name}/${branch}/
distname            ${my_name}-${version}
dist_subdir         ${my_name}
use_xz              yes

checksums           rmd160  440f4c2edcc7501917df1d6cd344697f95d7e727 \
                    sha256  36659f13cc73282392d1305858f3bbca46fbd1ce2f078cc9db8b9f79b2e93cfe \
                    size    7398144

depends_build-append \
                    port:pkgconfig \
                    port:mm-common

depends_lib-append \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:libsigcxx2

# glibmm > 2.44.0 requires C++11 or better
compiler.cxx_standard 2011

configure.perl      /usr/bin/perl

configure.args-append \
                    --disable-silent-rules

post-destroot {
    set mmdoctooldir ${prefix}/share/glibmm-2.4/doctool
    xinstall -d ${destroot}${mmdoctooldir}
    xinstall -m 0644 -W ${worksrcpath}/docs \
        doc-install.pl doc-postprocess.pl \
        tagfile-to-devhelp2.xsl \
        ${destroot}${mmdoctooldir}
    xinstall -m 0644 -W ${worksrcpath}/docs/reference/html \
        doxygen.css \
        ${destroot}${mmdoctooldir}
}

# This port provides legacy bindings, previously provided by 'glibmm'.
# So the latter must be deactivated first, if an older version is installed.
# This logic added 2023-04-30; keep in place for at least 12 months.
pre-activate {
    set port_conflict_name    glibmm
    set port_conflict_ver_max "2.62.0"

    if { ![catch {set port_conflict_ver_info [lindex [registry_active ${port_conflict_name}] 0]}] } {
        set port_conflict_ver [lindex ${port_conflict_ver_info} 1]
        ui_info "${port_conflict_name} active version: ${port_conflict_ver}"

        if { [vercmp ${port_conflict_ver} ${port_conflict_ver_max}] <= 0 } {
            ui_info "Deactivating conflicting port: ${port_conflict_name}"
            registry_deactivate_composite ${port_conflict_name} "" [list ports_nodepcheck 1]
        }
    }
}

variant quartz conflicts x11 {
    require_active_variants path:lib/pkgconfig/glib-2.0.pc:glib2 quartz
}

variant x11 conflicts quartz {
    require_active_variants path:lib/pkgconfig/glib-2.0.pc:glib2 x11
    patchfiles-append patch-no_cocoa.diff
}

if {![variant_isset quartz]} {
    default_variants +x11
}

test.run            yes
test.target         check

livecheck.type      gnome
livecheck.name      ${my_name}
livecheck.url       http://ftp.gnome.org/pub/gnome/sources/${my_name}/${branch}/
