tSquashed commit of the following: - petsc-git-PKGBUILD - build template for non-complex PETSC with petsc4py
git clone git://src.adamsgaard.dk/petsc-git-PKGBUILD
Log
Files
Refs
---
commit 797eae7e2136892b394836ecd75cd45b3fbb1aa1
parent 483c0558a92ca886d9cbaec70948f088f8563101
Author: eDgar 
Date:   Sun, 19 Sep 2021 20:20:43 -0500

Squashed commit of the following:

commit b1d62b2e31965eb7aecf2af6aa63b3623cc6ae62
Author: eDgar 
Date:   Sat Sep 18 14:59:25 2021 -0500

    upd8 SRCINFO

commit 76d2570563dac06c24a8b6e1af07a415947b269e
Author: eDgar 
Date:   Sat Sep 18 14:15:31 2021 -0500

    upd8 contribs, move flags to CONFOPTS, rm LD_PRELOAD libfakeroot

commit 95a9ee5d8ab02cb266b9987e9c34f043c3f8ebb2
Author: eDgar 
Date:   Sat Sep 18 14:15:11 2021 -0500

    test_optdepends: use type instead of which where appropriate

commit 3cd56907d05db1e243cf5967c3ff6db1e7e13386
Author: eDgar 
Date:   Sat Sep 18 00:18:31 2021 -0500

    3.15.4; fix petsc4py with patch (SUDO_USER)

commit 594139c1e91a1df97b7964b4f829786c43116240
Author: eDgar 
Date:   Fri Sep 17 17:49:39 2021 -0500

    disable env flags; enable debug messages (make tests); move sed BlasLapack.py into build

commit 91af4923fc0348e2f6e5b46b2ad0e9f2bac873c4
Author: eDgar 
Date:   Fri Sep 17 16:40:31 2021 -0500

    test_optdepends.sh: GDB, comment out OpenGL (not working)

commit e06da72ea7b391d44f45b14135ef414374866440
Author: eDgar 
Date:   Fri Sep 17 16:38:42 2021 -0500

    3.15.4, get rid of BlasLapack.py (testing)

commit 666743cdc9920832e4efee7e4c29bcf2f7da3ce3
Author: eDgar 
Date:   Fri Sep 17 16:37:15 2021 -0500

    _base, remove _config, clean CONFOPTS

commit 52f73e80d4da9f75a1b2f961376c85f2dcd95945
Author: eDgar 
Date:   Tue Aug 31 01:08:18 2021 -0500

    add pets4py by means of PYTHONPATH

commit a08bf9f41335bea69bc68a24d8fd59ff6779a796
Author: eDgar 
Date:   Tue Aug 31 01:07:23 2021 -0500

    remove cruft (comments) and add legibility

commit 878a7afa08083d5ada268ea77a4c2c54570bccd2
Author: eDgar 
Date:   Tue Aug 31 01:04:06 2021 -0500

    use git release in pkgversion instead of date

commit 9b4cc7b57cb785f71344e5a7f46e52f093f1de8b
Author: eDgar 
Date:   Tue Aug 31 01:03:33 2021 -0500

    /usr/local → /usr

commit 48647091e2d5d40da337e1c90318d448d65abc72
Author: eDgar 
Date:   Tue Aug 31 01:02:47 2021 -0500

    change top-legend

commit 4cbe05b6a9a2135abde29e8d3b12d795ff851c37
Author: eDgar 
Date:   Tue Aug 31 01:02:13 2021 -0500

    Make description much shorter

commit c43a1d27045c3b4daa920ec07928efa4da38d11f
Author: eDgar 
Date:   Sun Aug 29 12:44:09 2021 -0500

    silent make, better pkgver, march=native

commit cc9bcc54dd9721fdcdc97c0558701309a268968e
Author: eDgar 
Date:   Sun Aug 29 12:42:10 2021 -0500

    enable X (libX11.so; for ksp_xmonitor)

commit b03b8a642ad55fc755111657d5116236a55b1e9d
Author: eDgar 
Date:   Mon Aug 16 17:23:58 2021 -0500

    remove petsc4py (not working); split package to petsc{,-doc}

commit b66ba61a72cb28df67b119e631096a9ea8773111
Author: eDgar 
Date:   Thu Aug 5 09:26:21 2021 -0500

    test_optdepends.sh: openblas with pkgconfig

commit 2ee1827afab76692742fe23149936e2152c12c75
Author: eDgar 
Date:   Wed Aug 4 22:50:06 2021 -0500

    hypre is makedepends, not optdepends

commit 28571fb8ce884e009bd84bd7cd1afc414bcda39b
Author: eDgar 
Date:   Fri May 21 00:43:24 2021 -0500

    flags in multi-lines, set libHYPRE.so directly

commit f9eb15bd087212a5eef9a369e22a88d859fce15e
Author: eDgar 
Date:   Wed May 19 09:56:06 2021 -0500

    use whereis, ldconfig, pkgconf to find optional deps

commit 1057e3d5e8db9faaf99a6c397fa186232e3cbcf6
Author: eDgar 
Date:   Tue May 18 13:04:49 2021 -0500

    remove petsc4py.patch

commit 98e3afef3525b2d44d3ac419adb9c87d47cfdf03
Author: eDgar 
Date:   Tue May 18 12:00:57 2021 -0500

    clean flags (add doc), sane petsc4py, resort optdepends, staticlibs

commit 12884b165c3017a87a2da2bb40b8b5758b493ac2
Author: eDgar 
Date:   Wed May 12 13:58:54 2021 -0500

    use ldconfig with test_optdepends.sh

