# -*- 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$

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

configure.compiler  macports-gcc-4.4

variant universal {
}

set archflags       [get_canonical_archflags]

depends_lib         port:openmpi port:gcc44

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
}