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