# -*- 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

PortSystem 1.0
PortGroup           github 1.0

github.setup        nulang nu 2.1.2 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            2
name                nu2
categories          devel
maintainers         nomaintainer
license             Apache-2
conflicts           nu
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/

checksums           rmd160  f2a7ef7366d577bbc91307f95e013c3d2401c1f2 \
                    sha256  9230551a2c15fe29703d409cef124a531995dc271ef7ec99919e731172c87532 \
                    size    994256

# error: instance variables may not be placed in class extension
universal_variant   no
supported_archs     x86_64

depends_build       port:pkgconfig

depends_lib         port:libffi \
                    port:libedit

platform darwin {
    if {${os.major} < 11} {
        known_fail  yes
        pre-fetch {
            return -code error "${subport} @${version} requires OS X 10.7 Lion or later"
        }
    }
}

patchfiles          patch-Makefile.diff \
                    patch-Nukefile.diff \
                    patch-tools-nuke.diff

post-patch {
    reinplace -W ${worksrcpath} "s|@ARCHS@|[join [get_canonical_archs] {" "}]|g" Nukefile
    reinplace -W ${worksrcpath} "s|@CC@|${configure.cc}|g" tools/nuke
    reinplace -W ${worksrcpath} "s|@FRAMEWORKS_DIR@|${frameworks_dir}|g" tools/nuke

    if {${configure.sdkroot} ne ""} {
        set sdk "-isysroot ${configure.sdkroot}"
    } else { 
        set sdk ""
    }
    reinplace -W ${worksrcpath} "s|@SDK@|${sdk}|g" Makefile Nukefile
}

use_configure       no

pre-build {
    system -W ${worksrcpath} "${build.env} make -j${build.jobs}"
}

build.cmd           ./mininush tools/nuke
build.target
build.env           CC=${configure.cc} \
                    PREFIX=${prefix}

test.run            yes
test.cmd            nuke

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