]> Creatis software - creaToolsTools.git/blob - Linux/scripts/ThirdParty-install.sh
Try to solve MacOS issues
[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   wget http://www.creatis.insa-lyon.fr/software/public/creatools/crea_ThirdParty_Libraries/source/VTK-5.6.1.patchCreatis.tar.gz
145   wget http://www.creatis.insa-lyon.fr/software/public/creatools/crea_ThirdParty_Libraries/source/gdcm_05_Mai_2011.tar.gz
146   wget http://www.creatis.insa-lyon.fr/software/public/creatools/crea_ThirdParty_Libraries/source/InsightToolkit-3.20.0.tar.gz
147   wget http://www.creatis.insa-lyon.fr/software/public/creatools/crea_Developer_Tools/All_Versions/tth/tth_linux/tth
148
149   tar -xvzf VTK-5.6.1.patchCreatis.tar.gz
150   tar -xvzf gdcm_05_Mai_2011.tar.gz
151   tar -xvzf InsightToolkit-3.20.0.tar.gz
152 fi
153
154
155 if [ $buildType = "Debug" ]
156 then
157    debug="ON"
158 else
159    debug="OFF"
160 fi
161
162
163 # the following stupid test is used at debug time; Please don't remove!
164 #if [ true = false ]
165 if [ true = true ]
166 then
167   libname=VTK
168   dirInstall=$binDir/$libname-Bin
169   dirInstallVTK=$dirInstall
170   export VTK_DIR=$installPrefixThird/lib/vtk-5.6/
171   mkdir $dirInstall
172   cd $dirInstall
173  
174   cmake -G"Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
175   ##cmake -G"CodeBlocks - Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
176   cmake -D USE_DEBUG_LIB:BOOL=$buildType -D CMAKE_INSTALL_PREFIX:PATH=$installPrefixThird CMakeCache.txt
177   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
178   make -j $corenumber
179   make install
180   cd ..
181 fi
182
183
184 # the following stupid test is used at debug time; Please don't remove!
185 #if [ true = false ]
186 if [ true = true ]
187 then
188   libname=gdcm
189   dirInstall=$binDir/$libname-Bin
190   export GDCM_DIR=$installPrefixThird/lib/gdcm/
191   mkdir $dirInstall
192   cd $dirInstall
193   cmake -G"Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
194   ##cmake -G"CodeBlocks - Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
195   cmake -D USE_DEBUG_LIB:BOOL=$buildType -D CMAKE_INSTALL_PREFIX:PATH=$installPrefixThird CMakeCache.txt
196   cmake -D VTK_DIR:PATH=$dirInstallVTK CMakeCache.txt
197   cmake -D GDCM_VTK:BOOL=ON -D GDCM_NAME_SPACE:STRING=gdcm13 CMakeCache.txt
198   make -j 2
199   make install
200   cd ..
201 fi
202
203 # the following stupid test is used at debug time; Please don't remove!
204 #if [ true = false ]
205 if [ true = true ]
206 then
207   libname=InsightToolkit-3.20.0
208   dirInstall=$binDir/$libname-Bin
209   export ITK_DIR=$installPrefixThird/lib/InsightToolkit/
210   mkdir $dirInstall
211   cd $dirInstall
212   cmake -G"Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
213   ##cmake -G"CodeBlocks - Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
214   cmake -D USE_DEBUG_LIB:BOOL=$buildType -D CMAKE_INSTALL_PREFIX:PATH=$installPrefixThird CMakeCache.txt
215   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
216   #uncomment following line if you want to use the bleeding edge of GDCM2!
217   #cmake -D ITK_USE_SYSTEM_GDCM:BOOL=ON CMakeCache.txt
218   cmake CMakeCache.txt
219   make -j 2
220   make install
221   cd ..
222 fi
223
224 #if [ true = false ]
225 if [ true = true ]
226 then
227   cd $sourcesDir
228   cp tth $installPrefixThird/bin
229 fi
230
231
232 #deal with create creatools_third_party_libraries_config.sh
233
234 if [ -f $installPrefixThird/share/creatools_third_party_library_config.sh ]
235 then
236    rm $installPrefixThird/share/creatools_third_party_library_config.sh
237 fi
238
239 if [ ! -e $installPrefixThird/share ]
240 then
241    mkdir $installPrefixThird/share
242 fi
243 touch     $installPrefixThird/share/creatools_third_party_library_config.sh
244 chmod 755 $installPrefixThird/share/creatools_third_party_library_config.sh
245
246 echo export PATH='$'PATH:$installPrefixThird/bin           >> $installPrefixThird/share/creatools_third_party_library_config.sh
247 echo export VTK_DIR=$installPrefixThird/lib/vtk-5.6        >> $installPrefixThird/share/creatools_third_party_library_config.sh
248 echo export ITK_DIR=$installPrefixThird/lib/InsightToolkit >> $installPrefixThird/share/creatools_third_party_library_config.sh
249 echo export GDCM_DIR=$installPrefixThird/lib/gdcm          >> $installPrefixThird/share/creatools_third_party_library_config.sh
250 echo export TTH=$installPrefixThird/bin/tth                >> $installPrefixThird/share/creatools_third_party_library_config.sh
251 if [ $OperatingSystem = "MacOS" ]
252 then
253 echo export DYLD_LIBRARY_PATH='$'DYLD_LIBRARY_PATH:$GDCM_DIR   >> $installPrefixThird/share/creatools_third_party_library_config.sh
254 echo export DYLD_LIBRARY_PATH='$'DYLD_LIBRARY_PATH:$ITK_DIR    >> $installPrefixThird/share/creatools_third_party_library_config.sh
255 echo export DYLD_LIBRARY_PATH='$'DYLD_LIBRARY_PATH:$VTK_DIR    >> $installPrefixThird/share/creatools_third_party_library_config.sh
256 else
257 echo export LD_LIBRARY_PATH='$'LD_LIBRARY_PATH:$GDCM_DIR   >> $installPrefixThird/share/creatools_third_party_library_config.sh
258 echo export LD_LIBRARY_PATH='$'LD_LIBRARY_PATH:$ITK_DIR    >> $installPrefixThird/share/creatools_third_party_library_config.sh
259 echo export LD_LIBRARY_PATH='$'LD_LIBRARY_PATH:$VTK_DIR    >> $installPrefixThird/share/creatools_third_party_library_config.sh
260 fi
261
262 #  modify .bashrc
263 # - remove line 'bash $installPrefixThird/share/creatools_third_party_library_config.sh' if any (with accurate value for ???)
264
265 # Install creatools as user (no longer as root) // JPR 2/5/2011
266 #if [ ! -f /etc/bashrc ]
267 #then
268 #    export ETC_BASHRC="/etc/bash.bashrc"
269 #else
270 #    export ETC_BASHRC="/etc/bashrc"
271 #fi
272
273    case "$OperatingSystem" in
274    Fedora)
275      export ETC_BASHRC=$HOME/.bashrc
276      ;;
277    Ubuntu)
278      export ETC_BASHRC=$HOME/.bashrc
279      ;;
280    MacOS)      
281      export ETC_BASHRC=$HOME/.profile 
282      ;;
283    esac
284
285
286    sed -i -e '/.*installPrefixThird*/ d' $ETC_BASHRC
287    sed -i -e '/.*creatools_third_party_library_config.*/ d' $ETC_BASHRC
288
289
290 # - add line 'bash $installPrefixThird/share/creatools_third_party_library_config.sh' (with accurate value for ???)
291 echo installPrefixThird=$installPrefixThird >> $ETC_BASHRC
292 echo '[ -f "$installPrefixThird/share/creatools_third_party_library_config.sh" ] &&  source $installPrefixThird/share/creatools_third_party_library_config.sh' >> $ETC_BASHRC 
293
294
295
296  chown -R $loginUserName:$loginGroupName $generationdir
297