@@ -16,19 +16,46 @@ set -o errexit
1616# #
1717# ------------------------------------------------------------------------- #
1818
19+ SKIP_GMP=no
20+ SKIP_MPFR=no
21+
1922USE_GMP=gmp
2023PATCH_GMP_ARM64=no
24+ BUILD_ARB=no
2125
2226while [[ $# -gt 0 ]]
2327do
2428 key=" $1 "
2529 case $key in
2630 -h|--help)
27- echo " bin/download_dependencies.sh [--gmp gmp|mpir] [--host HOST]"
31+ echo " bin/download_dependencies.sh [options]"
32+ echo
33+ echo " Build local installs of python-flint's dependencies."
34+ echo
35+ echo " Supported options:"
36+ echo " --help - show this help message"
37+ echo " --host <HOST> - set the host (target) for GMP build"
38+ echo " --skip-gmp - skip building GMP"
39+ echo " --skip-mpfr - skip building MPFR"
40+ echo
41+ echo " Legacy options:"
42+ echo " --gmp gmp - build based on GMP (default)"
43+ echo " --gmp mpir - build based on MPIR (no longer works)"
44+ echo " --patch-gmp-arm64 - apply patch to GMP 6.2.1 for OSX arm64"
45+ echo " --arb - build Arb (only needed for flint < 3.0.0)"
46+ echo
2847 exit
2948 ;;
49+ --host)
50+ # e.g. --host x86_64-unknown-linux-gnu
51+ # or --host x86_64-apple-darwin
52+ HOST_ARG=" $2 "
53+ shift
54+ shift
55+ ;;
3056 --gmp)
3157 # e.g. --gmp gmp or --gmp mpir
58+ # The mpir build no longer works because the download fails.
3259 USE_GMP=" $2 "
3360 if [[ " $USE_GMP " != " gmp" && " $USE_GMP " != " mpir" ]]; then
3461 echo " --gmp option should be gmp or mpir"
3764 shift
3865 shift
3966 ;;
40- --host )
41- # e.g. --host x86_64-unknown-linux-gnu
42- # or --host x86_64-apple-darwin
43- HOST_ARG= " $2 "
67+ --arb )
68+ # With flint >= 3.0.0 Arb is included so we do not need to build it
69+ # separately. Pass --arb if building for older versions of flint.
70+ BUILD_ARB=yes
4471 shift
72+ ;;
73+ --skip-gmp)
74+ # If you already have a local install of GMP you can pass --skip-gmp
75+ # to skip building it.
76+ SKIP_GMP=yes
77+ shift
78+ ;;
79+ --skip-mpfr)
80+ # If you already have a local install of MPFR you can pass --skip-mpfr
81+ # to skip building it.
82+ SKIP_MPFR=yes
4583 shift
4684 ;;
4785 --patch-gmp-arm64)
86+ # Needed only for GMP 6.2.1 on OSX arm64 (Apple M1) hardware
87+ # As of GMP 6.3.0 this patch is no longer needed
4888 PATCH_GMP_ARM64=yes
4989 shift
5090 ;;
@@ -86,42 +126,60 @@ if [ $USE_GMP = "gmp" ]; then
86126 # #
87127 # ----------------------------------------------------------------------- #
88128
89- if [ $USE_GMP_GITHUB_MIRROR = " yes" ]; then
90- # Needed in GitHub Actions because it is blocked from gmplib.org
91- git clone https://github.com/oscarbenjamin/gmp_mirror.git
92- cp gmp_mirror/gmp-$GMPVER .tar.xz .
129+ if [ $SKIP_GMP = " yes" ]; then
130+ echo
131+ echo --------------------------------------------
132+ echo " skipping GMP"
133+ echo --------------------------------------------
134+ echo
93135 else
94- curl -O https://gmplib.org/download/gmp/gmp-$GMPVER .tar.xz
95- fi
136+ echo
137+ echo --------------------------------------------
138+ echo " building GMP"
139+ echo --------------------------------------------
140+ echo
141+
142+ if [ $USE_GMP_GITHUB_MIRROR = " yes" ]; then
143+ # Needed in GitHub Actions because it is blocked from gmplib.org
144+ git clone https://github.com/oscarbenjamin/gmp_mirror.git
145+ cp gmp_mirror/gmp-$GMPVER .tar.xz .
146+ else
147+ curl -O https://gmplib.org/download/gmp/gmp-$GMPVER .tar.xz
148+ fi
96149
97- tar xf gmp-$GMPVER .tar.xz
98- cd gmp-$GMPVER
150+ tar xf gmp-$GMPVER .tar.xz
151+ cd gmp-$GMPVER
152+
153+ #
154+ # See https://github.com/aleaxit/gmpy/issues/350
155+ #
156+ # We need to patch GMP for OSX arm64 (Apple M1) hardware. This patch is
157+ # from the GMP repo but was applied after the release of GMP 6.2.1.
158+ # This patch is no longer needed for GMP 6.3.0.
159+ #
160+ if [ $PATCH_GMP_ARM64 = " yes" ]; then
161+ echo
162+ echo --------------------------------------------
163+ echo " patching GMP"
164+ echo --------------------------------------------
165+ patch -N -Z -p0 < ../../../bin/patch-arm64.diff
166+ fi
99167
100- #
101- # See https://github.com/aleaxit/gmpy/issues/350
102- #
103- # We need to patch GMP for OSX arm64 (Apple M1) hardware for GMP 6.2.1.
104- # Now with GMP 6.3.0 this should not be needed any more.
105- #
106- if [ $PATCH_GMP_ARM64 = " yes" ]; then
107- echo
108- echo --------------------------------------------
109- echo " patching GMP"
110- echo --------------------------------------------
111- patch -N -Z -p0 < ../../../bin/patch-arm64.diff
112- fi
168+ # Show the output of configfsf.guess
169+ chmod +x configfsf.guess
170+ ./configfsf.guess
113171
114- # Show the output of configfsf.guess
115- chmod +x configfsf.guess
116- ./configfsf.guess
117- ./configure --prefix= $PREFIX \
118- --enable-fat\
119- --enable-shared=yes\
120- --enable-static=no\
121- --host= $HOST_ARG
122- make -j3
123- make install
124- cd ..
172+ ./configure --prefix= $PREFIX \
173+ --enable-fat\
174+ --enable-shared=yes\
175+ --enable-static=no \
176+ --host= $HOST_ARG
177+ make -j3
178+ make install
179+
180+ cd ..
181+
182+ fi
125183
126184 FLINTARB_WITHGMP=" --with-gmp=$PREFIX "
127185
182240# #
183241# ------------------------------------------------------------------------- #
184242
185- curl -O https://ftp.gnu.org/gnu/mpfr/mpfr-$MPFRVER .tar.gz
186- tar xf mpfr-$MPFRVER .tar.gz
187- cd mpfr-$MPFRVER
188- ./configure --prefix=$PREFIX \
189- --with-gmp=$PREFIX \
190- --enable-shared=yes\
191- --enable-static=no
192- make -j3
193- make install
194- cd ..
243+ if [ $SKIP_MPFR = " yes" ]; then
244+ echo
245+ echo --------------------------------------------
246+ echo " skipping MPFR"
247+ echo --------------------------------------------
248+ echo
249+ else
250+ echo
251+ echo --------------------------------------------
252+ echo " building MPFR"
253+ echo --------------------------------------------
254+ echo
255+
256+ curl -O https://ftp.gnu.org/gnu/mpfr/mpfr-$MPFRVER .tar.gz
257+ tar xf mpfr-$MPFRVER .tar.gz
258+ cd mpfr-$MPFRVER
259+ ./configure --prefix=$PREFIX \
260+ --with-gmp=$PREFIX \
261+ --enable-shared=yes\
262+ --enable-static=no
263+ make -j3
264+ make install
265+ cd ..
266+ fi
195267
196268# ------------------------------------------------------------------------- #
197269# #
198270# FLINT #
199271# #
200272# ------------------------------------------------------------------------- #
201273
274+ echo
275+ echo --------------------------------------------
276+ echo " building Flint"
277+ echo --------------------------------------------
278+ echo
279+
202280curl -O -L https://www.flintlib.org/flint-$FLINTVER .tar.gz
203281tar xf flint-$FLINTVER .tar.gz
204282cd flint-$FLINTVER
283+ ./bootstrap.sh
205284 ./configure --prefix=$PREFIX \
206285 $FLINTARB_WITHGMP \
207286 --with-mpfr=$PREFIX \
@@ -216,25 +295,34 @@ cd ..
216295# #
217296# ------------------------------------------------------------------------- #
218297
219- curl -O -L https://github.com/fredrik-johansson/arb/archive/refs/tags/$ARBVER .tar.gz
220- mv $ARBVER .tar.gz arb-$ARBVER .tar.gz
221- tar xf arb-$ARBVER .tar.gz
222- cd arb-$ARBVER
223- ./configure --prefix=$PREFIX \
224- --with-flint=$PREFIX \
225- $FLINTARB_WITHGMP \
226- --with-mpfr=$PREFIX \
227- --disable-static
228- make -j3
229- make install
230- #
231- # Set PATH so that DLLs are picked up on Windows.
232- #
233- PATH=$PATH :$PREFIX /lib:$PREFIX /bin \
234- ARB_TEST_MULTIPLIER=0.1 \
235- # Skip Arb tests now because they are slow.
236- # make check
237- cd ..
298+ if [ $BUILD_ARB = " yes" ]; then
299+
300+ echo
301+ echo --------------------------------------------
302+ echo " building Arb"
303+ echo --------------------------------------------
304+ echo
305+
306+ curl -O -L https://github.com/fredrik-johansson/arb/archive/refs/tags/$ARBVER .tar.gz
307+ mv $ARBVER .tar.gz arb-$ARBVER .tar.gz
308+ tar xf arb-$ARBVER .tar.gz
309+ cd arb-$ARBVER
310+ ./configure --prefix=$PREFIX \
311+ --with-flint=$PREFIX \
312+ $FLINTARB_WITHGMP \
313+ --with-mpfr=$PREFIX \
314+ --disable-static
315+ make -j3
316+ make install
317+ #
318+ # Set PATH so that DLLs are picked up on Windows.
319+ #
320+ PATH=$PATH :$PREFIX /lib:$PREFIX /bin \
321+ ARB_TEST_MULTIPLIER=0.1 \
322+ # Skip Arb tests now because they are slow.
323+ # make check
324+ cd ..
325+ fi
238326
239327# ------------------------------------------------------------------------- #
240328# #
@@ -249,14 +337,28 @@ echo Build dependencies for python-flint compiled as shared libraries in:
249337echo $PREFIX
250338echo
251339echo Versions:
252- if [[ $USE_GMP = " gmp" ]]; then
253- echo GMP: $GMPVER
340+
341+ if [ $SKIP_GMP = " yes" ]; then
342+ echo GMP: skipped
254343else
255- echo MPIR: $MPIRVER
344+ if [[ $USE_GMP = " gmp" ]]; then
345+ echo GMP: $GMPVER
346+ else
347+ echo MPIR: $MPIRVER
348+ fi
256349fi
257- echo MPFR: $MPFRVER
350+
351+ if [ $SKIP_MPFR = " yes" ]; then
352+ echo MPFR: skipped
353+ else
354+ echo MPFR: $MPFRVER
355+ fi
356+
258357echo Flint: $FLINTVER
259- echo Arb: $ARBVER
358+
359+ if [ $BUILD_ARB = " yes" ]; then
360+ echo Arb: $ARBVER
361+ fi
260362echo
261363echo -----------------------------------------------------------------------
262364echo
0 commit comments