# -*- 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 67898 2010-05-21 09:18:36Z takeshi@macports.org $

PortSystem              1.0

name                    grads2
version                 2.0.a7.oga.3
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     0cf98ccf59cc81996e3b139ffaf3dfd8 \
                        sha1    d5a6f10578e4d8af75047b211b0af2cce46db6fd \
                        rmd160  7861998b9f9d84c92c6c51eef03e00afc0f9d071
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-delete   -I${prefix}/include
set jpegdir ${prefix}/lib/jpeg6b
configure.cppflags-append   -I${jpegdir}/include -I${prefix}/include
configure.ldflags-delete    -L${prefix}/lib 
configure.ldflags-append    -L${jpegdir}/lib -L${prefix}/lib 

post-configure {
    reinplace "s|^INCLUDES = |INCLUDES = -I${jpegdir}/include |" ${worksrcpath}/src/Makefile
    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
}
