1616
1717# Bash utilities for use with gfortran
1818
19- ARCHIVE_SDIR=" ${ARCHIVE_SDIR:- archives} "
20-
21- GF_UTIL_DIR=$( dirname " ${BASH_SOURCE[0]} " )
22-
23- function get_distutils_platform {
24- # Report platform as in form of distutils get_platform.
25- # This is like the platform tag that pip will use.
26- # Modify fat architecture tags on macOS to reflect compiled architecture
27-
28- # Deprecate this function once get_distutils_platform_ex is used in all
29- # downstream projects
30- local plat=$1
31- case $plat in
32- i686|x86_64|arm64|universal2|intel|aarch64|s390x|ppc64le) ;;
33- * ) echo Did not recognize plat $plat ; return 1 ;;
34- esac
35- local uname=${2:- $(uname)}
36- if [ " $uname " != " Darwin" ]; then
37- if [ " $plat " == " intel" ]; then
38- echo plat=intel not allowed for Manylinux
39- return 1
40- fi
41- echo " manylinux1_$plat "
42- return
43- fi
44- # macOS 32-bit arch is i386
45- [ " $plat " == " i686" ] && plat=" i386"
46- local target=$( echo $MACOSX_DEPLOYMENT_TARGET | tr .- _)
47- echo " macosx_${target} _${plat} "
48- }
49-
50- function get_distutils_platform_ex {
51- # Report platform as in form of distutils get_platform.
52- # This is like the platform tag that pip will use.
53- # Modify fat architecture tags on macOS to reflect compiled architecture
54- # For non-darwin, report manylinux version
55- local plat=$1
56- local mb_ml_ver=${MB_ML_VER:- 1}
57- case $plat in
58- i686|x86_64|arm64|universal2|intel|aarch64|s390x|ppc64le) ;;
59- * ) echo Did not recognize plat $plat ; return 1 ;;
60- esac
61- local uname=${2:- $(uname)}
62- if [ " $uname " != " Darwin" ]; then
63- if [ " $plat " == " intel" ]; then
64- echo plat=intel not allowed for Manylinux
65- return 1
66- fi
67- echo " manylinux${mb_ml_ver} _${plat} "
68- return
69- fi
70- # macOS 32-bit arch is i386
71- [ " $plat " == " i686" ] && plat=" i386"
72- local target=$( echo $MACOSX_DEPLOYMENT_TARGET | tr .- _)
73- echo " macosx_${target} _${plat} "
74- }
75-
76- function get_macosx_target {
77- # Report MACOSX_DEPLOYMENT_TARGET as given by distutils get_platform.
78- python3 -c " import sysconfig as s; print(s.get_config_vars()['MACOSX_DEPLOYMENT_TARGET'])"
79- }
80-
81- function check_gfortran {
82- # Check that gfortran exists on the path
83- if [ -z " $( which gfortran) " ]; then
84- echo Missing gfortran
85- exit 1
86- fi
87- }
88-
89- function get_gf_lib_for_suf {
90- local suffix=$1
91- local prefix=$2
92- local plat=${3:- $PLAT }
93- local uname=${4:- $(uname)}
94- if [ -z " $prefix " ]; then echo Prefix not defined; exit 1; fi
95- local plat_tag=$( get_distutils_platform_ex $plat $uname )
96- if [ -n " $suffix " ]; then suffix=" -$suffix " ; fi
97- local fname=" $prefix -${plat_tag}${suffix} .tar.gz"
98- local out_fname=" ${ARCHIVE_SDIR} /$fname "
99- [ -s $out_fname ] || (echo " $out_fname is empty" ; exit 24)
100- echo " $out_fname "
101- }
102-
10319if [ " $( uname) " == " Darwin" ]; then
104- mac_target=${MACOSX_DEPLOYMENT_TARGET:- $(get_macosx_target)}
105- export MACOSX_DEPLOYMENT_TARGET=$mac_target
106- # Keep this for now as some builds might depend on this being
107- # available before install_gfortran is called
108- export GFORTRAN_SHA=c469a420d2d003112749dcdcbe3c684eef42127e
10920 # Set SDKROOT env variable if not set
11021 export SDKROOT=${SDKROOT:- $(xcrun --show-sdk-path)}
11122
11223 function download_and_unpack_gfortran {
113- local arch=$1
114- local type=$2
115- curl -L -O https://github.com/isuruf/gcc/releases/download/gcc-11.3.0-2/gfortran-darwin-${arch} -${type} .tar.gz
116- case ${arch} -${type} in
117- arm64-native)
118- export GFORTRAN_SHA=0d5c118e5966d0fb9e7ddb49321f63cac1397ce8
119- ;;
120- arm64-cross)
121- export GFORTRAN_SHA=527232845abc5af21f21ceacc46fb19c190fe804
122- ;;
123- x86_64-native)
124- export GFORTRAN_SHA=c469a420d2d003112749dcdcbe3c684eef42127e
125- ;;
126- x86_64-cross)
127- export GFORTRAN_SHA=107604e57db97a0ae3e7ca7f5dd722959752f0b3
128- ;;
129- esac
24+ local arch=$1
25+ local type=$2
26+ curl -L -O https://github.com/isuruf/gcc/releases/download/gcc-11.3.0-2/gfortran-darwin-${arch} -${type} .tar.gz
27+ case ${arch} -${type} in
28+ arm64-native)
29+ export GFORTRAN_SHA=0d5c118e5966d0fb9e7ddb49321f63cac1397ce8
30+ ;;
31+ arm64-cross)
32+ export GFORTRAN_SHA=527232845abc5af21f21ceacc46fb19c190fe804
33+ ;;
34+ x86_64-native)
35+ export GFORTRAN_SHA=c469a420d2d003112749dcdcbe3c684eef42127e
36+ ;;
37+ x86_64-cross)
38+ export GFORTRAN_SHA=107604e57db97a0ae3e7ca7f5dd722959752f0b3
39+ ;;
40+ * )
41+ echo unknown ${arch} -${type}
42+ exit 1
43+ ;;
44+ esac
13045 if [[ " $( shasum gfortran-darwin-${arch} -${type} .tar.gz) " != " ${GFORTRAN_SHA} gfortran-darwin-${arch} -${type} .tar.gz" ]]; then
13146 echo " shasum mismatch for gfortran-darwin-${arch} -${type} "
13247 exit 1
@@ -140,7 +55,6 @@ if [ "$(uname)" == "Darwin" ]; then
14055 tar -xvf gfortran-darwin-${arch} -${type} .tar.gz
14156 rm gfortran-darwin-${arch} -${type} .tar.gz
14257 popd
143- fi
14458 }
14559
14660 function install_arm64_cross_gfortran {
@@ -156,24 +70,13 @@ if [ "$(uname)" == "Darwin" ]; then
15670 }
15771 function install_gfortran {
15872 download_and_unpack_gfortran $( uname -m) native
159- check_gfortran
16073 if [[ " ${PLAT:- } " == " universal2" ]]; then
16174 install_arm64_cross_gfortran
16275 fi
16376 }
16477
165- function get_gf_lib {
166- # Get lib with gfortran suffix
167- get_gf_lib_for_suf " gf_${GFORTRAN_SHA: 0: 7} " $@
168- }
16978else
17079 function install_gfortran {
17180 # No-op - already installed on manylinux image
172- check_gfortran
173- }
174-
175- function get_gf_lib {
176- # Get library with no suffix
177- get_gf_lib_for_suf " " $@
17881 }
17982fi
0 commit comments