# $Id: Portfile 63559 2010-02-08 21:54:17Z mmoll@macports.org $

PortSystem	1.0

name		petsc
version	    3.0.0-p11
categories  math science
maintainers	mmoll
description	Portable, Extensible Toolkit for Scientific Computation
long_description	PETSc, pronounced PET-see (the S is silent), is a suite \
        of data structures and routines for the scalable (parallel) solution \
        of scientific applications modeled by partial differential equations. \
        It employs the MPI standard for all message-passing communication.
platforms	darwin
homepage	http://www-unix.mcs.anl.gov/petsc/petsc-as/
master_sites	ftp://ftp.mcs.anl.gov/pub/petsc/release-snapshots/
distname	${name}-lite-${version}
worksrcdir	${name}-${version}
universal_variant   no
checksums           md5     ebaa7638bb30bce694c440f2f63f7b8b \
                    sha1    7fcba825134a8c65f53f4653bbf8b3bbac814d53 \
                    rmd160  d1f1708540d697a78421b8df1097c8a92243e0e3

depends_lib-append  port:openmpi

configure.env-append	PETSC_DIR=${worksrcpath} PETSC_ARCH=darwin
configure.cmd   ${worksrcpath}/config/configure.py
configure.args  --with-python --with-debugging=0 \
 		--with-c-support=1 --with-c++-support=1 --with-pic=fPIC \
		--prefix=${prefix}/lib/petsc \
		--with-cc=${prefix}/bin/openmpicc \
		--with-cxx=${prefix}/bin/openmpicxx \
		--with-mpiexec=${prefix}/bin/openmpiexec
build.env       PETSC_DIR=${worksrcpath} PETSC_ARCH=darwin
destroot.destdir    INSTALL_DIR=${destroot}${prefix}/lib/petsc \
        PETSC_DIR=${worksrcpath} PETSC_ARCH=darwin
post-destroot {
    reinplace "s|${destroot}${prefix}|${prefix}|g" ${destroot}${prefix}/lib/petsc/conf/base
    reinplace "s|${destroot}${prefix}|${prefix}|g" ${destroot}${prefix}/lib/petsc/conf/rules
    reinplace "s|${destroot}${prefix}|${prefix}|g" ${destroot}${prefix}/lib/petsc/conf/petscvariables
    reinplace "s|${destroot}${prefix}|${prefix}|g" ${destroot}${prefix}/lib/petsc/conf/variables
}

# disabled for now; no mpi support in fftw port yet
# variant fftw description {build with fftw support} {
#   configure.args-append   --with-fftw=1 --with-fftw-dir=${prefix}
#   depends_lib-append  port:fftw-3
# }

variant hdf5 description {build with support for HDF5 file format} {
    configure.args-append   --with-hdf5=1 --with-hdf5-dir=${prefix} \
                            --LIBS=-lsz
    depends_lib-append	port:hdf5-18
}

variant triangle description {build with support for Triangle library} {
    configure.args-append   --with-triangle=1 --with-triangle-dir=${prefix}
    depends_lib-append	port:triangle
}

post-activate {
    ui_msg "******************************************************"
    ui_msg "* Add the following line to your .bash_profile if you "
    ui_msg "* plan to use the PETSC makefile rules in             "
    ui_msg "* $prefix/lib/petsc/conf:                             "
    ui_msg "*                                                     "
    ui_msg "*   export PETSC_DIR=${prefix}/lib/petsc              "
    ui_msg "*                                                     "
    ui_msg "******************************************************"
}

livecheck.type  regex
livecheck.url   http://www.mcs.anl.gov/petsc/petsc-2/download/index.html
livecheck.regex petsc-lite-(\[0-9.\]+(-p\[0-9\]+))\\.tar\\.gz
