# -*- 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
# $Id: Portfile 91882 2012-04-12 09:33:32Z ryandesign@macports.org $

PortSystem          1.0
PortGroup           github 1.0

github.setup        jashkenas coffee-script 1.3.1
platforms           darwin
categories          lang
maintainers         ryandesign openmaintainer
license             MIT
supported_archs     noarch

description         a language that compiles into JavaScript

long_description    CoffeeScript is ${description}. Underneath all of \
                    those embarrassing braces and semicolons, JavaScript \
                    has always had a gorgeous object model at its heart. \
                    CoffeeScript is an attempt to expose the good parts \
                    of JavaScript in a simple way.

homepage            http://jashkenas.github.com/coffee-script/

checksums           rmd160  4c99f83939196298f45b3b4917f2f9d2cc113861 \
                    sha256  52e11cd3ef52dc90a06d42f9152c764c797d2bd842c49b96ec8a6a6ee20eff93

depends_lib         port:nodejs

patchfiles          patch-Cakefile.diff patch-prefix.diff

post-patch {
    reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/bin/cake ${worksrcpath}/bin/coffee
}

use_configure       no

build.cmd           bin/cake
build.target        build

destroot.destdir
destroot.pre_args   --prefix ${destroot}${prefix} ${destroot.target}

post-destroot {
    set docdir ${destroot}${prefix}/share/doc/${name}
    xinstall -d ${docdir}
    xinstall -m 644 -W ${worksrcpath} \
        LICENSE \
        README \
        ${docdir}
}

if {![file exists $env(HOME)/.node_libraries/coffee-script]} {
    notes-append "
To use ${name}, make a symlink to ${prefix}/lib/coffee-script/lib at\
~/.node_libraries/coffee-script:

    mkdir -p ~/.node_libraries
    ln -s ${prefix}/lib/coffee-script/lib ~/.node_libraries/coffee-script
"
}
