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

name                    mosh
version                 1.3.2
categories              net
license                 {GPL-3+ OpenSSLException}
platforms               darwin
maintainers             mit.edu:quentin
description             Mobile Shell
long_description        Mosh is a replacement for ssh that better handles \
                        high-latency, high-packet-loss, dynamically-addressed \
                        network links
homepage                https://mosh.org/
master_sites            ${homepage}

checksums               rmd160  09cec7da65f525c4a414c1506d153ac72ea38c8a \
                        sha256  da600573dfa827d88ce114e0fed30210689381bbdcff543c931e4d6a2e851216

perl5.require_variant   yes
perl5.conflict_variants no
perl5.branches          5.24
perl5.default_branch    5.24
perl5.create_variants   ${perl5.branches}

depends_build           port:pkgconfig

depends_lib             port:ncurses \
                        port:protobuf-cpp \
                        port:zlib \
                        port:p${perl5.major}-getopt-long \
                        port:p${perl5.major}-io-socket-ip

post-patch {
    reinplace "s|#!/usr/bin/env perl|#!${prefix}/bin/perl${perl5.major}|" \
        ${worksrcpath}/scripts/mosh.pl
}

# Apple commoncrypto available 10.7 or later
if { ${os.major} > 10 } {
    configure.args      --with-crypto-library=apple-common-crypto
  } else {
    configure.args      --with-crypto-library=openssl
    depends_lib-append  path:lib/libssl.dylib:openssl
}

post-destroot {
    xinstall -d ${destroot}${prefix}/etc/bash_completion.d
    copy ${worksrcpath}/conf/bash-completion/completions/mosh \
         ${destroot}${prefix}/etc/bash_completion.d/mosh
}

livecheck.type          regex
livecheck.url           ${homepage}
livecheck.regex         "[quotemeta ${name}]-(\[0-9a-z.\]+)[quotemeta ${extract.suffix}]"
