# -*- 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           gobject_introspection 1.0
PortGroup           compiler_blacklist_versions 1.0

name                vte
version             0.52.2
set branch          [join [lrange [split $version .] 0 1] .]
maintainers         {devans @dbevans} openmaintainer
categories          gnome
license             LGPL
platforms           darwin
description         VTE is a library (libvte) implementing a terminal emulator widget for GTK+, \
                    and a minimal sample application (vte) using that.

long_description    ${description} \
                    Vte is mainly used in gnome-terminal, but can also be used to embed a \
                    console/terminal in games, editors, IDEs, etc.

homepage            https://wiki.gnome.org/Apps/Terminal/VTE
master_sites        gnome:sources/$name/$branch/

use_xz              yes

checksums           rmd160  3707a2a4a0ca7bbc562dbf2d570e7e4a4a15afef \
                    sha256  0f2657cef52accbfe56feede553155552d7c1984b1291838af3cb8cfc19b26af \
                    size    1011696

depends_build       port:pkgconfig \
                    port:intltool \
                    port:gtk-doc \
                    port:autoconf \
                    port:automake \
                    port:libtool

depends_lib         port:gtk3 \
                    port:gnutls \
                    port:pcre2 \
                    port:zlib \
                    port:vala

depends_run         port:adwaita-icon-theme

patchfiles          patch-src-pty.cc.diff \
                    patch-strchrnul.diff

gobject_introspection yes

# reconfigure using upstream autogen.sh for intltool 0.51 compatibility

post-patch {
    xinstall -m 755 ${filespath}/autogen.sh ${worksrcpath}
}

# gcc-4.2 from Xcode 3.6.2 fails with:
# vte.cc:5275: error: expected primary-expression before ‘[’ token
compiler.blacklist  *gcc* {clang < 300}

configure.cmd       ./autogen.sh

configure.args      --disable-Bsymbolic \
                    --disable-silent-rules \
                    --enable-vala=yes

configure.cflags-append -fstrict-aliasing

variant glade description {Enable building of glade catalog items} {
    depends_lib-append      port:glade
    configure.args-append   --enable-glade-catalogue
}

# glade expects catalog modules and libraries to have a .so suffix

post-destroot {
    if {[variant_isset glade]} {
        set libdir ${prefix}/lib
        ln -s ${libdir}/libvte-2.91.dylib ${destroot}${libdir}/libvte-2.91.so
    }
}

platform darwin {
    if {${configure.cxx_stdlib} eq "libstdc++"} {
        # vte 0.43.1+ build fails on platforms supporting libstdc++ (#50492)
        version             0.43.0
        revision            3
        checksums           rmd160  d9a1eb6d6d5cbb39e04f625d22e43315500750b8 \
                            sha256  2f10ae4148633e9ee458639f72cf2929703d413b95eee416fd6f03db8c4d4ab9
        patchfiles          patch-src-Makefile.am-0.43.0.diff \
                            patch-src-pty.cc-0.43.0.diff \
                            patch-src-vteutils.cc-0.43.0.diff
        configure.args-append \
                            --without-pcre2
        livecheck.type      none
    } else {
        livecheck.type      gnome
    }
}