1 files changed, 37 insertions(+), 0 deletions(-)
A gmp.sh
A gmp.sh => gmp.sh +37 -0
@@ 0,0 1,37 @@
+#!/bin/sh
+# $ opam install zarith
+# https://github.com/ocaml/Zarith/issues/77#issuecomment-991797884
+#
+# 'Opam install fails with OCaml 4.12 flambda musl static'
+# https://github.com/nberth/mlgmpidl/issues/11#issuecomment-884881150
+#
+set -eu
+
+musl-gcc --version >/dev/null || {
+ echo "install \$ sudo apt-get install musl-tools"
+ exit 1
+}
+lzip --version >/dev/null || {
+ echo "install \$ sudo apt-get install lzip"
+ exit 1
+}
+
+readonly prefix="$HOME/.opam/$(opam switch show)/share/gmp-prefix"
+
+rm -r "$prefix" 2>/dev/null || true
+mkdir -p "$prefix"
+cd "$prefix" || exit 1
+
+# MUSL-based GMP
+curl --silent -LO https://gmplib.org/download/gmp/gmp-6.2.1.tar.lz \
+ && tar xaf gmp-6.2.1.tar.lz \
+ && cd gmp-6.2.1 \
+ && CC=musl-gcc ./configure --prefix "$prefix" \
+ && make \
+ && make check \
+ && make install \
+ && cd ..
+
+# https://github.com/ocaml/Zarith/issues/77#issuecomment-991797884
+CPPFLAGS=-I"$prefix/include" LDFLAGS=-L"$prefix/lib" opam install zarith
+