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

PortGroup           legacysupport 1.0
# AT_FDCWD
legacysupport.newest_darwin_requires_legacy 13

name                ksh
conflicts           ksh93 ksh93-devel pdksh
categories          shells
platforms           darwin freebsd
maintainers         {ryandesign @ryandesign} openmaintainer
license             EPL-1

depends_lib         port:libiconv

patchfiles-append   dlfcn.c.patch

platform darwin 8 {
    configure.cppflags-append -D__DARWIN_UNIX03
}

if {${os.platform} eq "darwin" && ${os.major} <= 10} {
    configure.cppflags-append -DF_DUPFD_CLOEXEC=67
}

if {${subport} eq ${name}} {
    github.setup            att ast 2020.0.0
    revision                1
    checksums               rmd160  2ec9f2d800e69fcc32c9ebda64e331885fd335b8 \
                            sha256  3d6287f9ad13132bf8e57a8eac512b36a63ccce2b1e4531d7a946c5bf2375c63 \
                            size    1241660
    github.tarball_from     releases
    use_xz                  yes

    set branchtype          stable
    conflicts-append        ${name}-devel

    patchfiles-append       ksh-2020.0.0-cve-2019-14868.patch
}

subport ${name}-devel {
    github.setup            att ast 43d1853550010c2badce7da704019f5e61f62cac
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from     tarball
    version                 20200125-g[string range ${github.version} 0 6]
    revision                0
    checksums               rmd160  e97b8827d5aac3c357ecdcdbb944700f616d31ec \
                            sha256  ac2e86c80f976ae6106b5a04fe9c260a3ddd5da9b9ca04784f3f66ed77963c26 \
                            size    2229672

    set branchtype          development
    conflicts-append        ${name}

    configure.args          -Dfallback-version-number=${version}
}

description         the KornShell UNIX shell and programming language \
                    (${branchtype} version)

long_description    ${subport} is the KornShell (${branchtype} version), \
                    a UNIX shell and programming language originally by \
                    David Korn of AT&T Research.

distname            ${name}-${version}

deprecated.upstream_support no
livecheck.type      none
