Skip to content

Commit 85f1210

Browse files
committed
reflow and fix gfortran_install.sh
1 parent d5a78e2 commit 85f1210

File tree

1 file changed

+32
-27
lines changed

1 file changed

+32
-27
lines changed

tools/gfortran_utils.sh

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -109,26 +109,29 @@ if [ "$(uname)" == "Darwin" ]; then
109109
export SDKROOT=${SDKROOT:-$(xcrun --show-sdk-path)}
110110

111111
function download_and_unpack_gfortran {
112-
local arch=$1
113-
local type=$2
112+
local arch=$1
113+
local type=$2
114114
curl -L -O https://github.com/isuruf/gcc/releases/download/gcc-15.2.0/gfortran-darwin-${arch}-${type}.tar.gz
115-
case ${arch}-${type} in
116-
arm64-native)
117-
export GFORTRAN_SHA=999a91eef894d32f99e3b641520bef9f475055067f301f0f1947b8b716b5922a
118-
;;
119-
arm64-cross)
120-
export GFORTRAN_SHA=39ef2590629c2f238f1a67469fa429d8d6362425b277abb57fd2f3c982568a3f
121-
;;
122-
x86_64-native)
123-
export GFORTRAN_SHA=fb03c1f37bf0258ada6e3e41698e3ad416fff4dad448fd746e01d8ccf1efdc0f
124-
;;
125-
x86_64-cross)
126-
export GFORTRAN_SHA=0a19ca91019a75501e504eed1cad2be6ea92ba457ec815beb0dd28652eb0ce3f
127-
;;
128-
*) echo Did not recognize arch-plat $arch-$plat; return 1 ;;
129-
esac
130-
if [[ "$(python3 tools/sha256sum.py gfortran-darwin-${arch}-${type}.tar.gz)" != "${GFORTRAN_SHA} gfortran-darwin-${arch}-${type}.tar.gz" ]]; then
131-
echo "shasum mismatch for gfortran-darwin-${arch}-${type}"
115+
case ${arch}-${type} in
116+
arm64-native)
117+
local GFORTRAN_SHA=999a91eef894d32f99e3b641520bef9f475055067f301f0f1947b8b716b5922a
118+
;;
119+
arm64-cross)
120+
local export GFORTRAN_SHA=39ef2590629c2f238f1a67469fa429d8d6362425b277abb57fd2f3c982568a3f
121+
;;
122+
x86_64-native)
123+
local export GFORTRAN_SHA=fb03c1f37bf0258ada6e3e41698e3ad416fff4dad448fd746e01d8ccf1efdc0f
124+
;;
125+
x86_64-cross)
126+
local export GFORTRAN_SHA=0a19ca91019a75501e504eed1cad2be6ea92ba457ec815beb0dd28652eb0ce3f
127+
;;
128+
*) echo Did not recognize arch-plat $arch-$plat; return 1 ;;
129+
esac
130+
local filesha=$(python3 tools/sha256sum.py gfortran-darwin-${arch}-${type}.tar.gz)
131+
if [[ "$filesha" != "${GFORTRAN_SHA}" ]]; then
132+
echo shasum mismatch for gfortran-darwin-${arch}-${type}
133+
echo expected $GFORTRAN_SHA,
134+
echo got $filesha
132135
exit 1
133136
fi
134137
sudo mkdir -p /opt/
@@ -137,18 +140,18 @@ if [ "$(uname)" == "Darwin" ]; then
137140
sudo tar -xvf gfortran-darwin-${arch}-${type}.tar.gz
138141
sudo rm gfortran-darwin-${arch}-${type}.tar.gz
139142
popd
140-
if [[ "${type}" == "native" ]]; then
141-
# Link these into /usr/local so that there's no need to add rpath or -L
142-
for f in libgfortran.dylib libgfortran.5.dylib libgcc_s.1.dylib libgcc_s.1.1.dylib libquadmath.dylib libquadmath.0.dylib; do
143-
ln -sf /opt/gfortran-darwin-${arch}-${type}/lib/$f /usr/local/lib/$f
143+
if [[ "${type}" == "native" ]]; then
144+
# Link these into /usr/local so that there's no need to add rpath or -L
145+
for f in libgfortran.dylib libgfortran.5.dylib libgcc_s.1.dylib libgcc_s.1.1.dylib libquadmath.dylib libquadmath.0.dylib; do
146+
ln -sf /opt/gfortran-darwin-${arch}-${type}/lib/$f /usr/local/lib/$f
144147
done
145-
# Add it to PATH
146-
ln -sf /opt/gfortran-darwin-${arch}-${type}/bin/gfortran /usr/local/bin/gfortran
147-
fi
148+
# Add it to PATH
149+
ln -sf /opt/gfortran-darwin-${arch}-${type}/bin/gfortran /usr/local/bin/gfortran
150+
fi
148151
}
149152

150153
function install_arm64_cross_gfortran {
151-
download_and_unpack_gfortran arm64 cross
154+
download_and_unpack_gfortran arm64 cross
152155
export FC_ARM64="$(find /opt/gfortran-darwin-arm64-cross/bin -name "*-gfortran")"
153156
local libgfortran="$(find /opt/gfortran-darwin-arm64-cross/lib -name libgfortran.dylib)"
154157
local libdir=$(dirname $libgfortran)
@@ -157,6 +160,7 @@ if [ "$(uname)" == "Darwin" ]; then
157160
if [[ "${PLAT:-}" == "arm64" ]]; then
158161
export FC=$FC_ARM64
159162
fi
163+
check_gfortran
160164
}
161165
function install_gfortran {
162166
download_and_unpack_gfortran $(uname -m) native
@@ -170,6 +174,7 @@ if [ "$(uname)" == "Darwin" ]; then
170174
# Get lib with gfortran suffix
171175
get_gf_lib_for_suf "gf_${GFORTRAN_SHA:0:7}" $@
172176
}
177+
173178
else
174179
function install_gfortran {
175180
# No-op - already installed on manylinux image

0 commit comments

Comments
 (0)