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

test_optdepends.sh (9764B)


      1 #!/bin/sh
      2 
      3 # Test if external packages for PETSC are installed
      4 
      5 # Fair attempt to find the directory of a header file
      6 find_inc () {
      7     local INC;
      8     INC="$(find_so "$1")";
      9     # * Faster first
     10     if [ -f "${INC}" ]; then
     11         INC="${INC}";
     12     elif [ -f "${INC}"/"$1" ]; then
     13         # ** The header is inside INC (a directory) e.g.
     14         #    /usr/include/scotch
     15         #    /usr/include/scotch/scotch.h
     16         INC="${INC}"/"$1"
     17     elif [ -d "${INC}" ]; then
     18         # ** INC is a directory, and the header is deep inside
     19         #    (hopefully faster than `pacman')
     20         INC="$(find "${INC}" -name "$1" -print -quit)";
     21     elif [ ! "x$2" == "x" ]; then
     22         # ** May be there is a package?
     23         pacman -Qs "$2" 2>&1>/dev/null && \
     24             INC="$(pacman -Qlq "$2" | grep "/$1\$" || printf "")";
     25     fi;
     26     dirname "${INC}"
     27 }
     28 
     29 # Find a shared object (library; .so extension)
     30 #   example: find_so libboost_mpi
     31 find_so () {
     32     whereis -b "$1" | cut -d' ' -f2
     33 }
     34 
     35 # Find directory where a pkg-config file is
     36 #   example: find_pc glut
     37 find_pc () {
     38     dirname "$(pkgconf --path "$1")"
     39 }
     40 
     41 ONLY_INC="--keep-system-cflags --cflags-only-I";
     42 
     43 type mpicc >/dev/null && \
     44     CONFOPTS="${CONFOPTS} --with-cc=mpicc"
     45 type mpicxx >/dev/null && \
     46     CONFOPTS="${CONFOPTS} --with-cxx=mpicxx"
     47 type mpifort >/dev/null && \
     48     CONFOPTS="${CONFOPTS} --with-fc=mpifort"
     49 
     50 # BOOST: Free peer-reviewed portable C++ source libraries
     51 if [ -f "$(find_so libboost_mpi.so)" ]; then
     52     CONFOPTS="${CONFOPTS} --with-boost=1"
     53 fi;
     54 
     55 # CGNS: Recording and recovering computer data
     56 if [ -f "$(find_so libcgns.so)" ]; then
     57 	CONFOPTS="${CONFOPTS} --with-cgns=1"
     58 fi
     59 
     60 # eigen: Lightweight C++ template library for vector and
     61 # matrix math
     62 EIGEN_DIR="$(pkgconf --cflags-only-I eigen3)"
     63 EIGEN_DIR="${EIGEN_DIR##-I}"
     64 if [ -d "${EIGEN_DIR}" ]; then
     65 	CONFOPTS="${CONFOPTS} --with-eigen=1"
     66 	CONFOPTS="${CONFOPTS} --with-eigen-include=${EIGEN_DIR}"
     67 fi
     68 
     69 # fftw: Fast-Fourier Transform
     70 if [ -f "$(find_so libfftw3_mpi.so)" ]; then
     71 	CONFOPTS="${CONFOPTS} --with-fftw=1"
     72 fi
     73 
     74 # GDB: GNU debugger
     75 if [ -f "$(find_so gdb)" ]; then
     76 	CONFOPTS="${CONFOPTS} --with-debugger=gdb"
     77 fi
     78 
     79 # # GLUT (requires OpenGL)
     80 # if [ -f "$(find_so libglut.so)" ]; then
     81 # 	CONFOPTS="${CONFOPTS} --with-glut=1"
     82 #     CONFOPTS="${CONFOPTS} --with-glut-pkg-config="
     83 #     CONFOPTS="${CONFOPTS} $(find_pc glut)"
     84 # fi
     85 
     86 # HDF5: large files
     87 if [[ "$(h5stat -V)" ]]; then
     88 	CONFOPTS="${CONFOPTS} --with-hdf5=1"
     89 fi
     90 
     91 # hwloc: abstraction of hierarchical architectures
     92 if [ -f "$(find_so libhwloc.so)" ]; then
     93 	CONFOPTS="${CONFOPTS} --with-hwloc=1"
     94     CONFOPTS="${CONFOPTS} --with-hwloc-pkg-config="
     95     CONFOPTS="${CONFOPTS} $(find_pc hwloc)"
     96 fi
     97 
     98 # Hypre: Large and sparse linear with massive parallel
     99 # computing
    100 HYPRE_SO="$(find_so libHYPRE.so)"
    101 if [ -f "${HYPRE_SO}" ]; then
    102 	CONFOPTS="${CONFOPTS} --with-hypre=1"
    103 	CONFOPTS="${CONFOPTS} --with-hypre-lib=${HYPRE_SO}"
    104     HYPRE_INC="$(find_inc "HYPRE.h" "hypre")"
    105 	CONFOPTS="${CONFOPTS} --with-hypre-include=${HYPRE_INC}"
    106 fi
    107 
    108 # MED: Data Modelization and Exchanges (meshes)
    109 if [ -f "$(find_so libmed.so)" ]; then
    110 	CONFOPTS="${CONFOPTS} --with-med=1"
    111 fi
    112 
    113 # METIS: Automatic meshing partitioning
    114 if [ -f "$(find_so libmetis.so)" ]; then
    115 	CONFOPTS="${CONFOPTS} --with-metis=1"
    116 	# parmetis support
    117 	if [ -f "/usr/include/parmetis.h" ]; then
    118 		CONFOPTS="${CONFOPTS} --with-parmetis=1"
    119 	fi
    120 fi
    121 
    122 # # MPI4Py
    123 # if [ -n "$(pacman -Qsq mpi4py)" ]; then
    124 #     mpi4py_inc="$(pacman -Ql python-mpi4py | awk '/mpi4py.h$/{print $NF}')"
    125 # 	CONFOPTS="${CONFOPTS} --with-mpi4py=1"
    126 #     CONFOPTS="${CONFOPTS} --with-mpi4py-include="
    127 #     CONFOPTS="${CONFOPTS} $(dirname "${mpi4py_inc}")"
    128 #     CONFOPTS="${CONFOPTS} --with-mpi4py-lib="
    129 #     CONFOPTS="${CONFOPTS} $(pacman -Ql python-mpi4py | awk '/.*\.so$/{print $NF}' | tr ' \n' ',')"
    130 # fi
    131 
    132 # MUMPS: Sparse solver library
    133 if [ -f "$(find_so libmumps_common.so)" ]; then
    134 	CONFOPTS="${CONFOPTS} --with-mumps=1"
    135 fi
    136 
    137 # NetCDF
    138 if [ -f "$(find_so libnetcdf.so)" ]; then
    139 	CONFOPTS="${CONFOPTS} --with-netcdf=1"
    140     CONFOPTS="${CONFOPTS} --with-netcdf-pkg-config="
    141     CONFOPTS="${CONFOPTS} $(find_pc netcdf)"
    142 fi
    143 
    144 # PNG
    145 if [ -f "$(find_so libpng.so)" ]; then
    146 	CONFOPTS="${CONFOPTS} --with-png=1"
    147     CONFOPTS="${CONFOPTS} --with-png-pkg-config="
    148     CONFOPTS="${CONFOPTS} $(find_pc libpng)"
    149 fi
    150 
    151 # PNetCDF
    152 if [ -f "$(find_so libpnetcdf.so)" ]; then
    153 	CONFOPTS="${CONFOPTS} --with-pnetcdf=1"
    154     CONFOPTS="${CONFOPTS} --with-pnetcdf-pkg-config="
    155     CONFOPTS="${CONFOPTS} $(find_pc pnetcdf)"
    156 fi
    157 
    158 # OpenBLAS: Linear algebra libraries
    159 BLAS_SO="$(find_so libblas.so)"
    160 OPENBLAS_SO="$(find_so libopenblas.so)"
    161 LAPACK_SO="$(find_so liblapack.so)"
    162 if [ -f "${BLAS_SO}" ] && [ -f "${OPENBLAS_SO}" ] \
    163        && [ -f "${LAPACK_SO}" ]; then
    164     # With help from Satish Balay
    165     # @ 3.15.4.33.g0bac13e0fe9 2021-09-21
    166     #  nm -AoD /usr/lib64/libopenblas.so | grep dgetrs_
    167     CONFOPTS="${CONFOPTS} --with-blaslapack-lib=[${LAPACK_SO},${BLAS_SO}]"
    168 fi
    169 
    170 # OpenCL: GPU computing
    171 # Check header files
    172 # (from opencl-headers package; how to do this in a consistent way?)
    173 OPENCL_INC="/usr/include/CL/cl.h"
    174 # Check library (find libOpenCL.so)
    175 OPENCL_SO="$(find_so libOpenCL.so)"
    176 if [ -f "${OPENCL_SO}" ] && [ -f "${OPENCL_INC}" ]; then
    177 	CONFOPTS="${CONFOPTS} --with-opencl=1"
    178 fi
    179 
    180 # # OpenGL (mesa)
    181 # # echo /lib64/libOpenGL.so /lib64/libGLX.so /lib64/libGLU.so
    182 # # FindOpenGL found both a legacy GL library:
    183 # #
    184 # #     OPENGL_gl_LIBRARY: /lib64/libGL.so
    185 # #
    186 # # and GLVND libraries for OpenGL and GLX:
    187 # #
    188 # #     OPENGL_opengl_LIBRARY: /lib64/libOpenGL.so
    189 # #     OPENGL_glx_LIBRARY: /lib64/libGLX.so
    190 # OPENGLIB="$(find_so libOpenGL.so)"
    191 # if [ -f "${OPENGLIB}" ]; then
    192 # #    OPENGLIB+=",$(find_so libGL),"
    193 #     # OPENGLIB+=",$(find_so libGLX)"
    194 #     # OPENGLIB+=",$(find_so libGLX)"
    195 #     # # OPENGLIB+="$(pacman -Ql mesa | awk '/\.so$/{print $NF}' | tr ' \n' ',')"
    196 # 	# CONFOPTS="${CONFOPTS} --with-opengl=1"
    197 #     # CONFOPTS="${CONFOPTS} --with-opengl-lib=[${OPENGLIB}]"
    198 #     # CONFOPTS="${CONFOPTS} --with-opengl-include=[/usr/include/GL/glew.h]"
    199 # 	CONFOPTS="${CONFOPTS} --with-opengl=1"
    200 #     CONFOPTS="${CONFOPTS} --with-opengl-pkg-config="
    201 #     CONFOPTS="${CONFOPTS} $(dirname $(pkgconf --path opengl))"
    202 #     # CONFOPTS="${CONFOPTS} $(pacman -Ql mesa | awk '/\/include\/[^/]*\/$/{print $NF}' | tr ' \n' ',')]"
    203 # fi
    204 
    205 # OpenMP: 64 bits blas and lapack, multi-threaded
    206 if [ -f "$(find_so libomp.so)" ]; then
    207 	CONFOPTS="${CONFOPTS} --with-openmp=1"
    208 fi
    209 
    210 # # OpenMPI (dependency; should be found by pacman)
    211 # MPILIBDIR=$(dirname "$(pacman -Qlq openmpi | grep 'libmpi.so$')")
    212 # MPIINC="$(pacman -Qlq openmpi | grep 'mpi.h$')"
    213 # if [ -d "${MPILIBDIR}" ]; then
    214 # 	CONFOPTS="${CONFOPTS} --with-mpi=1"
    215 #     CONFOPTS="${CONFOPTS} --with-mpi-dir=/usr/"
    216 # fi
    217 
    218 # Scalapack: Parallel memory linear algebra
    219 if [ -f "$(find_so libscalapack.so)" ]; then
    220 	CONFOPTS="${CONFOPTS} --with-scalapack=1"
    221 fi
    222 
    223 # Scotch: Partitioning with sparse matrices
    224 # TODO: general (non-pacman) way
    225 PTSCOTCH_SO="$(find_so libptscotch.so)"
    226 if [ -f "${PTSCOTCH_SO}" ]; then
    227 	CONFOPTS="${CONFOPTS} --with-ptscotch=1"
    228     SCOTCH_LIBS=$(pacman -Qlq scotch | grep '.so$'| tr '\n' ',')
    229     # Check if libscotch was compiled with bz2
    230     if [ ! -z "$(nm -D $(find_so libscotch.so) | grep bz)" ]; then
    231         CONFOPTS="${CONFOPTS}$(find_so libbz2.so)"
    232     else
    233         # Remove trailing ,
    234         SCOTCH_LIBS="${SCOTCH_LIBS%%,}"
    235     fi;
    236     CONFOPTS="${CONFOPTS} --with-ptscotch-lib=[${SCOTCH_LIBS}]"
    237     CONFOPTS="${CONFOPTS} --with-ptscotch-include="
    238     CONFOPTS="${CONFOPTS}$(find_inc ptscotch.h scotch)"
    239 fi
    240 
    241 # SuiteSparse: Sparse matrix library
    242 if [ -f "$(find_so libsuitesparseconfig.so)" ]; then
    243 	CONFOPTS="${CONFOPTS} --with-suitesparse=1"
    244 fi
    245 
    246 # SuperLU: Subroutines for sparsse linear systems
    247 # TODO: programatic way
    248 SUPERLU_DIR="/usr/include/superlu"
    249 if [ -d "${SUPERLU_DIR}" ]; then
    250 	CONFOPTS="${CONFOPTS} --with-superlu=1"
    251 	CONFOPTS="${CONFOPTS} --with-superlu-lib=-lsuperlu"
    252 	CONFOPTS="${CONFOPTS} --with-superlu-include=${SUPERLU_DIR}"
    253 fi
    254 
    255 # YAML: configuration files
    256 # Check library (find libyaml.so)
    257 OPENCL_SO="$(find_so libyaml.so)"
    258 if [ -f "${OPENCL_SO}" ]; then
    259 	CONFOPTS="${CONFOPTS} --with-yaml=1"
    260 fi
    261 
    262 # X: to enable ksp_xmonitor
    263 LIBX11_SO="$(find_so libX11.so)"
    264 LIBX11_DIR="$(dirname ${LIBX11_SO})"
    265 if [ -f "${LIBX11_SO}" ]; then
    266     LIBX11_INC="$(pkgconf ${ONLY_INC} x11)";
    267     LIBX11_INC="${LIBX11_INC//-I/}";
    268 	CONFOPTS="${CONFOPTS} --with-x-lib=[${LIBX11_DIR}/";
    269     # As per X11.pc, it seems that xcb.so is needed
    270     CONFOPTS="${CONFOPTS}libX11-xcb.so,${LIBX11_SO}]"
    271     CONFOPTS="${CONFOPTS} --with-x-include=${LIBX11_INC}"
    272 fi
    273 
    274 # ZLIB
    275 if [ -f "$(find_so libzlib.so)" ]; then
    276 	CONFOPTS="${CONFOPTS} --with-zlib=1"
    277     CONFOPTS="${CONFOPTS} --with-zlib-pkg-config="
    278     CONFOPTS="${CONFOPTS} $(find_pc zlib)"
    279 fi
    280 
    281 # # trilinos support
    282 #
    283 # if [ "${TRILINOS_DIR}" ]; then
    284 # 	CONFOPTS="${CONFOPTS} --with-ml-dir=${TRILINOS_DIR}"
    285 # 	# boost support (may be useful for trilinos)
    286 # 	CONFOPTS="${CONFOPTS} --with-boost=1"
    287 # fi
    288 
    289 # Incompatible with complex
    290 # # sundials support
    291 # SUNDIALS_DIR="/usr/include/sundials/"
    292 # if [ -d "${SUNDIALS_DIR}" ]; then
    293 # 	CONFOPTS="${CONFOPTS} --with-sundials=1"
    294 # 	CONFOPTS="${CONFOPTS} --with-sundials-include=${SUNDIALS_DIR}"
    295 # fi
    296 
    297 # # pastix support (non-free)
    298 # PASTIX_CONF=$(which pastix-conf)
    299 # if [ -f "${PASTIX_CONF}" ]; then
    300 # 	PASTIX_DIR="$($PASTIX_CONF --incs | sed 's/-I//')"
    301 # 	if [ ! -d ${PASTIX_DIR} ]; then
    302 # 		PASTIX_DIR="[]"
    303 # 	fi
    304 # 	#PASTIX_LIBS="$($PASTIX_CONF --libs)"
    305 # 	PASTIX_LIBS="[libpastix.a,librt.so,libhwloc.so,libpthread.a]"
    306 # 	CONFOPTS="${CONFOPTS} --with-pastix=1"
    307 # 	CONFOPTS="${CONFOPTS} --with-pastix-lib=${PASTIX_LIBS}"
    308 # 	CONFOPTS="${CONFOPTS} --with-pastix-include=${PASTIX_DIR}"
    309 # fi
    310 
    311 echo "${CONFOPTS}"