# $Id: Portfile 53542 2009-07-08 00:15:29Z takanori@macports.org $

PortSystem              1.0

name			parrot
version			1.0.0
revision                1
categories		lang devel
maintainers		bfulgham coleda.com:will
description		Open source virtual machine (for Perl6 et al.)
long_description	\
        Parrot is a virtual machine designed to efficiently compile and \
        execute bytecode for dynamic languages. Parrot currently hosts a \
        variety of language implementations in various stages of completion, \
        including Tcl, Javascript, Ruby, Lua, Scheme, PHP, Python, Perl 6, \
        and a .NET bytecode translator.

platforms		darwin
homepage		http://www.parrot.org/
master_sites		ftp://ftp.parrot.org/pub/parrot/releases/stable/${version}/

checksums		md5 649ce1fb7c0edaf89dc1cd52ff267b1a \
			sha1 9e028f5fff38a332c13ad4389652a016d7a824f7 \
			rmd160 46f60accd33f16cc910f4ea03840badc358d22c7

depends_build		bin:perl:perl5
depends_lib		port:gmp port:icu

configure.cmd		perl Configure.pl
configure.pre_args	--prefix=${prefix}/lib/parrot
configure.args		--optimize

destroot.target         install

build.type		gnu
build.target

test.run		yes
test.target		test

destroot.destdir	 PREFIX=${destroot}${prefix}/lib/parrot

post-destroot {
	set bindir	${destroot}${prefix}/bin
	set docdir      ${destroot}${prefix}/share/doc/${name}

        set executables {
            parrot parrot_config parrot_debugger
            pbc_disassemble pbc_info pbc_merge pbc_to_exe pbc_dump
        }

        foreach exe $executables { 
            # fixup the library path
            set old_path "${workpath}/parrot-${version}/blib/lib/libparrot.dylib"
            set new_path "${prefix}/lib/parrot/lib/libparrot.${version}.dylib"
	    system "cd ${prefix}/lib/parrot/bin && \
                install_name_tool -change \"$old_path\" \"$new_path\" ${exe}"

            # install into the common area.
            system "cd ${bindir} && ln -sf ${prefix}/lib/parrot/bin/${exe}"
        }
	xinstall -m 755 -d ${docdir}
}
