10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-12-23 04:43:45 +01:00
QuantumPackage/configure

487 lines
13 KiB
Plaintext
Raw Normal View History

2020-02-26 15:58:14 +01:00
#!/bin/bash
2019-01-25 11:39:31 +01:00
#
# Quantum Package configuration script
#
export QP_ROOT="$( cd "$(dirname "$0")" ; pwd -P )"
echo "QP_ROOT="$QP_ROOT
2019-10-24 13:55:38 +02:00
unset CC
unset CCXX
2019-01-25 11:39:31 +01:00
2024-04-03 15:32:56 +02:00
TREXIO_VERSION=2.4.2
2023-05-10 18:06:50 +02:00
2019-11-19 18:55:21 +01:00
# Force GCC instead of ICC for dependencies
export CC=gcc
2020-12-06 21:27:28 +01:00
# Download submodules
git submodule init
git submodule update
2019-01-25 11:39:31 +01:00
2023-02-06 13:43:09 +01:00
# Update ARM or x86 dependencies
2023-04-18 09:46:11 +02:00
SYSTEM=$(uname -s)
if [[ $SYSTEM = "Linux" ]] ; then
SYSTEM=""
fi
ARCHITECTURE=$(uname -m)$SYSTEM
2023-02-06 13:43:09 +01:00
cd ${QP_ROOT}/external/qp2-dependencies
2023-02-24 16:33:28 +01:00
git checkout master
git pull
2023-02-06 13:43:09 +01:00
echo "Architecture: $ARCHITECTURE"
cd ${QP_ROOT}
2019-01-25 11:39:31 +01:00
function help()
{
cat <<EOF
Quantum Package configuration script.
Usage:
2021-11-16 23:35:30 +01:00
$(basename $0) -c <file>
$(basename $0) -h
$(basename $0) -i <package>
2019-01-25 11:39:31 +01:00
Options:
2021-11-16 23:35:30 +01:00
-c <file> Define a COMPILATION configuration file,
in "${QP_ROOT}/config/".
-h Print the HELP message
-i <package> INSTALL <package>. Use at your OWN RISK:
no support will be provided for the installation of
dependencies.
2019-01-25 11:39:31 +01:00
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} ;"
2020-02-26 15:58:14 +01:00
done
2019-01-25 11:39:31 +01:00
sleep 1
echo ""
printf "\e[0;94m"
( eval "set -x ; $_command set +x" ) || exit -1
printf "\e[m"
echo ""
}
PACKAGES=""
2021-11-16 23:35:30 +01:00
while getopts "d:c:i:h" c ; do
case "$c" in
c)
case "$OPTARG" in
2019-01-25 11:39:31 +01:00
"") help ; break;;
2021-11-16 23:35:30 +01:00
*) if [[ -f $OPTARG ]] ; then
CONFIG="$OPTARG"
2019-01-25 11:39:31 +01:00
else
2021-11-16 23:35:30 +01:00
error "error: configuration file $OPTARG not found."
2019-01-25 11:39:31 +01:00
exit 1
fi
2021-11-16 23:35:30 +01:00
esac;;
i)
case "$OPTARG" in
2019-01-25 11:39:31 +01:00
"") help ; break;;
2021-11-16 23:35:30 +01:00
*) PACKAGES="${PACKAGE} $OPTARG"
esac;;
h)
2019-01-25 11:39:31 +01:00
help
exit 0;;
*)
2022-01-25 22:39:18 +01:00
error $(basename $0)": unknown option $c, try -h for help"
2019-01-25 11:39:31 +01:00
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
2023-02-06 13:42:20 +01:00
source ${QP_ROOT}/quantum_package.rc
2019-01-25 11:39:31 +01:00
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
2019-01-25 11:39:31 +01:00
}
function success() {
echo ""
echo "Configuration successful."
exit 0
2019-01-25 11:39:31 +01:00
}
function not_found() {
echo 'not_found'
}
function find_exe() {
which $1 2> /dev/null || not_found
}
function find_python_lib() {
2020-03-17 16:39:43 +01:00
python3 -c "import $1" &> /dev/null && echo "$1" || not_found
2019-01-25 11:39:31 +01:00
}
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
}
2021-07-05 19:14:59 +02:00
# Make program believe stdin is a tty
function faketty() {
script -qfc "$(printf "%q " "$@")" /dev/null
}
2019-01-25 11:39:31 +01:00
2020-12-06 21:27:28 +01:00
# Install IRPF90 if needed
IRPF90=$(find_exe irpf90)
if [[ ${IRPF90} = $(not_found) ]] ; then
make -C ${QP_ROOT}/external/irpf90
2020-02-20 19:33:42 +01:00
fi
2019-01-25 11:39:31 +01:00
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
2023-11-07 10:42:19 +01:00
PACKAGES="zlib ninja zeromq f77zmq gmp ocaml docopt resultsFile bats trexio"
2019-01-25 11:39:31 +01:00
fi
for PACKAGE in ${PACKAGES} ; do
if [[ ${PACKAGE} = ninja ]] ; then
execute << EOF
rm -f "\${QP_ROOT}"/bin/ninja
tar -zxvf "\${QP_ROOT}"/external/qp2-dependencies/${ARCHITECTURE}/ninja.tar.gz
2023-02-06 13:43:09 +01:00
mv ninja "\${QP_ROOT}"/bin/
2019-01-25 11:39:31 +01:00
EOF
2023-05-10 18:06:50 +02:00
elif [[ ${PACKAGE} = trexio-nohdf5 ]] ; then
VERSION=$TREXIO_VERSION
execute << EOF
cd "\${QP_ROOT}"/external
wget https://github.com/TREX-CoE/trexio/releases/download/v${VERSION}/trexio-${VERSION}.tar.gz
rm -rf trexio-${VERSION}
tar -zxf trexio-${VERSION}.tar.gz && rm trexio-${VERSION}.tar.gz
2023-05-10 18:06:50 +02:00
cd trexio-${VERSION}
2023-09-22 16:26:58 +02:00
./configure --prefix=\${QP_ROOT} --without-hdf5 CFLAGS='-g'
2024-04-03 15:32:56 +02:00
(make -j 8 || make) && make check && make -j 8 install
2023-05-10 18:06:50 +02:00
tar -zxvf "\${QP_ROOT}"/external/qp2-dependencies/${ARCHITECTURE}/ninja.tar.gz
mv ninja "\${QP_ROOT}"/bin/
EOF
elif [[ ${PACKAGE} = trexio ]] ; then
VERSION=$TREXIO_VERSION
execute << EOF
cd "\${QP_ROOT}"/external
wget https://github.com/TREX-CoE/trexio/releases/download/v${VERSION}/trexio-${VERSION}.tar.gz
rm -rf trexio-${VERSION}
tar -zxf trexio-${VERSION}.tar.gz && rm trexio-${VERSION}.tar.gz
2023-05-10 18:06:50 +02:00
cd trexio-${VERSION}
2023-09-22 16:26:58 +02:00
./configure --prefix=\${QP_ROOT} CFLAGS="-g"
2024-04-03 15:32:56 +02:00
(make -j 8 || make) && make check && make -j 8 install
2023-05-10 18:06:50 +02:00
EOF
2023-09-18 18:14:04 +02:00
elif [[ ${PACKAGE} = qmckl ]] ; then
2023-10-06 11:46:24 +02:00
VERSION=0.5.4
2023-09-18 18:14:04 +02:00
execute << EOF
cd "\${QP_ROOT}"/external
wget https://github.com/TREX-CoE/qmckl/releases/download/v${VERSION}/qmckl-${VERSION}.tar.gz
rm -rf qmckl-${VERSION}
tar -zxf qmckl-${VERSION}.tar.gz && rm qmckl-${VERSION}.tar.gz
2023-09-18 18:14:04 +02:00
cd qmckl-${VERSION}
2023-09-22 16:26:58 +02:00
./configure --prefix=\${QP_ROOT} --enable-hpc --disable-doc CFLAGS='-g'
2024-04-03 15:32:56 +02:00
(make -j 8 || make) && make check && make install
2023-09-18 18:14:04 +02:00
EOF
elif [[ ${PACKAGE} = qmckl-intel ]] ; then
VERSION=0.5.4
execute << EOF
cd "\${QP_ROOT}"/external
wget https://github.com/TREX-CoE/qmckl/releases/download/v${VERSION}/qmckl-${VERSION}.tar.gz
rm -rf qmckl-${VERSION}
tar -zxf qmckl-${VERSION}.tar.gz && rm qmckl-${VERSION}.tar.gz
cd qmckl-${VERSION}
./configure --prefix=\${QP_ROOT} --enable-hpc --disable-doc --with-icc --with-ifort CFLAGS='-g'
2024-04-03 15:32:56 +02:00
(make -j 8 || make) && make check && make install
EOF
2023-05-10 18:06:50 +02:00
2019-01-25 11:39:31 +01:00
elif [[ ${PACKAGE} = gmp ]] ; then
execute << EOF
cd "\${QP_ROOT}"/external
2021-07-05 18:15:26 +02:00
tar --bzip2 --extract --file qp2-dependencies/gmp-6.1.2.tar.bz2
2020-12-29 01:27:40 +01:00
cd gmp-6.1.2
./configure --prefix=$QP_ROOT && make -j 8
2021-07-05 18:15:26 +02:00
make -j 8 install
EOF
2019-01-25 11:39:31 +01:00
elif [[ ${PACKAGE} = zeromq ]] ; then
execute << EOF
2020-03-05 08:51:39 +01:00
export CC=gcc
export CXX=g++
2019-01-25 11:39:31 +01:00
cd "\${QP_ROOT}"/external
2021-07-05 18:15:26 +02:00
tar --gunzip --extract --file qp2-dependencies/zeromq-4.2.5.tar.gz
2019-01-25 11:39:31 +01:00
cd zeromq-*
2023-04-18 14:45:44 +02:00
[[ "${SYSTEM}" = "Darwin" ]] && ./autogen.sh
2019-01-25 11:39:31 +01:00
./configure --prefix="\$QP_ROOT" --without-libsodium --enable-libunwind=no
2021-07-05 18:15:26 +02:00
make -j 8
2019-01-25 11:39:31 +01:00
make install
EOF
elif [[ ${PACKAGE} = f77zmq ]] ; then
execute << EOF
cd "\${QP_ROOT}"/external
2023-04-19 09:31:36 +02:00
tar --gunzip --extract --file qp2-dependencies/f77-zmq-4.3.?.tar.gz
2021-11-16 19:22:54 +01:00
cd f77-zmq-*
./configure --prefix=\$QP_ROOT
2019-01-25 11:39:31 +01:00
export ZMQ_H="\$QP_ROOT"/include/zmq.h
2021-11-16 19:22:54 +01:00
make && make check && make install
2019-01-25 11:39:31 +01:00
EOF
2020-02-26 15:58:14 +01:00
2019-01-25 11:39:31 +01:00
elif [[ ${PACKAGE} = ocaml ]] ; then
2021-07-05 18:15:26 +02:00
execute <<EOF
source "${QP_ROOT}"/quantum_package.rc
rm -rf "${QP_ROOT}"/external/opampack
2021-07-05 15:37:33 +02:00
cd "${QP_ROOT}"/external/
tar --gunzip --extract --file qp2-dependencies/${ARCHITECTURE}/opampack.tar.gz
2023-02-06 13:43:09 +01:00
cd "${QP_ROOT}"/external/opampack
./install.sh
export OPAMROOT="${QP_ROOT}"/external/opampack/opamroot
eval \$("${QP_ROOT}"/external/opampack/opam env)
2021-07-05 16:31:43 +02:00
EOF
2019-01-25 11:39:31 +01:00
elif [[ ${PACKAGE} = bse ]] ; then
2019-01-25 11:39:31 +01:00
execute << EOF
cd "\${QP_ROOT}"/external
2021-07-05 18:15:26 +02:00
tar --gunzip --extract --file qp2-dependencies/bse-v0.8.11.tar.gz
2023-02-06 13:42:20 +01:00
python3 -m pip install -e basis_set_exchange-*
2019-01-25 11:39:31 +01:00
EOF
2021-07-05 16:31:43 +02:00
2019-01-25 11:39:31 +01:00
elif [[ ${PACKAGE} = zlib ]] ; then
execute << EOF
cd "\${QP_ROOT}"/external
2021-07-05 18:15:26 +02:00
tar --gunzip --extract --file qp2-dependencies/zlib-1.2.11.tar.gz
2019-01-25 11:39:31 +01:00
cd zlib-*/
./configure --prefix=${QP_ROOT} && \
make && make install
EOF
2020-02-26 15:58:14 +01:00
2019-01-25 11:39:31 +01:00
elif [[ ${PACKAGE} = docopt ]] ; then
execute << EOF
cd "\${QP_ROOT}"/external
2021-07-05 18:15:26 +02:00
tar --gunzip --extract --file qp2-dependencies/docopt-0.6.2.tar.gz
2019-01-25 11:39:31 +01:00
mv docopt-*/docopt.py "\${QP_ROOT}/external/Python"
EOF
elif [[ ${PACKAGE} = resultsFile ]] ; then
execute << EOF
cd "\${QP_ROOT}"/external
2021-12-20 19:01:45 +01:00
tar --gunzip --extract --file qp2-dependencies/resultsFile-v2.3.tar.gz
2020-02-12 21:42:49 +01:00
mv resultsFile-*/resultsFile "\${QP_ROOT}/external/Python/"
2019-01-25 11:39:31 +01:00
EOF
elif [[ ${PACKAGE} = bats ]] ; then
execute << EOF
cd "\${QP_ROOT}"/external
2023-02-06 13:42:20 +01:00
tar -zxf qp2-dependencies/bats-v1.7.0.tar.gz
( cd bats-core-1.7.0/ ; ./install.sh \${QP_ROOT})
2019-01-25 11:39:31 +01:00
EOF
2020-12-04 11:03:51 +01:00
else
error "${PACKAGE} unknown."
fail
2019-01-25 11:39:31 +01:00
fi
done
2019-02-04 13:14:57 +01:00
2023-02-06 13:42:20 +01:00
source ${QP_ROOT}/quantum_package.rc
2019-01-25 11:39:31 +01:00
NINJA=$(find_exe ninja)
if [[ ${NINJA} = $(not_found) ]] ; then
2019-02-04 13:14:57 +01:00
error "Ninja (ninja) is not installed."
2019-01-25 11:39:31 +01:00
fail
fi
ZEROMQ=$(find_lib -lzmq)
if [[ ${ZEROMQ} = $(not_found) ]] ; then
2023-02-06 13:43:09 +01:00
MAKE=$(find_exe make)
if [[ ${MAKE} = $(not_found) ]] ; then
error "make is not installed."
fail
fi
M4=$(find_exe autoreconf)
if [[ ${M4} = $(not_found) ]] ; then
error "autoreconf is not installed."
fail
fi
M4=$(find_exe m4)
if [[ ${M4} = $(not_found) ]] ; then
error "m4 preprocesssor is not installed."
fail
fi
2019-02-04 13:14:57 +01:00
error "ZeroMQ (zeromq) is not installed."
2019-01-25 11:39:31 +01:00
fail
fi
2023-05-10 18:06:50 +02:00
TREXIO=$(find_lib -ltrexio)
if [[ ${TREXIO} = $(not_found) ]] ; then
error "TREXIO (trexio | trexio-nohdf5) is not installed. If you don't have HDF5, use trexio-nohdf5"
2023-05-10 18:06:50 +02:00
fail
fi
2023-11-07 10:42:19 +01:00
#QMCKL=$(find_lib -lqmckl)
#if [[ ${QMCKL} = $(not_found) ]] ; then
# error "QMCkl (qmckl | qmckl-intel) is not installed."
# fail
#fi
2023-09-18 18:14:04 +02:00
2019-04-12 13:34:17 +02:00
F77ZMQ=$(find_lib -lzmq -lf77zmq -lpthread)
2019-01-25 11:39:31 +01:00
if [[ ${F77ZMQ} = $(not_found) ]] ; then
error "Fortran binding of ZeroMQ (f77zmq) is not installed."
fail
fi
GMP=$(find_lib -lgmp)
if [[ ${ZLIB} = $(not_found) ]] ; then
error "GMP (gmp) is not installed."
fail
fi
OCAML=$(find_exe ocamlc)
2019-01-25 11:39:31 +01:00
if [[ ${OCAML} = $(not_found) ]] ; then
2019-02-04 13:14:57 +01:00
error "OCaml (ocaml) compiler is not installed."
2019-01-25 11:39:31 +01:00
fail
fi
ZLIB=$(find_lib -lz)
if [[ ${ZLIB} = $(not_found) ]] ; then
2019-02-04 13:14:57 +01:00
error "Zlib (zlib) is not installed."
2019-01-25 11:39:31 +01:00
fail
fi
DOCOPT=$(find_python_lib docopt)
if [[ ${DOCOPT} = $(not_found) ]] ; then
2019-02-04 13:14:57 +01:00
error "docopt (docopt) is not installed."
2019-01-25 11:39:31 +01:00
fail
fi
RESULTSFILE=$(find_python_lib resultsFile)
if [[ ${RESULTSFILE} = $(not_found) ]] ; then
2019-02-04 13:14:57 +01:00
error "resultsFile (resultsFile) is not installed."
2019-01-25 11:39:31 +01:00
fail
fi
printf "\e[0;34m"
echo " ___________________________ "
echo "< All dependencies installed. >"
echo " --------------------------- "
echo " \ ^__^ "
echo " \ (oo)\_______ "
echo " (__)\ )\/\. "
echo " ||----w | "
echo " || || "
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
2020-02-04 19:04:36 +01:00
echo ""
2020-08-26 10:19:40 +02:00
echo "If you have PIP, you can install the Basis Set Exchange command-line tool:"
2020-02-04 19:04:36 +01:00
echo ""
echo " ./configure -i bse"
echo ""
2020-02-04 19:30:04 +01:00
echo "This will enable the usage of qp_basis to install extra basis sets."
2020-02-04 19:04:36 +01:00
echo ""
echo ""
2019-01-25 11:39:31 +01:00
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 :)"
2020-02-26 15:58:14 +01:00
else
2019-01-25 11:39:31 +01:00
echo ""
echo "${QP_ROOT}/build.ninja does not exist,"
echo "you need to specify the COMPILATION configuration file."
2023-02-06 13:42:20 +01:00
echo "See ./configure -h for more details."
2019-01-25 11:39:31 +01:00
echo ""
fi
2019-01-25 11:39:31 +01:00
exit 0
2020-02-26 15:58:14 +01:00
2019-01-25 11:39:31 +01:00