]> Creatis software - creaToolsTools.git/blob - Linux/scripts/ThirdParty-install.sh
Don't install creaTools as root!
[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.patchCreatis.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.patchCreatis.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 # the following stupid test is used at debug time; Please don't remove!
160 #if [ true = false ]
161 if [ true = true ]
162 then
163   libname=VTK
164   dirInstall=$binDir/$libname-Bin
165   dirInstallVTK=$dirInstall
166   export VTK_DIR=$installPrefixThird/lib/vtk-5.6/
167   mkdir $dirInstall
168   cd $dirInstall
169  
170   cmake -G"Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
171   ##cmake -G"CodeBlocks - Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
172   cmake -D USE_DEBUG_LIB:BOOL=$buildType -D CMAKE_INSTALL_PREFIX:PATH=$installPrefixThird CMakeCache.txt
173   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
174   make -j 2
175   make install
176   cd ..
177 fi
178
179
180 # the following stupid test is used at debug time; Please don't remove!
181 #if [ true = false ]
182 if [ true = true ]
183 then
184   libname=gdcm
185   dirInstall=$binDir/$libname-Bin
186   export GDCM_DIR=$installPrefixThird/lib/gdcm/
187   mkdir $dirInstall
188   cd $dirInstall
189   cmake -G"Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
190   ##cmake -G"CodeBlocks - Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
191   cmake -D USE_DEBUG_LIB:BOOL=$buildType -D CMAKE_INSTALL_PREFIX:PATH=$installPrefixThird CMakeCache.txt
192   cmake -D VTK_DIR:PATH=$dirInstallVTK CMakeCache.txt
193   cmake -D GDCM_VTK:BOOL=ON -D GDCM_NAME_SPACE:STRING=gdcm13 CMakeCache.txt
194   make -j 2
195   make install
196   cd ..
197 fi
198
199 # the following stupid test is used at debug time; Please don't remove!
200 #if [ true = false ]
201 if [ true = true ]
202 then
203   libname=InsightToolkit-3.20.0
204   dirInstall=$binDir/$libname-Bin
205   export ITK_DIR=$installPrefixThird/lib/InsightToolkit/
206   mkdir $dirInstall
207   cd $dirInstall
208   cmake -G"Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
209   ##cmake -G"CodeBlocks - Unix Makefiles" -H$sourcesDir/$libname -B$dirInstall/
210   cmake -D USE_DEBUG_LIB:BOOL=$buildType -D CMAKE_INSTALL_PREFIX:PATH=$installPrefixThird CMakeCache.txt
211   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
212   cmake CMakeCache.txt
213   make -j 2
214   make install
215   cd ..
216 fi
217
218 #if [ true = false ]
219 if [ true = true ]
220 then
221   cd $sourcesDir
222   cp tth $installPrefixThird/bin
223 fi
224
225
226 #deal with create creatools_third_party_libraries_config.sh
227
228 if [ -f $installPrefixThird/share/creatools_third_party_library_config.sh ]
229 then
230    rm $installPrefixThird/share/creatools_third_party_library_config.sh
231 fi
232
233 if [ ! -e $installPrefixThird/share ]
234 then
235    mkdir $installPrefixThird/share
236 fi
237 touch     $installPrefixThird/share/creatools_third_party_library_config.sh
238 chmod 755 $installPrefixThird/share/creatools_third_party_library_config.sh
239
240 echo export PATH='$'PATH:$installPrefixThird/bin           >> $installPrefixThird/share/creatools_third_party_library_config.sh
241 echo export VTK_DIR=$installPrefixThird/lib/vtk-5.6        >> $installPrefixThird/share/creatools_third_party_library_config.sh
242 echo export ITK_DIR=$installPrefixThird/lib/InsightToolkit >> $installPrefixThird/share/creatools_third_party_library_config.sh
243 echo export GDCM_DIR=$installPrefixThird/lib/gdcm          >> $installPrefixThird/share/creatools_third_party_library_config.sh
244 echo export TTH=$installPrefixThird/bin/tth                >> $installPrefixThird/share/creatools_third_party_library_config.sh
245 echo export LD_LIBRARY_PATH='$'LD_LIBRARY_PATH:$GDCM_DIR   >> $installPrefixThird/share/creatools_third_party_library_config.sh
246 echo export LD_LIBRARY_PATH='$'LD_LIBRARY_PATH:$ITK_DIR    >> $installPrefixThird/share/creatools_third_party_library_config.sh
247 echo export LD_LIBRARY_PATH='$'LD_LIBRARY_PATH:$VTK_DIR    >> $installPrefixThird/share/creatools_third_party_library_config.sh
248
249 #  modify .bashrc
250 # - remove line 'bash $installPrefixThird/share/creatools_third_party_library_config.sh' if any (with accurate value for ???)
251
252 # Install creatools as user (no longer as root) // JPR 2/5/2011
253 #if [ ! -f /etc/bashrc ]
254 #then
255 #    export ETC_BASHRC="/etc/bash.bashrc"
256 #else
257 #    export ETC_BASHRC="/etc/bashrc"
258 #fi
259
260 export ETC_BASHRC=$HOME/.bashrc
261
262    sed -i -e '/.*installPrefixThird*/ d' $ETC_BASHRC
263    sed -i -e '/.*creatools_third_party_library_config.*/ d' $ETC_BASHRC
264
265
266 # - add line 'bash $installPrefixThird/share/creatools_third_party_library_config.sh' (with accurate value for ???)
267 echo installPrefixThird=$installPrefixThird >> $ETC_BASHRC
268 echo '[ -f "$installPrefixThird/share/creatools_third_party_library_config.sh" ] &&  source $installPrefixThird/share/creatools_third_party_library_config.sh' >> $ETC_BASHRC