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