# $Id$

PortSystem              1.0

name                    lua50
conflicts               lua
version                 5.0.3
categories              lang
license                 MIT
maintainers             nomaintainer
description             powerful, 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 feee27132056de2949ce499b0ef4c480
distname                lua-${version}

depends_lib		port:readline

patchfiles		patch-config \
				patch-Makefile
post-patch {
	reinplace s|@PREFIX@|${prefix}| ${worksrcpath}/config
	reinplace s|@DESTROOT@|${destroot}| ${worksrcpath}/config
	reinplace s|@CC@|${configure.cc}| ${worksrcpath}/config
	reinplace "s|@CFLAGS@|${configure.cflags} [get_canonical_archflags]|" ${worksrcpath}/config
	reinplace "s|@LDFLAGS@|[get_canonical_archflags]|" ${worksrcpath}/config ${worksrcpath}/Makefile
}

build.target	all dylib dylibbin

destroot.target	install dylibinstall
post-destroot {
	xinstall -d -m 0755 ${destroot}${prefix}/share/doc/${name}
	xinstall -W ${worksrcpath} -m 0644 README ${destroot}${prefix}/share/doc/${name}
	xinstall -W ${worksrcpath} -m 0644 COPYRIGHT ${destroot}${prefix}/share/doc/${name}
	xinstall -W ${worksrcpath} -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 -W ${worksrcpath} -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 -W ${worksrcpath} -m 0644 ${test} ${destroot}${prefix}/share/doc/${name}/test
	}
}

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

livecheck.type	regex
livecheck.url	${master_sites}
livecheck.regex	"lua-(5.0(?:\\.\\d+)*)${extract.suffix}"

use_parallel_build no