# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem                  1.0
PortGroup                   deprecated 1.0

name                        scotty
version                     3.0.0
revision                    9
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                    https://wiki.tcl-lang.org/page/Scotty
platforms                   darwin
license                     Tcl/Tk
worksrcdir                  ${name}/trunk

master_sites                macports
checksums                   rmd160  e61fcc86c0f9bddfd356497b1f3c160cab946495 \
                            sha256  ebf65199b3205d309056df1de3f6e8a9ed672ce1de82c72e4be527f42e1cabff \
                            size    10969088
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 \
                            port:zlib

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

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}

configure.cflags-append     -DBIND_8_COMPAT \
                            -DUSE_INTERP_RESULT \
                            -DUSE_INTERP_ERRORLINE

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"
}
}

deprecated.upstream_support no

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.)
"