# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 64907 2010-03-17 08:54:27Z jmr@macports.org $

PortSystem          1.0

name                pypy
version             1.2
set branch          [join [lrange [split ${version} .] 0 1] .]
categories          lang python devel
license             MIT/PSF
maintainers         jmr openmaintainer
description         implementation of Python in Python
long_description \
   PyPy is both a reimplementation of Python in Python, and a framework for \
   implementing interpreters and virtual machines for programming languages, \
   especially dynamic languages.

platforms           darwin

homepage            http://pypy.org/
master_sites        http://pypy.org/download/
use_bzip2           yes
distfiles           ${name}-${version}-src${extract.suffix}

checksums           md5 d423bd7dfbfbcfebb8435e55bcb36516 \
                    sha1 17d32765ce28a6fd3877fda003e5aceaf5f43511 \
                    rmd160 162ba5c84728be032000c3c39bf3c26f069f9795

depends_lib         port:libffi \
                    port:python26

use_configure       no

build.dir           ${worksrcpath}/pypy/translator/goal
build.cmd           arch -${build_arch} ${prefix}/bin/python2.6
build.args          --batch --cc=${configure.cc} --opt=3 \
                    --cflags=\"${configure.cc_archflags} ${configure.cppflags} ${configure.ldflags}\"
build.target        translate.py
build.post_args     targetpypystandalone.py

# JIT is only available on i386 at present
if {$build_arch == "i386"} {
    build.args-delete --opt=3
    build.args-append --opt=jit
}

destroot {
    xinstall -d ${destroot}${prefix}/share/${name}-${branch}/pypy
    copy ${worksrcpath}/pypy/lib ${destroot}${prefix}/share/${name}-${branch}/pypy
    xinstall -d ${destroot}${prefix}/share/${name}-${branch}/lib-python
    copy ${worksrcpath}/lib-python/2.5.2 ${worksrcpath}/lib-python/modified-2.5.2 \
         ${destroot}${prefix}/share/${name}-${branch}/lib-python
    xinstall -m 755 ${build.dir}/pypy-c ${destroot}${prefix}/bin
}

variant opt1 description {use optimization level 1 for faster build} {
    depends_lib-append port:boehmgc
    build.args-delete  --opt=3 --opt=jit
    build.args-append  --opt=1
}

livecheck.type      regex
livecheck.url       http://pypy.org/download.html
livecheck.regex     pypy-(\[0-9.\]+)-src${extract.suffix}
