@@ -36,7 +36,7 @@ find_shlib()
36
36
lib_path=" $1 "
37
37
if [ -f " $lib_path " ]; then
38
38
if [ " $UNAME " = " Linux" ]; then
39
- ldd " $lib_path " | grep $2 | grep -v " not found " | cut -d ' ' -f3 | xargs
39
+ " ${PATCHELF} " --print-needed " $lib_path " | grep $2 | xargs
40
40
else # $UNAME is "Darwin", we only have two options, see above
41
41
otool -L " $lib_path " | grep $2 | cut -d' ' -f1 | xargs
42
42
fi
@@ -50,7 +50,7 @@ find_shlib_dir()
50
50
# only get something like `@rpath/libgfortran.5.dylib` when inspecting the
51
51
# libraries. We can, as a last resort, ask `$FC` directly what the full
52
52
# filepath for this library is, but only if we don't have a direct path to it:
53
- if [ $( dirname " $1 " ) = " @rpath" ]; then
53
+ if [ $( dirname " $1 " ) = " @rpath" ] || [ $( dirname " $1 " ) = " . " ] ; then
54
54
dirname " $( $FC -print-file-name=" $( basename " $1 " ) " 2> /dev/null) "
55
55
else
56
56
dirname " $1 " 2> /dev/null
@@ -62,19 +62,25 @@ for lib in lapack blas openblas; do
62
62
for private_libname in ${private_libdir} /lib$lib * .$SHLIB_EXT * ; do
63
63
# Find the paths to the libraries we're interested in. These are almost
64
64
# always within the same directory, but we like to be general.
65
- LIBGFORTRAN_PATH=$( find_shlib " $private_libname " libgfortran)
66
- LIBGCC_PATH=$( find_shlib " $private_libname " libgcc_s)
67
- LIBQUADMATH_PATH=$( find_shlib " $private_libname " libquadmath)
65
+ LIBGFORTRAN_PATH=" $( find_shlib " $private_libname " libgfortran) "
68
66
69
67
# Take the directories, add them onto LIBGFORTRAN_DIRS, which we use to
70
68
# search for these libraries in the future. If there is no directory, try
71
69
# asking `$FC` where such a file could be found.
72
- LIBGFORTRAN_DIRS=" $LIBGFORTRAN_DIRS $( find_shlib_dir $LIBGFORTRAN_PATH ) "
70
+ LIBGFORTRAN_DIR=" $( find_shlib_dir " $LIBGFORTRAN_PATH " ) "
71
+ LIBGFORTRAN_DIRS=" $LIBGFORTRAN_DIRS $LIBGFORTRAN_DIR "
72
+
73
+ # Save the SONAME
74
+ LIBGFORTRAN_SONAME=" $( basename " $LIBGFORTRAN_PATH " ) "
75
+ LIBGFORTRAN_SONAMES=" $LIBGFORTRAN_SONAMES $LIBGFORTRAN_SONAME "
76
+
77
+
78
+ # Now that we've (maybe) found a libgfortran, ask _it_ for things like libgcc_s and libquadmath:
79
+ LIBGCC_PATH=" $( find_shlib " ${LIBGFORTRAN_DIR} /${LIBGFORTRAN_SONAME} " libgcc_s) "
80
+ LIBQUADMATH_PATH=" $( find_shlib " ${LIBGFORTRAN_DIR} /${LIBGFORTRAN_SONAME} " libquadmath) "
81
+
73
82
LIBGFORTRAN_DIRS=" $LIBGFORTRAN_DIRS $( find_shlib_dir $LIBGCC_PATH ) "
74
83
LIBGFORTRAN_DIRS=" $LIBGFORTRAN_DIRS $( find_shlib_dir $LIBQUADMATH_PATH ) "
75
-
76
- # Save the SONAMES
77
- LIBGFORTRAN_SONAMES=" $LIBGFORTRAN_SONAMES $( basename " $LIBGFORTRAN_PATH " ) "
78
84
LIBGCC_SONAMES=" $LIBGCC_SONAMES $( basename " $LIBGCC_PATH " ) "
79
85
LIBQUADMATH_SONAMES=" $LIBQUADMATH_SONAMES $( basename " $LIBQUADMATH_PATH " ) "
80
86
done
0 commit comments