# $Id: Portfile 76845 2011-03-10 14:01:14Z afb@macports.org $

PortSystem 1.0
name            gwhich
version         2.20
revision        1
categories      sysutils
maintainers     nomaintainer
description     GNU Which - Everything you never wanted in a which
long_description \
    Which is a utility that prints out the full path of the executables \
    that bash would execute when the passed program names would have    \
    been entered on the shell prompt. It does this by using the exact   \
    same algorithm as bash. Tildes and a dot in the PATH are now        \
    expanded to the full path by default.  Options allow to rather print\
    '~/*' or './*' and/or to print all executables that match any       \
    directory in PATH.

homepage        http://www.xs4all.nl/~carlo17/which/
platforms       darwin
master_sites    gnu:which
distname        which-${version}
checksums       md5     95be0501a466e515422cde4af46b2744 \
                sha1    3bcd6d87aa5231917ba7123319eedcae90cfa0fd \
                rmd160  f0e8f464b9fe70c0126749d559e98170cdac0b98

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

post-destroot {
    file rename ${destroot}${prefix}/share/info/which.info ${destroot}${prefix}/share/info/gwhich.info
    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
    }
}

test.run        yes
test.target     check
