]> Creatis software - cpPlugins.git/blob - install/cpPlugins_Install_Dependencies.sh
cbfb9862e17f17aa7b43cf1de49746d110110772
[cpPlugins.git] / install / cpPlugins_Install_Dependencies.sh
1 #!/bin/bash
2
3 # ===================
4 # = Welcome message =
5 # ===================
6
7 echo "#######################################################################"
8 echo "# This wizard will guide you through the installation of all packages #"
9 echo "# that cpPlugins relies on. Please read carefully all instructions.   #"
10 echo "#######################################################################"
11
12 # ==================
13 # = Various values =
14 # ==================
15
16 number_of_threads="nope"
17 while ! [[ "$number_of_threads" =~ ^[0-9]+$ ]]; do
18     echo -n "--> How many threads do you want to use to compile?: "
19     read number_of_threads
20 done
21 read -e -p "--> Please provide where you want to install the packages I will generate: " tmp
22 install_prefix="${tmp/#\~/$HOME}"
23 echo "--> What kind of compilation will you want to perform?"
24 echo "    [0] Debug"
25 echo "    [1] Release"
26 echo -n "  Please choose a number and press [ENTER]: "
27 read choice
28 qt_build_type="release"
29 tk_build_type="MinSizeRel"
30 if [ "$choice" -eq 0 ]; then
31     qt_build_type="debug"
32     tk_build_type="Debug"
33 fi
34 echo "--> What kind of linkage will you want to perform?"
35 echo "    [0] Static"
36 echo "    [1] Shared"
37 echo -n "  Please choose a number and press [ENTER]: "
38 read choice
39 link_type="shared"
40 if [ "$choice" -eq 0 ]; then
41     link_type="static"
42 fi
43 cur_dir=`pwd`
44 bash_dir=`readlink -f ${0/#\~/$HOME} | xargs dirname`
45
46 echo "#######################################################################"
47 echo "  PLEASE REVIEW THE FOLLOWING INFORMATION:"
48 echo "#######################################################################"
49 echo "  Number of threads : $number_of_threads"
50 echo "  Install prefix    : $install_prefix"
51 echo "  Build type        : $qt_build_type;$tk_build_type"
52 echo "  Linking mode      : $link_type"
53 echo "  Current directory : $cur_dir"
54 echo "  Bash directory    : $bash_dir"
55 echo "#######################################################################"
56 read -p "Is this ok? [y/N] " -n 1 -r
57 echo
58 if [[ $REPLY =~ ^[Nn]$ ]]; then
59     echo "Sorry to hear this. Please change these values by re-executing this script."
60     exit 1
61 fi
62
63 # =====================
64 # = Include functions =
65 # =====================
66
67 source $bash_dir/cpPlugins_Install_Functions.sh
68
69 # ===================
70 # = Check for Qt4.8 =
71 # ===================
72
73 read -p "Do you want to use Qt4.8? [y/N] " -n 1 -r
74 echo
75 if [[ $REPLY =~ ^[Yy]$ ]]; then
76     echo "#####################"
77     echo "# Configuring Qt4.8 #"
78     echo "#####################"
79     qmake_exe=`choose_installation \`which -a qmake qmake-qt4\``
80     if [ "x$qmake_exe" == "x" ]; then
81         qmake_source_dir=`prepare_compilation`
82         qmake_binary_dir="$qmake_source_dir"_build
83         rm -rf $qmake_binary_dir
84         mkdir -p $qmake_binary_dir
85         cd $qmake_binary_dir
86         $qmake_source_dir/configure \
87             -$qt_build_type -opensource -$link_type -fast \
88             -optimized-qmake -confirm-license \
89             -nomake demos -nomake examples \
90             -prefix $install_prefix
91         make -j$number_of_threads -k
92         make -j install
93         cd $cur_dir
94     fi
95 fi
96
97
98 #         qmake_exe=""
99 #         qmake_execs=($install_prefix/bin/qmake $install_prefix/bin/qmake-qt4)
100 #         for i in $qmake_execs; do
101 #             if [[ -f "$i" ]]; then
102 #                 qmake_exe=$i
103 #                 break
104 #             fi
105 #         done
106 #     fi
107 #     if [ "x$qmake_exe" == "x" ]; then
108 #         echo "Sorry, could not find a vaild qmake executable. Bailing out!!!"
109 #         exit 1
110 #     fi
111 #     qt_version=`$qmake_exe -v | grep Using\ Qt\ version | sed 's/Using\ Qt\ version\ //g'`
112 #     if version_gt 4.8 $qt_version; then
113 #         echo "*** FATAL ERROR: your Qt version is $qt_version, but needed version should be 4.8 ***"
114 #     fi
115 # fi
116
117 # # ===============
118 # # = Build CMake =
119 # # ===============
120
121 # echo "#####################"
122 # echo "# Configuring CMake #"
123 # echo "#####################"
124 # cmake_exe=`find_executables cmake`
125 # if [ "x$cmake_exe" == "x" ]; then
126 #     cmake_source_dir=""
127 #     cmake_binary_dir=""
128 #     echo "----> Ok, we will compile CMake from source code <----"
129 #     read -e -p "--> Please provide a valid location of CMake's source code (either a compressed file or directory): " tmp
130 #     cmake_loc=`readlink -f ${tmp/#\~/$HOME}`
131 #     if [[ -f $cmake_loc ]]; then
132 #         echo -n "--> Expanding CMake source code... "
133 #         cmake_source_dir=`dirname $cmake_loc`/`echo \`basename $cmake_loc\` | sed 's/\./_/g'`_sources
134 #         cmake_binary_dir=`dirname $cmake_loc`/`echo \`basename $cmake_loc\` | sed 's/\./_/g'`_binary
135 #         rm -rf $cmake_source_dir $cmake_binary_dir
136 #         mkdir -p $cmake_source_dir
137 #         uncompress $cmake_loc $cmake_source_dir
138 #         echo "done!"
139 #     else
140 #         cmake_source_dir=$cmake_loc
141 #         cmake_binary_dir="$cmake_loc"_binary
142 #     fi
143 #     cmake_qt_options="--no-qt-gui"
144 #     if [ -x "$qmake_exe" ]; then
145 #         cmake_qt_options="--qt-gui --qt-qmake=$qmake_exe"
146 #     fi
147 #     mkdir -p $cmake_binary_dir
148 #     cd $cmake_binary_dir
149 #     $cmake_source_dir/bootstrap --prefix=$install_prefix $cmake_qt_options
150 #     make -j$number_of_threads -k
151 #     make -j install
152 #     cd $cur_dir
153 #     cmake_exe=""
154 #     cmake_execs=($install_prefix/bin/cmake)
155 #     for i in $cmake_execs; do
156 #         if [[ -f "$i" ]]; then
157 #             cmake_exe=$i
158 #             break
159 #         fi
160 #     done
161 # fi
162 # if [ "x$cmake_exe" == "x" ]; then
163 #     echo "Sorry, could not find a vaild cmake executable. Bailing out!!!"
164 #     exit 1
165 # fi
166 # cmake_version=`$cmake_exe -version | grep cmake\ version | sed 's/cmake\ version\ //g'`
167 # if version_gt 3.0 $cmake_version; then
168 #     echo "*** FATAL ERROR: your CMake version is $cmake_version, but needed version should be at least 3.0 ***"
169 # fi
170
171 # # =============
172 # # = Build ITK =
173 # # =============
174
175 # echo "#####################"
176 # echo "# Configuring ITK #"
177 # echo "#####################"
178 # itk_source_dir=""
179 # itk_binary_dir=""
180 # echo "----> Ok, we will compile ITK from source code <----"
181 # read -e -p "--> Please provide a valid location of ITK's source code (either a compressed file or directory): " tmp
182 # itk_loc=`readlink -f ${tmp/#\~/$HOME}`
183 # if [[ -f $itk_loc ]]; then
184 #     echo -n "--> Expanding ITK source code... "
185 #     itk_source_dir=`dirname $itk_loc`/`echo \`basename $itk_loc\` | sed 's/\./_/g'`_sources
186 #     itk_binary_dir=`dirname $itk_loc`/`echo \`basename $itk_loc\` | sed 's/\./_/g'`_binary
187 #     rm -rf $itk_source_dir $itk_binary_dir
188 #     mkdir -p $itk_source_dir
189 #     uncompress $itk_loc $itk_source_dir
190 #     echo "done!"
191 # else
192 #     itk_source_dir=$itk_loc
193 #     itk_binary_dir="$itk_loc"_binary
194 # fi
195 # mkdir -p $itk_binary_dir
196 # cd $itk_binary_dir
197 # $cmake_exe \
198 #     -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
199 #     -DBUILD_DOCUMENTATION:BOOL=OFF \
200 #     -DBUILD_EXAMPLES:BOOL=OFF \
201 #     -DBUILD_SHARED_LIBS:BOOL=ON \
202 #     -DBUILD_TESTING:BOOL=OFF \
203 #     -DCMAKE_BUILD_TYPE:STRING=$itk_build_type \
204 #     -DModule_ITKReview:BOOL=ON \
205 #     -DModule_ITKVtkGlue:BOOL=OFF \
206 #     -DCMAKE_INSTALL_PREFIX:PATH=$install_prefix \
207 #     $itk_source_dir
208 # make -j$number_of_threads -k
209 # make -j install
210 # cd $cur_dir
211
212 # # =============
213 # # = Build VTK =
214 # # =============
215
216 # echo "#####################"
217 # echo "# Configuring VTK #"
218 # echo "#####################"
219 # vtk_source_dir=""
220 # vtk_binary_dir=""
221 # echo "----> Ok, we will compile VTK from source code <----"
222 # read -e -p "--> Please provide a valid location of VTK's source code (either a compressed file or directory): " tmp
223 # vtk_loc=`readlink -f ${tmp/#\~/$HOME}`
224 # if [[ -f $vtk_loc ]]; then
225 #     echo -n "--> Expanding VTK source code... "
226 #     vtk_source_dir=`dirname $vtk_loc`/`echo \`basename $vtk_loc\` | sed 's/\./_/g'`_sources
227 #     vtk_binary_dir=`dirname $vtk_loc`/`echo \`basename $vtk_loc\` | sed 's/\./_/g'`_binary
228 #     rm -rf $vtk_source_dir $vtk_binary_dir
229 #     mkdir -p $vtk_source_dir
230 #     uncompress $vtk_loc $vtk_source_dir
231 #     echo "done!"
232 # else
233 #     vtk_source_dir=$vtk_loc
234 #     vtk_binary_dir="$vtk_loc"_binary
235 # fi
236 # mkdir -p $vtk_binary_dir
237 # cd $vtk_binary_dir
238 # if [ "x$qmake_exe" == "x" ]; then
239 #     $cmake_exe \
240 #         -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
241 #         -DBUILD_DOCUMENTATION:BOOL=OFF \
242 #         -DBUILD_EXAMPLES:BOOL=OFF \
243 #         -DBUILD_SHARED_LIBS:BOOL=ON \
244 #         -DBUILD_TESTING:BOOL=OFF \
245 #         -DCMAKE_BUILD_TYPE:STRING=$vtk_build_type \
246 #         -DCMAKE_INSTALL_PREFIX:PATH=$install_prefix \
247 #         $vtk_source_dir
248 # else
249 #     $cmake_exe \
250 #         -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
251 #         -DBUILD_DOCUMENTATION:BOOL=OFF \
252 #         -DBUILD_EXAMPLES:BOOL=OFF \
253 #         -DBUILD_SHARED_LIBS:BOOL=ON \
254 #         -DBUILD_TESTING:BOOL=OFF \
255 #         -DQT_QMAKE_EXECUTABLE:PATH=$qmake_exe \
256 #         -DCMAKE_BUILD_TYPE:STRING=$vtk_build_type \
257 #         -DModule_vtkGUISupportQt:BOOL=ON \
258 #         -DModule_vtkGUISupportQtOpenGL:BOOL=ON \
259 #         -DModule_vtkGUISupportQtSQL:BOOL=OFF \
260 #         -DModule_vtkGUISupportQtWebkit:BOOL=OFF \
261 #         -DCMAKE_INSTALL_PREFIX:PATH=$install_prefix \
262 #         $vtk_source_dir
263 # fi
264 # make -j$number_of_threads -k
265 # make -j install
266 # cd $cur_dir
267
268 ## eof - $RCSfile$