# -*- 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 80612 2011-07-15 21:43:06Z ciserlohn@macports.org $

PortSystem              1.0

name                    nodejs-devel
version                 0.5.1
categories              devel net
platforms               darwin
maintainers             ciserlohn

description             Evented I/O for V8 JavaScript

long_description        Node's goal is to provide an easy way to build scalable network programs in JavaScript. \
                        Node is similar in design to and influenced by systems like Ruby's Event \
                        Machine or Python's Twisted. Node takes the event model a bit further-it \
                        presents the event loop as a language construct instead of as a library.

conflicts               nodejs

homepage                http://nodejs.org/
master_sites            ${homepage}dist/v${version}/

checksums               sha1    4c5b56885b4ce99b15d2f48d3073544394afa04a \
                        rmd160  a91bd373fd465cd74b2b9b0e34006f625d9f73e6

distname                node-v${version}

depends_build           port:python27

patchfiles              patch-Makefile-python.diff \
                        patch-platform.diff

pre-configure {
    foreach {badport badfile} "libev ${prefix}/include/ev.h c-ares ${prefix}/include/ares.h" {
        if {[file exists ${badfile}]} {
            ui_error "${name} cannot be built while ${badport} is active."
            ui_error "Please deactivate ${badport} and try again."
            ui_error "You can reactivate ${badport} again later."
            return -code error "${badport} is installed"
        }
    }
}

configure.args          --without-ssl

variant ssl description {Add secure socket layer support} {
    depends_build-append    port:pkgconfig
    depends_lib-append      port:openssl
    configure.args-delete   --without-ssl
}

default_variants        +ssl

# V8 only supports ARM and IA-32 processors
universal_variant       no

# "V8 doesn't like cache."
configure.ccache        no

test.run                yes

# TODO: Fix the doc installation
#variant doc description {Build and install manpages} {
#    use_configure   no
#    build {}
#    destroot.target doc install
#
#    depends_lib-append      port:asciidoc \
#                            port:libxslt
#}

build.args-append   CC=${configure.cc} \
                    CXX=${configure.cxx} \
                    CFLAGS="${configure.cflags} ${configure.cc_archflags}" \
                    LDFLAGS="${configure.ldflags} ${configure.ld_archflags}" \
                    PYTHON=${prefix}/bin/python2.7

livecheck.type      regex
livecheck.regex     node-v(\\d+\\.\[13579\]+\\.\\d+)
