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

PortSystem          1.0
PortGroup           cmake 1.0
PortGroup           compilers 1.0

compilers.choose    cc cxx cpp
compilers.setup

name                metis
version             5.1.0
revision            3
categories          math
platforms           darwin
maintainers         sean
license             Apache-2 LGPL-2.1+

description         A package for unstructured graph partitioning

long_description    METIS is a set of programs for partitioning graphs and \
                    for producing fill reducing orderings for sparse \
                    matrices. The algorithms implemented by METIS are based \
                    on the multilevel graph partitioning scheme described \
                    in \[KK95a\] and \[KK95e\]. METIS provides high quality \
                    partitions, is extremely fast, and produces low fill \
                    orderings.

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

checksums           rmd160  2c4a54bcd3179a609842cde1908dbd232a770495 \
                    sha256  76faebe03f6c963127dbb73c13eab58c9a3faeae48779f049066a21c087c5db2

patch.pre_args      -p1
patchfiles-append   remove_home_dir.patch \
                    cmake64.patch \
                    sharedprefix.patch \
                    missing_includes.patch \
                    cmake_tls.patch \
                    gkl.patch \
                    cmake_gklib_tls.patch \
                    cmake_system_include.patch

configure.args-append \
                    -DGKLIB_PATH=${worksrcpath}/GKlib \
                    -DSHARED=1 \
                    -DMETIS_USE_DOUBLEPRECISION=1

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-destroot {
    # Install documentation
    xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 ${worksrcpath}/manual/manual.pdf \
        ${destroot}${prefix}/share/doc/${name}
}

variant openmp description {Enable openmp support} {
  configure.args-append       -DOPENMP=1
}

variant longindex description {Build with index type being long} {
  configure.args-append       -DMETIS_USE_LONGINDEX=1
}

variant single description {Build with single precision} {
  configure.args-delete       -DMETIS_USE_DOUBLEPRECISION=1
}

livecheck.type  regex
livecheck.url   http://glaros.dtc.umn.edu/gkhome/metis/metis/changes
livecheck.regex {Ver: ([0-9.]+),}
