# $Id: Portfile 64950 2010-03-18 12:22:44Z ryandesign@macports.org $

PortSystem              1.0

name                    pure
conflicts               pure-devel
version                 0.43
categories              lang
platforms               darwin
maintainers             ryandesign
license                 LGPLv3 GPLv3 BSD
use_parallel_build      yes
homepage                http://pure-lang.googlecode.com/
master_sites            ${homepage}files/
universal_variant       no

description \
    functional programming language based on term rewriting

long_description \
    Pure is a functional programming language based on term rewriting. \
    It has a modern syntax featuring curried function applications, lexical \
    closures and equational definitions with pattern matching, and thus is \
    somewhat similar to languages of the Haskell and ML variety. But Pure is \
    also a very dynamic and reflective language, and is more like Lisp in \
    this respect. The interpreter has an LLVM backend to do JIT compilation, \
    hence programs run blazingly fast and interfacing to C modules is easy. \
    The libraries are licensed under LGPLv3, the interpreter is GPLv3, and \
    the examples are BSD-licensed.

checksums               md5     f15b77eb6bb15e78c69e94a4ac1d9bd9 \
                        sha1    ce74deb19d2e45e388855cf9ff6c7cd4028fb400 \
                        rmd160  106108d803601565c3fb3dcaefcc0fce2f9b09fa

depends_build \
    path:bin/llvm-config:llvm

depends_lib \
    port:gmp \
    port:libiconv \
    port:libtool \
    port:readline

depends_run \
    path:bin/w3m:w3m

patchfiles \
    patch-Makefile.in.diff

platform macosx {
    depends_run-delete  path:bin/w3m:w3m
    depends_run-append  path:bin/openbrowser:openbrowser
    patchfiles-append   patch-openbrowser.diff
}

platform powerpc {
    configure.args-append --disable-fastcc
}

pre-configure {
    if {"i386" == ${os.arch}} {
        set arch Intel
        set llvm_minimum_version 2.4
    } else {
        set arch PowerPC
        set llvm_minimum_version 2.6
    }
    set llvm_installed_version [exec llvm-config --version]
    if {[rpm-vercomp ${llvm_installed_version} ${llvm_minimum_version}] < 0} {
        ui_error "${name} ${version} requires llvm ${llvm_minimum_version} or later on ${arch} but you have llvm ${llvm_installed_version}."
        return -code error "incompatible llvm version"
    }
    set llvm_cflags [exec llvm-config --cflags]
    if {-1 != [string first -mdynamic-no-pic ${llvm_cflags}]} {
        ui_error "${name} ${version} requires llvm be compiled using position-independent code (PIC)"
        return -code error "incompatible llvm installation"
    }
}

post-destroot {
    set docdir ${destroot}${prefix}/share/doc/${name}
    xinstall -d ${docdir} ${destroot}${prefix}/share/examples
    xinstall -W ${worksrcpath} -m 644 \
        COPYING \
        COPYING.LESSER \
        ChangeLog \
        NEWS \
        README \
        TODO \
        ${docdir}
    copy ${worksrcpath}/examples ${destroot}${prefix}/share/examples/${name}
}

test.run                yes
test.target             check

livecheck.type          regex
livecheck.url           http://code.google.com/p/pure-lang/downloads/list
livecheck.regex         ${name}-(\[0-9.\]+\[a-z\]*)\\.tar
