# -*- 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 116386 2014-01-23 20:15:22Z sean@macports.org $

PortSystem          1.0
PortGroup           cmake 1.0
PortGroup           mpi 1.0

compilers.choose    cc cxx
mpi.setup

name                parmetis
version             4.0.3
revision            3
categories          math
platforms           darwin
maintainers         sean openmaintainer
# Included license is for "evaluation purposes" only (whatever that means) if
# you're not a non-profit or US government agency.
license             Restrictive

description         ParMETIS - parallel graph partitioning

long_description    ParMETIS - Parallel Graph Partitioning and Fill-reducing Matrix Ordering

homepage            http://glaros.dtc.umn.edu/gkhome/metis/parmetis/overview
master_sites        http://glaros.dtc.umn.edu/gkhome/fetch/sw/parmetis/

checksums           rmd160  1e81baf2bafe79b7abed656bff2fa3745966a196 \
                    sha256  f2d9a231b7cf97f1fee6e8c9663113ebf6c240d407d3c118c55b3633d6be6e5f

depends_lib         port:metis

patch.pre_args      -p1
patchfiles-append   sharedprefix.patch \
                    break_code_copying.patch \
                    headers.patch \
                    add_math_flag.patch \
                    tls.patch \
                    less_than_equal.patch \
                    default_path.patch \
                    static.patch \
                    cmake_system_include.patch

# mpich-default and openmpi are not universal
universal_variant   no

configure.args-append \
                    -DSHARED=1

if {![mpi_variant_isset]} {
    default_variants +mpich
}

if {[variant_isset debug]} {
    # just to be safe
    configure.cflags-delete    -O1 -O2 -O3 -Os -DNDEBUG
    configure.cxxflags-delete  -O1 -O2 -O3 -Os -DNDEBUG
    configure.optflags-delete  -O1 -O2 -O3 -Os -DNDEBUG

    configure.optflags-append  -O0
    configure.cflags-append    -g
    configure.cxxflags-append  -g
}

post-extract {
    delete ${worksrcpath}/metis/include/metis.h
}

livecheck.type      regex
livecheck.url       http://glaros.dtc.umn.edu/gkhome/metis/parmetis/download
livecheck.regex     /${name}-(\[0-9.\]+)${extract.suffix}
