# $Id: Portfile 92644 2012-05-02 23:48:17Z ryandesign@macports.org $

PortSystem 1.0

name			expect
conflicts		whois
version			5.45
revision		3
platforms		darwin
categories		devel
maintainers		markd openmaintainer
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.5.11

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 \
			md5     44e1a4f4c877e9ddc5a542dfa7ecc92b \
			sha1    e634992cab35b7c6931e1f21fbb8f74d464bd496 \
			rmd160  edffe881ee45abe6e9aa150ea5958a04d0ffeab0 \
			tcl${tclv}-src.tar.gz \
			md5     b01a9691c83990b3db0ce62d1012ca67 \
			sha1    cb70dcfb7625389afd774e0438a7ade3e7aa13c8 \
			rmd160  36140b5e8365c190202132dd6f0dfeb831ea9bc8

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.cflags	"-I${workpath}/tcl${tclv}/generic -I${workpath}/tcl${tclv}/unix"
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}
			}

