# -*- 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 103131 2013-02-15 21:07:27Z takeshi@macports.org $

PortSystem          1.0
PortGroup           active_variants 1.1

name                hdfeos5
version             1.14
revision            3
categories          science
platforms           darwin
license             public-domain
maintainers         takeshi
description         HDF-EOS library built on HDF5
long_description \
    library designed built on HDF5 to support the same Grid/Point/Swath \
    functionality in HDF-EOS 2 and to the extent possible it will be    \
    built with the same calling sequences as the original HDF-EOS 2 library.
homepage            http://hdfeos.org/
master_sites        ftp://edhs1.gsfc.nasa.gov/edhs/${name}/latest_release/ \
                    ftp://edhs1.gsfc.nasa.gov/edhs/${name}/previous_releases/

distname            HDF-EOS5.${version}

checksums           md5     4a332f9bb4401103d484a1e9184e8972 \
                    sha1    e27d276dd1bef5eab77a42d2c9fa26b98026f75d \
                    rmd160  b9ff8e7a81d6738256884cb5b11914ab7c8d6449

depends_build       port:libtool
depends_lib         port:hdf5-18
worksrcdir          ${name}
extract.suffix      .tar.Z
fetch.use_epsv      no

configure.cc        ${prefix}/bin/h5cc
configure.cflags-append -DH5_USE_16_API
configure.cc_archflags ""
configure.ld_archflags ""
configure.args      --prefix=${prefix}/lib/${name} \
                    --enable-shared \
                    --with-hdf5=${prefix} \
                    --with-zlib=${prefix} \
                    --disable-dependency-tracking

post-configure {
    file copy -force ${prefix}/bin/glibtool ${worksrcpath}/libtool
    reinplace "s|\\\\\$CC|${prefix}/bin/h5cc|" ${worksrcpath}/libtool
}

variant szip description {enables szip support} {
    require_active_variants     hdf5-18 szip
    depends_lib-append          port:szip
    configure.args-append       --with-szlib=${prefix} \
}

post-destroot {
    set incdir ${destroot}${prefix}/lib/${name}/include
    xinstall -d -m 755 ${incdir}
    xinstall -m 644 ${worksrcpath}/include/HE5_GctpFunc.h ${incdir}
    xinstall -m 644 ${worksrcpath}/include/HE5_HdfEosDef.h ${incdir}
}

livecheck.type      regex
livecheck.url       ${homepage}/software/hdfeos.php
livecheck.regex     {HDF-EOS 5.([0-9]+.[0-9]+) is the latest version}
