# -*- 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 106553 2013-05-30 21:25:54Z g5pw@macports.org $

PortSystem          1.0
PortGroup           github 1.0

github.setup        D-Programming-Language phobos 2.063 v
categories          lang
platforms           darwin
license             Boost-1
maintainers         takeshi openmaintainer
description         Runtime library for the D programming language
long_description \
    Phobos is the standard runtime library that comes with the D language compiler.
homepage            http://dlang.org/

checksums           rmd160  1d7a45a33a23089461fcfb23ea1d5dc4a652de76 \
                    sha256  10cdefdae0c29a307a2e9a8a8582ed1ab15a9c965855871335e2dc9fa3ee015d

depends_lib         port:druntime

post-patch {
    reinplace "s|-m\$(MODEL)||" ${worksrcpath}/posix.mak
    reinplace "s|/import||" ${worksrcpath}/posix.mak
}

use_configure       no

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

build.args          -f posix.mak \
                    DRUNTIME=${prefix}/lib/libdruntime.a \
                    CC=${configure.cc} \
                    CFLAGS="${configure.cflags} [get_canonical_archflags cc]" \
                    DMD=${prefix}/bin/dmd \
                    DFLAGS="-w -d -property -m${model} -O -release" \
                    MODEL=${model}
build.target        ""

destroot {
    xinstall -m 755 -d ${destroot}${prefix}/lib
    xinstall -m 644 ${worksrcpath}/generated/osx/release/${model}/lib${name}2.a \
        ${destroot}${prefix}/lib
    xinstall -d -m 755 ${destroot}${prefix}/include
    xinstall -d -m 755 ${destroot}${prefix}/include/${name}
    eval xinstall -m 644 [glob ${worksrcpath}/*.d] ${destroot}${prefix}/include/${name}
    file copy ${worksrcpath}/etc ${destroot}${prefix}/include/${name}
    file copy ${worksrcpath}/std ${destroot}${prefix}/include/${name}
}

livecheck.type      regex
livecheck.url       ${homepage}download.html
livecheck.regex     {\.([0-9]+\.[0-9]+)\.zip}
