# -*- 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 118803 2014-04-11 00:15:11Z sean@macports.org $

PortSystem          1.0
PortGroup           bitbucket 1.0
PortGroup           conflicts_build 1.0
PortGroup           mpi 1.0

mpi.setup
mpi.enforce_variant petsc

bitbucket.setup     slepc slepc 3.4.4 v
categories          math science
maintainers         sean
license             LGPL
description         Scalable Library for Eigenvalue Problem Computations
long_description    SLEPc is a software library for the solution of large \
                    scale sparse eigenvalue problems on parallel computers. It is an \
                    extension of PETSc and can be used for either standard or generalized \
                    eigenproblems, with real or complex arithmetic. It can also be used for \
                    computing a partial SVD of a large, sparse, rectangular matrix.

notes               "Add the following lines to your .bash_profile if you plan to\
                    use the PETSC/SLEPC makefile rules in $prefix/lib/petsc/conf:\n\
                    \texport PETSC_DIR=${prefix}/lib/petsc\n\
                    \texport SLEPC_DIR=${prefix}/lib/petsc"

platforms           darwin
universal_variant   no

checksums           rmd160  f7efe797897974d59a86dceacbefd29fefbeb550 \
                    sha256  d738843bb48c11bf3e3395988bdd302d10b2eb6da6981d7b4a119477e524f87b

depends_lib-append  port:petsc
conflicts_build     slepc
use_parallel_build  no

configure.args      --prefix=${prefix}/lib/petsc
build.env-append    PETSC_DIR=${prefix}/lib/petsc PETSC_ARCH=arch-installed-petsc SLEPC_DIR=${worksrcpath}
destroot.env-append PETSC_DIR=${prefix}/lib/petsc PETSC_ARCH=arch-installed-petsc SLEPC_DIR=${worksrcpath}
destroot.cmd-append SLEPC_DESTDIR=${destroot}${prefix}/lib/petsc

variant arpack description {compile with ARPACK support} {
    mpi.enforce_variant arpack
    mpi.enforce_fortran

    pre-fetch {
        if {![file exists ${prefix}/lib/libparpack.a]} {
            return -code error "Please install a mpi variant of arpack first."
        }
    }

    depends_lib-append      port:arpack
    configure.args-append   --with-arpack-dir=${prefix} \
                            --with-arpack-flags=-lparpack,-larpack
}

# fix install name
post-destroot {
    system "install_name_tool -id ${prefix}/lib/petsc/lib/libslepc.dylib ${destroot}${prefix}/lib/petsc/lib/libslepc.dylib"
}
