# $Id$

PortSystem      1.0

name                    scotty
version                 3.0.0
revision                6
categories              net
maintainers             nomaintainer
description             Network management extensions to Tcl that enables \
			TCP/UDP connections, DNS queries, and SNMP.  The graphical \
			network mapper tkined is also included.
long_description        ${description}
homepage                http://wiki.tcl.tk/220
platforms               darwin
worksrcdir              ${name}/trunk

master_sites            macports
checksums               md5 40e1aeeee79767b882a78910ad177f78
distfiles		${name}-${version}-rev2813.tar.bz2
use_bzip2		yes

#fetch.type             svn
#svn.url                https://subversion.eecs.iu-bremen.de/svn/schoenw/src/scotty

depends_lib             port:tcl \
			port:tk

patchfiles		patch-Makefile.in \
			patch-configure.in.diff \
			patch-tnm-library-init.tcl

startupitem.create      yes
startupitem.name        nmicmpd
startupitem.executable  "${prefix}/bin/nmicmpd"

autoconf.dir            ${worksrcpath}/unix
configure.dir		${worksrcpath}/unix
build.dir		${worksrcpath}/unix

use_autoconf            yes

configure.args		--exec_prefix=${prefix} \
			--with-tcl=${prefix} \
			--with-tk=${prefix}

destroot.target		install sinstall

post-patch {
        reinplace "s|\$(INSTALL_ROOT)|${destroot}|g" \
                ${worksrcpath}/unix/Makefile.in

        reinplace "s|\$(BIN_INSTALL_DIR)/nmicmpd|${prefix}/bin/nmicmpd|g" \
                ${worksrcpath}/unix/Makefile.in

        reinplace "s|\$(BIN_INSTALL_DIR)/nmtrapd|${prefix}/bin/nmtrapd|g" \
                ${worksrcpath}/unix/Makefile.in
}

use_parallel_build      no

post-destroot {
        ln -s scotty3.0.0 ${destroot}${prefix}/bin/scotty
        ln -s tkined1.5.0 ${destroot}${prefix}/bin/tkined
}

platform darwin 8 {
pre-install {
# Replace the launchd item with one supporting inetdCompatibility
        file copy -force ${filespath}/org.macports.nmicmpd.plist \
                ${destroot}${prefix}/etc/LaunchDaemons/org.macports.nmicmpd/
        reinplace "s|__PREFIX__|${prefix}|g" \
                "${destroot}${prefix}/etc/LaunchDaemons/org.macports.nmicmpd/org.macports.nmicmpd.plist"
}
}

notes "
To enable the ${startupitem.executable} daemon:

   1) Add the following line to /etc/services:
        nmicmp 57777/tcp
      (You may use another port if necessary.)

   2) Load the launchd script installed by MacPorts:
        sudo port load ${name}

   3) Reboot and test the nmicmpd daemon:
        telnet localhost nmicmp
        ps -ax | grep nmicmpd
      (The daemon loads only when requested and unloads afterwards.)
"