@@ -9,12 +9,15 @@ set -o errexit
99# #
1010# Supported options: #
1111# #
12- # --gmp gmp - build based on GMP (default) #
13- # --gmp mpir - build based on MPIR (instead of GMP) #
12+ # --gmp gmp - build based on GMP (default) #
13+ # --gmp mpir - build based on MPIR (no longer works) #
14+ # --host <HOST> - set the host (target) for GMP build #
15+ # --patch-gmp-arm64 - apply patch to GMP for OSX arm64 #
1416# #
1517# ------------------------------------------------------------------------- #
1618
1719USE_GMP=gmp
20+ PATCH_GMP_ARM64=no
1821
1922while [[ $# -gt 0 ]]
2023do
4144 shift
4245 shift
4346 ;;
47+ --patch-gmp-arm64)
48+ PATCH_GMP_ARM64=yes
49+ shift
50+ ;;
51+ * )
52+ 2>&1 echo " unrecognised argument:" $key
53+ exit 1
54+ ;;
4455 esac
4556done
4657
@@ -74,6 +85,23 @@ if [ $USE_GMP = "gmp" ]; then
7485 curl -O https://gmplib.org/download/gmp/gmp-$GMPVER .tar.xz
7586 tar xf gmp-$GMPVER .tar.xz
7687 cd gmp-$GMPVER
88+
89+ #
90+ # See https://github.com/aleaxit/gmpy/issues/350
91+ #
92+ # We need to patch GMP for OSX arm64 (Apple M1) hardware. This patch is
93+ # from the GMP repo but was applied after the release of GMP 6.2.1.
94+ # Hopefully when a newer version of GMP is released we will not need to
95+ # apply this patch any more.
96+ #
97+ if [ $PATCH_GMP_ARM64 = " yes" ]; then
98+ echo
99+ echo --------------------------------------------
100+ echo " patching GMP"
101+ echo --------------------------------------------
102+ patch -N -Z -p0 < ../../../bin/patch-arm64.diff
103+ fi
104+
77105 # Show the output of configfsf.guess
78106 ./configfsf.guess
79107 ./configure --prefix=$PREFIX \
@@ -109,6 +137,18 @@ else
109137 # #
110138 # ----------------------------------------------------------------------- #
111139
140+ #
141+ # The mpir.org domain has expired and no longer hosts the source code so the
142+ # call to curl below will fail.
143+ # We could try to download from https://github.com/wbhart/mpir/releases.
144+ #
145+ # Ultimately it seems that MPIR is no longer maintained though so for now
146+ # this remains unfixed.
147+ #
148+
149+ >&2 echo " MPIR build of python_flint is no longer supported"
150+ exit 1
151+
112152 curl -O http://mpir.org/mpir-$MPIRVER .tar.bz2
113153 tar xf mpir-$MPIRVER .tar.bz2
114154 cd mpir-$MPIRVER
0 commit comments