# -*- 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 90820 2012-03-15 03:13:40Z jmr@macports.org $

PortSystem          1.0

name                scotch
version             5.1.11
revision            4

# this is specific to this port and *version* for downloading it:
set release         28043

categories          science
maintainers         mk pixilla
platforms           darwin
license             CeCILL-C

description         Scotch is a software package for graph and mesh/hypergraph partitioning and sparse matrix ordering.
long_description    ${description}

homepage            http://gforge.inria.fr/projects/scotch
master_sites        https://gforge.inria.fr/frs/download.php/${release}
distname            scotch_${version}

livecheck.type      regex
livecheck.url       https://gforge.inria.fr/frs/?group_id=248
livecheck.regex     "scotch_(5\\.\\d+\\.\\d+)\\.tar\\.gz"

use_bzip2           no

worksrcdir          ${name}_${version}/src

checksums           md5     36d638a227f38a219b51fe8ddc2093ac \
                    sha1    7cee69345bd101b0dbd8aff9b410dea6834c32d6 \
                    rmd160  2b72f555af192a17eecec65d50bd241ad87adec2

use_configure       no

variant gcc44 conflicts gcc45 description {Build with gcc 4.4} {}
variant gcc45 conflicts gcc44 description {Build with gcc 4.5} {}

if {[variant_isset gcc44]} {
    depends_lib-append  port:gcc44
    configure.compiler  macports-gcc-4.4
} else {
    default_variants    +gcc45
    depends_lib-append  port:gcc45
    configure.compiler  macports-gcc-4.5
}

variant universal {
}

set archflags       [get_canonical_archflags]

depends_lib-append  port:openmpi

build.env-append    CC=${configure.cc} \
                    CXX=${configure.cxx} \
                    CFLAGS="${configure.cflags} ${archflags}" \
                    CXXFLAGS="${configure.cxxflags} ${archflags}" \
                    LDFLAGS="[join ${configure.ldflags}] ${archflags}"

pre-build {
    copy ${worksrcpath}/Make.inc/Makefile.inc.i686_mac_darwin8 ${worksrcpath}/Makefile.inc
    reinplace "s|gcc|\$(CC)|" ${worksrcpath}/Makefile.inc
}

build.target scotch ptscotch

# scotch and ptscotch MUST be built sequentially according to scotch's INSTALL.txt
use_parallel_build no

destroot {
    eval xinstall -m 755 [glob ${worksrcpath}/../bin/*] ${destroot}${prefix}/bin
    eval xinstall -m 755 [glob ${worksrcpath}/../include/*] ${destroot}${prefix}/include
    eval xinstall -m 755 [glob ${worksrcpath}/../lib/*] ${destroot}${prefix}/lib
    xinstall -m 755 -d ${destroot}${prefix}/share/man/man1
    eval xinstall -m 755 [glob ${worksrcpath}/../man/man1/*] ${destroot}${prefix}/share/man/man1
}

