# -*- 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           cmake 1.1
PortGroup           github 1.0
PortGroup           mpi 1.0

github.setup        geospace-code h5fortran 4.11.0 v
revision            0
categories          fortran science
license             BSD
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
description         Object-oriented Fortran HDF5 interface
long_description    {*}${description}
checksums           rmd160  e9d8a41860026a4c408df5a90e3ef54b40762620 \
                    sha256  4bbda0631973ea52280228c82b1da6690dedcda3f65654dcc895c8c7db54de08 \
                    size    93712
github.tarball_from archive

compilers.choose    cc fc f90
mpi.setup           require_fortran -gcc44 -gcc45 -gcc46 -gcc47 -gcc48 -gcc49 -gcc5 -gcc6 -g95

# Clang of 10.7 fails to build it.
# https://github.com/macports/macports-ports/commit/772f5cb003aafac822a866132a775e93253ee683
compiler.blacklist-append \
                    {*gcc-[34].*} {macports-gcc-[56]} {clang < 500}

set python.branch   3.13
set python.version  [join [split ${python.branch} "."] ""]

depends_build-append \
                    path:bin/pkg-config:pkgconfig \
                    port:python${python.version}

depends_lib-append  port:hdf5 \
                    port:szip \
                    port:zlib

patchfiles-append   patch-fix-install-dirs.diff

configure.args-append \
                    -DBUILD_SHARED_LIBS=ON \
                    -Dh5fortran_BUILD_TESTING=ON \
                    -DHDF5_HAVE_PARALLEL=OFF \
                    -DPYTHON_EXECUTABLE=${prefix}/bin/python${python.branch}

if {[variant_isset mpich] || [variant_isset openmpi]} {
    require_active_variants \
                    port:hdf5 [list fortran mpich]

    configure.args-replace \
                    -DHDF5_HAVE_PARALLEL=OFF -DHDF5_HAVE_PARALLEL=ON
} else {
    require_active_variants \
                    port:hdf5 fortran
}

# Some tests fail on PowerPC: https://github.com/geospace-code/h5fortran/issues/41
test.run            yes
test.cmd            ctest
