Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fixup-libgfortran #27667

Merged
merged 3 commits into from
Jun 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions contrib/fixup-libgfortran.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Run as: fixup-libgfortran.sh [--verbose] <$private_libdir>

# If we're invoked with "--verbose", create a `debug` function that prints stuff out
if [ "$1" == "--verbose" ] || [ "$1" == "-v" ]; then
if [ "$1" = "--verbose" ] || [ "$1" = "-v" ]; then
shift 1
debug() { echo "$*"; }
else
Expand Down Expand Up @@ -41,31 +41,26 @@ find_shlib()
fi
}

private_libname()
{
echo "$private_libdir/lib$1.$SHLIB_EXT"
}

# First, discover all the places where libgfortran/libgcc is, as well as their true SONAMES
for lib in lapack; do
if [ -f "$private_libdir/lib$lib.$SHLIB_EXT" ]; then
for lib in lapack blas openblas; do
for private_libname in ${private_libdir}/lib$lib*.$SHLIB_EXT*; do
# Find the paths to the libraries we're interested in. These are almost
# always within the same directory, but we like to be general.
LIBGFORTRAN_PATH=$(find_shlib "$(private_libname $lib)" libgfortran)
LIBGCC_PATH=$(find_shlib "$(private_libname $lib)" libgcc_s)
LIBQUADMATH_PATH=$(find_shlib "$(private_libname $lib)" libquadmath)
LIBGFORTRAN_PATH=$(find_shlib "$private_libname" libgfortran)
LIBGCC_PATH=$(find_shlib "$private_libname" libgcc_s)
LIBQUADMATH_PATH=$(find_shlib "$private_libname" libquadmath)

# Take the directories, add them onto LIBGFORTRAN_DIRS, which we use to
# search for these libraries in the future.
LIBGFORTRAN_DIRS="$LIBGFORTRAN_DIRS $(dirname $LIBGFORTRAN_PATH)"
LIBGFORTRAN_DIRS="$LIBGFORTRAN_DIRS $(dirname $LIBGCC_PATH)"
LIBGFORTRAN_DIRS="$LIBGFORTRAN_DIRS $(dirname $LIBQUADMATH_PATH)"
LIBGFORTRAN_DIRS="$LIBGFORTRAN_DIRS $(dirname $LIBGFORTRAN_PATH 2>/dev/null)"
LIBGFORTRAN_DIRS="$LIBGFORTRAN_DIRS $(dirname $LIBGCC_PATH 2>/dev/null)"
LIBGFORTRAN_DIRS="$LIBGFORTRAN_DIRS $(dirname $LIBQUADMATH_PATH 2>/dev/null)"

# Save the SONAMES
LIBGFORTRAN_SONAMES="$LIBGFORTRAN_SONAMES $(basename "$LIBGFORTRAN_PATH")"
LIBGCC_SONAMES="$LIBGCC_SONAMES $(basename "$LIBGCC_PATH")"
LIBQUADMATH_SONAMES="$LIBQUADMATH_SONAMES $(basename "$LIBQUADMATH_PATH")"
fi
done
done

# Take in a list of space-separated tokens, return a deduplicated list of the same
Expand Down