# -*- 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 117881 2014-03-16 05:02:06Z takeshi@macports.org $

PortSystem                  1.0
PortGroup                   mpi 1.0
PortGroup                   github 1.0

compilers.choose            cc cpp
mpi.setup

# If hdf5-18 is built without a compiler variant (with /usr/bin/clang),
# cxx is the only variant, which does not exist in netcdf.
# configure fails if mpi.enforce_variant is used.
#mpi.enforce_variant         hdf5-18

github.setup                Unidata netcdf-c 4.3.1.1 v
name                        netcdf
maintainers                 takeshi openmaintainer
platforms                   darwin
categories                  science
license                     Permissive

description                 libraries for array-oriented scientific data
long_description \
    NetCDF (network Common Data Form) is a set of software libraries \
    and machine-independent data formats that support the creation,  \
    access, and sharing of array-oriented scientific data.

homepage                    http://www.unidata.ucar.edu/software/netcdf/

checksums           md5     532c1fb1ca70d329955566dc70ad9fce \
                    sha1    c1ae35193ed312fe5c1ff3d46c27d306fed18f6d \
                    rmd160  0ac2e390697daea60bd1cc1accd021da16c1ea08

patchfiles          patch-configure.diff \
                    patch-daputil.c.diff

configure.cppflags-append   -DNDEBUG
configure.cflags-append     -fno-common
configure.args              --disable-doxygen \
                            --disable-netcdf-4 \
                            --disable-dap

test.run                    yes
test.target                 check

destroot.destdir            prefix=${destroot}${prefix} \
                            MANDIR=\\\${prefix}/share/man

post-destroot {
    file delete -force ${destroot}${prefix}/share/man/whatis.db
}

default_variants +netcdf4 +dap

variant netcdf4 description {enable support for netcdf-4 API} {
    depends_lib-append      port:hdf5-18
    configure.args-delete   --disable-netcdf-4
    configure.args-append   --enable-netcdf-4
}

variant hdf4 description {enable support for hdf4} {
    depends_lib-append    port:hdf4
    configure.args-append --enable-hdf4 \
                          --disable-hdf4-file-tests
}

variant dap description {enable dap} {
    depends_lib-append      port:curl
    configure.args-delete   --disable-dap
}

notes "
As of version 4.2 c++ and fortran interfaces are separate ports,\
netcdf-cxx and netcdf-fortran, respectively.
"
