]> Creatis software - creaToolsTools.git/blob - Linux/installscript
#2689 creaToolsTools Feature New Normal - Third party Linux WT configuration
[creaToolsTools.git] / Linux / installscript
1 # ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
4 #                        pour la Santé)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 #
7 #  This software is governed by the CeCILL-B license under French law and 
8 #  abiding by the rules of distribution of free software. You can  use, 
9 #  modify and/ or redistribute the software under the terms of the CeCILL-B 
10 #  license as circulated by CEA, CNRS and INRIA at the following URL 
11 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
12 #  or in the file LICENSE.txt.
13 #
14 #  As a counterpart to the access to the source code and  rights to copy,
15 #  modify and redistribute granted by the license, users are provided only
16 #  with a limited warranty  and the software's author,  the holder of the
17 #  economic rights,  and the successive licensors  have only  limited
18 #  liability. 
19 #
20 #  The fact that you are presently reading this means that you have had
21 #  knowledge of the CeCILL-B license and that you accept its terms.
22 # ------------------------------------------------------------------------  
23
24 #!/bin/bash -e
25
26 scriptDirName=$(dirname $(readlink -f $0) )
27
28 #########################################################################
29 ############     Local Functions  #######################################
30 #########################################################################
31
32
33 source scripts/LocalFunctions.sh
34
35 configureFile="scripts/CreaTools-configure.sh"
36
37
38 # default configuration parameters
39 OperatingSystem=`getDistrib`
40 corenumber=`getncore`
41 generationdir=$HOME/Creatis/creaTools
42 installPrefixThird=
43 installPrefix=
44 docgeneration=OFF
45 sourcesFrom=GIT
46
47 loginUserName=$USER
48 loginGroupName=`groups | awk '{print $1}'`
49 buildType=Release
50 gdcmVersion=GDCM1
51 ITKVersion=ITK3
52 export ETC_BASHRC=`getbashrc`
53
54
55 function usage {
56     echo "installscript [options] command" 
57     echo "creatools configure/compile/install script" 
58     echo "" 
59     echo "" 
60     echo "OPTIONS ARE USE FOR CONFIGURATION ONLY: THEY WILL BE IGNORED IF <COMMAND> IS NOT \"CONFIG\" OR \"ALL\"" 
61     echo "" 
62     echo "" 
63     echo "    command:" 
64     echo "" 
65     echo "    as a normal user:" 
66     echo "         config                    : set the configuration parameters only" 
67     echo "         "                 
68     echo "    need root password:" 
69     echo "         3rd                       : Get, Compile, Install all 3rd party library "
70     echo "         3rd-base                  : Install basic tools (cmake, doxygen...)"
71     echo "         3rd-vtk                   : Get, Compile, Install vtk"
72     echo "         3rd-itk                   : Get, Compile, Install itk"
73     echo "         3rd-gdcm                  : Get, Compile, Install gdcm"
74     echo "         3rd-wx                    : Get, Compile, Install wx widget (for Mac Users)"
75     echo "         3rd-wt                    : Get, Compile, Install wt"
76     echo "   "
77     echo "    as a normal user:" 
78     echo "         creatools                 : Get Compile and Install the CreaTools"
79     echo "         creatools-get             : Get the CreaTools"
80     echo "         creatools-cmp             : Compile the CreaTools"
81     echo "         creatools-install         : Install the CreaTools"
82     echo "   "
83     echo "         creatools-generateBinTGZ  : generation of CreaTools.tgz (binary version)" 
84     echo "   "
85     echo "         uninstall                 : uninstall the creatools"
86     echo "   "
87     echo "         printconfig               : print the configuration" 
88     echo "         help                      : print help"
89     echo "         env                       : print some environnement variables"
90     echo "" 
91     echo "         all                       : configure / compile / install" 
92     echo "         "                 
93     echo "   "
94     echo "   "
95     echo "   "
96     echo "   "
97     echo "    configure options: !!!!! IGNORED IF COMMAND IS NOT CONFIG OR ALL !!!!!!" 
98     echo "        -os <os>              : operating system distribution (default $OperatingSystem)"
99     echo "        -ncore <n>            : number of core to use (default $corenumber)"
100     echo "        -gdir <dir>           : generation directory (default $generationdir)"
101     echo "        -instprefix <dir>     : creatools install prefix" 
102     echo "        -instprefix3 <dir>    : 3rd party library install prefix" 
103     echo "        -html                 : get creatools from HTML"
104     echo "        -git                  : get creatools from git (CREATIS user only)"
105     echo "        -git-read-only        : get creatools from git (anonymously, no write access)"
106     echo "        -build                : build type Release, RelWithDebug or Debug (default RelWithDebug)"
107     echo ""
108     echo "     experimental configure options (use at your own risk!!):"
109     echo "        -gdcm2         : use GDCM2 "
110     echo "        -doc           : generate documentation"
111     echo "        -itk4          : use ITK4"
112     echo "" 
113     exit 1
114 }
115
116 ##################################################
117 # parse command line
118 while [ $# -ge 1 ] ; do
119     case $1 in
120         -os)                OperatingSystem=$2;                        shift 2;;
121         -ncore)             corenumber=$2;                             shift 2;;                     
122         -gdir)              generationdir=$2;                          shift 2;;                     
123         -instprefix)        installPrefix=$2;                          shift 2;;
124         -instprefix3)       installPrefixThird=$2;                     shift 2;;
125         -doc)               docgeneration=ON;                          shift 1;;
126         -html)              sourcesFrom=HTML;                          shift 1;;
127         -git)               sourcesFrom=GIT;                           shift 1;;
128         -git-read-only)     sourcesFrom=GIT-READ-ONLY;
129 shift 1;;
130         -gdcm2)             gdcmVersion=GDCM2;                         shift 1;;
131         -itk4)              ITKVersion=ITK4;                           shift 1;;
132         -build)             buildType=$2;                              shift 2;;
133         *) break;;
134     esac
135 done
136
137 if [ $# -le 0 ] ; then usage; fi
138
139 command=$1
140
141 # check that command is valid
142 if [ `checkVal $command all config 3rd 3rd-base 3rd-vtk 3rd-itk 3rd-gdcm 3rd-wx 3rd-wt creatools creatools-get creatools-cmp creatools-install creatools-generateBinTGZ uninstall printconfig help env` == "false" ] ; then
143     echo "Unrecognized command: $command"
144     echo ""
145     usage
146 fi
147
148
149 ############################## use existing configuration if command is not config or all
150 if [ `checkVal $command config all` == false ] ; then
151     if [ ! -f $configureFile ] ; then
152         echo "scripts/CreaTools-configure.sh does not exists"
153         echo "please run the scripts with command \"config\" or \"all\""
154         exit
155     fi
156     source $configureFile
157     if [ ! -f $installPrefixThird/share/creatools/creatools_third_party_library_config.sh ] ; then
158         echo WARNING
159         echo "the curently used Third Party libraries are NOT in $installPrefixThird but ... in :"
160         grep "installPrefixThird=" $ETC_BASHRC
161         echo "VTK_DIR  : " $VTK_DIR
162         echo "ITK_DIR  : " $ITK_DIR
163         echo "GDCM_DIR : " $GDCM_DIR
164         echo "(Have a look at $ETC_BASHRC=, edit it or run again Install Third Party Libraries if you disagree)"
165     
166 #        exit
167     fi
168     
169 fi
170
171 ##################################################################################
172 ############################ check configuration parameters
173 # check distrib
174 checkDistrib $OperatingSystem
175
176 # complete default install prefix
177 if [ -z "$installPrefix" ]      ; then installPrefix=$generationdir/creatools_install; fi
178 if [ -z "$installPrefixThird" ] ; then installPrefixThird=$generationdir/thirdparty_install; fi
179
180 # check build type
181 if [ `checkVal $buildType Release Debug RelWithDebug` == "false" ] ; then
182     echo "Unsupported build type: $buildType"
183     echo "Please use one of: Release Debug RelWithDebug"
184     exit 1
185 fi
186
187
188 ##################################################################################
189 ############################  write configuration file
190 if [ `checkVal $command config all` == true ] ; then
191     echo "#!/bin/bash"                            >  $configureFile
192     echo                                          >> $configureFile
193     echo "#File generated by 'installscript'"           >> $configureFile
194     echo "#DO NOT edit !"                         >> $configureFile
195     echo "#(except if you *do* know what you do)" >> $configureFile
196     echo                                          >> $configureFile
197     echo "OperatingSystem=$OperatingSystem"       >> $configureFile
198     echo "corenumber=$corenumber"                 >> $configureFile   
199     echo "generationdir=$generationdir"           >> $configureFile
200     echo "installPrefix=$installPrefix"           >> $configureFile
201     echo "installPrefixThird=$installPrefixThird" >> $configureFile
202     echo "docgeneration=$docgeneration"           >> $configureFile
203     echo "sourcesFrom=$sourcesFrom"               >> $configureFile
204     echo "loginUserName=$loginUserName"           >> $configureFile
205     echo "loginGroupName=$loginGroupName"         >> $configureFile
206     echo "buildType=$buildType"                   >> $configureFile
207     echo "gdcmVersion=$gdcmVersion"               >> $configureFile
208     echo "ITKVersion=$ITKVersion"                 >> $configureFile
209     echo "ETC_BASHRC=$ETC_BASHRC"                 >> $configureFile
210 fi
211
212
213
214 ################################### print current configuration
215 printconfig
216
217
218 ##################################################################################
219 ##################################################################################
220 ############   Process commands
221 ##################################################################################
222 ##################################################################################
223
224
225 ################################################################################## config printconfig
226 # config or printconfig : already done
227 if [ `checkVal $command config printconfig` == true ] ; then
228     exit
229 fi
230
231 ################################################################################## creatools
232 # download creatools
233 if [ `checkVal $command all creatools creatools-get` == true ] ; then
234     bigDisplay "DOWNLOAD CREATOOLS"
235     bash scripts/CreaTools-load.sh
236 fi
237
238 ################################################################################## 3rd library
239 # install packaged dependencies as root
240 if [ `checkVal $command all 3rd 3rd-base` == true ] ; then
241     bigDisplay "INSTALL PACKAGES DEPENDENCIES"
242     source scripts/CreaTools-configure.sh
243     cd scripts
244     source ThirdParty-install-Base-Stuff.sh $OperatingSystem
245     cd ..
246     bash scripts/ThirdParty-install.sh
247 fi
248
249 # vtk
250 if [ `checkVal $command all 3rd 3rd-vtk` == true ] ; then
251     bigDisplay "INSTALL VTK"
252     source scripts/ThirdParty-install-VTK.sh
253     cd $scriptDirName
254 fi
255
256 # gdcm
257 if [ `checkVal $command all 3rd 3rd-gdcm` == true ] ; then
258     bigDisplay "INSTALL $gdcmVersion"
259     source scripts/ThirdParty-install-gdcm.sh
260     cd $scriptDirName
261 fi
262
263 # wt
264 if [ `checkVal $command all 3rd 3rd-wt` == true ] ; then
265     bigDisplay "INSTALL WT"
266     source scripts/ThirdParty-install-WT.sh
267     cd $scriptDirName
268 fi
269
270 # itk
271 if [ `checkVal $command all 3rd 3rd-itk` == true ] ; then
272     bigDisplay "INSTALL $ITKVersion"
273     bash scripts/ThirdParty-install-ITK.sh
274     cd $scriptDirName
275 fi
276
277
278 # Setup the user .bashrc correctly
279 if [ `checkVal $command all 3rd 3rd-vtk 3rd-itk 3rd-gdcm 3rd-wx 3rd-wt ` == true ] ; then
280     bigDisplay "FINALIZE 3RD PARTY LIBRARY INSTALLATION"
281     bash scripts/ThirdParty-install-Finalize.sh
282     if [ `checkVal $command 3rd 3rd-vtk 3rd-itk 3rd-gdcm 3rd-wx ` == true ] ; then
283         bigDisplay "Third Party Install Done" 
284         bigDisplay "Please copy paste the following command or open a new terminal: source ~/.bashrc" 
285     fi
286 fi
287
288 ################################################################################## creatools
289 # compile creatools
290 if [ `checkVal $command all creatools creatools-cmp` == true ] ; then
291     bigDisplay "COMPILE CREATOOLS"
292 echo "EED installscript compile creatools"
293 echo $ETC_BASHRC
294     source $ETC_BASHRC
295     bash -x scripts/CreaTools-compile.sh
296
297     # To allow (*very* aware) user to patch code, later
298     if [ ! -e $generationdir/creatools_source ] ; then
299         echo "You probabely made a mistake : "
300         echo "Directory $loginUserName $generationdir/creatools_source not found"
301         echo "Make sure you know the mistake"
302         echo "Hit any key to continue"
303         echo "Fix the mistake!"
304         read a
305     else
306         chown -R $loginUserName  $generationdir/creatools_source
307         chgrp -R $loginGroupName $generationdir/creatools_source
308     fi
309 fi
310      
311 #install creatools
312 if [ `checkVal $command all creatools creatools-install` == true ] ; then
313     bigDisplay "INSTALL CREATOOLS"
314     source $ETC_BASHRC
315     bash scripts/CreaTools-install.sh
316     source $ETC_BASHRC
317     echo " "
318     echo " "
319     echo " "
320     echo " "
321     echo "Open a new terminal to run creatools."
322     echo "(Close this window and continue....) "
323     echo " "
324     echo " "
325     ##EED read -p "Press [Enter] key to continue..."
326 fi
327
328 #generate TGZ version of the bin (Creatools and ThirdParty)
329 if [ `checkVal $command creatools-generateBinTGZ` == true ] ; then
330     bash scripts/CreaTools-GenerateBinTGZ.sh
331 fi
332
333 ################################################################################## uninstall
334 if [ `checkVal $command uninstall` == true ] ; then
335     bigDisplay "UNINSTALL CREATOOLS"
336     bash scripts/CreaTools-uninstall.sh 
337 fi
338
339 ################################################################################## help
340 if [ `checkVal $command help` == true ] ; then
341     cat README.txt
342 fi
343
344 ################################################################################## print env variables
345 if [ `checkVal $command env` == true ] ; then
346     if [ ! -f $installPrefixThird/share/creatools_third_party_library_config.sh ] ; then
347         echo WARNING
348         echo
349         echo "the curently used Third Party libraries are NOT in $installPrefixThird but in :"
350         grep "installPrefixThird=" $ETC_BASHRC
351         echo "VTK_DIR  : " $VTK_DIR
352         echo "ITK_DIR  : " $ITK_DIR
353         echo "GDCM_DIR : " $GDCM_DIR
354         echo
355         echo "installPrefixThird ... " $installPrefixThird
356     fi
357              
358     if [ -f $installPrefixThird/share/creatools_third_party_library_config.sh ] ; then
359         echo  "Third party config file : " $installPrefixThird/share/creatools_third_party_library_config.sh
360         echo  ------
361         cat $installPrefixThird/share/creatools_third_party_library_config.sh
362         echo  ------
363     fi
364      
365     echo
366      
367     if [ -f $installPrefix/share/creatools_base_library_config.sh ] ; then
368        echo  "Creatools base library config file : " $installPrefix/share/creatools_base_library_config.sh
369        echo  ------ 
370        cat $installPrefix/share/creatools_base_library_config.sh
371        echo  ------ 
372        echo
373        echo "installPrefix ... " $installPrefix
374     fi
375
376     echo  ------
377     echo "VTK_DIR  :                 " $VTK_DIR
378     echo "ITK_DIR  :                 " $ITK_DIR
379     echo "GDCM_DIR :                 " $GDCM_DIR
380     echo
381     echo "crea_DIR :                 " $crea_DIR
382     echo "BBTK_DIR :                 " $BBTK_DIR
383     echo "creaMaracasVisu_DIR :      " $creaMaracasVisu_DIR
384     echo "creaEnvironment_DIR :      " $creaEnvironment_DIR
385     echo "creaBruker_DIR :           " $creaBruker_DIR
386     echo "creaImageIO_DIR :          " $creaImageIO_DIR
387     echo "creaContours_DIR :         " $creaContours_DIR
388     echo "creaRigidRegistration_DIR :" $creaRigidRegistration_DIR
389     echo "bbtkGEditor_DIR :          " $bbtkGEditor_DIR
390     echo "creaTools_DIR :            " $creaTools_DIR
391     echo "creaMiniTools_DIR :        " $creaMiniTools_DIR
392     echo "Ido_DIR :                  " $Ido_DIR
393     echo "==================================="
394     echo
395
396 fi
397
398
399