]> Creatis software - cpPlugins.git/blob - config/install_ivq.sh
...
[cpPlugins.git] / config / install_ivq.sh
1 #!/bin/bash
2
3 ## -- Configuration
4 boost_version="1.65.1"
5 qt5_version="5.9.2"
6 cmake_version="3.9.5"
7 vtk_version="8.0.1"
8 itk_version="4.12.2"
9
10 ## -- Abortion code
11 abort( )
12 {
13     echo >&2 '
14 ***************
15 *** ABORTED ***
16 ***************
17 '
18     echo "An error occurred. Exiting..." >&2
19     exit 1
20 }
21 trap 'abort' 0
22 trap 'abort' 2
23 set -e
24
25 ## -- Download function
26 download( )
27 {
28     file=$1
29     url=$2
30     sum=`dirname $file`/sum.txt
31     mkdir -p `dirname $file`
32     if [ ! -f $sum ] ; then
33         echo >&2 "*** Receiving $url ***"
34         curl -L -o $file $url
35         if [ -n "$sum_cmd" ] && [ -f $file ] ; then
36             $sum_cmd $file > $sum
37         fi
38     fi
39 }
40
41 ## -- Decompress function
42 decompress( )
43 {
44     file=$1
45     if [ -f $file ] ; then
46         echo >&2 "*** Decompressing $file ***"
47         mkdir -p `dirname $file`/src
48         mkdir -p `dirname $file`/bin
49         tar xf $file -C `dirname $file`/src --strip-components=1
50     fi
51 }
52
53 ## -- Check platform
54 platform=`uname`
55 qt5extras_id="x11"
56 if [[ "$platform" == 'Darwin' ]]; then
57     qt5extras_id="mac"
58 fi
59
60 ## -- Get best checksum command
61 sum_cmd=`command -v sha512sum`
62 if [ -z "$sum_cmd" ] ; then
63     sum_cmd=`command -v sha384sum`
64 fi
65 if [ -z "$sum_cmd" ] ; then
66     sum_cmd=`command -v sha256sum`
67 fi
68 if [ -z "$sum_cmd" ] ; then
69     sum_cmd=`command -v sha224sum`
70 fi
71 if [ -z "$sum_cmd" ] ; then
72     sum_cmd=`command -v sha1sum`
73 fi
74 if [ -z "$sum_cmd" ] ; then
75     sum_cmd=`command -v md5sum`
76 fi
77
78 ## -- Download information
79 boost_url="https://downloads.sourceforge.net/project/boost/boost/$boost_version/boost_`echo $boost_version | sed 's/\./\_/g'`.tar.bz2"
80 qt5_short_version=`echo $qt5_version | sed 's/\.[^.]*$//'`
81 qt5_url="https://download.qt.io/official_releases/qt/$qt5_short_version/$qt5_version/submodules/qtbase-opensource-src-$qt5_version.tar.xz"
82 qt5extras_url="https://download.qt.io/official_releases/qt/$qt5_short_version/$qt5_version/submodules/qt${qt5extras_id}extras-opensource-src-$qt5_version.tar.xz"
83 qt5tools_url="https://download.qt.io/official_releases/qt/$qt5_short_version/$qt5_version/submodules/qttools-opensource-src-$qt5_version.tar.xz"
84 cmake_short_version=`echo $cmake_version | sed 's/\.[^.]*$//'`
85 cmake_url="https://www.cmake.org/files/v$cmake_short_version/cmake-$cmake_version.tar.gz"
86 vtk_short_version=`echo $vtk_version | sed 's/\.[^.]*$//'`
87 vtk_url="https://www.vtk.org/files/release/$vtk_short_version/VTK-$vtk_version.tar.gz"
88 itk_short_version=`echo $itk_version | sed 's/\.[^.]*$//'`
89 itk_url="https://downloads.sourceforge.net/project/itk/itk/$itk_short_version/InsightToolkit-$itk_version.tar.xz"
90
91 ## -- Command line options
92 while [[ "$#" -gt 1 ]]; do
93     key="$1"
94     case $key in
95         -prefix)
96         prefix="$2"
97         shift
98         ;;
99         -build_dir)
100         build_dir="$2"
101         shift
102         ;;
103         -cores)
104         cores="$2"
105         shift
106         ;;
107         *)
108         # Do nothing
109         ;;
110     esac
111     shift
112 done
113
114 ## -- Check command line options
115 if \
116     [ -z "$prefix" ] ; then
117     (>&2 echo "Usage: $0 -prefix [dir] [-build_dir [dir]] [-cores [n]]")
118     exit 1
119 fi
120
121 ## -- Complete optional parameters
122 if [ -z "$cores" ] ; then
123     cores="1"
124 fi
125 if [ -z "$build_dir" ] ; then
126     build_dir="$HOME/.tmp"
127 fi
128 curr_dir=`pwd`
129
130 ## -- Download files
131 download $build_dir/boost/boost.tar.bz2 $boost_url
132 download $build_dir/qt5/qt5.tar.xz $qt5_url
133 download $build_dir/qt5extras/qt5extras.tar.xz $qt5extras_url
134 download $build_dir/qt5tools/qt5tools.tar.xz $qt5tools_url
135 download $build_dir/cmake/cmake.tar.gz $cmake_url
136 download $build_dir/vtk/vtk.tar.gz $vtk_url
137 download $build_dir/itk/itk.tar.xz $itk_url
138
139 ## -- Decompress files
140 decompress $build_dir/boost/boost.tar.bz2
141 decompress $build_dir/qt5/qt5.tar.xz
142 decompress $build_dir/qt5extras/qt5extras.tar.xz
143 decompress $build_dir/qt5tools/qt5tools.tar.xz
144 decompress $build_dir/cmake/cmake.tar.gz
145 decompress $build_dir/vtk/vtk.tar.gz
146 decompress $build_dir/itk/itk.tar.xz
147
148 ## -- Configure, build and install boost
149 cd $build_dir/boost/src
150 ./bootstrap.sh
151 ./b2 -a -q -j $cores \
152     link=shared \
153     cxxflags="-std=c++11" \
154     --prefix=$prefix \
155     install
156
157 ## -- Configure, build and install Qt5
158 cd $build_dir/qt5/bin
159 $build_dir/qt5/src/configure \
160     -prefix $prefix -shared -confirm-license -opensource -release \
161     -c++std c++11 -opengl desktop \
162     -nomake examples -nomake tests -no-harfbuzz \
163     -qt-xcb -qt-xkbcommon -qt-pcre
164 make -j$cores -k
165 make -j -k install
166
167 ## -- Configure, build and install Qt5Extras
168 cd $build_dir/qt5extras/bin
169 $prefix/bin/qmake $build_dir/qt5extras/src
170 make -j$cores -k
171 make -j -k install
172
173 ## -- Configure, build and install Qt5Tools
174 cd $build_dir/qt5tools/bin
175 $prefix/bin/qmake $build_dir/qt5tools/src
176 make -j$cores -k
177 make -j -k install
178
179 ## -- Configure, build and install CMake
180 cd $build_dir/cmake/bin
181 $build_dir/cmake/src/bootstrap --parallel=$cores --prefix=$prefix --no-qt-gui
182 make -j$cores -k
183 make -j -k install
184
185 ## -- Configure, build and install VTK
186 cd $build_dir/vtk/bin
187 $prefix/bin/cmake \
188     -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
189     -DVTK_USE_CXX11_FEATURES:BOOL=ON \
190     -DBUILD_SHARED_LIBS:BOOL=ON \
191     -DCMAKE_BUILD_TYPE:STRING=Release \
192     -DCMAKE_INSTALL_PREFIX:PATH=$prefix \
193     -DBUILD_DOCUMENTATION:BOOL=OFF \
194     -DBUILD_EXAMPLES:BOOL=OFF \
195     -DBUILD_TESTING:BOOL=OFF \
196     -DVTK_Group_Qt:BOOL=ON \
197     -DVTK_QT_VERSION:STRING=5 \
198     -DQt5_DIR:PATH=$prefix/lib/cmake/Qt5 \
199     -DVTK_Group_Qt:BOOL=ON \
200     -DCMAKE_MACOSX_RPATH:BOOL=ON \
201     $build_dir/vtk/src
202 make -j$cores -k
203 use_vtk=`make -j -k -s install | grep UseVTK | sed 's/.*: //'`
204
205 ## -- Configure, build and install VTK
206 cd $build_dir/itk/bin
207 $prefix/bin/cmake \
208     -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
209     -DBUILD_SHARED_LIBS:BOOL=ON \
210     -DCMAKE_BUILD_TYPE:STRING=Release \
211     -DCMAKE_INSTALL_PREFIX:PATH=$prefix \
212     -DBUILD_DOCUMENTATION:BOOL=OFF \
213     -DBUILD_EXAMPLES:BOOL=OFF \
214     -DBUILD_TESTING:BOOL=OFF \
215     -DVTK_DIR:PATH=`dirname $use_vtk` \
216     -DModule_ITKReview:BOOL=ON \
217     -DModule_ITKVtkGlue:BOOL=ON \
218     -DCMAKE_MACOSX_RPATH:BOOL=ON \
219     $build_dir/itk/src
220 make -j$cores -k
221 make -j -k install
222
223 ## -- End
224 cd $curr_dir
225
226 trap : 0
227 trap : 2
228 echo >&2 '
229 ************
230 *** DONE ***
231 ************
232 '
233
234 ## eof - $RCSfile$