# -*- 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
# $Id: Portfile 85049 2011-10-08 09:53:47Z takeshi@macports.org $

PortSystem          1.0
name                vapor
version             1.5.2
revision            1
categories          science
maintainers         takeshi
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        ftp://ftp.ucar.edu/vapor/source
distname            ${name}-${version}-src

checksums           md5     615ac60aaf1680689e98dbb14fe6a6d3 \
                    sha1    c023702a99ab4672b26634d178141384e8f3d5c7 \
                    rmd160  2f940dcce85edd5f728ad3472f5737bd8a40cec2

depends_lib         port:expat \
                    port:qt3 \
                    port:netcdf \
                    port:proj \
                    port:libgeotiff \
                    port:hdf5-18

worksrcdir          ${name}-${version}/${name}
patchfiles          patch-base.mk.diff \
                    patch-glew.h.diff
post-patch {
    reinplace "s|dynamic_lookup|dynamic_lookup -install_name ${prefix}/lib/${name}/lib\$(LIBRARY).dylib|" ${worksrcpath}/make/config/Darwin.mk
    reinplace "s|INSTALL_DOC_DIR = \$(INSTALL_SHAREDIR)/doc|INSTALL_DOC_DIR = ${destroot}${prefix}/share/doc/${name}|" ${worksrcpath}/doc/Makefile
}
use_configure       no
post-configure {
    reinplace "s|INSTALL_PREFIX_DIR=/usr/local|INSTALL_PREFIX_DIR=${prefix}|" \
        ${worksrcpath}/options.mk
    reinplace "s|RELEASE=0|RELEASE=1|" ${worksrcpath}/options.mk
    reinplace "s|_INC_PATH=|_INC_PATH=${prefix}/include|" ${worksrcpath}/options.mk
    reinplace "s|_LIB_PATH=|_LIB_PATH=${prefix}/lib|" ${worksrcpath}/options.mk
    reinplace "s|QTDIR =|QTDIR =${prefix}/lib/qt3|" ${worksrcpath}/options.mk
    reinplace "s|QT_LIB_PATH = |QT_LIB_PATH=${prefix}/lib/qt3/lib|" ${worksrcpath}/options.mk
    reinplace "s|BUILD_AMR_SUPPORT = 0|BUILD_AMR_SUPPORT = 1|" ${worksrcpath}/options.mk
    if {${build_arch}=="x86_64"} {
        set f [open ${worksrcpath}/site.mk "w"]
        puts $f "MACHTYPE=x86_64"
        close $f
    }
}
use_parallel_build  no

livecheck.type              regex
livecheck.url               ${homepage}/downloads/index.php?id=source
livecheck.regex             {Latest Release: ([0-9]+\.[0-9]+\.[0-9]+)}
