10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-06-02 11:25:26 +02:00

Improved configure script

This commit is contained in:
Anthony Scemama 2019-01-15 18:53:44 +01:00
parent d62017af67
commit 95ccb8849a
3 changed files with 94 additions and 55 deletions

135
configure vendored
View File

@ -42,6 +42,20 @@ function error() {
exit 2 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"
printf "\e[m"
echo ""
}
PACKAGES="" PACKAGES=""
OCAML_PACKAGES="ocamlbuild cryptokit zmq core sexplib ppx_sexp_conv ppx_deriving getopt" OCAML_PACKAGES="ocamlbuild cryptokit zmq core sexplib ppx_sexp_conv ppx_deriving getopt"
@ -85,6 +99,7 @@ source quantum_package.rc
function fail() { function fail() {
echo "You can try to install it using the -i option."
echo "Please refer to INSTALL.rst to install the missing dependencies." echo "Please refer to INSTALL.rst to install the missing dependencies."
exit 1 exit 1
} }
@ -96,7 +111,13 @@ function success() {
} }
function download() { function download() {
echo "Downloading $1"
echo ""
printf "\e[0;34m"
wget --no-check-certificate $1 --output-document=$2 || error "Unable to download $1" wget --no-check-certificate $1 --output-document=$2 || error "Unable to download $1"
printf "\e[m"
echo "Saved dowloaded file as $2"
echo ""
} }
function not_found() { function not_found() {
@ -133,6 +154,7 @@ function find_dir() {
if [[ "${PACKAGES}.x" != ".x" ]] ; then if [[ "${PACKAGES}.x" != ".x" ]] ; then
printf "\e[0;31m"
echo "" echo ""
echo "#########################################################" echo "#########################################################"
echo "# #" echo "# #"
@ -145,7 +167,9 @@ if [[ "${PACKAGES}.x" != ".x" ]] ; then
echo "# You may refer to the INSTALL.rst file for help. #" echo "# You may refer to the INSTALL.rst file for help. #"
echo "# #" echo "# #"
echo "#########################################################" echo "#########################################################"
printf "\e[m"
echo "" echo ""
sleep 1
fi fi
if [[ ${PACKAGES} = all ]] ; then if [[ ${PACKAGES} = all ]] ; then
@ -160,7 +184,10 @@ for PACKAGE in ${PACKAGES} ; do
download \ download \
"https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip" \ "https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip" \
"${QP_ROOT}"/external/ninja.zip "${QP_ROOT}"/external/ninja.zip
unzip "${QP_ROOT}"/external/ninja.zip -d "${QP_ROOT}"/bin execute << EOF
rm -f "\${QP_ROOT}"/bin/ninja
unzip "\${QP_ROOT}"/external/ninja.zip -d "\${QP_ROOT}"/bin
EOF
elif [[ ${PACKAGE} = irpf90 ]] ; then elif [[ ${PACKAGE} = irpf90 ]] ; then
@ -169,13 +196,13 @@ for PACKAGE in ${PACKAGES} ; do
download \ download \
"https://gitlab.com/scemama/irpf90/-/archive/v1.7.4/irpf90-v1.7.4.tar.gz" \ "https://gitlab.com/scemama/irpf90/-/archive/v1.7.4/irpf90-v1.7.4.tar.gz" \
"${QP_ROOT}"/external/irpf90.tar.gz "${QP_ROOT}"/external/irpf90.tar.gz
( execute << EOF
cd "${QP_ROOT}"/external cd "\${QP_ROOT}"/external
tar --gunzip --extract --file irpf90.tar.gz tar --gunzip --extract --file irpf90.tar.gz
rm irpf90.tar.gz rm irpf90.tar.gz
cd irpf90-* cd irpf90-*
make make
) EOF
elif [[ ${PACKAGE} = zeromq ]] ; then elif [[ ${PACKAGE} = zeromq ]] ; then
@ -183,15 +210,15 @@ for PACKAGE in ${PACKAGES} ; do
download \ download \
"https://github.com/zeromq/libzmq/releases/download/v4.2.5/zeromq-4.2.5.tar.gz" \ "https://github.com/zeromq/libzmq/releases/download/v4.2.5/zeromq-4.2.5.tar.gz" \
"${QP_ROOT}"/external/zeromq.tar.gz "${QP_ROOT}"/external/zeromq.tar.gz
( execute << EOF
cd "${QP_ROOT}"/external cd "\${QP_ROOT}"/external
tar --gunzip --extract --file zeromq.tar.gz tar --gunzip --extract --file zeromq.tar.gz
rm zeromq.tar.gz rm zeromq.tar.gz
cd zeromq-* cd zeromq-*
./configure --prefix="$QP_ROOT" --without-libsodium --enable-libunwind=no ./configure --prefix="\$QP_ROOT" --without-libsodium --enable-libunwind=no
make make
make install make install
) EOF
elif [[ ${PACKAGE} = f77zmq ]] ; then elif [[ ${PACKAGE} = f77zmq ]] ; then
@ -199,17 +226,17 @@ for PACKAGE in ${PACKAGES} ; do
download \ download \
"https://github.com/scemama/f77_zmq/archive/v4.2.5.tar.gz" \ "https://github.com/scemama/f77_zmq/archive/v4.2.5.tar.gz" \
"${QP_ROOT}"/external/f77_zmq.tar.gz "${QP_ROOT}"/external/f77_zmq.tar.gz
( execute << EOF
cd "${QP_ROOT}"/external cd "\${QP_ROOT}"/external
tar --gunzip --extract --file f77_zmq.tar.gz tar --gunzip --extract --file f77_zmq.tar.gz
rm f77_zmq.tar.gz rm f77_zmq.tar.gz
cd f77_zmq-* cd f77_zmq-*
export ZMQ_H="$QP_ROOT"/include/zmq.h export ZMQ_H="\$QP_ROOT"/include/zmq.h
make make
cp libf77zmq.a "${QP_ROOT}"/lib cp libf77zmq.a "\${QP_ROOT}"/lib
cp libf77zmq.so "${QP_ROOT}"/lib cp libf77zmq.so "\${QP_ROOT}"/lib
cp f77_zmq_free.h "${QP_ROOT}"/include cp f77_zmq_free.h "\${QP_ROOT}"/include
) EOF
elif [[ ${PACKAGE} = ocaml ]] ; then elif [[ ${PACKAGE} = ocaml ]] ; then
@ -217,11 +244,11 @@ for PACKAGE in ${PACKAGES} ; do
download \ download \
"https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh" \ "https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh" \
"${QP_ROOT}"/external/opam_installer.sh "${QP_ROOT}"/external/opam_installer.sh
chmod +x "${QP_ROOT}"/external/opam_installer.sh
rm --force ${QP_ROOT}/bin/opam
if [[ -n ${TRAVIS} ]] ; then if [[ -n ${TRAVIS} ]] ; then
# Special commands for Travis CI # Special commands for Travis CI
chmod +x "${QP_ROOT}"/external/opam_installer.sh
rm --force ${QP_ROOT}/bin/opam
export OPAMROOT=${HOME}/.opam export OPAMROOT=${HOME}/.opam
cat << EOF | bash ${QP_ROOT}/external/opam_installer.sh --no-backup cat << EOF | bash ${QP_ROOT}/external/opam_installer.sh --no-backup
${QP_ROOT}/bin ${QP_ROOT}/bin
@ -229,23 +256,30 @@ ${QP_ROOT}/bin
EOF EOF
rm ${QP_ROOT}/external/opam_installer.sh
source ${OPAMROOT}/opam-init/init.sh > /dev/null 2> /dev/null || true
${QP_ROOT}/bin/opam init --disable-sandboxing --verbose \
--yes --comp=4.07.0
eval $(${QP_ROOT}/bin/opam env)
opam install -y ${OCAML_PACKAGES} || exit 1
else else
# Conventional commands # Conventional commands
export OPAMROOT=${OPAMROOT:-${QP_ROOT}/external/opam} execute << EOF
echo "======================================================== " chmod +x "\${QP_ROOT}"/external/opam_installer.sh
echo "" rm --force \${QP_ROOT}/bin/opam
echo "|QP> Please install it here: " ${QP_ROOT}/bin export OPAMROOT=\${OPAMROOT:-\${QP_ROOT}/external/opam}
echo "" echo \${QP_ROOT}/bin \
sh ${QP_ROOT}/external/opam_installer.sh | sh \${QP_ROOT}/external/opam_installer.sh
rm \${QP_ROOT}/external/opam_installer.sh
source \${OPAMROOT}/opam-init/init.sh > /dev/null 2> /dev/null || true
\${QP_ROOT}/bin/opam init --disable-sandboxing --verbose \
--yes --comp=4.07.0
eval \$(\${QP_ROOT}/bin/opam env)
opam install -y \${OCAML_PACKAGES} || exit 1
EOF
fi fi
source ${OPAMROOT}/opam-init/init.sh > /dev/null 2> /dev/null || true
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 ${OCAML_PACKAGES} || exit 1
elif [[ ${PACKAGE} = ezfio ]] ; then elif [[ ${PACKAGE} = ezfio ]] ; then
@ -253,11 +287,12 @@ EOF
download \ download \
"https://gitlab.com/scemama/EZFIO/-/archive/v1.3.4/EZFIO-v1.3.4.tar.gz" \ "https://gitlab.com/scemama/EZFIO/-/archive/v1.3.4/EZFIO-v1.3.4.tar.gz" \
"${QP_ROOT}"/external/ezfio.tar.gz "${QP_ROOT}"/external/ezfio.tar.gz
( execute << EOF
cd "${QP_ROOT}"/external cd "\${QP_ROOT}"/external
tar --gunzip --extract --file ezfio.tar.gz tar --gunzip --extract --file ezfio.tar.gz
rm -rf ezfio
mv EZFIO-* ezfio mv EZFIO-* ezfio
) EOF
elif [[ ${PACKAGE} = emsl ]] ; then elif [[ ${PACKAGE} = emsl ]] ; then
@ -265,11 +300,11 @@ EOF
download \ download \
"https://github.com/LCPQ/EMSL_Basis_Set_Exchange_Local/archive/v1.0.tar.gz" \ "https://github.com/LCPQ/EMSL_Basis_Set_Exchange_Local/archive/v1.0.tar.gz" \
"${QP_ROOT}"/external/EMSL.tar.gz "${QP_ROOT}"/external/EMSL.tar.gz
( execute << EOF
cd "${QP_ROOT}"/external cd "\${QP_ROOT}"/external
tar --gunzip --extract --file EMSL.tar.gz tar --gunzip --extract --file EMSL.tar.gz
mv EMSL_Basis* emsl mv EMSL_Basis* emsl
) EOF
elif [[ ${PACKAGE} = docopt ]] ; then elif [[ ${PACKAGE} = docopt ]] ; then
@ -277,12 +312,12 @@ EOF
download \ download \
"https://github.com/docopt/docopt/archive/0.6.2.tar.gz" \ "https://github.com/docopt/docopt/archive/0.6.2.tar.gz" \
"${QP_ROOT}"/external/docopt.tar.gz "${QP_ROOT}"/external/docopt.tar.gz
( execute << EOF
cd "${QP_ROOT}"/external cd "\${QP_ROOT}"/external
tar --gunzip --extract --file docopt.tar.gz tar --gunzip --extract --file docopt.tar.gz
mv docopt-*/docopt.py "${QP_ROOT}/external/Python" mv docopt-*/docopt.py "\${QP_ROOT}/external/Python"
rm --recursive --force -- docopt-*/ docopt.tar.gz rm --recursive --force -- docopt-*/ docopt.tar.gz
) EOF
elif [[ ${PACKAGE} = resultsFile ]] ; then elif [[ ${PACKAGE} = resultsFile ]] ; then
@ -290,28 +325,28 @@ EOF
download \ download \
"https://gitlab.com/scemama/resultsFile/-/archive/master/resultsFile-master.tar.gz" \ "https://gitlab.com/scemama/resultsFile/-/archive/master/resultsFile-master.tar.gz" \
"${QP_ROOT}"/external/resultsFile.tar.gz "${QP_ROOT}"/external/resultsFile.tar.gz
( execute << EOF
cd "${QP_ROOT}"/external cd "\${QP_ROOT}"/external
tar --gunzip --extract --file resultsFile.tar.gz tar --gunzip --extract --file resultsFile.tar.gz
mv resultsFile-master/resultsFile "${QP_ROOT}/external/Python" mv resultsFile-master/resultsFile "\${QP_ROOT}/external/Python"
rm --recursive --force resultsFile-master resultsFile.tar.gz rm --recursive --force resultsFile-master resultsFile.tar.gz
) EOF
elif [[ ${PACKAGE} = bats ]] ; then elif [[ ${PACKAGE} = bats ]] ; then
download \ download \
"https://github.com/bats-core/bats-core/archive/v1.1.0.tar.gz" \ "https://github.com/bats-core/bats-core/archive/v1.1.0.tar.gz" \
"${QP_ROOT}"/external/bats.tar.gz "${QP_ROOT}"/external/bats.tar.gz
( execute << EOF
cd "${QP_ROOT}"/external cd "\${QP_ROOT}"/external
tar -zxf bats.tar.gz tar -zxf bats.tar.gz
( (
cd bats-core-1.1.0/ cd bats-core-1.1.0/
./install.sh $QP_ROOT ./install.sh \${QP_ROOT}
) )
rm --recursive --force -- bats-core-1.1.0 \ rm --recursive --force -- bats-core-1.1.0 \
"${QP_ROOT}"/external/bats.tar.gz "\${QP_ROOT}"/external/bats.tar.gz
) EOF
fi fi

View File

@ -38,8 +38,14 @@ Usage:
function qp() function qp()
{ {
case $1 in case $1 in
"has"|"set"|"get"|"set_file"|"unset_file") "set_file")
ezfio "$@" if [[ -d ${EZFIO_FILE} ]] ; then
ezfio "$@"
else
>&2 echo "qp: ${EZFIO_FILE} not found"
fi;;
"has"|"set"|"get"|"unset_file")
;; ;;
"set_frozen_core") "set_frozen_core")
@ -140,7 +146,7 @@ function _get_basis_sets () {
| while IFS= read -r LINE ; do | while IFS= read -r LINE ; do
printf '%s\n' ${LINE} printf '%s\n' ${LINE}
done done
(cd ~/quantum_package/data/basis/ ; \ls) (cd ${QP_ROOT}/data/basis/ ; \ls)
) | sort | uniq ) | sort | uniq
} }

View File

@ -1,2 +0,0 @@
*