Skip to content

Instantly share code, notes, and snippets.

@andres-erbsen
Last active December 23, 2018 13:33
Show Gist options
  • Save andres-erbsen/2139718c00b268e9c5bf658cbcd62d75 to your computer and use it in GitHub Desktop.
Save andres-erbsen/2139718c00b268e9c5bf658cbcd62d75 to your computer and use it in GitHub Desktop.
#!/bin/sh -eu
prefix="$(pwd)/coq-bootstrap"
ocamlversion=4.07.0
findlibversion=1.8.0
camlp5version=706
numversion=1.1
coqbranches="master v8.9 v8.8"
jobs=4
mkdir "$prefix"
mkdir "$prefix/common"
mkdir "$prefix/common/bin"
prefix=$(realpath "$prefix")
export PATH="$prefix/common/bin:$PATH"
build=$(mktemp -d)
cd "$build"
curl "http://caml.inria.fr/pub/distrib/ocaml-$(echo "$ocamlversion" | cut -d. -f-2)/ocaml-$ocamlversion.tar.gz" "-#" | tar -xz
cd "ocaml-$ocamlversion"
./configure --prefix "$prefix/common" -no-shared-libs -lib -
static --flambda --no-curses --no-graph --disable-libunwind --no-debug-runtime --no-instrumented-runtime --no-debugger --no-ocamldoc --disable-call-counts --no-cfi
make -j"$jobs" world.opt
make -j"$jobs" install
cd ..
curl "http://download.camlcity.org/download/findlib-$findlibversion.tar.gz" "-#" | tar -xz
cd "findlib-$findlibversion"
./configure
printf "OCAMLOPT_FLAGS+=-ccopt -static\n" > Makefile.conf
make -j"$jobs"
make -j"$jobs" install
cd ..
curl "https://codeload.github.com/ocaml/num/tar.gz/v$numversion" "-#" | tar -xz
cd "num-$numversion"
make -j"$jobs"
make -j"$jobs" install
cd ..
curl "https://codeload.github.com/camlp5/camlp5/tar.gz/rel$camlp5version" "-#" | tar -xz
cd "camlp5-rel$camlp5version"
./configure --libdir "$prefix/common/lib/ocaml/site-lib" # idk why pass this here, but not passing this results in ocamlfind not finding camlp5 during coq make (but fine during configure)
make -j"$jobs"
make -j"$jobs" install
cd ..
for coqbranch in $coqbranches; do
curl "https://codeload.github.com/coq/coq/zip/$coqbranch" -o "coq-$coqbranch.zip" "-#"
unzip "coq-$coqbranch.zip" # bsdtar unzip pipe loses file permissions
rm "coq-$coqbranch.zip"
cd "coq-$coqbranch"
git apply ~/coq-static.patch
/home/opam/.opam/4.06.0+flambda/bin/ocaml -w -3 ./configure.ml -prefix /home/opam/coq-bootstrap/master -natdynlink no -coqide no -with-doc no -nodebug -bytecode-compiler yes -native-compiler yes
make -j"$jobs"
make -j"$jobs" install
cd ..
done
cd ..
rm -rf "$build"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment