# -*- 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 97636 2012-09-10 13:00:36Z takeshi@macports.org $

PortSystem          1.0
PortGroup           github 1.0

set realname        d-programming-language.org
github.setup        D-Programming-Language ${realname} 2.063 v
name                dmd-doc
categories          lang
platforms           darwin
license             DMD
maintainers         takeshi openmaintainer
description         HTML files for dman of 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 html files required to build the dman command of \
    the D programming language compiler.
homepage            http://dlang.org/
checksums           rmd160  5bb269875d06432a8bcc3aae06cc90b9bd5f5a5f \
                    sha256  3d1d1b5455f2c99461e9295084e0249ced754511ae59473a2d77eb1aea6a3a4e

depends_lib         port:phobos

use_configure       no

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

set dmd ${prefix}/bin/dmd
set dflags "-O -d"
set ddocflags " -c -o- -Df"
set ddoc "macros.ddoc doc.ddoc"
set stddoc "std.ddoc"
set stddocflags "-m${model} -d -c -o- -version=StdDoc"
build {
   file mkdir ${worksrcpath}/dmd
    system "
        cd ${worksrcpath};
        ${dmd} ${ddocflags}dmd/expression.html ${ddoc} expression.dd;
        ${dmd} ${ddocflags}dmd/statement.html ${ddoc} statement.dd 
    "
    foreach f [glob ${prefix}/include/phobos/std/*.d] {
        set html std_[file rootname [file tail ${f}]].html
        system "
            cd ${worksrcpath};
            ${dmd} ${stddocflags} ${stddoc} -Dfdmd/${html} ${f}
        "
    }
}

destroot {
    xinstall -d -m 755 ${destroot}${prefix}/share/doc
    file copy ${worksrcpath}/dmd ${destroot}${prefix}/share/doc
}

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