# -*- 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           compilers 1.0
PortGroup           conflicts_build 1.0
PortGroup           github 1.0
PortGroup           legacysupport 1.1

# clock_gettime
legacysupport.newest_darwin_requires_legacy 15

github.setup        NLAFET StarNEig a9da7bb880e32c4fed83599c393f63942465d71a
version             2023.01.15
categories          math
license             BSD
maintainers         {@barracuda156 macos-powerpc.org:barracuda} openmaintainer
description         Task-based library for solving dense non-symmetric eigenvalue problems
long_description    StarNEig library aims to provide a complete task-based software stack \
                    for solving dense non-symmetric (generalized) Eigenvalue problems. \
                    The library is built on top of the StarPU runtime system and targets \
                    both shared memory and distributed memory machines. Some components \
                    of the library support GPUs.
homepage            https://nlafet.github.io/StarNEig
checksums           rmd160  99353668911304a7f9dc0570e941d211c89e882d \
                    sha256  d07753bd874ab5cc2cd51d2d533e621fea48f35b3407ceaf13886e5212140bf9 \
                    size    510862
github.tarball_from archive

depends_build-append \
                    path:bin/pkg-config:pkgconfig
depends_lib-append  port:hwloc \
                    port:starpu13

# https://github.com/NLAFET/StarNEig/issues/5
conflicts_build     lfortran

compiler.openmp_version 4.0
compiler.c_standard 1999
compilers.choose    fc f90 f77 cc

patch.pre_args      -p1
patchfiles-append   0001-Use-cblas_openblas.h.patch

pre-configure {
    configure.args-append \
                    -DBLA_VENDOR=OpenBLAS
}

# Please update this when starpu is updated:
set starpu_ver      1.3

configure.args-append \
                    -DSTARPU_INCLUDE_PATH=${prefix}/libexec/starpu13/include/starpu/${starpu_ver} \
                    -DSTARPU_LIBRARIES=${prefix}/libexec/starpu13/lib/libstarpu-${starpu_ver}.dylib \
                    -DSTARPU_MPI_LIBRARIES=${prefix}/libexec/starpu13/lib/libstarpumpi-${starpu_ver}.dylib \
                    -DSTARPU_USE_MPI=OFF \
                    -DSTARNEIG_ENABLE_TESTS=ON \
                    -DSTARNEIG_ENABLE_DOCS=OFF \
                    -DSTARNEIG_ENABLE_EVENT_PARSER=OFF \
                    -DSTARNEIG_ENABLE_EXAMPLES=OFF \
                    -DSTARNEIG_ENABLE_OPTIMIZATION=ON \
                    -DSTARNEIG_DISABLE_MPI=ON \
                    -DSTARNEIG_DISABLE_CUDA=ON \
                    -DSTARNEIG_DISABLE_BLACS=ON \
                    -DSTARNEIG_ENABLE_EVENTS=OFF \
                    -DSTARNEIG_ENABLE_SANITY_CHECKS=OFF \
                    -DSTARNEIG_ENABLE_PRUNING=OFF \
                    -DSTARNEIG_ENABLE_MRM=OFF \
                    -DSTARNEIG_ENABLE_CUDA_REORDER_WINDOW=OFF \
                    -DSTARNEIG_ENABLE_INTEGER_SCALING=OFF \
                    -DSTARNEIG_ENABLE_FULL_TESTS=ON \
                    -DSTARNEIG_ENABLE_REFERENCE=ON \
                    -DSTARNEIG_ENABLE_VERBOSE=ON

depends_test-append port:gsl \
                    path:bin/pkg-config:pkgconfig

# FIXME: https://github.com/NLAFET/StarNEig/issues/4
test.run            yes
test.cmd            ctest
test.target         test

# Drop once someone finally removes this from cmake PG:
configure.pre_args-replace \
                    -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON \
                    -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF

platform darwin powerpc {
    test.post_args  --cores=1
}
