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

gitlab.setup        gbrein tnylpo 1.1.7
revision            0

categories          emulators
license             BSD
maintainers         {@aeiouaeiouaeiouaeiouaeiouaeiou outlook.com:aeioudev} openmaintainer

description         Utility to run CP/M-80 programs under Unix/Linux
long_description    ${name} allows the execution of programs written \
                    for CP/M-80 version 2.2 under Unixy operating systems.

checksums           rmd160  5c24744f7e1e96a8803b52079f545d318a128013 \
                    sha256  b963eed9a8c580cb386ef76ce812754c2260f952f5877e7cf4e09b51c269d5a5 \
                    size    99791

depends_build       port:gmake
depends_lib         port:ncurses

use_configure       no

post-patch {
    reinplace "s|CFLAGS=|#CFLAGS=|g" ${worksrcpath}/makefile
}

build.cmd           gmake
build.env           CC=${configure.cc} \
                    "CFLAGS=${configure.cflags} [get_canonical_archflags cc]" \
                    "LDFLAGS=${configure.ldflags} [get_canonical_archflags ld]"

destroot {
    set mine_dir    ${destroot}${prefix}/share/examples/${name}/mine
    set tcpm_dir    ${destroot}${prefix}/share/examples/${name}/tcpm
    set doc_dir     ${destroot}${prefix}/share/doc/${name}

    xinstall -d -m 0755 ${mine_dir} ${tcpm_dir} ${doc_dir}
    xinstall -m 0755 ${build.dir}/tnylpo ${build.dir}/tnylpo-convert \
                    ${destroot}${prefix}/bin
    xinstall -m 0644 ${worksrcpath}/${name}.1 ${worksrcpath}/tnylpo-convert.1 \
                    ${destroot}${prefix}/share/man/man1/
    xinstall -m 0644 {*}[glob ${worksrcpath}/mine/*.*] ${mine_dir}
    xinstall -m 0644 {*}[glob ${worksrcpath}/tcpm/*.*] ${tcpm_dir}
    xinstall -m 0644 -W ${worksrcpath} LICENSE README.md ${doc_dir}
}
