|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +while [[ $# -gt 0 ]] |
| 6 | +do |
| 7 | + key="$1" |
| 8 | + case $key in |
| 9 | + -h|--help) |
| 10 | + echo "bin/pyodide_build_dependencies.sh [options]" |
| 11 | + echo |
| 12 | + echo "Build local emscripten installs of python-flint's dependencies." |
| 13 | + echo |
| 14 | + echo "Supported options:" |
| 15 | + echo " --help - show this help message" |
| 16 | + echo " --wasm-library-dir <WASM_LIBRARY_DIR> - directory to install libraries" |
| 17 | + echo " --flint-commit <FLINT_COMMIT> - flint commit to build" |
| 18 | + echo |
| 19 | + exit |
| 20 | + ;; |
| 21 | + --wasm-library-dir) |
| 22 | + # e.g. --wasm-library-dir /path/to/wasm-library-dir |
| 23 | + WASM_LIBRARY_DIR="$2" |
| 24 | + shift |
| 25 | + shift |
| 26 | + ;; |
| 27 | + --flint-commit) |
| 28 | + # e.g. --flint-commit 3.3.1 |
| 29 | + FLINT_COMMIT="$2" |
| 30 | + shift |
| 31 | + shift |
| 32 | + ;; |
| 33 | + *) |
| 34 | + 2>&1 echo "unrecognised argument:" $key |
| 35 | + exit 1 |
| 36 | + ;; |
| 37 | + esac |
| 38 | +done |
| 39 | + |
| 40 | + |
| 41 | +if [ -z "$WASM_LIBRARY_DIR" ]; then |
| 42 | + echo "WASM_LIBRARY_DIR not set" |
| 43 | + exit 1 |
| 44 | +fi |
| 45 | + |
| 46 | +source bin/build_variables.sh |
| 47 | + |
| 48 | + |
| 49 | +# ---------------------------Build GMP ----------------------------------# |
| 50 | + |
| 51 | + |
| 52 | +curl -L https://ftp.gnu.org/gnu/gmp/gmp-$GMPVER.tar.xz -o gmp-$GMPVER.tar.xz |
| 53 | +tar -xf gmp-$GMPVER.tar.xz |
| 54 | + |
| 55 | +cd gmp-$GMPVER |
| 56 | + |
| 57 | + emconfigure ./configure \ |
| 58 | + --disable-dependency-tracking \ |
| 59 | + --host none \ |
| 60 | + --disable-shared \ |
| 61 | + --enable-static \ |
| 62 | + --enable-cxx \ |
| 63 | + --prefix=$WASM_LIBRARY_DIR |
| 64 | + |
| 65 | + emmake make -j $(nproc) |
| 66 | + emmake make install |
| 67 | + |
| 68 | +cd .. |
| 69 | + |
| 70 | + |
| 71 | +# ---------------------------Build MPFR ----------------------------------# |
| 72 | + |
| 73 | + |
| 74 | +curl -L https://ftp.gnu.org/gnu/mpfr/mpfr-$MPFRVER.tar.xz -o mpfr-$MPFRVER.tar.xz |
| 75 | +tar -xf mpfr-$MPFRVER.tar.xz |
| 76 | + |
| 77 | +cd mpfr-$MPFRVER |
| 78 | + |
| 79 | + emconfigure ./configure \ |
| 80 | + --disable-dependency-tracking \ |
| 81 | + --disable-shared \ |
| 82 | + --with-gmp=$WASM_LIBRARY_DIR \ |
| 83 | + --prefix=$WASM_LIBRARY_DIR |
| 84 | + |
| 85 | + emmake make -j $(nproc) |
| 86 | + emmake make install |
| 87 | + |
| 88 | +cd .. |
| 89 | + |
| 90 | + |
| 91 | +# ---------------------------Build FLINT----------------------------------# |
| 92 | + |
| 93 | + |
| 94 | +if [ -z "$FLINT_COMMIT" ]; then |
| 95 | + curl -O -L https://github.com/flintlib/flint/releases/download/v$FLINTVER/flint-$FLINTVER.tar.gz |
| 96 | + tar xf flint-$FLINTVER.tar.gz |
| 97 | + cd flint-$FLINTVER |
| 98 | +else |
| 99 | + git clone https://github.com/flintlib/flint --branch $FLINT_COMMIT |
| 100 | + cd flint |
| 101 | +fi |
| 102 | + |
| 103 | + ./bootstrap.sh |
| 104 | + |
| 105 | + emconfigure ./configure \ |
| 106 | + --disable-dependency-tracking \ |
| 107 | + --disable-shared \ |
| 108 | + --prefix=$WASM_LIBRARY_DIR \ |
| 109 | + --with-gmp=$WASM_LIBRARY_DIR \ |
| 110 | + --with-mpfr=$WASM_LIBRARY_DIR \ |
| 111 | + --host=wasm32-unknown-emscripten \ |
| 112 | + --disable-assembly \ |
| 113 | + --disable-pthread |
| 114 | + |
| 115 | + emmake make -j $(nproc) |
| 116 | + emmake make install |
| 117 | + |
| 118 | +cd .. |
0 commit comments