# $Id: Portfile 105970 2013-05-11 11:53:48Z mmoll@macports.org $

PortSystem      1.0
PortGroup       conflicts_build 1.0

name            slepc
version         3.3-p4
license         LGPL
categories      math science
maintainers     mmoll
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
homepage        http://www.grycap.upv.es/slepc
master_sites    http://www.grycap.upv.es/slepc/download/distrib
distname        ${name}-${version}
universal_variant   no

checksums           md5     d034e8b894bda374ec330a750428ac3f \
                    sha1    49620a9aa6bb502bd773dadee11aa7f98a784ba6 \
                    rmd160  0426a86aab0e765618ade3ac8c17548661cbe1f7

depends_lib-append  port:petsc

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

conflicts_build     slepc

variant arpack description {compile with ARPACK support} {
    pre-fetch {
        if {![file exists ${prefix}/lib/libparpack.a]} {
            return -code error "Please install the openmpi or mpich2 variant of arpack first."
        }
    }
    # This is a rather fragile way to figure out where the fortran library can be
    # found that is needed to link against libparpack.a:
    set fortrandirs {g95 gcc42 gcc43 gcc44 gcc45 gcc46 gcc47 gcc48}
    set fortrandir ""
    foreach dir ${fortrandirs} {
        if {[file exists ${prefix}/lib/${dir}]} {
            set fortrandir ${prefix}/lib/${dir}
        }
    }
    if {${fortrandir} == ""} {
        ui_error "Install a fortran compiler by installing one of these ports:"
        ui_error "gcc42, gcc43, gcc44, gcc45, gcc46, gcc47, gcc48, or g95."
        return -code error "No fortran compiler installed"
    }
    depends_lib-append      port:arpack
    configure.args-append   --with-arpack-dir=${fortrandir} \
                --with-arpack-flags=-lparpack,-larpack,-lgfortran
}

livecheck.type  regex
livecheck.url   http://www.grycap.upv.es/slepc/download/download.htm
livecheck.regex slepc-(\[0-9.\]+(-p\[0-9\]+))\\.tar.gz
