# -*- 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.3.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            https://omniorb.sourceforge.io

conflicts_build     ${name}

master_sites        sourceforge:project/omniorb/omniORB/omniORB-${version}/
use_bzip2           yes
checksums           rmd160  b9af3849dd1cc58954514d3ae6ec2a838e9bdb23 \
                    sha256  79720d415d23cd8da99287a4ef4da0aa1bd34d3e4c7b1530715600adc5ed3dc3 \
                    size    2635770

depends_build-append \
                    path:bin/pkg-config:pkgconfig

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 python313 conflicts python314 description {Build Python 3.13 IDL support} {
    configure.python            ${prefix}/bin/python3.13
    set python_framework        ${frameworks_dir}/Python.framework/Versions/3.13/lib
    depends_lib-append          port:python313
    configure.pkg_config_path   ${python_framework}/lib/pkgconfig

    notes "Install py313-omniORBpy for omniORBpy."
}

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

    notes "Install py314-omniORBpy for omniORBpy."
}

if {![variant_isset python313]} {
    default_variants +python314
}

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+)*)"