commit 53d06c02010af2da62a7e78475affa60912eba22
Author: eDgar 
Date:   Mon Mar 15 16:21:38 2021 -0600

    recover missing directories from AUR; add option for petsc4py

commit cc36baddff61dfa2a3bd158301d2729cd45250b9
Author: eDgar 
Date:   Mon Mar 15 00:06:32 2021 -0600

    use python instead of python2

commit afe93d89fb79ccc1f1b2647d0351bb2bbabc0d71
Author: Lucas Heitzmann Gabrielli 
Date:   Wed Feb 3 17:03:02 2021 -0300

    Fix petsc4py build

commit 1260bb53b9c1ddbe8814504ed46adb8a644a7933
Author: Lucas Heitzmann Gabrielli 
Date:   Tue May 12 12:13:21 2020 -0300

    Changes by eDgar: use test_optdepends, remove patch

commit 2a92162ebdef2c5e2fba43eeded92499713927aa
Author: eDgar 
Date:   Tue May 12 23:21:34 2020 -0500

    improve dependencies (whereis, add zlib); use slepc-maint (heitzmann)

commit 92ccc72c2dfa39630e7597917fce3b2b6b6cd0d7
Author: eDgar 
Date:   Mon May 11 21:29:50 2020 -0500

    OpenCL > test_optdepends.sh

commit bdb874186d686eb8cd9255156cd5a87f49828aff
Author: eDgar 
Date:   Sun May 10 18:50:20 2020 -0500

    mtune=generic

commit 37ec0108f6ccdb87f759c0e1a537d228ab187f17
Author: eDgar 
Date:   Sun May 10 18:21:35 2020 -0500

    update deps: sowing,med>=4.0/add FORTIFY-SOURCE=2 to flags

commit e3d46fcf98e9f3aad40be3f66913d139f872c518
Author: eDgar 
Date:   Mon Dec 30 15:29:26 2019 +0100

    export flags for all functions; del flags also in test_optdepends

commit 538517d9ca8e28b4d7263af91ad4eab8834235aa
Author: eDgar 
Date:   Wed Dec 25 19:25:01 2019 +0100

    Added openblas (hacked BlasLapack.py)

commit ed0b0b66dc38da1a2b68be1185ad557d1201c5e6
Author: eDgar 
Date:   Sat Dec 21 22:22:36 2019 +0100

    enable  openmp, hwloc, opengl, eigen, cgns, libpng

commit 05e824313dc9b367bd0d34ee22f5f70da936a4f4
Author: eDgar 
Date:   Fri Dec 20 22:06:17 2019 +0100

    generic_flags; future extra packages list

commit d623eca1b515d52149ceae860a5c479d60584b7b
Author: eDgar 
Date:   Fri Dec 20 10:31:34 2019 +0100

    openmpi=4, test_optdepends

commit 3fc79265b9729b90846da4cbacc315fe5de62677
Author: eDgar 
Date:   Mon Nov 4 15:52:49 2019 +0100

    custom build eDgar

Diffstat:
  M .SRCINFO                            |      70 ++++++++++++++++++++++----------
  A .gitignore                          |       8 ++++++++
  M PKGBUILD                            |     363 +++++++++++++++++--------------
  A blaslapack_download.patch           |      11 +++++++++++
  A petsc4py_newuser.patch              |      11 +++++++++++
  A test_optdepends.sh                  |     276 ++++++++++++++++++++++++++++++

6 files changed, 553 insertions(+), 186 deletions(-)
---
diff --git a/.SRCINFO b/.SRCINFO
t@@ -1,9 +1,8 @@
 pkgbase = petsc-git
-        pkgdesc = Portable, extensible toolkit for scientific computation (external downloads enabled)
-        pkgver = 20210515
-        pkgrel = 1
+        pkgdesc = Portable, extensible toolkit for scientific computation
+        pkgver = 3.15.4.27.g1085e15b135
+        pkgrel = 2
         url = https://gitlab.com/petsc/petsc
-        install = petsc.install
         arch = i686
         arch = x86_64
         license = BSD
t@@ -11,31 +10,60 @@ pkgbase = petsc-git
         makedepends = gcc-fortran
         makedepends = cmake
         makedepends = sowing
-        makedepends = python
         makedepends = git
         makedepends = cython
         makedepends = chrpath
+        makedepends = hypre=2.18.2
         depends = openmpi
         depends = lapack
         depends = fftw
-        depends = hdf5
-        depends = suitesparse
-        depends = metis
-        depends = parmetis
-        depends = superlu
-        depends = eigen
+        depends = zlib
         depends = cython
         depends = python-mpi4py
