# -*- 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            ascii-boxes boxes 1.3 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from     tarball

categories              textproc
license                 GPL-2+
maintainers             @StefKKK openmaintainer

description             draws boxes around text
long_description        boxes is a text filter which can draw various \
                        ASCII art boxes around its input text. \
                        Variants: 'emacs' -- installs boxes.el, which \
                        simplifies using boxes from emacs

homepage                http://boxes.thomasjensen.com

checksums               rmd160  c7cb62e5d491562c766d1ba9404544d1e80c46f9 \
                        sha256  c42d59e6fe58282b6e4835434326af6613f6a87219d3117989ec3886596ad95b \
                        size    99591

patchfiles              boxes.c.diff \
                        tools.c.diff \
                        regexp.h.diff \
                        testrunner.sh.diff


depends_build-append    port:bison port:cctools port:flex port:gsed

use_configure           no

variant emacs description {Install boxes.el for running inside emacs} {
    post-destroot {
        xinstall -m 755 -d ${destroot}${prefix}/share/emacs/site-lisp/${name}
        xinstall -m 644 ${worksrcpath}/doc/boxes.el ${destroot}${prefix}/share/emacs/site-lisp/${name}/
    }
}

build.target            ;# default target
build.args              CC=${configure.cc} GLOBALCONF=${prefix}/share/boxes CFLAGS_ADDTL="-D_POSIX_C_SOURCE=200809L"

test.run                yes

destroot {
    xinstall -m 755 ${worksrcpath}/src/boxes ${destroot}${prefix}/bin/${name}
    file copy ${worksrcpath}/boxes-config ${worksrcpath}/boxes
    xinstall -m 644 ${worksrcpath}/boxes ${destroot}${prefix}/share/${name}
    xinstall ${worksrcpath}/doc/boxes.1 ${destroot}${prefix}/share/man/man1/
    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} README.md LICENSE boxes-config ${destroot}${prefix}/share/doc/${name}
}

# can't use regex provided from GitHub portgroup as distfiles are different
livecheck.regex         [join [list {v([0-9]+(\.[0-9]+)*)} [string map {. \\.} ${extract.suffix}]] ""]
