]> Creatis software - creaToolsTools.git/blob - Linux/scripts/ThirdParty-install.sh
for MacOS
[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      port selfupdate
114      port install cmake                -y
115      port install doxygen              -y
116      port install graphviz             -y
117     # port install tetex                -y   (replaced by texlive) # cf EED : http://www.creatis.insa-lyon.fr/site/fr/CreatoolsInstallInstructionsv2.0.1MacOsv10.5.6-Developpers
118      port install texlive              -y
119      port install latex2html           -y
120      port install wxGTK                -y
121      port install boost                -y
122         ln -s libboost_signals-xgcc40-mt-1_38.dylib    libboost_signals.dylib    /opt/local/lib # cf EED : http://www.creatis.insa-lyon.fr/site
123         ln -s libboost_signals-xgcc40-mt-1_38.dylib    libboost_signals.dylib    /opt/local/lib # cf EED
124         ln -s libboost_filesystem-xgcc40-mt-1_38.dylib libboost_filesystem.dylib /opt/local/lib # cf EE
125         ln -s libboost_system-xgcc40-mt-1_38.dylib     libboost_system.dylib     /opt/local/lib # cf EE 
126      port install sqlite3              -y
127      port install qt4-mac              -y
128         ln -s qmake-mac qmake /opt/local/bin  # cf EED
129      port install mesa                 -y
130      ;;
131   *)
132      #echo " '$OperatingSystem' : Unknown (for us...) Operating Sytem "
133      echo " Allowed values are (right now) Fedora, Ubuntu, MacOS "
134      exit 0
135      ;;
136   esac             
137 fi
138
139
140
141 # the following stupid test is used at debug time; Please don't remove!
142 #if [ true = false ]
143 if [ true = true ]
144 then
145   echo "we remove old stuff"
146   rm -rf $sourcesDir/VTK*
147   rm -rf $sourcesDir/vtk*
148   rm -rf $sourcesDir/InsightToolkit*
149   rm -rf $sourcesDir/gdcm*
150   rm -rf $sourcesDir/tth*
151
152   rm -rf $binDir/gdcm*
153   rm -rf $binDir/InsightToolkit*
154   rm -rf $binDir/VTK*
155   cd $sourcesDir
156
157  if [ $OperatingSystem = "MacOS" ]
158  then     
159   curl -O http://www.creatis.insa-lyon.fr/software/public/creatools/crea_ThirdParty_Libraries/source/VTK-5.6.1.patchCreatis.tar.gz
160   curl -O http://www.creatis.insa-lyon.fr/software/public/creatools/crea_ThirdParty_Libraries/source/gdcm_05_Mai_2011.tar.gz
161   curl -O http://www.creatis.insa-lyon.fr/software/public/creatools/crea_ThirdParty_Libraries/source/InsightToolkit-3.20.0.tar.gz
162   curl -O http://www.creatis.insa-lyon.fr/software/public/creatools/crea_Developer_Tools/All_Versions/tth/tth_linux/tth
163
164   tar -xvf VTK-5.6.1.patchCreatis.tar.gz
165   tar -xvf gdcm_05_Mai_2011.tar.gz
166   tar -xvf InsightToolkit-3.20.0.tar.gz
167 else
168   wget http://www.creatis.insa-lyon.fr/software/public/creatools/crea_ThirdParty_Libraries/source/VTK-5.6.1.patchCreatis.tar.gz
169   wget http://www.creatis.insa-lyon.fr/software/public/creatools/crea_ThirdParty_Libraries/source/gdcm_05_Mai_2011.tar.gz
170   wget http://www.creatis.insa-lyon.fr/software/public/creatools/crea_ThirdParty_Libraries/source/InsightToolkit-3.20.0.tar.gz
171   wget http://www.creatis.insa-lyon.fr/software/public/creatools/crea_Developer_Tools/All_Versions/tth/tth_linux/tth
172   
173   tar -xvzf VTK-5.6.1.patchCreatis.tar.gz
174   tar -xvzf gdcm_05_Mai_2011.tar.gz
175   tar -xvzf InsightToolkit-3.20.0.tar.gz
176 fi
177
178 fi
179
180
181 if [ $buildType = "Debug" ]
182 then
183    debug="ON"
184 else
185    debug="OFF"
186 fi
187
188
189 # the following stupid test is used at debug time; Please don't remove!
190 #if [ true = false ]
191 if [ true = true ]
192 then
193   libname=VTK
194   dirInstall=$binDir/$libname-Bin
195   dirInstallVTK=$dirInstall
196   export VTK_DIR=$installPrefixThird/lib/vtk-5.6/
197   mkdir $dirInstall
198   cd $dirInstall
199  
200   cmake -G"Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
201   ##cmake -G"CodeBlocks - Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
202   cmake -D USE_DEBUG_LIB:BOOL=$buildType -D CMAKE_INSTALL_PREFIX:PATH=$installPrefixThird  CMakeCache.txt 
203   if [ $OperatingSystem = "MacOS" ]
204   then
205     cmake -D BUILD_SHARE_LIBS:BOOL=ON -D VTK_USE_CARBON:BOOL=ON -D  VTK_USE_COCOA:BOOL=OFF CMakeCache.txt 
206     cmake -D  VTK_USE_TCL:BOOL=OFF                                                         CMakeCache.txt  
207     cmake -D  CMAKE_CXX_COMPILER:FILE=/usr/bin/g++                                         CMakeCache.txt    
208   fi      
209   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
210   make -j $corenumber
211   make install
212   cd ..
213 fi
214
215
216 # the following stupid test is used at debug time; Please don't remove!
217 #if [ true = false ]
218 if [ true = true ]
219 then
220   libname=gdcm
221   dirInstall=$binDir/$libname-Bin
222   export GDCM_DIR=$installPrefixThird/lib/gdcm/
223   mkdir $dirInstall
224   cd $dirInstall
225   cmake -G"Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
226   ##cmake -G"CodeBlocks - Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
227   cmake -D USE_DEBUG_LIB:BOOL=$buildType -D CMAKE_INSTALL_PREFIX:PATH=$installPrefixThird CMakeCache.txt
228   cmake -D VTK_DIR:PATH=$dirInstallVTK CMakeCache.txt
229   cmake -D GDCM_VTK:BOOL=ON -D GDCM_NAME_SPACE:STRING=gdcm13 CMakeCache.txt
230   make -j 2
231   make install
232   cd ..
233 fi
234
235 # the following stupid test is used at debug time; Please don't remove!
236 #if [ true = false ]
237 if [ true = true ]
238 then
239   libname=InsightToolkit-3.20.0
240   dirInstall=$binDir/$libname-Bin
241   export ITK_DIR=$installPrefixThird/lib/InsightToolkit/
242   mkdir $dirInstall
243   cd $dirInstall
244   cmake -G"Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
245   ##cmake -G"CodeBlocks - Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
246   cmake -D USE_DEBUG_LIB:BOOL=$buildType -D CMAKE_INSTALL_PREFIX:PATH=$installPrefixThird CMakeCache.txt
247   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
248   #uncomment following line if you want to use the bleeding edge of GDCM2!
249   #cmake -D ITK_USE_SYSTEM_GDCM:BOOL=ON CMakeCache.txt
250   cmake CMakeCache.txt
251   make -j 2
252   make install
253   cd ..
254 fi
255
256 #if [ true = false ]
257 if [ true = true ]
258 then
259   cd $sourcesDir
260  # pourquoi ne copie-t-on plus? JPR
261  # cp tth $installPrefixThird/bin
262 fi
263
264
265 #deal with create creatools_third_party_libraries_config.sh
266
267 if [ -f $installPrefixThird/share/creatools_third_party_library_config.sh ]
268 then
269    rm $installPrefixThird/share/creatools_third_party_library_config.sh
270 fi
271
272 if [ ! -e $installPrefixThird/share ]
273 then
274    mkdir $installPrefixThird/share
275 fi
276 touch     $installPrefixThird/share/creatools_third_party_library_config.sh
277 chmod 755 $installPrefixThird/share/creatools_third_party_library_config.sh
278
279 echo export PATH='$'PATH:$installPrefixThird/bin           >> $installPrefixThird/share/creatools_third_party_library_config.sh
280 echo export VTK_DIR=$installPrefixThird/lib/vtk-5.6        >> $installPrefixThird/share/creatools_third_party_library_config.sh
281 echo export ITK_DIR=$installPrefixThird/lib/InsightToolkit >> $installPrefixThird/share/creatools_third_party_library_config.sh
282 echo export GDCM_DIR=$installPrefixThird/lib/gdcm          >> $installPrefixThird/share/creatools_third_party_library_config.sh
283 echo export TTH=$installPrefixThird/bin/tth                >> $installPrefixThird/share/creatools_third_party_library_config.sh
284 if [ $OperatingSystem = "MacOS" ]
285 then
286 echo export DYLD_LIBRARY_PATH='$'DYLD_LIBRARY_PATH:$GDCM_DIR   >> $installPrefixThird/share/creatools_third_party_library_config.sh
287 echo export DYLD_LIBRARY_PATH='$'DYLD_LIBRARY_PATH:$ITK_DIR    >> $installPrefixThird/share/creatools_third_party_library_config.sh
288 echo export DYLD_LIBRARY_PATH='$'DYLD_LIBRARY_PATH:$VTK_DIR    >> $installPrefixThird/share/creatools_third_party_library_config.sh
289 else
290 echo export LD_LIBRARY_PATH='$'LD_LIBRARY_PATH:$GDCM_DIR   >> $installPrefixThird/share/creatools_third_party_library_config.sh
291 echo export LD_LIBRARY_PATH='$'LD_LIBRARY_PATH:$ITK_DIR    >> $installPrefixThird/share/creatools_third_party_library_config.sh
292 echo export LD_LIBRARY_PATH='$'LD_LIBRARY_PATH:$VTK_DIR    >> $installPrefixThird/share/creatools_third_party_library_config.sh
293 fi
294
295 #  modify .bashrc
296 # - remove line 'bash $installPrefixThird/share/creatools_third_party_library_config.sh' if any (with accurate value for ???)
297
298 # Install creatools as user (no longer as root) // JPR 2/5/2011
299 #if [ ! -f /etc/bashrc ]
300 #then
301 #    export ETC_BASHRC="/etc/bash.bashrc"
302 #else
303 #    export ETC_BASHRC="/etc/bashrc"
304 #fi
305
306    case "$OperatingSystem" in
307    Fedora)
308      export ETC_BASHRC=$HOME/.bashrc
309      ;;
310    Ubuntu)
311      export ETC_BASHRC=$HOME/.bashrc
312      ;;
313    MacOS)      
314      export ETC_BASHRC=$HOME/.profile 
315      ;;
316    esac
317
318
319    sed -i -e '/.*installPrefixThird*/ d' $ETC_BASHRC
320    sed -i -e '/.*creatools_third_party_library_config.*/ d' $ETC_BASHRC
321
322
323 # - add line 'bash $installPrefixThird/share/creatools_third_party_library_config.sh' (with accurate value for ???)
324 echo installPrefixThird=$installPrefixThird >> $ETC_BASHRC
325 echo '[ -f "$installPrefixThird/share/creatools_third_party_library_config.sh" ] &&  source $installPrefixThird/share/creatools_third_party_library_config.sh' >> $ETC_BASHRC 
326
327 chown -R $loginUserName  $generationdir
328 chgrp -R $loginGroupName $generationdir