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