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

github.setup        ngs-lang ngs 0.2.16 v
github.tarball_from archive
revision            0

homepage            https://ngs-lang.org

description         \
    Next Generation Shell (NGS)

long_description    \
    NGS is an alternative shell. At its core is a domain-specific language \
    that was specifically designed to be a shell language. It is designed \
    with a focus on Ops and systems engineering. One way to think about NGS \
    is bash plus data structures plus better syntax and error handling.

checksums           rmd160  1bad347434e78e4ea212e380ab44757acee9210b \
                    sha256  282bcd00164044a01b025b5373ed2e0b03d6e5b3d04cea2f363629a7ea5b92c7 \
                    size    745378

categories          shells
installs_libs       no
license             GPL-3
maintainers         {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

patchfiles          patch-implicit.diff

post-patch {
    # Replace hard-coded prefixes
    foreach ftarget {
        doc/ngstut.1.md
        doc/ngs.1.md
        doc/ngslang.1.md
        lib/autoload/globals/DelimStr.ngs
        lib/stdlib.ngs
        CMakeLists.txt
    } {
        reinplace -E "s|/usr/local|${prefix}|g" ${worksrcpath}/${ftarget}
    }

    # Correct man and doc paths
    reinplace {s|DESTINATION man/man1|DESTINATION share/man/man1|} \
        ${worksrcpath}/CMakeLists.txt

    reinplace {s|DESTINATION doc/ngs|DESTINATION share/doc/ngs|} \
        ${worksrcpath}/CMakeLists.txt
}

depends_build-append \
                    path:bin/gawk:gawk  \
                    path:bin/gsed:gsed  \
                    port:pandoc         \
                    port:peg            \
                    port:pkgconfig

depends_lib-append  port:boehmgc    \
                    port:json-c     \
                    port:libffi     \
                    port:pcre

configure.env-append \
                    "PKG_CONFIG_PATH=${prefix}/lib/pkgconfig"

build.env-append    "PKG_CONFIG_PATH=${prefix}/lib/pkgconfig"
