# -*- 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 104264 2013-03-22 12:47:02Z ryandesign@macports.org $

PortSystem          1.0
PortGroup           compiler_blacklist_versions 1.0

name                rethinkdb
version             1.4.0
categories          databases
platforms           darwin
maintainers         nomaintainer
license             AGPL-3

description         open-source distributed database

long_description    ${name} is an ${description} that has an intuitive query \
                    language, automatically parallelized queries, and simple \
                    administration.

homepage            http://www.rethinkdb.com/
master_sites        http://download.rethinkdb.com/dist/
extract.suffix      .tgz

checksums           rmd160  4b6a7ca9ac167848ba3b0877b9a94a8a92535440 \
                    sha256  da40ac64a0eac9d6b76452bed4ab9189eaa960c143479d862170d564253fdc5a

depends_lib         port:boost \
                    port:v8 \
                    path:bin/node:nodejs \
                    port:protobuf-cpp \
                    port:coffee-script

# nodejs only supports Intel processors and is not universal
supported_archs     i386 x86_64
universal_variant   no

# Error: GCC 4.2.2 is too old. At least GCC 4.4.3 is required
compiler.blacklist-append apple-gcc-4.0 apple-gcc-4.2
compiler.blacklist-append gcc-4.0 gcc-4.2
compiler.blacklist-append llvm-gcc-4.2 macports-llvm-gcc-4.2
compiler.blacklist-append macports-gcc-4.2 macports-gcc-4.3

# Xcode 3.2.x included clang but not clang++, so it used llvm-g++-4.2 instead.
compiler.blacklist-append {clang < 137}

# TODO: Remove when base fallback lists are updated (2.2?).
compiler.fallback-append macports-clang-3.2

# TODO: Remove when automatic compiler dependencies are released (2.2?).
if {[info exists portconfigure::compiler_name_map(${configure.compiler})]} {
    set compiler $portconfigure::compiler_name_map(${configure.compiler})
    if {[string first macports-gcc- ${configure.compiler}] == 0} {
        depends_lib-append              port:${compiler}
    } else {
        depends_build-append            port:${compiler}
    }
    if {[portconfigure::arch_flag_supported ${configure.compiler}]} {
        depends_skip_archcheck-append   ${compiler}
    }
}

set webresdir       ${prefix}/share/${name}/web
build.args          DEBUG=0 ALLOW_WARNINGS=1 BUILD_DIR=build WEBRESDIR=${webresdir}
build.target        build/rethinkdb web-assets

destroot.keepdirs   ${destroot}${prefix}/var/lib/rethinkdb/

destroot {
    xinstall ${worksrcpath}/build/rethinkdb ${destroot}${prefix}/bin/
    xinstall -m 644 ${worksrcpath}/packaging/assets/man/rethinkdb.1 ${destroot}${prefix}/share/man/man1/
    xinstall -d ${destroot}${prefix}/etc/rethinkdb/instances.d/
    xinstall -m 644 ${worksrcpath}/packaging/assets/config/default.conf.sample ${destroot}${prefix}/etc/rethinkdb/
    xinstall -d ${destroot}${prefix}/etc/bash_completion.d/
    xinstall -m 644 ${worksrcpath}/packaging/assets/scripts/rethinkdb.bash ${destroot}${prefix}/etc/bash_completion.d/
    xinstall -d ${destroot}${prefix}/share/${name}/
    move ${worksrcpath}/build/rethinkdb_web_assets/ ${destroot}${webresdir}

    # startup script ?
}

livecheck.type      regex
livecheck.url       ${master_sites}
livecheck.regex     ${name}-(\[0-9.\]+)${extract.suffix}
