test_optdepends.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #!/bin/bash
  2. # Test if external packages for PETSC are installed
  3. # Fair attempt to find the directory of a header file
  4. find_inc () {
  5. local INC;
  6. INC="$(find_so "$1")";
  7. # * Faster first
  8. if [ -f "${INC}" ]; then
  9. INC="${INC}";
  10. elif [ -f "${INC}"/"$1" ]; then
  11. # ** The header is inside INC (a directory) e.g.
  12. # /usr/include/scotch
  13. # /usr/include/scotch/scotch.h
  14. INC="${INC}"/"$1"
  15. elif [ -d "${INC}" ]; then
  16. # ** INC is a directory, and the header is deep inside
  17. # (hopefully faster than `pacman')
  18. INC="$(find "${INC}" -name "$1" -print -quit)";
  19. elif [ ! "x$2" == "x" ]; then
  20. # ** May be there is a package?
  21. pacman -Qs "$2" 2>&1>/dev/null && \
  22. INC="$(pacman -Qlq "$2" | grep "/$1\$" || printf "")";
  23. fi;
  24. dirname "${INC}"
  25. }
  26. # Find a shared object (library; .so extension)
  27. # example: find_so libboost_mpi
  28. find_so () {
  29. whereis -b "$1" | cut -d' ' -f2
  30. }
  31. CONFOPTS=""
  32. ## External downloads
  33. #for external_pkg in hypre; do
  34. #CONFOPTS="${CONFOPTS} --download-${external_pkg}=1"
  35. #done
  36. # Hypre: Large and sparse linear with massive parallel
  37. # computing
  38. # CONFOPTS+=" --with-hypre=0"
  39. HYPRE_SO="$(find_so libHYPRE.so)"
  40. if [ -f "${HYPRE_SO}" ]; then
  41. CONFOPTS="${CONFOPTS} --with-hypre=1"
  42. CONFOPTS="${CONFOPTS} --with-hypre-lib=${HYPRE_SO}"
  43. HYPRE_INC="$(find_inc "HYPRE.h" "hypre")"
  44. CONFOPTS="${CONFOPTS} --with-hypre-include=${HYPRE_INC}"
  45. fi
  46. # FFTW
  47. if [ -f "/usr/lib/pkgconfig/fftw3.pc" ]; then
  48. CONFOPTS="${CONFOPTS} --with-fftw=1"
  49. fi
  50. # HDF5
  51. if [ -f "/usr/lib/pkgconfig/hdf5.pc" ]; then
  52. CONFOPTS="${CONFOPTS} --with-hdf5=1 --with-hdf5-fortran-bindings=1"
  53. fi
  54. # (Par)METIS
  55. if [ -f "/usr/include/metis.h" ]; then
  56. CONFOPTS="${CONFOPTS} --with-metis=1"
  57. if [ -f "/usr/include/parmetis.h" ]; then
  58. CONFOPTS="${CONFOPTS} --with-parmetis=1"
  59. fi
  60. fi
  61. # MUMPS
  62. if [ -f "/usr/lib/libmumps_common.so" ]; then
  63. CONFOPTS="${CONFOPTS} --with-mumps=1"
  64. fi
  65. # PaStiX https://gitlab.com/petsc/petsc/-/issues/1259
  66. #if [ -f "/usr/lib/pkgconfig/pastic.pc" ]; then
  67. # CONFOPTS="${CONFOPTS} --with-pastix=1"
  68. #fi
  69. # ScaLAPACK
  70. if [ -f "/usr/lib/pkgconfig/scalapack.pc" ]; then
  71. CONFOPTS="${CONFOPTS} --with-scalapack=1"
  72. fi
  73. # Scotch: Partitioning with sparse matrices
  74. # TODO: general (non-pacman) way
  75. PTSCOTCH_SO="$(find_so libptscotch.so)"
  76. if [ -f "${PTSCOTCH_SO}" ]; then
  77. CONFOPTS="${CONFOPTS} --with-ptscotch=1"
  78. SCOTCH_LIBS=$(pacman -Qlq scotch | grep '.so$'| tr '\n' ',')
  79. # Check if libscotch was compiled with bz2
  80. if [ ! -z "$(nm -D $(find_so libscotch.so) | grep bz)" ]; then
  81. SCOTCH_LIBS="${SCOTCH_LIBS}$(find_so libbz2.so)"
  82. else
  83. # Remove trailing ,
  84. SCOTCH_LIBS="${SCOTCH_LIBS%%,}"
  85. fi;
  86. CONFOPTS="${CONFOPTS} --with-ptscotch-lib=[${SCOTCH_LIBS}]"
  87. CONFOPTS="${CONFOPTS} --with-ptscotch-include="
  88. CONFOPTS="${CONFOPTS}$(find_inc ptscotch.h scotch)"
  89. fi
  90. # SuiteSparse
  91. if [ -f "/usr/include/SuiteSparse_config.h" ]; then
  92. CONFOPTS="${CONFOPTS} --with-suitesparse=1"
  93. fi
  94. # SuperLU
  95. if [ -f "/usr/lib/pkgconfig/superlu.pc" ]; then
  96. CONFOPTS="${CONFOPTS} --with-superlu-lib=-lsuperlu --with-superlu-include=/usr/include/superlu"
  97. fi
  98. # SuperLU_DIST
  99. if [ -f "/usr/lib/pkgconfig/superlu_dist.pc" ]; then
  100. CONFOPTS="${CONFOPTS} --with-superlu_dist-lib=-lsuperlu_dist --with-superlu_dist-include=/usr/include/superlu_dist"
  101. fi
  102. # Triangle
  103. if [ -f "/usr/lib/libtriangle.so" ]; then
  104. CONFOPTS="${CONFOPTS} --with-triangle=1"
  105. fi
  106. # Trilinos (ML)
  107. if [ -f "/usr/lib/libml.so" ]; then
  108. CONFOPTS="${CONFOPTS} --with-ml=1"
  109. # Add boost support (may be useful for trilinos)
  110. CONFOPTS="${CONFOPTS} --with-boost=1"
  111. fi
  112. echo "${CONFOPTS}"