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

PortSystem          1.0

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

supported_archs     x86_64
universal_variant   no

# prebuilt binary uses libstdc++
configure.cxx_stdlib libstdc++

use_zip             yes
distfiles           dmd.${version}.osx${extract.suffix}
checksums           rmd160  e1283a098c6bf73a7798c86fa6859f141d1708dc \
                    sha256  76dbe4b1f5ad617a1cbe4cbbd288dcf051097d7cf49aaf91e74e12f5569ebcde \
                    size    33801497

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}
}

livecheck.type      none
