tbetter way to find HYPRE (not working for A. Damsgaard) and PTScotch - petsc-git-PKGBUILD - build template for non-complex PETSC with petsc4py
 (HTM) git clone git://src.adamsgaard.dk/petsc-git-PKGBUILD
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
 (DIR) commit 2d45841652059d613ca65763f2d2cff899bc82a2
 (DIR) parent 6a822f8eace2d237f67494d94b5a67ca8bb5dbfa
 (HTM) Author: eDgar <eDgar_|at|_openmail.cc>
       Date:   Mon, 27 Sep 2021 16:41:55 -0500
       
       better way to find HYPRE (not working for A. Damsgaard) and PTScotch
       
       Diffstat:
         M .SRCINFO                            |       6 +++---
         M PKGBUILD                            |       2 +-
         M test_optdepends.sh                  |      57 ++++++++++++++++++++++---------
       
       3 files changed, 44 insertions(+), 21 deletions(-)
       ---
 (DIR) diff --git a/.SRCINFO b/.SRCINFO
       t@@ -14,7 +14,7 @@ pkgbase = petsc-git
                makedepends = git
                makedepends = cython
                makedepends = chrpath
       -        makedepends = hypre
       +        makedepends = hypre=2.18.2
                depends = openmpi
                depends = lapack
                depends = fftw
       t@@ -22,7 +22,7 @@ pkgbase = petsc-git
                depends = cython
                depends = python-mpi4py
                depends = python-numpy
       -        depends = eigen
       +        depends = eigen>=3
                depends = openblas
                options = !staticlibs
                source = git+https://gitlab.com/petsc/petsc.git#branch=release
       t@@ -30,7 +30,7 @@ pkgbase = petsc-git
                source = test_optdepends.sh
                sha512sums = SKIP
                sha512sums = b6a1d48aab1c2639a4c1cbd8b313ace253f1c36eedaa3de3508ffbd6060e1def99e2f516ed9bb509307f614b41791d09342e2c2280c0b2c25dda1092b0e569d2
       -        sha512sums = 77b257ea28a9f109c48c8447ab2db4204f6dba715626f15e916ec8f54c18d01588aa4d760c30b9a58659eefddafc7b54319525f8d89a693fd5305144eba7fc28
       +        sha512sums = a4e064c08730058d63120a22c12657a100e5330546d66c44bb85e5bf84df80a23a729b0266af3efce2c8148f0266ddca99eaf9c8ea88d323cebe1d0c18c45d09
        
        pkgname = petsc-git
                optdepends = boost: Free peer-reviewed portable C++ source libraries
 (DIR) diff --git a/PKGBUILD b/PKGBUILD
       t@@ -22,7 +22,7 @@ source=(git+${url}.git#branch=release
                test_optdepends.sh)
        sha512sums=('SKIP'
                    'b6a1d48aab1c2639a4c1cbd8b313ace253f1c36eedaa3de3508ffbd6060e1def99e2f516ed9bb509307f614b41791d09342e2c2280c0b2c25dda1092b0e569d2'
       -            '77b257ea28a9f109c48c8447ab2db4204f6dba715626f15e916ec8f54c18d01588aa4d760c30b9a58659eefddafc7b54319525f8d89a693fd5305144eba7fc28')
       +            'a4e064c08730058d63120a22c12657a100e5330546d66c44bb85e5bf84df80a23a729b0266af3efce2c8148f0266ddca99eaf9c8ea88d323cebe1d0c18c45d09')
        
        _config=linux-c-opt
        _install_dir="/usr"
 (DIR) diff --git a/test_optdepends.sh b/test_optdepends.sh
       t@@ -2,6 +2,30 @@
        
        # Test if external packages for PETSC are installed
        
       +# Fair attempt to find the directory of a header file
       +find_inc () {
       +    local INC;
       +    INC="$(find_so "$1")";
       +    # * Faster first
       +    if [ -f "${INC}" ]; then
       +        INC="${INC}";
       +    elif [ -f "${INC}"/"$1" ]; then
       +        # ** The header is inside INC (a directory) e.g.
       +        #    /usr/include/scotch
       +        #    /usr/include/scotch/scotch.h
       +        INC="${INC}"/"$1"
       +    elif [ -d "${INC}" ]; then
       +        # ** INC is a directory, and the header is deep inside
       +        #    (hopefully faster than `pacman')
       +        INC="$(find "${INC}" -name "$1" -print -quit)";
       +    elif [ ! "x$2" == "x" ]; then
       +        # ** May be there is a package?
       +        pacman -Qs "$2" 2>&1>/dev/null && \
       +            INC="$(pacman -Qlq "$2" | grep "/$1\$" || printf "")";
       +    fi;
       +    dirname "${INC}"
       +}
       +
        # Find a shared object (library; .so extension)
        #   example: find_so libboost_mpi
        find_so () {
       t@@ -77,7 +101,8 @@ HYPRE_SO="$(find_so libHYPRE.so)"
        if [ -f "${HYPRE_SO}" ]; then
                CONFOPTS="${CONFOPTS} --with-hypre=1"
                CONFOPTS="${CONFOPTS} --with-hypre-lib=${HYPRE_SO}"
       -        CONFOPTS="${CONFOPTS} --with-hypre-include=/usr/include"
       +    HYPRE_INC="$(find_inc "HYPRE.h" "hypre")"
       +        CONFOPTS="${CONFOPTS} --with-hypre-include=${HYPRE_INC}"
        fi
        
        # MED: Data Modelization and Exchanges (meshes)
       t@@ -196,23 +221,21 @@ if [ -f "$(find_so libscalapack.so)" ]; then
        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"
       -        SCOTCH_LIBS="${SCOTCH_LIBS},libptscotcherr.so,libscotch.so"
       -        SCOTCH_LIBS="${SCOTCH_LIBS},libscotcherr.so"
       -
       -        # Include bzip2 if scotch was built with bzip2 support
       -        if [ -f "$(find_so libbz2.so)" ]; then
       -                SCOTCH_LIBS="${SCOTCH_LIBS},${SCOTCH_DIR}/libbz2.so"
       -        fi
       -    # Add [], remove trailing ,
       -        SCOTCH_LIBS="[${SCOTCH_LIBS}]"
       +# TODO: general (non-pacman) way
       +PTSCOTCH_SO="$(find_so libptscotch.so)"
       +if [ -f "${PTSCOTCH_SO}" ]; then
                CONFOPTS="${CONFOPTS} --with-ptscotch=1"
       -    CONFOPTS="${CONFOPTS} --with-ptscotch-lib=${SCOTCH_LIBS}"
       -    CONFOPTS="${CONFOPTS} --with-ptscotch-include=${SCOTCH_DIR}"
       +    SCOTCH_LIBS=$(pacman -Qlq scotch | grep '.so$'| tr '\n' ',')
       +    # Check if libscotch was compiled with bz2
       +    if [ ! -z "$(nm -D $(find_so libscotch.so) | grep bz)" ]; then
       +        CONFOPTS="${CONFOPTS}$(find_so libbz2.so)"
       +    else
       +        # Remove trailing ,
       +        SCOTCH_LIBS="${SCOTCH_LIBS%%,}"
       +    fi;
       +    CONFOPTS="${CONFOPTS} --with-ptscotch-lib=[${SCOTCH_LIBS}]"
       +    CONFOPTS="${CONFOPTS} --with-ptscotch-include="
       +    CONFOPTS="${CONFOPTS}$(find_inc ptscotch.h scotch)"
        fi
        
        # SuiteSparse: Sparse matrix library