# -*- 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           cxx11 1.1
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}
}

# uses C++11 bracketed initialization which requires clang 7.0.0 or better
# app.cc:309:31: error: no viable conversion from 'const GdkRGBA' (aka 'const _GdkRGBA') to 'gdouble' (aka 'double')
#                GdkRGBA color{bg_color};
#                              ^~~~~~~~
compiler.blacklist  *gcc-3.* *gcc-4.* {clang < 700}

if {[vercmp $xcodeversion 4.3] < 0 && [string match "*macports*" ${configure.compiler}]} {
    # Xcode 4.2 fails with load commands in the newer toolchain
    depends_build-append port:cctools

    configure.env-append \
        AR=${prefix}/bin/ar \
        RANLIB=${prefix}/bin/ranlib
}

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
    }
}

livecheck.type      gnome