]> Creatis software - creaToolsTools.git/blob - Linux/scripts/ThirdParty-install.sh
Allow user to specify number of cores
[creaToolsTools.git] / Linux / scripts / ThirdParty-install.sh
1 #!/bin/bash
2  if [ ! -f $PWD/scripts/CreaTools-configure.sh ]
3  then 
4    echo
5    echo "..ERROR.."
6    echo "==================================================="
7    echo "REMEMBER !"
8    echo ""
9    echo "YOU NEED TO RUN 'Configure' (0) First !"
10    echo "==================================================="
11    echo
12    echo
13    exit 0
14 fi 
15
16 source $PWD/scripts/CreaTools-configure.sh
17
18    echo "------"
19    echo $PWD/scripts/CreaTools-configure.sh
20    echo --generationdir--
21    echo $generationdir
22    echo --corenumber--
23    echo $corenumber   
24    echo --docgeneration--
25    echo $docgeneration
26    echo --installPrefix--
27    echo $installPrefix
28    echo --installPrefixThird--
29    echo $installPrefixThird
30    echo --buildType--
31    echo $buildType
32    echo --gdcmVersion--
33    echo $gdcmVersion
34 #   echo --sourcesFrom--
35 #   echo $sourcesFrom
36 #   echo --scriptDir--
37 #   echo $scriptDir
38 #   echo --start_point--
39 #   echo $start_point
40    echo "------"
41
42
43 scriptDir=$PWD
44 sourcesDir=$generationdir/thirdparty_sources
45 binDir=$generationdir/thirdparty_bin
46
47 if [ ! -e $generationdir ]
48 then
49    mkdir $generationdir
50    chown $loginUserName:$loginGroupName $generationdir
51 fi
52 if [ ! -e $sourcesDir ]
53 then
54    mkdir $sourcesDir
55 fi
56
57 if [ ! -e $binDir ]
58 then
59    mkdir $binDir
60 fi
61
62
63 # the following stupid test is used at debug time; Please don't remove!
64 if [ true = true ]
65 #if [ true = false ]
66 then
67
68   case "$OperatingSystem" in
69   Fedora)
70      yum install cmake -y 
71      yum install cmake-gui -y 
72      yum install doxygen -y
73      yum install graphviz -y
74      yum install texlive -y
75      yum install latex2html -y
76      yum install wxGTK-devel wxBase -y
77      yum install boost-devel -y
78      yum install sqlite-devel -y
79      yum install qt-devel -y
80      yum install mesa-libOSMesa-devel -y
81      ;;
82   Ubuntu)  
83      apt-get --yes install build-essential  # esta linea instala las librerias necesarias para compilar en ubuntu, g++ gcc etc etc etc.
84      apt-get --yes install cmake
85      apt-get --yes install cmake-gui
86      apt-get --yes install cmake-curses-gui
87      apt-get --yes install doxygen
88      apt-get --yes install graphviz
89      apt-get --yes install texlive
90      apt-get --yes install latex2html
91      apt-get --yes install libgtk2.0-dev #GTK
92      apt-get --yes install libwxgtk2.8-dev #Wx GTK
93      apt-get --yes install libwxbase2.8-dev #Wx solito
94      apt-get --yes install libboost-dev  #Boost
95      apt-get --yes install libboost-all-dev #Boost
96      apt-get --yes install libqt4-dev #QT4
97      apt-get --yes install sqlite
98      apt-get --yes install libsqlite0-dev
99      apt-get --yes install libosmesa6-dev #Mesa6
100      apt-get --yes install uuid-dev # uuid para la instalacion de itk
101      apt-get --yes install libxaw7-dev # X11
102      ;;
103   MacOS)
104 # QUESTION : is -y  mandatory?
105
106      port install cmake -y 
107      port install cmake-gui -y 
108      port install doxygen -y
109      port install graphviz -y
110      port install texlive -y
111      port install latex2html -y
112      port install wxGTK-devel wxBase -y
113      port install boost-devel -y
114      port install sqlite-devel -y
115      port install qt-devel -y
116      port install mesa-libOSMesa-devel -y
117      ;;
118   *)
119      #echo " '$OperatingSystem' : Unknown (for us...) Operating Sytem "
120      echo " Allowed values are (right now) Fedora, Ubuntu, MacOS "
121      exit 0
122      ;;
123   esac             
124 fi
125
126
127
128 # the following stupid test is used at debug time; Please don't remove!
129 #if [ true = false ]
130 if [ true = true ]
131 then
132   rm -rf $sourcesDir/VTK*
133   rm -rf $sourcesDir/vtk*
134   rm -rf $sourcesDir/InsightToolkit*
135   rm -rf $sourcesDir/gdcm*
136   rm -rf $sourcesDir/tth*
137
138   rm -rf $binDir/gdcm*
139   rm -rf $binDir/InsightToolkit*
140   rm -rf $binDir/VTK*
141   cd $sourcesDir
142   wget http://www.creatis.insa-lyon.fr/software/public/creatools/crea_ThirdParty_Libraries/source/VTK-5.6.1.patchCreatis.tar.gz
143   wget http://www.creatis.insa-lyon.fr/software/public/creatools/crea_ThirdParty_Libraries/source/gdcm_08_Dic_2009.tar.gz
144   wget http://www.creatis.insa-lyon.fr/software/public/creatools/crea_ThirdParty_Libraries/source/InsightToolkit-3.20.0.tar.gz
145   wget http://www.creatis.insa-lyon.fr/software/public/creatools/crea_Developer_Tools/All_Versions/tth/tth_linux/tth
146
147   tar -xvzf VTK-5.6.1.patchCreatis.tar.gz
148   tar -xvzf gdcm_08_Dic_2009.tar.gz
149   tar -xvzf InsightToolkit-3.20.0.tar.gz
150 fi
151
152
153 if [ $buildType = "Debug" ]
154 then
155    debug="ON"
156 else
157    debug="OFF"
158 fi
159
160
161 # the following stupid test is used at debug time; Please don't remove!
162 #if [ true = false ]
163 if [ true = true ]
164 then
165   libname=VTK
166   dirInstall=$binDir/$libname-Bin
167   dirInstallVTK=$dirInstall
168   export VTK_DIR=$installPrefixThird/lib/vtk-5.6/
169   mkdir $dirInstall
170   cd $dirInstall
171  
172   cmake -G"Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
173   ##cmake -G"CodeBlocks - Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
174   cmake -D USE_DEBUG_LIB:BOOL=$buildType -D CMAKE_INSTALL_PREFIX:PATH=$installPrefixThird CMakeCache.txt
175   cmake -D BUILD_EXAMPLES:BOOL=OFF -D BUILD_TESTING:BOOL=OFF -D BUILD_SHARED_LIBS:BOOL=ON -D VTK_USE_QT:BOOL=ON CMakeCache.txt
176   make -j $corenumber
177   make install
178   cd ..
179 fi
180
181
182 # the following stupid test is used at debug time; Please don't remove!
183 #if [ true = false ]
184 if [ true = true ]
185 then
186   libname=gdcm
187   dirInstall=$binDir/$libname-Bin
188   export GDCM_DIR=$installPrefixThird/lib/gdcm/
189   mkdir $dirInstall
190   cd $dirInstall
191   cmake -G"Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
192   ##cmake -G"CodeBlocks - Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
193   cmake -D USE_DEBUG_LIB:BOOL=$buildType -D CMAKE_INSTALL_PREFIX:PATH=$installPrefixThird CMakeCache.txt
194   cmake -D VTK_DIR:PATH=$dirInstallVTK CMakeCache.txt
195   cmake -D GDCM_VTK:BOOL=ON -D GDCM_NAME_SPACE:STRING=gdcm13 CMakeCache.txt
196   make -j 2
197   make install
198   cd ..
199 fi
200
201 # the following stupid test is used at debug time; Please don't remove!
202 #if [ true = false ]
203 if [ true = true ]
204 then
205   libname=InsightToolkit-3.20.0
206   dirInstall=$binDir/$libname-Bin
207   export ITK_DIR=$installPrefixThird/lib/InsightToolkit/
208   mkdir $dirInstall
209   cd $dirInstall
210   cmake -G"Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
211   ##cmake -G"CodeBlocks - Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
212   cmake -D USE_DEBUG_LIB:BOOL=$buildType -D CMAKE_INSTALL_PREFIX:PATH=$installPrefixThird CMakeCache.txt
213   cmake -D BUILD_EXAMPLES:BOOL=OFF -D BUILD_TESTING:BOOL=OFF -D BUILD_SHARED_LIBS:BOOL=ON -D ITK_USE_REVIEW:BOOL=ON CMakeCache.txt
214   #uncomment following line if you want to use the bleeding edge of GDCM2!
215   #cmake -D ITK_USE_SYSTEM_GDCM:BOOL=ON CMakeCache.txt
216   cmake CMakeCache.txt
217   make -j 2
218   make install
219   cd ..
220 fi
221
222 #if [ true = false ]
223 if [ true = true ]
224 then
225   cd $sourcesDir
226   cp tth $installPrefixThird/bin
227 fi
228
229
230 #deal with create creatools_third_party_libraries_config.sh
231
232 if [ -f $installPrefixThird/share/creatools_third_party_library_config.sh ]
233 then
234    rm $installPrefixThird/share/creatools_third_party_library_config.sh
235 fi
236
237 if [ ! -e $installPrefixThird/share ]
238 then
239    mkdir $installPrefixThird/share
240 fi
241 touch     $installPrefixThird/share/creatools_third_party_library_config.sh
242 chmod 755 $installPrefixThird/share/creatools_third_party_library_config.sh
243
244 echo export PATH='$'PATH:$installPrefixThird/bin           >> $installPrefixThird/share/creatools_third_party_library_config.sh
245 echo export VTK_DIR=$installPrefixThird/lib/vtk-5.6        >> $installPrefixThird/share/creatools_third_party_library_config.sh
246 echo export ITK_DIR=$installPrefixThird/lib/InsightToolkit >> $installPrefixThird/share/creatools_third_party_library_config.sh
247 echo export GDCM_DIR=$installPrefixThird/lib/gdcm          >> $installPrefixThird/share/creatools_third_party_library_config.sh
248 echo export TTH=$installPrefixThird/bin/tth                >> $installPrefixThird/share/creatools_third_party_library_config.sh
249 echo export LD_LIBRARY_PATH='$'LD_LIBRARY_PATH:$GDCM_DIR   >> $installPrefixThird/share/creatools_third_party_library_config.sh
250 echo export LD_LIBRARY_PATH='$'LD_LIBRARY_PATH:$ITK_DIR    >> $installPrefixThird/share/creatools_third_party_library_config.sh
251 echo export LD_LIBRARY_PATH='$'LD_LIBRARY_PATH:$VTK_DIR    >> $installPrefixThird/share/creatools_third_party_library_config.sh
252
253 #  modify .bashrc
254 # - remove line 'bash $installPrefixThird/share/creatools_third_party_library_config.sh' if any (with accurate value for ???)
255
256 # Install creatools as user (no longer as root) // JPR 2/5/2011
257 #if [ ! -f /etc/bashrc ]
258 #then
259 #    export ETC_BASHRC="/etc/bash.bashrc"
260 #else
261 #    export ETC_BASHRC="/etc/bashrc"
262 #fi
263
264 export ETC_BASHRC=$HOME/.bashrc
265
266    sed -i -e '/.*installPrefixThird*/ d' $ETC_BASHRC
267    sed -i -e '/.*creatools_third_party_library_config.*/ d' $ETC_BASHRC
268
269
270 # - add line 'bash $installPrefixThird/share/creatools_third_party_library_config.sh' (with accurate value for ???)
271 echo installPrefixThird=$installPrefixThird >> $ETC_BASHRC
272 echo '[ -f "$installPrefixThird/share/creatools_third_party_library_config.sh" ] &&  source $installPrefixThird/share/creatools_third_party_library_config.sh' >> $ETC_BASHRC