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

github.setup        mananapr cfiles 1.8 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
categories          sysutils
license             MIT
maintainers         {@sikmir disroot.org:sikmir} openmaintainer

description         A ncurses file manager written in C with vim like keybindings
long_description    ${name} is a terminal file manager with vim like keybindings, \
                    written in C using the ncurses library. It aims to provide an \
                    interface like ranger while being lightweight, fast and minimal.

checksums           rmd160  fe4bba2a66d074f9bf81a5adff4e4fa3f0540e31 \
                    sha256  171780dde629193fa78e362d7607420ce99c7eecb4203de3a0383c4bbddbb4e7 \
                    size    237986

patchfiles          patch-config.h.diff \
                    patch-Makefile.diff

use_configure       no
depends_build       port:pkgconfig
depends_lib         port:ncurses
depends_run         port:atool \
                    port:fzf \
                    port:mediainfo \
                    path:bin/pdftoppm:poppler

build.args-append   CC=${configure.cc}

post-patch {
    reinplace "s#/usr/bin#${prefix}/share/cfiles/scripts#g" ${worksrcpath}/config.h
}

post-build {
    system -W ${worksrcpath} "gzip cfiles.1"
}

destroot {
    xinstall -m 755 ${worksrcpath}/cfiles ${destroot}${prefix}/bin
    xinstall -m 444 ${worksrcpath}/cfiles.1.gz ${destroot}${prefix}/share/man/man1
    xinstall -d ${destroot}${prefix}/share/cfiles/scripts
    xinstall -m 755 ${worksrcpath}/scripts/displayimg ${destroot}${prefix}/share/cfiles/scripts
    xinstall -m 755 ${worksrcpath}/scripts/displayimg_uberzug ${destroot}${prefix}/share/cfiles/scripts
    xinstall -m 755 ${worksrcpath}/scripts/clearimg ${destroot}${prefix}/share/cfiles/scripts
    xinstall -m 755 ${worksrcpath}/scripts/clearimg_uberzug ${destroot}${prefix}/share/cfiles/scripts
}