-        optdepends = opencl: GPU computing
-        optdepends = hwloc: hardware locality
-        optdepends = cgns: CFD data support
-        optdepends = libpng: PNG support
-        optdepends = libyaml: YAML configuration support
-        optdepends = libx11: GUI tools
-        provides = petsc
-        conflicts = petsc
-        source = petsc::git+https://gitlab.com/petsc/petsc.git#branch=release
-        sha256sums = SKIP
+        depends = python-numpy
+        depends = eigen>=3
+        depends = openblas
+        options = !staticlibs
+        source = git+https://gitlab.com/petsc/petsc.git#branch=release
+        source = https://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-with-docs-3.15.4.tar.gz
+        source = test_optdepends.sh
+        source = petsc4py_newuser.patch
+        source = blaslapack_download.patch
+        sha512sums = SKIP
+        sha512sums = b6a1d48aab1c2639a4c1cbd8b313ace253f1c36eedaa3de3508ffbd6060e1def99e2f516ed9bb509307f614b41791d09342e2c2280c0b2c25dda1092b0e569d2
+        sha512sums = 2c2c48f6b87e24b6f5fccfd2a6eb0889d47385c0be7ba14614c55c774f8b915c33a5d5ec5cc1637d41f7407423b77ac1bcc129bfa3d7967bb917ad8d1de3a6b5
+        sha512sums = 038f4f54cb8771590b528e41666f33095d9381bf07636c53841293a3937faeb8604bfe3cb98fac588b647661ea74602e6c261cf7809e0cec7ed086e8b01b5f01
+        sha512sums = af899ea1d06bf6d4cee1c1fe86902ba2772d1001caf00e89363c6217fed9dd837588ee6f7f827ca8b8fd2a01316fbcd73d98874e28d452af71b9598127b6f179
 
 pkgname = petsc-git
+        optdepends = boost: Free peer-reviewed portable C++ source libraries
+        optdepends = cgns: Recording and recovering computer data
+        optdepends = eigen: Lightweight C++ template library for vector and matrix math
+        optdepends = fftw: Fast-Fourier Transform
+        optdepends = gdb: Debugging
+        optdepends = hdf5: large files
+        optdepends = hwloc: Portable Hardware Locality (abstraction of hierarchical architectures)
+        optdepends = med>=4.0: Data Modelization and Exchanges (meshes)
+        optdepends = metis: Partitioning library (for meshes)
+        optdepends = mumps: Sparse solver library
+        optdepends = openblas: Linear algebra libraries
+        optdepends = opencl-headers: for opencl (GPU computing)
+        optdepends = opencl: GPU computing
+        optdepends = openmp: Parallel distributed tasks
+        optdepends = png
+        optdepends = scalapack: Parallel memory linear algebra
+        optdepends = scotch: Partitioning with sparse matrices
+        optdepends = suitesparse: Sparse matrix library
+        optdepends = superlu: Subroutines for sparsse linear systems
+        optdepends = yaml: configuration files
+        provides = petsc=3.15.4
+        provides = petsc4py=3.15.4
+        conflicts = petsc
 
+pkgname = petsc-doc
+        pkgdesc = Documentation for PETSc
+        depends = 
+        optdepends = 
+        provides = petsc-doc
+        conflicts = 
+        replaces = petsc-doc
diff --git a/.gitignore b/.gitignore
t@@ -0,0 +1,8 @@
+*.pkg.tar.xz
+pkg
+src
+*\~
+*.bak
+*.tar.gz
+
+petsc
diff --git a/PKGBUILD b/PKGBUILD
t@@ -1,179 +1,212 @@
-# Maintainer: Lucas H. Gabrielli 
+# Based on AUR petsc and petsc-git package.
 
-pkgname=petsc-git
-pkgver=20210515
-pkgrel=1
-_config=linux-c-opt
-pkgdesc="Portable, extensible toolkit for scientific computation (external downloads enabled)"
-provides=(petsc)
-conflicts=(petsc)
+# Contributor: Lucas H. Gabrielli 
+# Contributor: Martin Diehl 
+
+_base=petsc
+pkgname=("${_base}"-git "${_base}"-doc)
+pkgver=3.15.4.27.g1085e15b135
+pkgrel=2
+_mainver="${pkgver:0:6}"
+pkgdesc="Portable, extensible toolkit for scientific computation"
 arch=('i686' 'x86_64')
-url="https://gitlab.com/petsc/petsc"
+url="https://gitlab.com/petsc/${_base}"
 license=('BSD')
-depends=('openmpi' 'lapack' 'fftw' 'hdf5' 'suitesparse' 'metis' 'parmetis' 'superlu' 'eigen' 'cython' 'python-mpi4py')
-makedepends=('gcc' 'gcc-fortran' 'cmake' 'sowing' 'python' 'git' 'cython' 'chrpath')
-optdepends=("opencl: GPU computing"
-            "hwloc: hardware locality"
-            "cgns: CFD data support"
-            "libpng: PNG support"
-            "libyaml: YAML configuration support"
-            "libx11: GUI tools")
-install=petsc.install
-source=(petsc::git+https://gitlab.com/petsc/petsc.git#branch=release)
-sha256sums=('SKIP')
-
-_petsc_arch="arch-${_config}"
-_petsc_dir='/usr/local/petsc'
-_install_dir="${_petsc_dir}/${_config}"
-
-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
-    git log --format="%cd" --date=short -1 | sed 's/-//g'
-}
+options=(!staticlibs)
+depends=('openmpi' 'lapack' 'fftw' 'zlib' 'cython'
+         'python-mpi4py' "python-numpy" "eigen>=3" "openblas")
+makedepends=('gcc' 'gcc-fortran' 'cmake' 'sowing'
+             'git' 'cython' 'chrpath' "hypre=2.18.2")
+source=(git+${url}.git#branch=release
+        https://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-with-docs-"${_mainver}".tar.gz
+        test_optdepends.sh
+        petsc4py_newuser.patch
+        blaslapack_download.patch)
+sha512sums=('SKIP'
+            'b6a1d48aab1c2639a4c1cbd8b313ace253f1c36eedaa3de3508ffbd6060e1def99e2f516ed9bb509307f614b41791d09342e2c2280c0b2c25dda1092b0e569d2'
+            '2c2c48f6b87e24b6f5fccfd2a6eb0889d47385c0be7ba14614c55c774f8b915c33a5d5ec5cc1637d41f7407423b77ac1bcc129bfa3d7967bb917ad8d1de3a6b5'
+            '038f4f54cb8771590b528e41666f33095d9381bf07636c53841293a3937faeb8604bfe3cb98fac588b647661ea74602e6c261cf7809e0cec7ed086e8b01b5f01'
+            'af899ea1d06bf6d4cee1c1fe86902ba2772d1001caf00e89363c6217fed9dd837588ee6f7f827ca8b8fd2a01316fbcd73d98874e28d452af71b9598127b6f179')
 
