# $Id: Portfile,v 1.4 2004/11/03 19:30:27 rshaw Exp $

PortSystem              1.0
name                    lua
version                 5.0.2
revision		1
categories              lang
maintainers             anselmg@t-online.de
description             powerfull, light-weight programming language
long_description        Lua is a powerful, light-weight programming language \
			designed for extending applications. Lua is also frequently \
			used as a general-purpose, stand-alone language. 
platforms               darwin
homepage                http://www.lua.org
master_sites	${homepage}/ftp/
checksums               md5 dea74646b7e5c621fef7174df83c34b1

depends_lib		lib:libreadline:readline

patchfiles		patch-config \
				patch-Makefile
post-patch {
	reinplace s|@PREFIX@|${prefix}| ${worksrcpath}/config
	reinplace s|@DESTROOT@|${destroot}| ${worksrcpath}/config
}

build.target	all dylib dylibbin

destroot.target	install dylibinstall
post-destroot {
	cd ${worksrcpath}
	xinstall -d -m 0755 ${destroot}${prefix}/share/doc/${name}
	xinstall -m 0644 README ${destroot}${prefix}/share/doc/${name}
	xinstall -m 0644 COPYRIGHT ${destroot}${prefix}/share/doc/${name}
	xinstall -m 0644 HISTORY ${destroot}${prefix}/share/doc/${name}
	xinstall -d -m 0755 ${destroot}${prefix}/share/doc/${name}/html
	foreach html [glob doc/*.html doc/*.gif] {
		xinstall -m 0644 ${html} ${destroot}${prefix}/share/doc/${name}/html
	}
	xinstall -d -m 0755 ${destroot}${prefix}/share/doc/${name}/test
	foreach test [glob test/README test/*.lua] {
		xinstall -m 0644 ${test} ${destroot}${prefix}/share/doc/${name}/test
	}
}

test.run		yes
test.env		DYLD_LIBRARY_PATH=./lib

variant static {
	build.target	all
	destroot.target	install
	test.env
}

