# $Id$

PortSystem 1.0

name                nu
version             0.4.0
revision            2
categories          devel
maintainers         nomaintainer
license             Apache-2

description         Nu is an interpreted object-oriented lisp-like language written in Objective-C.
long_description    \
    Nu is an interpreted object-oriented language. \
    It uses a Lisp-style grammar, but is semantically closer to Ruby than to Lisp. \
    Nu is written in Objective-C and is designed to take full advantange of \
    the Objective-C runtime and the many mature class libraries written in Objective-C. \
    Nu code can fully interoperate with code written in Objective-C\; \
    messages can be sent to and from objects with no concern for whether those messages \
    are implemented in Objective-C or Nu.
homepage            http://programming.nu/
platforms           darwin
master_sites        http://programming.nu/releases/
distname            Nu-${version}
extract.suffix      .tgz

checksums           sha1    02e0df424f18a6c6c3c3221699014018cabcd8bc \
                    rmd160  31aa22c7a4dddd1135a55f6bdaf27b1f485ded43

patchfiles          patch-Makefile.diff patch-Nukefile.diff

depends_build       port:pkgconfig

depends_lib         port:libffi port:pcre port:libedit

use_configure       no
variant universal {}

test.run            yes
test.cmd            nuke

livecheck.type      regex
livecheck.url       http://programming.nu/downloads
livecheck.regex     {Nu-([\d.]+).tgz}

post-patch {
    if {[variant_isset universal]} {
        set archs ${configure.universal_archs}
    } else {
        set archs ${configure.build_arch}
    }
    reinplace "s|@ARCHS@|[join ${archs} {" "}]|g" ${worksrcpath}/Nukefile
    reinplace "s|@CC@|${configure.cc}|g" ${worksrcpath}/Nukefile
    reinplace "s|@SDKROOT@|${configure.sdkroot}|g" ${worksrcpath}/Nukefile
    reinplace "s|/usr/local|${prefix}|g" \
        ${worksrcpath}/tools/nubile \
        ${worksrcpath}/examples/NuAnywhere/nu-anywhere
}

pre-build {
    system -W ${worksrcpath} "make PREFIX=${prefix} CC=${configure.cc}"
}

build.cmd           "./mininush tools/nuke"
build.target
build.env           PREFIX=${prefix}

pre-destroot {
    file mkdir ${destroot}/Library/Frameworks
}

destroot.destdir
destroot.env-append PREFIX=${prefix} \
                    DESTDIR=${destroot}