Skip to content

Commit 7db0133

Browse files
committed
do not run install_gfortran in a shell, export FC and FFLAGS
1 parent c6eaaa2 commit 7db0133

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

tools/build_steps.sh

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,15 @@ function before_build {
3939
# get_macpython_environment ${MB_PYTHON_VERSION} venv
4040
python3.9 -m venv venv
4141
source venv/bin/activate
42-
# Since install_fortran uses `uname -a` to determine arch,
43-
# force the architecture
42+
4443
unalias gfortran 2>/dev/null || true
45-
arch -${PLAT} bash -s << " EOF"
46-
set -ex
47-
source tools/gfortran_utils.sh
48-
install_gfortran
49-
EOF
50-
which gfortran
51-
gfortran --version
44+
source tools/gfortran_utils.sh
45+
download_and_unpack_gfortran ${PLAT} native
46+
export FC=/opt/gfortran/gfortran-darwin-${PLAT}-native/bin/gfortran
47+
which ${FC}
48+
${FC} --version
49+
local libdir=/opt/gfortran/gfortran-darwin-${PLAT}-native/lib
50+
export FFLAGS="-L${libdir} -Wl,-rpath,${libdir}"
5251

5352
# Deployment target set by gfortran_utils
5453
echo "Deployment target $MACOSX_DEPLOYMENT_TARGET"

tools/gfortran_utils.sh

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,14 @@ if [ "$(uname)" == "Darwin" ]; then
131131
echo "shasum mismatch for gfortran-darwin-${arch}-${type}"
132132
exit 1
133133
fi
134-
sudo mkdir -p /opt/
135-
sudo cp "gfortran-darwin-${arch}-${type}.tar.gz" /opt/gfortran-darwin-${arch}-${type}.tar.gz
136-
pushd /opt
137-
sudo tar -xvf gfortran-darwin-${arch}-${type}.tar.gz
138-
sudo rm gfortran-darwin-${arch}-${type}.tar.gz
134+
if [! -d /opt/gfortran ]; then
135+
sudo mkdir -p /opt/gfortran
136+
sudo chmod 777 /opt/gfortran
137+
cp "gfortran-darwin-${arch}-${type}.tar.gz" /opt/goftran/gfortran-darwin-${arch}-${type}.tar.gz
138+
pushd /opt/gfortran
139+
tar -xvf gfortran-darwin-${arch}-${type}.tar.gz
140+
rm gfortran-darwin-${arch}-${type}.tar.gz
139141
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
144-
done
145-
# Add it to PATH
146-
ln -sf /opt/gfortran-darwin-${arch}-${type}/bin/gfortran /usr/local/bin/gfortran
147142
fi
148143
}
149144

@@ -161,7 +156,7 @@ if [ "$(uname)" == "Darwin" ]; then
161156
function install_gfortran {
162157
download_and_unpack_gfortran $(uname -m) native
163158
check_gfortran
164-
if [[ "${PLAT:-}" == "universal2" || "${PLAT:-}" == "arm64" ]]; then
159+
if [[ "${PLAT:-}" == "universal2"]]; then
165160
install_arm64_cross_gfortran
166161
fi
167162
}

0 commit comments

Comments
 (0)