# -*- 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 115709 2014-01-09 16:10:16Z eborisch@macports.org $

PortSystem              1.0

name                    ncview
version                 2.1.1
revision                4
maintainers             nomaintainer
platforms               darwin
categories              science
license                 GPL-3

description             X windows point'n'click NetCDF viewer.
long_description        Ncview is a visual browser for NetCDF format \
                        files. Typically you would use ncview to get \
                        a quick and easy, push-button look at your \
                        NetCDF files. You can view simple movies of \
                        the data, view along various dimensions, take \
                        a look at the actual data values, change color \
                        maps, invert the data, etc.

homepage                http://meteora.ucsd.edu/~pierce/ncview_home_page.html

master_sites            ftp://cirrus.ucsd.edu/pub/ncview/

checksums               rmd160  6308916cb309e2f2f809b4d4b47ad89263714885 \
                        sha256  8aaf98fad15790313739520b88e17748617be504f0a2b0322a62144e390db1dd

patchfiles              patch-configure.diff

depends_lib             port:expat \
                        port:hdf5-18 \
                        port:libpng \
                        port:netcdf \
                        port:udunits2 \
                        port:xorg-libXaw port:xorg-libXt port:xorg-libice

pre-configure {
    set nc4 [exec ${prefix}/bin/nc-config --has-nc4]
    if {${nc4} != "yes"} {
        ui_error "Install netcdf +netcdf4 first. Run:"
        ui_error "    port install netcdf +netcdf4"
        return -code error "netcdf +netcdf4 not installed"
    }
}

configure.args          --with-netcdf_incdir=${prefix}/include \
                        --with-netcdf_libdir=${prefix}/lib \
                        --with-bindir=${prefix}/bin \
                        --with-udunits2_incdir=${prefix}/include/udunits2 \
                        --with-udunits2_libdir=${prefix}/lib \
                        --with-png_incdir=${prefix}/include \
                        --with-png_libdir=${prefix}/lib \
                        --with-x

use_parallel_build      yes

post-destroot {
    xinstall -m 755 -d ${destroot}${prefix}/lib/${name}
    xinstall -m 755 -W ${worksrcpath} 3gauss.ncmap 3saw.ncmap bw.ncmap default.ncmap detail.ncmap hotres.ncmap ${destroot}${prefix}/lib/${name}
    
    xinstall -m 755 ${worksrcpath}/data/ncview.1 ${destroot}${prefix}/share/man/man1
    
    set docdir ${prefix}/share/doc/${subport}
    xinstall -m 755 -d ${destroot}${docdir}
    xinstall -m 755 -W ${worksrcpath} README ${destroot}${docdir}
}

livecheck.type              regex
livecheck.url               ${homepage}
livecheck.regex             {New version \(([^)]+)\)}
