# -*- 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$

PortSystem          1.0

name                dmd-bootstrap
# version should be same as HOST_DMD_VER found in posix.mak from dmd port
version             2.068.2
categories          lang
platforms           darwin
license             {GPL-1 Artistic-1} Boost-1 Restrictive
maintainers         mcalhoun openmaintainer
description         dmd Digital Mars D bootstrap compiler
long_description \
                    This is a package that installs a binary \
                    bootstrap dmd compiler.
homepage            http://dlang.org/
master_sites        http://downloads.dlang.org/releases/2.x/${version}

supported_archs     x86_64
universal_variant   no

use_zip             yes
distfiles           dmd.${version}.osx${extract.suffix}
checksums           rmd160 9f8cc6bb1b4171271cd5a8013cdbc85f63ca93cb \
                    sha256 e0d87d264e06155b695436bfc38df87cf133f2c63c279906ec648f24f6bb2207

worksrcdir          dmd2

use_configure       no

build {}

destroot {
    xinstall -d -m 0755 ${destroot}${prefix}/libexec/${name}/bin
    xinstall -d -m 0755 ${destroot}${prefix}/libexec/${name}/lib
    xinstall -d -m 0755 ${destroot}${prefix}/libexec/${name}/include/druntime
    xinstall -d -m 0755 ${destroot}${prefix}/libexec/${name}/include/phobos

    # only install the one program needed to bootstrap dmd
    xinstall -m 0755 \
        -W ${worksrcpath}/osx/bin \
        dmd \
        ${destroot}${prefix}/libexec/${name}/bin

    # install runtime environment
    file copy ${worksrcpath}/src/druntime/import  ${destroot}${prefix}/libexec/${name}/include/druntime
    file copy ${worksrcpath}/src/phobos/etc       ${destroot}${prefix}/libexec/${name}/include/phobos
    file copy ${worksrcpath}/src/phobos/std       ${destroot}${prefix}/libexec/${name}/include/phobos
    xinstall -m 0644 \
        {*}[glob ${worksrcpath}/src/phobos/*.d]   ${destroot}${prefix}/libexec/${name}/include/phobos

    xinstall -m 0644 \
        -W ${worksrcpath}/osx/lib \
        libphobos2.a \
        ${destroot}${prefix}/libexec/${name}/lib

    # install configuration file
    set conf [open ${destroot}${prefix}/libexec/${name}/bin/dmd.conf w]
    puts ${conf} "\[Environment\]
DFLAGS=-I%@P%/../include/phobos -I%@P%/../include/druntime/import -L-L%@P%/../lib"
    close ${conf}
}