# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 115652 2014-01-07 23:26:18Z ryandesign@macports.org $

PortSystem      1.0

name            coreutils
conflicts       gexpr
version         8.22
categories      sysutils
platforms       darwin
license         GPL-3+
installs_libs   no
maintainers     nomaintainer
description     GNU File, Shell, and Text utilities

long_description \
    The GNU Core Utilities are the basic file, shell, and text \
    manipulation utilities of the GNU operating system. These are the \
    core utilities which are expected to exist on every operating \
    system. Previously these utilities were offered as three individual \
    sets of GNU utilities, fileutils, shellutils, and textutils. Those \
    three have been combined into a single set of utilities called the \
    coreutils.

homepage        http://www.gnu.org/software/${name}/
master_sites    gnu

use_xz          yes
checksums           rmd160  c3da7ade1d3ac82e97ac4a24c70376af8b9b503b \
                    sha256  5b3e94998152c017e6c75d56b9b994188eb71bf46d4038a642cb9141f6ff1212

depends_lib \
    port:gettext \
    port:gmp \
    port:libiconv

use_autoreconf yes
autoreconf.args -fvi

configure.args  --program-prefix=g
configure.env-append    FORCE_UNSAFE_CONFIGURE=1

post-destroot {
    if {[file exists ${destroot}${prefix}/share/info/dir]} {
        delete ${destroot}${prefix}/share/info/dir
    }

    if {[file exists ${destroot}${prefix}/lib/charset.alias]} {
        delete ${destroot}${prefix}/lib/charset.alias
    }

    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} AUTHORS COPYING ChangeLog NEWS README \
        THANKS THANKS-to-translators TODO ${destroot}${docdir}

    xinstall -m 755 -d ${destroot}${prefix}/libexec/gnubin
    foreach binary [glob -tails -directory ${destroot}${prefix}/bin g*] {
        ln -s ${prefix}/bin/${binary} ${destroot}${prefix}/libexec/gnubin/[string range $binary 1 end]
    }
    xinstall -m 755 -d ${destroot}${prefix}/libexec/gnubin/man/man1
    foreach manpage [glob -tails -directory ${destroot}${prefix}/share/man/man1 g*] {
        ln -s ${prefix}/share/man/man1/${manpage}.gz ${destroot}${prefix}/libexec/gnubin/man/man1/[string range $manpage 1 end].gz
    }
}

# Set the RUN_EXPENSIVE_TESTS environmental variable to 'yes' to run more
# expensive tests.  Set the RUN_VERY_EXPENSIVE_TESTS environmental variable
# to 'yes' to run even more expensive tests.
test.run        yes
test.target     check

notes "
    The tools provided by GNU coreutils are prefixed with the character 'g' by default to distinguish them from the BSD commands.
    For example, cp becomes gcp and ls becomes gls.

    If you want to use the GNU tools by default, add this directory to the front of your PATH environment variable:
        ${prefix}/libexec/gnubin/
"
