]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Wed, 19 Apr 2017 20:05:31 +0000 (15:05 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Wed, 19 Apr 2017 20:05:31 +0000 (15:05 -0500)
INSTALL.txt [deleted file]
README.txt
install/INSTALL.txt [new file with mode: 0644]
install/cpPlugins_Install_Dependencies.sh [new file with mode: 0755]
install/cpPlugins_Install_Functions.sh [new file with mode: 0644]

diff --git a/INSTALL.txt b/INSTALL.txt
deleted file mode 100644 (file)
index bf667ef..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-
-0. Pre-requisites
------------------
-
-cpPlugins is developed in C++11 and makes extensive use of VTK (>=7.0) and
-ITK (>=4.10). Qt (=4.8) could be used at will.
-
-In order to compile it, you will need a development environment that includes:
-
-  - A decent C++11 compiler. If you use g++ (on linux-like machines) or Xcode
-    (on Mac boxes) you should be ok. On Windows, is rather difficult (thanks
-    Microsoft?), but it is recommened to use the MinGW environment.
-  - make.
-  - git, if you want to gain access to the latest versions of every package.
-  - GLUT.
-  - whatever your compiler complains about... ;-)
-
-On this manual, all third party packages will be downloaded and compiled on the
-~/sources path and will be installed on the ~/local path. If you want to follow
-exactly the same commands, please execute the next commands on your console
-before continuing:
-
-  $ cd
-  $ mkdir -p sources
-  $ mkdir -p local
-
-1. Qt compilation
------------------
-
-Although native Qt4.8 installers can be found on most platforms, you could face
-the (really ugly) Qt compilation process, specially if you are on Windows or MAC.
-However, the normal compilation is rather simple:
-
- - download your qt4.8 source code:
-   $ cd ~/sources
-   $ wget http://download.qt.io/official_releases/qt/4.8/4.8.7/qt-everywhere-opensource-src-4.8.7.tar.gz
-
- - On linux, configure the native Qt compilation chain:
-   $ cd ~/sources
-   $ mkdir -p qt-binaries-4.8.7
-   $ cd qt-binaries-4.8.7
-   $ ~/sources/qt-source-4.8.7/configure \
-       -release -opensource -shared -fast \
-       -optimized-qmake -confirm-license \
-       -prefix ~/local
-
-## eof - $RCSfile$
index f5500f276a1765817e059076ccb004cf653fa615..249c1df8c6bc5643944abea90444f7f9dd4ae6b5 100644 (file)
@@ -1,7 +1,14 @@
 
+Authors
+-------
+
+Leonardo Flórez-Valencia (florez-l@javeriana.edu.co)
+Maciej Orkisz (orkisz@creatis.insa-lyon.fr)
+
+
 Installation
 ------------
 
-Please refer to the file "INSTALL.txt"
+Please refer to the file "install/INSTALL.txt"
 
 ## eof - $RCSfile$
\ No newline at end of file
diff --git a/install/INSTALL.txt b/install/INSTALL.txt
new file mode 100644 (file)
index 0000000..26d2a8f
--- /dev/null
@@ -0,0 +1,30 @@
+
+0. Pre-requisites
+-----------------
+
+cpPlugins is developed in C++11 and makes extensive use of VTK (>=7.0) and
+ITK (>=4.10). Qt (=4.8) could be used at will.
+
+In order to compile it, you will need a development environment that includes:
+
+  - A decent C++11 compiler. If you use g++ (on linux-like machines) or Xcode
+    (on Mac boxes) you should be ok. On Windows, is rather difficult (thanks
+    Microsoft?), but it is recommened to use the MinGW environment.
+  - make.
+  - git, if you want to gain access to the latest versions of every package.
+  - GLUT.
+  - whatever your compiler complains about... ;-)
+
+A convinient shell script (cpPlugins_Install_Dependencies.sh) is distributed
+with this notice in order to simplify the base librraries installation process.
+You could use it to compile Qt, CMake, ITK and VTK, as long as you have
+downloaded the compressed files of each package:
+
+  - Qt    : http://download.qt.io/official_releases/qt/4.8/4.8.7/
+  - CMake : http://www.cmake.org
+  - ITK   : http://www.itk.org
+  - VTK   : http://www.vtk.org
+
+This script has been tested on: Ubuntu.
+
+## eof - $RCSfile$
diff --git a/install/cpPlugins_Install_Dependencies.sh b/install/cpPlugins_Install_Dependencies.sh
new file mode 100755 (executable)
index 0000000..c18416d
--- /dev/null
@@ -0,0 +1,265 @@
+#!/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$
diff --git a/install/cpPlugins_Install_Functions.sh b/install/cpPlugins_Install_Functions.sh
new file mode 100644 (file)
index 0000000..f69aca0
--- /dev/null
@@ -0,0 +1,95 @@
+#!/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$