3 ## ====================================
4 ## == Some base configuration values ==
5 ## ====================================
7 cmake_min_version="3.0"
9 number_of_cores=`grep -c ^processor /proc/cpuinfo`
10 number_of_threads=`expr $number_of_cores / 2`
12 ## =================================
13 ## == Compare two version strings ==
14 ## =================================
16 function version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; }
18 ## ==============================
19 ## == Try to locate base tools ==
20 ## ==============================
23 if [ -z "gpp_exe" ]; then
24 echo "ERROR: \"g++\" program was not found."
25 echo "ERROR: Please install \"g++\""
29 if [ -z "$make_exe" ]; then
30 echo "ERROR: \"make\" program was not found."
31 echo "ERROR: Please install \"make\""
38 read -p "Do you want to use Qt4.8? [y/N] " -n 1 -r
40 if [[ $REPLY =~ ^[Yy]$ ]]; then
42 qmake_exe=`which qmake`
43 while [ $cont == true ]; do
44 if [ -z "$qmake_exe" ]; then
45 read -e -p "Please provide a valid location for qmake: " tmp
47 qmake_exe=`readlink -f $tmp`
49 read -p "I am going to use \"$qmake_exe\" as the entry tool for Qt. Is this ok? [y/N] " -n 1 -r
51 if [[ $REPLY =~ ^[Nn]$ ]]; then
57 qt_version=`$qmake_exe -v | grep Using\ Qt\ version | sed 's/Using\ Qt\ version\ //g'`
58 if version_gt $qt_min_version $qt_version; then
59 echo "FATAL ERROR: your Qt version is $qt_version, but needed version should be at least $qt_min_version"
67 cmake_qt_options="--no-qt-gui"
68 if [ -x "$qmake_exe" ]; then
69 cmake_qt_options="--qt-gui --qt-qmake=$qmake_exe"
73 cmake_exe=`which cmake`
74 while [ $cont == true ]; do
75 if [ -z "$cmake_exe" ]; then
76 read -e -p "Please provide a valid location for cmake: " tmp
78 cmake_exe=`readlink -f $tmp`
80 read -p "I am going to use \"$cmake_exe\". Is this ok? [y/N] " -n 1 -r
82 if [[ $REPLY =~ ^[Nn]$ ]]; then
88 if [ -z $cmake_exe ]; then
89 echo "FATAL ERROR: cmake is really needed to build cpPlugins."
93 cmake_mime=`file -bzk --mime-type $cmake_exe`
94 if [ "$cmake_mime" != "application/x-executable" ]; then
95 echo "WARNING: I will try to compile cmake..."
96 if [[ -f $cmake_exe ]]; then
97 if [ "$cmake_mime" == "application/x-tar" ]; then
98 sub_mime=`file -b --mime-type $cmake_exe`
99 if [ $sub_mime == "application/gzip" ]; then
100 cmake_source_dir=`dirname $cmake_exe`/`basename $cmake_exe .tar.gz`
101 cmake_binary_dir=`dirname $cmake_exe`/`basename $cmake_exe .tar.gz`-build
102 echo -n "==> Extracting cmake sources... "
103 rm -rf $cmake_source_dir $cmake_binary_dir
104 mkdir -p $cmake_source_dir $cmake_binary_dir
105 tar xzf $cmake_exe -C $cmake_source_dir --strip-components=1
109 elif [[ -d $cmake_exe ]]; then
110 cmake_source_dir="$cmake_exe"
111 cmake_binary_dir="$cmake_exe"-build
113 echo "FATAL ERROR: $cmake_exe is not a valid file/directory"
117 read -e -p "==> Please provide instalation location for \"cmake\": " tmp
119 cmake_prefix=`readlink -f $tmp`
121 echo "==> Configuring sources... "
123 $cmake_source_dir/bootstrap --prefix=$cmake_prefix $cmake_qt_options
124 echo "==> Configuring sources... done."
126 echo "==> Compiling sources..."
128 make -j$number_of_threads
129 echo "==> Compiling sources... done."
131 echo "==> Installing package..."
134 echo "==> Installing package... done."
135 cmake_exe=$cmake_binary_dir/bin/cmake
137 cmake_version=`$cmake_exe --version | grep version | sed 's/cmake\ version\ //g'`
139 if version_gt $cmake_min_version $cmake_version; then
140 echo "FATAL ERROR: your cmake version is $cmake_version, but needed version should be at least $cmake_min_version"
148 vtk_sources=`which cmake`
149 while [ $cont == true ]; do
150 if [ -z "$vtk_sources" ]; then
151 read -e -p "Please provide a valid location for VTK: " tmp
153 vtk_sources=`readlink -f $tmp`
155 read -p "I am going to use \"$vtk_sources\". Is this ok? [y/N] " -n 1 -r
157 if [[ $REPLY =~ ^[Nn]$ ]]; then
163 if [ -z $vtk_sources ]; then
164 echo "FATAL ERROR: VTK is really needed to build cpPlugins."
168 echo "Now, I will try to compile VTK..."
169 vtk_mime=`file -bzk --mime-type $vtk_sources`
170 if [[ -f $vtk_sources ]]; then
171 if [ "$vtk_mime" == "application/x-tar" ]; then
172 sub_mime=`file -b --mime-type $vtk_sources`
173 if [ $sub_mime == "application/gzip" ]; then
174 vtk_source_dir=`dirname $vtk_sources`/`basename $vtk_sources .tar.gz`
175 vtk_binary_dir=`dirname $vtk_sources`/`basename $vtk_sources .tar.gz`-build
176 echo -n "==> Extracting VTK sources... "
177 rm -rf $vtk_source_dir $vtk_binary_dir
178 mkdir -p $vtk_source_dir $vtk_binary_dir
179 tar xzf $vtk_sources -C $vtk_source_dir --strip-components=1
183 elif [[ -d $vtk_sources ]]; then
184 vtk_source_dir="$vtk_sources"
185 vtk_binary_dir="$vtk_sources"-build
187 echo "FATAL ERROR: $vtk_sources is not a valid file/directory"
191 read -e -p "==> Please provide instalation location for \"VTK\": " tmp
193 vtk_prefix=`readlink -f $tmp`
195 vtk_build_type=MinSizeRel
197 echo "==> Configuring sources... "
199 if [ -x "$qmake_exe" ]; then
201 -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
202 -DBUILD_DOCUMENTATION:BOOL=OFF \
203 -DBUILD_EXAMPLES:BOOL=OFF \
204 -DBUILD_SHARED_LIBS:BOOL=ON \
205 -DBUILD_TESTING:BOOL=OFF \
206 -DQT_QMAKE_EXECUTABLE:PATH=$qmake_exe \
207 -DCMAKE_BUILD_TYPE:STRING=$vtk_build_type \
208 -DModule_vtkGUISupportQt:BOOL=ON \
209 -DModule_vtkGUISupportQtOpenGL:BOOL=ON \
210 -DModule_vtkGUISupportQtSQL:BOOL=OFF \
211 -DModule_vtkGUISupportQtWebkit:BOOL=OFF \
212 -DCMAKE_INSTALL_PREFIX:PATH=$vtk_prefix \
216 -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
217 -DBUILD_DOCUMENTATION:BOOL=OFF \
218 -DBUILD_EXAMPLES:BOOL=OFF \
219 -DBUILD_SHARED_LIBS:BOOL=ON \
220 -DBUILD_TESTING:BOOL=OFF \
221 -DCMAKE_BUILD_TYPE:STRING=$build_type \
222 -DCMAKE_INSTALL_PREFIX:PATH=$vtk_prefix \
225 echo "==> Configuring sources... done."
227 echo "==> Compiling sources..."
229 make -j$number_of_threads
230 echo "==> Compiling sources... done."
232 echo "==> Installing package..."
235 echo "==> Installing package... done."
242 itk_sources=`which cmake`
243 while [ $cont == true ]; do
244 if [ -z "$itk_sources" ]; then
245 read -e -p "Please provide a valid location for ITK: " tmp
247 itk_sources=`readlink -f $tmp`
249 read -p "I am going to use \"$itk_sources\". Is this ok? [y/N] " -n 1 -r
251 if [[ $REPLY =~ ^[Nn]$ ]]; then
257 if [ -z $itk_sources ]; then
258 echo "FATAL ERROR: ITK is really needed to build cpPlugins."
262 echo "Now, I will try to compile ITK..."
263 itk_mime=`file -bzk --mime-type $itk_sources`
264 if [[ -f $itk_sources ]]; then
265 if [ "$itk_mime" == "application/x-tar" ]; then
266 sub_mime=`file -b --mime-type $itk_sources`
267 if [ $sub_mime == "application/gzip" ]; then
268 itk_source_dir=`dirname $itk_sources`/`basename $itk_sources .tar.gz`
269 itk_binary_dir=`dirname $itk_sources`/`basename $itk_sources .tar.gz`-build
270 echo -n "==> Extracting ITK sources... "
271 rm -rf $itk_source_dir $itk_binary_dir
272 mkdir -p $itk_source_dir $itk_binary_dir
273 tar xzf $itk_sources -C $itk_source_dir --strip-components=1
277 elif [[ -d $itk_sources ]]; then
278 itk_source_dir="$itk_sources"
279 itk_binary_dir="$itk_sources"-build
281 echo "FATAL ERROR: $itk_sources is not a valid file/directory"
285 read -e -p "==> Please provide instalation location for \"ITK\": " tmp
287 itk_prefix=`readlink -f $tmp`
289 itk_build_type=MinSizeRel
291 echo "==> Configuring sources... "
293 if [ -x "$qmake_exe" ]; then
295 -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
296 -DBUILD_DOCUMENTATION:BOOL=OFF \
297 -DBUILD_EXAMPLES:BOOL=OFF \
298 -DBUILD_SHARED_LIBS:BOOL=ON \
299 -DBUILD_TESTING:BOOL=OFF \
300 -DQT_QMAKE_EXECUTABLE:PATH=$qmake_exe \
301 -DCMAKE_BUILD_TYPE:STRING=$itk_build_type \
302 -DModule_itkGUISupportQt:BOOL=ON \
303 -DModule_itkGUISupportQtOpenGL:BOOL=ON \
304 -DModule_itkGUISupportQtSQL:BOOL=OFF \
305 -DModule_itkGUISupportQtWebkit:BOOL=OFF \
306 -DCMAKE_INSTALL_PREFIX:PATH=$itk_prefix \
310 -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
311 -DBUILD_DOCUMENTATION:BOOL=OFF \
312 -DBUILD_EXAMPLES:BOOL=OFF \
313 -DBUILD_SHARED_LIBS:BOOL=ON \
314 -DBUILD_TESTING:BOOL=OFF \
315 -DCMAKE_BUILD_TYPE:STRING=$build_type \
316 -DCMAKE_INSTALL_PREFIX:PATH=$itk_prefix \
319 echo "==> Configuring sources... done."
321 echo "==> Compiling sources..."
323 make -j$number_of_threads
324 echo "==> Compiling sources... done."
326 echo "==> Installing package..."
329 echo "==> Installing package... done."