# -*- 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        LLNL RAJA 2024.07.0 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
name                raja
revision            0
categories          devel
license             BSD
maintainers         nomaintainer
description         RAJA Performance Portability Layer (C++)
long_description    RAJA is a library of C++ software abstractions, primarily developed \
                    at Lawrence Livermore National Laboratory (LLNL), that enables architecture \
                    and programming model portability for HPC applications.

fetch.type          git

if {${os.platform} eq "darwin" && ${os.major} < 14} {
    # Lion+ (with Xcode 4.1+) have git; earlier need to bring their own.
    # However Lion through Mavericks fail with SSL errors.
    depends_build-append \
                    path:bin/git:git
    git.cmd         ${prefix}/bin/git
}

set py_ver          3.12
set py_ver_nodot    [string map {. {}} ${py_ver}]
depends_build-append \
                    path:bin/pkg-config:pkgconfig \
                    port:python${py_ver_nodot}

if {${os.platform} eq "darwin" && ${os.arch} eq "powerpc"} {
    mpi.setup       require require_fortran \
                    -gcc44 -gcc45 -gcc46 -gcc47 -gcc48 -gcc49 -gcc5 -gcc6 \
                    -clang -fortran
} else {
    mpi.setup       require require_fortran \
                    -gcc44 -gcc45 -gcc46 -gcc47 -gcc48 -gcc49 -gcc5 -gcc6 \
                    -clang18
}

post-fetch {
    system -W ${worksrcpath} "git submodule update --init"
}

# https://trac.macports.org/ticket/70176
compiler.blacklist-append \
                    {macports-clang-1[8-9]}
compiler.cxx_standard   2014
compiler.openmp_version 4.0

# Dynamic lib disabled for a reason: https://github.com/LLNL/RAJA/issues/1431
# Tests also fail to build with similar linking errors.
# OneTBB not yet supported: https://github.com/LLNL/RAJA/issues/1456
configure.args-append \
                    -DBUILD_SHARED_LIBS=OFF \
                    -DENABLE_FORTRAN=ON \
                    -DENABLE_FRUIT=ON \
                    -DENABLE_FRUIT_MPI=ON \
                    -DENABLE_GIT=ON \
                    -DENABLE_MPI=ON \
                    -DENABLE_OPENMP=ON \
                    -DPython_EXECUTABLE=${prefix}/bin/python${py_ver} \
                    -DRAJA_ENABLE_BENCHMARKS=OFF \
                    -DRAJA_ENABLE_CUDA=OFF \
                    -DRAJA_ENABLE_DESUL_ATOMICS=OFF \
                    -DRAJA_ENABLE_DOCUMENTATION=OFF \
                    -DRAJA_ENABLE_EXAMPLES=OFF \
                    -DRAJA_ENABLE_EXERCISES=OFF \
                    -DRAJA_ENABLE_HIP=OFF \
                    -DRAJA_ENABLE_REPRODUCERS=ON \
                    -DRAJA_ENABLE_TBB=OFF \
                    -DRAJA_ENABLE_TESTS=OFF \
                    -DRAJA_ENABLE_VECTORIZATION=OFF

if {[string match *clang* ${configure.compiler}]} {
    configure.ldflags-append \
                    -L${prefix}/lib/libomp \
                    -lomp
}

# Desul Atomics headers conflict with Kokkos installation of the same.
# And it is super-stubborn: deleting in post-destroot has no effect, it still creeps in.
patchfiles-append   patch-throw-away-desul.diff
