Skip to content

Commit

Permalink
Add gcc libdir symlinks for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Feb 17, 2023
1 parent 9ba80a3 commit a2cc027
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions setup-fortran.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,24 @@ install_gcc_brew()
ln -fs /usr/local/bin/gcc-${version} /usr/local/bin/gcc
ln -fs /usr/local/bin/g++-${version} /usr/local/bin/g++

# link lib dir for previous GCC versions to avoid missing .dylib issues
# check which version we installed
# sed instead of head to take first line avoids ruby broken pipe issues
# https://stackoverflow.com/a/2845541/6514033
ver=$(brew info gfortran | sed -n 1p | cut -d' ' -f 4)

# link homebrew lib dir to other common lib dir locations to avoid missing .dylib issues
sudo mkdir -p /opt/local/lib
sudo ln -fs usr/local/Cellar/gcc/${ver}/lib/gcc/${version} /opt/local/lib/libgcc

# link lib dirs for previous GCC versions to avoid missing .dylib issues
for (( i=12; i>4; i-- ))
do
gcc_lib_path="/usr/local/opt/gcc/lib/gcc/$i"
if [ -d $gcc_lib_path ]; then
echo "found $gcc_lib_path"
for (( j=$i; j>4; j-- ))
do
ln -fs /usr/local/opt/gcc/lib/gcc/$i /usr/local/opt/gcc/lib/gcc/$j
sudo ln -fs /usr/local/opt/gcc/lib/gcc/$i /usr/local/opt/gcc/lib/gcc/$j
done
break
fi
Expand Down

0 comments on commit a2cc027

Please # to comment.