123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- #!/bin/bash
- # 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 () {
- whereis -b "$1" | cut -d' ' -f2
- }
- CONFOPTS=""
- ## External downloads
- #for external_pkg in hypre; do
- #CONFOPTS="${CONFOPTS} --download-${external_pkg}=1"
- #done
- # Hypre: Large and sparse linear with massive parallel
- # computing
- # CONFOPTS+=" --with-hypre=0"
- HYPRE_SO="$(find_so libHYPRE.so)"
- if [ -f "${HYPRE_SO}" ]; then
- CONFOPTS="${CONFOPTS} --with-hypre=1"
- CONFOPTS="${CONFOPTS} --with-hypre-lib=${HYPRE_SO}"
- HYPRE_INC="$(find_inc "HYPRE.h" "hypre")"
- CONFOPTS="${CONFOPTS} --with-hypre-include=${HYPRE_INC}"
- fi
- # FFTW
- if [ -f "/usr/lib/pkgconfig/fftw3.pc" ]; then
- CONFOPTS="${CONFOPTS} --with-fftw=1"
- fi
- # HDF5
- if [ -f "/usr/lib/pkgconfig/hdf5.pc" ]; then
- CONFOPTS="${CONFOPTS} --with-hdf5=1 --with-hdf5-fortran-bindings=1"
- fi
- # (Par)METIS
- if [ -f "/usr/include/metis.h" ]; then
- CONFOPTS="${CONFOPTS} --with-metis=1"
- if [ -f "/usr/include/parmetis.h" ]; then
- CONFOPTS="${CONFOPTS} --with-parmetis=1"
- fi
- fi
- # MUMPS
- if [ -f "/usr/lib/libmumps_common.so" ]; then
- CONFOPTS="${CONFOPTS} --with-mumps=1"
- fi
- # PaStiX https://gitlab.com/petsc/petsc/-/issues/1259
- #if [ -f "/usr/lib/pkgconfig/pastic.pc" ]; then
- # CONFOPTS="${CONFOPTS} --with-pastix=1"
- #fi
- # ScaLAPACK
- if [ -f "/usr/lib/pkgconfig/scalapack.pc" ]; then
- CONFOPTS="${CONFOPTS} --with-scalapack=1"
- fi
- # Scotch: Partitioning with sparse matrices
- # TODO: general (non-pacman) way
- PTSCOTCH_SO="$(find_so libptscotch.so)"
- if [ -f "${PTSCOTCH_SO}" ]; then
- CONFOPTS="${CONFOPTS} --with-ptscotch=1"
- 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
- SCOTCH_LIBS="${SCOTCH_LIBS}$(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
- if [ -f "/usr/include/SuiteSparse_config.h" ]; then
- CONFOPTS="${CONFOPTS} --with-suitesparse=1"
- fi
- # SuperLU
- if [ -f "/usr/lib/pkgconfig/superlu.pc" ]; then
- CONFOPTS="${CONFOPTS} --with-superlu-lib=-lsuperlu --with-superlu-include=/usr/include/superlu"
- fi
- # SuperLU_DIST
- if [ -f "/usr/lib/pkgconfig/superlu_dist.pc" ]; then
- CONFOPTS="${CONFOPTS} --with-superlu_dist-lib=-lsuperlu_dist --with-superlu_dist-include=/usr/include/superlu_dist"
- fi
- # Triangle
- if [ -f "/usr/lib/libtriangle.so" ]; then
- CONFOPTS="${CONFOPTS} --with-triangle=1"
- fi
- # Trilinos (ML)
- if [ -f "/usr/lib/libml.so" ]; then
- CONFOPTS="${CONFOPTS} --with-ml=1"
- # Add boost support (may be useful for trilinos)
- CONFOPTS="${CONFOPTS} --with-boost=1"
- fi
- echo "${CONFOPTS}"
|