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