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

name                omniORB
version             4.2.4
categories          devel
universal_variant   no
# executables are GPL, libs are LGPL
license             {LGPL GPL-2+}
maintainers         nomaintainer

description         high performance CORBA ORB for C++
long_description    omniORB is a robust high performance CORBA ORB for C++ and \
                    Python. omniORB is largely CORBA 2.6 compliant.
homepage            http://omniorb.sourceforge.net/

conflicts_build     ${name}

master_sites        sourceforge:project/omniorb/omniORB/omniORB-${version}/
use_bzip2           yes
checksums           rmd160  bc955f62f794f7c5bea8d74e15e0f6621dbd6c86 \
                    sha256  28c01cd0df76c1e81524ca369dc9e6e75f57dc70f30688c99c67926e4bdc7a6f \
                    size    2713397

patchfiles          patch-configure.diff \
                    src_tool_omniidl_cxx_cccp_config-darwin.h.diff
post-patch {
    reinplace "s|\\(\$(CXXLINKOPTIONS)\\)|\\1 [get_canonical_archflags cxx]|g" \
        ${worksrcpath}/mk/beforeauto.mk.in
}

configure.args      CC="${configure.cc}" \
                    CXX="${configure.cxx}" \
                    CCFLAGS="[get_canonical_archflags cc]" \
                    EXTRA_GCC_CXXFLAGS="[get_canonical_archflags cxx]" \
                    --with-omniORB-config="${prefix}/etc/omniORB.cfg" \
                    --with-omniNames-logdir="${prefix}/var"

if {${build_arch} eq "x86_64" && ${os.platform} eq "darwin"} {
    configure.args-append --build=${build_arch}-apple-${os.platform}${os.version}
}

# force a global variable
set python_framework []

variant python39 conflicts description {Build Python 3.9 IDL support} {
    configure.python            ${prefix}/bin/python3.9
    set python_framework        ${frameworks_dir}/Python.framework/Versions/3.9/lib
    depends_lib-append          port:python39
    configure.pkg_config_path   ${python_framework}/lib/pkgconfig

    notes "Install py39-omniORBpy for omniORBpy."
}

if {![variant_isset python38]} {
    default_variants +python39
}

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

post-destroot {
    # omniORB for python3x installs into /opt/local/lib/python3.x/site-packages/
    # but omniORBpy installs into /opt/local/Library/Frameworks/Python.framework/Versions/X.Y/
    # so adjust locations for this package
    file mkdir [file normalize ${destroot}${python_framework}]
    file rename [glob ${destroot}${prefix}/lib/python*] ${destroot}${python_framework}
}

livecheck.type      regex
livecheck.url       http://omniorb.sourceforge.net/
livecheck.regex     "${name}-(\\d+(?:\\.\\d+)*)"
