# Copyright 1999-2004 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit eutils DESCRIPTION="A serial or parallel linear system solver library based on iterative methods." HOMEPAGE="http://www-unix.mcs.anl.gov/petsc/petsc-2/" SRC_URI="ftp://ftp.mcs.anl.gov/pub/petsc/${PN}.tar.gz" LICENSE="TO_DEFINE" SLOT="0" KEYWORDS="~x86 ~ppc" IUSE="mpi X fortran" RDEPEND="mpi? ( sys-cluster/mpich ) !sys-cluster/lam-mpi virtual/lapack virtual/blas" MY_PV=${P/_p/-p} S1=${WORKDIR}/${MY_PV} S=${WORKDIR}/${PN} src_unpack() { unpack ${A} mv ${S1} ${S} cd ${S} epatch "${FILESDIR}"/root_priv.patch #this will help in the configure part. It will be installed in /opt/petsc } petsc_test() { eerror eerror "PETSc test failed." eerror "Do emerge -C petsc" eerror die } src_compile() { export PETSC_DIR=${S} || die local myconf="" use mpi && myconf="${myconf} --with-mpi=1 --with-mpi-compiler=1" || myconf="${myconf} --with-mpi=0" use X && myconf="${myconf} --with-X=1" || myconf="${myconf} --with-X=0" use fortran && myconf="${myconf} --with-fortran=1" || myconf="${myconf} --with-fortran=0" myconf="${myconf} --with-clanguage=C --with-matlab=0 --with-python=0 \ --with-shared=0 --prefix=/opt/ -PETSC_DIR=$PETSC_DIR" #--with-gcov=1 export OPT_D="-PETSC_ARCH=linux_opt_d --with-precision=double --with-debugging=no" export OPT_M="-PETSC_ARCH=linux_opt_m --with-precision=matsingle --with-debugging=no" export OPT_S="-PETSC_ARCH=linux_opt_s --with-precision=single --with-debugging=no" export DEB_D="-PETSC_ARCH=linux_deb_d --with-precision=double --with-debugging=yes" export DEB_M="-PETSC_ARCH=linux_deb_m --with-precision=matsingle --with-debugging=yes" export DEB_S="-PETSC_ARCH=linux_deb_s --with-precision=single --with-debugging=yes" ./config/configure.py ${myconf} ${OPT_D} || die "PETSc OPT_D config failed." ./config/configure.py ${myconf} ${OPT_M} || die "PETSc OPT_M config failed." ./config/configure.py ${myconf} ${OPT_S} || die "PETSc OPT_S config failed." ./config/configure.py ${myconf} ${DEB_D} || die "PETSc DEB_D config failed." ./config/configure.py ${myconf} ${DEB_M} || die "PETSc DEB_M config failed." ./config/configure.py ${myconf} ${DEB_S} || die "PETSc DEB_S config failed." export PETSC_ARCH=linux_opt_d make all || die "error in make opt_d" export PETSC_ARCH=linux_opt_m make all || die "error in make opt_m" export PETSC_ARCH=linux_opt_s make all || die "error in make opt_s" export PETSC_ARCH=linux_deb_d make all || die "error in make deb_d" export PETSC_ARCH=linux_deb_m make all || die "error in make deb_m" export PETSC_ARCH=linux_deb_s make all || die "error in make deb_s" } src_install() { # cd ${S} || die export PETSC_ARCH="linux_deb_s" || die export PETSC_DIR=${S} || die make INSTALL_DIR="${D}/opt/${PN}" install || die make INSTALL_DIR="${D}/opt/${PN}" install_src || die make INSTALL_DIR="${D}/opt/${PN}" install_docs || die export PETSC_ARCH="linux_deb_m" || die make INSTALL_DIR="${D}/opt/${PN}" install || die export PETSC_ARCH="linux_deb_d" || die make INSTALL_DIR="${D}/opt/${PN}" install || die export PETSC_ARCH="linux_opt_s" || die make INSTALL_DIR="${D}/opt/${PN}" install || die export PETSC_ARCH="linux_opt_m" || die make INSTALL_DIR="${D}/opt/${PN}" install || die export PETSC_ARCH="linux_opt_d" || die make INSTALL_DIR="${D}/opt/${PN}" install || die # fix the libtool .la files #LAOBJS=`find . | grep ".la$"` #dosed -i -e "s:${WORKDIR}:/opt:g" ${LAOBJS} # fix broken libtool executable stuff #dosed -i -e "s:${SHELL} ${top_builddir}/libtool:`which libtool`:g" bmake/linux_local/variables #dosed -i -e "s:/bin/sh /opt/petsc/libtool:`which libtool`:g" bmake/linux_local/petscmachineinfo.h } pkg_preinst() { # replace this with doenvd (doenv?) dodir /etc/env.d echo "PATH=/opt/${PN}/bin" > ${D}/etc/env.d/33${PN} echo "PETSC_DIR=/opt/${PN}" >> ${D}/etc/env.d/33${PN} echo "PETSC_ARCH=linux_deb_s" >> ${D}/etc/env.d/33${PN} } pkg_postinst() { einfo "If it is a binary installation, the tests will not be run." if [ -d ${S} ] ; then cd ${S} export PETSC_ARCH="linux_deb_s" || die export PETSC_DIR=${S} || die make test || petsc_test einfo "Running env-update to add the binaries to the PATH and" einfo "to add the PETSC_ARCH and PETSC_DIR variables" einfo "to the environment" /usr/sbin/env-update && source /etc/profile fi #einfo "Need to modify some .la in the library dirs and the bmake/linux_local/petscmachineinfo.h" }