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

github.setup        dlang dub 1.18.0 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
categories          devel
license             GPL-3
maintainers         nomaintainer
description         Package and build management system for D
long_description    Package and build manager for D applications and libraries.

depends_lib         port:dmd \
                    port:druntime \
                    port:phobos \
                    port:dmd-tools

checksums           rmd160  a7b9d2fda4c3d0591acdc6cce424634531204342 \
                    sha256  79cde78c6f99fffd9212b3f7f2fe204e7882ebab7476d259e257017f44220b23 \
                    size    1281236

use_configure       no

build.cmd           ./build.sh
build.target
build.env           CC=${configure.cc}

destroot {
    xinstall -d -m 0755 ${destroot}${prefix}/share/bash-completion/completions
    xinstall -m 0644 ${worksrcpath}/scripts/bash-completion/dub.bash ${destroot}${prefix}/share/bash-completion/completions

    xinstall -m 0755 ${worksrcpath}/bin/dub ${destroot}${prefix}/bin

    xinstall -d -m 0755 ${destroot}${prefix}/share/${name}
    copy ${worksrcpath}/examples ${destroot}${prefix}/share/dub
}

# respect MACOSX_DEPLOYMENT_TARGET environment value
patchfiles-append   patch-build.sh.diff

# look for configuration file in ${prefix} instead of /
patchfiles-append   patch-dub.d.diff
post-patch {
    reinplace "s|__MACPORTS_PREFIX__|${prefix}|g" source/dub/dub.d
}
if {!${universal_possible} || ![variant_isset universal]} {
    if { ${build_arch} eq "x86_64" || ${build_arch} eq "ppc64" } {
        build.env-append "DMD=${prefix}/bin/dmd -m64"
    } else {
        build.env-append "DMD=${prefix}/bin/dmd -m32"
    }
} else {
    lappend merger_build_env(x86_64) "DMD=${prefix}/bin/dmd -m64"
    lappend merger_build_env(i386)   "DMD=${prefix}/bin/dmd -m32"
    lappend merger_build_env(ppc64)  "DMD=${prefix}/bin/dmd -m64"
    lappend merger_build_env(ppc)    "DMD=${prefix}/bin/dmd -m32"
}

github.livecheck.regex  {([^"rba]+)}
