# -*- 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.0
PortGroup           mpi 1.0

name                superlu_dist
version             5.3.0
revision            0
categories          math
license             BSD
platforms           darwin
maintainers         {sean @seanfarley} openmaintainer
description         A package for solving linear equations
long_description    SuperLU is a general purpose library for the direct \
                    solution of large, sparse, nonsymmetric systems of \
                    linear equations on high performance machines.

homepage            http://crd-legacy.lbl.gov/~xiaoye/SuperLU
master_sites        ${homepage}

distname            ${name}_${version}
worksrcdir          SuperLU_DIST_${version}

checksums           rmd160  5f2c22bf848040c94dfb6558a08d73308df1a90e \
                    sha256  de40808a7916f2ef002e0c1c17d24b556b5ef7af9478541a0faacd1d318c4549

compilers.choose    cc cxx
mpi.setup           require

depends_lib         port:parmetis \
                    port:superlu \
                    port:SuiteSparse

configure.cflags    -Os -mtune=native

post-patch {
    reinplace "s|^enable_language.*Fortran.*||" ${worksrcpath}/CMakeLists.txt
    reinplace "s|^set(NOFORTRAN FALSE)$|set(NOFORTRAN TRUE)|" ${worksrcpath}/CMakeLists.txt
}

configure.args-append \
                    -DTPL_BLAS_LIBRARIES="-framework Accelerate" \
                    -DTPL_PARMETIS_INCLUDE_DIRS=${prefix}/include \
                    -DTPL_PARMETIS_LIBRARIES="${prefix}/lib/libparmetis.dylib\;${prefix}/lib/libmetis.dylib" \
                    -Denable_tests=OFF \
                    -DUSE_XSDK_DEFAULTS=ON \
                    -DXSDK_ENABLE_Fortran=OFF

post-destroot {
    # these are the same files as installed by superlu, so we'll just depend on
    # superlu for now
    delete ${destroot}${prefix}/include/superlu_enum_consts.h
    delete ${destroot}${prefix}/include/supermatrix.h

    # installed by suitesparse
    delete ${destroot}${prefix}/include/colamd.h
}

variant longindex description {Build with 64 ints} {
    configure.cflags-append     -DXSDK_INDEX_SIZE=64
}

livecheck.type      none