--- /dev/null
+#!/bin/bash
+
+
+# ===================
+# = Welcome message =
+# ===================
+
+echo "#######################################################################"
+echo "# This wizard will guide you through the installation of all packages #"
+echo "# that cpPlugins relies on. Please read carefully all instructions. #"
+echo "#######################################################################"
+
+# ==================
+# = Various values =
+# ==================
+
+number_of_cores=`nproc --all`
+number_of_threads=`expr $number_of_cores / 2`
+install_prefix="$HOME/local"
+build_type="release"
+linking_mode="shared"
+cur_dir=`pwd`
+bash_dir=`readlink -f ${0/#\~/$HOME} | xargs dirname`
+
+echo "#######################################################################"
+echo " Number of cores : $number_of_cores "
+echo " Number of threads : $number_of_threads "
+echo " Install prefix : $install_prefix "
+echo " Build type : $build_type "
+echo " Linking mode : $linking_mode "
+echo " Current directory : $cur_dir "
+echo " Bash directory : $bash_dir "
+echo "#######################################################################"
+read -p "Is this ok? [y/N] " -n 1 -r
+echo
+if [[ $REPLY =~ ^[Nn]$ ]]; then
+ echo "Sorry to hear this. Please change these values by modifying this script."
+ exit 1
+fi
+
+if [ "$build_type" == "release" ]; then
+ itk_build_type="MinSizeRel"
+ vtk_build_type="MinSizeRel"
+else
+ itk_build_type="Debug"
+ vtk_build_type="Debug"
+fi
+
+
+# =====================
+# = Include functions =
+# =====================
+
+source $bash_dir/cpPlugins_Install_Functions.sh
+
+# ===================
+# = Check for Qt4.8 =
+# ===================
+
+read -p "Do you want to use Qt4.8? [y/N] " -n 1 -r
+echo
+if [[ $REPLY =~ ^[Yy]$ ]]; then
+ echo "#####################"
+ echo "# Configuring Qt4.8 #"
+ echo "#####################"
+ qmake_exe=`find_executables qmake qmake-qt4`
+ if [ "x$qmake_exe" == "x" ]; then
+ qmake_source_dir=""
+ qmake_binary_dir=""
+ echo "----> Ok, we will compile Qt4.8 from source code <----"
+ read -e -p "--> Please provide a valid location of Qt4.8's source code (either a compressed file or directory): " tmp
+ qmake_loc=`readlink -f ${tmp/#\~/$HOME}`
+ if [[ -f $qmake_loc ]]; then
+ echo -n "--> Expanding Qt4.8 source code... "
+ qmake_source_dir=`dirname $qmake_loc`/`echo \`basename $qmake_loc\` | sed 's/\./_/g'`_sources
+ qmake_binary_dir=`dirname $qmake_loc`/`echo \`basename $qmake_loc\` | sed 's/\./_/g'`_binary
+ rm -rf $qmake_source_dir $qmake_binary_dir
+ mkdir -p $qmake_source_dir
+ uncompress $qmake_loc $qmake_source_dir
+ echo "done!"
+ else
+ qmake_source_dir=$qmake_loc
+ qmake_binary_dir="$qmake_loc"_binary
+ fi
+ mkdir -p $qmake_binary_dir
+ cd $qmake_binary_dir
+ $qmake_source_dir/configure \
+ -$build_type -opensource -$linking_mode -fast \
+ -optimized-qmake -confirm-license \
+ -nomake demos -nomake examples \
+ -prefix $install_prefix
+ make -j$number_of_threads -k
+ make -j install
+ cd $cur_dir
+ qmake_exe=""
+ qmake_execs=($install_prefix/bin/qmake $install_prefix/bin/qmake-qt4)
+ for i in $qmake_execs; do
+ if [[ -f "$i" ]]; then
+ qmake_exe=$i
+ break
+ fi
+ done
+ fi
+ if [ "x$qmake_exe" == "x" ]; then
+ echo "Sorry, could not find a vaild qmake executable. Bailing out!!!"
+ exit 1
+ fi
+ qt_version=`$qmake_exe -v | grep Using\ Qt\ version | sed 's/Using\ Qt\ version\ //g'`
+ if version_gt 4.8 $qt_version; then
+ echo "*** FATAL ERROR: your Qt version is $qt_version, but needed version should be 4.8 ***"
+ fi
+fi
+
+# ===============
+# = Build CMake =
+# ===============
+
+echo "#####################"
+echo "# Configuring CMake #"
+echo "#####################"
+cmake_exe=`find_executables cmake`
+if [ "x$cmake_exe" == "x" ]; then
+ cmake_source_dir=""
+ cmake_binary_dir=""
+ echo "----> Ok, we will compile CMake from source code <----"
+ read -e -p "--> Please provide a valid location of CMake's source code (either a compressed file or directory): " tmp
+ cmake_loc=`readlink -f ${tmp/#\~/$HOME}`
+ if [[ -f $cmake_loc ]]; then
+ echo -n "--> Expanding CMake source code... "
+ cmake_source_dir=`dirname $cmake_loc`/`echo \`basename $cmake_loc\` | sed 's/\./_/g'`_sources
+ cmake_binary_dir=`dirname $cmake_loc`/`echo \`basename $cmake_loc\` | sed 's/\./_/g'`_binary
+ rm -rf $cmake_source_dir $cmake_binary_dir
+ mkdir -p $cmake_source_dir
+ uncompress $cmake_loc $cmake_source_dir
+ echo "done!"
+ else
+ cmake_source_dir=$cmake_loc
+ cmake_binary_dir="$cmake_loc"_binary
+ fi
+ cmake_qt_options="--no-qt-gui"
+ if [ -x "$qmake_exe" ]; then
+ cmake_qt_options="--qt-gui --qt-qmake=$qmake_exe"
+ fi
+ mkdir -p $cmake_binary_dir
+ cd $cmake_binary_dir
+ $cmake_source_dir/bootstrap --prefix=$install_prefix $cmake_qt_options
+ make -j$number_of_threads -k
+ make -j install
+ cd $cur_dir
+ cmake_exe=""
+ cmake_execs=($install_prefix/bin/cmake)
+ for i in $cmake_execs; do
+ if [[ -f "$i" ]]; then
+ cmake_exe=$i
+ break
+ fi
+ done
+fi
+if [ "x$cmake_exe" == "x" ]; then
+ echo "Sorry, could not find a vaild cmake executable. Bailing out!!!"
+ exit 1
+fi
+cmake_version=`$cmake_exe -version | grep cmake\ version | sed 's/cmake\ version\ //g'`
+if version_gt 3.0 $cmake_version; then
+ echo "*** FATAL ERROR: your CMake version is $cmake_version, but needed version should be at least 3.0 ***"
+fi
+
+# =============
+# = Build ITK =
+# =============
+
+echo "#####################"
+echo "# Configuring ITK #"
+echo "#####################"
+itk_source_dir=""
+itk_binary_dir=""
+echo "----> Ok, we will compile ITK from source code <----"
+read -e -p "--> Please provide a valid location of ITK's source code (either a compressed file or directory): " tmp
+itk_loc=`readlink -f ${tmp/#\~/$HOME}`
+if [[ -f $itk_loc ]]; then
+ echo -n "--> Expanding ITK source code... "
+ itk_source_dir=`dirname $itk_loc`/`echo \`basename $itk_loc\` | sed 's/\./_/g'`_sources
+ itk_binary_dir=`dirname $itk_loc`/`echo \`basename $itk_loc\` | sed 's/\./_/g'`_binary
+ rm -rf $itk_source_dir $itk_binary_dir
+ mkdir -p $itk_source_dir
+ uncompress $itk_loc $itk_source_dir
+ echo "done!"
+else
+ itk_source_dir=$itk_loc
+ itk_binary_dir="$itk_loc"_binary
+fi
+mkdir -p $itk_binary_dir
+cd $itk_binary_dir
+$cmake_exe \
+ -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
+ -DBUILD_DOCUMENTATION:BOOL=OFF \
+ -DBUILD_EXAMPLES:BOOL=OFF \
+ -DBUILD_SHARED_LIBS:BOOL=ON \
+ -DBUILD_TESTING:BOOL=OFF \
+ -DCMAKE_BUILD_TYPE:STRING=$itk_build_type \
+ -DModule_ITKReview:BOOL=ON \
+ -DModule_ITKVtkGlue:BOOL=OFF \
+ -DCMAKE_INSTALL_PREFIX:PATH=$install_prefix \
+ $itk_source_dir
+make -j$number_of_threads -k
+make -j install
+cd $cur_dir
+
+# =============
+# = Build VTK =
+# =============
+
+echo "#####################"
+echo "# Configuring VTK #"
+echo "#####################"
+vtk_source_dir=""
+vtk_binary_dir=""
+echo "----> Ok, we will compile VTK from source code <----"
+read -e -p "--> Please provide a valid location of VTK's source code (either a compressed file or directory): " tmp
+vtk_loc=`readlink -f ${tmp/#\~/$HOME}`
+if [[ -f $vtk_loc ]]; then
+ echo -n "--> Expanding VTK source code... "
+ vtk_source_dir=`dirname $vtk_loc`/`echo \`basename $vtk_loc\` | sed 's/\./_/g'`_sources
+ vtk_binary_dir=`dirname $vtk_loc`/`echo \`basename $vtk_loc\` | sed 's/\./_/g'`_binary
+ rm -rf $vtk_source_dir $vtk_binary_dir
+ mkdir -p $vtk_source_dir
+ uncompress $vtk_loc $vtk_source_dir
+ echo "done!"
+else
+ vtk_source_dir=$vtk_loc
+ vtk_binary_dir="$vtk_loc"_binary
+fi
+mkdir -p $vtk_binary_dir
+cd $vtk_binary_dir
+if [ "x$qmake_exe" == "x" ]; then
+ $cmake_exe \
+ -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
+ -DBUILD_DOCUMENTATION:BOOL=OFF \
+ -DBUILD_EXAMPLES:BOOL=OFF \
+ -DBUILD_SHARED_LIBS:BOOL=ON \
+ -DBUILD_TESTING:BOOL=OFF \
+ -DCMAKE_BUILD_TYPE:STRING=$vtk_build_type \
+ -DCMAKE_INSTALL_PREFIX:PATH=$install_prefix \
+ $vtk_source_dir
+else
+ $cmake_exe \
+ -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
+ -DBUILD_DOCUMENTATION:BOOL=OFF \
+ -DBUILD_EXAMPLES:BOOL=OFF \
+ -DBUILD_SHARED_LIBS:BOOL=ON \
+ -DBUILD_TESTING:BOOL=OFF \
+ -DQT_QMAKE_EXECUTABLE:PATH=$qmake_exe \
+ -DCMAKE_BUILD_TYPE:STRING=$vtk_build_type \
+ -DModule_vtkGUISupportQt:BOOL=ON \
+ -DModule_vtkGUISupportQtOpenGL:BOOL=ON \
+ -DModule_vtkGUISupportQtSQL:BOOL=OFF \
+ -DModule_vtkGUISupportQtWebkit:BOOL=OFF \
+ -DCMAKE_INSTALL_PREFIX:PATH=$install_prefix \
+ $vtk_source_dir
+fi
+make -j$number_of_threads -k
+make -j install
+cd $cur_dir
+
+## eof - $RCSfile$
--- /dev/null
+#!/bin/bash
+
+## =================================
+## == Compare two version strings ==
+## =================================
+
+function version_gt {
+ test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1";
+}
+
+# =======================
+# = Uncompress function =
+# =======================
+
+function uncompress {
+ z_file=$1
+ z_output=$2
+ z_mime=`file -b --mime-type $z_file`:`file -bz --mime-type $z_file`
+
+ uz_command=""
+ case $z_mime in
+ application/gzip:application/x-tar)
+ uz_command="tar xzf $z_file -C $z_output --strip-components=1"
+ ;;
+ application/x-bzip2:application/x-tar)
+ uz_command="tar xjf $z_file -C $z_output --strip-components=1"
+ ;;
+ application/x-compress:application/x-tar)
+ uz_command="zcat $z_file | tar xf - -C $z_output --strip-components=1"
+ ;;
+ application/x-lzip:application/x-empty)
+ uz_command="tar --lzip xf $z_file -C $z_output --strip-components=1"
+ ;;
+ application/x-tar:application/x-tar)
+ uz_command="tar xf $z_file -C $z_output --strip-components=1"
+ ;;
+ application/x-xz:application/x-tar)
+ uz_command="tar xJf $z_file -C $z_output --strip-components=1"
+ ;;
+ application/zip:application/x-empty)
+ uz_command="unzip $z_file -d $z_output"
+ ;;
+ *)
+ (>&2 echo "====================================")
+ (>&2 echo "Unknown file format for \"$z_file\"")
+ (>&2 echo "MIME-TYPE: $z_mime")
+ (>&2 echo "====================================")
+ exit 1
+ ;;
+ esac
+ eval $uz_command
+}
+
+# =============================
+# = Find executables function =
+# =============================
+
+function find_executables {
+ exe=""
+ execs=`which -a $@`
+ if [ "${#execs[@]}" -gt "0" ]; then
+ (>&2 echo "--> I have found a(some) executable(s), please choose one:")
+ c=0
+ choices=()
+ for i in ${execs[@]}; do
+ (>&2 echo " [$c] $i")
+ choices+=("$i")
+ c=$[$c+1]
+ done
+ (>&2 echo " [$c] Manually choose another installation")
+ c=$[$c+1]
+ (>&2 echo " [$c] Compile from source code")
+ (>&2 echo -n " Please choose a number and press [ENTER]: ")
+ read choice
+ if [ "$choice" -lt "${#choices[@]}" ]; then
+ exe=${choices[$choice]}
+ elif [ "$choice" -eq "${#choices[@]}" ]; then
+ read -e -p "Please provide a valid location: " tmp
+ exe=`readlink -f ${tmp/#\~/$HOME}`
+ fi
+ else
+ (>&2 echo "--> I have not found any valid install, please choose:")
+ (>&2 echo " [0] Manually choose an installation")
+ (>&2 echo " [1] Compile from source code")
+ (>&2 echo -n " Please choose a number and press [ENTER]: ")
+ read choice
+ if [ "$choice" -eq "0" ]; then
+ read -e -p "Please provide a valid location: " tmp
+ exe=`readlink -f ${tmp/#\~/$HOME}`
+ fi
+ fi
+ echo "$exe"
+}
+
+## eof - $RCSfile$