-
Pietro Incardona authoredPietro Incardona authored
install 18.10 KiB
#! /bin/bash
source script/help
source script/discover_os
source script/show_solutions
source script/pre_req
source script/remove_old
source script/set_mpi
source script/conf_PETSC
source script/update_openfpm
source script/solve_python
### switch to the branch
#b_switch=`git rev-parse --abbrev-ref HEAD`
#b_switch=
b_switch=$(cat switch_branch)
if [ x"$b_switch" != x"" ]; then
git checkout $b_switch
rm switch_branch
./install "$@"
exit 0
fi
## Check that your home is not empty
if [ x"$HOME" == x"" ]; then
echo -e "Your $HOME folder is empty \033[91;5;1m FAILED \033[0m"
exit 1
fi
## If
install_req=1
i_dir=""
sq=0
nomake=0
update_openfpm=0
upgrade_openfpm=0
gpu_support=0
while getopts di:smghc:nu FLAG; do
case $FLAG in
d)
echo "Disable depencencies installation"
install_req=0
;;
i)
echo "Setting dependencies installation dir: $OPTARG"
i_dir=$OPTARG
;;
s)
echo "Skipping user cin"
sq=1
;;
c)
echo "Fowarding options $OPTARG to configure script"
configure_options=$OPTARG
;;
m)
echo "Skip compilation of the test"
nomake=1
;;
g)
echo "Installing with GPU support"
gpu_support=1
;;
u)
echo "Updating openfpm"
update_openfpm=1
;;
n)
echo "Upgrading openfpm"
upgrade_openfpm=1
;;
h) #show help
HELP
;;
\?) #unrecognized option - are fowarded to configure
;;
esac
done
### Configure options
i_dir_old=$i_dir
configure_options_old=$configure_options
discover_os
## Remove old dependencies and installations
if [ x"$i_dir" == x"" ]; then
i_dir="$HOME"
fi
## Check and try to install the prerequisites
if [ $update_openfpm -eq 1 -a $upgrade_openfpm -eq 1 ]; then
echo -e "\033[1;5;31m It is not possible to update and upgrade at the same time \033[0m"
exit 1
fi
if [ $update_openfpm -eq 1 ]; then
update_openfpm update
exit 0
fi
if [ $upgrade_openfpm -eq 1 ]; then
update_openfpm upgrade
exit 0
fi
remove_old $i_dir $configure_options
## Check and try to install the prerequisites
pre_req
## clone the dependencies
git submodule init
if [ $? -ne 0 ]; then
echo -e "Configure\033[91;5;1m FAILED \033[0m"
exit 1
fi
git submodule update
if [ $? -ne 0 ]; then
echo -e "Configure\033[91;5;1m FAILED \033[0m"
exit 1
fi
#### Eventualy remove garbage from old installation
rm -rf openfpm_numerics/src/.deps
rm -rf src/.deps
# Create config directory in each submodule
cd openfpm_data
if [ ! -d src/config ]; then
mkdir src/config
fi
cd ..
cd openfpm_devices
if [ ! -d src/config ]; then
mkdir src/config
fi
cd ..
cd openfpm_vcluster
if [ ! -d src/config ]; then
mkdir src/config
fi
cd ..
cd openfpm_io
if [ ! -d src/config ]; then
mkdir src/config
fi
cd ..
cd openfpm_numerics
if [ ! -d src/config ]; then
mkdir src/config
fi
cd ..
# Create config directory
if [ ! -d src/config ]; then
mkdir src/config
fi
## generate configure script
sh ./autogen.sh
if [ $? -ne 0 ]; then
echo -e "Configure\033[91;5;1m FAILED \033[0m"
exit 1
fi
## check for options
echo -e "\033[1;34;5mDEPENCENCIES INSTALLATION DIR \033[0m"
echo -e "Every required dependencies if needed will be installed into: \033[1;34;5m$i_dir\033[0m"
echo -e "if you want to install somewhere else do ./install -i /somewhere/else"
if [ x"$configure_options" == x"" ]; then
echo -e "OpenFPM will be installed into: \033[1;34;5m/usr/local\033[0m"
echo "if you want to install in a different place use ./install -c \"--prefix=/where/you/want/to/install\""
fi
if [ $sq -eq 0 ]; then
unset commands
# commands[0]="continue"
possible_solutions "${commands[@]}"
fi
ncore=4
echo -e "\033[1mHow many core you want to use to install the dependencies?\033[0m"
if [ $sq -eq 0 ]; then
read ncore
fi
echo -e "Installing requirements into: $i_dir "
##
## Take all the options with the exception of -d -i -s
## call the configure script
### Installing PETSC
if [ ! -d "$i_dir/PETSC" -o ! -f "$i_dir/PETSC/include/petsc.h" -o ! -d "$i_dir/EIGEN" ]; then
echo -e "\033[1;34m Optional packages \033[0m"
echo -e "\033[1mDo you want to install linear algebra packages ?(y/n)\033[0m"
echo "Installation can take long time (90 minutes on i7-3612QM 4 cores)"
if [ $sq -eq 0 ]; then
read inst_lin_alg
else
inst_lin_alg="y"
fi
### PETSC require Python
command -v python
if [ $? -ne 0 ]; then
### We have to install python
echo "OpenFPM require python but it's not installed, searching a solution... "
solve_python $platform
command -v python
if [ $? -ne 0 ]; then
echo -e "python\033[91;5;1m FAILED \033[0m"
exit 1
fi
fi
if haveProg python2; then
python_command=python2
else
# we check that python is python2
py_ver=$(python --version 2>&1 | grep Python | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)/\1/g')
if [ $py_ver -eq 3 ]; then
# we have to install python2
echo -e "\033[1mPETSC require python2 installed, searching a solution to install python2 ... \033[0m"
solve_python $platform
fi
python_command=python
fi
fi
#### License and Copyright disclamer
echo -e "\033[1;34m Licenses \033[0m"
echo -e "\033[1;34m OpenFPM install several dependencies automatically. Some of them impose restriction and the user must explicitly accept it \033[0m"
echo -e "\033[1;33m PARMETIS: \033[0m \033[1m http://glaros.dtc.umn.edu/gkhome/metis/parmetis/download (Copyright and License) \033[0m"
echo -e ""
if [ $sq -eq 0 ]; then
unset commands
commands[0]="Accept and continue"
possible_solutions_no_continue "${commands[@]}"
fi
####
lin_alg_dir=""
lin_alg_lib=""
lin_alg_inc=""
if [ -d "$i_dir/BOOST" ]; then
configure_options=" $configure_options --with-boost=$i_dir/BOOST "
fi
if [ -d "$i_dir/HDF5" ]; then
configure_options=" $configure_options --with-hdf5=$i_dir/HDF5/ "
fi
if [ -d "$i_dir/LIBHILBERT" ]; then
configure_options=" $configure_options --with-libhilbert=$i_dir/LIBHILBERT "
fi
### if we are on linux we have to add -rt
if [ x"$platform" = x"linux" ]; then
lin_alg_lib="$lin_alg_lib -lrt"
fi
### MPI compilers must be in your PATH folder
set_mpi $i_dir $ncore $gpu_support $CC $CXX $F77 $FC
### METIS and ParMETIS must be installed independently from sistem wide installation
./script/install_Parmetis.sh $i_dir $ncore
configure_options=" $configure_options --with-parmetis=$i_dir/PARMETIS "
./script/install_Metis.sh $i_dir $CC $CXX $ncore
configure_options=" $configure_options --with-metis=$i_dir/METIS "
if [ x"$gpu_support" == x"1" ]; then
configure_options=" $configure_options --enable-gpu "
fi
MPI_installed=0
MPI_System_prv=1
METIS_installed=1
PARMETIS_installed=1
BOOST_installed=0
BOOST_System_prv=1
LAPACK_installed=0
LAPACK_System_prv=1
SUITESPARSE_installed=0
SUITESPARSE_System_prv=1
EIGEN_installed=0
EIGEN_System_prv=1
HDF5_installed=0
HDF5_System_prv=1
LIBHILBERT_installed=0
VCDEVEL_installed=0
conf_err=1
if [ $install_req -eq 0 ]; then
./configure $options $configure_options "$configure_blas_option"
else
while [ $conf_err -ne 0 ]
do
pwd
./configure $options $configure_options "$configure_blas_option"
conf_err=$?
echo "Configure script terminated with $conf_err"
## if METIS installation required install it
if [ $conf_err -eq 201 ]; then
echo "Metis not found try to install"
if [ $METIS_installed -eq 1 ]; then
echo "Error the installation of METIS failed"
exit 1
fi
./script/install_Metis.sh $i_dir $CC $CXX
METIS_installed=1
configure_options=" $configure_options --with-metis=$i_dir/METIS "
elif [ $conf_err -eq 202 ]; then
echo "Boost not found try to install in $i_dir with $compiler_opt"
if [ $BOOST_installed -eq 1 ]; then
echo "Error the installation of Boost failed"
exit 1
fi
if [ x"$CXX" == x"icpc" ]; then
./script/install_BOOST.sh $i_dir $ncore intel-linux
elif [ x"$CXX" == x"clang++" ]; then
./script/install_BOOST.sh $i_dir $ncore darwin
else
if [ x"$CXX" == x"gcc" ]; then
./script/install_BOOST.sh $i_dir $ncore gcc
else
./script/install_BOOST.sh $i_dir $ncore gcc $(which $CXX) $dgc_major $dgc_middle
fi
fi
BOOST_installed=1
configure_options=" $configure_options --with-boost=$i_dir/BOOST "
elif [ $conf_err -eq 208 ]; then
echo "ParMetis not found try to install"
if [ $PARMETIS_installed -eq 1 ]; then
echo "Error the installation of ParMETIS failed"
exit 1
fi
./script/install_Parmetis.sh $i_dir $ncore
PARMETIS_installed=1
configure_options=" $configure_options --with-parmetis=$i_dir/PARMETIS "
elif [ $conf_err -eq 207 ]; then
echo "HDF5 not found try to install"
if [ $HDF5_installed -eq 1 ]; then
echo "Error the installation of HDF5 failed"
exit 1
fi
./script/install_HDF5.sh $i_dir $ncore
configure_options=" $configure_options --with-hdf5=$i_dir/HDF5/ "
HDF5_installed=1
elif [ $conf_err -eq 210 ]; then
echo "LIBHILBERT not found try to install"
if [ $LIBHILBERT_installed -eq 1 ]; then
echo "Error the installation of LIBHILBERT failed"
exit 1
fi
./script/install_LIBHILBERT.sh $i_dir $ncore
configure_options=" $configure_options --with-libhilbert=$i_dir/LIBHILBERT "
LIBHILBERT_installed=1
elif [ $conf_err -eq 211 ]; then
echo "VCDEVEL not found try to install"
if [ $VCDEVEL_installed -eq 1 ]; then
echo "Error the installation of VCDEVEL failed"
exit 1
fi
./script/install_VCDEVEL.sh $i_dir $ncore
configure_options=" $configure_options --with-vcdevel=$i_dir/VCDEVEL "
VCDEVEL_installed=1
elif [ $conf_err -ne 0 ]; then
echo "I do not know how to recover from this error"
exit 1
fi
done
if [ x"$inst_lin_alg" == x"y" ]; then
CXX="$CXX" CC="$CC" FC="$FC" F77="$F77" ./script/install_EIGEN.sh $i_dir $ncore
CXX="$CXX" CC="$CC" FC="$FC" F77="$F77" ./script/install_PETSC.sh $i_dir $ncore $CC $CXX $F77 $FC
fi
### collect PETSC configuration options
conf_PETSC
./configure $options $configure_options "$configure_blas_option"
fi
### Create example.mk
install_base=$(cat install_dir)
openmp_flags="$(cat openmp_flags)"
cuda_include_dirs=$(cat cuda_include)
mpi_include_dirs=$(cat mpi_include)
mpi_libs=$(cat mpi_libs)
if [ -d "$i_dir/HDF5/lib" ]; then
hdf5_lib=$i_dir/HDF5/lib
elif [ -d "$i_dir/HDF5/lib64" ]; then
hdf5_lib=$i_dir/HDF5/lib64
fi
echo "INCLUDE_PATH=$cuda_include_dirs -Wno-deprecated-declarations $openmp_flags -I. -I$install_base/openfpm_numerics/include -I$install_base/openfpm_pdata/include/config -I$install_base/openfpm_pdata/include -I$install_base/openfpm_data/include -I$install_base/openfpm_vcluster/include -I$install_base/openfpm_io/include -I$install_base/openfpm_devices/include -I$i_dir/VCDEVEL/include -I$i_dir/METIS/include -I$i_dir/PARMETIS/include -I$i_dir/BOOST/include -I$i_dir/HDF5/include -I$i_dir/LIBHILBERT/include $lin_alg_inc" > example.mk
echo "LIBS_PATH=$openmp_flags -L$install_base/openfpm_devices/lib -L$install_base/openfpm_pdata/lib -L$install_base/openfpm_vcluster/lib -L$i_dir/VCDEVEL/lib -L$i_dir/METIS/lib -L$i_dir/PARMETIS/lib -L$i_dir/BOOST/lib -L$hdf5_lib -L$i_dir/LIBHILBERT/lib $lin_alg_dir " >> example.mk
if [ x"$gpu_support" == x"1" ]; then
echo "LIBS=-lvcluster -lofpm_pdata -lofpmmemory -lparmetis -lmetis -lboost_iostreams -lboost_program_options -lhdf5 -llibhilbert -lVc $(cat cuda_lib) $lin_alg_lib -ldl" >> example.mk
echo "LIBS_SE2=-lvcluster -lofpmmemory_se2 -lparmetis -lmetis -lboost_iostreams -lboost_program_options -lhdf5 -llibhilbert -lVc $(cat cuda_lib) $lin_alg_lib" >> example.mk
else
echo "LIBS=-lvcluster -lofpm_pdata -lofpmmemory -lparmetis -lmetis -lboost_iostreams -lboost_program_options -lhdf5 -llibhilbert -lVc $lin_alg_lib -ldl" >> example.mk
echo "LIBS_SE2=-lvcluster -lofpmmemory_se2 -lparmetis -lmetis -lboost_iostreams -lboost_program_options -lhdf5 -llibhilbert -lVc $lin_alg_lib" >> example.mk
fi
echo "INCLUDE_PATH_NVCC=-Xcompiler="-Wno-deprecated-declarations" $(cat openmp_flags) "$(cat cuda_options)" -I. -I$install_base/openfpm_numerics/include -I$install_base/openfpm_pdata/include/config -I$install_base/openfpm_pdata/include -I$install_base/openfpm_data/include -I$install_base/openfpm_vcluster/include -I$install_base/openfpm_io/include -I$install_base/openfpm_devices/include -I$i_dir/METIS/include -I$i_dir/PARMETIS/include -I$i_dir/BOOST/include -I$i_dir/HDF5/include -I$i_dir/LIBHILBERT/include $lin_alg_inc" >> example.mk
cp example.mk src/example.mk
cp example.mk example/example.mk
if [ $nomake -eq 0 ]; then
make clean
make VERBOSE=1 -j $ncore
fi
if [ $? -ne 0 ]; then
conf_err=1
fi
echo "Command used to configure"
echo ""
echo -e "\033[1m ./configure $options $configure_options \033[0m "
echo ""
if [ x"$platform" == x"linux" -o x"$platform" == x"cygwin" ]; then
bash_library="export LD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH:/$install_base/openfpm_devices/lib:/$install_base/openfpm_vcluster/lib"
else
bash_library="export DYLD_LIBRARY_PATH=\"\$DYLD_LIBRARY_PATH:/$install_base/openfpm_devices/lib:/$install_base/openfpm_vcluster/lib"
fi
bash_path="export PATH=\""
echo -e "\033[1;34;5m --------------------------------------- \033[0m"
echo -e "\033[1;34;5m --------- INSTALLATION REPORT --------- \033[0m"
echo ""
echo -e "\033[1;34;5m ---------- Mandatory packages --------- \033[0m"
echo ""
if [ -d "$i_dir/MPI" ]; then
installation_report="$installation_report \033[92;1mMPI\033[0m Installed: \033[1m $i_dir/MPI \033[0m\n"
bash_path="$bash_path$i_dir/MPI/bin:"
bash_library="$bash_library:$i_dir/MPI/lib"
elif [ $MPI_System_prv -eq 1 ]; then
installation_report="$installation_report \033[92;1mMPI\033[0m Installed: \033[1m System installation \033[0m\n"
fi
if [ -d "$i_dir/METIS" ]; then
installation_report="$installation_report \033[92;1mMETIS\033[0m Installed: \033[1m $i_dir/METIS \033[0m\n"
bash_library="$bash_library:$i_dir/METIS/lib"
fi
if [ -d "$i_dir/PARMETIS" ]; then
installation_report="$installation_report \033[92;1mPARMETIS\033[0m Installed: \033[1m $i_dir/PARMETIS \033[0m\n"
bash_library="$bash_library:$i_dir/PARMETIS/lib"
fi
if [ -d "$i_dir/BOOST" ]; then
installation_report="$installation_report \033[92;1mBOOST\033[0m Installed: \033[1m $i_dir/BOOST \033[0m\n"
bash_library="$bash_library:$i_dir/BOOST/lib"
elif [ $BOOST_System_prv -eq 1 ]; then
installation_report="$installation_report \033[92;1mBOOST\033[0m Installed: \033[1m System installation \033[0m\n"
fi
if [ -d "$i_dir/HDF5" ]; then
installation_report="$installation_report \033[92;1mHDF5\033[0m Installed: \033[1m $i_dir/HDF5 \033[0m\n"
bash_library="$bash_library:$hdf5_lib"
fi
if [ -d "$i_dir/LIBHILBERT" ]; then
installation_report="$installation_report \033[92;1mLibHilbert\033[0m Installed: \033[1m $i_dir/LIBHILBERT \033[0m\n"
bash_library="$bash_library:$i_dir/LIBHILBERT/lib"
fi
echo -e "$installation_report"
echo ""
echo -e "\033[1;34;5m ---------- Optional packages ----------- \033[0m"
echo ""
installation_report=""
lin_alg_installed=""
if [ -d "$i_dir/PETSC" -a -f "$i_dir/PETSC/include/petsc.h" ]; then
installation_report="$installation_report \033[92;1mPETSC\033[0m Installed: \033[1m $i_dir/PETSC \033[0m\n"
bash_library="$bash_library:$i_dir/PETSC/lib"
lin_alg_installed="y"
else
installation_report="$installation_report \033[91;1mPETSC\033[0m Installed: \033[1m NO \033[0m\n"
fi
if [ -d "$i_dir/EIGEN" ]; then
installation_report="$installation_report \033[92;1mEIGEN\033[0m Installed: \033[1m $i_dir/EIGEN \033[0m\n"
fi
echo -e "$installation_report"
echo -e "\033[1;34;5m -------------------------------- \033[0m"
installation_report=""
if [ -d "$i_dir/OPENBLAS" ]; then
installation_report="$installation_report \033[92;1mOPENBLAS\033[0m Installed: \033[1m $i_dir/OPENBLAS \033[0m\n"
bash_library="$bash_library:$i_dir/OPENBLAS/lib"
else
installation_report="$installation_report \033[91;1mOPENBLAS\033[0m Installed: \033[1m NO \033[0m\n"
fi
if [ -d "$i_dir/SUITESPARSE" -a -f "$i_dir/SUITESPARSE/include/umfpack.h" ]; then
installation_report="$installation_report \033[92;1mSUITESPARSE\033[0m Installed: \033[1m $i_dir/SUITESPARSE \033[0m\n"
bash_library="$bash_library:$i_dir/SUITESPARSE/lib"
else
installation_report="$installation_report \033[91;1mSUITESPARSE\033[0m Installed: \033[1m NO \033[0m\n"
fi
bash_path="$bash_path\$PATH\""
bash_library="$bash_library\""
##### Writing openfpm_vars file
echo "$bash_path" > $HOME/openfpm_vars
echo "$bash_library" >> $HOME/openfpm_vars
if [ x"$platform" = x"osx" ]; then
echo "TMPDIR=/tmp/" >> $HOME/openfpm_vars
fi
echo -e "$installation_report"
echo ""
echo ""
if [ $conf_err -eq 0 ]; then
echo -e "Install summary\033[92;5;1m SUCCEED \033[0m"
## Save dependencies dir and foward options
printf "%s" "$i_dir_old" > dependencies_dir
printf "%s" "$configure_options_old" > foward_options
else
echo -e "Install summary\033[91;5;1m FAILED \033[0m"
fi
echo ""
if [ x"$platform" = x"linux" ]; then
echo "Before run any openfpm program you must execute the following command. A simple way would be to append this line at the end of your $HOME/.bashrc"
else
echo "Before run any openfpm program you must execute the following command. A simple way would be to append this line at the end of your $HOME/.bash_profile"
fi
echo ""
echo -e "\033[1m source $HOME/openfpm_vars \033[0m"
echo ""
echo ""
echo -e "Remember to do: \033[91;5;1m make install \033[0m"
echo ""
if [ x"$inst_lin_alg" == "y" -a x"$lin_alg_installed" == x"" ]; then
conf_err=1
fi
if [ $conf_err -ne 0 ]; then
exit 1
fi