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

# Please keep the ksh93 and ksh93-devel ports as similar as possible.

github.setup        ksh93 ksh 1.0.10 v
revision            0
checksums           rmd160  29d8965318c8a3fc3bcb142380a515208ecd16fd \
                    sha256  9f4c7a9531cec6941d6a9fd7fb70a4aeda24ea32800f578fd4099083f98b4e8a\
                    size    2019536

name                ksh93-devel
version             93u+m-${github.version}
conflicts           ksh ksh-devel ksh93 pdksh
categories          shells
platforms           darwin freebsd
maintainers         {ryandesign @ryandesign} openmaintainer
license             EPL-1

description         continued development of the AT&T KornShell

long_description    This is ksh 93u+m, a continuation of the \
                    development of the KornShell, based on ksh 93u+ by \
                    David Korn and AT&T Research.

dist_subdir         ksh93
github.tarball_from archive

use_configure       no

build.cmd           bin/package
build.target        make

# Build output is misleading: You will see "CC=cc" and builds being done
# by "cc", but that "cc" is a wrapper script created by the build system
# which in turn calls the compiler we specify here.
build.env           "CC=${configure.cc}" \
                    "CCFLAGS=${configure.cflags} [get_canonical_archflags cc]" \
                    "LDFLAGS=${configure.ldflags} [get_canonical_archflags ld]" \
                    "NPROC=${build.jobs}"
build.args          SHELL="/bin/sh"

destroot {
    xinstall -m 0755 ${build.dir}/arch/${ksharch}/bin/ksh \
        ${destroot}${prefix}/bin
    xinstall -m 0444 ${build.dir}/src/cmd/ksh93/sh.1 \
        ${destroot}${prefix}/share/man/man1/ksh.1
    xinstall -m 0755 -d ${destroot}${prefix}/share/${name}
    xinstall -m 0755 ${build.dir}/src/cmd/ksh93/fun/autocd \
        ${destroot}${prefix}/share/${name}
    xinstall -m 0755 ${build.dir}/src/cmd/ksh93/fun/cd \
        ${destroot}${prefix}/share/${name}
    xinstall -m 0755 ${build.dir}/src/cmd/ksh93/fun/dirs \
        ${destroot}${prefix}/share/${name}
    xinstall -m 0755 ${build.dir}/src/cmd/ksh93/fun/mcd \
        ${destroot}${prefix}/share/${name}
    xinstall -m 0755 ${build.dir}/src/cmd/ksh93/fun/popd \
        ${destroot}${prefix}/share/${name}
    xinstall -m 0755 ${build.dir}/src/cmd/ksh93/fun/pushd \
        ${destroot}${prefix}/share/${name}
}

options ksharch
default ksharch {[ksharch]}

proc ksharch {} {
    global build.cmd build.dir build.env
    return [exec env {*}${build.env} ${build.dir}/${build.cmd} host type]
}