10
1
mirror of https://gitlab.com/scemama/qmcchem.git synced 2024-12-22 20:33:32 +01:00
qmcchem/install/scripts/install_ocaml.sh

99 lines
2.0 KiB
Bash
Raw Normal View History

2015-12-18 22:25:32 +01:00
#!/bin/bash -x
set -u
set -e
2015-12-18 22:53:27 +01:00
cd .. ; QMCCHEM_PATH="$PWD" ; cd -
2020-11-02 22:13:40 +01:00
PACKAGES="cryptokit ocamlbuild getopt ocamlfind sexplib ppx_sexp_conv ppx_deriving"
2015-12-18 22:25:32 +01:00
# return 0 if program version is equal or greater than check version
check_version () {
if [[ $1 == $2 ]]
then
return 0
fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
do
ver1[i]=0
done
for ((i=0; i<${#ver1[@]}; i++))
do
if [[ -z ${ver2[i]} ]]
then
# fill empty fields in ver2 with zeros
ver2[i]=0
fi
if ((10#${ver1[i]} > 10#${ver2[i]}))
then
return 1
fi
if ((10#${ver1[i]} < 10#${ver2[i]}))
then
2016-06-18 22:40:22 +02:00
return 0
fi
done
return 0
}
i=$(gcc -dumpversion)
check_version 4.6 $i
if [[ $? == 1 ]]
2015-12-18 22:25:32 +01:00
then
echo "GCC version $(gcc -dumpversion) too old. GCC >= 4.6 required."
exit 1
fi
2015-12-19 02:35:13 +01:00
set +u
2015-12-18 22:53:27 +01:00
source "${QMCCHEM_PATH}"/qmcchemrc
2015-12-19 02:35:13 +01:00
set -u
2015-12-18 22:25:32 +01:00
cd Downloads
chmod +x opam_installer.sh
2019-07-01 13:11:46 +02:00
rm --force ${QMCCHEM_PATH}/bin/opam
2020-11-02 18:13:53 +01:00
export OPAMROOT=${OPAMROOT:-${HOME}/.opam}
2019-07-01 13:11:46 +02:00
2015-12-18 22:25:32 +01:00
2019-07-01 13:11:46 +02:00
if [[ -d "$OPAMROOT" ]]
2015-12-18 22:25:32 +01:00
then
set +e
set +u
2019-07-01 13:11:46 +02:00
source "${OPAMROOT}"/opam-init/init.sh
2015-12-18 22:25:32 +01:00
set -e
set -u
2019-07-01 13:11:46 +02:00
rm -f ${QMCCHEM_PATH}/bin/opam
ln -s $(which opam) ${QMCCHEM_PATH}/bin/opam
2015-12-18 22:25:32 +01:00
fi
2019-07-01 13:11:46 +02:00
cat << EOF | bash ./opam_installer.sh --no-backup
${QMCCHEM_PATH}/bin/
EOF
2015-12-18 22:25:32 +01:00
if [[ ! -f "${QMCCHEM_PATH}"/bin/opam ]]
then
echo "Installation of OPAM failed"
exit 2
fi
2019-07-01 13:11:46 +02:00
source ${OPAMROOT}/opam-init/init.sh > /dev/null 2> /dev/null || true
2020-11-02 22:02:04 +01:00
${QMCCHEM_PATH}/bin/opam init --verbose --yes --compiler=4.10.0 --disable-sandboxing
2015-12-18 22:25:32 +01:00
touch "${QMCCHEM_PATH}"/bin/opam
2019-07-01 13:11:46 +02:00
eval $(${QMCCHEM_PATH}/bin/opam env)
2015-12-18 22:25:32 +01:00
set +u
export LD_LIBRARY_PATH="${QMCCHEM_PATH}/lib:${LD_LIBRARY_PATH}"
export LIBRARY_PATH="${QMCCHEM_PATH}/lib:${LIBRARY_PATH}"
export C_INCLUDE_PATH="${QMCCHEM_PATH}/lib:${C_INCLUDE_PATH}"
set -u
2020-11-02 22:13:40 +01:00
opam install -y --unlock-base ${PACKAGES} || exit 3
2015-12-18 22:53:27 +01:00
rm "${QMCCHEM_PATH}"/install/_build/ocaml.log
2015-12-18 22:25:32 +01:00
exit 0