# $Id: Portfile 92919 2012-05-10 20:21:01Z and.damore@macports.org $

PortSystem 1.0

name                nu2
version             2.0.1
revision            2
categories          devel
maintainers         nomaintainer
license             Apache-2.0
conflicts           nu
description         Nu is an interpreted object-oriented lisp-like language written in Objective-C. From version 2 Nu targets only from 10.7 onward.  
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/
master_sites        ${homepage}releases
distname            Nu-${version}
extract.suffix      .tgz

platforms           darwin

checksums           rmd160  b461b08fb7cf9e1a5569fbf85b411e62320f5cab \
                    sha256  bfaf9f17a2dbf0ef85cb3db267f2d773b14504aedd78e16580a61cfed676c4f4

use_configure       no
universal_variant   no
supported_archs     x86_64
depends_build       port:pkgconfig
depends_lib         port:libffi \
                    port:pcre \
                    port:libedit

pre-fetch {
     if {${os.major} < 11} then { error "Nu 2 requires Lion" }
}

patchfiles          patch-tools_nuke.diff \
                    patch-Makefile.diff \
                    patch-Nukefile.diff

post-patch {
    reinplace "s|\$(DEVROOT)/usr/bin/clang|${configure.cc}|"      ${worksrcpath}/Makefile
    reinplace "s|#{DEVROOT}/usr/bin/clang|${configure.cc}|"       ${worksrcpath}/Nukefile
    reinplace "s|{@destdir}/Library|{@destdir}${prefix}/Library|" ${worksrcpath}/Nukefile

    # replace placeholders in source files  
    reinplace "s|@ARCHS@|[join ${configure.build_arch} {" "}]|g" ${worksrcpath}/Nukefile
    reinplace "s|@CC@|${configure.cc}|g" ${worksrcpath}/Nukefile
    reinplace "s|@SDKROOT@|${configure.sdkroot}|g" ${worksrcpath}/Nukefile

    if {[vercmp $xcodeversion 4.3] < 0} { 
        set SDK ${developer_dir}/SDKs/MacOSX${macosx_deployment_target}.sdk 
    } else { 
        set SDK ${developer_dir}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${macosx_deployment_target}.sdk 
    } 
    reinplace "s|@SDKFLAGS@|-isysroot ${SDK}|g" ${worksrcpath}/Nukefile

    reinplace "s|/Library/Frameworks|${frameworks_dir}|"          ${worksrcpath}/tools/nuke
}

test.run            yes
test.cmd            nuke

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

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

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

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