PortSystem      1.0

name            gpatch
version         2.7.6
categories      devel
platforms       darwin sunos
license         GPL-3+
maintainers     nomaintainer

description     GNU patch, for applying diffs to files
long_description \
    Patch takes a patch file containing a difference listing produced by the \
    diff program and applies those differences to one or more original files, \
    producing patched versions.

homepage        https://www.gnu.org/software/patch/
master_sites    gnu:patch

distname        patch-${version}
checksums       rmd160  af10f7c59bf693bcaccf9067134b20c60c88429a \
                sha256  3d1d001210d76c9f754c12824aa69f25de7cb27bb6765df63455b77601a0dcc9
use_bzip2       yes

configure.args  --program-prefix=g

post-destroot {
    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
    }
}

notes "
    The patch tool provided by this port is prefixed with the character 'g' by default making it available as 'gpatch'.

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