10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-09-12 22:08:31 +02:00

updated configure

This commit is contained in:
Kevin Gasperich 2022-06-22 18:14:20 -05:00
parent 2ba43e6b6c
commit 30962a0c57

275
configure vendored
View File

@ -3,8 +3,6 @@
# Quantum Package configuration script
#
TEMP=$(getopt -o c:i:h -l config:,install:,help -n $0 -- "$@") || exit 1
eval set -- "$TEMP"
export QP_ROOT="$( cd "$(dirname "$0")" ; pwd -P )"
echo "QP_ROOT="$QP_ROOT
@ -14,24 +12,9 @@ unset CCXX
# Force GCC instead of ICC for dependencies
export CC=gcc
# /!\ When updating version, update also etc files
EZFIO_TGZ="EZFIO-v2.0.3.tar.gz"
BATS_URL="https://github.com/bats-core/bats-core/archive/v1.1.0.tar.gz"
BUBBLE_URL="https://github.com/projectatomic/bubblewrap/releases/download/v0.3.3/bubblewrap-0.3.3.tar.xz"
DOCOPT_URL="https://github.com/docopt/docopt/archive/0.6.2.tar.gz"
BSE_URL="https://github.com/MolSSI-BSE/basis_set_exchange/archive/v0.8.11.tar.gz"
F77ZMQ_URL="https://github.com/scemama/f77_zmq/archive/v4.2.5.tar.gz"
GMP_URL="ftp://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.bz2"
IRPF90_URL="https://gitlab.com/scemama/irpf90/-/archive/v2.0.0/irpf90-v2.0.0.tar.gz"
LIBCAP_URL="https://git.kernel.org/pub/scm/linux/kernel/git/morgan/libcap.git/snapshot/libcap-2.25.tar.gz"
NINJA_URL="https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip"
OCAML_URL="https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh"
RESULTS_URL="https://gitlab.com/scemama/resultsFile/-/archive/v2.0/resultsFile-v2.0.tar.gz"
ZEROMQ_URL="https://github.com/zeromq/libzmq/releases/download/v4.2.5/zeromq-4.2.5.tar.gz"
ZLIB_URL="https://www.zlib.net/zlib-1.2.11.tar.gz"
# Download submodules
git submodule init
git submodule update
function help()
{
@ -39,17 +22,17 @@ function help()
Quantum Package configuration script.
Usage:
$(basename $0) -c <file> | --config=<file>
$(basename $0) -h | --help
$(basename $0) -i <package> | --install=<package>
$(basename $0) -c <file>
$(basename $0) -h
$(basename $0) -i <package>
Options:
-c, --config=<file> Define a COMPILATION configuration file,
in "${QP_ROOT}/config/".
-h, --help Print the HELP message
-i, --install=<package> INSTALL <package>. Use at your OWN RISK:
no support will be provided for the installation of
dependencies.
-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.
Example:
./$(basename $0) -c config/gfortran.cfg
@ -83,33 +66,30 @@ function execute () {
}
PACKAGES=""
OCAML_PACKAGES="ocamlbuild cryptokit zmq sexplib ppx_sexp_conv ppx_deriving getopt"
while true ; do
case "$1" in
-c|--config)
case "$2" in
while getopts "d:c:i:h" c ; do
case "$c" in
c)
case "$OPTARG" in
"") help ; break;;
*) if [[ -f $2 ]] ; then
CONFIG="$2"
*) if [[ -f $OPTARG ]] ; then
CONFIG="$OPTARG"
else
error "error: configuration file $2 not found."
error "error: configuration file $OPTARG not found."
exit 1
fi
esac
shift 2;;
-i|--install)
case "$2" in
esac;;
i)
case "$OPTARG" in
"") help ; break;;
*) PACKAGES="${PACKAGE} $2"
esac
shift 2;;
-h|-help|--help)
*) PACKAGES="${PACKAGE} $OPTARG"
esac;;
h)
help
exit 0;;
--) shift ; break ;;
*)
error $(basename $0)": unknown option $1, try --help"
error $(basename $0)": unknown option $c, try -h for help"
exit 2;;
esac
done
@ -126,23 +106,13 @@ 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
exit -1
}
function success() {
echo ""
echo "Configuration successful."
exit 1
}
function download() {
echo "Downloading $1"
echo ""
printf "\e[0;34m"
wget --no-check-certificate $1 --output-document=$2 || error "Unable to download $1"
printf "\e[m"
echo "Saved dowloaded file as $2"
echo ""
exit 0
}
function not_found() {
@ -177,16 +147,15 @@ function find_dir() {
fi
}
# Make program believe stdin is a tty
function faketty() {
script -qfc "$(printf "%q " "$@")" /dev/null
}
# Extract EZFIO if needed
EZFIO=$(find_dir "${QP_ROOT}"/external/ezfio)
if [[ ${EZFIO} = $(not_found) ]] ; then
execute << EOF
cd "\${QP_ROOT}"/external
tar --gunzip --extract --file ${EZFIO_TGZ}
rm -rf ezfio
mv EZFIO ezfio || mv EZFIO-v*/ ezfio
EOF
# Install IRPF90 if needed
IRPF90=$(find_exe irpf90)
if [[ ${IRPF90} = $(not_found) ]] ; then
make -C ${QP_ROOT}/external/irpf90
fi
@ -211,7 +180,7 @@ if [[ "${PACKAGES}.x" != ".x" ]] ; then
fi
if [[ ${PACKAGES} = all ]] ; then
PACKAGES="zlib ninja irpf90 zeromq f77zmq gmp libcap bwrap ocaml ezfio docopt resultsFile bats"
PACKAGES="zlib ninja zeromq f77zmq gmp ocaml docopt resultsFile bats"
fi
@ -219,159 +188,72 @@ for PACKAGE in ${PACKAGES} ; do
if [[ ${PACKAGE} = ninja ]] ; then
download ${NINJA_URL} "${QP_ROOT}"/external/ninja.zip
execute << EOF
rm -f "\${QP_ROOT}"/bin/ninja
unzip "\${QP_ROOT}"/external/ninja.zip -d "\${QP_ROOT}"/bin
unzip "\${QP_ROOT}"/external/qp2-dependencies/ninja-linux.zip -d "\${QP_ROOT}"/bin
EOF
elif [[ ${PACKAGE} = gmp ]] ; then
download ${GMP_URL} "${QP_ROOT}"/external/gmp.tar.bz2
execute << EOF
cd "\${QP_ROOT}"/external
tar --bzip2 --extract --file gmp.tar.bz2
rm gmp.tar.bz2
cd gmp*
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 install
make -j 8 install
EOF
elif [[ ${PACKAGE} = libcap ]] ; then
download ${LIBCAP_URL} "${QP_ROOT}"/external/libcap.tar.gz
execute << EOF
cd "\${QP_ROOT}"/external
tar --gunzip --extract --file libcap.tar.gz
rm libcap.tar.gz
cd libcap-*/libcap
prefix=$QP_ROOT make install
EOF
elif [[ ${PACKAGE} = bwrap ]] ; then
download ${BUBBLE_URL} "${QP_ROOT}"/external/bwrap.tar.xz
execute << EOF
cd "\${QP_ROOT}"/external
tar --xz --extract --file bwrap.tar.xz
rm bwrap.tar.xz
cd bubblewrap*
./configure --prefix=$QP_ROOT && make -j 8
make install-exec-am
EOF
elif [[ ${PACKAGE} = irpf90 ]] ; then
# When changing version of irpf90, don't forget to update etc/irpf90.rc
download ${IRPF90_URL} "${QP_ROOT}"/external/irpf90.tar.gz
execute << EOF
cd "\${QP_ROOT}"/external
tar --gunzip --extract --file irpf90.tar.gz
rm irpf90.tar.gz
cd irpf90-*
make
EOF
elif [[ ${PACKAGE} = zeromq ]] ; then
download ${ZEROMQ_URL} "${QP_ROOT}"/external/zeromq.tar.gz
execute << EOF
export CC=gcc
export CXX=g++
cd "\${QP_ROOT}"/external
tar --gunzip --extract --file zeromq.tar.gz
rm zeromq.tar.gz
tar --gunzip --extract --file qp2-dependencies/zeromq-4.2.5.tar.gz
cd zeromq-*
./configure --prefix="\$QP_ROOT" --without-libsodium --enable-libunwind=no
make
make -j 8
make install
EOF
elif [[ ${PACKAGE} = f77zmq ]] ; then
download ${F77ZMQ_URL} "${QP_ROOT}"/external/f77_zmq.tar.gz
execute << EOF
cd "\${QP_ROOT}"/external
tar --gunzip --extract --file f77_zmq.tar.gz
rm f77_zmq.tar.gz
cd f77_zmq-*
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
cp libf77zmq.a "\${QP_ROOT}"/lib
cp libf77zmq.so "\${QP_ROOT}"/lib
cp f77_zmq_free.h "\${QP_ROOT}"/include
make && make check && make install
EOF
elif [[ ${PACKAGE} = ocaml ]] ; then
download ${OCAML_URL} "${QP_ROOT}"/external/opam_installer.sh
if [[ -n ${TRAVIS} ]] ; then
# Special commands for Travis CI
chmod +x "${QP_ROOT}"/external/opam_installer.sh
rm --force ${QP_ROOT}/bin/opam
if [[ -n ${NO_CACHE} ]] ; then
rm -rf ${HOME}/.opam
fi
export OPAMROOT=${HOME}/.opam
cat << EOF | bash ${QP_ROOT}/external/opam_installer.sh --no-backup
${QP_ROOT}/bin
execute <<EOF
source "${QP_ROOT}"/quantum_package.rc
cd "${QP_ROOT}"/external/
tar --gunzip --extract --file qp2-dependencies/ocaml-bundle_x86.tar.gz
echo "" | ./ocaml-bundle/bootstrap.sh "${QP_ROOT}"
./ocaml-bundle/configure.sh "${QP_ROOT}"
echo "" | ./ocaml-bundle/compile.sh "${QP_ROOT}"
EOF
rm ${QP_ROOT}/external/opam_installer.sh
# source ${OPAMROOT}/opam-init/init.sh > /dev/null 2> /dev/null || true
#
# opam switch create ocaml-base-compiler.4.10.0
opam init --verbose --yes --compiler=4.10.0 --disable-sandboxing
eval $(opam env)
opam install -y ${OCAML_PACKAGES} || exit 1
else
# Conventional commands
execute << EOF
chmod +x "${QP_ROOT}"/external/opam_installer.sh
"${QP_ROOT}"/external/opam_installer.sh --no-backup
EOF
execute << EOF
rm --force ${QP_ROOT}/bin/opam
export OPAMROOT=${OPAMROOT:-${QP_ROOT}/external/opam}
echo ${QP_ROOT}/bin \
| sh ${QP_ROOT}/external/opam_installer.sh
EOF
rm ${QP_ROOT}/external/opam_installer.sh
# source ${OPAMROOT}/opam-init/init.sh > /dev/null 2> /dev/null || true
# opam switch create ocaml-base-compiler.4.10.0 || exit 1
opam init --verbose --yes --compiler=4.10.0 --disable-sandboxing
eval $(opam env)
execute << EOF
opam install -y \${OCAML_PACKAGES} || exit 1
EOF
fi
elif [[ ${PACKAGE} = bse ]] ; then
download ${BSE_URL} "${QP_ROOT}"/external/bse.tar.gz
execute << EOF
cd "\${QP_ROOT}"/external
tar --gunzip --extract --file bse.tar.gz
tar --gunzip --extract --file qp2-dependencies/bse-v0.8.11.tar.gz
pip install -e basis_set_exchange-*
EOF
elif [[ ${PACKAGE} = zlib ]] ; then
download ${ZLIB_URL} "${QP_ROOT}"/external/zlib.tar.gz
execute << EOF
cd "\${QP_ROOT}"/external
tar --gunzip --extract --file zlib.tar.gz
rm zlib.tar.gz && \
tar --gunzip --extract --file qp2-dependencies/zlib-1.2.11.tar.gz
cd zlib-*/
./configure --prefix=${QP_ROOT} && \
make && make install
@ -380,35 +262,32 @@ EOF
elif [[ ${PACKAGE} = docopt ]] ; then
download ${DOCOPT_URL} "${QP_ROOT}"/external/docopt.tar.gz
execute << EOF
cd "\${QP_ROOT}"/external
tar --gunzip --extract --file docopt.tar.gz
tar --gunzip --extract --file qp2-dependencies/docopt-0.6.2.tar.gz
mv docopt-*/docopt.py "\${QP_ROOT}/external/Python"
rm --recursive --force -- docopt-*/ docopt.tar.gz
EOF
elif [[ ${PACKAGE} = resultsFile ]] ; then
download ${RESULTS_URL} "${QP_ROOT}"/external/resultsFile.tar.gz
execute << EOF
cd "\${QP_ROOT}"/external
tar --gunzip --extract --file resultsFile.tar.gz
tar --gunzip --extract --file qp2-dependencies/resultsFile-v2.3.tar.gz
mv resultsFile-*/resultsFile "\${QP_ROOT}/external/Python/"
rm --recursive --force resultsFile-* resultsFile.tar.gz
EOF
elif [[ ${PACKAGE} = bats ]] ; then
download ${BATS_URL} "${QP_ROOT}"/external/bats.tar.gz
execute << EOF
cd "\${QP_ROOT}"/external
tar -zxf bats.tar.gz
tar -zxf qp2-dependencies/bats-v1.1.0.tar.gz
( cd bats-core-1.1.0/ ; ./install.sh \${QP_ROOT})
rm --recursive --force -- bats-core-1.1.0 \ "\${QP_ROOT}"/external/bats.tar.gz
EOF
else
error "${PACKAGE} unknown."
fail
fi
@ -422,12 +301,6 @@ if [[ ${NINJA} = $(not_found) ]] ; then
fail
fi
IRPF90=$(find_exe irpf90)
if [[ ${IRPF90} = $(not_found) ]] ; then
error "IRPf90 (irpf90) is not installed."
fail
fi
ZEROMQ=$(find_lib -lzmq)
if [[ ${ZEROMQ} = $(not_found) ]] ; then
error "ZeroMQ (zeromq) is not installed."
@ -446,24 +319,6 @@ if [[ ${ZLIB} = $(not_found) ]] ; then
fail
fi
LIBCAP=$(find_lib -lcap)
if [[ ${LIBCAP} = $(not_found) ]] ; then
error "Libcap (libcap) is not installed."
fail
fi
BWRAP=$(find_exe bwrap)
if [[ ${BWRAP} = $(not_found) ]] ; then
error "Bubblewrap (bwrap) is not installed."
fail
fi
OPAM=$(find_exe opam)
if [[ ${OPAM} = $(not_found) ]] ; then
error "OPAM (ocaml) package manager is not installed."
fail
fi
OCAML=$(find_exe ocaml)
if [[ ${OCAML} = $(not_found) ]] ; then
error "OCaml (ocaml) compiler is not installed."