# $Id: Portfile 68035 2010-05-25 02:52:17Z ryandesign@macports.org $

PortSystem              1.0

name                    pure-devel
conflicts               pure
version                 0.44-r3408
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

fetch.type              svn
svn.url                 ${homepage}svn/trunk/pure
svn.revision            [strsed ${version} {g/^.*-r//}]
worksrcdir              pure

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.

# bison and flex aren't needed for released tarballs
depends_build \
    path:bin/llvm-config:llvm \
    port:bison \
    port:flex

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.version       [lindex [split ${version} -] 0]
livecheck.type          regex
livecheck.url           ${svn.url}/configure.ac
livecheck.regex         {pure, ([0-9.]+)}
