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

# strndup
legacysupport.newest_darwin_requires_legacy 10

name                screen
version             5.0.1
revision            0
homepage            https://www.gnu.org/software/screen/
description         Screen manager with VT100/ANSI terminal emulation
long_description    \
    Screen is a full-screen window manager that multiplexes a physical \
    terminal between several processes (typically interactive shells). \
    Each virtual terminal provides the functions of a DEC VT100 terminal \
    and, in addition, several control functions from the ANSI X3.64 (ISO \
    6429) and ISO 2022 standards (e.g. insert/delete line and support for \
    multiple character sets). There is a scrollback history buffer for each \
    virtual terminal and a copy-and-paste mechanism that allows moving text \
    regions between windows.
conflicts           screen4
categories          sysutils
license             GPL-3+
maintainers         {gmail.com:davidgilman1 @dgilman} openmaintainer
master_sites        gnu:${name} \
                    http://www.ryandesign.com/macports/distfiles/screen/:encoding \
                    http://www.ryandesign.com/macports/distfiles/screen/r23776/:launchd_priv_header

# The file '18' above is a fix for UTF8-to-Big5HKSCS encoding translation.
# Reference: http://freebsd.sinica.edu.tw/~statue/index.php?file=20020513
distfiles-append    18:encoding

checksums           ${distname}${extract.suffix} \
                    rmd160  a7905cd84be4c98e4d05fbc459cfe9348bbb28e7 \
                    sha256  2dae36f4db379ffcd14b691596ba6ec18ac3a9e22bc47ac239789ab58409869d \
                    size    897507 \
                    18 \
                    rmd160  bd143058417e1d4c040a2589fdfbf8f9203f0b4c \
                    sha256  4d4b674a61dab6bac9b4207307c5f020fa670fc3948c39e7ea93c7fb9dfb5174 \
                    size    54746 \
                    vproc_priv.h \
                    rmd160  ea1fb112d58a168c581ee58e761c26f7caed40ec \
                    sha256  dcd2786d82865fb10542c20e97d7052110f7ca9a551f2ab5628c607f20e2bb2f \
                    size    4883

patchfiles          patch-apple-screen.diff \
                    patch-apple-window.diff \
                    patch-tic.diff \
                    patch-use-right-environ.diff
depends_lib-append  port:ncurses

extract.only        ${distname}${extract.suffix}
post-extract {
    file copy ${distpath}/18 ${workpath}
}

configure.args      --mandir=${prefix}/share/man \
                    --infodir=${prefix}/share/info \
                    --disable-utmp \
                    --enable-telnet \
                    --with-system_screenrc=${prefix}/etc
configure.cflags-append -DRUN_LOGIN

compiler.c_standard     2017

post-destroot {
    xinstall -m 644 ${workpath}/18 ${destroot}${prefix}/share/${name}/utf8encodings
    xinstall -m 644 ${worksrcpath}/etc/etcscreenrc ${destroot}${prefix}/etc/screenrc
    xinstall -m 644 ${worksrcpath}/terminfo/screencap ${destroot}${prefix}/etc/termcap
}

platform darwin {
    # The vproc_priv.h is the private header from launchd
    # We copied the header file from http://launchd.macosforge.org/trac/browser/trunk/launchd/src/vproc_priv.h, r23776
    distfiles-append    vproc_priv.h:launchd_priv_header
    post-extract {
        file copy ${distpath}/vproc_priv.h ${worksrcpath}
    }
}

if {${os.platform} eq "darwin" && ${os.major} < 10} {
    # Tiger lacks vproc.h and _CS_DARWIN_USER_TEMP_DIR, just nix the screen.c patch
    patchfiles-delete   patch-apple-screen.diff
}

notes "
Any screens running before upgrading, will not be available, post-install.
"
