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

github.setup        DOCGroup ACE_TAO 8_0_0 ACE+TAO-
github.tarball_from releases

name                ace
set name_package    ACE
version             [string map {_ .} ${github.version}]
revision            0
distname            ${name_package}-${version}
categories          devel
maintainers         {gmail.com:tlockhart1976 @lockhart} {remedy.nl:jwillemsen @jwillemsen} openmaintainer
license             BSD
description         ACE is an object-oriented framework that implements many core patterns for \
                    concurrent communication software.
long_description    The ADAPTIVE Communication Environment (ACE) is a freely available, \
                    open-source object-oriented (OO) framework that implements many core \
                    patterns for concurrent communication software. ACE provides a rich set \
                    of reusable C++ wrapper facades and framework components that perform \
                    common communication software tasks across a range of OS platforms. The \
                    communication software tasks provided by ACE include event \
                    demultiplexing and event handler dispatching, signal handling, service \
                    initialization, interprocess communication, shared memory management, \
                    message routing, dynamic (re)configuration of distributed services, \
                    concurrent execution and synchronization.

conflicts           tao

homepage            https://www.dre.vanderbilt.edu/~schmidt/ACE.html

universal_variant   yes

use_bzip2           yes

worksrcdir          ACE_wrappers

patchfiles          patch-ace-config.h.diff \
                    patch-ace-config-macosx.h.diff \
                    patch-include-makeinclude-platform_macros.GNU.diff \
                    patch-archflags.diff

checksums           rmd160  2c08cc91ef7dbdbd1cfbfc09d75f4c830ec3f9c2 \
                    sha256  d812d6007013e955ce83b905094db614e5ea2729e507ff79d24d1f9ae85d9ab9 \
                    size    8417817

# omit examples and test programs to cut build time by 60%
set subdirs         { ace ACEXML ASNMP Kokyu apps netsvcs }

post-patch {
    reinplace "s|@@CFLAGS@@|[get_canonical_archflags cc]|" \
        ${worksrcpath}/include/makeinclude/platform_macosx_common.GNU
    set stdlib_flag [expr {[string match *-stdlib=* ${configure.cxxflags}] ? " -stdlib=${configure.cxx_stdlib}" : ""}]
    reinplace "s|@@LDFLAGS@@|[get_canonical_archflags ld]${stdlib_flag}|" \
        ${worksrcpath}/include/makeinclude/platform_macosx_common.GNU
    reinplace "s|@@CXXFLAGS@@|[get_canonical_archflags cxx]${stdlib_flag}|" \
        ${worksrcpath}/include/makeinclude/platform_macosx_common.GNU
}

depends_lib-append  path:bin/perl:perl5

variant ssl description {Enable SSL} {
    depends_lib-append path:lib/libssl.dylib:openssl

    post-patch {
        reinplace "s|ssl=0|ssl=1|g" \
            ${worksrcpath}/include/makeinclude/platform_macros.GNU
    }
}

use_configure       no

use_parallel_build  no

compiler.cxx_standard \
                    2017

build.env           DYLD_LIBRARY_PATH=${worksrcpath}/lib \
                    ACE_ROOT=${worksrcpath}
build.args          CC=${configure.cc} \
                    CXX=${configure.cxx} \
                    CPP=${configure.cpp} \
                    INSTALL_PREFIX=${prefix}
build {
    foreach {subdir} $subdirs {
        build.dir ${worksrcpath}/${subdir}
        command_exec build
    }
}

destroot.env        {*}${build.env}
destroot.args       {*}${build.args}
destroot {
    foreach {subdir} $subdirs {
        destroot.dir ${worksrcpath}/${subdir}
        command_exec destroot
    }
}
