# -*- 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$

PortSystem          1.0
PortGroup           compilers 1.0
PortGroup           github 1.0

github.setup        nco nco 4.6.0
platforms           darwin
maintainers         takeshi
license             GPL-3
categories          science
description         The netCDF Operators

compilers.choose    cc cxx
compilers.setup     -clang -dragonegg -llvm

checksums           rmd160  1c18006a38b45cd9804c1f5e15fd7a10598cdec4 \
                    sha256  ad03fe602f3e890c1bae113b169d0e5a3c5249e7b3e8d14e6947a3538e6d4ce9

homepage            http://nco.sourceforge.net/
long_description \
    Each NCO operator (e.g., ncks) takes netCDF or HDF input file(s), \
    performs an operation (e.g., averaging, hyperslabbing, or renaming), \
    and outputs a processed netCDF file. Although most users of netCDF \
    and HDF data are involved in scientific research, these data formats, \
    and thus NCO, are generic and are equally useful in fields like finance. \
    This version is OPeNDAP/DODS enabled, so it can be given \
    URLs to read remote datasets as if they were local netCDF files.

depends_lib         port:curl \
                    port:gettext \
                    port:libiconv \
                    port:libxml2 \
                    port:netcdf \
                    path:lib/libssl.dylib:openssl \
                    port:udunits2 \
                    port:zlib \
                    port:gsl \
                    port:hdf5 \
                    port:xercesc3
depends_build       port:antlr \
                    port:bison \
                    port:m4 \
                    port:texinfo
depends_run         port:wget

patchfiles-append    nawk.patch

configure.env       HAVE_ANTLR=yes ANTLR_ROOT=${prefix} \
                    PATH_TO_NCGEN=${prefix}/bin/ncgen
configure.cppflags-append   -I/usr/include/malloc \
                            -I${prefix}/include/udunits2 \
                            -I${prefix}/include \
                            -DENABLE_NETCDF4
configure.ldflags-append    -lxerces-c
configure.args      --disable-dependency-tracking \
                    --mandir=${prefix}/share/man  \
                    --enable-udunits2             \
                    --enable-dap                  \
                    --enable-netcdf4              \
                    --disable-esmf                \
                    --disable-openmp

if [gcc_variant_isset] {
    configure.args-delete   --disable-openmp
    configure.args-append   --enable-openmp --disable-ncoxx
}

if {[variant_isset atlas]} {
    configure.ldflags-append    -lsatlas
} else {
    default_variants-append     +accelerate
    configure.ldflags-append    -lvecLibFort
}

post-destroot {
    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    foreach f {ANNOUNCE ChangeLog LICENSE NEWS README TODO VERSION *.txt *.pdf} {
        eval xinstall -m 644 [glob ${worksrcpath}/doc/${f}] \
            ${destroot}${prefix}/share/doc/${name}
    }
}

variant mpich description {enable MPI with mpich (currently MPI is not supported)} {
}

variant openmpi description {enable MPI with openmpi (currently MPI is not supported)} {
}

variant accelerate conflicts atlas description {use Accelerate framework for LAPACK} {
    depends_lib-append  port:vecLibFort
}

variant atlas conflicts accelerate description {use Atlas for LAPACK} {
    depends_lib-append  port:atlas
}