# -*- 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 55498 2009-08-12 08:26:02Z takeshi@macports.org $

PortSystem              1.0

name                    grads2
version                 2.0.a5.oga.5
revision                1
platforms               darwin
maintainers             takeshi
categories              science
description             interactive visualization tool for earth science data
master_sites            sourceforge:opengrads
distname                grads-${version}-bundle
worksrcdir              grads-${version}
checksums               md5    16ea4c90f6e42be18fa49693ddc5d810         \
                        sha1   dcae4bf6744a69a5d7bfa020dc087d5f12fc67ae \
                        rmd160 9fcaf9aadb5488f5597bf80799c68fb3f50104ff
homepage                http://www.opengrads.org/
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_lib             port:libwww     port:readline   port:rx         \
                        port:netcdf     port:udunits                    \
                        port:hdf4       port:gd2        port:libnc-dap  \
                        port:gadap      port:wgrib2                     \
                        port:curl       port:libgeotiff
depends_build           port:pkgconfig

patchfiles              patch-src-Makefile.in.diff

pre-configure {
    reinplace "s|lwww|lwwwcore|g" ${worksrcpath}/configure
}

configure.env-append    SUPPLIBS="${prefix}"
configure.args          --with-readline                             \
                        --enable-dyn-supplibs                       \
                        --with-nc --with-dap                        \
                        --with-netcdf=${prefix}                     \
                        --with-geotiff                              \
                        --with-x --with-printim --without-gui       \
                        --program-suffix="-2"
configure.cppflags      -I${prefix}/include
configure.ldflags       -L${prefix}/lib

pre-build {
    reinplace "s|libwww.a|libwwwcore.a|g" ${worksrcpath}/src/Makefile
    reinplace "s|\$(supp_lib_dir)/inst.o| |g" ${worksrcpath}/src/Makefile
}

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 {
    depends_lib-delete      libnc-dap
    configure.args-delete   --with-dap
    configure.args-append   --without-dap
}
