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

PortSystem          1.0
PortGroup           active_variants 1.1
PortGroup           conflicts_build 1.0

name                hdfeos
version             3.0
categories          science
maintainers         {takeshi @tenomoto}
license             public-domain
description         HDF-EOS library built on HDF4
long_description \
    library designed built on HDF4 to support EOS-specific \
    data structures, namely Grid, Point, and Swath.
homepage            https://git.earthdata.nasa.gov/projects/DAS/repos/${name}
distname            hdf-eos2-${version}
distfiles           ${distname}-src${extract.suffix}
master_sites        ${homepage}/raw/${distfiles}?at=refs%2Fheads%2FHDFEOS2_${version}&dummy=

depends_build       port:libtool
depends_lib         port:hdf4
checksums           rmd160  39f2b934fd05cbdd94465ac7edfa12bc2c72e814 \
                    sha256  3a5564b4d69b541139ff7dfdad948696cf31d9d1a6ea8af290c91a4c0ee37188 \
                    size    752290

patchfiles          patch-configure.diff \
                    implicit.patch

configure.args      --with-hdf4=${prefix} \
                    --with-jpeg=${prefix} \
                    --with-zlib=${prefix} \
                    --without-szlib       \
                    --enable-shared       \
                    --disable-dependency-tracking

conflicts_build     hdfeos

post-configure {
    file copy -force ${prefix}/bin/glibtool ${worksrcpath}/libtool
}

post-destroot {
    xinstall -m 0644 {*}[glob ${worksrcpath}/include/*.h] \
        ${destroot}${prefix}/include
}

if {![catch {set result [active_variants port:hdf4 szip]}]} {
    if {$result} {
        default_variants-append +szip
    }
}
variant szip description {build with szip} {
    require_active_variants hdf4 szip
    depends_lib-append      port:szip
    configure.cc            ${prefix}/bin/h4cc
    configure.args-delete   --without-szlib
    configure.args-append   --with-szlib=${prefix}
}

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