#!/bin/bash # # Quantum Package configuration script # export QP_ROOT="$( cd "$(dirname "$0")" ; pwd -P )" echo "QP_ROOT="$QP_ROOT unset CC unset CCXX # Force GCC instead of ICC for dependencies export CC=gcc # Download submodules git submodule init git submodule update function help() { cat < $(basename $0) -h $(basename $0) -i Options: -c Define a COMPILATION configuration file, in "${QP_ROOT}/config/". -h Print the HELP message -i INSTALL . Use at your OWN RISK: no support will be provided for the installation of dependencies. Example: ./$(basename $0) -c config/gfortran.cfg Note: Users are encouraged to create their own configuration files instead of modifying the existing ones. EOF exit } function error() { >&2 echo "$(basename $0): $@" exit 2 } function execute () { local _command echo "Executing:" while read -r line; do echo " " $line _command+="${line} ;" done sleep 1 echo "" printf "\e[0;94m" ( eval "set -x ; $_command set +x" ) || exit -1 printf "\e[m" echo "" } PACKAGES="" while getopts "d:c:i:h" c ; do case "$c" in c) case "$OPTARG" in "") help ; break;; *) if [[ -f $OPTARG ]] ; then CONFIG="$OPTARG" else error "error: configuration file $OPTARG not found." exit 1 fi esac;; i) case "$OPTARG" in "") help ; break;; *) PACKAGES="${PACKAGE} $OPTARG" esac;; h) help exit 0;; *) error $(basename $0)": unknown option $c, try -h for help" exit 2;; esac done # Trim leading and trailing spaces PACKAGES=$(echo $PACKAGES | xargs) echo "export QP_ROOT=\"$QP_ROOT\"" > ${QP_ROOT}/etc/00.qp_root.rc source quantum_package.rc function fail() { echo "You can try to install it using the -i option." echo "Please refer to INSTALL.rst to install the missing dependencies." exit -1 } function success() { echo "" echo "Configuration successful." exit 0 } function not_found() { echo 'not_found' } function find_exe() { which $1 2> /dev/null || not_found } function find_python_lib() { python3 -c "import $1" &> /dev/null && echo "$1" || not_found } function find_lib() { echo "int main() { return 0; }" > "${QP_ROOT}"/external/tmp.c gcc $@ "${QP_ROOT}"/external/tmp.c -o "${QP_ROOT}"/external/tmp.exe 2> /dev/null if [[ -x "${QP_ROOT}"/external/tmp.exe ]] ; then rm "${QP_ROOT}"/external/tmp.exe "${QP_ROOT}"/external/tmp.c echo "$lib" else rm "${QP_ROOT}"/external/tmp.c not_found fi } function find_dir() { if [[ -d $1 ]] ; then echo "$1" else not_found fi } # Make program believe stdin is a tty function faketty() { script -qfc "$(printf "%q " "$@")" /dev/null } # Install IRPF90 if needed IRPF90=$(find_exe irpf90) if [[ ${IRPF90} = $(not_found) ]] ; then make -C ${QP_ROOT}/external/irpf90 fi if [[ "${PACKAGES}.x" != ".x" ]] ; then printf "\e[0;31m" 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 "#########################################################" printf "\e[m" echo "" sleep 1 fi if [[ ${PACKAGES} = all ]] ; then PACKAGES="zlib ninja zeromq f77zmq gmp ocaml docopt resultsFile bats trexio" fi for PACKAGE in ${PACKAGES} ; do if [[ ${PACKAGE} = ninja ]] ; then execute << EOF rm -f "\${QP_ROOT}"/bin/ninja unzip "\${QP_ROOT}"/external/qp2-dependencies/ninja-linux.zip -d "\${QP_ROOT}"/bin EOF elif [[ ${PACKAGE} = trexio ]] ; then VERSION="2.2.0" execute << EOF cd "\${QP_ROOT}"/external wget https://github.com/TREX-CoE/trexio/releases/download/v${VERSION}/trexio-${VERSION}.tar.gz tar -zxf trexio-${VERSION}.tar.gz cd trexio-${VERSION} ./configure --prefix=\${QP_ROOT} make -j 8 && make -j 8 check && make -j 8 install EOF elif [[ ${PACKAGE} = gmp ]] ; then execute << EOF cd "\${QP_ROOT}"/external tar --bzip2 --extract --file qp2-dependencies/gmp-6.1.2.tar.bz2 cd gmp-6.1.2 ./configure --prefix=$QP_ROOT && make -j 8 make -j 8 install EOF elif [[ ${PACKAGE} = zeromq ]] ; then execute << EOF export CC=gcc export CXX=g++ cd "\${QP_ROOT}"/external tar --gunzip --extract --file qp2-dependencies/zeromq-4.2.5.tar.gz cd zeromq-* ./configure --prefix="\$QP_ROOT" --without-libsodium --enable-libunwind=no make -j 8 make install EOF elif [[ ${PACKAGE} = f77zmq ]] ; then execute << EOF cd "\${QP_ROOT}"/external tar --gunzip --extract --file qp2-dependencies/f77-zmq-4.3.2.tar.gz cd f77-zmq-* ./configure --prefix=\$QP_ROOT export ZMQ_H="\$QP_ROOT"/include/zmq.h make && make check && make install EOF elif [[ ${PACKAGE} = ocaml ]] ; then execute <" echo " --------------------------- " echo " \ ^__^ " echo " \ (oo)\_______ " echo " (__)\ )\/\. " echo " ||----w | " echo " || || " echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" echo "" echo "If you have PIP, you can install the Basis Set Exchange command-line tool:" echo "" echo " ./configure -i bse" echo "" echo "This will enable the usage of qp_basis to install extra basis sets." echo "" echo "" printf "\e[m\n" if [[ -n $CONFIG ]] ; then "${QP_ROOT}"/scripts/compilation/qp_create_ninja create --development "${CONFIG}" fi if [[ -f ${QP_ROOT}/build.ninja ]] ; then [[ -z ${TRAVIS} ]] && echo "You can now run ./bin/qpsh to enter in the QP shell mode :)" else echo "" echo "${QP_ROOT}/build.ninja does not exist," echo "you need to specify the COMPILATION configuration file." echo "See ./configure --help for more details." echo "" fi exit 0