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

github.setup        BIC-MNI libminc 2.5.0 release-
github.tarball_from archive
revision            0

categories          science
maintainers         nomaintainer
# The MINC package itself and most of the associated tools are licensed under a modified BSD license.
license             BSD

description         Library handling the MINC file format
long_description    {*}${description}, which is a highly flexible medical image \
                    file format built on the HDF5 generalized data format. \
                    The format is simple, self-describing, extensible, \
                    portable and N-dimensional, with programming interfaces \
                    for both low-level data access and high-level volume \
                    manipulation. On top of the libraries is a suite of generic \
                    image-file manipulation tools. The format, libraries and \
                    tools are designed for use in a medical-imaging research \
                    environment: they are simple and powerful and make no \
                    attempt to provide a pretty interface to users.

homepage            https://www.bic.mni.mcgill.ca/ServicesSoftware/MINC

checksums           rmd160  3f348dda3f8f237c6528c37b8aa3ecc61f976364 \
                    sha256  57d807e86a353a93024a8849f5e21e2abea4f09f0be934e1f538bdc2b02f8885 \
                    size    823875

depends_lib-append  port:hdf5 \
                    port:libaec \
                    port:netcdf \
                    port:nifticlib \
                    port:zlib

pre-configure {
    # Figure out HDF5's mpi include directory
    set mpl_include_dir ""
    if {![catch {set result [active_variants hdf5 openmpi]}]} {
        if {$result} {
            set mpl_include_dir "-I${prefix}/include/openmpi-mp"
        }
    }
    if {![catch {set result [active_variants hdf5 mpich]}]} {
        if {$result} {
            set mpl_include_dir "-I${prefix}/include/mpich-mp"
        }
    }
    if {$mpl_include_dir ne ""} {
        configure.cflags-append ${mpl_include_dir}
    }
}

patchfiles          patch-cmake.diff

configure.args-append \
                    -DLIBMINC_BUILD_SHARED_LIBS=ON \
                    -DLIBMINC_MINC1_SUPPORT=ON \
                    -DLIBMINC_USE_SYSTEM_NIFTI=ON

post-destroot {
    file mkdir ${destroot}${prefix}/lib/cmake/LIBMINC
    move {*}[glob ${destroot}${prefix}/lib/cmake/*.cmake] ${destroot}${prefix}/lib/cmake/LIBMINC
}
