#!/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_REQUIRED | cut -d- -f2 | cut -d. -f1) cmake_required_minor_version=$(echo $CMAKEVERSION_REQUIRED | cut -d- -f2 |cut -d. -f2) cmake_required_patch_version=$(echo $CMAKEVERSION_REQUIRED | cut -d- -f2 |cut -d. -f3) cmake_required_version=$(echo $CMAKEVERSION_REQUIRED | cut -d- -f2) cmake_installed_major_version=$(cmake --version | cut -d' ' -f3 | cut -d. -f1) cmake_installed_minor_version=$(cmake --version | cut -d. -f2) cmake_installed_patch_version=$(cmake --version | cut -d. -f3) cmake_version=$(cmake --version | cut -c15-) if [ "$cmake_installed_patch_version" == "" ]; then # output of cmake 2.8 is 'cmake version 2.8.2' # output of cmake 2.6 is 'cmake version 2.6-patch 0' cmake_installed_patch_version=$(cmake --version | cut -c19) fi 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 $cmake_version which is newer than the"| tee -a $logfile echo "required version $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 $cmake_version which is older than the"| tee -a $logfile echo "required version $cmake_required_version in 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 if [ "$make_install" = "yes" ]; then install_prefix=$SIMPATH_INSTALL else install_prefix=$SIMPATH/basics/cmake fi checkfile=$install_prefix/bin/cmake export PATH=$install_prefix/bin:$PATH: if (not_there CMake $checkfile) then cd $SIMPATH/basics untar CMake $CMAKEVERSION.tar.gz ln -s $CMAKEVERSION cmake cd cmake # is_in_path cmake # result=$? # if [ "$result" = "0" ]; # then ./bootstrap --prefix=$install_prefix # else # mkdir builddir # cd builddir # cmake .. -DCMAKE_INSTALL_PREFIX=$install_prefix # fi $MAKE_command -j $number_of_processes $MAKE_command install -j $number_of_processes check_success CMake $checkfile check=$? fi if [ "$check" = "1" ]; then export PATH=$install_prefix/bin:$PATH else echo "There was a problem installing cmake" echo "Stop the script at this point" exit fi fi cd $SIMPATH return 1