# -*- 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.17 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  3ae81431097870c03b6054dc6f82e77dccaf33fa \
                    sha256  029c5d1167e884fee54fc99881e3d8c30478314f6e5fc2a7b832c909ed35d5b0 \
                    size    769926

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"
