# -*- 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           python 1.0
PortGroup           active_variants 1.1

name                py-omniORBpy
version             4.3.4
revision            0

categories-append   devel
license             LGPL-2.1
supported_archs     i386 x86_64
maintainers         nomaintainer

description         Python bindings for omniORB
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.net/
master_sites        sourceforge:project/omniorb/omniORBpy/omniORBpy-${version}

distname            omniORBpy-${version}

checksums           rmd160  dd442450103c87fc47232b47a46d0181d9ea4f04 \
                    sha256  a709c3c77b9c6b08616e1c9e12a5a9b9d5ccc1f2dcf6f647f205018d77f819a7 \
                    size    761815

use_bzip2           yes

python.versions     313 314
# Use the python subports feature but omniORBpy uses make
# rather than setup.py for building since there are compiled libraries.
# So the build procedure must unravel the python PortGroup settings
# and revert to values compatible with a make environment.
# Ugly but it works.

if {${name} ne ${subport}} {
    depends_build-append \
                    path:bin/pkg-config:pkgconfig

    depends_lib-append \
                    port:omniORB

    # omniORB is not universal
    universal_variant   no

    require_active_variants omniORB python${python.version}

    post-patch {
        # python libraries (PYTHON_PREFIX)
        reinplace "s|get_python_lib(0,\[^)\]*)|get_python_lib()|g" \
            ${worksrcpath}/configure
        # compiled libraries to support python (PYTHON_EXEC_PREFIX)
        reinplace "s|get_python_lib(1,\[^)\]*)|get_python_lib()|g" \
            ${worksrcpath}/configure
    }

    use_configure       yes
    configure.python    ${python.bin}

    build.type          gnu
    build.cmd           make
    build.target        all
    build.args          {}

    destroot.cmd        ${build.cmd}
    destroot.target     install
    destroot.args       {}
    destroot.destdir    DESTDIR=${destroot}

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

    post-destroot {
        # create a directory under /opt/local/Library/Frameworks/Python.framework/
        file mkdir ${destroot}${python.pkgd}
        # remove only the lowest-level directory to allow a directory copy...
        file delete ${destroot}${python.pkgd}
        file rename [glob ${destroot}${prefix}/lib/python*/site-packages] ${destroot}${python.pkgd}
        # omniORB already installs an empty __init__.py
        file delete [glob ${destroot}${python.pkgd}/omniidl_be/__init__.py]
        file delete [glob ${destroot}${python.pkgd}/omniidl_be/__pycache__/__init__*.pyc]
    }

    livecheck.type      none
} else {
    livecheck.type      regex
    livecheck.url       http://sourceforge.net/projects/omniorb/files/omniORBpy/
    livecheck.regex     "/omniorb/files/omniORBpy/omniORBpy-(\\d+\\.\\d+(?:\\.\\d+)*)/"
}
