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

PortSystem      1.0

name            gsed
set my_name     sed
version         4.10
revision        0
categories      textproc
license         GPL-3+
installs_libs   no
maintainers     {mps @Schamschula} openmaintainer
description     GNU version of the stream editor, sed

long_description \
    Sed (streams editor) isn't really a true text editor or text \
    processor. Instead, it is used to filter text, i.e., it takes text \
    input and performs some operation (or set of operations) on it and \
    outputs the modified text. Sed is typically used for extracting part \
    of a file using pattern matching or substituting multiple occurrences \
    of a string within a file.

homepage        https://www.gnu.org/software/${my_name}
master_sites    gnu:${my_name}
distname        ${my_name}-${version}
use_xz          yes

checksums       rmd160  2f7bfdc01880a6d596748bab95aac6aff2302632 \
                sha256  b8e72182b2ec96a3574e2998c47b7aaa64cc20ce000d8e9ac313cc07cecf28c7 \
                size    1732800

# TODO: does Tiger really need this?
# On Tiger it is desirable not to depend on texinfo port, which is pulled in via this PG.
if {${os.platform} ne "darwin" || ${os.major} > 8} {
    PortGroup   gnu_info 1.0
}

depends_build   port:gettext

depends_lib     port:gettext-runtime \
                port:libiconv

configure.args  --infodir=${prefix}/share/info \
                --mandir=${prefix}/share/man \
                --program-prefix=g

post-destroot {
    foreach i [glob -tails -directory ${destroot}${prefix}/share/info *.info*] {
        move ${destroot}${prefix}/share/info/${i} ${destroot}${prefix}/share/info/g${i}
    }

    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} AUTHORS BUGS COPYING ChangeLog NEWS README THANKS \
        ${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
    }
}

platform darwin 8 {
    # Drop on next update:
    incr revision

    # Bad things happen running 64-bit gsed on Tiger. Fine on Leopard.
    # See https://trac.macports.org/ticket/18297.
    supported_archs i386 ppc
}

test.run        yes
test.target     check
