]> 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 [ -f $file ] ; then
36             touch $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 ## -- Download information
61 boost_url="https://downloads.sourceforge.net/project/boost/boost/$boost_version/boost_`echo $boost_version | sed 's/\./\_/g'`.tar.bz2"
62 qt5_short_version=`echo $qt5_version | sed 's/\.[^.]*$//'`
63 qt5_url="https://download.qt.io/official_releases/qt/$qt5_short_version/$qt5_version/submodules/qtbase-opensource-src-$qt5_version.tar.xz"
64 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"
65 qt5tools_url="https://download.qt.io/official_releases/qt/$qt5_short_version/$qt5_version/submodules/qttools-opensource-src-$qt5_version.tar.xz"
66 cmake_short_version=`echo $cmake_version | sed 's/\.[^.]*$//'`
67 cmake_url="https://www.cmake.org/files/v$cmake_short_version/cmake-$cmake_version.tar.gz"
68 vtk_short_version=`echo $vtk_version | sed 's/\.[^.]*$//'`
69 vtk_url="https://www.vtk.org/files/release/$vtk_short_version/VTK-$vtk_version.tar.gz"
70 itk_short_version=`echo $itk_version | sed 's/\.[^.]*$//'`
71 itk_url="https://downloads.sourceforge.net/project/itk/itk/$itk_short_version/InsightToolkit-$itk_version.tar.xz"
72
73 ## -- Command line options
74 while [[ "$#" -gt 1 ]] ; do
75     key="$1"
76     case $key in
77         -prefix)
78         prefix="$2"
79         shift
80         ;;
81         -build_dir)
82         build_dir="$2"
83         shift
84         ;;
85         -cores)
86         cores="$2"
87         shift
88         ;;
89         *)
90         # Do nothing
91         ;;
92     esac
93     shift
94 done
95
96 ## -- Check command line options
97 if \
98     [ -z "$prefix" ] ; then
99     (>&2 echo "Usage: $0 -prefix [dir] [-build_dir [dir]] [-cores [n]]")
100     exit 1
101 fi
102
103 ## -- Complete optional parameters
104 if [ -z "$cores" ] ; then
105     cores="1"
106 fi
107 if [ -z "$build_dir" ] ; then
108     build_dir="$HOME/.tmp"
109 fi
110 curr_dir=`pwd`
111
112 ## -- Download files
113 download $build_dir/boost/boost.tar.bz2 $boost_url
114 download $build_dir/qt5/qt5.tar.xz $qt5_url
115 download $build_dir/qt5extras/qt5extras.tar.xz $qt5extras_url
116 download $build_dir/qt5tools/qt5tools.tar.xz $qt5tools_url
117 download $build_dir/cmake/cmake.tar.gz $cmake_url
118 download $build_dir/vtk/vtk.tar.gz $vtk_url
119 download $build_dir/itk/itk.tar.xz $itk_url
120
121 ## -- Decompress files
122 decompress $build_dir/boost/boost.tar.bz2
123 decompress $build_dir/qt5/qt5.tar.xz
124 decompress $build_dir/qt5extras/qt5extras.tar.xz
125 decompress $build_dir/qt5tools/qt5tools.tar.xz
126 decompress $build_dir/cmake/cmake.tar.gz
127 decompress $build_dir/vtk/vtk.tar.gz
128 decompress $build_dir/itk/itk.tar.xz
129
130 ## -- Configure, build and install boost
131 cd $build_dir/boost/src
132 ./bootstrap.sh
133 ./b2 -a -q -j $cores \
134     link=shared \
135     cxxflags="-std=c++11" \
136     --prefix=$prefix \
137     install
138
139 ## -- Configure, build and install Qt5
140 cd $build_dir/qt5/bin
141 $build_dir/qt5/src/configure \
142     -prefix $prefix -shared -confirm-license -opensource -release \
143     -c++std c++11 -opengl desktop \
144     -nomake examples -nomake tests -no-harfbuzz \
145     -qt-xcb -qt-xkbcommon -qt-pcre
146 make -j$cores -k
147 make -j -k install
148
149 ## -- Configure, build and install Qt5Extras
150 cd $build_dir/qt5extras/bin
151 $prefix/bin/qmake $build_dir/qt5extras/src
152 make -j$cores -k
153 make -j -k install
154
155 ## -- Configure, build and install Qt5Tools
156 cd $build_dir/qt5tools/bin
157 $prefix/bin/qmake $build_dir/qt5tools/src
158 make -j$cores -k
159 make -j -k install
160
161 ## -- Configure, build and install CMake
162 cd $build_dir/cmake/bin
163 $build_dir/cmake/src/bootstrap --parallel=$cores --prefix=$prefix --no-qt-gui
164 make -j$cores -k
165 make -j -k install
166
167 ## -- Configure, build and install VTK
168 cd $build_dir/vtk/bin
169 $prefix/bin/cmake \
170     -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
171     -DVTK_USE_CXX11_FEATURES:BOOL=ON \
172     -DBUILD_SHARED_LIBS:BOOL=ON \
173     -DCMAKE_BUILD_TYPE:STRING=Release \
174     -DCMAKE_INSTALL_PREFIX:PATH=$prefix \
175     -DBUILD_DOCUMENTATION:BOOL=OFF \
176     -DBUILD_EXAMPLES:BOOL=OFF \
177     -DBUILD_TESTING:BOOL=OFF \
178     -DVTK_Group_Qt:BOOL=ON \
179     -DVTK_QT_VERSION:STRING=5 \
180     -DQt5_DIR:PATH=$prefix/lib/cmake/Qt5 \
181     -DVTK_Group_Qt:BOOL=ON \
182     -DCMAKE_MACOSX_RPATH:BOOL=ON \
183     $build_dir/vtk/src
184 make -j$cores -k
185 use_vtk=`make -j -k -s install | grep UseVTK | sed 's/.*: //'`
186
187 ## -- Configure, build and install VTK
188 cd $build_dir/itk/bin
189 $prefix/bin/cmake \
190     -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
191     -DBUILD_SHARED_LIBS:BOOL=ON \
192     -DCMAKE_BUILD_TYPE:STRING=Release \
193     -DCMAKE_INSTALL_PREFIX:PATH=$prefix \
194     -DBUILD_DOCUMENTATION:BOOL=OFF \
195     -DBUILD_EXAMPLES:BOOL=OFF \
196     -DBUILD_TESTING:BOOL=OFF \
197     -DVTK_DIR:PATH=`dirname $use_vtk` \
198     -DModule_ITKReview:BOOL=ON \
199     -DModule_ITKVtkGlue:BOOL=ON \
200     -DCMAKE_MACOSX_RPATH:BOOL=ON \
201     $build_dir/itk/src
202 make -j$cores -k
203 make -j -k install
204
205 ## -- End
206 cd $curr_dir
207
208 trap : 0
209 trap : 2
210 echo >&2 '
211 ************
212 *** DONE ***
213 ************
214 '
215
216 ## eof - $RCSfile$