# -*- 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

name                xterm
version             398
revision            0
checksums           rmd160  ae52a0bbd1ac328c07c25d89456296ff83110c3c \
                    sha256  f679bd45f97063f10a880ecf7fc1611a9a03e8c8b98f063e99e0a079e87ee968 \
                    size    1605117

categories          x11
license             X11
maintainers         {jeremyhu @jeremyhu} openmaintainer
description         the ubiquitous X terminal emulator, stand-alone
long_description    The xterm program is a terminal emulator for the X \
                    Window System. It supports a plethora of features, \
                    including colors, Unicode, etc.

homepage            https://invisible-island.net/xterm/
master_sites        https://invisible-island.net/archives/${name}/ \
                    https://invisible-mirror.net/archives/${name}/
extract.suffix      .tgz

depends_build       port:xorg-xorgproto

depends_run         bin:luit:luit

depends_lib         port:ncurses \
                    port:fontconfig \
                    port:freetype \
                    port:xorg-libXaw \
                    port:xorg-libX11 \
                    port:xorg-libXext \
                    port:xorg-libXinerama \
                    port:xorg-libXmu \
                    port:xorg-libXt \
                    port:xorg-libice \
                    port:xpm \
                    port:Xft2

patchfiles          PR-7191532.patch

configure.args      --mandir=${prefix}/share/man --enable-luit \
                    --enable-logging --enable-wide-chars \
                    --enable-256-color --enable-load-vt-fonts \
                    --enable-double-buffer \
                    --enable-sixel-graphics --enable-regis-graphics \
                    --x-include=${prefix}/include --x-lib=${prefix}/lib \
                    --with-app-defaults=${prefix}/share/X11/app-defaults


if {${os.platform} eq "darwin" && ${os.major} > 19} {
    # add missing ncurses library to Makefile
    post-configure {
        reinplace "s|-lfontconfig|-lfontconfig -lncurses|" ${worksrcpath}/Makefile
    }
} else {
    # If -ltermcap stays in the LDFLAGS, xterm is linked against both
    # /usr/lib's and ${prefix}/lib's libncurses.
    post-configure {
        reinplace "s|-ltermcap|-lncurses|" ${worksrcpath}/Makefile
    }
}

livecheck.type      regex
livecheck.url       https://invisible-island.net/xterm/xterm.log.html
livecheck.regex     "Patch #(\\d+)"

variant utmp description {Support updating utmp/utmpx database
                          (installs setgid daemon)} {
   configure.args-append   --with-utmp-setgid=daemon --with-utempter
}

platform darwin 8 {
    configure.args-append cf_cv_xopen_source=no cf_cv_posix_c_source=no
}
