|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# Build local installs of python-flint's dependencies. This should be run |
| 4 | +# before attempting to build python-flint itself. |
| 5 | + |
| 6 | +set -o errexit |
| 7 | + |
| 8 | +# ------------------------------------------------------------------------- # |
| 9 | +# # |
| 10 | +# Supported options: # |
| 11 | +# # |
| 12 | +# --gmp gmp - build based on GMP (default) # |
| 13 | +# --gmp mpir - build based on MPIR (instead of GMP) # |
| 14 | +# # |
| 15 | +# ------------------------------------------------------------------------- # |
| 16 | + |
| 17 | +USE_GMP=gmp |
| 18 | + |
| 19 | +while [[ $# -gt 0 ]] |
| 20 | +do |
| 21 | + key="$1" |
| 22 | + case $key in |
| 23 | + -h|--help) |
| 24 | + echo "bin/download_dependencies.sh [--gmp gmp|mpir] [--host HOST]" |
| 25 | + exit |
| 26 | + ;; |
| 27 | + --gmp) |
| 28 | + # e.g. --gmp gmp or --gmp mpir |
| 29 | + USE_GMP="$2" |
| 30 | + if [[ "$USE_GMP" != "gmp" && "$USE_GMP" != "mpir" ]]; then |
| 31 | + echo "--gmp option should be gmp or mpir" |
| 32 | + exit 1 |
| 33 | + fi |
| 34 | + shift |
| 35 | + shift |
| 36 | + ;; |
| 37 | + --host) |
| 38 | + # e.g. --host x86_64-unknown-linux-gnu |
| 39 | + # or --host x86_64-apple-darwin |
| 40 | + HOST_ARG="$2" |
| 41 | + shift |
| 42 | + shift |
| 43 | + ;; |
| 44 | + esac |
| 45 | +done |
| 46 | + |
| 47 | +# ------------------------------------------------------------------------- # |
| 48 | +# # |
| 49 | +# The build_variables.sh script sets variables specifying the versions to # |
| 50 | +# use for all dependencies and also the PREFIX variable. # |
| 51 | +# # |
| 52 | +# ------------------------------------------------------------------------- # |
| 53 | + |
| 54 | +source bin/build_variables.sh |
| 55 | + |
| 56 | +cd $PREFIX |
| 57 | +mkdir -p src |
| 58 | +cd src |
| 59 | + |
| 60 | +# ------------------------------------------------------------------------- # |
| 61 | +# # |
| 62 | +# Now build all dependencies. # |
| 63 | +# # |
| 64 | +# ------------------------------------------------------------------------- # |
| 65 | + |
| 66 | +if [ $USE_GMP = "gmp" ]; then |
| 67 | + |
| 68 | + # ----------------------------------------------------------------------- # |
| 69 | + # # |
| 70 | + # GMP # |
| 71 | + # # |
| 72 | + # ----------------------------------------------------------------------- # |
| 73 | + |
| 74 | + curl -O https://gmplib.org/download/gmp/gmp-$GMPVER.tar.xz |
| 75 | + tar xf gmp-$GMPVER.tar.xz |
| 76 | + cd gmp-$GMPVER |
| 77 | + ./configure --prefix=$PREFIX\ |
| 78 | + --enable-fat\ |
| 79 | + --enable-shared=yes\ |
| 80 | + --enable-static=no\ |
| 81 | + --host=$HOSTARG |
| 82 | + make -j3 |
| 83 | + make install |
| 84 | + cd .. |
| 85 | + |
| 86 | + FLINTARB_WITHGMP="--with-gmp=$PREFIX" |
| 87 | + |
| 88 | +else |
| 89 | + |
| 90 | + # ----------------------------------------------------------------------- # |
| 91 | + # # |
| 92 | + # YASM (needed to build MPIR) # |
| 93 | + # # |
| 94 | + # ----------------------------------------------------------------------- # |
| 95 | + |
| 96 | + curl -O http://www.tortall.net/projects/yasm/releases/yasm-$YASMVER.tar.gz |
| 97 | + tar xf yasm-$YASMVER.tar.gz |
| 98 | + cd yasm-$YASMVER |
| 99 | + ./configure --prefix=$PREFIX |
| 100 | + make -j3 |
| 101 | + make install |
| 102 | + cd .. |
| 103 | + |
| 104 | + # ----------------------------------------------------------------------- # |
| 105 | + # # |
| 106 | + # MPIR # |
| 107 | + # # |
| 108 | + # ----------------------------------------------------------------------- # |
| 109 | + |
| 110 | + curl -O http://mpir.org/mpir-$MPIRVER.tar.bz2 |
| 111 | + tar xf mpir-$MPIRVER.tar.bz2 |
| 112 | + cd mpir-$MPIRVER |
| 113 | + ./configure --prefix=$PREFIX\ |
| 114 | + --with-yasm=$PREFIX/bin/yasm\ |
| 115 | + --enable-fat\ |
| 116 | + --enable-shared=yes\ |
| 117 | + --enable-static=no\ |
| 118 | + --enable-gmpcompat |
| 119 | + make -j3 |
| 120 | + make install |
| 121 | + cd .. |
| 122 | + |
| 123 | + FLINTARB_WITHGMP="--with-mpir=$PREFIX" |
| 124 | + |
| 125 | +fi |
| 126 | + |
| 127 | +# ------------------------------------------------------------------------- # |
| 128 | +# # |
| 129 | +# MPFR # |
| 130 | +# # |
| 131 | +# ------------------------------------------------------------------------- # |
| 132 | + |
| 133 | +curl -O https://www.mpfr.org/mpfr-current/mpfr-$MPFRVER.tar.gz |
| 134 | +tar xf mpfr-$MPFRVER.tar.gz |
| 135 | +cd mpfr-$MPFRVER |
| 136 | + ./configure --prefix=$PREFIX\ |
| 137 | + --with-gmp=$PREFIX\ |
| 138 | + --enable-shared=yes\ |
| 139 | + --enable-static=no |
| 140 | + make -j3 |
| 141 | + make install |
| 142 | +cd .. |
| 143 | + |
| 144 | +# ------------------------------------------------------------------------- # |
| 145 | +# # |
| 146 | +# FLINT # |
| 147 | +# # |
| 148 | +# ------------------------------------------------------------------------- # |
| 149 | + |
| 150 | +curl -O https://www.flintlib.org/flint-$FLINTVER.tar.gz |
| 151 | +tar xf flint-$FLINTVER.tar.gz |
| 152 | +cd flint-$FLINTVER |
| 153 | + ./configure --prefix=$PREFIX\ |
| 154 | + $FLINTARB_WITHGMP\ |
| 155 | + --with-mpfr=$PREFIX\ |
| 156 | + --disable-static |
| 157 | + make -j3 |
| 158 | + make install |
| 159 | +cd .. |
| 160 | + |
| 161 | +# ------------------------------------------------------------------------- # |
| 162 | +# # |
| 163 | +# ARB # |
| 164 | +# # |
| 165 | +# ------------------------------------------------------------------------- # |
| 166 | + |
| 167 | +curl -O -L https://github.com/fredrik-johansson/arb/archive/refs/tags/$ARBVER.tar.gz |
| 168 | +mv $ARBVER.tar.gz arb-$ARBVER.tar.gz |
| 169 | +tar xf arb-$ARBVER.tar.gz |
| 170 | +cd arb-$ARBVER |
| 171 | + ./configure --prefix=$PREFIX\ |
| 172 | + --with-flint=$PREFIX\ |
| 173 | + $FLINTARB_WITHGMP\ |
| 174 | + --with-mpfr=$PREFIX\ |
| 175 | + --disable-static |
| 176 | + make -j3 |
| 177 | + make install |
| 178 | +cd .. |
| 179 | + |
| 180 | +# ------------------------------------------------------------------------- # |
| 181 | +# # |
| 182 | +# Done! # |
| 183 | +# # |
| 184 | +# ------------------------------------------------------------------------- # |
| 185 | + |
| 186 | +echo |
| 187 | +echo ----------------------------------------------------------------------- |
| 188 | +echo |
| 189 | +echo Build dependencies for python-flint compiled as shared libraries in: |
| 190 | +echo $PREFIX |
| 191 | +echo |
| 192 | +echo Versions: |
| 193 | +if [[ $USE_GMP = "gmp" ]]; then |
| 194 | + echo GMP: $GMPVER |
| 195 | +else |
| 196 | + echo MPIR: $MPIRVER |
| 197 | +fi |
| 198 | +echo MPFR: $MPFRVER |
| 199 | +echo Flint: $FLINTVER |
| 200 | +echo Arb: $ARBVER |
| 201 | +echo |
| 202 | +echo ----------------------------------------------------------------------- |
| 203 | +echo |
0 commit comments