]> Creatis software - creaToolsTools.git/blob - Linux/scripts/ThirdParty-install.sh
curl vs wget
[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    chown $loginUserName:$loginGroupName $sourcesDir   
56 fi
57
58 if [ ! -e $binDir ]
59 then
60    mkdir $binDir
61    chown $loginUserName:$loginGroupName $binDir     
62 fi
63
64
65 # the following stupid test is used at debug time; Please don't remove!
66 if [ true = true ]
67 #if [ true = false ]
68 then
69
70   case "$OperatingSystem" in
71   Fedora)
72      yum install cmake -y 
73      yum install cmake-gui -y 
74      yum install doxygen -y
75      yum install graphviz -y
76      yum install texlive -y
77      yum install latex2html -y
78      yum install wxGTK-devel wxBase -y
79      yum install boost-devel -y
80      yum install sqlite-devel -y
81      yum install qt-devel -y
82      yum install mesa-libOSMesa-devel -y
83      ;;
84   Ubuntu)  
85      apt-get --yes install build-essential  # esta linea instala las librerias necesarias para compilar en ubuntu, g++ gcc etc etc etc.
86      apt-get --yes install cmake
87      apt-get --yes install cmake-gui
88      apt-get --yes install cmake-curses-gui
89      apt-get --yes install doxygen
90      apt-get --yes install graphviz
91      apt-get --yes install texlive
92      apt-get --yes install latex2html
93      apt-get --yes install libgtk2.0-dev #GTK
94      apt-get --yes install libwxgtk2.8-dev #Wx GTK
95      apt-get --yes install libwxbase2.8-dev #Wx solito
96      apt-get --yes install libboost-dev  #Boost
97      apt-get --yes install libboost-all-dev #Boost
98      apt-get --yes install libqt4-dev #QT4
99      apt-get --yes install sqlite
100      apt-get --yes install libsqlite0-dev
101      apt-get --yes install libosmesa6-dev #Mesa6
102      apt-get --yes install uuid-dev # uuid para la instalacion de itk
103      apt-get --yes install libxaw7-dev # X11
104      ;;
105   MacOS)
106 # QUESTION : is -y  mandatory?
107
108      port install cmake -y 
109      port install cmake-gui -y 
110      port install doxygen -y
111      port install graphviz -y
112      port install texlive -y
113      port install latex2html -y
114      port install wxGTK-devel wxBase -y
115      port install boost-devel -y
116      port install sqlite-devel -y
117      port install qt-devel -y
118      port install mesa-libOSMesa-devel -y
119      ;;
120   *)
121      #echo " '$OperatingSystem' : Unknown (for us...) Operating Sytem "
122      echo " Allowed values are (right now) Fedora, Ubuntu, MacOS "
123      exit 0
124      ;;
125   esac             
126 fi
127
128
129
130 # the following stupid test is used at debug time; Please don't remove!
131 #if [ true = false ]
132 if [ true = true ]
133 then
134   rm -rf $sourcesDir/VTK*
135   rm -rf $sourcesDir/vtk*
136   rm -rf $sourcesDir/InsightToolkit*
137   rm -rf $sourcesDir/gdcm*
138   rm -rf $sourcesDir/tth*
139
140   rm -rf $binDir/gdcm*
141   rm -rf $binDir/InsightToolkit*
142   rm -rf $binDir/VTK*
143   cd $sourcesDir
144   
145  if [ $OperatingSystem = "MacOS" ]
146  then     
147   curl http://www.creatis.insa-lyon.fr/software/public/creatools/crea_ThirdParty_Libraries/source/VTK-5.6.1.patchCreatis.tar.gz
148   curl http://www.creatis.insa-lyon.fr/software/public/creatools/crea_ThirdParty_Libraries/source/gdcm_05_Mai_2011.tar.gz
149   curl http://www.creatis.insa-lyon.fr/software/public/creatools/crea_ThirdParty_Libraries/source/InsightToolkit-3.20.0.tar.gz
150   curl http://www.creatis.insa-lyon.fr/software/public/creatools/crea_Developer_Tools/All_Versions/tth/tth_linux/tth
151 else
152   wget http://www.creatis.insa-lyon.fr/software/public/creatools/crea_ThirdParty_Libraries/source/VTK-5.6.1.patchCreatis.tar.gz
153   wget http://www.creatis.insa-lyon.fr/software/public/creatools/crea_ThirdParty_Libraries/source/gdcm_05_Mai_2011.tar.gz
154   wget http://www.creatis.insa-lyon.fr/software/public/creatools/crea_ThirdParty_Libraries/source/InsightToolkit-3.20.0.tar.gz
155   wget http://www.creatis.insa-lyon.fr/software/public/creatools/crea_Developer_Tools/All_Versions/tth/tth_linux/tth
156 fi  
157   
158   tar -xvzf VTK-5.6.1.patchCreatis.tar.gz
159   tar -xvzf gdcm_05_Mai_2011.tar.gz
160   tar -xvzf InsightToolkit-3.20.0.tar.gz
161 fi
162
163
164 if [ $buildType = "Debug" ]
165 then
166    debug="ON"
167 else
168    debug="OFF"
169 fi
170
171
172 # the following stupid test is used at debug time; Please don't remove!
173 #if [ true = false ]
174 if [ true = true ]
175 then
176   libname=VTK
177   dirInstall=$binDir/$libname-Bin
178   dirInstallVTK=$dirInstall
179   export VTK_DIR=$installPrefixThird/lib/vtk-5.6/
180   mkdir $dirInstall
181   cd $dirInstall
182  
183   cmake -G"Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
184   ##cmake -G"CodeBlocks - Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
185   cmake -D USE_DEBUG_LIB:BOOL=$buildType -D CMAKE_INSTALL_PREFIX:PATH=$installPrefixThird CMakeCache.txt
186   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
187   make -j $corenumber
188   make install
189   cd ..
190 fi
191
192
193 # the following stupid test is used at debug time; Please don't remove!
194 #if [ true = false ]
195 if [ true = true ]
196 then
197   libname=gdcm
198   dirInstall=$binDir/$libname-Bin
199   export GDCM_DIR=$installPrefixThird/lib/gdcm/
200   mkdir $dirInstall
201   cd $dirInstall
202   cmake -G"Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
203   ##cmake -G"CodeBlocks - Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
204   cmake -D USE_DEBUG_LIB:BOOL=$buildType -D CMAKE_INSTALL_PREFIX:PATH=$installPrefixThird CMakeCache.txt
205   cmake -D VTK_DIR:PATH=$dirInstallVTK CMakeCache.txt
206   cmake -D GDCM_VTK:BOOL=ON -D GDCM_NAME_SPACE:STRING=gdcm13 CMakeCache.txt
207   make -j 2
208   make install
209   cd ..
210 fi
211
212 # the following stupid test is used at debug time; Please don't remove!
213 #if [ true = false ]
214 if [ true = true ]
215 then
216   libname=InsightToolkit-3.20.0
217   dirInstall=$binDir/$libname-Bin
218   export ITK_DIR=$installPrefixThird/lib/InsightToolkit/
219   mkdir $dirInstall
220   cd $dirInstall
221   cmake -G"Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
222   ##cmake -G"CodeBlocks - Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
223   cmake -D USE_DEBUG_LIB:BOOL=$buildType -D CMAKE_INSTALL_PREFIX:PATH=$installPrefixThird CMakeCache.txt
224   cmake -D BUILD_EXAMPLES:BOOL=OFF -D BUILD_TESTING:BOOL=OFF -D BUILD_SHARED_LIBS:BOOL=ON -D ITK_USE_REVIEW:BOOL=ON -D ITK_USE_REVIEW_STATISTICS:BOOL=ON CMakeCache.txt
225   #uncomment following line if you want to use the bleeding edge of GDCM2!
226   #cmake -D ITK_USE_SYSTEM_GDCM:BOOL=ON CMakeCache.txt
227   cmake CMakeCache.txt
228   make -j 2
229   make install
230   cd ..
231 fi
232
233 #if [ true = false ]
234 if [ true = true ]
235 then
236   cd $sourcesDir
237   cp tth $installPrefixThird/bin
238 fi
239
240
241 #deal with create creatools_third_party_libraries_config.sh
242
243 if [ -f $installPrefixThird/share/creatools_third_party_library_config.sh ]
244 then
245    rm $installPrefixThird/share/creatools_third_party_library_config.sh
246 fi
247
248 if [ ! -e $installPrefixThird/share ]
249 then
250    mkdir $installPrefixThird/share
251 fi
252 touch     $installPrefixThird/share/creatools_third_party_library_config.sh
253 chmod 755 $installPrefixThird/share/creatools_third_party_library_config.sh
254
255 echo export PATH='$'PATH:$installPrefixThird/bin           >> $installPrefixThird/share/creatools_third_party_library_config.sh
256 echo export VTK_DIR=$installPrefixThird/lib/vtk-5.6        >> $installPrefixThird/share/creatools_third_party_library_config.sh
257 echo export ITK_DIR=$installPrefixThird/lib/InsightToolkit >> $installPrefixThird/share/creatools_third_party_library_config.sh
258 echo export GDCM_DIR=$installPrefixThird/lib/gdcm          >> $installPrefixThird/share/creatools_third_party_library_config.sh
259 echo export TTH=$installPrefixThird/bin/tth                >> $installPrefixThird/share/creatools_third_party_library_config.sh
260 if [ $OperatingSystem = "MacOS" ]
261 then
262 echo export DYLD_LIBRARY_PATH='$'DYLD_LIBRARY_PATH:$GDCM_DIR   >> $installPrefixThird/share/creatools_third_party_library_config.sh
263 echo export DYLD_LIBRARY_PATH='$'DYLD_LIBRARY_PATH:$ITK_DIR    >> $installPrefixThird/share/creatools_third_party_library_config.sh
264 echo export DYLD_LIBRARY_PATH='$'DYLD_LIBRARY_PATH:$VTK_DIR    >> $installPrefixThird/share/creatools_third_party_library_config.sh
265 else
266 echo export LD_LIBRARY_PATH='$'LD_LIBRARY_PATH:$GDCM_DIR   >> $installPrefixThird/share/creatools_third_party_library_config.sh
267 echo export LD_LIBRARY_PATH='$'LD_LIBRARY_PATH:$ITK_DIR    >> $installPrefixThird/share/creatools_third_party_library_config.sh
268 echo export LD_LIBRARY_PATH='$'LD_LIBRARY_PATH:$VTK_DIR    >> $installPrefixThird/share/creatools_third_party_library_config.sh
269 fi
270
271 #  modify .bashrc
272 # - remove line 'bash $installPrefixThird/share/creatools_third_party_library_config.sh' if any (with accurate value for ???)
273
274 # Install creatools as user (no longer as root) // JPR 2/5/2011
275 #if [ ! -f /etc/bashrc ]
276 #then
277 #    export ETC_BASHRC="/etc/bash.bashrc"
278 #else
279 #    export ETC_BASHRC="/etc/bashrc"
280 #fi
281
282    case "$OperatingSystem" in
283    Fedora)
284      export ETC_BASHRC=$HOME/.bashrc
285      ;;
286    Ubuntu)
287      export ETC_BASHRC=$HOME/.bashrc
288      ;;
289    MacOS)      
290      export ETC_BASHRC=$HOME/.profile 
291      ;;
292    esac
293
294
295    sed -i -e '/.*installPrefixThird*/ d' $ETC_BASHRC
296    sed -i -e '/.*creatools_third_party_library_config.*/ d' $ETC_BASHRC
297
298
299 # - add line 'bash $installPrefixThird/share/creatools_third_party_library_config.sh' (with accurate value for ???)
300 echo installPrefixThird=$installPrefixThird >> $ETC_BASHRC
301 echo '[ -f "$installPrefixThird/share/creatools_third_party_library_config.sh" ] &&  source $installPrefixThird/share/creatools_third_party_library_config.sh' >> $ETC_BASHRC 
302
303
304
305  chown -R $loginUserName:$loginGroupName $generationdir
306