petsc-git-PKGBUILD

build template for non-complex PETSC with petsc4py
git clone git://src.adamsgaard.dk/petsc-git-PKGBUILD # fast
git clone https://src.adamsgaard.dk/petsc-git-PKGBUILD.git # slow
Log | Files | Refs Back to index

commit acf8ee6afcc1b738e1337c2901eeb948346c64d6
parent b3de4b154ef9aa84493368218f6a96e13df17ed7
Author: Lucas Heitzmann Gabrielli <heitzmann@gmail.com>
Date:   Tue, 12 May 2020 12:13:21 -0300

Changes by eDgar: use test_optdepends, remove patch

Diffstat:
M.SRCINFO | 30+++++++++++++++++++++++++-----
MPKGBUILD | 134++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------
Dpatch.diff | 13-------------
Atest_optdepends.sh | 139+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 262 insertions(+), 54 deletions(-)

diff --git a/.SRCINFO b/.SRCINFO @@ -1,6 +1,6 @@ pkgbase = petsc-git - pkgdesc = Portable, extensible toolkit for scientific computation - pkgver = 20191031 + pkgdesc = Portable, extensible toolkit for scientific computation with MUMPS, Hypre, FFTW, HDF5, Scalapack, Suitesparse, Metis, Scotch, Superlu, OpenBLAS, Eigen, OpenMP, HWloc, CGNS, PNG, MED and trilinos + pkgver = 20200512 pkgrel = 1 url = https://www.mcs.anl.gov/petsc/ install = petsc.install @@ -10,18 +10,38 @@ pkgbase = petsc-git makedepends = gcc makedepends = gcc-fortran makedepends = cmake + makedepends = sowing depends = python2 depends = openmpi depends = boost depends = lapack depends = fftw depends = hdf5 + optdepends = hdf5: large files + optdepends = fftw: Fast-Fourier Transform + optdepends = openblas: Linear algebra libraries + optdepends = scalapack: Parallel memory linear algebra + optdepends = mumps: Sparse solver library + optdepends = hypre: Large and sparse linear with massive parallel computing + optdepends = suitesparse: Sparse matrix library + optdepends = metis: Partitioning library (for meshes) + optdepends = scotch: Partitioning with sparse matrices + optdepends = superlu: Subroutines for sparsse linear systems + optdepends = eigen: Lightweight C++ template library for vector and matrix math + optdepends = openmp: Parallel distributed tasks + optdepends = hwloc: Portable Hardware Locality (abstraction of hierarchical architectures) + optdepends = cgns: Recording and recovering computer data + optdepends = png + optdepends = med>=4.0: Data Modelization and Exchanges (meshes) + optdepends = boost: Free peer-reviewed portable C++ source libraries + optdepends = yaml: configuration files + optdepends = opencl: GPU computing provides = petsc conflicts = petsc - source = petsc::git+https://gitlab.com/petsc/petsc#branch=maint - source = patch.diff + source = petsc::git+https://gitlab.com/petsc/petsc.git#branch=maint + source = test_optdepends.sh sha256sums = SKIP - sha256sums = fdf016437dd94f33316e734e35858476aeea1ca0f3ab4d0ee36029b016498de7 + sha256sums = 2c21313b21b7a76ed4d39d040ef60462f8760ae3d4b76ff6aa717ebc43a2275b pkgname = petsc-git diff --git a/PKGBUILD b/PKGBUILD @@ -1,25 +1,76 @@ +# Based on AUR petsc and petsc-git package. Adapted to my +# MOOSE requirements + # Maintainer: Lucas H. Gabrielli <heitzmann@gmail.com> pkgname=petsc-git -pkgver=20191031 +pkgver=20200512 pkgrel=1 _config=linux-c-opt -pkgdesc="Portable, extensible toolkit for scientific computation" +pkgdesc="Portable, extensible toolkit for scientific computation with MUMPS, Hypre, FFTW, HDF5, Scalapack, Suitesparse, Metis, Scotch, Superlu, OpenBLAS, Eigen, OpenMP, HWloc, CGNS, PNG, MED and trilinos" provides=(petsc) conflicts=(petsc) arch=('i686' 'x86_64') url="https://www.mcs.anl.gov/petsc/" license=('BSD') depends=('python2' 'openmpi' 'boost' 'lapack' 'fftw' 'hdf5') -makedepends=('gcc' 'gcc-fortran' 'cmake') +makedepends=('gcc' 'gcc-fortran' 'cmake' 'sowing') +optdepends=("hdf5: large files" + "fftw: Fast-Fourier Transform" + "openblas: Linear algebra libraries" + "scalapack: Parallel memory linear algebra" + "mumps: Sparse solver library" + "hypre: Large and sparse linear with massive parallel computing" + "suitesparse: Sparse matrix library" + "metis: Partitioning library (for meshes)" + "scotch: Partitioning with sparse matrices" + "superlu: Subroutines for sparsse linear systems" + "eigen: Lightweight C++ template library for vector and matrix math" + "openmp: Parallel distributed tasks" + "hwloc: Portable Hardware Locality (abstraction of hierarchical architectures)" + "cgns: Recording and recovering computer data" + "png" + "med>=4.0: Data Modelization and Exchanges (meshes)" + "boost: Free peer-reviewed portable C++ source libraries" + "yaml: configuration files" + "opencl: GPU computing") install=petsc.install -source=(petsc::git+https://gitlab.com/petsc/petsc#branch=maint - patch.diff) +source=(petsc::git+https://gitlab.com/petsc/petsc.git#branch=maint + test_optdepends.sh) sha256sums=('SKIP' - 'fdf016437dd94f33316e734e35858476aeea1ca0f3ab4d0ee36029b016498de7') + '2c21313b21b7a76ed4d39d040ef60462f8760ae3d4b76ff6aa717ebc43a2275b') _petsc_arch="arch-${_config}" +##################################################################### +# From UPC: Building And Using Static And Shared "C" Libraries.html # +# #+begin_QUOTE # +# we need that all jump calls ("goto", in assembly speak) # +# and subroutine calls will use relative addresses, and not # +# absolute addresses. Thus, we need to use ... ~-fPIC~ or # +# ~-fpic~ # +# #+end_QUOTE # +##################################################################### +############################################################################### +# From makepkg.conf # +# -march (or -mcpu) builds exclusively for an architecture # +# -mtune optimizes for an architecture, but builds for whole processor family # +############################################################################### +# -O3 optimises +generic_flags="-fPIC -fopenmp -O3 -march=x86-64 -mtune=generic" +# generic_flags="-fPIC -fopenmp -O3 -march=amdfam10 -mtune=generic" + +export COPTFLAGS=-O3 +export CXXOPTFLAGS=-O3 +export FOPTFLAGS=-O3 +export CPPFLAGS="$generic_flags -O2 -D-FORTIFY-SOURCE=2" +export CFLAGS="$generic_flags" +export CXXFLAGS="$generic_flags" +export FFLAGS="$generic_flags" +export FCFLAGS="$generic_flags" +export F90FLAGS="$generic_flags" +export F77FLAGS="$generic_flags" + pkgver() { cd petsc @@ -35,39 +86,67 @@ prepare() { done < <( find ${srcdir} -name "*" -type f -exec grep -le "$MATCH" \{\} + ) cd "${srcdir}/petsc" - patch -p1 < ../patch.diff + # patch -p1 < ../patch.diff + sed -i 's-\(self.publicInstall[^=]*=[[:space:]]\)[^#]*-\10 -g' config/BuildSystem/config/package.py + + sed -i "s/\(raise RuntimeError('--download-openblas libraries cannot be used')\)/#\1/" config/BuildSystem/config/packages/BlasLapack.py } build() { cd petsc - CONFOPTS='--with-shared-libraries=1 --COPTFLAGS=-O3 --CXXOPTFLAGS=-O3 --with-cxx-dialect=C++11 --with-mpi=1 --with-fftw=1 --with-hdf5=1 --with-zlib=1' + declare -a CONFOPTS + # Run python2 ./configure --help for the meaning of this + CONFOPTS=( + --COPTFLAGS="$COPTFLAGS" + --CXXOPTFLAGS="CXXOPTFLAGS" + --CPPFLAGS="$CPPFLAGS" + --CFLAGS="$CFLAGS" + --CXXFLAGS="$CXXFLAGS" + --FFLAGS="$FFLAGS" + --FCFLAGS="$FCFLAGS" + --F90FLAGS="$F90FLAGS" + --F77FLAGS="$F77FLAGS" + + --with-cxx-dialect=C++11 + --with-mpi=1 + --with-pic=1 + --with-shared-libraries=1 + --with-zlib=1 + + --with-scalar-type=complex + # Add this to test_optdepends.sh + --with-opencl=1 + --with-yaml=1 + ) # if --with-debugging=1 is set then PETSC_ARCH is automatically set to # "linux-c-debug" for some things, so _config should be changed to "linux-c-debug" #CONFOPTS="${CONFOPTS} --with-debugging=1" - # Removed pastix due to incompatibility with current MPI (2019-10-31) - for external_pkg in amd eigen hypre metis mumps parmetis party ptscotch scalapack suitesparse sundials superlu superlu_dist - do - CONFOPTS="${CONFOPTS} --download-${external_pkg}=1" - done + CONFOPTS=( "${CONFOPTS[@]}" $(sh "${srcdir}"/test_optdepends.sh) ) + + dirpkg=${srcdir}/petsc/${_petsc_arch}/externalpackages/ export PETSC_DIR="${srcdir}/petsc" export PETSC_ARCH="${_petsc_arch}" - python2 ./configure LDFLAGS="$LDFLAGS" --prefix=/opt/petsc/${_config} ${CONFOPTS} - + python2 ./configure LDFLAGS="$LDFLAGS" \ + --prefix=/usr/petsc/${_config} \ + --MAKEFLAGS="$MAKEFLAGS" \ + $(for (( i=1; i<=${#CONFOPTS[@]}; i++)); do + echo "${CONFOPTS[$i]}"; + done) + make clean make all } - package() { cd petsc _build_dir="${srcdir}/petsc" - _install_dir=/opt/petsc/${_config} + _install_dir=/usr/petsc/${_config} export PETSC_DIR=${_build_dir} export PETSC_ARCH="${_petsc_arch}" @@ -88,7 +167,7 @@ package() { #mkdir -p ${pkgdir}/usr/share/doc/petsc/include #cp -r ${_build_dir}/include/*.html ${pkgdir}/usr/share/doc/petsc/include/ - # install licence (even though there is no such word as licenses) + # install license (even though there is no such word as licenses) install -Dm 644 ${_build_dir}/LICENSE ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE mkdir -p "${pkgdir}/etc/profile.d" @@ -99,22 +178,5 @@ package() { install -dm 755 "${pkgdir}/etc/ld.so.conf.d/" echo "${_install_dir}/lib" > "${pkgdir}/etc/ld.so.conf.d/petsc.conf" - sed -i "s#-L${_build_dir}/${_petsc_arch}/lib ##" "${pkgdir}${_install_dir}/lib/pkgconfig/PETSc.pc" - sed -i \ - -e "s#prefix=.*#prefix=${_install_dir}#" \ - -e "s#libdir=.*#libdir=\${prefix}/lib#" \ - -e "s#includedir=.*#includedir=\${prefix}/include#" \ - "${pkgdir}${_install_dir}/lib/pkgconfig/superlu.pc" - sed -i \ - -e "s#prefix=.*#prefix=${_install_dir}#" \ - -e "s#libdir=.*#libdir=\${prefix}/lib#" \ - -e "s#includedir=.*#includedir=\${prefix}/include#" \ - "${pkgdir}${_install_dir}/lib/pkgconfig/superlu_dist.pc" - sed -i \ - -e "s#prefix=.*#prefix=${_install_dir};#" \ - -e "s#libdir=.*#libdir=\${prefix}/lib;#" \ - "${pkgdir}${_install_dir}/lib/petsc/bin/sundials-config" - - # install pkgconfig settings - #install -Dm 644 "${_build_dir}/${_petsc_arch}/lib/pkgconfig/PETSc.pc" "${pkgdir}/usr/share/pkgconfig/PETSc.pc" + sed -i "s#-L${_build_dir}/${_petsc_arch}/lib ##" "${pkgdir}${_install_dir}/lib/pkgconfig/PETSc.pc" } diff --git a/patch.diff b/patch.diff @@ -1,13 +0,0 @@ -diff --git a/config/BuildSystem/config/package.py b/config/BuildSystem/config/package.py -index d7777d623b..9dfcf66cee 100644 ---- a/config/BuildSystem/config/package.py -+++ b/config/BuildSystem/config/package.py -@@ -60,7 +60,7 @@ class Package(config.base.Configure): - self.excludedDirs = [] # list of directory names that could be false positives, SuperLU_DIST when looking for SuperLU - self.downloadonWindows = 0 # 1 means the --download-package works on Microsoft Windows - self.requirescxx11 = 0 -- self.publicInstall = 1 # Installs the package in the --prefix directory if it was given. Packages that are only used -+ self.publicInstall = 0 # Installs the package in the --prefix directory if it was given. Packages that are only used - # during the configuration/installation process such as sowing, make etc should be marked as 0 - self.parallelMake = 1 # 1 indicates the package supports make -j np option - diff --git a/test_optdepends.sh b/test_optdepends.sh @@ -0,0 +1,139 @@ +#!/bin/bash + +# Test if external packages for PETSC are installed + +# CONFOPTS="" + +# # External downloads +# for external_pkg in hypre fblaslapack metis parmetis superlu_dist mumps scalapack; do +# CONFOPTS="${CONFOPTS} --download-${external_pkg}=1" +# done + +# Add hypre support +if [ -f "/usr/lib/libHYPRE.so" ]; then + CONFOPTS="${CONFOPTS} --with-hypre=1" +fi + +# Add mumps support +if [ -f "/usr/lib/libmumps_common.so" ]; then + CONFOPTS="${CONFOPTS} --with-mumps=1" +fi + +# Add fftw support +if [ -f "/usr/lib/libfftw3_mpi.so" ]; then + CONFOPTS="${CONFOPTS} --with-fftw=1" +fi + +# Add hdf5 support +if [[ "$(h5stat -V)" ]]; then + CONFOPTS="${CONFOPTS} --with-hdf5=1" +fi + +# Add scalapack support +if [ -f "/usr/lib/pkgconfig/scalapack.pc" ]; then + CONFOPTS="${CONFOPTS} --with-scalapack=1" +fi + +# Add suitesparse support +if [ -f "/usr/include/SuiteSparse_config.h" ]; then + CONFOPTS="${CONFOPTS} --with-suitesparse=1" +fi + +# Add metis support +if [ -f "/usr/include/metis.h" ]; then + CONFOPTS="${CONFOPTS} --with-metis=1" + # Add parmetis support + if [ -f "/usr/include/parmetis.h" ]; then + CONFOPTS="${CONFOPTS} --with-parmetis=1" + fi +fi + +# Add scotch support +SCOTCH_DIR="/usr/include/scotch" +if [ -d "${SCOTCH_DIR}" ]; then + SCOTCH_LIBS="libesmumps.so,libptscotch.so,libptscotcherr.so,libscotch.so,libscotcherr.so" + # Include bzip2 if scotch was build with bzip2 support + if [ -f /usr/include/bzlib.h ];then + SCOTCH_LIBS="${SCOTCH_LIBS},libbz2.so" + fi + SCOTCH_LIBS="[${SCOTCH_LIBS}]" + CONFOPTS="${CONFOPTS} --with-ptscotch=1 --with-ptscotch-lib=${SCOTCH_LIBS} --with-ptscotch-include=${SCOTCH_DIR}" +fi + +# Add superlu support +SUPERLU_DIR="/usr/include/superlu" +if [ -d "${SUPERLU_DIR}" ]; then + CONFOPTS="${CONFOPTS} --with-superlu=1 --with-superlu-lib=-lsuperlu --with-superlu-include=${SUPERLU_DIR}" +fi + +# Incompatible with complex +# # Add sundials support +# SUNDIALS_DIR="/usr/include/sundials/" +# if [ -d "${SUNDIALS_DIR}" ]; then +# CONFOPTS="${CONFOPTS} --with-sundials=1 --with-sundials-include=${SUNDIALS_DIR}" +# fi + +# Add openblas support +if [ -f "/usr/lib/libblas.so" ]; then + CONFOPTS="${CONFOPTS} --with-openblas=1" +fi + +# Add OpenCL support +OPENCL_DIR="/usr/include/CL/" +if [ -f "${OPENCL_DIR}/cl.h" ]; then + CONFOPTS="${CONFOPTS} --with-opencl=1" +else + CONFOPTS="${CONFOPTS} --with-opencl=0" +fi + +# Add eigen support +EIGEN_DIR="/usr/include/eigen3" +if [ -d "${EIGEN_DIR}" ]; then + CONFOPTS="${CONFOPTS} --with-eigen=1 --with-eigen-include=${EIGEN_DIR}" +fi + +# Add OpenMP support +if [ -f "/usr/lib/libomp.so" ]; then + CONFOPTS="${CONFOPTS} --with-openmp=1" +fi + +# Add hwloc support +if [ -f "/usr/lib/libhwloc.so" ]; then + CONFOPTS="${CONFOPTS} --with-hwloc=1 --with-hwloc-pkg-config=/usr/lib/pkgconfig/" +fi + +# Add CGNS support +if [ -f "/usr/lib/libcgns.so" ]; then + CONFOPTS="${CONFOPTS} --with-cgns=1" +fi + +# Add PNG support +if [ -f "/usr/lib/libpng.so" ]; then + CONFOPTS="${CONFOPTS} --with-png=1 --with-png-pkg-config=/usr/lib/pkgconfig/" +fi + +# Add MED support +if [ -f "/usr/lib/libmed.so" ]; then + CONFOPTS="${CONFOPTS} --with-med=1" +fi + +# # Add pastix support +# PASTIX_CONF=$(which pastix-conf) +# if [ -f "${PASTIX_CONF}" ]; then +# PASTIX_DIR="$($PASTIX_CONF --incs | sed 's/-I//')" +# if [ ! -d ${PASTIX_DIR} ]; then +# PASTIX_DIR="[]" +# fi +# #PASTIX_LIBS="$($PASTIX_CONF --libs)" +# PASTIX_LIBS="[libpastix.a,librt.so,libhwloc.so,libpthread.a]" +# CONFOPTS="${CONFOPTS} --with-pastix=1 --with-pastix-lib=${PASTIX_LIBS} --with-pastix-include=${PASTIX_DIR}" +# fi + +# Add trilinos support +if [ "${TRILINOS_DIR}" ]; then + CONFOPTS="${CONFOPTS} --with-ml-dir=${TRILINOS_DIR}" + # Add boost support (may be useful for trilinos) + CONFOPTS="${CONFOPTS} --with-boost=1" +fi + +echo "${CONFOPTS}"