+_config=linux-c-opt
+_install_dir="/usr"
+
+#  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
+#
+# -D-FORTIFY-SOURCE=2
+# | https://stackoverflow.com/a/16604146
+# |- man 7 feature_test_macros
+# checks to be performed to detect some buffer overflow
+# errors when employing various string and memory
+# manipulation functions ... some  conforming programs
+# might fail
+#
+# -fcf-protection
+# | Info pages for gcc (gnu compiler collection)
+# intended to protect against such threats as
+# Return-oriented Programming (ROP), and similarly
+# call/jmp-oriented programming (COP/JOP)
+#
+# -pipe
+# | Info pages for gcc (controlling the kind of output)
+# Use pipes rather than temporary files for communication
+# between the various stages of compilation
+#
+# -fno-plt
+# | Info pages for gcc (code generation conventions)
+# leads to more efficient code by eliminating PLT stubs and
+# exposing GOT loads to optimizations
+#
+# -fopenmp
+# | Info pages for gcc (controlling c dialect)
+# Enable handling of OpenMP directives
+#
+
+safe_flags="-Wp,-D-FORTIFY-SOURCE=2,-D_GLIBCXX_ASSERTIONS"
+safe_flags+=" -fcf-protection -fno-plt"
+safe_flags+=" -fstack-clash-protection -Wformat"
+safe_flags+=" -Werror=format-security"
+generic_flags="-pipe -fno-plt -fPIC -fopenmp"
+generic_flags+=" -march=native"
+generic_flags+=" -mtune=native ${safe_flags}"
+opt_flags="${generic_flags} -O3"
+generic_flags="${generic_flags} -O2"
+
+export LANG=C
+export OMPI_MCA_opal_cuda_support=0
+unset PETSC_DIR
+export PETSC_ARCH=${_config}
 
 prepare() {
-    cd "${srcdir}/petsc"
-    sed -i 's-\(self.publicInstall[^=]*=[[:space:]]\)[^#]*-\10 -g' config/BuildSystem/config/package.py
+  patch -p1 -i blaslapack_download.patch
+  patch -p1 -i petsc4py_newuser.patch
 }
 
