# -*- 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               compiler_blacklist_versions 1.0
PortGroup               github 1.0
PortGroup               legacysupport 1.1
PortGroup               makefile 1.0

github.setup            jarun nnn 5.0 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from     tarball
revision                0
categories              sysutils
license                 BSD
maintainers             {mcalhoun @MarcusCalhoun-Lopez} openmaintainer
description             tiny, lightning fast, feature-packed file manager
long_description        ${name} is a tiny, lightning fast, feature-packed file manager.

checksums               rmd160  15f8419dfdb2672590aebb1cb69ba3491dc90c12 \
                        sha256  36c3d00d52905c1509e0d41f9a5ef8d466ef981c434e66b0b9b401b0bd948ead \
                        size    258526

installs_libs           no

depends_build           path:bin/pkg-config:pkgconfig

depends_lib             port:readline \
                        port:ncurses \
                        port:pcre

# https://trac.macports.org/ticket/70577
patchfiles-append       0001-Drop-a-defunct-fallback.patch

compiler.c_standard     2011
compiler.blacklist-append \
                        {clang < 602}

build.args-append       CFLAGS_OPTIMIZATION="" \
                        O_PCRE=1

post-destroot {
    set bash_completion ${prefix}/share/bash-completion/completions
    xinstall -d ${destroot}${bash_completion}
    xinstall -m 0644 ${worksrcpath}/misc/auto-completion/bash/nnn-completion.bash \
        ${destroot}${bash_completion}/nnn.bash

    set zsh_completion ${prefix}/share/zsh/site-functions
    xinstall -d ${destroot}${zsh_completion}
    xinstall -m 0644 ${worksrcpath}/misc/auto-completion/zsh/_nnn \
        ${destroot}${zsh_completion}/_nnn

    set fish_completion ${prefix}/share/fish/vendor_completions.d
    xinstall -d ${destroot}${fish_completion}
    xinstall -m 0644 ${worksrcpath}/misc/auto-completion/fish/nnn.fish \
        ${destroot}${fish_completion}/nnn.fish

    xinstall -d ${destroot}${prefix}/share/${name}/quitcd
    xinstall -m 0644 {*}[glob ${worksrcpath}/misc/quitcd/quitcd.*] \
        ${destroot}${prefix}/share/${name}/quitcd

    xinstall -d ${destroot}${prefix}/share/${name}/plugins
    xinstall -m 0644 {*}[glob ${worksrcpath}/plugins/*] \
        ${destroot}${prefix}/share/${name}/plugins
}