# $Id: Portfile 56293 2009-08-26 02:08:31Z mmoll@macports.org $

PortSystem	1.0

name		petsc
version	    3.0.0-p8
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}

checksums   md5     e2bd471a36689c9ec3e8f26e9d7ede3e \
            sha1    88a1fce967da2b005bf1858dc4a411a05a990571 \
            rmd160  5303555cbafd32e51121ca0f6a07750e3a7ee9ea

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-fc=${prefix}/bin/openmpif90 \
		--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.check 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
