2018-11-20 11:33:07 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Quantum Package configuration script
|
|
|
|
#
|
2015-06-11 11:58:26 +02:00
|
|
|
|
2018-11-20 11:33:07 +01:00
|
|
|
help()
|
|
|
|
{
|
|
|
|
cat <<EOF
|
|
|
|
Quantum Package configuration script.
|
2015-06-11 11:58:26 +02:00
|
|
|
|
2018-11-20 11:33:07 +01:00
|
|
|
Usage:
|
|
|
|
configure -c <file> | --config <file>
|
|
|
|
configure -h | --help
|
|
|
|
configure -i <package> | --install <package>
|
2015-06-11 16:25:35 +02:00
|
|
|
|
2015-06-11 11:58:26 +02:00
|
|
|
Options:
|
2018-11-20 11:33:07 +01:00
|
|
|
-c <file>, --config <file> define a configuration file, in
|
|
|
|
"${QP_ROOT}/config/"
|
|
|
|
-h, --help print the help message
|
|
|
|
-i <package>, --install <package> install <package>. Use at your own risk.
|
2015-06-11 16:25:35 +02:00
|
|
|
|
2018-11-20 11:33:07 +01:00
|
|
|
Example:
|
|
|
|
./configure -c config/gfortran.cfg
|
2015-06-11 16:25:35 +02:00
|
|
|
|
|
|
|
|
2018-11-20 11:33:07 +01:00
|
|
|
EOF
|
|
|
|
exit
|
|
|
|
}
|
2015-07-03 15:42:12 +02:00
|
|
|
|
2015-06-11 11:58:26 +02:00
|
|
|
|
2018-11-20 11:33:07 +01:00
|
|
|
PACKAGES=""
|
2015-06-11 11:58:26 +02:00
|
|
|
|
2018-11-20 11:33:07 +01:00
|
|
|
while : ; do
|
|
|
|
case "$1" in
|
|
|
|
"")
|
|
|
|
break;;
|
|
|
|
-c|--config)
|
|
|
|
CONFIG="$2"
|
|
|
|
shift;;
|
|
|
|
-i|--install)
|
|
|
|
PACKAGES="${PACKAGE} $2"
|
|
|
|
shift;;
|
|
|
|
-h|--help)
|
|
|
|
help;;
|
|
|
|
*)
|
|
|
|
echo "unknown option $1, try --help"
|
|
|
|
exit 2;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2015-06-11 11:58:26 +02:00
|
|
|
|
2018-11-20 11:33:07 +01:00
|
|
|
# Trim leading and trailing spaces
|
|
|
|
PACKAGES=$(echo $PACKAGES | xargs)
|
2015-06-11 11:58:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-11-20 11:33:07 +01:00
|
|
|
sed "s!^export QP_ROOT=.*\$!export QP_ROOT=\"$PWD\"!" quantum_package.rc.default > quantum_package.rc
|
|
|
|
|
|
|
|
echo "quantum_package.rc created."
|
|
|
|
|
|
|
|
source quantum_package.rc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function fail() {
|
|
|
|
echo "Please refer to INSTALL.rst to install the missing dependencies."
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function success() {
|
|
|
|
echo ""
|
|
|
|
echo "Configuration successful."
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function error() {
|
|
|
|
echo "Error : $1"
|
|
|
|
exit 2
|
|
|
|
}
|
|
|
|
|
|
|
|
function download() {
|
|
|
|
wget --no-check-certificate $1 -O $2 || error "Unable to download $1"
|
|
|
|
}
|
|
|
|
|
|
|
|
function find_exe() {
|
|
|
|
which $1 2> /dev/null || echo 'not_found'
|
|
|
|
}
|
|
|
|
|
|
|
|
function find_python_lib() {
|
|
|
|
python2 -c "import $1" &> /dev/null && echo "$1" || echo 'not_found'
|
|
|
|
}
|
|
|
|
|
|
|
|
function find_lib() {
|
|
|
|
echo "int main() { return 0; }" > "${QP_ROOT}"/external/tmp.c
|
2018-11-21 12:58:20 +01:00
|
|
|
gcc $@ "${QP_ROOT}"/external/tmp.c -o "${QP_ROOT}"/external/tmp.exe 2> /dev/null
|
2018-11-20 11:33:07 +01:00
|
|
|
if [[ -x "${QP_ROOT}"/external/tmp.exe ]] ; then
|
|
|
|
rm "${QP_ROOT}"/external/tmp.exe "${QP_ROOT}"/external/tmp.c
|
2018-11-21 12:58:20 +01:00
|
|
|
echo "$lib"
|
2018-11-20 11:33:07 +01:00
|
|
|
else
|
|
|
|
rm "${QP_ROOT}"/external/tmp.c
|
|
|
|
echo "not_found"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function find_dir() {
|
|
|
|
if [[ -d $1 ]] ; then
|
|
|
|
echo "$1"
|
|
|
|
else
|
|
|
|
echo "not_found"
|
|
|
|
fi
|
2015-06-11 11:58:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-20 11:33:07 +01:00
|
|
|
if [[ "${PACKAGES}.x" != ".x" ]] ; then
|
|
|
|
echo ""
|
|
|
|
echo "#########################################################"
|
|
|
|
echo "# #"
|
|
|
|
echo "# Automatic installation of dependencies #"
|
|
|
|
echo "# #"
|
|
|
|
echo "# USE AT YOUR OWN RISK : #"
|
|
|
|
echo "# No support will be provided by the quantum package #"
|
|
|
|
echo "# developers for the installation of external software. #"
|
|
|
|
echo "# #"
|
|
|
|
echo "# You may refer to the INSTALL.rst file for help. #"
|
|
|
|
echo "# #"
|
|
|
|
echo "#########################################################"
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ${PACKAGES} = all ]] ; then
|
|
|
|
PACKAGES="ninja irpf90 zeromq f77zmq ocaml ezfio emsl docopt resultsFile"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
for PACKAGE in ${PACKAGES} ; do
|
|
|
|
|
|
|
|
if [[ ${PACKAGE} = ninja ]] ; then
|
|
|
|
|
|
|
|
download \
|
|
|
|
"https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip" \
|
|
|
|
"${QP_ROOT}"/external/ninja.zip
|
|
|
|
unzip "${QP_ROOT}"/external/ninja.zip -d "${QP_ROOT}"/bin
|
|
|
|
|
|
|
|
|
|
|
|
elif [[ ${PACKAGE} = irpf90 ]] ; then
|
|
|
|
|
|
|
|
download \
|
|
|
|
"https://github.com/scemama/irpf90/archive/v1.7.2.tar.gz" \
|
|
|
|
"${QP_ROOT}"/external/irpf90.tar.gz
|
|
|
|
cd "${QP_ROOT}"/external
|
|
|
|
tar -zxf irpf90.tar.gz
|
|
|
|
rm irpf90.tar.gz
|
|
|
|
cd irpf90-*
|
|
|
|
make
|
|
|
|
for i in irpf90 irpman irpf90_indent
|
|
|
|
do
|
|
|
|
cat << EOF > "${QP_ROOT}"/bin/$i
|
|
|
|
#!/bin/sh
|
|
|
|
exec $PWD/bin/$i \$@
|
|
|
|
EOF
|
|
|
|
|
|
|
|
chmod +x "${QP_ROOT}"/bin/$i
|
|
|
|
done
|
|
|
|
cd "${QP_ROOT}"
|
|
|
|
|
|
|
|
|
|
|
|
elif [[ ${PACKAGE} = zeromq ]] ; then
|
|
|
|
|
|
|
|
download \
|
|
|
|
"https://github.com/zeromq/libzmq/releases/download/v4.2.5/zeromq-4.2.5.tar.gz" \
|
|
|
|
"${QP_ROOT}"/external/zeromq.tar.gz
|
|
|
|
cd "${QP_ROOT}"/external
|
|
|
|
tar -zxf zeromq.tar.gz
|
|
|
|
rm zeromq.tar.gz
|
|
|
|
cd zeromq-*
|
|
|
|
./configure --prefix="$QP_ROOT" --without-libsodium --enable-libunwind=no
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
cd "${QP_ROOT}"
|
|
|
|
|
|
|
|
|
|
|
|
elif [[ ${PACKAGE} = f77zmq ]] ; then
|
|
|
|
|
|
|
|
download \
|
|
|
|
"https://github.com/scemama/f77_zmq/archive/v4.2.5.tar.gz" \
|
|
|
|
"${QP_ROOT}"/external/f77_zmq.tar.gz
|
|
|
|
cd "${QP_ROOT}"/external
|
|
|
|
tar -zxf f77_zmq.tar.gz
|
|
|
|
rm f77_zmq.tar.gz
|
|
|
|
cd f77_zmq-*
|
|
|
|
export ZMQ_H="$QP_ROOT"/include/zmq.h
|
|
|
|
make
|
|
|
|
cp libf77zmq.a "${QP_ROOT}"/lib
|
|
|
|
cp libf77zmq.so "${QP_ROOT}"/lib
|
|
|
|
cp f77_zmq_free.h "${QP_ROOT}"/include
|
|
|
|
cd "${QP_ROOT}"
|
|
|
|
|
|
|
|
|
|
|
|
elif [[ ${PACKAGE} = ocaml ]] ; then
|
|
|
|
|
|
|
|
download \
|
|
|
|
"https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh" \
|
|
|
|
"${QP_ROOT}"/external/opam_installer.sh
|
|
|
|
chmod +x "${QP_ROOT}"/external/opam_installer.sh
|
|
|
|
rm -f ${QP_ROOT}/bin/opam
|
|
|
|
|
|
|
|
if [[ ${TRAVIS} = true ]] ; then
|
|
|
|
# Special commands for Travis CI
|
|
|
|
export OPAMROOT=${HOME}/.opam
|
|
|
|
cat << EOF | ${QP_ROOT}/external/opam_installer.sh --no-backup
|
|
|
|
${QP_ROOT}/bin
|
|
|
|
|
|
|
|
|
|
|
|
EOF
|
|
|
|
source ${OPAMROOT}/opam-init/init.sh > /dev/null 2> /dev/null || true
|
|
|
|
|
|
|
|
else
|
|
|
|
# Conventional commands
|
|
|
|
export OPAMROOT=${OPAMROOT:-${QP_ROOT}/external/opam}
|
|
|
|
echo ${QP_ROOT}/bin
|
|
|
|
${QP_ROOT}/external/opam_installer.sh
|
|
|
|
fi
|
|
|
|
rm ${QP_ROOT}/external/opam_installer.sh
|
|
|
|
|
|
|
|
${QP_ROOT}/bin/opam init --disable-sandboxing --verbose --yes --comp=4.07.0
|
|
|
|
|
|
|
|
eval $(${QP_ROOT}/bin/opam env)
|
|
|
|
opam install -y ocamlbuild cryptokit zmq core sexplib ppx_sexp_conv ppx_deriving
|
|
|
|
|
|
|
|
|
|
|
|
elif [[ ${PACKAGE} = ezfio ]] ; then
|
|
|
|
|
|
|
|
download \
|
|
|
|
"https://gitlab.com/scemama/EZFIO/-/archive/master/EZFIO-master.tar.gz" \
|
|
|
|
"${QP_ROOT}"/external/ezfio.tar.gz
|
|
|
|
cd "${QP_ROOT}"/external
|
|
|
|
tar -zxf ezfio.tar.gz
|
|
|
|
mv EZFIO-* ezfio
|
|
|
|
cd "${QP_ROOT}"
|
|
|
|
|
|
|
|
|
|
|
|
elif [[ ${PACKAGE} = emsl ]] ; then
|
|
|
|
|
|
|
|
download \
|
|
|
|
"https://github.com/LCPQ/EMSL_Basis_Set_Exchange_Local/archive/v1.0.tar.gz" \
|
|
|
|
"${QP_ROOT}"/external/EMSL.tar.gz
|
|
|
|
cd "${QP_ROOT}"/external
|
|
|
|
tar -zxf EMSL.tar.gz
|
|
|
|
mv EMSL_Basis* emsl
|
|
|
|
cd "${QP_ROOT}"
|
|
|
|
|
|
|
|
|
|
|
|
elif [[ ${PACKAGE} = docopt ]] ; then
|
|
|
|
|
|
|
|
download \
|
|
|
|
"https://github.com/docopt/docopt/archive/0.6.2.tar.gz" \
|
|
|
|
"${QP_ROOT}"/external/docopt.tar.gz
|
|
|
|
cd "${QP_ROOT}"/external
|
|
|
|
tar -zxf docopt.tar.gz
|
|
|
|
mv docopt-*/docopt.py "${QP_ROOT}/external/Python"
|
|
|
|
rm -rf docopt-*/ docopt.tar.gz
|
|
|
|
cd "${QP_ROOT}"
|
|
|
|
|
|
|
|
|
|
|
|
elif [[ ${PACKAGE} = resultsFile ]] ; then
|
|
|
|
|
|
|
|
download \
|
|
|
|
"https://gitlab.com/scemama/resultsFile/-/archive/master/resultsFile-master.tar.gz" \
|
|
|
|
"${QP_ROOT}"/external/resultsFile.tar.gz
|
|
|
|
cd "${QP_ROOT}"/external
|
|
|
|
tar -zxf resultsFile.tar.gz
|
|
|
|
mv resultsFile-master/resultsFile "${QP_ROOT}/external/Python"
|
|
|
|
rm -rf resultsFile-master resultsFile.tar.gz
|
|
|
|
cd "${QP_ROOT}"
|
|
|
|
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
NINJA=$(find_exe ninja)
|
|
|
|
if [[ ${NINJA} = not_found ]] ; then
|
|
|
|
echo "Ninja is not installed."
|
|
|
|
fail
|
|
|
|
fi
|
|
|
|
|
|
|
|
IRPF90=$(find_exe irpf90)
|
|
|
|
if [[ ${IRPF90} = not_found ]] ; then
|
|
|
|
echo "IRPf90 is not installed."
|
|
|
|
fail
|
|
|
|
fi
|
|
|
|
|
|
|
|
ZEROMQ=$(find_lib -lzmq)
|
|
|
|
if [[ ${ZEROMQ} = not_found ]] ; then
|
|
|
|
echo "ZeroMQ is not installed."
|
|
|
|
fail
|
|
|
|
fi
|
|
|
|
|
|
|
|
F77ZMQ=$(find_lib -lzmq -lf77zmq)
|
|
|
|
if [[ ${F77ZMQ} = not_found ]] ; then
|
|
|
|
echo "Fortran binding of ZeroMQ is not installed."
|
|
|
|
fail
|
|
|
|
fi
|
|
|
|
|
|
|
|
OPAM=$(find_exe opam)
|
|
|
|
if [[ ${OPAM} = not_found ]] ; then
|
|
|
|
echo "OPAM package manager is not installed."
|
|
|
|
fail
|
|
|
|
fi
|
|
|
|
|
|
|
|
OCAML=$(find_exe ocaml)
|
|
|
|
if [[ ${OCAML} = not_found ]] ; then
|
|
|
|
echo "OCaml compiler is not installed."
|
|
|
|
fail
|
|
|
|
fi
|
|
|
|
|
|
|
|
EZFIO=$(find_dir "${QP_ROOT}"/external/ezfio)
|
|
|
|
if [[ ${EZFIO} = not_found ]] ; then
|
|
|
|
echo "EZFIO is not installed."
|
|
|
|
fail
|
|
|
|
fi
|
|
|
|
|
|
|
|
EMSL=$(find_dir "${QP_ROOT}"/external/emsl)
|
|
|
|
if [[ ${EMSL} = not_found ]] ; then
|
|
|
|
echo "EMSL is not installed."
|
|
|
|
fail
|
|
|
|
fi
|
|
|
|
|
|
|
|
DOCOPT=$(find_python_lib docopt)
|
|
|
|
if [[ ${DOCOPT} = not_found ]] ; then
|
|
|
|
echo "docopt is not installed."
|
|
|
|
fail
|
|
|
|
fi
|
|
|
|
|
|
|
|
RESULTSFILE=$(find_python_lib resultsFile)
|
|
|
|
if [[ ${RESULTSFILE} = not_found ]] ; then
|
|
|
|
echo "resultsFile is not installed."
|
|
|
|
fail
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "All dependencies installed."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [[ -n $CONFIG ]] ; then
|
|
|
|
|
|
|
|
"${QP_ROOT}"/scripts/compilation/qp_create_ninja create --development "${CONFIG}"
|
|
|
|
fi
|
2015-06-11 11:58:26 +02:00
|
|
|
|
|
|
|
|
2015-11-25 11:49:42 +01:00
|
|
|
|