18 echo "An error occurred. Exiting..." >&2
25 ## -- Download function
30 sum=`dirname $file`/sum.txt
31 mkdir -p `dirname $file`
32 if [ ! -f $sum ] ; then
33 echo >&2 "*** Receiving $url ***"
35 if [ -n "$sum_cmd" ] && [ -f $file ] ; then
41 ## -- Decompress function
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
56 if [[ "$platform" == 'Darwin' ]]; then
60 ## -- Get best checksum command
61 sum_cmd=`command -v sha512sum`
62 if [ -z "$sum_cmd" ] ; then
63 sum_cmd=`command -v sha384sum`
65 if [ -z "$sum_cmd" ] ; then
66 sum_cmd=`command -v sha256sum`
68 if [ -z "$sum_cmd" ] ; then
69 sum_cmd=`command -v sha224sum`
71 if [ -z "$sum_cmd" ] ; then
72 sum_cmd=`command -v sha1sum`
74 if [ -z "$sum_cmd" ] ; then
75 sum_cmd=`command -v md5sum`
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"
91 ## -- Command line options
92 while [[ "$#" -gt 1 ]]; do
114 ## -- Check command line options
116 [ -z "$prefix" ] ; then
117 (>&2 echo "Usage: $0 -prefix [dir] [-build_dir [dir]] [-cores [n]]")
121 ## -- Complete optional parameters
122 if [ -z "$cores" ] ; then
125 if [ -z "$build_dir" ] ; then
126 build_dir="$HOME/.tmp"
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
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
148 ## -- Configure, build and install boost
149 cd $build_dir/boost/src
151 ./b2 -a -q -j $cores \
153 cxxflags="-std=c++11" \
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
167 ## -- Configure, build and install Qt5Extras
168 cd $build_dir/qt5extras/bin
169 $prefix/bin/qmake $build_dir/qt5extras/src
173 ## -- Configure, build and install Qt5Tools
174 cd $build_dir/qt5tools/bin
175 $prefix/bin/qmake $build_dir/qt5tools/src
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
185 ## -- Configure, build and install VTK
186 cd $build_dir/vtk/bin
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 \
203 use_vtk=`make -j -k -s install | grep UseVTK | sed 's/.*: //'`
205 ## -- Configure, build and install VTK
206 cd $build_dir/itk/bin
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 \