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