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

name                    opendx
version                 4.4.4
revision                14
categories              science
license                 Permissive
# "IBM PUBLIC LICENSE", http://opendx.org/dlSource.html
maintainers             nomaintainer

description             IBM's Open Visualization Data Explorer
long_description        OpenDX is a uniquely powerful, full-featured software   \
                        package for the visualization of scientific,        \
                        engineering and analytical data: Its open system design \
                        is built on familiar standard interface environments.   \
                        And its sophisticated data model provides users with    \
                        great flexibility in creating visualizations.

#homepage                http://opendx.org/
#master_sites            http://opendx.informatics.jax.org/source/
homepage                http://web.archive.org/web/20180102225501/http://www.opendx.org/
master_sites            macports_distfiles

deprecated.upstream_support \
                        no

checksums               rmd160  db4cff78c9712a6e1e19265b0f42fdb87ab5ff7b \
                        sha256  a9915e17d49c5499edd3df69ffeac0b7ba24f8b38ddf7509712b48eb3c21f1ff \
                        size    9676049

distname                dx-${version}

installs_libs           no

depends_lib             port:ImageMagick \
                        port:cdf \
                        port:hdf4 \
                        port:libGLU \
                        port:mesa \
                        port:netcdf \
                        lib:libXm:motif \
                        port:tiff \
                        port:xorg-libX11 \
                        port:xorg-libXext \
                        port:xorg-libXinerama \
                        port:xorg-libXmu \
                        port:xorg-libXp \
                        port:xorg-libXt \
                        port:xorg-libice \
                        port:xorg-libsm \
                        port:xpm

# cdf is not universal
universal_variant       no

patchfiles              configure.ac.diff \
                        patch-src-exec-dpexec-packet.c.diff \
                        patch-src-exec-dxmods-local.mk.in.diff \
                        main.diff \
                        patch-src-uipp-java-Makefile.am.diff \
                        patch-imagemagick.diff \
                        implicit.patch \
                        client-gethostbyname.diff

# see https://trac.macports.org/ticket/56716
# fix missing -c flag
# see https://trac.macports.org/ticket/35538
# see https://trac.macports.org/ticket/39098
patchfiles-append       patch-no_macos.diff \
                        patch-compile.diff \
                        patch-correct_compiler.diff \
                        patch-destroot.diff \
                        patch-compiler_compat_2024.diff

use_autoreconf          yes
autoreconf.args         -fvi

# see https://trac.macports.org/ticket/24280
configure.pre_args-replace \
                        --prefix=${prefix} \
                        --prefix=${prefix}/libexec/${name}

configure.args-append   --without-javadx

# ignore implicitly declared functions to allow compilation with modern
# compilers
configure.cflags-append -Wno-error=implicit-function-declaration

post-destroot {
    foreach bin [glob -tails -directory ${destroot}${prefix}/libexec/${name}/bin *] {
        ln -s ${prefix}/libexec/${name}/bin/${bin} ${destroot}${prefix}/bin/${bin}
    }
}

if {${os.platform} eq "darwin" && ${os.major} >= 9} {
    configure.cppflags-append -D_UINT64 -D_UINT32 -D_UINT16 -D_UINT8
}

variant java description "enable java support" {
    depends_lib-append      port:cosmoplayer \
                            port:opendx-java40
    configure.args-delete   --without-javadx
    configure.args-append   --with-jni-path=/System/Library/Frameworks/JavaVM.framework/Headers \
                            --with-java40jar-path=${prefix}/share/java/java40.jar   \
                            --with-cosmojar-path=${prefix}/share/java/npcosmop211.jar
    #
    # The configure.env variables are to make sure we use Apple's preinstalled
    # java; the kaffe port will not work to build JavaDX.
    #
    configure.javac         /usr/bin/javac
    configure.env-append    JAVA_HOME=/Library/Java/Home \
                            JAVA=/usr/bin/java \
                            JAVAH=/usr/bin/javah \
                            JAVAP=/usr/bin/javap
}

default_variants        +java

post-destroot {
    set fixers [ exec find ${destroot}${prefix} -type f | xargs grep -l /usr/lpp ]
    foreach fil ${fixers} {
        reinplace -locale C "s|/usr/lpp|${prefix}|g" ${fil}
    }
}

livecheck.type          none
