@@ -32,65 +32,50 @@ if [ "$(uname)" == "Darwin" ]; then
3232 local gccver=gcc-15.2.0
3333 case ${arch} -${type} in
3434 arm64-native)
35- local GFORTRAN_SHA=999a91eef894d32f99e3b641520bef9f475055067f301f0f1947b8b716b5922a
35+ export GFORTRAN_SHA=999a91eef894d32f99e3b641520bef9f475055067f301f0f1947b8b716b5922a
3636 ;;
3737 arm64-cross)
38- local export GFORTRAN_SHA=39ef2590629c2f238f1a67469fa429d8d6362425b277abb57fd2f3c982568a3f
38+ export GFORTRAN_SHA=39ef2590629c2f238f1a67469fa429d8d6362425b277abb57fd2f3c982568a3f
3939 ;;
4040 x86_64-native)
4141 # override gccver
4242 gccver=gcc-11.3.0.2
43- local export GFORTRAN_SHA=981367dd0ad4335613e91bbee453d60b6669f5d7e976d18c7bdb7f1966f26ae4
43+ export GFORTRAN_SHA=981367dd0ad4335613e91bbee453d60b6669f5d7e976d18c7bdb7f1966f26ae4
4444 ;;
4545 x86_64-cross)
46- local export GFORTRAN_SHA=0a19ca91019a75501e504eed1cad2be6ea92ba457ec815beb0dd28652eb0ce3f
46+ export GFORTRAN_SHA=0a19ca91019a75501e504eed1cad2be6ea92ba457ec815beb0dd28652eb0ce3f
4747 ;;
4848 * ) echo Did not recognize arch-plat $arch -$plat ; return 1 ;;
4949 esac
5050 curl -L -O https://github.com/isuruf/gcc/releases/download/${gccver} /gfortran-darwin-${arch} -${type} .tar.gz
5151 local filesha=$( python3 tools/sha256sum.py gfortran-darwin-${arch} -${type} .tar.gz)
5252 if [[ " $filesha " != " ${GFORTRAN_SHA} " ]]; then
53- echo shasum mismatch for gfortran-darwin-${arch} -${type}
54- echo expected $GFORTRAN_SHA ,
53+ echo shasum mismatch for ${gccver} / gfortran-darwin-${arch} -${type}
54+ echo expected $GFORTRAN_SHA
5555 echo got $filesha
5656 exit 1
5757 fi
58- sudo mkdir -p /opt/
59- sudo cp " gfortran-darwin-${arch} -${type} .tar.gz" /opt/gfortran-darwin-${arch} -${type} .tar.gz
60- pushd /opt
61- sudo tar -xvf gfortran-darwin-${arch} -${type} .tar.gz
62- sudo rm gfortran-darwin-${arch} -${type} .tar.gz
63- popd
64- if [[ " ${type} " == " native" ]]; then
65- # Link these into /usr/local so that there's no need to add rpath or -L
66- for f in libgfortran.dylib libgfortran.5.dylib \
67- libgcc_s.1.dylib libgcc_s.1.1.dylib libquadmath.dylib \
68- libquadmath.0.dylib libgfortran.spec; do
69- ln -sf /opt/gfortran-darwin-${arch} -${type} /lib/$f /usr/local/lib/$f
70- done
71- # Add it to PATH
72- ln -sf /opt/gfortran-darwin-${arch} -${type} /bin/gfortran /usr/local/bin/gfortran
58+ if [[ ! -e /opt/gfortran ]]; then
59+ sudo mkdir -p /opt/gfortran
60+ sudo chmod 777 -p /opt/gfortran
7361 fi
74- }
75-
76- function install_arm64_cross_gfortran {
77- download_and_unpack_gfortran arm64 cross
78- export FC_ARM64=" $( find /opt/gfortran-darwin-arm64-cross/bin -name " *-gfortran" ) "
79- local libgfortran=" $( find /opt/gfortran-darwin-arm64-cross/lib -name libgfortran.dylib) "
62+ cp " gfortran-darwin-${arch} -${type} .tar.gz" /opt/gfortran/gfortran-darwin-${arch} -${type} .tar.gz
63+ pushd /opt/gfortran
64+ tar -xvf gfortran-darwin-${arch} -${type} .tar.gz
65+ rm gfortran-darwin-${arch} -${type} .tar.gz
66+ popd
67+ export FC=" $( find /opt/gfortran/gfortran-darwin-${arch} -${type} /bin -name " *-gfortran" ) "
68+ local libgfortran=" $( find /opt/gfortran/gfortran-darwin-${arch} -${cross} /lib -name libgfortran.dylib) "
8069 local libdir=$( dirname $libgfortran )
81-
82- export FC_ARM64_LDFLAGS=" -L$libdir -Wl,-rpath,$libdir "
83- if [[ " ${PLAT:- } " == " arm64" ]]; then
84- export FC=$FC_ARM64
85- fi
86- check_gfortran
70+ export FFLAGS=" -L$libdir -Wl,-rpath,$libdir "
8771 }
72+
8873 function install_gfortran {
8974 download_and_unpack_gfortran $( uname -m) native
90- check_gfortran
9175 if [[ " ${PLAT:- } " == " universal2" || " ${PLAT:- } " == " arm64" ]]; then
92- install_arm64_cross_gfortran
76+ download_and_unpack_gfortran arm64 cross
9377 fi
78+ check_gfortran
9479 }
9580
9681else
0 commit comments