diff --git a/build_pdata.sh b/build_pdata.sh index b9144016abbe0938a39b1264dcce93371abb171d..8d12ecdbae2478c1ae94c8b6e95b5e72e20faa43 100644 --- a/build_pdata.sh +++ b/build_pdata.sh @@ -11,7 +11,6 @@ git submodule init git submodule update cd openfpm_data -pwd git checkout develop cd .. diff --git a/install b/install index 0430006f2669101d487a4a326c6f0dcaef6ab097..1b4a86be2dd2d092098b46d47b323d05836af4f0 100755 --- a/install +++ b/install @@ -1,5 +1,14 @@ #! /bin/bash +## Check and try to install the prerequisites + +script/pre_req + +## clone the dependencies + +git submodules init +git submodules update + ## Take all the options with the exception of --enable-install-req install_req=1 @@ -39,7 +48,7 @@ else echo "Error the installation of MPI failed" exit 1 fi - ./install_MPI.sh + ./script/install_MPI.sh MPI_installed=1 export PATH="$PATH:${HOME}/MPI/bin" configure_options="$configure_options CXX=mpic++ " @@ -49,7 +58,7 @@ else echo "Error the installation of METIS failed" exit 1 fi - ./install_Metis.sh + ./script/install_Metis.sh METIS_installed=1 configure_options=" $configure_options --with-metis=${HOME}/METIS " elif [ $conf_err -eq 202 ]; then @@ -58,7 +67,7 @@ else echo "Error the installation of Boost failed" exit 1 fi - ./install_BOOST.sh + ./script/install_BOOST.sh BOOST_installed=1 configure_options=" $configure_options --with-boost=${HOME}/BOOST " elif [ $conf_err -ne 0 ]; then diff --git a/script/discover_package_manager b/script/discover_package_manager new file mode 100644 index 0000000000000000000000000000000000000000..7d7573d816c5fa66e2b7dca81e9d6258f322c165 --- /dev/null +++ b/script/discover_package_manager @@ -0,0 +1,42 @@ +#! /bin/bash + +function discover_package_manager() { + if [ x"$1" = x"osx" ]; then + command -v brew >/dev/null + if [ $? -eq 0 ]; then + discover_package_manager_ret="brew" + if [ ! -w /usr/local ]; then + echo -e "\033[93;5mWARNING: \033[0m /usr/local is not writtable, brew require that /usr/local is writtable and /usr/local/bin is in your PATH, otherwise the solutions with brew will fail" + fi + return + fi + command -v port >/dev/null + if [ command -v port >/dev/null 2>&1 ]; then + discover_package_manager_ret="sudo port" + return + else + return + fi + elif [ x"$1" = x"linux" ]; then + command -v yum >/dev/null + if [ $? -eq 0 ]; then + discover_package_manager_ret="yum" + return + fi + command -v apt-get >/dev/null + if [ $? -eq 0 ]; then + discover_package_manager_ret="apt-get" + return + fi + command -v zypper >/dev/null + if [ command -v zypper >/dev/null -eq 0 ]; then + discover_package_manager_ret="zypper" + return + else + return + fi + fi +} + +echo "$discover_package_manager_ret" + diff --git a/install_BOOST.sh b/script/install_BOOST.sh similarity index 100% rename from install_BOOST.sh rename to script/install_BOOST.sh diff --git a/install_MPI.sh b/script/install_MPI.sh similarity index 100% rename from install_MPI.sh rename to script/install_MPI.sh diff --git a/install_Metis.sh b/script/install_Metis.sh similarity index 100% rename from install_Metis.sh rename to script/install_Metis.sh diff --git a/script/pre_req b/script/pre_req new file mode 100755 index 0000000000000000000000000000000000000000..f844ec575367816bd86af8409a0cdc683682e57a --- /dev/null +++ b/script/pre_req @@ -0,0 +1,128 @@ +#! /bin/bash + +source script/discover_package_manager + +platform=unknown + + +if [[ "$OSTYPE" == "linux-gnu" ]]; then + echo -e "We are on\033[1;34m LINUX \033[0m" + platform=linux +elif [[ "$OSTYPE" == "darwin"* ]]; then + echo -e "We are on\033[1;34m MAC OSX \033[0m" + platform=osx +elif [[ "$OSTYPE" == "cygwin" ]]; then + echo -e "We are on\033[1;34m CYGWIN \033[0m" + echo "This platform is not supported" + exit 1 +elif [[ "$OSTYPE" == "msys" ]]; then + echo -e "We are on\033[1;34m Microsoft Window \033[0m" + echo "This platform is not supported" + exit 1 +elif [[ "$OSTYPE" == "win32" ]]; then + echo -e "We are on\033[1;34m Microsoft Window \033[0m" + echo "This platform is not supported" + exit 1 +elif [[ "$OSTYPE" == "freebsd"* ]]; then + echo -e "We are on\033[1;34m FREEBSD \033[0m" + echo "This platform is not supported" + exit 1 +else + echo -e "We are on an\033[1;34m unknown OS \033[0m" + echo "This platform is not supported" + exit 1 +fi + +discover_package_manager $platform +pcman=discover_package_manager_ret + +if [ x"$platform" = x"osx" -a x"$pcman" = x"" ]; then + echo -e "\033[93;5;1m WARNING \033[0m No package manager has been found on this system" +fi + +command -v git >/dev/null 2>&1 +if [ $? -ne 0 ]; then + echo >&2 + echo -e "git\033[91;5;1m FAILED \033[0m" + echo "OpenFPM require git but it's not installed, searching a solution... " + script/solve_git $platform + command -v git >/dev/null 2>&1 + if [ $? -ne 0 ]; then + echo -e "git\033[91;5;1m FAILED \033[0m" + exit 1 + else + echo -e "git\033[92;1m SUCCESS \033[0m" + fi +else + echo -e "git \033[92;1m SUCCESS \033[0m" +fi + +command -v autoconf >/dev/null 2>&1 +if [ $? -ne 0 ]; then + echo >&2 + echo -e "autoconf\033[91;5;1m FAILED \033[0m" + echo "OpenFPM require autoconf but it's not installed, searching a solution..." + script/solve_autoconf $platform + command -v autoheader >/dev/null 2>&1 + if [ $? -ne 0 ]; then + echo -e "autoconf\033[91;5;1m FAILED \033[0m" + exit 1 + else + echo -e "autoconf\033[92;1m SUCCESS \033[0m" + fi +else + echo -e "autoconf\033[92;1m SUCCESS \033[0m" +fi + +command -v automake >/dev/null 2>&1 +if [ $? -ne 0 ]; then + echo >&2 + echo -e "automake\033[91;5;1m FAILED \033[0m" + echo "OpenFPM require automake but it's not installed, searching a solution..." + script/solve_automake $platform + command -v automake >/dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "automake\033[91;5;1m FAILED \033[0m" + exit 1 + else + echo -e "automake\033[92;1m SUCCESS \033[0m" + fi +else + echo -e "automake\033[92;1m SUCCESS \033[0m" +fi + +command -v libtool >/dev/null 2>&1 +if [ $? -ne 0 ]; then + echo >&2 + echo -e "libtool\033[91;5;1m FAILED \033[0m" + echo "OpenFPM require libtool but it's not installed, searching a solution..." + script/solve_libtool $platform + command -v libtool >/dev/null 2>&1 + if [ $? -ne 0 ]; then + echo -e "libtool\033[91;5;1m FAILED \033[0m" + exit 1 + else + echo -e "libtool\033[92;1m SUCCESS \033[0m" + fi +else + echo -e "libtool\033[92;1m SUCCESS \033[0m" +fi + +command -v g++ >/dev/null 2>&1 +if [ $? -ne 0 ]; then + echo >&2 + echo -e "Configure\033[91;5;1m FAILED \033[0m" + echo "OpenFPM require g++ but it's not installed, searching a solution..." + script/solve_gpp $platform + command -v g++ >/dev/null 2>&1 + if [ $? -ne 0 ]; then + echo -e "g++\033[91;5;1m FAILED \033[0m" + exit 1 + else + echo -e "g++\033[92;1m SUCCESS \033[0m" + fi +else + echo -e "g++\033[92;1m SUCCESS \033[0m" +fi + + diff --git a/script/show_solutions b/script/show_solutions new file mode 100644 index 0000000000000000000000000000000000000000..3da12c682465831317477127aeb224d086f77311 --- /dev/null +++ b/script/show_solutions @@ -0,0 +1,19 @@ +#! /bin/bash + +function possible_solutions { + sol=1 + echo "Possible solutions:" + for com in "$@" + do + echo "$sol $com" + sol=`expr $sol + 1` + done + echo "$sol exit the script" + echo "Choose the solution:" + read choose + if [ x"$choose" = x"$sol" ]; then + exit 1 + fi + possible_solutions_ret=`expr $choose - 1` +} + diff --git a/script/solve_autoconf b/script/solve_autoconf new file mode 100644 index 0000000000000000000000000000000000000000..7ddbd8cd4b41237d90c833111816afb7b4d5d727 --- /dev/null +++ b/script/solve_autoconf @@ -0,0 +1,24 @@ +#! /bin/bash + +source script/show_solutions +source script/discover_package_manager +discover_package_manager $1 +pcman=$discover_package_manager_ret + +if [ x"$pcman" = x"" ]; then + exit 1 +fi + +if [ x"$1" = x"osx" ]; then + commands[0]="$pcman install autoconf" + possible_solutions "${commands[@]}" + echo "Executing: ${command[$possible_solutions_ret]}" + eval ${commands[$possible_solutions_ret]} +elif [ x"$1" = x"linux" ]; then + commands[0]="su -c \"$pcman install autoconf\"" + commands[1]="sudo $pcman install autoconf" + possible_solutions "${commands[@]}" + echo "Executing: ${command[$possible_solutions_ret]}" + eval ${commands[$possible_solutions_ret]} +fi + diff --git a/script/solve_automake b/script/solve_automake new file mode 100644 index 0000000000000000000000000000000000000000..4d18db7671b227a071c2d5ea22203c7bb0ff85c0 --- /dev/null +++ b/script/solve_automake @@ -0,0 +1,24 @@ +#! /bin/bash + +source script/show_solutions +source script/discover_package_manager +discover_package_manager $1 +pcman=$discover_package_manager_ret + +if [ x"$pcman" = x"" ]; then + exit 1 +fi + +if [ x"$1" = x"osx" ]; then + commands[0]="$pcman install automake" + possible_solutions "${commands[@]}" + echo "Executing: ${command[$possible_solutions_ret]}" + eval ${commands[$possible_solutions_ret]} +elif [ x"$1" = x"linux" ]; then + commands[0]="su -c \"$pcman install automake\"" + commands[1]="sudo $pcman install automake" + possible_solutions "${commands[@]}" + echo "Executing: ${command[$possible_solutions_ret]}" + eval ${commands[$possible_solutions_ret]} +fi + diff --git a/script/solve_git b/script/solve_git new file mode 100644 index 0000000000000000000000000000000000000000..c622e3d470e5a1d95aae104e79dff369b312e09c --- /dev/null +++ b/script/solve_git @@ -0,0 +1,22 @@ +#! /bin/bash + +source script/show_solutions +source script/discover_package_manager +discover_package_manager $1 +pcman=$discover_package_manager_ret + +if [ x"$pcman" = x"" ]; then + exit 1 +fi + +if [ x"$1" = x"osx" ]; then + commands[0]="$pcman install git" + possible_solutions "${commands[@]}" + eval ${command[possible_solutions_ret]} +elif [ x"$1" = x"linux" ]; then + commands[0]="su -c \"$pcman install git\"" + commands[1]="sudo $pcman install git" + possible_solutions "${commands[@]}" + eval ${commands[$possible_solutions_ret]} +fi + diff --git a/script/solve_libtool b/script/solve_libtool new file mode 100644 index 0000000000000000000000000000000000000000..e2ec3911f97b7dc1eedd05f60a5d50d7745d043e --- /dev/null +++ b/script/solve_libtool @@ -0,0 +1,24 @@ +#! /bin/bash + +source script/show_solutions +source script/discover_package_manager +discover_package_manager $1 +pcman=$discover_package_manager_ret + +if [ x"$pcman" = x"" ]; then + exit 1 +fi + +if [ x"$1" = x"osx" ]; then + commands[0]="$pcman install libtool" + possible_solutions "${commands[@]}" + echo "Executing: ${command[$possible_solutions_ret]}" + eval ${commands[$possible_solutions_ret]} +elif [ x"$1" = x"linux" ]; then + commands[0]="su -c \"$pcman install libtool\"" + commands[1]="sudo $pcman install libtool" + possible_solutions "${commands[@]}" + echo "Executing: ${command[$possible_solutions_ret]}" + eval ${commands[$possible_solutions_ret]} +fi +