# -*- 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           gitlab 1.0
PortGroup           legacysupport 1.1
PortGroup           meson 1.0

gitlab.instance     https://gitlab.gnome.org
gitlab.setup        GNOME vte 0.76.4
revision            1

categories          gnome
license             LGPL
maintainers         {devans @dbevans} {mascguy @mascguy} openmaintainer

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

set branch          [join [lrange [split $version .] 0 1] .]
use_bzip2           yes

# NOTE: macports-libcxx needed for std::bad_variant_access
legacysupport.newest_darwin_requires_legacy 16
legacysupport.use_mp_libcxx                 yes

checksums           rmd160  fcce3ff9b044853ed093dd6c304e5e9d5d766dea \
                    sha256  09dfba043112066f8002bc37757dd6f70b346ff30ed30f0701bebb186e465565 \
                    size    564972

# Disable unexpected download of subprojects
meson.wrap_mode     nodownload

# Upstream doesn't (yet) support quieting compiler warnings via meson_options.txt,
# so for now, patch meson.build to reduce the massive number of warnings.
patchfiles-append   patch-meson-warnings.diff

# https://trac.macports.org/ticket/69963
patchfiles-append   patch-F_DUPFD_CLOEXEC.diff

depends_build-append \
                    port:gettext \
                    port:intltool \
                    path:bin/pkg-config:pkgconfig

depends_lib-append \
                    path:lib/pkgconfig/cairo.pc:cairo \
                    port:gettext-runtime \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    path:lib/pkgconfig/gnutls.pc:gnutls \
                    path:lib/pkgconfig/gobject-introspection-1.0.pc:gobject-introspection \
                    path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                    port:fribidi \
                    path:lib/pkgconfig/icu-uc.pc:icu \
                    port:lz4 \
                    path:lib/pkgconfig/pango.pc:pango \
                    port:pcre2 \
                    path:bin/vala:vala \
                    port:zlib

depends_run-append \
                    port:adwaita-icon-theme

# requires C++20
compiler.cxx_standard 2020

# base does not yet know about c++20 so manually blacklist Xcode clangs for now
compiler.blacklist-append \
                    clang

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.args-append \
                    -D_b_symbolic_functions=false \
                    -D_systemd=false \
                    -Ddocs=false \
                    -Dfribidi=true \
                    -Dgir=true \
                    -Dglade=false \
                    -Dgnutls=true \
                    -Dgtk3=true \
                    -Dgtk4=false \
                    -Dvapi=true

configure.cflags-append \
                    -fstrict-aliasing

variant docs description {Enable docs} {
    depends_build-append \
                    port:gi-docgen \
                    port:gtk-doc

    configure.args-replace \
                    -Ddocs=false \
                    -Ddocs=true
}

variant glade description {Enable building of glade catalog items} {
    depends_lib-append \
                    port:glade

    configure.args-replace \
                    -Dglade=false \
                    -Dglade=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}/libvte-2.91.dylib ${destroot}${libdir}/libvte-2.91.so
    }
}

livecheck.type      gnome
