# -*- 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
PortGroup           github 1.0
PortGroup           muniversal 1.0

github.setup        dlang dmd 2.071.0 v
categories          lang
platforms           darwin
license             {GPL-1 Artistic-1} Boost-1 Restrictive
maintainers         takeshi openmaintainer
description         dmd Digital Mars D 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.
homepage            http://dlang.org/
checksums           rmd160  0a16e840a9184747dc6a9be68693d5ffcea350e9 \
                    sha256  a2012524d89f8bd2e6b625ee6a85af74ba8d217a3b4220270b4667924b13112f
post-patch {
    reinplace "s|/etc|${prefix}/etc/${name}|" ${worksrcpath}/docs/man/man1/${name}.1
    reinplace "s|/etc|${prefix}/etc/${name}|" ${worksrcpath}/docs/man/man5/${name}.conf.5
}

use_configure       no

depends_build-append          port:dmd-bootstrap
depends_skip_archcheck-append dmd-bootstrap

build.dir           ${worksrcpath}/src

post-extract {
    xinstall -m 0644 ${filespath}/makefile_macports_install ${build.dir}
}

# Use CFLAGS in the posix.make; some source needs special flags.
# Command-line arguments wipe the CFLAGS in posix.mak and
# extra flags cannot be added with +=.
# Another solution would be the use of override directive in posix.mak.
build.args          -f posix.mak \
                    HOST_CXX="${configure.cxx}" \
                    LDFLAGS="${configure.ldflags} -framework CoreServices" \
                    ENVP="MACOSX_DEPLOYMENT_TARGET=${macosx_deployment_target}" \
                    SYSCONFDIR=${prefix}/etc/${name} \
                    HOST_DMD=${prefix}/libexec/dmd-bootstrap/bin/dmd

if { ![variant_isset universal] } {
    if { ${build_arch} eq "x86_64" || ${build_arch} eq "ppc64" } {
        build.args-append MODEL=64
    } else {
        build.args-append MODEL=32
    }
} else {
    lappend merger_build_args(x86_64) MODEL=64
    lappend merger_build_args(i386)   MODEL=32
    lappend merger_build_args(ppc64)  MODEL=64
    lappend merger_build_args(ppc)    MODEL=32
}

destroot.args \
    -f makefile_macports_install \
    PREFIX=${prefix}

notes {
    In order to have a complete dmd runtime environment consider installing the following ports:
    druntime phobos dmd-tools }

livecheck.regex     archive/[join ${github.tag_prefix} ""](\[^"-\]+)${extract.suffix}