# -*- 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 tools 2.063 v
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/
set site            d-programming-language.org
checksums           rmd160  a12885c0d9e30e77111fdb3e9125197fb2a1130c \
                    sha256  8c27c66af938bf94e1a8241b68cf034e5257e18a1ba9150949322df98506fb1c

depends_lib         port:phobos
depends_build       port:dmd-doc

use_configure       no

set bin "catdoc ddemangle detab findtags rdmd tolf"
set dmd ${prefix}/bin/dmd
set dflags "-O -d"

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

build.args          -f posix.mak \
                    CC=${configure.cc} \
                    DFLAGS=${dflags} \
                    DMD=${dmd} \
                    MODEL=${model}
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"
}

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

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