-
-build() {
-    cd petsc
-
-    declare -a CONFOPTS
-    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-fftw=1
-      --with-hdf5=1
-      --with-suitesparse=1
-
-      --with-parmetis=1
-      --with-metis=1
-      --with-superlu=1
-      --with-superlu-include=/usr/include/superlu
-      --with-superlu-lib=superlu
-      --with-eigen=1
-      --with-eigen-pkg-config=/usr/share/pkgconfig
-
-      --with-scalar-type=complex
-
-      --download-scotch=1
-      --download-ptscotch=1
-      --download-mumps=1
-      --download-scalapack=1
-      --download-hypre=1
-    )
-
-    CONFOPTS=( "${CONFOPTS[@]}" )
-
-    # Add OpenCL support
-    OPENCL_DIR="/usr/include/CL/"
-    if [ -f "${OPENCL_DIR}/cl.h" ]; then
-        CONFOPTS="${CONFOPTS} --with-opencl=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 YAML support
-    if [ -f "/usr/lib/libyaml.so" ]; then
-        CONFOPTS="${CONFOPTS} --with-yaml=1 --with-yaml-pkg-config=/usr/lib/pkgconfig/"
-    fi
-
-    # 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"
-
-    export PETSC_DIR="${srcdir}/petsc"
-    export PETSC_ARCH="${_petsc_arch}"
-
-    python ./configure LDFLAGS="$LDFLAGS" \
-           --prefix="${_install_dir}" \
-           --MAKEFLAGS="$MAKEFLAGS" \
-           $(for (( i=1; i<=${#CONFOPTS[@]}; i++)); do echo "${CONFOPTS[$i]}"; done)
-
-    make all
+pkgver() {
+  cd "${srcdir}"/"${_base}"
+  git describe --tags --match '*.*' | tr '-' '.' | sed 's-^v--'
 }
 
-package() {
-    cd petsc
-
-    _build_dir="${srcdir}/petsc"
-
-    export PETSC_DIR=${_build_dir}
-    export PETSC_ARCH="${_petsc_arch}"
-
-    make DESTDIR="${pkgdir}" install
-
-    # petsc4py
-    pushd ${_build_dir}/src/binding/petsc4py
-    CFLAGS="$(echo "${CFLAGS}" | sed 's%-D[^[:space:]]*%%g')" python setup.py install --root="${pkgdir}"
-    popd
-
-    # install license
-    install -Dm 644 ${_build_dir}/LICENSE ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE
-
-    mkdir -p "${pkgdir}/etc/profile.d"
-    printf "export PETSC_DIR=${_install_dir}" > "${pkgdir}/etc/profile.d/petsc.sh"
-    chmod +x "${pkgdir}/etc/profile.d/petsc.sh"
-
-    # show where the shared libraries are
-    install -dm 755 "${pkgdir}/etc/ld.so.conf.d/"
-    printf "${_install_dir}/lib" > "${pkgdir}/etc/ld.so.conf.d/petsc.conf"
+build() {
 
-    printf "PETSC_DIR  = ${_petsc_dir}\nPETSC_ARCH = ${_petsc_arch}" \
-        > "${pkgdir}/usr/lib/python3.9/site-packages/petsc4py/lib/petsc.cfg"
+  CONFOPTS=(
+    --silent --enable-silent-rules
+    --ignoreWarnings=1
+    --prefix="${_install_dir}"
+    --COPTFLAGS="${opt_flags}"
+    --CXXOPTFLAGS="${opt_flags}"
+    --FOPTFLAGS="${opt_flags}"
+    --CFLAGS="${generic_flags}"
+    --CXXFLAGS="$generic_flags"
+    --CPPFLAGS="$generic_flags"
+    --FCFLAGS="$generic_flags"
+    --F90FLAGS="$generic_flags"
+    --FFLAGS="$generic_flags"
+    --MAKEFLAGS=${MAKEFLAGS}
+    --LDFLAGS=${LDFLAGS}
+    --with-environment-variables=0
+    --disable-environment-variables=1
+    --with-cxx-dialect=auto
+    --with-mpi=1
+    --with-pic=1
+    --with-shared-libraries=1
+    --with-zlib=1
+    --with-petsc4py=1
+    --with-scalar-type=complex
+    --with-single-library=1
+    " $(sh ${srcdir}/test_optdepends.sh)")
+
+  cd "${srcdir}"/"${_base}"
+  python ./configure ${CONFOPTS[@]}
+
+  make -s ${MAKEFLAGS} all
+}
 
-    _rem_dir="${_build_dir}/${_petsc_arch}"
+check() {
+  cd "${srcdir}"/"${_base}"
+  make check
+  }
+
+package_petsc-git() {
+  optdepends=(
+    "boost: Free peer-reviewed portable C++ source libraries"
+    "cgns: Recording and recovering computer data"
+    "eigen: Lightweight C++ template library for vector and matrix math"
+    "fftw: Fast-Fourier Transform"
+    "gdb: Debugging"
+    "hdf5: large files"
+    "hwloc: Portable Hardware Locality (abstraction of hierarchical architectures)"
+    "med>=4.0: Data Modelization and Exchanges (meshes)"
+    "metis: Partitioning library (for meshes)"
+    "mumps: Sparse solver library"
+    "openblas: Linear algebra libraries"
+    "opencl-headers: for opencl (GPU computing)"
+    "opencl: GPU computing"
+    "openmp: Parallel distributed tasks"
+    "png"
+    "scalapack: Parallel memory linear algebra"
+    "scotch: Partitioning with sparse matrices"
+    "suitesparse: Sparse matrix library"
+    "superlu: Subroutines for sparsse linear systems"
+    "yaml: configuration files")
+  provides=(${_base}="${_mainver}" petsc4py="${_mainver}")
+  conflicts=(${_base})
+
+  unset PETSC_DIR
+  _build_dir="${srcdir}"/"${_base}"
+
+  make -C "${_build_dir}" \
+       ${MAKEFLAGS} DESTDIR="${pkgdir}" install
+
+  export PETSC_DIR=${_install_dir}
+
+  # install licence (even though there is no such word as licenses)
+  install -Dm 644 ${_build_dir}/LICENSE \
+          "${pkgdir}"/"${_install_dir}"/share/licenses/"${pkgname}"/LICENSE
+
+  mkdir -p "${pkgdir}"/etc/profile.d
+  echo "export PETSC_DIR=${_install_dir}" > \
+       "${pkgdir}"/etc/profile.d/${_base}.sh
+  echo "export PYTHONPATH=\$PYTHONPATH:/${_install_dir}/${_base}/${_config}/lib" \
+       >> "${pkgdir}"/etc/profile.d/${_base}.sh
+  chmod +x "${pkgdir}"/etc/profile.d/${_base}.sh
+
+  # show where the shared libraries are
+  install -dm 755 "${pkgdir}"/etc/ld.so.conf.d/
+  echo "${_install_dir}/lib" > \
+       "${pkgdir}"/etc/ld.so.conf.d/${_base}.conf
+
+  # install pkgconfig settings
+  install -Dm 644 "${_build_dir}/${_config}"/lib/pkgconfig/PETSc.pc \
+          "${pkgdir}"/"${_install_dir}"/share/pkgconfig/PETSc.pc
+}
 
-    sed -i "s#-L${_rem_dir}/lib ##" "${pkgdir}${_install_dir}/lib/pkgconfig/PETSc.pc"
-    sed -i "s#-L${_rem_dir}/lib ##" "${pkgdir}${_install_dir}/lib/pkgconfig/petsc.pc"
-    sed -i "s#${_rem_dir}#${_install_dir}#g" "${pkgdir}${_install_dir}/include/petscmachineinfo.h"
-    sed -i "s#${_rem_dir}#${_install_dir}#g" "${pkgdir}${_install_dir}/lib/petsc/conf/pkg.conf.mumps"
-    sed -i "s#${_rem_dir}#${_install_dir}#g" "${pkgdir}${_install_dir}/lib/petsc/conf/pkg.conf.hypre"
-    sed -i "s#${_rem_dir}#${_install_dir}#g" "${pkgdir}${_install_dir}/lib/petsc/conf/petscvariables"
-    sed -i "s#${_rem_dir}#${_install_dir}#g" "${pkgdir}${_install_dir}/lib/petsc/conf/petscrules"
+package_petsc-doc () {
+  depends=()
+  optdepends=()
+  provides=(${_base}-doc)
+  replaces=(${_base}-doc)
+  conflicts=()
+  pkgdesc="Documentation for PETSc"
+  # Two options: compile the documentation or get it from
+  # the web. Downloading is easier.
+  [[ -d ${pkgdir}/${_install_dir}/share/doc ]] && \
+    rm -fr "${pkgdir}"/"${_install_dir}"/share/doc
+  mkdir -p "${pkgdir}"/"${_install_dir}"/share/doc
+  cp -r "${srcdir}/${_base}-${_mainver}/docs" \
+     "${pkgdir}"/"${_install_dir}"/share/doc/${_base}
 }
diff --git a/blaslapack_download.patch b/blaslapack_download.patch
t@@ -0,0 +1,11 @@
+--- b/petsc/config/BuildSystem/config/packages/BlasLapack.py        2021-09-17 23:26:42.115594175 -0500
++++ b/petsc/config/BuildSystem/config/packages/BlasLapack.py        2021-09-17 22:53:07.122154127 -0500
+@@ -187,7 +187,7 @@
+         yield ('OpenBLAS with full path', None, os.path.join(self.openblas.libDir,'libopenblas.a'),self.openblas.known64,self.openblas.usesopenmp)
+       else:
+         yield ('OpenBLAS', None, self.openblas.lib,self.openblas.known64,self.openblas.usesopenmp)
+-      raise RuntimeError('--download-openblas libraries cannot be used')
++      ###raise RuntimeError('--download-openblas libraries cannot be used')
+     if 'with-blas-lib' in self.argDB and not 'with-lapack-lib' in self.argDB:
+       raise RuntimeError('If you use the --with-blas-lib= you must also use --with-lapack-lib= option')
+     if not 'with-blas-lib' in self.argDB and 'with-lapack-lib' in self.argDB:
diff --git a/petsc4py_newuser.patch b/petsc4py_newuser.patch
t@@ -0,0 +1,11 @@
+--- a/petsc/config/BuildSystem/config/packages/petsc4py.py        2021-09-17 23:23:54.438918631 -0500
++++ b/petsc/config/BuildSystem/config/packages/petsc4py.py        2021-09-17 23:19:50.395572374 -0500
+@@ -58,7 +58,7 @@
+ 
+     #  if installing as Superuser than want to return to regular user for clean and build
+     if self.installSudo:
+-       newuser = self.installSudo+' -u $${SUDO_USER} '
++       newuser = ''
+     else:
+        newuser = ''
+ 
diff --git a/test_optdepends.sh b/test_optdepends.sh
t@@ -0,0 +1,276 @@
+#!/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+=" --download-${external_pkg}=1"
+# done
+
+type mpicc >/dev/null && CONFOPTS+=" --with-cc=mpicc"
+type mpicxx >/dev/null && CONFOPTS+=" --with-cxx=mpicxx"
+type mpifort >/dev/null && CONFOPTS+=" --with-fc=mpifort"
+
+# BOOST: Free peer-reviewed portable C++ source libraries
+if [ -f "$(whereis -b libboost_mpi.so | cut -d' ' -f2)" ]; then
+    CONFOPTS+=" --with-boost=1"
+fi;
+
+# CGNS: Recording and recovering computer data
+if [ -f "$(whereis -b libcgns.so | cut -d' ' -f2)" ]; then
+        CONFOPTS+=" --with-cgns=1"
+fi
+
+# eigen: Lightweight C++ template library for vector and matrix math
+EIGEN_DIR="$(pkgconf --cflags-only-I eigen3)"
+EIGEN_DIR="${EIGEN_DIR##-I}"
+if [ -d "${EIGEN_DIR}" ]; then
+        CONFOPTS+=" --with-eigen=1 --with-eigen-include=${EIGEN_DIR}"
+fi
+
+# fftw: Fast-Fourier Transform
+if [ -f "$(whereis -b libfftw3_mpi.so | cut -d' ' -f2)" ]; then
+        CONFOPTS+=" --with-fftw=1"
+fi
+
+# GDB: GNU debugger
+if [ -f "$(whereis -b gdb | cut -d' ' -f2)" ]; then
+        CONFOPTS+=" --with-debugger=gdb"
+fi
+
+# # GLUT (requires OpenGL)
+# if [ -f "$(whereis -b libglut.so | cut -d' ' -f2)" ]; then
+#         CONFOPTS+=" --with-glut=1"
+#     CONFOPTS+=" --with-glut-pkg-config="
+#     CONFOPTS+="$(dirname $(pkgconf --path glut))"
+# fi
+
+# HDF5: large files
+if [[ "$(h5stat -V)" ]]; then
+        CONFOPTS+=" --with-hdf5=1"
+fi
+
+# hwloc: abstraction of hierarchical architectures
+if [ -f "$(whereis -b libhwloc.so | cut -d' ' -f2)" ]; then
+        CONFOPTS+=" --with-hwloc=1"
+    CONFOPTS+=" --with-hwloc-pkg-config="
+    CONFOPTS+="$(dirname $(pkgconf --path hwloc))"
+fi
+
+# Hypre: Large and sparse linear with massive parallel computing
+if [ -f "$(whereis -b libHYPRE.so | cut -d' ' -f2)" ]; then
+        CONFOPTS+=" --with-hypre=1"
+        CONFOPTS+=" --with-hypre-lib=[/usr/lib/libHYPRE.so]"
+        CONFOPTS+=" --with-hypre-include=/usr/include"
+fi
+
+# MED: Data Modelization and Exchanges (meshes)
+if [ -f "$(whereis -b libmed.so | cut -d' ' -f2)" ]; then
+        CONFOPTS+=" --with-med=1"
+fi
+
+# METIS: Automatic meshing partitioning
+if [ -f "$(whereis -b libmetis.so | cut -d' ' -f2)" ]; then
+        CONFOPTS+=" --with-metis=1"
+        # parmetis support
+        if [ -f "/usr/include/parmetis.h" ]; then
+                CONFOPTS+=" --with-parmetis=1"
+        fi
+fi
+
+# # MPI4Py
+# if [ -n "$(pacman -Qsq mpi4py)" ]; then
+#     mpi4py_inc="$(pacman -Ql python-mpi4py | awk '/mpi4py.h$/{print $NF}')"
+#         CONFOPTS+=" --with-mpi4py=1"
+#     CONFOPTS+=" --with-mpi4py-include="
+#     CONFOPTS+="$(dirname $mpi4py_inc)"
+#     CONFOPTS+=" --with-mpi4py-lib="
+#     CONFOPTS+="$(pacman -Ql python-mpi4py | awk '/.*\.so$/{print $NF}' | tr ' \n' ',')"
+# fi
+
+# MUMPS: Sparse solver library
+if [ -f "$(whereis -b libmumps_common.so | cut -d' ' -f2)" ]; then
+        CONFOPTS+=" --with-mumps=1"
+    # MUMPS_LIBS="[/usr/lib/libcmumps.so,"
+    # MUMPS_LIBS+="/usr/lib/libdmumps.so,"
+    # MUMPS_LIBS+="/usr/lib/libsmumps.so,"
+    # MUMPS_LIBS+="/usr/lib/libzmumps.so,"
+    # MUMPS_LIBS+="/usr/lib/libmumps_common.so,"
+    # MUMPS_LIBS+="/usr/lib/libpord.so]"
+    # CONFOPTS+=" --with-mumps-lib=${MUMPS_LIBS}"
+    # CONFOPTS+=" --with-mumps-include=/usr/include"
+    # CONFOPTS+=" --with-mumps-dir=/usr/"
+fi
+
+# NetCDF
+if [ -f "$(whereis -b libnetcdf.so | cut -d' ' -f2)" ]; then
+        CONFOPTS+=" --with-netcdf=1"
+    CONFOPTS+=" --with-netcdf-pkg-config="
+    CONFOPTS+="$(dirname $(pkgconf --path netcdf))"
+fi
+
+# PNG
+if [ -f "$(whereis -b libpng.so | cut -d' ' -f2)" ]; then
+        CONFOPTS+=" --with-png=1"
+    CONFOPTS+=" --with-png-pkg-config="
+    CONFOPTS+="$(dirname $(pkgconf --path libpng))"
+fi
+
+# PNetCDF
+if [ -f "$(whereis -b libpnetcdf.so | cut -d' ' -f2)" ]; then
+        CONFOPTS+=" --with-pnetcdf=1"
+    CONFOPTS+=" --with-pnetcdf-pkg-config="
+    CONFOPTS+="$(dirname $(pkgconf --path pnetcdf))"
+fi
+
+# OpenBLAS: Linear algebra libraries
+OPENBLAS_SO="$(whereis -b libblas.so | cut -d' ' -f2)"
+if [ -f "${OPENBLAS_SO}" ]; then
+        CONFOPTS+=" --with-openblas=1"
+        # CONFOPTS+=" --with-openblas-lib=[-lopenblas,-lm,-lpthread,-lgfortran,-lm,-lpthread,-lgfortran]"
+        # CONFOPTS+=" --with-openblas-include=/usr/include"
+        CONFOPTS+=" --with-openblas-pkg-config="
+    CONFOPTS+="$(dirname $(pkgconf --path openblas))"
+        # CONFOPTS+=" --download-openblas=0"
+        CONFOPTS+=" --download-f2cblaslapack=0"
+fi
+
+# OpenCL: GPU computing
+# Check header files
+# (from opencl-headers package; how to do this in a consistent way?)
+OPENCL_INC="/usr/include/CL/cl.h"
+# Check library (find libOpenCL.so)
+OPENCL_SO="$(whereis -b libOpenCL.so | cut -d' ' -f2)"
+if [ -f "${OPENCL_SO}" ] && [ -f "${OPENCL_INC}" ]; then
+        CONFOPTS+=" --with-opencl=1"
+fi
+
+# # OpenGL (mesa)
+# # echo /lib64/libOpenGL.so /lib64/libGLX.so /lib64/libGLU.so
+# # FindOpenGL found both a legacy GL library:
+# #
+# #     OPENGL_gl_LIBRARY: /lib64/libGL.so
+# #
+# # and GLVND libraries for OpenGL and GLX:
+# #
+# #     OPENGL_opengl_LIBRARY: /lib64/libOpenGL.so
+# #     OPENGL_glx_LIBRARY: /lib64/libGLX.so
+# OPENGLIB="$(whereis -b libOpenGL.so | cut -d' ' -f2)"
+# if [ -f "${OPENGLIB}" ]; then
+# #    OPENGLIB+=",$(whereis -b libGL | cut -d' ' -f2),"
+#     # OPENGLIB+=",$(whereis -b libGLX | cut -d' ' -f2)"
+#     # OPENGLIB+=",$(whereis -b libGLX | cut -d' ' -f2)"
+#     # # OPENGLIB+="$(pacman -Ql mesa | awk '/\.so$/{print $NF}' | tr ' \n' ',')"
+#         # CONFOPTS+=" --with-opengl=1"
+#     # CONFOPTS+=" --with-opengl-lib=[${OPENGLIB}]"
+#     # CONFOPTS+=" --with-opengl-include=[/usr/include/GL/glew.h]"
+#         CONFOPTS+=" --with-opengl=1"
+#     CONFOPTS+=" --with-opengl-pkg-config="
+#     CONFOPTS+="$(dirname $(pkgconf --path opengl))"
+#     # CONFOPTS+="$(pacman -Ql mesa | awk '/\/include\/[^/]*\/$/{print $NF}' | tr ' \n' ',')]"
+# fi
+
+# OpenMP: 64 bits blas and lapack, multi-threaded
+if [ -f "$(whereis -b libomp.so | cut -d' ' -f2)" ]; then
+        CONFOPTS+=" --with-openmp=1"
+fi
+
+# # OpenMPI (dependency; should be found by pacman)
+# MPILIBDIR=$(dirname "$(pacman -Qlq openmpi | grep 'libmpi.so$')")
+# MPIINC="$(pacman -Qlq openmpi | grep 'mpi.h$')"
+# if [ -d "${MPILIBDIR}" ]; then
+#         CONFOPTS+=" --with-mpi=1"
+#     CONFOPTS+=" --with-mpi-dir=/usr/"
+# fi
+
+# Scalapack: Parallel memory linear algebra
+if [ -f "$(whereis -b libscalapack.so | cut -d' ' -f2)" ]; then
+        CONFOPTS+=" --with-scalapack=1"
+fi
+
+# Scotch: Partitioning with sparse matrices
+# TODO: programatic way
+SCOTCH_DIR="/usr/include/scotch"
+if [ -d "${SCOTCH_DIR}" ]; then
+        # SCOTCH_LIBS="$(ldconfig -p | awk '/scotch/{printf("'"${SCOTCH_DIR}"'/%s,", $1)}')"
+        SCOTCH_LIBS="libesmumps.so,libptscotch.so,libptscotcherr.so,libscotch.so,libscotcherr.so"
+
+        # Include bzip2 if scotch was built with bzip2 support
+        if [ -f "$(whereis -b libbz2.so | cut -d' ' -f2)" ]; then
+                SCOTCH_LIBS+=",${SCOTCH_DIR}/libbz2.so"
+        fi
+    # Add [], remove trailing ,
+        SCOTCH_LIBS="[${SCOTCH_LIBS}]"
+        CONFOPTS+=" --with-ptscotch=1"
+    CONFOPTS+=" --with-ptscotch-lib=${SCOTCH_LIBS}"
+    CONFOPTS+=" --with-ptscotch-include=${SCOTCH_DIR}"
+fi
+
+# SuiteSparse: Sparse matrix library
+if [ -f "$(whereis -b libsuitesparseconfig.so | cut -d' ' -f2)" ]; then
+        CONFOPTS+=" --with-suitesparse=1"
+fi
+
+# SuperLU: Subroutines for sparsse linear systems
+# TODO: programatic way
+SUPERLU_DIR="/usr/include/superlu"
+if [ -d "${SUPERLU_DIR}" ]; then
+        CONFOPTS+=" --with-superlu=1 --with-superlu-lib=-lsuperlu --with-superlu-include=${SUPERLU_DIR}"
+fi
+
+# YAML: configuration files
+# Check library (find libyaml.so)
+OPENCL_SO="$(whereis -b libyaml.so | cut -d' ' -f2)"
+if [ -f "${OPENCL_SO}" ]; then
+        CONFOPTS+=" --with-yaml=1"
+fi
+
+# X: to enable ksp_xmonitor
+LIBX11="$(whereis -b libX11.so | cut -d' ' -f2)"
+LIBX11_DIR="$(dirname ${LIBX11})"
+if [ -f "${LIBX11}" ]; then
+    LIBX11_INC="--keep-system-cflags --cflags-only-I";
+    LIBX11_INC="$(pkgconf ${LIBX11_INC} x11)";
+        CONFOPTS+=" --with-x-lib=[${LIBX11_DIR}/";
+    # As per X11.pc, it seems that xcb.so is needed
+    CONFOPTS+="libX11-xcb.so,${LIBX11}]"
+    CONFOPTS+=" --with-x-include=${LIBX11_INC//-I/}"
+fi
+
+# ZLIB
+if [ -f "$(whereis -b libzlib.so | cut -d' ' -f2)" ]; then
+        CONFOPTS+=" --with-zlib=1"
+    CONFOPTS+=" --with-zlib-pkg-config="
+    CONFOPTS+="$(dirname $(pkgconf --path zlib))"
+fi
+
+# # trilinos support
+#
+# if [ "${TRILINOS_DIR}" ]; then
+#         CONFOPTS+=" --with-ml-dir=${TRILINOS_DIR}"
+#         # boost support (may be useful for trilinos)
+#         CONFOPTS+=" --with-boost=1"
+# fi
+
+# Incompatible with complex
+# # sundials support
+# SUNDIALS_DIR="/usr/include/sundials/"
+# if [ -d "${SUNDIALS_DIR}" ]; then
+#         CONFOPTS+=" --with-sundials=1 --with-sundials-include=${SUNDIALS_DIR}"
+# fi
+
+# # pastix support (non-free)
+# 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+=" --with-pastix=1 --with-pastix-lib=${PASTIX_LIBS} --with-pastix-include=${PASTIX_DIR}"
+# fi
+
+echo "${CONFOPTS}"