# -*- 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 113451 2013-11-16 13:42:15Z takeshi@macports.org $

PortSystem          1.0

name                grads
version             2.0.2
revision            3
set branch          [join [lrange [split ${version} .] 0 1] .]
platforms           darwin
maintainers         takeshi
license             GPL-2
categories          science
description         interactive visualization tool for earth science data
master_sites        ftp://cola.gmu.edu/grads/${branch}/:src \
                    ftp://cola.gmu.edu/grads/:data
set gradssrc        ${name}-${version}-src${extract.suffix}
set gradsdata       data2${extract.suffix}
distfiles           ${gradssrc}:src ${gradsdata}:data
checksums           ${gradssrc} \
                    rmd160  1e15249ad8f77314b3b430038b8fc5f6594e6319 \
                    sha256  7bc777292836b104ff6f9c1793f80e8de48c7adf6e24711edffe023bd09becdd \
                    ${gradsdata} \
                    rmd160 98637dd79e49335e0d986429549fbce2b81afc7a \
                    sha256 55419fe15478d8213031bb1bfa7adec96984379373ec751cbe37d4bb22f6ce18
set url http://www.iges.org/grads/
homepage            ${url}/grads.html
long_description   \
    The Grid Analysis and Display System (GrADS) is an interactive     \
    desktop tool that is used for easy access, manipulation, and       \
    visualization of earth science data. The format of the data may    \
    be either binary, GRIB, NetCDF, or HDF-SDS (Scientific Data Sets). \
    GrADS has been implemented worldwide on a variety of commonly used \
    operating systems and is freely distributed over the Internet.

depends_build       port:gadap
depends_lib         port:readline   \
                    port:netcdf     \
                    port:udunits    \
                    port:hdf4       \
                    port:hdf5-18    \
                    port:gd2        \
                    port:libdap     \
                    port:wgrib2     \
                    port:curl       \
                    port:libgeotiff \
                    port:shapelib   \
                    port:xorg-libXmu
depends_build       port:pkgconfig

patchfiles          patch-configure.diff

configure.env-append    SUPPLIBS="${prefix}"
configure.args          --without-gui   \
                        --with-readline \
                        --with-printim  \
                        --with-grib2    \
                        --with-sdf      \
                        --with-gadap    \
                        --with-shp      \
                        --with-geotiff=${prefix}  \
                        --with-hdf4=${prefix} \
                        --with-hdf5=${prefix} \
                        --with-netcdf=${prefix} \
                        --with-x

test.run            yes
test.target         check

post-destroot {
    xinstall -d -m 755 ${destroot}${prefix}/share/${name}
    eval xinstall -m 644 [glob -directory ${worksrcpath}/data *.dat *res] \
        ${destroot}${prefix}/share/${name}
    xinstall -d -m 755 ${destroot}${prefix}/share/${name}/tables
    eval xinstall -m 644 [glob -directory ${worksrcpath}/data/tables *] \
        ${destroot}${prefix}/share/${name}/tables
}

platform darwin 8 {
    configure.args-delete   --with-dap
    configure.args-append   --without-dap
}

livecheck.type      regex
livecheck.url       ${url}/downloads.html
#livecheck.regex     {The Latest Version of GrADS </span><br>
#            <span class="red">GrADS version ([0-9]+\.[0-9]+\.[0-9]+)}
#livecheck.regex     {GrADS version ([0-9]+\.[0-9]+\.[0-9]+)}
livecheck.regex     {^\s+<span class="red">GrADS version (\d+\.\d+\.\d+)}
