# -*- 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            gnetcat
set my_name     netcat
version         0.7.1
revision        1
homepage        http://netcat.sourceforge.net/
description     A rewrite of the well-known networking tool, but more portable, with new features and fully GNU compliant.
long_description \
    Netcat is a featured networking utility which reads and writes data \
    across network connections, using the TCP/IP protocol.  It is designed to \
    be a reliable "back-end" tool that can be used directly or easily driven \
    by other programs and scripts. At the same time, it is a feature-rich \
    network debugging and exploration tool, since it can create almost any \
    kind of connection you would need and has several interesting built-in \
    capabilities.

categories      net
license         GPL-2+
platforms       darwin
maintainers     {alum.wpi.edu:arno+macports @fracai}
master_sites    sourceforge:${my_name}
distname        ${my_name}-${version}

checksums \
    md5 088def25efe04dcdd1f8369d8926ab34 \
	sha1 b5cbc52a7ceed2fd5c4f5081f5747130b2d0fe01 \
	rmd160 9eabed2b4b5585a55062b4a82c8c6aee1b01e3b7

depends_lib	\
	port:gettext \
	port:getopt \
	port:libiconv

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

use_parallel_build  yes

set docdir  ${prefix}/share/doc/${my_name}-${version}

test.run    yes
test.target check

post-configure {
    # prefix the shortname
    reinplace "s|netcat_nc = \$(DESTDIR)\$(bindir)/nc|netcat_nc = \$(DESTDIR)\$(bindir)/gnc|" ${worksrcpath}/src/Makefile
    reinplace "s|ln -s netcat \$(netcat_nc);|ln -s gnetcat \$(netcat_nc);|" ${worksrcpath}/src/Makefile
}

post-destroot {
    # prefix the info files
    foreach {f} [glob -tails -directory ${destroot}${prefix}/share/info *.info] {
        move ${destroot}${prefix}/share/info/${f} ${destroot}${prefix}/share/info/g${f}
    }
    # prefix the locale files
    foreach {d} [glob -tails -directory ${destroot}${prefix}/share/locale */] {
        foreach {f} [glob -tails -directory ${destroot}${prefix}/share/locale/${d}/LC_MESSAGES *.mo] {
            move ${destroot}${prefix}/share/locale/${d}/LC_MESSAGES/${f} ${destroot}${prefix}/share/locale/${d}/LC_MESSAGES/g${f}
        }
    }

    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
    }

    # create and copy the port docs
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} ABOUT-NLS AUTHORS COPYING ChangeLog INSTALL NEWS README TODO \
        ${destroot}${docdir}
}