# -*- 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 55661 2009-08-16 14:52:28Z jmr@macports.org $

PortSystem          1.0

name                pypy
version             1.1.0
set branch          [join [lrange [split ${version} .] 0 1] .]
categories          lang python devel
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
#license             MIT

homepage            http://codespeak.net/pypy/
master_sites        http://codespeak.net/download/pypy/
use_bzip2           yes

checksums           md5 562779596ca08e5405dd3c48df194744 \
                    sha1 cf62fc6d5dacca20f540f84431e5adee872b98d4 \
                    rmd160 c4715a620334251fdd98c6015805057813773c30

depends_lib         port:bzip2 \
                    port:libffi \
                    port:ncurses \
                    port:python26 \
                    port:zlib

patchfiles          setpgrp.diff
patch.args          -p2

use_configure       no

build.dir           ${worksrcpath}/pypy/translator/goal
build.cmd           ${prefix}/bin/python2.6
build.args          --batch --cc=${configure.cc} --opt=3
build.target        translate.py
build.post_args     targetpypystandalone.py

if {[info exists configure.cc_archflags]} {
    build.args-append --cflags=\"${configure.cc_archflags} ${configure.cppflags} ${configure.ldflags}\"
} else {
    build.args-append --cflags=\"${configure.cppflags} ${configure.ldflags}\"
}

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
    build.args-append  --opt=1
}
#variant jit description {enable just-in-time compiler} {
#    build.args-append  --jit
#}

livecheck.check     regex
livecheck.url       http://codespeak.net/pypy/dist/pypy/doc/download.html
livecheck.regex     pypy-(\[0-9.\]+)${extract.suffix}
