# -*- 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
# $Id: Portfile 92833 2012-05-08 23:46:29Z ryandesign@macports.org $

PortSystem          1.0

name                omnixmp
version             0.5.4
revision            2
categories          lang devel parallel
maintainers         takeshi
description         Omni OpenMP/XcalableMP Compiler
license             LGPL-2.1
long_description \
    Omni OpenMP/XcalableMP Compiler
homepage            http://www.xcalablemp.org/
platforms           darwin
master_sites        ${homepage}/xmp_files/

checksums           rmd160  ba684fab05adccf0fa74eddfe676ca2bcbef3621 \
                    sha256  234202058c4c214b99eeb0c434c466ddf1d18bbf3fc12e4170bcf764fd19ef18

depends_lib         port:flex \
                    port:gmp \
                    port:libxml2

worksrcdir          xmp-${version}
patchfiles          patch-configure.diff \
                    patch-ompc_thread.c.diff \
                    patch-c-expr.c.diff

post-patch {
    if {${build_arch}=="x86_64"} {
        reinplace "s|CPU=i386|CPU=x86_64|g" ${worksrcpath}/configure
    }
}

configure.args      --prefix=${prefix}/lib/${name} \
                    --disable-xmpgpu \
                    --with-gmpLibDir=${prefix}/lib \
                    --with-gmpIncDir=${prefix}/include \
                    --with-cflag=${configure.cflags} \
                    --with-cppflag="${configure.cppflags} -I${prefix}/include/libxml2 -I/usr/include -DSIMPLE_SPIN"

post-destroot {
    ln -s ${prefix}/lib/${name}/bin/xmpcc ${destroot}${prefix}/bin
}

if {![variant_isset gcc44] && ![variant_isset gcc46]} {
    default_variants    +gcc45
}

if {![variant_isset mpich2]} {
    default_variants    +openmpi
}

use_parallel_build  no

variant gcc44 conflicts gcc45 gcc46 description {use gfortran-mp-4.4 as backend fortran compiler} {
    depends_lib-append  port:gcc44
    configure.compiler  macports-gcc-4.4
}

variant gcc45 conflicts gcc44 gcc46 description {use gfortran-mp-4.5 as backend fortran compiler} {
    depends_lib-append  port:gcc45
    configure.compiler  macports-gcc-4.5
}

variant gcc46 conflicts gcc44 gcc45 description {use gfortran-mp-4.6 as backend fortran compiler} {
    depends_lib-append  port:gcc46
    configure.compiler  macports-gcc-4.6
}

variant openmpi conflicts mpich2 description {build with OpenMPI} {
    depends_lib-append      port:openmpi
    configure.args-append   --with-mpicc=${prefix}/lib/openmpi/bin/mpicc
}

variant mpich2 conflicts openmpi description {build with MPICH2} {
    depends_lib-append      port:mpich2
    configure.args-append   --with-mpicc=${prefix}/bin/mpicc
}

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