1. # Maintainer: Myles English <myles at rockhead dot biz>
  2. pkgname=petsc
  3. pkgver=3.4.2
  4. pkgrel=1
  5. _config=arch-linux2-cxx-opt
  6. # if --with-debugging=yes is set then PETSC_ARCH is automatically set to
  7. #"arch-linux2-cxx-debug" for some things, so the _config should be changed too
  8. #_config=arch-linux2-cxx-debug
  9. pkgdesc="Portable, extensible toolkit for scientific computation"
  10. arch=('any')
  11. url="http://www.mcs.anl.gov/petsc/petsc-as"
  12. license=('MIT compatible')
  13. depends=('python2' 'openmpi' 'boost' 'blas' 'lapack')
  14. makedepends=('gcc' 'gcc-fortran')
  15. install=petsc.install
  16. source=(http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/${pkgname}-${pkgver/_/-}.tar.gz)
  17. md5sums=('449e27f3c9a37d0bd9d7941cc79a09a9')
  18.  
  19. _install_dir=/opt/petsc/${_config}
  20.  
  21. # to avoid: "make[2]: *** No rule to make target `libptesmumps.a', needed by `main_esmumps'.  Stop."
  22. export MAKEFLAGS="-j1"
  23.  
  24. build() {
  25.     _build_dir="${srcdir}/${pkgname}-${pkgver/_/-}"
  26.  
  27.     cd ${_build_dir}
  28.     #patch -Np1 -i ${startdir}/patch_debug.diff
  29.  
  30.     unset PETSC_ARCH
  31.     export PETSC_DIR=${_build_dir}
  32.  
  33.     find ${srcdir} -name "*" -type f -exec \
  34.     sed -i 's#\(/usr/bin/env \|/usr/bin/\)python[2-3]*#\1python2#' {} \;
  35.  
  36.     CONFOPTS="--with-shared-libraries=1 --with-clanguage=C++ --COPTFLAGS=-O2 --CXXOPTFLAGS=-O2"
  37.  
  38.     # External downloads
  39.     for external_pkg in ptscotch scalapack metis parmetis superlu mumps pastix hypre umfpack; do
  40.         CONFOPTS="${CONFOPTS} --download-${external_pkg}=yes"
  41.     done
  42.  
  43.     if [ "${TRILINOS_DIR}" ]; then
  44.         CONFOPTS="${CONFOPTS} --with-ml=1 --with-ml-lib=${TRILINOS_DIR}/lib/libml.so --with-ml-include=${TRILINOS_DIR}/include"
  45.     fi
  46.  
  47.     # Arch specific
  48.     CONFOPTS="${CONFOPTS} --with-boost=1 --with-boost-dir=/usr"
  49.  
  50.     python2 ./configure \
  51.         --prefix=${pkgdir}${_install_dir} \
  52.         --PETSC_ARCH=${_config} \
  53.         ${CONFOPTS}
  54.  
  55.     make ${MAKEFLAGS} PETSC_DIR=${_build_dir} PETSC_ARCH=${_config} all
  56. }
  57.  
  58. package() {
  59.     _build_dir="${srcdir}/${pkgname}-${pkgver/_/-}"
  60.     cd ${_build_dir}
  61.     echo "make ${MAKEFLAGS} PETSC_DIR=${_build_dir} PETSC_ARCH=${_config} install"
  62.     export PETSC_DIR=${_build_dir}
  63.     make ${MAKEFLAGS} PETSC_DIR=${_build_dir} PETSC_ARCH=${_config} install # > /dev/null
  64.  
  65.     sed -i 's#'"${pkgdir}"'##g' "${pkgdir}${_install_dir}/conf/variables"
  66.     sed -i 's#'"${pkgdir}"'##g' "${pkgdir}${_install_dir}/conf/petscvariables"
  67.     sed -i 's#'"${pkgdir}"'##g' "${pkgdir}${_install_dir}/conf/rules"
  68.     sed -i 's#'"${pkgdir}"'##g' "${pkgdir}${_install_dir}/include/petscconf.h"
  69.     sed -i 's#'"${pkgdir}"'##g' "${pkgdir}${_install_dir}/include/petscconfiginfo.h"
  70.     sed -i 's#'"${pkgdir}"'##g' "${pkgdir}${_install_dir}/conf/petscrules"
  71.  
  72.     export PETSC_DIR=${_install_dir}
  73.    
  74.     # Note: the hyperlinks between documentation, tutorials and examples are
  75.     # not perfect yet
  76.  
  77.     # documentation
  78.     mkdir -p ${pkgdir}/usr/share/doc/$pkgname/
  79.     cp -r ${_build_dir}/docs ${pkgdir}/usr/share/doc/$pkgname/
  80.  
  81.     # tutorials
  82.     cp -r ${_build_dir}/tutorials ${pkgdir}/usr/share/doc/$pkgname/
  83.  
  84.     # src for tutorials
  85.     cp -r ${_build_dir}/src ${pkgdir}/usr/share/doc/$pkgname/
  86.  
  87.     # html versions of header files
  88.     mkdir -p ${pkgdir}/usr/share/doc/$pkgname/include
  89.     cp -r ${_build_dir}/include/*.html ${pkgdir}/usr/share/doc/$pkgname/include/
  90.  
  91.     # install licenCe (even though there is no such word as licenSes)
  92.     mkdir -p ${pkgdir}/usr/share/licenses/petsc
  93.     cp ${_build_dir}/docs/copyright.html ${pkgdir}/usr/share/licenses/$pkgname/
  94.  
  95.     mkdir -p ${pkgdir}/etc/profile.d
  96.     echo "export PETSC_DIR=${_install_dir}" > ${pkgdir}/etc/profile.d/petsc.sh
  97.     chmod +x ${pkgdir}/etc/profile.d/petsc.sh
  98.  
  99.     # show where the shared libraries are
  100.     install -d -m755 "${pkgdir}"/etc/ld.so.conf.d/
  101.     echo "${_install_dir}/lib" > "${pkgdir}"/etc/ld.so.conf.d/petsc.conf
  102. }