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

name                vapor
version             2.2.4
revision            30
categories          science
maintainers         nomaintainer
description         interactive 3D scientific visualization environment
long_description    VAPOR is the Visualization and Analysis Platform \
                    for Ocean, Atmosphere, and Solar Researchers. \
                    VAPOR provides an interactive 3D visualization environment \
                    that runs on most UNIX and Windows systems \
                    equipped with modern 3D graphics cards.
homepage            http://www.vapor.ucar.edu/
platforms           darwin
master_sites        https://www.vapor.ucar.edu/sites/default/files/
distname            ${name}-${version}-src

checksums           rmd160  a690f7f587f858195db8bdbb6736ccb4f5ba8626 \
                    sha256  e43721801c89dc31766ae9304768670f24bea022690cefdd5cc73684249999af

depends_build       port:gmake

depends_lib         port:assimp2 \
                    port:expat \
                    port:glew \
                    port:hdf5 \
                    port:libgeotiff \
                    port:netcdf \
                    port:proj4 \
                    port:py27-numpy \
                    port:py27-scipy \
                    port:qt4-mac \
                    port:udunits2

patchfiles          patch-options.mk.diff \
                    patch-make-config-Darwin.mk.diff

use_configure       no

post-configure {
    reinplace "s|@@MP_INSTALL_PREFIX@@|${destroot}${prefix}|g" ${worksrcpath}/options.mk
    reinplace "s|@@MP_PREFIX@@|${prefix}|g" ${worksrcpath}/options.mk ${worksrcpath}/make/config/Darwin.mk
    reinplace "s|@@MP_FRAMEWORKS_DIR@@|${frameworks_dir}|g" ${worksrcpath}/options.mk
    reinplace "s|@@MP_CC@@|${configure.cc}|g" ${worksrcpath}/options.mk
    reinplace "s|@@MP_CXX@@|${configure.cxx}|g" ${worksrcpath}/options.mk
    reinplace "s|-F.*/lib|-F${frameworks_dir}|" ${worksrcpath}/apps/vaporgui/Makefile ${worksrcpath}/apps/asciitf2vtf/Makefile
    if {${build_arch} eq "x86_64"} {
        set f [open ${worksrcpath}/site.mk "w"]
        puts $f "MACHTYPE=x86_64"
        close $f
    }
}

use_parallel_build  no

build.cmd           gmake
destroot.cmd        gmake

post-destroot {
    file delete -force ${destroot}${prefix}/share/udunits
}

universal_variant   no

livecheck.type      regex
livecheck.url       ${homepage}
livecheck.regex     "Version (\\d+(?:\\.\\d+)*) of VAPOR"
