# $Id$

PortSystem 1.0

name			expect
conflicts		bahamut whois
version			5.45
revision		4
platforms		darwin
categories		devel
license			Tcl/Tk
maintainers		nomaintainer
description		An automating and testing tool
long_description	Expect is a tool for automating interactive applications \
			such as telnet, ftp, passwd, fsck, rlogin, tip, etc. \
			Expect is also useful for testing these same applications. \
			And by adding Tk, you can also wrap interactive \
			applications in X11 GUIs.
homepage		http://expect.sourceforge.net/

# Set tclv and md5 checksum to the current MacPorts Tcl port version, though port doesn't
# break if they aren't in sync.

set tclv		8.6.0

master_sites		sourceforge:project/expect/Expect/${version}:exp \
			sourceforge:project/tcl/Tcl/${tclv}:tcl

dist_subdir		tcltk
distname		${name}${version}

distfiles		${distname}.tar.gz:exp \
			tcl${tclv}-src.tar.gz:tcl

checksums		${distname}.tar.gz \
			rmd160  edffe881ee45abe6e9aa150ea5958a04d0ffeab0 \
			sha256  b28dca90428a3b30e650525cdc16255d76bb6ccd65d448be53e620d95d5cc040 \
			tcl${tclv}-src.tar.gz \
			rmd160  656d100ad89d3c63596159b43c36f0fbd0507aca \
			sha256  354422b9c4791685499123b2dfe01faa98b555c08906c010cb4449ddc75dcade

depends_lib		port:tcl

post-patch {
	# For each example that gets installed in ${prefix}/bin, fix its
	# shebang (#!) line to directly run expect (why not?) to fix
	# "can't find package Expect while executing 'package require Expect'"
	foreach example {autoexpect autopasswd cryptdir decryptdir dislocate \
		ftp-rfc kibitz lpunlock mkpasswd multixterm passmass rftp \
		rlogin-cwd timed-read timed-run tknewsbiff tkpasswd unbuffer \
		weather xkibitz xpstat} {
		set file ${worksrcpath}/example/${example}
		system "patch ${file} < ${filespath}/patch-example.diff"
		reinplace "s|@PREFIX@|${prefix}|g" ${file}
	}
}

configure.cppflags-append -I${workpath}/tcl${tclv}/generic -I${workpath}/tcl${tclv}/unix
configure.ldflags-append -ltclstub8.6
configure.args		--disable-shared \
			--mandir=${prefix}/share/man \
			--with-tcl=${prefix}/lib \
			--with-tclinclude=${workpath}/tcl${tclv}/generic/

test.run		yes
test.target		test

post-destroot		{ ln -s expect${version}/libexpect${version}.a ${destroot}${prefix}/lib/libexpect.a

			file mkdir ${destroot}${prefix}/share/doc/${name}/examples
			eval xinstall -m 644 [glob ${worksrcpath}/example/*] \
				${destroot}${prefix}/share/doc/${name}/examples

			xinstall -m 644 -W ${worksrcpath} ChangeLog FAQ INSTALL NEWS README \
				${destroot}${prefix}/share/doc/${name}
			}