#!/bin/bash # Script checks existence of cmake. If cmake is not # installed or the installed version is to old (compared # to the requiered version) cmake is installed and # the bin directory is added to $PATH # TODO: Do we should edit the login script and add the # cmake bin directory to the PATH is_in_path cmake result=$? if [ "$result" = "0" ]; then echo "cmake not found in PATH" | tee -a $logfile echo "install cmake as external package" | tee -a $logfile install_cmake=yes else cmake_required_major_version=$(echo $CMAKEVERSION | cut -c7) cmake_required_minor_version=$(echo $CMAKEVERSION | cut -c9) cmake_required_patch_version=$(echo $CMAKEVERSION | cut -c11) cmake_required_version=$(echo $CMAKEVERSION | cut -c7-12) cmake_installed_major_version=$(cmake --version | cut -c15) cmake_installed_minor_version=$(cmake --version | cut -c17) cmake_installed_patch_version=$(cmake --version | cut -c25) if [ $cmake_installed_major_version -eq $cmake_required_major_version -a \ $cmake_installed_minor_version -ge $cmake_required_minor_version ]; then if [ $cmake_installed_patch_version -ge $cmake_required_patch_version -o \ $cmake_installed_minor_version -gt $cmake_required_minor_version ]; then install_cmake=no echo "Found cmake version newer than $cmake_required_version in PATH"| tee -a $logfile echo "This version is okay. Don't install cmake as external package."| tee -a $logfile else install_cmake=yes echo "Found cmake version older than $cmake_required_version PATH"| tee -a $logfile echo "This version is to old"| tee -a $logfile echo "install cmake as external package"| tee -a $logfile fi else install_cmake=yes echo "Found cmake version older than $cmake_required_version PATH"| tee -a $logfile echo "This version is to old"| tee -a $logfile echo "install cmake as external package"| tee -a $logfile fi fi if [ "$install_cmake" = "yes" ]; then export PATH=$SIMPATH/basics/cmake/bin:$PATH: if (not_there CMake $SIMPATH/basics/cmake/bin/cmake) then cd $SIMPATH/basics untar CMake $CMAKEVERSION.tar.gz ln -s $CMAKEVERSION cmake cd cmake ./bootstrap --prefix=$SIMPATH/basics/cmake $MAKE_command -j $number_of_processes $MAKE_command install -j $number_of_processes check_success CMake $SIMPATH/basics/cmake/bin/cmake check=$? fi if [ "$check" = "1" ]; then export PATH=$SIMPATH/basics/cmake/bin:$PATH else echo "There was a problem installing cmake" echo "Stop the script at this point" exit fi fi cd $SIMPATH return 1