# -*- 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 117569 2014-03-04 00:16:55Z takeshi@macports.org $

PortSystem          1.0
PortGroup           github 1.0

github.setup        D-Programming-Language tools 2.065
name                dmd-${github.project}
categories          lang
platforms           darwin
license             DMD
maintainers         takeshi openmaintainer
description         Ancilliary tools for the D programming language compiler
long_description \
    D is a language with C-like syntax and static typing. \
    It pragmatically combines efficiency, control, \
    and modeling power, with safety and programmer productivity. \
    This port provides the ancilliary tools for the D programming language compiler.
homepage            http://dlang.org/
checksums           rmd160  2aaaa9711b77a97e6d65beed5857ec3bea0237df \
                    sha256  a79d8afda8f2876219dd8de10027812b989985432492bf747e09f8181dc05c3d

depends_lib         port:phobos \
                    lib:libcurl:curl
depends_build       port:dmd-doc

use_configure       no

set bin "catdoc ddemangle detab findtags rdmd tolf"
set dmd ${prefix}/bin/dmd

if {${build_arch} eq "x86_64"} {
    set model 64
} else {
    set model 32
}
set dflags "-m${model} -O -d"

build {
    system -W ${worksrcpath} "
        for f in ${bin}; do
            ${dmd} ${dflags} \$f.d
        done
    "
    foreach f [glob ${prefix}/share/doc/dmd/*.html] {
        set tag [file rootname [file tail ${f}]].tag
        system -W ${worksrcpath} "
            ./findtags ${f} > ${tag}
        "
    }
    system -W ${worksrcpath} "${dmd} ${dflags} -J. dman.d"
    foreach f {dget changed} {
        system -W ${worksrcpath} "
            ${dmd} ${dflags} -of${f} ${f}.d -L-lcurl
        "
    }
    system -W ${worksrcpath}/DustMite "${dmd} ${dflags} dustmite.d dsplit.d -ofdustmite"
}

destroot {
    eval xinstall -W ${worksrcpath} -m 755 "${bin} dman dget changed DustMite/dustmite" ${destroot}${prefix}/bin
}
