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

name                omnicompiler
version             1.3.1
revision            1
categories          lang devel parallel
maintainers         {takeshi @tenomoto} openmaintainer
description         code transformation compilers for C, Fortran and OpenACC
license             LGPL-2.1
long_description \
    Omni compiler is a collection of programs and libraries \
    that allow users to build code transformation compilers. \
    Omni Compiler is to translate C and Fortran programs \
    with XcalableMP and/or OpenACC directives into parallel code \
    suitable for compiling with a native compiler \
    linked with the Omni Compiler runtime library.
homepage            http://omni-compiler.org
# Following error occurs on i386 systems
# In file included from ompc_thread.c:31:0:
# ompclib.h:209:14: error: size of array '_padding' is too large
#         char _padding[CACHE_LINE_SIZE-sizeof(int)-sizeof(any_type)];
#              ^
supported_archs     x86_64
master_sites        ${homepage}/download/stable/

checksums           rmd160  011ff2882665523b7b690280c9f1617d0270847f \
                    sha256  9fee60855a2c25a63168923be468fc9598e200897dfffec61494de6d38f001bd \
                    size    3106504
use_bzip2           yes

compilers.choose    cc fc
mpi.setup           require -clang -g95 -gfortran
if {[variant_isset coarray]} {
    mpi.enforce_variant GASNet
}

depends_build       port:apache-ant \
                    port:bison \
                    port:flex \
                    path:libexec/coreutils/libstdbuf.so:coreutils \
                    bin:base64:base64
depends_lib         port:gmp \
                    port:libxml2 \
                    port:uchardet \
                    port:vecLibFort

patchfiles          patch-xcodeml-tools-F-FrontEnd-src-Makefile.in.diff

if {![gcc_variant_isset]} {
    default_variants-append +gcc7
}
set mpi [mpi_variant_name]
set cmp [gcc_variant_name]
if {${cmp} == ""} {
    set cmp mp
}

pre-configure {
    configure.env   MPI_CC=${configure.cc} \
                    MPI_FC=${configure.fc}
}
configure.args-append \
                    --prefix=${prefix}/lib/${name} \
                    --disable-dependency-tracking \
                    --disable-xmpgpu \
                    --with-libblas=${prefix}/lib/libvecLibFort.dylib \
                    --with-cppflag=${configure.cppflags} \
                    --with-backend-cc=${prefix}/bin/mpicc-${mpi}-${cmp} \
                    --with-backend-cflag=${configure.cflags} \
                    --with-backend-fc=${prefix}/bin/mpif90-${mpi}-${cmp} \
                    --with-gmp-lib=${prefix}/lib \
                    --with-gmp-include=${prefix}/include \
                    --with-libxml=${prefix} \
                    --enable-gnu-extension \
                    --enable-uchardet \
                    --with-uchardet=${prefix}

variant coarray description {enable support for Coarray} {
    depends_build-append    port:GASNet
    configure.args-append   --with-gasnet=${prefix} \
                            --with-gasnet-conduit=mpi
}

#variant openacc description {enable support for OpenACC (requires CUDA installation at /usr/local/cuda)} {
#    configure.args-append   --enable-openacc \
#                            --with-gpucc=/usr/local/cuda/bin/nvcc \
#                            --with-cuda=/usr/local/cuda
#}

notes \
   "${name} is installed in ${prefix}/lib/${name}."
