https://github.com/EasyCrypt/easycrypt
Tip revision: a79f9aeb6de046ca12210d26317fab59c175d0dd authored by Pierre-Yves Strub on 08 July 2014, 09:43:21 UTC
Fix bug w.r.t. _tools presence detection.
Fix bug w.r.t. _tools presence detection.
Tip revision: a79f9ae
ec-build-toolchain
#! /bin/bash
# --------------------------------------------------------------------
set -e
# --------------------------------------------------------------------
: ${OVERSION=4.01.0}
: ${DEST="${PWD}/_tools"} # MUST BE ABSOLUTE
# --------------------------------------------------------------------
PATCHES=ocaml-patches.diff
OBREW_URL=https://www.easycrypt.info/toolchain/ocamlbrew
OPAM_VERSION=1.1.1
OPAM_URL=http://www.ocamlpro.com/pub/opam-full-${OPAM_VERSION}.tar.gz
ECOPAM_URL=https://www.easycrypt.info/opam-${OPAM_VERSION}
OCONFIG_BASE="ocaml-${OVERSION}/etc/ocamlbrew.bashrc"
OCONFIG="${DEST}/${OCONFIG_BASE}"
export OCAMLBREW_BASE=${DEST}
export OCAMLBREW_FLAGS="-v ${OVERSION} -p ${PWD}/scripts/patches/${PATCHES} -f"
export OPAMROOT=${DEST}/ocaml-${OVERSION}/opam
export OPAMFLAGS="--no-setup default ${ECOPAM_URL}"
unset OCAMLFIND_CONF
unset OCAML_TOPLEVEL_PATH
unset CAML_LD_LIBRARY_PATH
case $(uname -s) in
CYGWIN*)
buildtype=cygwin;;
*)
buildtype=posix;;
esac
# --------------------------------------------------------------------
if [ "${DEST}" != "${DEST//[ ]/}" ]; then
echo "Destination folder contains spaces" >&2
echo "Please, set the DEST variable to a valid value" >&2
exit 1
fi
# --------------------------------------------------------------------
function check_cmd {
if ! type -P "$1" >/dev/null 2>&1; then
echo "missing program: $1. install it first" >&2
exit 1
fi
}
check_cmd m4
check_cmd autoconf
check_cmd gcc
check_cmd g++
check_cmd curl
if [ ${buildtype} = "cygwin" ]; then
check_cmd ocaml
fi
# --------------------------------------------------------------------
set -e
rm -rf "${DEST}" && mkdir "${DEST}" "${DEST}/src"
if [ ${buildtype} != "cygwin" ]; then
curl -f -kL -o "${DEST}/src/ocamlbrew" ${OBREW_URL}
bash "${DEST}/src/ocamlbrew" ${OCAMLBREW_FLAGS}
else
mkdir "${DEST}"/ocaml-${OVERSION}/
mkdir "${DEST}"/ocaml-${OVERSION}/build
mkdir "${DEST}"/ocaml-${OVERSION}/etc
cat >>"${OCONFIG}" <<-EOF
export PATH="${DEST}/ocaml-${OVERSION}/bin:\${PATH}"
EOF
fi
# --------------------------------------------------------------------
function build_opam {
source "${OCONFIG}"
curl -f -kL -O ${OPAM_URL}
rm -rf opam-full-${OPAM_VERSION}
tar -xozf opam-full-${OPAM_VERSION}.tar.gz
cd opam-full-${OPAM_VERSION}
./configure --prefix="${DEST}/ocaml-${OVERSION}"
make && make install
"${DEST}"/ocaml-${OVERSION}/bin/opam init ${OPAMFLAGS}
cat >>"${OCONFIG}" <<-EOF
export PS1="(ec-tool) \${PS1}"
export OCAMLFIND_CONF="${DEST}/ocaml-${OVERSION}/opam/system/lib/findlib.conf"
export OPAMROOT="${OPAMROOT}"
EOF
echo "eval \`${DEST}/ocaml-${OVERSION}/bin/opam config env\`" >>"${OCONFIG}"
}
( set -e; cd "${DEST}"/ocaml-${OVERSION}/build && build_opam )
source "${OCONFIG}"
opam install -v -y ec-toolchain
# --------------------------------------------------------------------
set +xe
function box {
echo
echo "$@" |sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$p' -e '$x'
echo
}
box "EasyCrypt toolchain installed"
cat <<EOF
%%% --------------------------------------------------------------------
%%%
%%% To use it, type:
%%%
%%% \$(./scripts/activate-toolchain.sh)
%%%
%%% Don't forget to [make clean] the easycrypt source tree
%%%
%%% --------------------------------------------------------------------
EOF