# -*- 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 92833 2012-05-08 23:46:29Z ryandesign@macports.org $

PortSystem          1.0
PortGroup           github 1.0

set dlang           D-Programming-Language
github.setup        ${dlang} druntime 2.059 v
categories          lang
platforms           darwin
license             Boost-1.0
maintainers         takeshi openmaintainer
description         Low level runtime library for the D programming language
long_description \
    Druntime is the minimum library required to support the D programming \
    language. It includes the system code required to support the garbage \
    collector, associative arrays, exception handling, array vector operations, \
    startup/shutdown, etc.
homepage            http://dlang.org/
set dbranch         3987c7
distname            ${dlang}-${name}-v${version}-0-g${dbranch}
checksums           rmd160  8754f330b0583060d65c2e37c8d931252132f50d \
                    sha256  055d6559edf98a1478a819897150d15cd691843dbca78cdd4d80082cc939100d \

worksrcdir          ${name}

depends_lib         port:dmd

post-patch {
    if {${configure.compiler}=="clang"} {
        reinplace "s|-Wa,-noexecstack||" ${worksrcpath}/posix.mak
    }
}

use_configure       no

if {${build_arch}=="x86_64"} {
    set model 64
} else {
    set model 32
}

build.args          -f posix.mak \
                    CC=${configure.cc} \
                    DMD=${prefix}/lib/dmd/bin/dmd \
                    MODEL=${model} \
                    CFLAGS=\"${configure.cflags}\"
build.target        ""

destroot {
    xinstall -m 644 ${worksrcpath}/lib/libdruntime-osx${model}.a \
        ${destroot}${prefix}/lib/libdruntime.a
    xinstall -m 755 -d ${destroot}${prefix}/include/${name}
    system "cd ${worksrcpath};
        cp -r import/* ${destroot}${prefix}/include/${name}
    "
}
